Comparing version 3.33.0 to 3.34.0
@@ -0,1 +1,6 @@ | ||
## 3.34.0 2024-01-18 | ||
* Internal plugin description now includes Gubu shape for plugin options. | ||
## 3.33.0 2023-11-05 | ||
@@ -2,0 +7,0 @@ |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
declare function wrap(this: any, pin: any, actdef: any, wrapper: any): any; | ||
@@ -2,0 +3,0 @@ declare function fix(this: any, patargs: any, msgargs: any, custom: any): any; |
@@ -302,3 +302,3 @@ "use strict"; | ||
quiet: false, | ||
reload$: true, | ||
reload$: true, // TODO: obsolete? | ||
log: logspec || 'test', | ||
@@ -305,0 +305,0 @@ debug: { callpoint: true }, |
@@ -379,151 +379,2 @@ /* Copyright © 2020 Richard Rodger and other contributors, MIT License. */ | ||
}, | ||
/* | ||
pre_options: (spec: TaskSpec) => { | ||
try { | ||
let plugin: any = spec.data.plugin | ||
// let delegate: any = spec.data.delegate | ||
let seneca = spec.ctx.seneca | ||
// let so = delegate.options() | ||
let so = seneca.options() | ||
let fullname = plugin.fullname | ||
let defaults = plugin.defaults | ||
let fullname_options = Object.assign( | ||
{}, | ||
// DEPRECATED: remove in 4 | ||
so.legacy.top_plugins ? so[fullname] : {}, | ||
so.plugin[fullname], | ||
// DEPRECATED: remove in 4 | ||
so.legacy.top_plugins ? so[fullname + '$' + plugin.tag] : {}, | ||
so.plugin[fullname + '$' + plugin.tag] | ||
) | ||
let shortname = fullname !== plugin.name ? plugin.name : null | ||
if (!shortname && fullname.indexOf('seneca-') === 0) { | ||
shortname = fullname.substring('seneca-'.length) | ||
} | ||
let shortname_options = Object.assign( | ||
{}, | ||
// DEPRECATED: remove in 4 | ||
so.legacy.top_plugins ? so[fullname] : {}, | ||
so.plugin[shortname], | ||
// DEPRECATED: remove in 4 | ||
so.legacy.top_plugins ? so[shortname + '$' + plugin.tag] : {}, | ||
so.plugin[shortname + '$' + plugin.tag] | ||
) | ||
let base: any = {} | ||
// NOTE: plugin error codes are in their own namespaces | ||
// TODO: test this!!! | ||
let errors = plugin.errors || (plugin.define && plugin.define.errors) | ||
if (errors) { | ||
base.errors = errors | ||
} | ||
// TODO: these should deep merge | ||
let fullopts = Object.assign( | ||
base, | ||
shortname_options, | ||
fullname_options, | ||
plugin.options || {} | ||
) | ||
let resolved_options: any = {} | ||
// let valid = delegate.valid // Gubu validator: https://github.com/rjrodger/gubu | ||
let valid = seneca.valid // Gubu validator: https://github.com/rjrodger/gubu | ||
let err: Error | undefined = void 0 | ||
let joi_schema: any = null | ||
// let Joi = delegate.util.Joi | ||
let Joi = seneca.util.Joi | ||
let defaults_values = | ||
('function' === typeof (defaults) && !defaults.gubu) ? | ||
defaults({ valid, Joi }) : defaults | ||
if (null == defaults_values || | ||
0 === Object.keys(defaults_values).length || | ||
!so.valid.active || | ||
!so.valid.plugin | ||
) { | ||
resolved_options = fullopts | ||
} | ||
else { | ||
if (!so.legacy.options && !Joi.isSchema(defaults_values, { legacy: true })) { | ||
// TODO: use Gubu.isShape | ||
let isShape = defaults_values.gubu && defaults_values.gubu.gubu$ | ||
// TODO: when Gubu supports merge, also merge if isShape | ||
if (!isShape && null == defaults_values.errors && null != errors) { | ||
defaults_values.errors = {} | ||
} | ||
let optionShape = | ||
// isShape ? defaults_values : delegate.valid(defaults_values) | ||
isShape ? defaults_values : seneca.valid(defaults_values) | ||
let shapeErrors: any[] = [] | ||
resolved_options = optionShape(fullopts, { err: shapeErrors }) | ||
if (0 < shapeErrors.length) { | ||
//err = delegate.error('invalid_plugin_option', { | ||
err = seneca.error('invalid_plugin_option', { | ||
name: fullname, | ||
err_msg: shapeErrors.map((se: any) => se.t).join('; '), | ||
options: fullopts, | ||
}) | ||
} | ||
} | ||
else { | ||
let joi_schema: any = intern.prepare_spec( | ||
Joi, | ||
defaults_values, | ||
{ allow_unknown: true }, | ||
{} | ||
) | ||
let joi_out = joi_schema.validate(fullopts) | ||
if (joi_out.error) { | ||
// err = delegate.error('invalid_plugin_option', { | ||
err = seneca.error('invalid_plugin_option', { | ||
name: fullname, | ||
err_msg: joi_out.error.message, | ||
options: fullopts, | ||
}) | ||
} | ||
else { | ||
resolved_options = joi_out.value | ||
} | ||
} | ||
} | ||
return { | ||
op: 'seneca_options', | ||
err: err, | ||
out: { | ||
plugin: { | ||
options: resolved_options, | ||
options_schema: joi_schema | ||
} | ||
} | ||
} | ||
} catch (e: any) { | ||
console.log('PREOPTS', e) | ||
} | ||
}, | ||
*/ | ||
options: (spec) => { | ||
@@ -564,2 +415,3 @@ let plugin = spec.data.plugin; | ||
let Joi = delegate.util.Joi; | ||
let optionsShape = null; | ||
let defaults_values = ('function' === typeof (defaults) && !defaults.gubu) ? | ||
@@ -581,5 +433,8 @@ defaults({ valid, Joi }) : defaults; | ||
} | ||
let optionShape = isShape ? defaults_values : delegate.valid(defaults_values); | ||
defaults_values.init$ = | ||
null == defaults_values.init$ ? true : defaults_values.init$; | ||
optionsShape = | ||
isShape ? defaults_values : delegate.valid(defaults_values); | ||
let shapeErrors = []; | ||
resolved_options = optionShape(fullopts, { err: shapeErrors }); | ||
resolved_options = optionsShape(fullopts, { err: shapeErrors }); | ||
if (0 < shapeErrors.length) { | ||
@@ -614,3 +469,4 @@ err = delegate.error('invalid_plugin_option', { | ||
options: resolved_options, | ||
options_schema: joi_schema | ||
options_schema: joi_schema, | ||
options_shape: optionsShape, | ||
} | ||
@@ -617,0 +473,0 @@ } |
@@ -509,152 +509,2 @@ /* Copyright © 2020 Richard Rodger and other contributors, MIT License. */ | ||
/* | ||
pre_options: (spec: TaskSpec) => { | ||
try { | ||
let plugin: any = spec.data.plugin | ||
// let delegate: any = spec.data.delegate | ||
let seneca = spec.ctx.seneca | ||
// let so = delegate.options() | ||
let so = seneca.options() | ||
let fullname = plugin.fullname | ||
let defaults = plugin.defaults | ||
let fullname_options = Object.assign( | ||
{}, | ||
// DEPRECATED: remove in 4 | ||
so.legacy.top_plugins ? so[fullname] : {}, | ||
so.plugin[fullname], | ||
// DEPRECATED: remove in 4 | ||
so.legacy.top_plugins ? so[fullname + '$' + plugin.tag] : {}, | ||
so.plugin[fullname + '$' + plugin.tag] | ||
) | ||
let shortname = fullname !== plugin.name ? plugin.name : null | ||
if (!shortname && fullname.indexOf('seneca-') === 0) { | ||
shortname = fullname.substring('seneca-'.length) | ||
} | ||
let shortname_options = Object.assign( | ||
{}, | ||
// DEPRECATED: remove in 4 | ||
so.legacy.top_plugins ? so[fullname] : {}, | ||
so.plugin[shortname], | ||
// DEPRECATED: remove in 4 | ||
so.legacy.top_plugins ? so[shortname + '$' + plugin.tag] : {}, | ||
so.plugin[shortname + '$' + plugin.tag] | ||
) | ||
let base: any = {} | ||
// NOTE: plugin error codes are in their own namespaces | ||
// TODO: test this!!! | ||
let errors = plugin.errors || (plugin.define && plugin.define.errors) | ||
if (errors) { | ||
base.errors = errors | ||
} | ||
// TODO: these should deep merge | ||
let fullopts = Object.assign( | ||
base, | ||
shortname_options, | ||
fullname_options, | ||
plugin.options || {} | ||
) | ||
let resolved_options: any = {} | ||
// let valid = delegate.valid // Gubu validator: https://github.com/rjrodger/gubu | ||
let valid = seneca.valid // Gubu validator: https://github.com/rjrodger/gubu | ||
let err: Error | undefined = void 0 | ||
let joi_schema: any = null | ||
// let Joi = delegate.util.Joi | ||
let Joi = seneca.util.Joi | ||
let defaults_values = | ||
('function' === typeof (defaults) && !defaults.gubu) ? | ||
defaults({ valid, Joi }) : defaults | ||
if (null == defaults_values || | ||
0 === Object.keys(defaults_values).length || | ||
!so.valid.active || | ||
!so.valid.plugin | ||
) { | ||
resolved_options = fullopts | ||
} | ||
else { | ||
if (!so.legacy.options && !Joi.isSchema(defaults_values, { legacy: true })) { | ||
// TODO: use Gubu.isShape | ||
let isShape = defaults_values.gubu && defaults_values.gubu.gubu$ | ||
// TODO: when Gubu supports merge, also merge if isShape | ||
if (!isShape && null == defaults_values.errors && null != errors) { | ||
defaults_values.errors = {} | ||
} | ||
let optionShape = | ||
// isShape ? defaults_values : delegate.valid(defaults_values) | ||
isShape ? defaults_values : seneca.valid(defaults_values) | ||
let shapeErrors: any[] = [] | ||
resolved_options = optionShape(fullopts, { err: shapeErrors }) | ||
if (0 < shapeErrors.length) { | ||
//err = delegate.error('invalid_plugin_option', { | ||
err = seneca.error('invalid_plugin_option', { | ||
name: fullname, | ||
err_msg: shapeErrors.map((se: any) => se.t).join('; '), | ||
options: fullopts, | ||
}) | ||
} | ||
} | ||
else { | ||
let joi_schema: any = intern.prepare_spec( | ||
Joi, | ||
defaults_values, | ||
{ allow_unknown: true }, | ||
{} | ||
) | ||
let joi_out = joi_schema.validate(fullopts) | ||
if (joi_out.error) { | ||
// err = delegate.error('invalid_plugin_option', { | ||
err = seneca.error('invalid_plugin_option', { | ||
name: fullname, | ||
err_msg: joi_out.error.message, | ||
options: fullopts, | ||
}) | ||
} | ||
else { | ||
resolved_options = joi_out.value | ||
} | ||
} | ||
} | ||
return { | ||
op: 'seneca_options', | ||
err: err, | ||
out: { | ||
plugin: { | ||
options: resolved_options, | ||
options_schema: joi_schema | ||
} | ||
} | ||
} | ||
} catch (e: any) { | ||
console.log('PREOPTS', e) | ||
} | ||
}, | ||
*/ | ||
options: (spec: TaskSpec) => { | ||
@@ -729,2 +579,4 @@ let plugin: any = spec.data.plugin | ||
let optionsShape = null | ||
let defaults_values = | ||
@@ -751,6 +603,10 @@ ('function' === typeof (defaults) && !defaults.gubu) ? | ||
let optionShape = | ||
defaults_values.init$ = | ||
null == defaults_values.init$ ? true : defaults_values.init$ | ||
optionsShape = | ||
isShape ? defaults_values : delegate.valid(defaults_values) | ||
let shapeErrors: any[] = [] | ||
resolved_options = optionShape(fullopts, { err: shapeErrors }) | ||
resolved_options = optionsShape(fullopts, { err: shapeErrors }) | ||
@@ -794,3 +650,4 @@ if (0 < shapeErrors.length) { | ||
options: resolved_options, | ||
options_schema: joi_schema | ||
options_schema: joi_schema, | ||
options_shape: optionsShape, | ||
} | ||
@@ -797,0 +654,0 @@ } |
{ | ||
"name": "seneca", | ||
"description": "A Microservices Framework for Node.js", | ||
"version": "3.33.0", | ||
"version": "3.34.0", | ||
"license": "MIT", | ||
@@ -90,6 +90,6 @@ "homepage": "http://senecajs.org", | ||
"@jsonic/jsonic-next": "2.12.1", | ||
"eraro": "^2.1.0", | ||
"eraro": "^3.0.1", | ||
"fast-safe-stringify": "^2.1.1", | ||
"gate-executor": "^3.1.1", | ||
"gubu": "6.0.1", | ||
"gubu": "7.0.0", | ||
"lodash.defaultsdeep": "^4.6.1", | ||
@@ -112,3 +112,3 @@ "lodash.flatten": "^4.4.0", | ||
"@seneca/test-plugin": "0.1.0", | ||
"@types/node": "^20.8.10", | ||
"@types/node": "^20.11.5", | ||
"async": "^3.2.5", | ||
@@ -121,10 +121,10 @@ "bench": "^0.3.6", | ||
"lolex": "^6.0.0", | ||
"prettier": "^3.0.3", | ||
"seneca-entity": "^25.0.0", | ||
"prettier": "^3.2.4", | ||
"seneca-entity": "^25.1.1", | ||
"seneca-error-test": "^0.2.2", | ||
"seneca-joi": "^7.0.2", | ||
"seneca-promisify": "^3.6.0", | ||
"seneca-promisify": "^3.7.1", | ||
"summary": "^2.1.0", | ||
"typescript": "^5.2.2" | ||
"typescript": "^5.3.3" | ||
} | ||
} |
@@ -46,3 +46,3 @@ /* Copyright © 2010-2023 Richard Rodger and other contributors, MIT License. */ | ||
// Tag this Seneca instance, will be appended to instance identifier. | ||
tag: '-', | ||
tag: '-', // TODO: FIX: Gubu api.test.js#292 | ||
// Standard timeout for actions. | ||
@@ -49,0 +49,0 @@ timeout: 22222, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
677995
13050
+ Addedgubu@7.0.0(transitive)
- Removedgubu@6.0.1(transitive)
Updatederaro@^3.0.1
Updatedgubu@7.0.0