Comparing version 3.30.0 to 3.30.1
@@ -0,1 +1,7 @@ | ||
## 3.30.1 2022-05-31 | ||
* Remove rebind decoration as not needed - seneca-entity handles own special case | ||
* Option debnug.datalen applies to test logs in all cases | ||
## 3.30.0 2022-02-10 | ||
@@ -2,0 +8,0 @@ |
@@ -59,2 +59,3 @@ "use strict"; | ||
catch (e) { | ||
// TODO: review, needs better test for when this actually happens | ||
for (let intercept of instance.private$.intercept.act_error) { | ||
@@ -61,0 +62,0 @@ intercept.call(instance, { |
@@ -99,2 +99,4 @@ /* Copyright © 2019-2022 Richard Rodger and other contributors, MIT License. */ | ||
} catch (e: any) { | ||
// TODO: review, needs better test for when this actually happens | ||
for (let intercept of instance.private$.intercept.act_error) { | ||
@@ -315,2 +317,3 @@ intercept.call(instance, { | ||
if (inwardres.err) { | ||
@@ -317,0 +320,0 @@ throw inwardres.err |
@@ -7,3 +7,2 @@ "use strict"; | ||
const common_1 = require("./common"); | ||
const Jsonic = require('jsonic'); | ||
function api_add() { | ||
@@ -99,2 +98,3 @@ let ctx = { | ||
const opts = spec.ctx.opts; | ||
const Jsonic = spec.ctx.instance.util.Jsonic; | ||
actdef.sub = !!actdef.raw.sub$; | ||
@@ -101,0 +101,0 @@ actdef.client = !!actdef.raw.client$; |
@@ -9,2 +9,3 @@ /* Copyright © 2019-2021 Richard Rodger and other contributors, MIT License. */ | ||
import { | ||
@@ -20,5 +21,5 @@ clean, | ||
const Jsonic = require('jsonic') | ||
function api_add(this: any) { | ||
@@ -133,2 +134,3 @@ let ctx = { | ||
const opts = spec.ctx.opts | ||
const Jsonic = spec.ctx.instance.util.Jsonic | ||
@@ -135,0 +137,0 @@ actdef.sub = !!actdef.raw.sub$ |
"use strict"; | ||
/* Copyright © 2010-2022 Richard Rodger and other contributors, MIT License. */ | ||
/* Copyright © 2010-2023 Richard Rodger and other contributors, MIT License. */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.API = void 0; | ||
var Jsonic = require('jsonic'); | ||
var Norma = require('norma'); | ||
var Common = require('./common'); | ||
var errlog = Common.make_standard_err_log_entry; | ||
var intern = {}; | ||
const Norma = require('norma'); | ||
const common_1 = require("./common"); | ||
const errlog = common_1.make_standard_err_log_entry; | ||
const intern = {}; | ||
function wrap(pin, actdef, wrapper) { | ||
@@ -15,4 +14,4 @@ var pinthis = this; | ||
pin = Array.isArray(pin) ? pin : [pin]; | ||
Common.each(pin, function (p) { | ||
Common.each(pinthis.list(p), function (actpattern) { | ||
(0, common_1.each)(pin, function (p) { | ||
(0, common_1.each)(pinthis.list(p), function (actpattern) { | ||
pinthis.add(actpattern, wrapper, actdef); | ||
@@ -25,3 +24,3 @@ }); | ||
var self = this; | ||
patargs = Jsonic(patargs || {}); | ||
patargs = self.util.Jsonic(patargs || {}); | ||
var fix_delegate = self.delegate(patargs); | ||
@@ -69,3 +68,3 @@ // TODO: attach msgargs and custom to delegate.private$ in some way for debugging | ||
if (out_opts.debug.callpoint) { | ||
private$.callpoint = Common.make_callpoint(out_opts.debug.callpoint); | ||
private$.callpoint = (0, common_1.make_callpoint)(out_opts.debug.callpoint); | ||
} | ||
@@ -91,3 +90,3 @@ // DEPRECATED | ||
if (false !== done && null == done) { | ||
return Common.promiser(intern.close.bind(seneca, callpoint)); | ||
return (0, common_1.promiser)(intern.close.bind(seneca, callpoint)); | ||
} | ||
@@ -134,3 +133,3 @@ return intern.close.call(seneca, callpoint, done); | ||
else { | ||
error = Common.eraro.apply(this, arguments); | ||
error = common_1.error.apply(this, arguments); | ||
} | ||
@@ -207,3 +206,3 @@ return error; | ||
self.toString() + | ||
(Object.keys(vfa).length ? '/' + Jsonic.stringify(vfa) : ''); | ||
(Object.keys(vfa).length ? '/' + (0, common_1.jsonic_stringify)(vfa) : ''); | ||
return strdesc; | ||
@@ -234,12 +233,2 @@ } | ||
}); | ||
// 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; | ||
@@ -351,4 +340,4 @@ } | ||
function translate(from_in, to_in, pick_in) { | ||
var from = 'string' === typeof from_in ? Jsonic(from_in) : from_in; | ||
var to = 'string' === typeof to_in ? Jsonic(to_in) : to_in; | ||
var from = 'string' === typeof from_in ? this.util.Jsonic(from_in) : from_in; | ||
var to = 'string' === typeof to_in ? this.util.Jsonic(to_in) : to_in; | ||
var pick = {}; | ||
@@ -404,7 +393,7 @@ if ('string' === typeof pick_in) { | ||
function find_plugin(plugindesc, tag) { | ||
var plugin_key = Common.make_plugin_key(plugindesc, tag); | ||
var plugin_key = (0, common_1.make_plugin_key)(plugindesc, tag); | ||
return this.private$.plugins[plugin_key]; | ||
} | ||
function has_plugin(plugindesc, tag) { | ||
var plugin_key = Common.make_plugin_key(plugindesc, tag); | ||
var plugin_key = (0, common_1.make_plugin_key)(plugindesc, tag); | ||
return !!this.private$.plugins[plugin_key]; | ||
@@ -417,3 +406,3 @@ } | ||
} | ||
var plugin_key = Common.make_plugin_key(plugindesc, tag); | ||
var plugin_key = (0, common_1.make_plugin_key)(plugindesc, tag); | ||
var resolved_ignore = (this.private$.ignore_plugins[plugin_key] = | ||
@@ -432,3 +421,3 @@ null == ignore ? true : !!ignore); | ||
var seneca = this; | ||
var pat = 'string' === typeof pattern ? Jsonic(pattern) : pattern; | ||
var pat = 'string' === typeof pattern ? seneca.util.Jsonic(pattern) : pattern; | ||
pat = seneca.util.clean(pat); | ||
@@ -449,10 +438,4 @@ pat = pat || {}; | ||
return this.private$.actrouter | ||
.list(null == pattern ? {} : Jsonic(pattern)) | ||
.list(null == pattern ? {} : this.util.Jsonic(pattern)) | ||
.map((x) => x.match); | ||
/* | ||
return _.map( | ||
this.private$.actrouter.list(null == pattern ? {} : Jsonic(pattern)), | ||
'match' | ||
) | ||
*/ | ||
} | ||
@@ -530,9 +513,9 @@ // Get the current status of the instance. | ||
// pg: pin group | ||
raw_config.pg = Common.pincanon(raw_config.pin || raw_config.pins); | ||
raw_config.pg = (0, common_1.pincanon)(raw_config.pin || raw_config.pins); | ||
var config = intern.resolve_config(raw_config, opts); | ||
config.id = config.id || Common.pattern(raw_config); | ||
config.id = config.id || (0, common_1.pattern)(raw_config); | ||
var pins = config.pins || | ||
(Array.isArray(config.pin) ? config.pin : [config.pin || '']); | ||
pins = pins.map((pin) => { | ||
return 'string' === typeof pin ? Jsonic(pin) : pin; | ||
return 'string' === typeof pin ? self.util.Jsonic(pin) : pin; | ||
}); | ||
@@ -596,3 +579,3 @@ // TODO: review - this feels like a hack | ||
if (null == liveclient) { | ||
return sd.die(private$.error('transport_client_null', Common.clean(config))); | ||
return sd.die(private$.error('transport_client_null', (0, common_1.clean)(config))); | ||
} | ||
@@ -693,3 +676,3 @@ sendclient = liveclient; | ||
// cleanup process event listeners | ||
Common.each(options.system.close_signals, function (active, signal) { | ||
(0, common_1.each)(options.system.close_signals, function (active, signal) { | ||
if (active) { | ||
@@ -723,3 +706,3 @@ process.removeListener(signal, seneca.private$.exit_close); | ||
function (origargs, patargs, msgargs, custom) { | ||
var args = Common.parsePattern(this, origargs, 'rest:.*', patargs); | ||
var args = (0, common_1.parsePattern)(this, origargs, 'rest:.*', patargs); | ||
var fixargs = [args.pattern] | ||
@@ -726,0 +709,0 @@ .concat({ |
@@ -1,11 +0,22 @@ | ||
/* Copyright © 2010-2022 Richard Rodger and other contributors, MIT License. */ | ||
/* Copyright © 2010-2023 Richard Rodger and other contributors, MIT License. */ | ||
var Jsonic = require('jsonic') | ||
var Norma = require('norma') | ||
const Norma = require('norma') | ||
var Common = require('./common') | ||
import { | ||
each, | ||
make_standard_err_log_entry, | ||
make_callpoint, | ||
promiser, | ||
error as common_error, | ||
jsonic_stringify, | ||
make_plugin_key, | ||
pincanon, | ||
pattern, | ||
clean, | ||
parsePattern, | ||
} from './common' | ||
var errlog = Common.make_standard_err_log_entry | ||
const errlog = make_standard_err_log_entry | ||
var intern: any = {} | ||
const intern: any = {} | ||
@@ -20,4 +31,4 @@ | ||
pin = Array.isArray(pin) ? pin : [pin] | ||
Common.each(pin, function(p: any) { | ||
Common.each(pinthis.list(p), function(actpattern: any) { | ||
each(pin, function(p: any) { | ||
each(pinthis.list(p), function(actpattern: any) { | ||
pinthis.add(actpattern, wrapper, actdef) | ||
@@ -34,3 +45,3 @@ }) | ||
patargs = Jsonic(patargs || {}) | ||
patargs = self.util.Jsonic(patargs || {}) | ||
@@ -97,3 +108,3 @@ var fix_delegate = self.delegate(patargs) | ||
if (out_opts.debug.callpoint) { | ||
private$.callpoint = Common.make_callpoint(out_opts.debug.callpoint) | ||
private$.callpoint = make_callpoint(out_opts.debug.callpoint) | ||
} | ||
@@ -124,3 +135,3 @@ | ||
if (false !== done && null == done) { | ||
return Common.promiser(intern.close.bind(seneca, callpoint)) | ||
return promiser(intern.close.bind(seneca, callpoint)) | ||
} | ||
@@ -178,3 +189,3 @@ | ||
} else { | ||
error = Common.eraro.apply(this, arguments) | ||
error = common_error.apply(this, arguments) | ||
} | ||
@@ -271,3 +282,3 @@ | ||
self.toString() + | ||
(Object.keys(vfa).length ? '/' + Jsonic.stringify(vfa) : '') | ||
(Object.keys(vfa).length ? '/' + jsonic_stringify(vfa) : '') | ||
@@ -309,13 +320,2 @@ return strdesc | ||
// 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 | ||
@@ -460,4 +460,4 @@ } | ||
function translate(this: any, from_in: any, to_in: any, pick_in: any) { | ||
var from = 'string' === typeof from_in ? Jsonic(from_in) : from_in | ||
var to = 'string' === typeof to_in ? Jsonic(to_in) : to_in | ||
var from = 'string' === typeof from_in ? this.util.Jsonic(from_in) : from_in | ||
var to = 'string' === typeof to_in ? this.util.Jsonic(to_in) : to_in | ||
@@ -524,3 +524,3 @@ var pick: any = {} | ||
function find_plugin(this: any, plugindesc: any, tag: any) { | ||
var plugin_key = Common.make_plugin_key(plugindesc, tag) | ||
var plugin_key = make_plugin_key(plugindesc, tag) | ||
return this.private$.plugins[plugin_key] | ||
@@ -531,3 +531,3 @@ } | ||
function has_plugin(this: any, plugindesc: any, tag: any) { | ||
var plugin_key = Common.make_plugin_key(plugindesc, tag) | ||
var plugin_key = make_plugin_key(plugindesc, tag) | ||
return !!this.private$.plugins[plugin_key] | ||
@@ -542,3 +542,3 @@ } | ||
} | ||
var plugin_key = Common.make_plugin_key(plugindesc, tag) | ||
var plugin_key = make_plugin_key(plugindesc, tag) | ||
var resolved_ignore = (this.private$.ignore_plugins[plugin_key] = | ||
@@ -562,3 +562,3 @@ null == ignore ? true : !!ignore) | ||
var pat = 'string' === typeof pattern ? Jsonic(pattern) : pattern | ||
var pat = 'string' === typeof pattern ? seneca.util.Jsonic(pattern) : pattern | ||
pat = seneca.util.clean(pat) | ||
@@ -586,11 +586,4 @@ pat = pat || {} | ||
return this.private$.actrouter | ||
.list(null == pattern ? {} : Jsonic(pattern)) | ||
.list(null == pattern ? {} : this.util.Jsonic(pattern)) | ||
.map((x: any) => x.match) | ||
/* | ||
return _.map( | ||
this.private$.actrouter.list(null == pattern ? {} : Jsonic(pattern)), | ||
'match' | ||
) | ||
*/ | ||
} | ||
@@ -694,7 +687,7 @@ | ||
// pg: pin group | ||
raw_config.pg = Common.pincanon(raw_config.pin || raw_config.pins) | ||
raw_config.pg = pincanon(raw_config.pin || raw_config.pins) | ||
var config = intern.resolve_config(raw_config, opts) | ||
config.id = config.id || Common.pattern(raw_config) | ||
config.id = config.id || pattern(raw_config) | ||
@@ -706,3 +699,3 @@ var pins = | ||
pins = pins.map((pin: any) => { | ||
return 'string' === typeof pin ? Jsonic(pin) : pin | ||
return 'string' === typeof pin ? self.util.Jsonic(pin) : pin | ||
}) | ||
@@ -787,3 +780,3 @@ | ||
return sd.die( | ||
private$.error('transport_client_null', Common.clean(config)) | ||
private$.error('transport_client_null', clean(config)) | ||
) | ||
@@ -915,3 +908,3 @@ } | ||
// cleanup process event listeners | ||
Common.each(options.system.close_signals, function(active: any, signal: any) { | ||
each(options.system.close_signals, function(active: any, signal: any) { | ||
if (active) { | ||
@@ -953,3 +946,3 @@ process.removeListener(signal, seneca.private$.exit_close) | ||
function(this: any, origargs: any, patargs: any, msgargs: any, custom: any) { | ||
var args = Common.parsePattern(this, origargs, 'rest:.*', patargs) | ||
var args = parsePattern(this, origargs, 'rest:.*', patargs) | ||
var fixargs = [args.pattern] | ||
@@ -956,0 +949,0 @@ .concat({ |
/// <reference types="node" /> | ||
import Util from 'util'; | ||
declare const error: any; | ||
declare function promiser(context: any, callback: any): Promise<unknown>; | ||
declare function promiser(context: any, callback?: any): Promise<unknown>; | ||
declare function stringify(): any; | ||
@@ -11,3 +11,3 @@ declare function wrap_error(err: any): void; | ||
declare function parse_jsonic(str: any, code: any): any; | ||
declare function parse_pattern(instance: any, rawargs: any, normaspec: any, fixed?: any): any; | ||
declare function parse_pattern(_instance: any, rawargs: any, normaspec: any, fixed?: any): any; | ||
declare const parsePattern: typeof parse_pattern; | ||
@@ -31,2 +31,3 @@ declare function build_message(instance: any, rawargs: any, normaspec: any, fixed: any): any; | ||
declare function msgstr(msg: any, len?: number): string; | ||
declare function jsonic_stringify(val: any, callopts?: any): string; | ||
declare const TRACE_PATTERN = 0; | ||
@@ -60,2 +61,2 @@ declare const TRACE_ID = 1; | ||
} | ||
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, }; | ||
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, jsonic_stringify, 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.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.jsonic_stringify = 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")); | ||
@@ -13,3 +13,3 @@ const errors_1 = __importDefault(require("./errors")); | ||
const Eraro = require('eraro'); | ||
const Jsonic = require('jsonic'); | ||
const Jsonic = require('@jsonic/jsonic-next'); | ||
const nid_1 = __importDefault(require("nid")); | ||
@@ -105,8 +105,7 @@ const Norma = require('norma'); | ||
catch (e) { | ||
let col = 1 === e.line ? e.column - 1 : e.column; | ||
throw error(code, { | ||
argstr: str, | ||
syntax: e.message, | ||
line: e.line, | ||
col: col, | ||
line: e.lineNumber, | ||
col: e.columnNumber, | ||
}); | ||
@@ -118,3 +117,3 @@ } | ||
// TODO: fix name | ||
function parse_pattern(instance, rawargs, normaspec, fixed) { | ||
function parse_pattern(_instance, rawargs, normaspec, fixed) { | ||
let args = Norma('{strargs:s? objargs:o? moreobjargs:o? ' + (normaspec || '') + '}', rawargs); | ||
@@ -290,3 +289,3 @@ // Precedence of arguments in add,act is left-to-right | ||
'\nLOG ::: ' + | ||
Jsonic.stringify(logdesc) + | ||
jsonic_stringify(logdesc) + | ||
'\nNODE ::: ' + | ||
@@ -472,2 +471,91 @@ process.version + | ||
exports.msgstr = msgstr; | ||
function jsonic_strify(val, opts, depth) { | ||
depth++; | ||
if (null == val) | ||
return 'null'; | ||
var type = Object.prototype.toString.call(val).charAt(8); | ||
if ('F' === type && !opts.showfunc) | ||
return null; | ||
// WARNING: output may not be jsonically parsable! | ||
if (opts.custom) { | ||
if (Object.prototype.hasOwnProperty.call(val, 'toString')) { | ||
return val.toString(); | ||
} | ||
else if (Object.prototype.hasOwnProperty.call(val, 'inspect')) { | ||
return val.inspect(); | ||
} | ||
} | ||
var out, i = 0, j, k; | ||
if ('N' === type) { | ||
return isNaN(val) ? 'null' : val.toString(); | ||
} | ||
else if ('O' === type) { | ||
out = []; | ||
if (depth <= opts.depth) { | ||
j = 0; | ||
for (let i in val) { | ||
if (j >= opts.maxitems) | ||
break; | ||
var pass = true; | ||
for (k = 0; k < opts.exclude.length && pass; k++) { | ||
pass = !~i.indexOf(opts.exclude[k]); | ||
} | ||
pass = pass && !opts.omit[i]; | ||
let str = jsonic_strify(val[i], opts, depth); | ||
if (null != str && pass) { | ||
var n = i.match(/^[a-zA-Z0-9_$]+$/) ? i : JSON.stringify(i); | ||
out.push(n + ':' + str); | ||
j++; | ||
} | ||
} | ||
} | ||
return '{' + out.join(',') + '}'; | ||
} | ||
else if ('A' === type) { | ||
out = []; | ||
if (depth <= opts.depth) { | ||
for (; i < val.length && i < opts.maxitems; i++) { | ||
let str = jsonic_strify(val[i], opts, depth); | ||
if (null != str) { | ||
out.push(str); | ||
} | ||
} | ||
} | ||
return '[' + out.join(',') + ']'; | ||
} | ||
else { | ||
var valstr = val.toString(); | ||
if (~" \"'\r\n\t,}]".indexOf(valstr[0]) || | ||
!~valstr.match(/,}]/) || | ||
~" \r\n\t".indexOf(valstr[valstr.length - 1])) { | ||
valstr = "'" + valstr.replace(/'/g, "\\'") + "'"; | ||
} | ||
return valstr; | ||
} | ||
} | ||
// Legacy Jsonic stringify | ||
function jsonic_stringify(val, callopts) { | ||
try { | ||
callopts = callopts || {}; | ||
var opts = {}; | ||
opts.showfunc = callopts.showfunc || callopts.f || false; | ||
opts.custom = callopts.custom || callopts.c || false; | ||
opts.depth = callopts.depth || callopts.d || 3; | ||
opts.maxitems = callopts.maxitems || callopts.mi || 11; | ||
opts.maxchars = callopts.maxchars || callopts.mc || 111; | ||
opts.exclude = callopts.exclude || callopts.x || ['$']; | ||
var omit = callopts.omit || callopts.o || []; | ||
opts.omit = {}; | ||
for (var i = 0; i < omit.length; i++) { | ||
opts.omit[omit[i]] = true; | ||
} | ||
var str = jsonic_strify(val, opts, 0); | ||
str = null == str ? '' : str.substring(0, opts.maxchars); | ||
return str; | ||
} | ||
catch (e) { | ||
return 'ERROR: jsonic_stringify: ' + e + ' input was: ' + JSON.stringify(val); | ||
} | ||
} | ||
exports.jsonic_stringify = jsonic_stringify; | ||
const TRACE_PATTERN = 0; | ||
@@ -474,0 +562,0 @@ exports.TRACE_PATTERN = TRACE_PATTERN; |
@@ -13,3 +13,3 @@ /* Copyright © 2010-2022 Richard Rodger and other contributors, MIT License. */ | ||
const Eraro = require('eraro') | ||
const Jsonic = require('jsonic') | ||
const Jsonic = require('@jsonic/jsonic-next') | ||
import Nid from 'nid' | ||
@@ -35,3 +35,3 @@ const Norma = require('norma') | ||
function promiser(context: any, callback: any) { | ||
function promiser(context: any, callback?: any) { | ||
if ('function' === typeof context && null == callback) { | ||
@@ -127,8 +127,7 @@ callback = context | ||
} catch (e: any) { | ||
let col = 1 === e.line ? e.column - 1 : e.column | ||
throw error(code, { | ||
argstr: str, | ||
syntax: e.message, | ||
line: e.line, | ||
col: col, | ||
line: e.lineNumber, | ||
col: e.columnNumber, | ||
}) | ||
@@ -143,3 +142,3 @@ } | ||
function parse_pattern( | ||
instance: any, | ||
_instance: any, | ||
rawargs: any, | ||
@@ -378,3 +377,3 @@ normaspec: any, | ||
'\nLOG ::: ' + | ||
Jsonic.stringify(logdesc) + | ||
jsonic_stringify(logdesc) + | ||
'\nNODE ::: ' + | ||
@@ -604,2 +603,106 @@ process.version + | ||
function jsonic_strify(val: any, opts: any, depth: number) { | ||
depth++ | ||
if (null == val) return 'null' | ||
var type = Object.prototype.toString.call(val).charAt(8) | ||
if ('F' === type && !opts.showfunc) return null | ||
// WARNING: output may not be jsonically parsable! | ||
if (opts.custom) { | ||
if (Object.prototype.hasOwnProperty.call(val, 'toString')) { | ||
return val.toString() | ||
} | ||
else if (Object.prototype.hasOwnProperty.call(val, 'inspect')) { | ||
return val.inspect() | ||
} | ||
} | ||
var out, i = 0, j, k | ||
if ('N' === type) { | ||
return isNaN(val) ? 'null' : val.toString() | ||
} | ||
else if ('O' === type) { | ||
out = [] | ||
if (depth <= opts.depth) { | ||
j = 0 | ||
for (let i in val) { | ||
if (j >= opts.maxitems) break | ||
var pass = true | ||
for (k = 0; k < opts.exclude.length && pass; k++) { | ||
pass = !~i.indexOf(opts.exclude[k]) | ||
} | ||
pass = pass && !opts.omit[i] | ||
let str: string = jsonic_strify(val[i], opts, depth) | ||
if (null != str && pass) { | ||
var n = i.match(/^[a-zA-Z0-9_$]+$/) ? i : JSON.stringify(i) | ||
out.push(n + ':' + str) | ||
j++ | ||
} | ||
} | ||
} | ||
return '{' + out.join(',') + '}' | ||
} | ||
else if ('A' === type) { | ||
out = [] | ||
if (depth <= opts.depth) { | ||
for (; i < val.length && i < opts.maxitems; i++) { | ||
let str: string = jsonic_strify(val[i], opts, depth) | ||
if (null != str) { | ||
out.push(str) | ||
} | ||
} | ||
} | ||
return '[' + out.join(',') + ']' | ||
} | ||
else { | ||
var valstr = val.toString() | ||
if (~" \"'\r\n\t,}]".indexOf(valstr[0]) || | ||
!~valstr.match(/,}]/) || | ||
~" \r\n\t".indexOf(valstr[valstr.length - 1])) { | ||
valstr = "'" + valstr.replace(/'/g, "\\'") + "'" | ||
} | ||
return valstr | ||
} | ||
} | ||
// Legacy Jsonic stringify | ||
function jsonic_stringify(val: any, callopts?: any) { | ||
try { | ||
callopts = callopts || {} | ||
var opts: any = {} | ||
opts.showfunc = callopts.showfunc || callopts.f || false | ||
opts.custom = callopts.custom || callopts.c || false | ||
opts.depth = callopts.depth || callopts.d || 3 | ||
opts.maxitems = callopts.maxitems || callopts.mi || 11 | ||
opts.maxchars = callopts.maxchars || callopts.mc || 111 | ||
opts.exclude = callopts.exclude || callopts.x || ['$'] | ||
var omit = callopts.omit || callopts.o || [] | ||
opts.omit = {} | ||
for (var i = 0; i < omit.length; i++) { | ||
opts.omit[omit[i]] = true; | ||
} | ||
var str: string = jsonic_strify(val, opts, 0) | ||
str = null == str ? '' : str.substring(0, opts.maxchars) | ||
return str | ||
} | ||
catch (e) { | ||
return 'ERROR: jsonic_stringify: ' + e + ' input was: ' + JSON.stringify(val) | ||
} | ||
} | ||
const TRACE_PATTERN = 0 | ||
@@ -755,2 +858,3 @@ const TRACE_ID = 1 | ||
msgstr, | ||
jsonic_stringify, | ||
TRACE_PATTERN, | ||
@@ -757,0 +861,0 @@ TRACE_ID, |
@@ -13,3 +13,3 @@ "use strict"; | ||
const Norma = require('norma'); | ||
const Jsonic = require('jsonic'); | ||
const Jsonic = require('@jsonic/jsonic-next'); | ||
const Common = require('./common'); | ||
@@ -16,0 +16,0 @@ const internals = { |
@@ -12,3 +12,3 @@ /* Copyright © 2010-2022 Richard Rodger and other contributors, MIT License. */ | ||
const Norma = require('norma') | ||
const Jsonic = require('jsonic') | ||
const Jsonic = require('@jsonic/jsonic-next') | ||
@@ -15,0 +15,0 @@ const Common = require('./common') |
@@ -380,5 +380,6 @@ "use strict"; | ||
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) + '...'); | ||
.replace(/\s+/g, ''); | ||
// .substring(0, datalen) | ||
logb.push(datastr.length <= datalen ? | ||
datastr : datastr.substring(0, datalen) + '...'); | ||
} | ||
@@ -385,0 +386,0 @@ if (data.did) { |
@@ -458,4 +458,5 @@ /* Copyright © 2016-2022 Richard Rodger and other contributors, MIT License. */ | ||
.replace(/\s+/g, '') | ||
.substring(0, datalen) | ||
logb.push(datastr.length <= 111 ? datastr : datastr.substring(0, 111) + '...') | ||
// .substring(0, datalen) | ||
logb.push(datastr.length <= datalen ? | ||
datastr : datastr.substring(0, datalen) + '...') | ||
} | ||
@@ -462,0 +463,0 @@ |
@@ -11,3 +11,3 @@ "use strict"; | ||
const Eraro = require('eraro'); | ||
const Jsonic = require('jsonic'); | ||
const Jsonic = require('@jsonic/jsonic-next'); | ||
const Minimist = require('minimist'); | ||
@@ -14,0 +14,0 @@ const { Gubu } = require('gubu'); |
@@ -8,3 +8,3 @@ /* Copyright © 2014-2022 Richard Rodger and other contributors, MIT License. */ | ||
const Eraro = require('eraro') | ||
const Jsonic = require('jsonic') | ||
const Jsonic = require('@jsonic/jsonic-next') | ||
const Minimist = require('minimist') | ||
@@ -11,0 +11,0 @@ const { Gubu } = require('gubu') |
@@ -13,3 +13,3 @@ "use strict"; | ||
const Url = require('url'); | ||
const Jsonic = require('jsonic'); | ||
const Jsonic = require('@jsonic/jsonic-next'); | ||
const Wreck = require('@hapi/wreck'); | ||
@@ -16,0 +16,0 @@ const Common = require('./common'); |
@@ -11,3 +11,3 @@ /* Copyright © 2015-2022 Richard Rodger and other contributors, MIT License. */ | ||
const Jsonic = require('jsonic') | ||
const Jsonic = require('@jsonic/jsonic-next') | ||
const Wreck = require('@hapi/wreck') | ||
@@ -14,0 +14,0 @@ const Common = require('./common') |
{ | ||
"name": "seneca", | ||
"description": "A Microservices Framework for Node.js", | ||
"version": "3.30.0", | ||
"version": "3.30.1", | ||
"license": "MIT", | ||
@@ -89,7 +89,7 @@ "homepage": "http://senecajs.org", | ||
"@hapi/wreck": "17", | ||
"@jsonic/jsonic-next": "2.9.1", | ||
"eraro": "^2.1.0", | ||
"fast-safe-stringify": "^2.1.1", | ||
"gate-executor": "^3.1.1", | ||
"gubu": "^4.0.0", | ||
"jsonic": "^1.0.1", | ||
"gubu": "5.0.1", | ||
"lodash.defaultsdeep": "^4.6.1", | ||
@@ -104,5 +104,5 @@ "lodash.flatten": "^4.4.0", | ||
"patrun": "^7.2.5", | ||
"qs": "^6.11.0", | ||
"qs": "^6.11.2", | ||
"rolling-stats": "^0.2.1", | ||
"seneca-transport": "^7.2.0", | ||
"seneca-transport": "^8.0.0", | ||
"use-plugin": "9" | ||
@@ -114,3 +114,3 @@ }, | ||
"@seneca/test-plugin": "0.1.0", | ||
"@types/node": "^18.13.0", | ||
"@types/node": "^20.2.5", | ||
"async": "^3.2.4", | ||
@@ -123,4 +123,4 @@ "bench": "^0.3.6", | ||
"lolex": "^6.0.0", | ||
"prettier": "^2.8.4", | ||
"seneca-entity": "^19.0.0", | ||
"prettier": "^2.8.8", | ||
"seneca-entity": "^22.0.0", | ||
"seneca-error-test": "^0.2.2", | ||
@@ -130,4 +130,4 @@ "seneca-joi": "^7.0.2", | ||
"summary": "^2.1.0", | ||
"typescript": "^4.9.5" | ||
"typescript": "^5.0.4" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
/* Copyright © 2010-2022 Richard Rodger and other contributors, MIT License. */ | ||
/* Copyright © 2010-2023 Richard Rodger and other contributors, MIT License. */ | ||
'use strict'; | ||
@@ -12,3 +12,3 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | ||
const GateExecutor = require('gate-executor'); | ||
const Jsonic = require('jsonic'); | ||
const Jsonic = require('@jsonic/jsonic-next'); | ||
const UsePlugin = require('use-plugin'); | ||
@@ -34,10 +34,10 @@ const nid_1 = __importDefault(require("nid")); | ||
const plugin_1 = require("./lib/plugin"); | ||
const { Inward } = require('./lib/inward'); | ||
const { Outward } = require('./lib/outward'); | ||
const inward_1 = require("./lib/inward"); | ||
const outward_1 = require("./lib/outward"); | ||
const { Legacy } = require('./lib/legacy'); | ||
const { resolve_options } = require('./lib/options'); | ||
const Package = require('./package.json'); | ||
const { Print } = require('./lib/print'); | ||
const { addActions } = require('./lib/actions'); | ||
const { transport } = require('./lib/transport'); | ||
const package_json_1 = __importDefault(require("./package.json")); | ||
// Internal data and utilities. | ||
@@ -449,5 +449,6 @@ const { error, deep } = Common; | ||
root$.context = {}; | ||
root$.version = Package.version; | ||
root$.version = package_json_1.default.version; | ||
// TODO: rename in 4.x as "args" terminology is legacy | ||
root$.fixedargs = {}; | ||
root$.fixedmeta = {}; | ||
root$.flags = { | ||
@@ -623,15 +624,15 @@ closed: false, | ||
}) | ||
.add(Inward.inward_msg_modify) | ||
.add(Inward.inward_closed) | ||
.add(Inward.inward_act_cache) | ||
.add(Inward.inward_act_default) | ||
.add(Inward.inward_act_not_found) | ||
.add(Inward.inward_act_stats) | ||
.add(Inward.inward_validate_msg) | ||
.add(Inward.inward_warnings) | ||
.add(Inward.inward_msg_meta) | ||
.add(Inward.inward_limit_msg) | ||
.add(Inward.inward_prepare_delegate) | ||
.add(Inward.inward_sub) | ||
.add(Inward.inward_announce); | ||
.add(inward_1.Inward.inward_msg_modify) | ||
.add(inward_1.Inward.inward_closed) | ||
.add(inward_1.Inward.inward_act_cache) | ||
.add(inward_1.Inward.inward_act_default) | ||
.add(inward_1.Inward.inward_act_not_found) | ||
.add(inward_1.Inward.inward_act_stats) | ||
.add(inward_1.Inward.inward_validate_msg) | ||
.add(inward_1.Inward.inward_warnings) | ||
.add(inward_1.Inward.inward_msg_meta) | ||
.add(inward_1.Inward.inward_limit_msg) | ||
.add(inward_1.Inward.inward_prepare_delegate) | ||
.add(inward_1.Inward.inward_sub) | ||
.add(inward_1.Inward.inward_announce); | ||
root$.order.outward = new Ordu({ | ||
@@ -641,12 +642,12 @@ name: 'outward', | ||
}) | ||
.add(Outward.outward_make_error) | ||
.add(Outward.outward_act_stats) | ||
.add(Outward.outward_act_cache) | ||
.add(Outward.outward_res_object) | ||
.add(Outward.outward_res_entity) | ||
.add(Outward.outward_msg_meta) | ||
.add(Outward.outward_trace) | ||
.add(Outward.outward_sub) | ||
.add(Outward.outward_announce) | ||
.add(Outward.outward_act_error); | ||
.add(outward_1.Outward.outward_make_error) | ||
.add(outward_1.Outward.outward_act_stats) | ||
.add(outward_1.Outward.outward_act_cache) | ||
.add(outward_1.Outward.outward_res_object) | ||
.add(outward_1.Outward.outward_res_entity) | ||
.add(outward_1.Outward.outward_msg_meta) | ||
.add(outward_1.Outward.outward_trace) | ||
.add(outward_1.Outward.outward_sub) | ||
.add(outward_1.Outward.outward_announce) | ||
.add(outward_1.Outward.outward_act_error); | ||
// Configure logging | ||
@@ -653,0 +654,0 @@ // Mark logger as being externally defined from options |
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
618576
78
11964
+ Added@jsonic/jsonic-next@2.9.1
+ Added@jsonic/jsonic-next@2.9.1(transitive)
+ Addederaro@3.0.1(transitive)
+ Addedgubu@5.0.18.3.0(transitive)
+ Addedlru-cache@8.0.5(transitive)
+ Addedseneca-entity@28.1.0(transitive)
+ Addedseneca-mem-store@9.4.0(transitive)
+ Addedseneca-promisify@3.7.2(transitive)
+ Addedseneca-transport@8.3.0(transitive)
- Removedjsonic@^1.0.1
- Removedgex@3.1.0(transitive)
- Removedgubu@4.0.0(transitive)
- Removedjsonic@1.0.1(transitive)
- Removedlru-cache@7.18.3(transitive)
- Removedseneca-transport@7.2.0(transitive)
Updatedgubu@5.0.1
Updatedqs@^6.11.2
Updatedseneca-transport@^8.0.0