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.29.0 to 3.30.0

8

CHANGES.md

@@ -0,1 +1,9 @@

## 3.30.0 2022-02-10
* Error intercept customization hook.
* Rebind decoration functions to current delegate.
* Custom error identification, default now just instanceof Error.
* Plugin options at top level moved to legacy option.
## 3.29.0 2022-09-01

@@ -2,0 +10,0 @@

17

lib/act.js

@@ -59,4 +59,15 @@ "use strict";

catch (e) {
for (let intercept of instance.private$.intercept.act_error) {
intercept.call(instance, {
error: e,
execspec,
opts,
actctxt,
actmsg,
meta,
action_reply
});
}
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));
const ex = opts.error.identify(e) ? e : new Error((0, common_1.inspect)(e));
intern.handle_reply(opts, meta, actctxt, actmsg, ex);

@@ -127,3 +138,3 @@ complete();

actctxt.error = common_1.error;
meta.error = (0, common_1.isError)(data.res);
meta.error = opts.error.identify(data.res);
// A nasty edge case

@@ -303,3 +314,3 @@ if (!meta.error && data.res === data.err) {

const msg = data.msg;
let err = (0, common_1.isError)(thrown_obj)
let err = instance.options().error.identify(thrown_obj)
? thrown_obj

@@ -306,0 +317,0 @@ : new Error((0, common_1.inspect)(thrown_obj));

19

lib/act.ts

@@ -8,3 +8,2 @@ /* Copyright © 2019-2022 Richard Rodger and other contributors, MIT License. */

import {
isError,
build_message,

@@ -101,4 +100,16 @@ inspect,

} catch (e: any) {
for (let intercept of instance.private$.intercept.act_error) {
intercept.call(instance, {
error: e,
execspec,
opts,
actctxt,
actmsg,
meta,
action_reply
})
}
if (opts.error.capture.action && true !== e?.$$seneca_callback_error$$) {
const ex = isError(e) ? e : new Error(inspect(e))
const ex = opts.error.identify(e) ? e : new Error(inspect(e))
intern.handle_reply(opts, meta, actctxt, actmsg, ex)

@@ -197,3 +208,3 @@ complete()

meta.error = isError(data.res)
meta.error = opts.error.identify(data.res)

@@ -456,3 +467,3 @@ // A nasty edge case

let err = isError(thrown_obj)
let err = instance.options().error.identify(thrown_obj)
? thrown_obj

@@ -459,0 +470,0 @@ : new Error(inspect(thrown_obj))

@@ -228,2 +228,12 @@ "use strict";

});
// Rebind function decorations to the delegate instance.
// In particular, this makes the seneca.entity API methods work correctly.
const decorations = self.private$.decorations;
for (let decorationName in decorations) {
if ('function' === typeof decorations[decorationName]) {
let orig_decoration = decorations[decorationName];
delegate[decorationName] = delegate[decorationName].bind(delegate);
Object.assign(delegate[decorationName], orig_decoration);
}
}
return delegate;

@@ -517,3 +527,2 @@ }

});
//var sd = Plugins.make_delegate(self, {
// TODO: review - this feels like a hack

@@ -520,0 +529,0 @@ // perhaps we should instantiate a virtual plugin to represent the client?

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

// Rebind function decorations to the delegate instance.
// In particular, this makes the seneca.entity API methods work correctly.
const decorations = self.private$.decorations
for (let decorationName in decorations) {
if ('function' === typeof decorations[decorationName]) {
let orig_decoration = decorations[decorationName]
delegate[decorationName] = delegate[decorationName].bind(delegate)
Object.assign(delegate[decorationName], orig_decoration)
}
}
return delegate

@@ -685,3 +696,2 @@ }

//var sd = Plugins.make_delegate(self, {
// TODO: review - this feels like a hack

@@ -688,0 +698,0 @@ // perhaps we should instantiate a virtual plugin to represent the client?

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

declare function autoincr(): () => number;
declare function isError(x: any): boolean;
declare function inspect(val: any, opts?: any): string;

@@ -60,2 +59,2 @@ declare function make_callpoint(active: any): (override: any) => any;

}
export { promiser, stringify, wrap_error, make_plugin_key, boolify, parse_jsonic, parse_pattern, build_message, pattern, pincanon, noop, clean, deep, each, makedie, make_standard_act_log_entry, make_standard_err_log_entry, resolve_option, autoincr, make_callpoint, make_trace_desc, history, print, parsePattern, tagnid, isError, inspect, error, msgstr, TRACE_PATTERN, TRACE_ID, TRACE_INSTANCE, TRACE_TAG, TRACE_VERSION, TRACE_START, TRACE_END, TRACE_SYNC, TRACE_ACTION, };
export { promiser, stringify, wrap_error, make_plugin_key, boolify, parse_jsonic, parse_pattern, build_message, pattern, pincanon, noop, clean, deep, each, makedie, make_standard_act_log_entry, make_standard_err_log_entry, resolve_option, autoincr, make_callpoint, make_trace_desc, history, print, parsePattern, tagnid, inspect, error, msgstr, TRACE_PATTERN, TRACE_ID, TRACE_INSTANCE, TRACE_TAG, TRACE_VERSION, TRACE_START, TRACE_END, TRACE_SYNC, TRACE_ACTION, };

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.TRACE_ACTION = exports.TRACE_SYNC = exports.TRACE_END = exports.TRACE_START = exports.TRACE_VERSION = exports.TRACE_TAG = exports.TRACE_INSTANCE = exports.TRACE_ID = exports.TRACE_PATTERN = exports.msgstr = exports.error = exports.inspect = exports.isError = exports.tagnid = exports.parsePattern = exports.print = exports.history = exports.make_trace_desc = exports.make_callpoint = exports.autoincr = exports.resolve_option = exports.make_standard_err_log_entry = exports.make_standard_act_log_entry = exports.makedie = exports.each = exports.deep = exports.clean = exports.noop = exports.pincanon = exports.pattern = exports.build_message = exports.parse_pattern = exports.parse_jsonic = exports.boolify = exports.make_plugin_key = exports.wrap_error = exports.stringify = exports.promiser = void 0;
exports.TRACE_ACTION = exports.TRACE_SYNC = exports.TRACE_END = exports.TRACE_START = exports.TRACE_VERSION = exports.TRACE_TAG = exports.TRACE_INSTANCE = exports.TRACE_ID = exports.TRACE_PATTERN = exports.msgstr = exports.error = exports.inspect = exports.tagnid = exports.parsePattern = exports.print = exports.history = exports.make_trace_desc = exports.make_callpoint = exports.autoincr = exports.resolve_option = exports.make_standard_err_log_entry = exports.make_standard_act_log_entry = exports.makedie = exports.each = exports.deep = exports.clean = exports.noop = exports.pincanon = exports.pattern = exports.build_message = exports.parse_pattern = exports.parse_jsonic = exports.boolify = exports.make_plugin_key = exports.wrap_error = exports.stringify = exports.promiser = void 0;
const util_1 = __importDefault(require("util"));

@@ -228,4 +228,5 @@ const errors_1 = __importDefault(require("./errors"));

err = new Error('unknown');
// } else if (!Util.isError(err)) {
}
else if (!util_1.default.isError(err)) {
else if (!so.error.identify(err)) {
err = new Error('string' === typeof err ? err : inspect(err));

@@ -424,6 +425,2 @@ }

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

@@ -430,0 +427,0 @@ return util_1.default.inspect(val, opts);

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

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

@@ -549,7 +550,2 @@ }

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

@@ -752,3 +748,2 @@ return Util.inspect(val, opts)

tagnid,
isError,
inspect,

@@ -755,0 +750,0 @@ error,

@@ -319,9 +319,4 @@ "use strict";

.substring(0, datalen);
if (objstr.length <= 22 || !data.err
// (!obj.$$logged$$ && (!data.err || !data.err.$$logged$$))
) {
if (objstr.length <= 22 || !data.err) {
logb.push(objstr);
// if ('object' === typeof obj) {
// obj.$$logged$$ = () => { }
// }
}

@@ -381,8 +376,11 @@ else {

].join(';'));
// } else if (!data.$$logged$$) {
// logb.push(Util.inspect(data).replace(/\n/g, ' ').substring(0, datalen))
// if ('object' === typeof data) {
// data.$$logged$$ = () => { }
// }
}
// Just plain data
else {
// TODO: use jsonic util
let datastr = util_1.default.inspect(seneca.util.clean(data.data || data))
.replace(/\s+/g, '')
.substring(0, datalen);
logb.push(datastr.length <= 111 ? datastr : datastr.substring(0, 111) + '...');
}
if (data.did) {

@@ -389,0 +387,0 @@ logb.push(data.did);

@@ -394,8 +394,4 @@ /* Copyright © 2016-2022 Richard Rodger and other contributors, MIT License. */

objstr.length <= 22 || !data.err
// (!obj.$$logged$$ && (!data.err || !data.err.$$logged$$))
) {
logb.push(objstr)
// if ('object' === typeof obj) {
// obj.$$logged$$ = () => { }
// }
} else {

@@ -456,9 +452,13 @@ logb.push(objstr.substring(0, 22)) + '...'

)
// } else if (!data.$$logged$$) {
// logb.push(Util.inspect(data).replace(/\n/g, ' ').substring(0, datalen))
// if ('object' === typeof data) {
// data.$$logged$$ = () => { }
// }
}
// Just plain data
else {
// TODO: use jsonic util
let datastr = Util.inspect(seneca.util.clean(data.data || data))
.replace(/\s+/g, '')
.substring(0, datalen)
logb.push(datastr.length <= 111 ? datastr : datastr.substring(0, 111) + '...')
}
if (data.did) {

@@ -465,0 +465,0 @@ logb.push(data.did)

@@ -123,2 +123,8 @@ /* Copyright © 2020 Richard Rodger and other contributors, MIT License. */

let private$ = seneca.private$;
// Special cases for short plugin names
// TODO: plugin loading should check for @seneca and seneca first!
// 1. Avoid conflict with the OG request module!
if ('request' === args[0]) {
args[0] = '@seneca/request';
}
// TODO: use-plugin needs better error message for malformed plugin desc

@@ -257,3 +263,2 @@ let desc = private$.use.build_plugin_desc(...args);

}
//seneca.register(plugin, meta)
},

@@ -373,5 +378,5 @@ delegate: (spec) => {

// DEPRECATED: remove in 4
so[fullname], so.plugin[fullname],
so.legacy.top_plugins ? so[fullname] : {}, so.plugin[fullname],
// DEPRECATED: remove in 4
so[fullname + '$' + plugin.tag], so.plugin[fullname + '$' + plugin.tag]);
so.legacy.top_plugins ? so[fullname + '$' + plugin.tag] : {}, so.plugin[fullname + '$' + plugin.tag]);
let shortname = fullname !== plugin.name ? plugin.name : null;

@@ -383,5 +388,5 @@ if (!shortname && fullname.indexOf('seneca-') === 0) {

// DEPRECATED: remove in 4
so[shortname], so.plugin[shortname],
so.legacy.top_plugins ? so[fullname] : {}, so.plugin[shortname],
// DEPRECATED: remove in 4
so[shortname + '$' + plugin.tag], so.plugin[shortname + '$' + plugin.tag]);
so.legacy.top_plugins ? so[shortname + '$' + plugin.tag] : {}, so.plugin[shortname + '$' + plugin.tag]);
let base = {};

@@ -388,0 +393,0 @@ // NOTE: plugin error codes are in their own namespaces

@@ -176,2 +176,9 @@ /* Copyright © 2020 Richard Rodger and other contributors, MIT License. */

// Special cases for short plugin names
// TODO: plugin loading should check for @seneca and seneca first!
// 1. Avoid conflict with the OG request module!
if ('request' === args[0]) {
args[0] = '@seneca/request'
}
// TODO: use-plugin needs better error message for malformed plugin desc

@@ -346,4 +353,2 @@ let desc = private$.use.build_plugin_desc(...args)

}
//seneca.register(plugin, meta)
},

@@ -504,3 +509,3 @@

// DEPRECATED: remove in 4
so[fullname],
so.legacy.top_plugins ? so[fullname] : {},

@@ -510,3 +515,3 @@ so.plugin[fullname],

// DEPRECATED: remove in 4
so[fullname + '$' + plugin.tag],
so.legacy.top_plugins ? so[fullname + '$' + plugin.tag] : {},

@@ -525,3 +530,3 @@ so.plugin[fullname + '$' + plugin.tag]

// DEPRECATED: remove in 4
so[shortname],
so.legacy.top_plugins ? so[fullname] : {},

@@ -531,3 +536,3 @@ so.plugin[shortname],

// DEPRECATED: remove in 4
so[shortname + '$' + plugin.tag],
so.legacy.top_plugins ? so[shortname + '$' + plugin.tag] : {},

@@ -534,0 +539,0 @@ so.plugin[shortname + '$' + plugin.tag]

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

@@ -97,4 +97,4 @@ "homepage": "http://senecajs.org",

"lodash.uniq": "^4.5.0",
"minimist": "^1.2.6",
"nid": "^2.0.0",
"minimist": "^1.2.8",
"nid": "^2.0.1",
"norma": "^2.0.2",

@@ -113,3 +113,3 @@ "optioner": "^5.0.1",

"@seneca/test-plugin": "0.1.0",
"@types/node": "^18.7.14",
"@types/node": "^18.13.0",
"async": "^3.2.4",

@@ -122,4 +122,4 @@ "bench": "^0.3.6",

"lolex": "^6.0.0",
"prettier": "^2.7.1",
"seneca-entity": "^18.4.0",
"prettier": "^2.8.4",
"seneca-entity": "^19.0.0",
"seneca-error-test": "^0.2.2",

@@ -129,4 +129,4 @@ "seneca-joi": "^7.0.2",

"summary": "^2.1.0",
"typescript": "^4.8.2"
"typescript": "^4.9.5"
}
}

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

action: true,
}
},
// Custom function to identify thrown errors.
identify: (e) => e instanceof Error,
},

@@ -252,2 +254,4 @@ // Validate messages and options.

options: true,
// If true, look for plugin options by name at the top level of options
top_plugins: false,
}),

@@ -719,4 +723,5 @@ // Processing task ordering.

ignore_plugins: {},
intercept: { act_error: [] }
};
}
//# sourceMappingURL=seneca.js.map

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