Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

seneca

Package Overview
Dependencies
Maintainers
1
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seneca - npm Package Compare versions

Comparing version 3.27.2 to 3.28.0

5

CHANGES.md

@@ -0,1 +1,6 @@

## 3.28.0 2022-05-23
* Validation control options: valid.active|message|option|plugin
## 3.27.2 2022-05-16

@@ -2,0 +7,0 @@

6

lib/act.js

@@ -59,3 +59,3 @@ "use strict";

catch (e) {
if (opts.error.capture.action) {
if (opts.error.capture.action && true !== (e === null || e === void 0 ? void 0 : e.$$seneca_callback_error$$)) {
const ex = (0, common_1.isError)(e) ? e : new Error((0, common_1.inspect)(e));

@@ -141,3 +141,2 @@ intern.handle_reply(opts, meta, actctxt, actmsg, ex);

}
// intern.process_outward(actctxt, data, delegate)
intern.process_outward(actctxt, data);

@@ -159,2 +158,5 @@ if (data.has_callback) {

else {
if ('object' === typeof thrown_obj) {
thrown_obj.$$seneca_callback_error$$ = true;
}
throw thrown_obj;

@@ -161,0 +163,0 @@ }

@@ -99,4 +99,4 @@ /* Copyright © 2019-2022 Richard Rodger and other contributors, MIT License. */

)
} catch (e) {
if (opts.error.capture.action) {
} catch (e: any) {
if (opts.error.capture.action && true !== e?.$$seneca_callback_error$$) {
const ex = isError(e) ? e : new Error(inspect(e))

@@ -215,3 +215,2 @@ intern.handle_reply(opts, meta, actctxt, actmsg, ex)

// intern.process_outward(actctxt, data, delegate)
intern.process_outward(actctxt, data)

@@ -227,3 +226,3 @@

}
} catch (thrown_obj) {
} catch (thrown_obj: any) {
if (opts.error.capture.callback) {

@@ -233,2 +232,5 @@ intern.callback_error(delegate, thrown_obj, actctxt, data)

else {
if ('object' === typeof thrown_obj) {
thrown_obj.$$seneca_callback_error$$ = true
}
throw thrown_obj

@@ -235,0 +237,0 @@ }

@@ -27,3 +27,3 @@ /// <reference types="node" />

declare function isError(x: any): boolean;
declare function inspect(x: any): string;
declare function inspect(val: any, opts?: any): string;
declare function make_callpoint(active: any): (override: any) => any;

@@ -30,0 +30,0 @@ declare function make_trace_desc(meta: any): any[];

@@ -229,3 +229,3 @@ /* Copyright © 2010-2022 Richard Rodger and other contributors, MIT License. */

else if (!util_1.default.isError(err)) {
err = new Error('string' === typeof err ? err : util_1.default.inspect(err));
err = new Error('string' === typeof err ? err : inspect(err));
}

@@ -257,3 +257,3 @@ err.fatal$ = true;

', argv=' +
util_1.default.inspect(process.argv).replace(/\n/g, '') +
inspect(process.argv).replace(/\n/g, '') +
(!full

@@ -263,3 +263,3 @@ ? ''

? ''
: ', env=' + util_1.default.inspect(process.env).replace(/\n/g, ''));
: ', env=' + inspect(process.env).replace(/\n/g, ''));
let when = new Date();

@@ -276,3 +276,3 @@ let clean_details = null;

'\nDETAILS ::: ' +
util_1.default.inspect(full
inspect(full
? err.details

@@ -297,7 +297,7 @@ : ((clean_details = clean(err.details) || {}),

: ', ' +
util_1.default.inspect(process.versions).replace(/\s+/g, ' ') +
inspect(process.versions).replace(/\s+/g, ' ') +
', ' +
util_1.default.inspect(process.features).replace(/\s+/g, ' ') +
inspect(process.features).replace(/\s+/g, ' ') +
', ' +
util_1.default.inspect(process.moduleLoadList).replace(/\s+/g, ' ')) +
inspect(process.moduleLoadList).replace(/\s+/g, ' ')) +
'\nPROCESS ::: ' +

@@ -323,3 +323,3 @@ procdesc +

kind: 'close',
err: util_1.default.inspect(close_err),
err: inspect(close_err),
});

@@ -361,3 +361,3 @@ }

kind: 'panic',
panic: util_1.default.inspect(panic),
panic: inspect(panic),
orig: arguments[0],

@@ -430,7 +430,7 @@ });

function isError(x) {
return util_1.default.isError(x);
return util_1.default.types.isNativeError(x);
}
exports.isError = isError;
function inspect(x) {
return util_1.default.inspect(x);
function inspect(val, opts) {
return util_1.default.inspect(val, opts);
}

@@ -576,3 +576,3 @@ exports.inspect = inspect;

toString() {
return util_1.default.inspect({
return inspect({
total: this._total,

@@ -579,0 +579,0 @@ map: this._map,

@@ -304,3 +304,3 @@ /* Copyright © 2010-2022 Richard Rodger and other contributors, MIT License. */

} else if (!Util.isError(err)) {
err = new Error('string' === typeof err ? err : Util.inspect(err))
err = new Error('string' === typeof err ? err : inspect(err))
}

@@ -338,3 +338,3 @@

', argv=' +
Util.inspect(process.argv).replace(/\n/g, '') +
inspect(process.argv).replace(/\n/g, '') +
(!full

@@ -344,3 +344,3 @@ ? ''

? ''
: ', env=' + Util.inspect(process.env).replace(/\n/g, ''))
: ', env=' + inspect(process.env).replace(/\n/g, ''))

@@ -361,3 +361,3 @@ let when = new Date()

'\nDETAILS ::: ' +
Util.inspect(
inspect(
full

@@ -385,7 +385,7 @@ ? err.details

: ', ' +
Util.inspect(process.versions).replace(/\s+/g, ' ') +
inspect(process.versions).replace(/\s+/g, ' ') +
', ' +
Util.inspect(process.features).replace(/\s+/g, ' ') +
inspect(process.features).replace(/\s+/g, ' ') +
', ' +
Util.inspect((process as any).moduleLoadList).replace(/\s+/g, ' ')) +
inspect((process as any).moduleLoadList).replace(/\s+/g, ' ')) +
'\nPROCESS ::: ' +

@@ -415,3 +415,3 @@ procdesc +

kind: 'close',
err: Util.inspect(close_err),
err: inspect(close_err),
})

@@ -464,3 +464,3 @@ }

kind: 'panic',
panic: Util.inspect(panic),
panic: inspect(panic),
orig: arguments[0],

@@ -556,8 +556,8 @@ })

function isError(x: any) {
return Util.isError(x)
return Util.types.isNativeError(x)
}
function inspect(x: any) {
return Util.inspect(x)
function inspect(val: any, opts?: any) {
return Util.inspect(val, opts)
}

@@ -719,3 +719,3 @@

toString(this: any) {
return Util.inspect({
return inspect({
total: this._total,

@@ -722,0 +722,0 @@ map: this._map,

"use strict";
/* Copyright © 2010-2022 Richard Rodger and other contributors, MIT License. */
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Inward = void 0;
const util_1 = __importDefault(require("util"));
const Common = require('./common');
const common_1 = require("./common");
const intern = {};

@@ -41,4 +37,4 @@ function inward_msg_modify(spec) {

numparents: meta.parents.length,
parents: meta.parents.map((p) => p[Common.TRACE_PATTERN] + ' ' + p[Common.TRACE_ACTION]),
args: util_1.default.inspect(Common.clean(data.msg)).replace(/\n/g, ''),
parents: meta.parents.map((p) => p[common_1.TRACE_PATTERN] + ' ' + p[common_1.TRACE_ACTION]),
args: (0, common_1.inspect)((0, common_1.clean)(data.msg)).replace(/\n/g, ''),
},

@@ -71,3 +67,3 @@ },

info: {
args: util_1.default.inspect(Common.clean(data.msg)).replace(/\n/g, ''),
args: (0, common_1.inspect)((0, common_1.clean)(data.msg)).replace(/\n/g, ''),
},

@@ -123,4 +119,4 @@ },

info: {
args: util_1.default.inspect(Common.clean(msg)).replace(/\n/g, ''),
xdefault: util_1.default.inspect(default$),
args: (0, common_1.inspect)((0, common_1.clean)(msg)).replace(/\n/g, ''),
xdefault: (0, common_1.inspect)(default$),
},

@@ -144,3 +140,3 @@ },

code: 'act_not_found',
info: { args: util_1.default.inspect(Common.clean(msg)).replace(/\n/g, '') },
info: { args: (0, common_1.inspect)((0, common_1.clean)(msg)).replace(/\n/g, '') },
log: {

@@ -163,18 +159,20 @@ level: so.trace.unknown ? 'warn' : 'debug',

var err = null;
if ('function' === typeof ctx.actdef.validate) {
// FIX: this is assumed to be synchronous
// seneca-parambulator and seneca-joi need to be updated
ctx.actdef.validate(msg, function (verr) {
err = verr;
});
}
else if (ctx.actdef.gubu) {
// TODO: gubu option to provide Error without throwing
// TODO: how to expose gubu builders, Required, etc?
// TODO: use original msg for error
try {
data.msg = ctx.actdef.gubu(msg);
if (so.valid.active && so.valid.message) {
if (ctx.actdef.gubu) {
// TODO: gubu option to provide Error without throwing
// TODO: how to expose gubu builders, Required, etc?
// TODO: use original msg for error
try {
data.msg = ctx.actdef.gubu(msg);
}
catch (e) {
err = e;
}
}
catch (e) {
err = e;
else if ('function' === typeof ctx.actdef.validate) {
// FIX: this is assumed to be synchronous
// seneca-parambulator and seneca-joi need to be updated
ctx.actdef.validate(msg, function (verr) {
err = verr;
});
}

@@ -191,3 +189,3 @@ }

message: err.message,
msg: Common.clean(msg),
msg: (0, common_1.clean)(msg),
error: err,

@@ -276,3 +274,3 @@ },

meta.parents = meta.parents.concat(parent.parents || []);
meta.parents.unshift(Common.make_trace_desc(parent));
meta.parents.unshift((0, common_1.make_trace_desc)(parent));
}

@@ -322,3 +320,3 @@ meta.custom = Object.assign(parentcustom, meta.custom, ctx.seneca.fixedmeta && ctx.seneca.fixedmeta.custom);

if (meta.explain) {
ctx.seneca.explain({ explain$: true, msg$: Common.clean(data.msg) });
ctx.seneca.explain({ explain$: true, msg$: (0, common_1.clean)(data.msg) });
}

@@ -325,0 +323,0 @@ }

/* Copyright © 2010-2022 Richard Rodger and other contributors, MIT License. */
import Util from 'util'
import {
TRACE_PATTERN,
TRACE_ACTION,
clean,
make_trace_desc,
inspect,
} from './common'
const Common = require('./common')
const intern: any = {}

@@ -51,5 +55,5 @@

parents: meta.parents.map(
(p: any) => p[Common.TRACE_PATTERN] + ' ' + p[Common.TRACE_ACTION]
(p: any) => p[TRACE_PATTERN] + ' ' + p[TRACE_ACTION]
),
args: Util.inspect(Common.clean(data.msg)).replace(/\n/g, ''),
args: inspect(clean(data.msg)).replace(/\n/g, ''),
},

@@ -89,3 +93,3 @@ },

info: {
args: Util.inspect(Common.clean(data.msg)).replace(/\n/g, ''),
args: inspect(clean(data.msg)).replace(/\n/g, ''),
},

@@ -116,2 +120,3 @@ },

function inward_act_default(spec: any) {

@@ -154,4 +159,4 @@ const ctx = spec.ctx

info: {
args: Util.inspect(Common.clean(msg)).replace(/\n/g, ''),
xdefault: Util.inspect(default$),
args: inspect(clean(msg)).replace(/\n/g, ''),
xdefault: inspect(default$),
},

@@ -164,2 +169,3 @@ },

function inward_act_not_found(spec: any) {

@@ -180,3 +186,3 @@ const ctx = spec.ctx

code: 'act_not_found',
info: { args: Util.inspect(Common.clean(msg)).replace(/\n/g, '') },
info: { args: inspect(clean(msg)).replace(/\n/g, '') },
log: {

@@ -194,2 +200,3 @@ level: so.trace.unknown ? 'warn' : 'debug',

function inward_validate_msg(spec: any) {

@@ -204,18 +211,20 @@ const ctx = spec.ctx

if ('function' === typeof ctx.actdef.validate) {
// FIX: this is assumed to be synchronous
// seneca-parambulator and seneca-joi need to be updated
ctx.actdef.validate(msg, function(verr: any) {
err = verr
})
} else if (ctx.actdef.gubu) {
// TODO: gubu option to provide Error without throwing
// TODO: how to expose gubu builders, Required, etc?
// TODO: use original msg for error
try {
data.msg = ctx.actdef.gubu(msg)
} catch (e) {
err = e
if (so.valid.active && so.valid.message) {
if (ctx.actdef.gubu) {
// TODO: gubu option to provide Error without throwing
// TODO: how to expose gubu builders, Required, etc?
// TODO: use original msg for error
try {
data.msg = ctx.actdef.gubu(msg)
} catch (e) {
err = e
}
}
else if ('function' === typeof ctx.actdef.validate) {
// FIX: this is assumed to be synchronous
// seneca-parambulator and seneca-joi need to be updated
ctx.actdef.validate(msg, function(verr: any) {
err = verr
})
}
}

@@ -232,3 +241,3 @@

message: err.message,
msg: Common.clean(msg),
msg: clean(msg),
error: err,

@@ -311,2 +320,3 @@ },

function inward_msg_meta(spec: any) {

@@ -336,3 +346,3 @@ const ctx = spec.ctx

meta.parents = meta.parents.concat(parent.parents || [])
meta.parents.unshift(Common.make_trace_desc(parent))
meta.parents.unshift(make_trace_desc(parent))
}

@@ -400,3 +410,3 @@

if (meta.explain) {
ctx.seneca.explain({ explain$: true, msg$: Common.clean(data.msg) })
ctx.seneca.explain({ explain$: true, msg$: clean(data.msg) })
}

@@ -448,2 +458,3 @@ }

intern.explain = function(meta: any, entry: any) {

@@ -500,3 +511,2 @@ var orig_explain = this.explain

let Inward = {

@@ -503,0 +513,0 @@ inward_msg_modify,

@@ -40,2 +40,3 @@ "use strict";

function prepare(basemodule, optionShape, initial) {
var _a, _b;
var DEFAULT_OPTIONS_FILE = './seneca.options.js';

@@ -140,9 +141,16 @@ var FATAL_OPTIONS_FILE = './options.seneca.js';

}
else if (true === initial.legacy) {
adjusted.legacy = {};
}
const validate = false !== ((_a = initial.valid) === null || _a === void 0 ? void 0 : _a.active) &&
false !== ((_b = initial.valid) === null || _b === void 0 ? void 0 : _b.option);
// This is the list of option sources.
// The list is in reverse precedence order,
// i.e. command line arguments (argv) win
var out = Common.deep({},
var out = Common.deep(validate ? {} : optionShape(),
// defaults,
sourcemap.default_file, options, sourcemap.loaded, initial, adjusted, sourcemap.env, sourcemap.argv);
out = optionShape(out);
if (validate) {
out = optionShape(out);
}
// Legacy log settings.

@@ -149,0 +157,0 @@ out.log = out.log || out.logger || out.logging || {};

@@ -168,3 +168,10 @@ /* Copyright © 2014-2022 Richard Rodger and other contributors, MIT License. */

}
else if (true === initial.legacy) {
adjusted.legacy = {}
}
const validate =
false !== initial.valid?.active &&
false !== initial.valid?.option
// This is the list of option sources.

@@ -174,3 +181,3 @@ // The list is in reverse precedence order,

var out = Common.deep(
{},
validate ? {} : optionShape(),
// defaults,

@@ -186,3 +193,5 @@ sourcemap.default_file,

out = optionShape(out)
if (validate) {
out = optionShape(out)
}

@@ -189,0 +198,0 @@ // Legacy log settings.

@@ -366,3 +366,3 @@ /* Copyright © 2020 Richard Rodger and other contributors, MIT License. */

let fullname = plugin.fullname;
let defaults = plugin.defaults || {};
let defaults = plugin.defaults;
let fullname_options = Object.assign({},

@@ -398,21 +398,40 @@ // DEPRECATED: remove in 4

defaults({ valid, Joi }) : defaults;
if (!so.legacy.options && !Joi.isSchema(defaults_values, { legacy: true })) {
let optionShape =
// TODO: use Gubu.isShape
(defaults_values.gubu && defaults_values.gubu.gubu$) ? defaults_values :
delegate.valid(defaults_values);
resolved_options = optionShape(fullopts);
if (null == defaults_values ||
0 === Object.keys(defaults_values).length ||
!so.valid.active ||
!so.valid.plugin) {
resolved_options = fullopts;
}
else {
let joi_schema = 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', {
name: fullname,
err_msg: joi_out.error.message,
options: fullopts,
});
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);
let shapeErrors = [];
resolved_options = optionShape(fullopts, { err: shapeErrors });
if (0 < shapeErrors.length) {
err = delegate.error('invalid_plugin_option', {
name: fullname,
err_msg: shapeErrors.map((se) => se.t).join('; '),
options: fullopts,
});
}
}
else {
resolved_options = joi_out.value;
let joi_schema = 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', {
name: fullname,
err_msg: joi_out.error.message,
options: fullopts,
});
}
else {
resolved_options = joi_out.value;
}
}

@@ -419,0 +438,0 @@ }

@@ -491,3 +491,3 @@ /* Copyright © 2020 Richard Rodger and other contributors, MIT License. */

let fullname = plugin.fullname
let defaults = plugin.defaults || {}
let defaults = plugin.defaults

@@ -556,28 +556,52 @@ let fullname_options = Object.assign(

if (!so.legacy.options && !Joi.isSchema(defaults_values, { legacy: true })) {
let optionShape =
// TODO: use Gubu.isShape
(defaults_values.gubu && defaults_values.gubu.gubu$) ? defaults_values :
delegate.valid(defaults_values)
resolved_options = optionShape(fullopts)
if (null == defaults_values ||
0 === Object.keys(defaults_values).length ||
!so.valid.active ||
!so.valid.plugin
) {
resolved_options = fullopts
}
else {
let joi_schema: any = intern.prepare_spec(
Joi,
defaults_values,
{ allow_unknown: true },
{}
)
if (!so.legacy.options && !Joi.isSchema(defaults_values, { legacy: true })) {
// TODO: use Gubu.isShape
let isShape = defaults_values.gubu && defaults_values.gubu.gubu$
let joi_out = joi_schema.validate(fullopts)
// TODO: when Gubu supports merge, also merge if isShape
if (!isShape && null == defaults_values.errors && null != errors) {
defaults_values.errors = {}
}
if (joi_out.error) {
err = delegate.error('invalid_plugin_option', {
name: fullname,
err_msg: joi_out.error.message,
options: fullopts,
})
let optionShape =
isShape ? defaults_values : delegate.valid(defaults_values)
let shapeErrors: any[] = []
resolved_options = optionShape(fullopts, { err: shapeErrors })
if (0 < shapeErrors.length) {
err = delegate.error('invalid_plugin_option', {
name: fullname,
err_msg: shapeErrors.map((se: any) => se.t).join('; '),
options: fullopts,
})
}
}
else {
resolved_options = joi_out.value
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', {
name: fullname,
err_msg: joi_out.error.message,
options: fullopts,
})
}
else {
resolved_options = joi_out.value
}
}

@@ -584,0 +608,0 @@ }

@@ -333,3 +333,5 @@ "use strict";

}
seneca.reply(internalize_reply(sending_instance, res));
// seneca.reply(internalize_reply(sending_instance, res))
let replySpec = internalize_reply(sending_instance, res);
reply(replySpec.err, replySpec.out, replySpec.meta);
};

@@ -336,0 +338,0 @@ const wreck_read = Wreck.read(res, spec.wreck.read);

@@ -424,3 +424,5 @@ /* Copyright © 2015-2022 Richard Rodger and other contributors, MIT License. */

seneca.reply(internalize_reply(sending_instance, res))
// seneca.reply(internalize_reply(sending_instance, res))
let replySpec = internalize_reply(sending_instance, res)
reply(replySpec.err, replySpec.out, replySpec.meta)
}

@@ -427,0 +429,0 @@

{
"name": "seneca",
"description": "A Microservices Framework for Node.js",
"version": "3.27.2",
"version": "3.28.0",
"license": "MIT",

@@ -92,3 +92,3 @@ "homepage": "http://senecajs.org",

"gate-executor": "^3.1.1",
"gubu": "^2.0.1",
"gubu": "^3.0.0",
"jsonic": "^1.0.1",

@@ -114,3 +114,3 @@ "lodash.defaultsdeep": "^4.6.1",

"@seneca/test-plugin": "0.1.0",
"@types/node": "^17.0.33",
"@types/node": "^17.0.35",
"async": "^3.2.3",

@@ -128,4 +128,5 @@ "bench": "^0.3.6",

"seneca-promisify": "^2.3.0",
"summary": "^2.1.0",
"typescript": "^4.6.4"
}
}

@@ -89,2 +89,13 @@ /* Copyright © 2010-2022 Richard Rodger and other contributors, MIT License. */

},
// Validate messages and options.
valid: {
// If false disables all validation.
active: true,
// Validate message parameters.
message: true,
// Validate main Seneca instance options.
option: true,
// Validate plugin options.
plugin: true,
},
// Debug settings.

@@ -91,0 +102,0 @@ debug: {

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc