From fdd21a4e7e3cd07c7d90238e74e5d05329abd979 Mon Sep 17 00:00:00 2001 From: rjrodger Date: Sat, 16 May 2020 13:49:59 +0100 Subject: [PATCH] plugin options task --- lib/use.js | 122 +- lib/use.js.map | 2 +- lib/use.ts | 291 ++- test/coverage.html | 4108 ++++++++++++++++++++++++------------------- test/plugin.test.js | 16 +- 5 files changed, 2543 insertions(+), 1996 deletions(-) diff --git a/lib/use.js b/lib/use.js index 80a5b3fc..0f965874 100644 --- a/lib/use.js +++ b/lib/use.js @@ -17,18 +17,20 @@ function api_use(callpoint) { const ordu = new ordu_1.Ordu({ debug: true }); ordu.operator('seneca_plugin', tasks.op.seneca_plugin); ordu.operator('seneca_export', tasks.op.seneca_export); + ordu.operator('seneca_options', tasks.op.seneca_options); + // TODO: exports -> meta and handle all meta processing ordu.add([ tasks.args, tasks.load, tasks.normalize, tasks.preload, - { name: 'pre_exports', exec: tasks.exports }, + { name: 'pre_meta', exec: tasks.meta }, { name: 'pre_legacy_extend', exec: tasks.legacy_extend }, tasks.delegate, - //intern.options, tasks.call_define, + tasks.options, tasks.define, - { name: 'post_exports', exec: tasks.exports }, + { name: 'post_meta', exec: tasks.meta }, { name: 'post_legacy_extend', exec: tasks.legacy_extend }, function complete() { //console.log('COMPLETE') @@ -57,7 +59,7 @@ function make_use(ordu, callpoint) { meta: null, delegate: null, plugin_done: null, - exports: {} + exports: {}, }; async function run() { // NOTE: don't wait for result! @@ -82,18 +84,27 @@ function make_use(ordu, callpoint) { } function make_tasks() { return { + // TODO: explicit tests for these operators op: { seneca_plugin: (tr, ctx, data) => { nua_1.default(data, tr.out.merge, { preserve: true }); ctx.seneca.private$.plugins[data.plugin.fullname] = tr.out.plugin; return { stop: false }; }, - // TODO: explicit test for exports needed seneca_export: (tr, ctx, data) => { Object.assign(data.exports, tr.out.exports); Object.assign(ctx.seneca.private$.exports, tr.out.exports); return { stop: false }; - } + }, + seneca_options: (tr, ctx, data) => { + nua_1.default(data.plugin.options, tr.out.plugin.options, { preserve: true }); + let plugin_fullname = data.plugin.fullname; + let plugin_options = data.plugin.options; + let plugin_options_update = { plugin: {} }; + plugin_options_update.plugin[plugin_fullname] = plugin_options; + ctx.seneca.options(plugin_options_update); + return { stop: false }; + }, }, args: (spec) => { let args = [...spec.ctx.args]; @@ -197,7 +208,7 @@ function make_tasks() { } }; }, - exports: (spec) => { + meta: (spec) => { let plugin = spec.data.plugin; let meta = spec.data.meta; let exports = {}; @@ -346,20 +357,64 @@ function make_tasks() { }); }); }, + options: (spec) => { + let seneca = spec.ctx.seneca; + let plugin = spec.data.plugin; + //let options = resolve_options(plugin.fullname, plugin, seneca) + let so = seneca.options(); + let fullname = plugin.fullname; + let defaults = plugin.defaults || {}; + let fullname_options = Object.assign({}, + // DEPRECATED: remove in 4 + so[fullname], so.plugin[fullname], + // DEPRECATED: remove in 4 + so[fullname + '$' + plugin.tag], so.plugin[fullname + '$' + plugin.tag]); + var shortname = fullname !== plugin.name ? plugin.name : null; + if (!shortname && fullname.indexOf('seneca-') === 0) { + shortname = fullname.substring('seneca-'.length); + } + var shortname_options = Object.assign({}, + // DEPRECATED: remove in 4 + so[shortname], so.plugin[shortname], + // DEPRECATED: remove in 4 + so[shortname + '$' + plugin.tag], so.plugin[shortname + '$' + plugin.tag]); + let base = {}; + // NOTE: plugin error codes are in their own namespaces + let errors = plugin.errors || (plugin.define && plugin.define.errors); + if (errors) { + base.errors = errors; + } + let outopts = Object.assign(base, shortname_options, fullname_options, plugin.options || {}); + let resolved_options = {}; + try { + resolved_options = seneca.util + .Optioner(defaults, { allow_unknown: true }) + .check(outopts); + } + catch (e) { + throw Common.error('invalid_plugin_option', { + name: fullname, + err_msg: e.message, + options: outopts, + }); + } + //let options = { ...plugin.options, ...resolved_options } + return { + op: 'seneca_options', + out: { + plugin: { + options: resolved_options + } + } + }; + }, define: (spec) => { let seneca = spec.ctx.seneca; let so = seneca.options(); let plugin = spec.data.plugin; let plugin_done = spec.data.plugin_done; - //return new Promise((resolve) => { var plugin_seneca = spec.data.delegate; - var plugin_options = resolve_options(plugin.fullname, plugin, seneca); - // Update stored plugin options (NOTE . != _ !!!) - plugin.options = { ...plugin.options, ...plugin_options }; - // Update plugin options data in Seneca options. - var seneca_options = { plugin: {} }; - seneca_options.plugin[plugin.fullname] = plugin.options; - seneca.options(seneca_options); + var plugin_options = spec.data.plugin.options; plugin_seneca.log.debug({ kind: 'plugin', case: 'DEFINE', @@ -458,43 +513,6 @@ function make_tasks() { }, }; } -function resolve_options(fullname, plugindef, seneca) { - var so = seneca.options(); - var defaults = plugindef.defaults || {}; - var fullname_options = Object.assign({}, - // DEPRECATED: remove in 4 - so[fullname], so.plugin[fullname], - // DEPRECATED: remove in 4 - so[fullname + '$' + plugindef.tag], so.plugin[fullname + '$' + plugindef.tag]); - var shortname = fullname !== plugindef.name ? plugindef.name : null; - if (!shortname && fullname.indexOf('seneca-') === 0) { - shortname = fullname.substring('seneca-'.length); - } - var shortname_options = Object.assign({}, - // DEPRECATED: remove in 4 - so[shortname], so.plugin[shortname], - // DEPRECATED: remove in 4 - so[shortname + '$' + plugindef.tag], so.plugin[shortname + '$' + plugindef.tag]); - var base = {}; - // NOTE: plugin error codes are in their own namespaces - var errors = plugindef.errors || (plugindef.define && plugindef.define.errors); - if (errors) { - base.errors = errors; - } - var outopts = Object.assign(base, shortname_options, fullname_options, plugindef.options || {}); - try { - return seneca.util - .Optioner(defaults, { allow_unknown: true }) - .check(outopts); - } - catch (e) { - throw Common.error('invalid_plugin_option', { - name: fullname, - err_msg: e.message, - options: outopts, - }); - } -} function define_plugin(delegate, plugin, options) { // legacy plugins if (plugin.define.length > 1) { diff --git a/lib/use.js.map b/lib/use.js.map index 2ff6c6e4..66348ed4 100644 --- a/lib/use.js.map +++ b/lib/use.js.map @@ -1 +1 @@ -{"version":3,"file":"use.js","sourceRoot":"","sources":["use.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,YAAY,CAAA;;;;;AAIZ,MAAM,IAAI,GAAQ,OAAO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,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,CAAA;KACnD;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,sBAAsB,EAAE;YAC3C,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,OAAO,EAAE,CACP,CAAC,CAAC,OAAO,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CACrE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,EAAE;SACvD,CAAC,CAAA;KACH;IAED,IAAI,GAAG,QAAQ,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;IACvD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,OAAO,CAAA;IAEtC,IAAI,eAAe,GAAQ,EAAE,CAAA;IAC7B,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,OAAO,CAAA;IAC/C,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;IAEjC,OAAO,IAAI,CAAA;AACb,CAAC"} \ No newline at end of file diff --git a/lib/use.ts b/lib/use.ts index a68dbcbd..915b7536 100644 --- a/lib/use.ts +++ b/lib/use.ts @@ -24,19 +24,23 @@ function api_use(callpoint: any) { ordu.operator('seneca_plugin', tasks.op.seneca_plugin) ordu.operator('seneca_export', tasks.op.seneca_export) + ordu.operator('seneca_options', tasks.op.seneca_options) + + + // TODO: exports -> meta and handle all meta processing ordu.add([ tasks.args, tasks.load, tasks.normalize, tasks.preload, - { name: 'pre_exports', exec: tasks.exports }, + { name: 'pre_meta', exec: tasks.meta }, { name: 'pre_legacy_extend', exec: tasks.legacy_extend }, tasks.delegate, - //intern.options, tasks.call_define, + tasks.options, tasks.define, - { name: 'post_exports', exec: tasks.exports }, + { name: 'post_meta', exec: tasks.meta }, { name: 'post_legacy_extend', exec: tasks.legacy_extend }, function complete() { //console.log('COMPLETE') @@ -68,6 +72,7 @@ interface UseData { delegate: any plugin_done: any exports: any + //options: any } interface UseSpec { @@ -98,7 +103,8 @@ function make_use(ordu: any, callpoint: any) { meta: null, delegate: null, plugin_done: null, - exports: {} + exports: {}, + //options: {} } async function run() { @@ -129,6 +135,8 @@ function make_use(ordu: any, callpoint: any) { function make_tasks(): any { return { + // TODO: explicit tests for these operators + op: { seneca_plugin: (tr: any, ctx: any, data: any): any => { Nua(data, tr.out.merge, { preserve: true }) @@ -136,12 +144,25 @@ function make_tasks(): any { return { stop: false } }, - // TODO: explicit test for exports needed seneca_export: (tr: any, ctx: any, data: any): any => { Object.assign(data.exports, tr.out.exports) Object.assign(ctx.seneca.private$.exports, tr.out.exports) return { stop: false } - } + }, + + seneca_options: (tr: any, ctx: any, data: any): any => { + Nua(data.plugin.options, tr.out.plugin.options, { preserve: true }) + + let plugin_fullname: string = data.plugin.fullname + let plugin_options = data.plugin.options + + let plugin_options_update: any = { plugin: {} } + plugin_options_update.plugin[plugin_fullname] = plugin_options + + ctx.seneca.options(plugin_options_update) + + return { stop: false } + }, }, args: (spec: UseSpec) => { @@ -274,7 +295,7 @@ function make_tasks(): any { }, - exports: (spec: UseSpec) => { + meta: (spec: UseSpec) => { let plugin: any = spec.data.plugin let meta: any = spec.data.meta @@ -471,6 +492,94 @@ function make_tasks(): any { }, + options: (spec: UseSpec) => { + let seneca: any = spec.ctx.seneca + let plugin: any = spec.data.plugin + + //let options = resolve_options(plugin.fullname, plugin, seneca) + + + let so = seneca.options() + let fullname = plugin.fullname + let defaults = plugin.defaults || {} + + let fullname_options = Object.assign( + {}, + + // DEPRECATED: remove in 4 + so[fullname], + + so.plugin[fullname], + + // DEPRECATED: remove in 4 + so[fullname + '$' + plugin.tag], + + so.plugin[fullname + '$' + plugin.tag] + ) + + var shortname = fullname !== plugin.name ? plugin.name : null + if (!shortname && fullname.indexOf('seneca-') === 0) { + shortname = fullname.substring('seneca-'.length) + } + + var shortname_options = Object.assign( + {}, + + // DEPRECATED: remove in 4 + so[shortname], + + so.plugin[shortname], + + // DEPRECATED: remove in 4 + so[shortname + '$' + plugin.tag], + + so.plugin[shortname + '$' + plugin.tag] + ) + + let base: any = {} + + // NOTE: plugin error codes are in their own namespaces + let errors = plugin.errors || (plugin.define && plugin.define.errors) + + if (errors) { + base.errors = errors + } + + let outopts = Object.assign( + base, + shortname_options, + fullname_options, + plugin.options || {} + ) + + let resolved_options: any = {} + + try { + resolved_options = seneca.util + .Optioner(defaults, { allow_unknown: true }) + .check(outopts) + } catch (e) { + throw Common.error('invalid_plugin_option', { + name: fullname, + err_msg: e.message, + options: outopts, + }) + } + + //let options = { ...plugin.options, ...resolved_options } + + + return { + op: 'seneca_options', + out: { + plugin: { + options: resolved_options + } + } + } + }, + + define: (spec: UseSpec) => { let seneca: any = spec.ctx.seneca let so: any = seneca.options() @@ -478,18 +587,8 @@ function make_tasks(): any { let plugin: any = spec.data.plugin let plugin_done: any = spec.data.plugin_done - - //return new Promise((resolve) => { var plugin_seneca: any = spec.data.delegate - var plugin_options = resolve_options(plugin.fullname, plugin, seneca) - - // Update stored plugin options (NOTE . != _ !!!) - plugin.options = { ...plugin.options, ...plugin_options } - - // Update plugin options data in Seneca options. - var seneca_options: any = { plugin: {} } - seneca_options.plugin[plugin.fullname] = plugin.options - seneca.options(seneca_options) + var plugin_options: any = spec.data.plugin.options plugin_seneca.log.debug({ kind: 'plugin', @@ -506,6 +605,7 @@ function make_tasks(): any { seneca.util.clean(plugin_options) ) + plugin.meta = meta // legacy api for service function @@ -626,73 +726,6 @@ function make_tasks(): any { } } -function resolve_options(fullname: string, plugindef: any, seneca: any): any { - var so = seneca.options() - - var defaults = plugindef.defaults || {} - - var fullname_options = Object.assign( - {}, - - // DEPRECATED: remove in 4 - so[fullname], - - so.plugin[fullname], - - // DEPRECATED: remove in 4 - so[fullname + '$' + plugindef.tag], - - so.plugin[fullname + '$' + plugindef.tag] - ) - - var shortname = fullname !== plugindef.name ? plugindef.name : null - if (!shortname && fullname.indexOf('seneca-') === 0) { - shortname = fullname.substring('seneca-'.length) - } - - var shortname_options = Object.assign( - {}, - - // DEPRECATED: remove in 4 - so[shortname], - - so.plugin[shortname], - - // DEPRECATED: remove in 4 - so[shortname + '$' + plugindef.tag], - - so.plugin[shortname + '$' + plugindef.tag] - ) - - var base: any = {} - - // NOTE: plugin error codes are in their own namespaces - var errors = plugindef.errors || (plugindef.define && plugindef.define.errors) - - if (errors) { - base.errors = errors - } - - var outopts = Object.assign( - base, - shortname_options, - fullname_options, - plugindef.options || {} - ) - - try { - return seneca.util - .Optioner(defaults, { allow_unknown: true }) - .check(outopts) - } catch (e) { - throw Common.error('invalid_plugin_option', { - name: fullname, - err_msg: e.message, - options: outopts, - }) - } -} - function define_plugin(delegate: any, plugin: any, options: any): any { // legacy plugins @@ -736,91 +769,3 @@ function define_plugin(delegate: any, plugin: any, options: any): any { return meta } - -/* -function make_delegate(instance: any, plugin: any): any { - // Adjust Seneca API to be plugin specific. - var delegate = instance.delegate({ - plugin$: { - name: plugin.name, - tag: plugin.tag, - }, - - fatal$: true, - }) - - delegate.private$ = Object.create(instance.private$) - delegate.private$.ge = delegate.private$.ge.gate() - - delegate.die = Common.makedie(delegate, { - type: 'plugin', - plugin: plugin.name, - }) - - var actdeflist: any = [] - - delegate.add = function() { - var argsarr = new Array(arguments.length) - for (var l = 0; l < argsarr.length; ++l) { - argsarr[l] = arguments[l] - } - - var actdef = argsarr[argsarr.length - 1] || {} - - if ('function' === typeof actdef) { - actdef = {} - argsarr.push(actdef) - } - - actdef.plugin_name = plugin.name || '-' - actdef.plugin_tag = plugin.tag || '-' - actdef.plugin_fullname = plugin.fullname - - // TODO: is this necessary? - actdef.log = delegate.log - - actdeflist.push(actdef) - - instance.add.apply(delegate, argsarr) - - return delegate - } - - delegate.__update_plugin__ = function(plugin: any) { - delegate.context.name = plugin.name || '-' - delegate.context.tag = plugin.tag || '-' - delegate.context.full = plugin.fullname || '-' - - actdeflist.forEach(function(actdef: any) { - actdef.plugin_name = plugin.name || actdef.plugin_name || '-' - actdef.plugin_tag = plugin.tag || actdef.plugin_tag || '-' - actdef.plugin_fullname = plugin.fullname || actdef.plugin_fullname || '-' - }) - } - - delegate.init = function(init: any) { - // TODO: validate init_action is function - - var pat: any = { - role: 'seneca', - plugin: 'init', - init: plugin.name, - } - - if (null != plugin.tag && '-' != plugin.tag) { - pat.tag = plugin.tag - } - - delegate.add(pat, function(msg: any, reply: any): any { - init.call(this, reply) - }) - } - - - delegate.context.plugin = plugin - - delegate.context.plugin.mark = Math.random() - - return delegate -} -*/ diff --git a/test/coverage.html b/test/coverage.html index 92ae4b0b..138ae09c 100644 --- a/test/coverage.html +++ b/test/coverage.html @@ -600,7 +600,7 @@ lib/transport.js
  • - 91.16 + 91.50 lib/use.js
  • Linting Report
  • @@ -611,7 +611,7 @@

    Test Report

    0
    0
    341
    -
    34450
    +
    35458
    @@ -712,140 +712,140 @@

    Test Report

    act make_actmsg - 15 + 14 2 act process_outward - 67 + 89 3 actions cmd_ping - 272 + 257 4 actions cmd_stats - 33 + 48 5 actions cmd_close - 131 + 142 6 actions info_fatal - 142 + 128 7 actions get_options - 37 + 42 8 add name - 28 + 24 9 add action_modifier - 122 + 127 10 api error - 4 + 7 11 api fail - 1 + 5 12 api list - 24 + 12 13 api translate - 133 + 137 14 api test-mode - 31 + 34 15 api find_plugin - 146 + 140 16 api has_plugin - 245 + 243 17 api ignore_plugin - 361 + 357 18 api has - 6 + 9 19 api find - 14 + 13 20 api status - 121 + 124 21 @@ -866,35 +866,35 @@

    Test Report

    close happy - 119 + 126 24 close add - 127 + 126 25 close graceful - 233 + 241 26 close timeout - 121 + 123 27 close handle-signal - 122 + 126 28 @@ -908,21 +908,21 @@

    Test Report

    close no-promise - 126 + 124 30 close with-promise - 122 + 127 31 close with-async-await - 121 + 129 32 @@ -936,7 +936,7 @@

    Test Report

    common deepextend-empty - 1 + 0 34 @@ -950,14 +950,14 @@

    Test Report

    common deepextend-objs - 5 + 4 36 common deepextend-objs with functions - 0 + 1 37 @@ -971,7 +971,7 @@

    Test Report

    common nil - 0 + 1 39 @@ -985,14 +985,14 @@

    Test Report

    common pincanon - 0 + 1 41 common history - 5 + 7 42 @@ -1020,14 +1020,14 @@

    Test Report

    custom custom-basic - 21 + 37 46 custom custom-deep - 132 + 134 47 @@ -1041,28 +1041,28 @@

    Test Report

    custom custom-entity - 151 + 159 49 custom custom-prior - 18 + 23 50 custom custom-simple-transport - 143 + 153 51 custom custom-bells-transport - 266 + 269 52 @@ -1076,21 +1076,21 @@

    Test Report

    custom custom-add-fix - 18 + 16 54 debug logroute - 5 + 4 55 delegation happy - 144 + 153 56 @@ -1104,238 +1104,238 @@

    Test Report

    delegation prior.basic - 135 + 133 58 delegation parent.plugin - 151 + 152 59 entity happy - 35 + 36 60 entity entity-msg - 132 + 137 61 entity mem-ops - 181 + 188 62 error fail - 7 + 15 63 error response_is_error - 24 + 27 64 error action_callback - 20 + 21 65 error plugin_load - 16 + 24 66 error act_not_found - 50 + 100 67 error exec_action_throw_basic - 24 + 15 68 error exec_action_throw_basic_legacy - 30 + 33 69 error exec_action_throw_nolog - 11 + 18 70 error exec_action_errhandler_throw - 51 + 55 71 error exec_action_result - 14 + 20 72 error exec_deep_action_result - 24 + 31 73 error exec_remote_action_result - 153 + 148 74 error exec_action_result_legacy - 30 + 32 75 error exec_action_result_nolog - 15 + 20 76 error exec_action_errhandler_result - 64 + 102 77 error action_callback - 170 + 167 78 error legacy_fail - 9 + 11 79 error types - 21 + 22 80 explain explain-basic - 47 + 46 81 explain explain-data - 30 + 40 82 explain explain-deep - 42 + 46 83 explain explain-toplevel - 132 + 127 84 explain explain-transport - 285 + 330 85 exports happy - 123 + 121 86 exports with-init - 120 + 122 87 exports with-preload - 122 + 123 88 exports with-preload-and-init - 122 + 124 89 outward act_error - 1 + 0 90 inward announce - 121 + 119 91 @@ -1349,77 +1349,77 @@

    Test Report

    legacy fail - 0 + 1 93 legacy argprops - 1 + 2 94 legacy router - 0 + 1 95 legacy no-default-transport - 117 + 118 96 legacy actdef - 8 + 9 97 logging happy - 119 + 125 98 logging happy-ng - 121 + 119 99 logging level-text-values - 8 + 7 100 logging build_log_spec - 4 + 2 101 logging event - 132 + 126 102 logging quiet - 118 + 120 103 @@ -1433,70 +1433,70 @@

    Test Report

    logging basic - 120 + 125 105 logging logger-output - 729 + 736 106 logging shortcuts - 1324 + 1326 107 logging test-mode-basic - 121 + 122 108 logging test-mode-option - 123 + 121 109 logging test-mode-argv - 121 + 123 110 logging test-mode-argv-opts - 121 + 124 111 logging test-mode-env - 120 + 125 112 logging quiet-mode-basic - 120 + 128 113 logging quiet-mode-option - 125 + 121 114 @@ -1510,7 +1510,7 @@

    Test Report

    logging quiet-mode-argv-opts - 118 + 119 116 @@ -1524,56 +1524,56 @@

    Test Report

    logging test-quiet-mode-basic - 121 + 122 118 logging quiet-test-mode-basic - 124 + 121 119 logging test-ready-quiet-mode-basic - 231 + 233 120 logging quiet-ready-test-mode-basic - 235 + 234 121 logging quiet-argv-override - 121 + 122 122 logging test-argv-override - 120 + 125 123 logging quiet-env-override - 123 + 121 124 logging test-env-override - 121 + 122 125 @@ -1587,147 +1587,147 @@

    Test Report

    message happy-vanilla - 19 + 22 127 message happy-msg - 22 + 26 128 message loop - 46 + 20 129 message branch - 55 + 30 130 message empty-response - 126 + 124 131 message reply - 120 + 122 132 message prior - 124 + 120 133 message entity - 30 + 38 134 message single-simple-transport - 140 + 145 135 message simple-transport - 587 + 594 136 message partial-patterns - 120 + 121 137 meta custom-parents - 28 + 24 138 meta custom-priors - 27 + 28 139 meta custom-fixed - 24 + 42 140 options strict.find - 7 + 19 141 options internal.routers - 10 + 39 142 outward make_error - 11 + 15 143 outward act_stats - 12 + 17 144 outward arg-check - 3 + 12 145 plugin plugin-internal-ordu - 8 + 11 146 plugin standard-test-plugin - 134 + 166 147 @@ -1741,7 +1741,7 @@

    Test Report

    plugin plugin-ignore-via-options - 122 + 121 149 @@ -1755,7 +1755,7 @@

    Test Report

    plugin plugin-delegate-init - 124 + 125 151 @@ -1769,98 +1769,98 @@

    Test Report

    plugin load-relative-to-root - 129 + 130 153 plugin good-default-options - 121 + 122 154 plugin bad-default-options - 19 + 20 155 plugin legacy-options - 13 + 9 156 plugin should return "no errors created." when passing test false - 391 + 397 157 plugin should return "error caught!" when passing test true - 374 + 375 158 plugin works with exportmap - 121 + 122 159 plugin bad - 128 + 133 160 plugin plugin-error-def - 18 + 23 161 plugin plugin-error-deprecated - 14 + 20 162 plugin plugin-error-add - 11 + 18 163 plugin plugin-error-act - 28 + 23 164 plugin depends - 17 + 36 165 plugin plugin-fix - 186 + 224 166 @@ -1874,147 +1874,147 @@

    Test Report

    plugin handles plugin with action that timesout - 249 + 246 168 plugin handles plugin action that throws an error - 127 + 134 169 plugin calling act from init actor is deprecated - 16 + 20 170 plugin plugin actions receive errors in callback function - 142 + 141 171 plugin dynamic-load-sequence - 355 + 356 172 plugin serial-load-sequence - 124 + 123 173 plugin plugin options can be modified by plugins during load sequence - 123 + 122 174 plugin plugin options can be modified by plugins during init sequence - 126 + 124 175 plugin plugin init can add actions for future init actions to call - 125 + 122 176 plugin plugin-init-error - 18 + 23 177 plugin plugin-extend-action-modifier - 131 + 126 178 plugin plugin-extend-logger - 116 + 118 179 plugin plugins-from-options - 126 + 138 180 plugin plugins-from-bad-options - 12 + 13 181 plugin plugins-options-precedence - 119 + 124 182 plugin error-plugin-define - 13 + 9 183 plugin error-plugin-init - 37 + 16 184 plugin error-plugin-action - 48 + 18 185 plugin no-name - 136 + 130 186 plugin seneca-prefix-wins - 126 + 124 187 print init - 7 + 8 188 @@ -2028,35 +2028,35 @@

    Test Report

    print print - 8 + 7 190 print custom-print - 13 + 12 191 prior happy - 32 + 44 192 prior top-level - 6 + 8 193 prior add-general-to-specific - 31 + 37 194 @@ -2070,112 +2070,112 @@

    Test Report

    prior add-specific-to-general - 12 + 18 196 prior add-strict-specific-to-general - 18 + 16 197 prior add-general-to-specific-alpha - 20 + 47 198 prior add-general-to-specific-reverse-alpha - 25 + 52 199 prior add-strict-default - 23 + 17 200 prior add-strict-true - 23 + 19 201 private exit_close - 368 + 372 202 ready ready_die - 119 + 118 203 ready ready_die_no_errhandler - 121 + 120 204 ready ready_null_name - 118 + 116 205 ready ready-complex - 264 + 267 206 ready ready-always-called - 230 + 229 207 ready ready-error-test - 121 + 120 208 ready ready-event - 15 + 14 209 ready ready-both - 117 + 118 210 seneca --seneca.log arguments tests: --seneca.log=level:warn - 6 + 5 211 @@ -2189,161 +2189,161 @@

    Test Report

    seneca --seneca.log arguments tests: --seneca.log.level.warn - 10 + 15 213 seneca --seneca.log arguments tests: --seneca.log.level.warn+ - 17 + 28 214 seneca --seneca.log arguments tests: duplicate param --seneca.log - 24 + 20 215 seneca --seneca.log arguments tests: incorrect arg --seneca.log=level: - 14 + 59 216 seneca --seneca.log arguments tests: incorrect arg --seneca.log.level.abc - 14 + 15 217 seneca --seneca.log arguments tests: incorrect arg --seneca.log.abc - 9 + 6 218 seneca --seneca.log aliases tests: --seneca.log.quiet - 12 + 18 219 seneca --seneca.log aliases tests: --seneca.log.silent - 17 + 16 220 seneca --seneca.log aliases tests: --seneca.log.all - 14 + 21 221 seneca --seneca.log aliases tests: --seneca.log.any - 12 + 13 222 seneca --seneca.log aliases tests: --seneca.log.print - 16 + 26 223 seneca --seneca.log aliases tests: --seneca.log.test - 12 + 22 224 seneca --seneca.log aliases tests: --seneca.log.standard - 15 + 27 225 seneca --seneca.log aliases tests: --seneca.log.level.quiet - 17 + 19 226 seneca --seneca.log aliases tests: --seneca.log.level.silent - 39 + 16 227 seneca --seneca.log aliases tests: --seneca.log.level.all - 44 + 22 228 seneca --seneca.log aliases tests: --seneca.log.level.any - 25 + 19 229 seneca --seneca.log aliases tests: --seneca.log.level.print - 19 + 24 230 seneca --seneca.log aliases tests: --seneca.log.level.test - 14 + 22 231 seneca --seneca.log aliases tests: --seneca.log.level.standard - 10 + 12 232 seneca happy - 33 + 35 233 seneca require-abbrev - 237 + 244 234 seneca version - 7 + 6 235 @@ -2357,238 +2357,238 @@

    Test Report

    seneca json-inspect - 14 + 13 237 seneca quick - 32 + 41 238 seneca happy-error - 16 + 35 239 seneca errhandler - 108 + 119 240 seneca action-basic - 19 + 16 241 seneca action-callback-instance - 10 + 12 242 seneca action-act-invalid-args - 17 + 20 243 seneca action-default - 17 + 22 244 seneca action-override - 127 + 128 245 seneca action-callback-args - 16 + 12 246 seneca action-extend - 125 + 124 247 seneca prior-nocache - 343 + 344 248 seneca gating - 122 + 119 249 seneca act_if - 30 + 33 250 seneca loading-plugins - 139 + 148 251 seneca fire-and-forget - 11 + 8 252 seneca strargs - 27 + 31 253 seneca string-add - 18 + 37 254 seneca fix-basic - 6 + 16 255 seneca act-history - 54 + 72 256 seneca wrap - 52 + 84 257 seneca meta - 21 + 36 258 seneca strict-result - 10 + 9 259 seneca add-noop - 13 + 29 260 seneca supports jsonic params to has - 9 + 13 261 seneca supports a function to trace actions - 31 + 39 262 seneca supports true to be passed as trace action option - 18 + 29 263 seneca strict-find-false - 15 + 16 264 seneca strict-find-true - 28 + 17 265 seneca strict-find-default - 39 + 20 266 seneca catchall-pattern - 134 + 124 267 seneca memory - 341 + 419 268 seneca use-shortcut - 25 + 20 269 seneca status-log - 10 + 12 270 @@ -2602,14 +2602,14 @@

    Test Report

    seneca pattern-types - 123 + 125 272 seneca order - 6 + 9 273 @@ -2630,70 +2630,70 @@

    Test Report

    seneca #decorate cannot overwrite a decorated property - 16 + 21 276 seneca #decorate cannot prefix a property with an underscore - 13 + 16 277 seneca #intercept intercept - 33 + 32 278 sequence single-add-act - 18 + 19 279 sequence double-add-act - 17 + 26 280 sequence single-add-act-ready - 124 + 128 281 sequence single-add-act-gate-action - 14 + 17 282 sequence single-add-act-gate-instance - 17 + 12 283 smoke seneca-smoke - 14 + 15 284 options options-happy - 122 + 128 285 @@ -2707,14 +2707,14 @@

    Test Report

    options options-legacy - 119 + 126 287 options options-file-js - 124 + 122 288 @@ -2735,7 +2735,7 @@

    Test Report

    options options-file-json-nomore - 119 + 120 291 @@ -2749,63 +2749,63 @@

    Test Report

    options options-cmdline - 124 + 123 293 sub happy-sub - 19 + 24 294 sub inwards-outwards-sub - 27 + 34 295 sub specific-sub - 22 + 28 296 sub error-sub - 19 + 18 297 sub mixed-sub - 22 + 70 298 sub sub-prior - 123 + 146 299 sub sub-close - 122 + 128 300 sub sub-fix - 14 + 17 301 @@ -2819,161 +2819,161 @@

    Test Report

    timeout error-handler - 120 + 124 303 timeout should accept a timeout value from options - 239 + 235 304 transport happy-nextgen - 380 + 400 305 transport config-legacy-nextgen - 481 + 483 306 transport error-nextgen - 364 + 366 307 transport interop-nextgen - 268 + 264 308 transport config-nextgen - 499 + 497 309 transport nextgen-transport-local-override - 366 + 374 310 transport nextgen-meta - 376 + 374 311 transport nextgen-ordering - 483 + 479 312 transport transport-exact-single - 163 + 160 313 transport transport-local-override - 144 + 150 314 transport transport-star - 272 + 273 315 transport transport-star-pin-object - 276 + 269 316 transport transport-single-notdef - 156 + 163 317 transport transport-pins-notdef - 174 + 180 318 transport transport-single-wrap-and-star - 287 + 292 319 transport transport-local-single-and-star - 270 + 276 320 transport transport-local-over-wrap - 243 + 242 321 transport transport-local-prior-wrap - 159 + 161 322 transport transport-init-ordering - 240 + 239 323 transport transport-no-plugin-init - 281 + 277 324 transport transport-balance-exact - 888 + 893 325 @@ -2987,7 +2987,7 @@

    Test Report

    transport server can be restarted without issues to clients - 600 + 610 327 @@ -3001,21 +3001,21 @@

    Test Report

    transport transport-listen supports type as tcp option - 127 + 125 329 transport transport-listen supports type as http option - 122 + 125 330 transport transport-listen supports the port number as an argument - 122 + 119 331 @@ -3029,7 +3029,7 @@

    Test Report

    transport transport-listen supports the port number, host, and path as an argument - 124 + 123 333 @@ -3043,7 +3043,7 @@

    Test Report

    transport client() supports null options - 123 + 127 335 @@ -3092,7 +3092,7 @@

    Test Report

    xward happy-outward - 13 + 15 @@ -3100,9 +3100,9 @@

    Test Report

    Code Coverage Report

    -
    91.41%
    -
    4633
    -
    4235
    +
    91.44%
    +
    4652
    +
    4254
    398
    @@ -7870,7 +7870,7 @@

    lib/act.js

    23 - 799 + 803 msg.caller$ = @@ -8410,7 +8410,7 @@

    lib/act.js

    113 - 800 + 804 delete actmsg.caller$ @@ -12676,7 +12676,7 @@

    lib/api.js

    58 - 21881 + 21884 var private$ = self.private$ @@ -12688,13 +12688,13 @@

    lib/api.js

    60 - 21881 + 21884 if (null == options) { 61 - 20633 + 20635 return private$.optioner.get() @@ -12724,7 +12724,7 @@

    lib/api.js

    66 - 1248 + 1249 self.log.debug({ @@ -12766,7 +12766,7 @@

    lib/api.js

    73 - 1248 + 1249 var out_opts = (private$.exports.options = private$.optioner.set(options)) @@ -12778,7 +12778,7 @@

    lib/api.js

    75 - 1248 + 1249 if ('string' === typeof options.tag) { @@ -12838,19 +12838,19 @@

    lib/api.js

    85 - 1248 + 1249 if (options.log) { 86 - 236 + 237 var logspec = private$.logging.build_log(self) 87 - 236 + 237 out_opts = private$.exports.options = private$.optioner.set({ @@ -14512,7 +14512,7 @@

    lib/api.js

    364 - 197 + 198 if ('-' != opts.tag) { @@ -14554,7 +14554,7 @@

    lib/api.js

    371 - 197 + 198 if ('function' !== typeof errhandler && null !== errhandler) { @@ -14596,7 +14596,7 @@

    lib/api.js

    378 - 197 + 198 var test_opts = { @@ -14644,7 +14644,7 @@

    lib/api.js

    386 - 197 + 198 var set_opts = this.options(test_opts) @@ -14662,7 +14662,7 @@

    lib/api.js

    389 - 197 + 198 if (set_opts.quiet) { @@ -14680,7 +14680,7 @@

    lib/api.js

    392 - 195 + 196 this.private$.logging.build_log(this) @@ -14704,13 +14704,13 @@

    lib/api.js

    396 - 195 + 196 if (!this.private$.logger.from_options$) { 397 - 182 + 183 this.root.private$.logger = this.private$.logging.test_logger @@ -14728,7 +14728,7 @@

    lib/api.js

    400 - 195 + 196 return this @@ -18290,7 +18290,7 @@

    lib/common.js

    94 - 627 + 628 return !!JSON.parse(v) @@ -19382,7 +19382,7 @@

    lib/common.js

    276 - 27182 + 27186 argsarr = argsarr.reverse() @@ -19406,7 +19406,7 @@

    lib/common.js

    280 - 27182 + 27186 argsarr.unshift({}) @@ -19418,7 +19418,7 @@

    lib/common.js

    282 - 27182 + 27186 return DefaultsDeep.apply(null, argsarr) @@ -21776,13 +21776,13 @@

    lib/common.js

    675 - 54966 + 56298 var s = 0 676 - 54966 + 56298 var e = i @@ -21794,13 +21794,13 @@

    lib/common.js

    678 - 54966 + 56298 if (0 === this._list.length) { 679 - 7421 + 8313 return 0 @@ -21818,13 +21818,13 @@

    lib/common.js

    682 - 47545 + 47985 do { 683 - 98977 + 99861 i = Math.floor((s + e) / 2) @@ -21836,31 +21836,31 @@

    lib/common.js

    685 - 98977 + 99861 if (timelimit > this._list[i].timelimit) { 686 - 184 + 207 s = i + 1 687 - 184 + 207 i = s 688 - 98793 + 99654 } else if (timelimit < this._list[i].timelimit) { 689 - 98784 + 99642 e = i @@ -21872,13 +21872,13 @@

    lib/common.js

    691 - 9 + 12 i++ 692 - 9 + 12 break @@ -21902,7 +21902,7 @@

    lib/common.js

    696 - 47545 + 47985 return i @@ -21938,13 +21938,13 @@

    lib/common.js

    702 - 54956 + 56288 for (var j = 0; j < i; j++) { 703 - 344 + 395 delete this._map[this._list[j].id] @@ -21956,7 +21956,7 @@

    lib/common.js

    705 - 54956 + 56288 this._list = this._list.slice(i) @@ -27342,7 +27342,7 @@

    lib/logging.js

    136 - 841 + 843 var logger = log_plugin @@ -27354,7 +27354,7 @@

    lib/logging.js

    138 - 841 + 843 if ('string' === typeof logger) { @@ -27384,7 +27384,7 @@

    lib/logging.js

    143 - 841 + 843 if (log_plugin.preload) { @@ -27414,7 +27414,7 @@

    lib/logging.js

    148 - 841 + 843 if (2 == logger.length) { @@ -27468,7 +27468,7 @@

    lib/logging.js

    157 - 757 + 759 return logger @@ -27498,13 +27498,13 @@

    lib/logging.js

    162 - 851 + 853 var options = self.options() 163 - 851 + 853 var orig_logspec = options.log @@ -27522,7 +27522,7 @@

    lib/logging.js

    166 - 851 + 853 var logspec = Common.deep( @@ -27558,7 +27558,7 @@

    lib/logging.js

    172 - 851 + 853 Object.keys(logspec.level_text).forEach((val) => { @@ -27582,13 +27582,13 @@

    lib/logging.js

    176 - 851 + 853 var text_level = logspec.text_level 177 - 851 + 853 var level_text = logspec.level_text @@ -27606,7 +27606,7 @@

    lib/logging.js

    180 - 851 + 853 var logger = @@ -27642,7 +27642,7 @@

    lib/logging.js

    186 - 851 + 853 if ('string' === typeof orig_logspec) { @@ -27810,7 +27810,7 @@

    lib/logging.js

    214 - 473 + 475 else if ('number' === typeof orig_logspec) { @@ -27822,7 +27822,7 @@

    lib/logging.js

    216 - 471 + 473 } else if ('function' === typeof orig_logspec) { @@ -27870,7 +27870,7 @@

    lib/logging.js

    224 - 849 + 851 logspec.level = level_text[logspec.level] || '' + logspec.level @@ -27888,7 +27888,7 @@

    lib/logging.js

    227 - 849 + 851 var live_level = text_level[logspec.level] || parseInt(logspec.level, 10) @@ -27900,7 +27900,7 @@

    lib/logging.js

    229 - 849 + 851 logspec.live_level = live_level @@ -27918,7 +27918,7 @@

    lib/logging.js

    232 - 849 + 851 logspec.logger = logger @@ -27936,7 +27936,7 @@

    lib/logging.js

    235 - 849 + 851 return logspec @@ -27960,7 +27960,7 @@

    lib/logging.js

    239 - 843 + 845 var logspec = build_log_spec(self) @@ -27978,7 +27978,7 @@

    lib/logging.js

    242 - 841 + 843 self.private$.logspec = logspec @@ -27990,7 +27990,7 @@

    lib/logging.js

    244 - 841 + 843 var logger = load_logger(self, logspec.logger) @@ -28002,7 +28002,7 @@

    lib/logging.js

    246 - 841 + 843 self.private$.logger = logger @@ -28014,7 +28014,7 @@

    lib/logging.js

    248 - 841 + 843 self.log = function log(entry) { @@ -28056,7 +28056,7 @@

    lib/logging.js

    255 - 17635 + 17638 } else if ('string' === typeof entry) { @@ -28080,13 +28080,13 @@

    lib/logging.js

    259 - 17635 + 17638 var logspec = instance.private$.logspec 260 - 17635 + 17638 entry.level = entry.level || logspec.default_level @@ -28098,7 +28098,7 @@

    lib/logging.js

    262 - 17635 + 17638 if ('number' !== typeof entry.level) { @@ -28134,7 +28134,7 @@

    lib/logging.js

    268 - 17635 + 17638 var now = new Date() @@ -28158,25 +28158,25 @@

    lib/logging.js

    272 - 17635 + 17638 entry.isot = entry.isot || now.toISOString() 273 - 17635 + 17638 entry.when = entry.when || now.getTime() 274 - 17635 + 17638 entry.level_name = entry.level_name || logspec.level_text[entry.level] 275 - 17635 + 17638 entry.seneca_id = entry.seneca_id || instance.id @@ -28188,7 +28188,7 @@

    lib/logging.js

    277 - 17635 + 17638 if (instance.did) { @@ -28212,7 +28212,7 @@

    lib/logging.js

    281 - 17635 + 17638 if (instance.fixedargs.plugin$) { @@ -28242,7 +28242,7 @@

    lib/logging.js

    286 - 17635 + 17638 if (instance.private$.act) { @@ -28272,7 +28272,7 @@

    lib/logging.js

    291 - 17635 + 17638 instance.emit('log', entry) @@ -28284,7 +28284,7 @@

    lib/logging.js

    293 - 17635 + 17638 var level_match = logspec.live_level <= entry.level @@ -28296,13 +28296,13 @@

    lib/logging.js

    295 - 17635 + 17638 if (level_match) { 296 - 741 + 743 instance.private$.logger.call(this, entry) @@ -28320,7 +28320,7 @@

    lib/logging.js

    299 - 17635 + 17638 return this @@ -28338,7 +28338,7 @@

    lib/logging.js

    302 - 841 + 843 self.log.self = () => self @@ -28350,7 +28350,7 @@

    lib/logging.js

    304 - 841 + 843 Object.keys(logspec.text_level).forEach((level_name) => { @@ -28374,7 +28374,7 @@

    lib/logging.js

    308 - 841 + 843 return logspec @@ -28398,7 +28398,7 @@

    lib/logging.js

    312 - 5887 + 5901 var level = logspec.text_level[level_name] @@ -28410,7 +28410,7 @@

    lib/logging.js

    314 - 5887 + 5901 var log_level = function (entry) { @@ -28422,7 +28422,7 @@

    lib/logging.js

    316 - 17592 + 17595 if ('object' !== typeof entry) { @@ -28458,13 +28458,13 @@

    lib/logging.js

    322 - 17592 + 17595 entry.level = level 323 - 17592 + 17595 return self.log(entry) @@ -28482,7 +28482,7 @@

    lib/logging.js

    326 - 5887 + 5901 Object.defineProperty(log_level, 'name', { value: 'log_' + level_name }) @@ -28494,7 +28494,7 @@

    lib/logging.js

    328 - 5887 + 5901 return log_level @@ -29464,13 +29464,13 @@

    lib/options.js

    38 - 612 + 613 var DEFAULT_OPTIONS_FILE = './seneca.options.js' 39 - 612 + 613 var FATAL_OPTIONS_FILE = './options.seneca.js' @@ -29506,13 +29506,13 @@

    lib/options.js

    45 - 612 + 613 var from = initial.from 46 - 612 + 613 if ('string' === typeof initial) { @@ -29542,7 +29542,7 @@

    lib/options.js

    51 - 612 + 613 if ('string' === typeof from) { @@ -29578,7 +29578,7 @@

    lib/options.js

    57 - 612 + 613 var argv = Minimist( @@ -29674,13 +29674,13 @@

    lib/options.js

    73 - 612 + 613 try { 74 - 612 + 613 sourcemap.default_file = @@ -29764,7 +29764,7 @@

    lib/options.js

    88 - 612 + 613 if (env.SENECA_OPTIONS) { @@ -29812,7 +29812,7 @@

    lib/options.js

    96 - 612 + 613 if (env.SENECA_TEST) { @@ -29836,7 +29836,7 @@

    lib/options.js

    100 - 612 + 613 if (env.SENECA_QUIET) { @@ -29860,7 +29860,7 @@

    lib/options.js

    104 - 612 + 613 if (argv.seneca) { @@ -30100,7 +30100,7 @@

    lib/options.js

    144 - 612 + 613 var adjusted = {} @@ -30118,13 +30118,13 @@

    lib/options.js

    147 - 612 + 613 if (false === initial.legacy) { 148 - 14 + 15 adjusted.legacy = { @@ -30208,7 +30208,7 @@

    lib/options.js

    162 - 612 + 613 var out = Common.deepextend( @@ -30304,7 +30304,7 @@

    lib/options.js

    178 - 612 + 613 out.legacy.logging = Common.boolify(out.legacy.logging) @@ -30316,7 +30316,7 @@

    lib/options.js

    180 - 612 + 613 return out @@ -30496,7 +30496,7 @@

    lib/options.js

    210 - 1857 + 1859 if ('string' === typeof input) { @@ -30508,13 +30508,13 @@

    lib/options.js

    212 - 1856 + 1858 } else if (input.reload$) { 213 - 236 + 237 options = prepare(basemodule, defaults, input) @@ -30526,7 +30526,7 @@

    lib/options.js

    215 - 1620 + 1621 options = Common.deepextend(options, input) @@ -30544,7 +30544,7 @@

    lib/options.js

    218 - 1857 + 1859 return options @@ -30568,7 +30568,7 @@

    lib/options.js

    222 - 21009 + 21011 return options @@ -33844,7 +33844,7 @@

    lib/ready.js

    48 - 600 + 597 execute_ready(self, ready_call) @@ -33856,7 +33856,7 @@

    lib/ready.js

    50 - 24 + 27 private$.ready_list.push(ready_call) @@ -33994,7 +33994,7 @@

    lib/ready.js

    73 - 1662 + 1656 if (null == ready_func) return @@ -37161,9 +37161,9 @@

    lib/transport.js

    lib/use.js

    -
    91.16%
    -
    475
    -
    433
    +
    91.50%
    +
    494
    +
    452
    42
    @@ -37295,3078 +37295,3660 @@

    lib/use.js

    - - + + - - + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - - + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - + + - - - + + + - - + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - + + - - + + - - - + + + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - - + + - - - - + + + + - - - - + + + + - - - - + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - + - - + + - - - - + + + + - - - + + + - - - + + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - - - + + + + - - - + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - + + + - - + + - - - + + + - - - + + + - - - - + + + + - - + + - - - - + + + + - - + + - - - - + + + + - - + + - - - + + + - - + + - - + + - - - + + + - - - + + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - + - - - + + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - - + + + - - - - - + + + + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - + + - - - + + + - - + + - - + + - - + + - - - + + + - - - + + + - - - - + + + + - - - - + + + + - - + + - - - + + + - - + + - - - + + + - - - - + + + + - - + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - - - + + + + - - + + - - + + - - - + + + - - - + + + - - + + - - + + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - - - + + + - - - - + + + + - - - + + + - - - + + + - - + + - - + + - - - + + + - - - + + + - - + + - - + + - - - - + + + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - - - + + + + - - + + - - - - + + + + - - + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - - - + + + + - - + + - - - - + + + + - - - + + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - - - + + + + - - - + + + - - - - + + + + - - + + - - + + - - - + + + - - + + - - + + - - + + - - - - + + + + - - + + - - - + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - - - + + + + - - - + + + - - + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/plugin.test.js b/test/plugin.test.js index b0168ee5..31a74ec8 100644 --- a/test/plugin.test.js +++ b/test/plugin.test.js @@ -1,4 +1,4 @@ -/* Copyright © 2013-2018 Richard Rodger and other contributors, MIT License. */ +/* Copyright © 2013-2020 Richard Rodger and other contributors, MIT License. */ 'use strict' const Code = require('@hapi/code') @@ -26,12 +26,13 @@ describe('plugin', function () { 'load', 'normalize', 'preload', - 'pre_exports', + 'pre_meta', 'pre_legacy_extend', 'delegate', 'call_define', + 'options', 'define', - 'post_exports', + 'post_meta', 'post_legacy_extend', 'complete' ]) @@ -42,7 +43,8 @@ describe('plugin', function () { 'stop', 'merge', 'seneca_plugin', - 'seneca_export' + 'seneca_export', + 'seneca_options', ]) fin() @@ -898,13 +900,13 @@ describe('plugin', function () { it('plugins-options-precedence', function (fin) { var si = Seneca({ - log: 'silent', - legacy: { transport: false }, + legacy: false, + debug: { undead: true }, plugin: { foo: { a: 2, c: 2 }, bar: { a: 2, c: 1 }, }, - }) + }).test(fin) function bar(opts) { expect(opts).equal({ a: 3, b: 1, c: 1, d: 1 })
    20 375 ordu.add([28 ordu.operator('seneca_options', tasks.op.seneca_options);27
    21 tasks.args,29 // TODO: exports -> meta and handle all meta processing30
    22 tasks.load,30375 ordu.add([32
    23 tasks.normalize,31 tasks.args,33
    24 tasks.preload,32 tasks.load,34
    25 { name: 'pre_exports', exec: tasks.exports },33 tasks.normalize,35
    26 { name: 'pre_legacy_extend', exec: tasks.legacy_extend },34 tasks.preload,36
    27 tasks.delegate,35 { name: 'pre_meta', exec: tasks.meta },37
    28 //intern.options,36 { name: 'pre_legacy_extend', exec: tasks.legacy_extend },38
    29 tasks.call_define,37 tasks.delegate,39
    30 tasks.define,38 tasks.call_define,40
    31 { name: 'post_exports', exec: tasks.exports },39 tasks.options,41
    32 { name: 'post_legacy_extend', exec: tasks.legacy_extend },40 tasks.define,42
    33 function complete() {41 { name: 'post_meta', exec: tasks.meta },43
    34 //console.log('COMPLETE')42 { name: 'post_legacy_extend', exec: tasks.legacy_extend },44
    35 },43 function complete() {45
    36 ]);44 //console.log('COMPLETE')46
    37 375 return {46 },47
    38 use: make_use(ordu, callpoint),47 ]);48
    39 ordu,48375 return {50
    40 tasks,49 use: make_use(ordu, callpoint),51
    41 };50 ordu,52
    42 }51 tasks,53
    43 function make_use(ordu, callpoint) {82 };54
    44 375 let seq = { index: 0 };83}55
    45 375 return function use() {85function make_use(ordu, callpoint) {87
    46 var self = this;86375 let seq = { index: 0 };88
    47 474 let ctx = {88375 return function use() {90
    48 seq: seq,89 var self = this;91
    49 args: [...arguments],90474 let ctx = {93
    50 seneca: this,91 seq: seq,94
    51 callpoint: callpoint(true)92 args: [...arguments],95
    52 };93 seneca: this,96
    53 474 let data = {94 callpoint: callpoint(true)97
    54 seq: -1,95 };98
    55 args: [],96474 let data = {99
    56 plugin: null,97 seq: -1,100
    57 meta: null,98 args: [],101
    58 delegate: null,99 plugin: null,102
    59 plugin_done: null,100 meta: null,103
    60 exports: {}101 delegate: null,104
    61 };102 plugin_done: null,105
    62 async function run() {104 exports: {},106
    63 // NOTE: don't wait for result!105 };108
    64 //var resp =106 async function run() {110
    65 474 await ordu.exec(ctx, data, {107 // NOTE: don't wait for result!111
    66 done: function (res) {108 //var resp =112
    67 //console.log('RES-ERR', res.err)109474 await ordu.exec(ctx, data, {113
    68 if (res.err) {111 done: function (res) {114
    69 //self.die(self.private$.error(res.err, 'plugin_' + res.err.code))112 //console.log('RES-ERR', res.err)115
    70 10 var err = res.err.seneca ? res.err :113 if (res.err) {117
    71 self.private$.error(res.err, res.err.code);114 //self.die(self.private$.error(res.err, 'plugin_' + res.err.code))118
    72 10 self.die(err);115 var err = res.err.seneca ? res.err :119
    73 }116 self.private$.error(res.err, res.err.code);120
    74 }11710 self.die(err);121
    75 });118 }122
    76 //console.log('RESP')120 }123
    77 //console.dir((resp.tasklog as any[]).map((x): any => [x.name, x.op, x.result.err]), { depth: null })121 });124
    78 }122 //console.log('RESP')126
    79 474 run();124 //console.dir((resp.tasklog as any[]).map((x): any => [x.name, x.op, x.result.err]), { depth: null })127
    80 474 return self;126 }128
    81 };127474 run();130
    82 }128474 return self;132
    83 function make_tasks() {130 };133
    84 375 return {131}134
    85 op: {132function make_tasks() {136
    86 seneca_plugin: (tr, ctx, data) => {133375 return {137
    87 nua_1.default(data, tr.out.merge, { preserve: true });134 // TODO: explicit tests for these operators138
    88 461 ctx.seneca.private$.plugins[data.plugin.fullname] = tr.out.plugin;135 op: {140
    89 461 return { stop: false };136 seneca_plugin: (tr, ctx, data) => {141
    90 },137 nua_1.default(data, tr.out.merge, { preserve: true });142
    91 // TODO: explicit test for exports needed139461 ctx.seneca.private$.plugins[data.plugin.fullname] = tr.out.plugin;143
    92 seneca_export: (tr, ctx, data) => {140461 return { stop: false };144
    93 Object.assign(data.exports, tr.out.exports);141 },145
    94 916 Object.assign(ctx.seneca.private$.exports, tr.out.exports);142 seneca_export: (tr, ctx, data) => {147
    95 916 return { stop: false };143 Object.assign(data.exports, tr.out.exports);148
    96 }144916 Object.assign(ctx.seneca.private$.exports, tr.out.exports);149
    97 },145916 return { stop: false };150
    98 args: (spec) => {147 },151
    99 let args = [...spec.ctx.args];148 seneca_options: (tr, ctx, data) => {153
    100 // DEPRECATED: Remove when Seneca >= 4.x150 nua_1.default(data.plugin.options, tr.out.plugin.options, { preserve: true });154
    101 // Allow chaining with seneca.use('options', {...})151460 let plugin_fullname = data.plugin.fullname;156
    102 // see https://github.com/rjrodger/seneca/issues/80152460 let plugin_options = data.plugin.options;157
    103 474 if ('options' === args[0]) {153460 let plugin_options_update = { plugin: {} };159
    104 3 spec.ctx.seneca.options(args[1]);154460 plugin_options_update.plugin[plugin_fullname] = plugin_options;160
    105 3 return {155460 ctx.seneca.options(plugin_options_update);162
    106 op: 'stop',156460 return { stop: false };164
    107 why: 'legacy-options'157 },165
    108 };158 },166
    109 }159 args: (spec) => {168
    110 // Plugin definition function is under property `define`.161 let args = [...spec.ctx.args];169
    111 // `init` is deprecated from 4.x162 // DEPRECATED: Remove when Seneca >= 4.x171
    112 // TODO: use-plugin expects `init` - update use-plugin to make this customizable163
    // Allow chaining with seneca.use('options', {...})172
    113
    if (
    null != args[0]
    && 'object' === typeof args[0]) {
    164 // see https://github.com/rjrodger/seneca/issues/80173
    114 17 args[0].init = args[0].define || args[0].init;165474 if ('options' === args[0]) {174
    115 }1663 spec.ctx.seneca.options(args[1]);175
    116 471 return {1693 return {176
    117 op: 'merge',170 op: 'stop',177
    118 out: { args }171 why: 'legacy-options'178
    119 };172 };179
    120 },173 }180
    121 load: (spec) => {176 // Plugin definition function is under property `define`.182
    122 let args = spec.data.args;177 // `init` is deprecated from 4.x183
    123 471 let seneca = spec.ctx.seneca;178
    // TODO: use-plugin expects `init` - update use-plugin to make this customizable184
    124 471 let private$ = seneca.private$;179
    if (
    null != args[0]
    && 'object' === typeof args[0]) {
    185
    125 // TODO: use-plugin needs better error message for malformed plugin desc18117 args[0].init = args[0].define || args[0].init;186
    126 471 var desc = private$.use.build_plugin_desc(...args);182 }187
    127 469 if (private$.ignore_plugins[desc.full]) {184471 return {190
    128 6 seneca.log.info({185 op: 'merge',191
    129 kind: 'plugin',186 out: { args }192
    130 case: 'ignore',187 };193
    131 plugin_full: desc.full,188 },194
    132 plugin_name: desc.name,189 load: (spec) => {197
    133 plugin_tag: desc.tag,190 let args = spec.data.args;198
    134 });191471 let seneca = spec.ctx.seneca;199
    135 6 return {193471 let private$ = seneca.private$;200
    136 op: 'stop',194 // TODO: use-plugin needs better error message for malformed plugin desc202
    137 why: 'ignore'195471 var desc = private$.use.build_plugin_desc(...args);203
    138 };196469 if (private$.ignore_plugins[desc.full]) {205
    139 }1976 seneca.log.info({206
    140 else {198 kind: 'plugin',207
    141 463 let plugin = private$.use.use_plugin_desc(desc);199 case: 'ignore',208
    142 461 return {201 plugin_full: desc.full,209
    143 op: 'merge',202 plugin_name: desc.name,210
    144 out: { plugin }203 plugin_tag: desc.tag,211
    145 };204 });212
    146 }2056 return {214
    147 },206 op: 'stop',215
    148 normalize: (spec) => {209 why: 'ignore'216
    149 let plugin = spec.data.plugin;210 };217
    150 461 var modify = {};212 }218
    151 // NOTE: `define` is the property for the plugin definition action.214 else {219
    152 // The property `init` will be deprecated in 4.x215463 let plugin = private$.use.use_plugin_desc(desc);220
    153 461 modify.define = plugin.define || plugin.init;216 return {222
    154 461 modify.fullname = Common.make_plugin_key(plugin);218 op: 'merge',223
    155 461 modify.loading = true;220 out: { plugin }224
    156 461 return {222 };225
    157 op: 'merge',223 }226
    158 out: { plugin: modify }224 },227
    159 };225 normalize: (spec) => {230
    160 },226 let plugin = spec.data.plugin;231
    161 preload: (spec) => {229461 var modify = {};233
    162 let seneca = spec.ctx.seneca;230 // NOTE: `define` is the property for the plugin definition action.235
    163 461 let plugin = spec.data.plugin;232 // The property `init` will be deprecated in 4.x236
    164 461 let so = seneca.options();234 modify.define = plugin.define || plugin.init;237
    165 // Don't reload plugins if load_once true.236
    461 modify.fullname = Common.make_plugin_key(plugin);239
    166
    if (
    so.system.plugin.load_once
    ) {
    237
    461 modify.loading = true;241
    167 if (seneca.has_plugin(plugin)) {238
    461 return {243
    168 return {239 op: 'merge',244
    169 op: 'stop',240 out: { plugin: modify }245
    170 why: 'already-loaded',241 };246
    171 out: {242 },247
    172 plugin: {243 preload: (spec) => {250
    173 loading: false244 let seneca = spec.ctx.seneca;251
    174 }245461 let plugin = spec.data.plugin;253
    175 }246461 let so = seneca.options();255
    176 };247
    // Don't reload plugins if load_once true.257
    177 }248
    if (
    so.system.plugin.load_once
    ) {
    258
    178 }249
    if (seneca.has_plugin(plugin)) {259
    179 461 let meta = {};251 return {260
    180 461 if ('function' === typeof plugin.define.preload) {253 op: 'stop',261
    181 // TODO: need to capture errors254 why: 'already-loaded',262
    182 340 meta = plugin.define.preload.call(seneca, plugin) || {};255 out: {263
    183 }256 plugin: {264
    184 461 let name = meta.name || plugin.name;258 loading: false265
    185 461 let fullname = Common.make_plugin_key(name, plugin.tag);259 }266
    186 461 return {261 }267
    187 op: 'seneca_plugin',262 };268
    188 out: {263 }269
    189 merge: {264 }270
    190 meta,265461 let meta = {};272
    191 plugin: {266461 if ('function' === typeof plugin.define.preload) {274
    192 name,267 // TODO: need to capture errors275
    193 fullname268340 meta = plugin.define.preload.call(seneca, plugin) || {};276
    194 }269 }277
    195 },270461 let name = meta.name || plugin.name;279
    196 plugin271461 let fullname = Common.make_plugin_key(name, plugin.tag);280
    197 }272461 return {282
    198 };273 op: 'seneca_plugin',283
    199 },274 out: {284
    200 exports: (spec) => {277 merge: {285
    201 let plugin = spec.data.plugin;278 meta,286
    202 916 let meta = spec.data.meta;279 plugin: {287
    203 916 let exports = {};281 name,288
    204 916 exports[plugin.name] = meta.export || plugin;282 fullname289
    205 916 exports[plugin.fullname] = meta.export || plugin;283 }290
    206 916 let exportmap = meta.exportmap || meta.exports || {};285 },291
    207 916 Object.keys(exportmap).forEach(k => {287 plugin292
    208 let v = exportmap[k];288
    }293
    209
    if (
    void 0 !== v
    ) {
    289 };294
    210 665 let exportname = plugin.fullname + '/' + k;290 },295
    211 665 exports[exportname] = v;291 meta: (spec) => {298
    212 }292 let plugin = spec.data.plugin;299
    213 });293916 let meta = spec.data.meta;300
    214 916 return {295 let exports = {};302
    215 op: 'seneca_export',296916 exports[plugin.name] = meta.export || plugin;303
    216 out: {297916 exports[plugin.fullname] = meta.export || plugin;304
    217 exports298916 let exportmap = meta.exportmap || meta.exports || {};306
    218 }299916 Object.keys(exportmap).forEach(k => {308
    219 };300
    let v = exportmap[k];309
    220 },301
    if (
    void 0 !== v
    ) {
    310
    221 // NOTE: mutates spec.ctx.seneca304665 let exportname = plugin.fullname + '/' + k;311
    222 legacy_extend: (spec) => {305665 exports[exportname] = v;312
    223 let seneca = spec.ctx.seneca;306 }313
    224 // let plugin: any = spec.data.plugin308 });314
    225 916 let meta = spec.data.meta;309 return {316
    226 916 if ('object' === typeof meta.extend) {311 op: 'seneca_export',317
    227 4 if ('function' === typeof meta.extend.action_modifier) {312 out: {318
    228 3 seneca.private$.action_modifiers.push(meta.extend.action_modifier);313 exports319
    229 }314320
    230 // FIX: needs to use logging.load_logger316 };321
    231 4 if ('function' === typeof meta.extend.logger) {317
    },322
    232
    if (
    !meta.extend.logger.replace
    &&
    319
    // NOTE: mutates spec.ctx.seneca325
    233
    'function' === typeof seneca.private$.logger.add
    ) {
    321
    legacy_extend: (spec) => {326
    234 seneca.private$.logger.add(meta.extend.logger);322 let seneca = spec.ctx.seneca;327
    235 }323 // let plugin: any = spec.data.plugin329
    236 else {323916 let meta = spec.data.meta;330
    237 1 seneca.private$.logger = meta.extend.logger;324916 if ('object' === typeof meta.extend) {332
    238 }3254 if ('function' === typeof meta.extend.action_modifier) {333
    239 }3263 seneca.private$.action_modifiers.push(meta.extend.action_modifier);334
    240 }327 }335
    241 //seneca.register(plugin, meta)329 // FIX: needs to use logging.load_logger337
    242 },330
    4 if ('function' === typeof meta.extend.logger) {338
    243 delegate: (spec) => {333
    if (
    !meta.extend.logger.replace
    &&
    340
    244 let seneca = spec.ctx.seneca;334
    'function' === typeof seneca.private$.logger.add
    ) {
    342
    245 504 let plugin = spec.data.plugin;335 seneca.private$.logger.add(meta.extend.logger);343
    246 //var delegate = make_delegate(seneca, plugin)337 }344
    247 // Adjust Seneca API to be plugin specific.340 else {344
    248 504 var delegate = seneca.delegate({3411 seneca.private$.logger = meta.extend.logger;345
    249 plugin$: {342 }346
    250 name: plugin.name,343 }347
    251 tag: plugin.tag,344 }348
    252 },345 //seneca.register(plugin, meta)350
    253 fatal$: true,347 },351
    254 });348 delegate: (spec) => {354
    255 504 delegate.private$ = Object.create(seneca.private$);350 let seneca = spec.ctx.seneca;355
    256 504 delegate.private$.ge = delegate.private$.ge.gate();351 let plugin = spec.data.plugin;356
    257 504 delegate.die = Common.makedie(delegate, {353 //var delegate = make_delegate(seneca, plugin)358
    258 type: 'plugin',354 // Adjust Seneca API to be plugin specific.361
    259 plugin: plugin.name,355504 var delegate = seneca.delegate({362
    260 });356 plugin$: {363
    261 504 var actdeflist = [];358 name: plugin.name,364
    262 504 delegate.add = function () {360 tag: plugin.tag,365
    263 var argsarr = new Array(arguments.length);361 },366
    264 4129 for (var l = 0; l < argsarr.length; ++l) {362 fatal$: true,368
    265 8257 argsarr[l] = arguments[l];363 });369
    266 }364
    504 delegate.private$ = Object.create(seneca.private$);371
    267
    var actdef =
    argsarr[argsarr.length - 1]
    ||
    {}
    ;
    366504 delegate.private$.ge = delegate.private$.ge.gate();372
    268 4129 if ('function' === typeof actdef) {368504 delegate.die = Common.makedie(delegate, {374
    269 4128 actdef = {};369 type: 'plugin',375
    270 4128 argsarr.push(actdef);370 plugin: plugin.name,376
    271 }371
    });377
    272
    actdef.plugin_name =
    plugin.name
    ||
    '-'
    ;
    373504 var actdeflist = [];379
    273 4129 actdef.plugin_tag = plugin.tag || '-';374504 delegate.add = function () {381
    274 4129 actdef.plugin_fullname = plugin.fullname;375 var argsarr = new Array(arguments.length);382
    275 // TODO: is this necessary?3774129 for (var l = 0; l < argsarr.length; ++l) {383
    276 4129 actdef.log = delegate.log;3788257 argsarr[l] = arguments[l];384
    277 4129 actdeflist.push(actdef);380
    }385
    278 4129 seneca.add.apply(delegate, argsarr);382
    var actdef =
    argsarr[argsarr.length - 1]
    ||
    {}
    ;
    387
    279 // FIX: should be this3844129 if ('function' === typeof actdef) {389
    280 4128 return delegate;385 actdef = {};390
    281 };3864128 argsarr.push(actdef);391
    282 504 delegate.__update_plugin__ = function (plugin) {388 }392
    283
    delegate.context.name =
    plugin.name
    ||
    '-'
    ;
    389
    actdef.plugin_name =
    plugin.name
    ||
    '-'
    ;
    394
    284 455 delegate.context.tag = plugin.tag || '-';390
    4129 actdef.plugin_tag = plugin.tag || '-';395
    285
    delegate.context.full =
    plugin.fullname
    ||
    '-'
    ;
    3914129 actdef.plugin_fullname = plugin.fullname;396
    286 455 actdeflist.forEach(function (actdef) {393
    // TODO: is this necessary?398
    287
    actdef.plugin_name =
    plugin.name
    ||
    actdef.plugin_name
    ||
    '-'
    ;
    394
    4129 actdef.log = delegate.log;399
    288
    actdef.plugin_tag = plugin.tag ||
    actdef.plugin_tag
    ||
    '-'
    ;
    395
    4129 actdeflist.push(actdef);401
    289
    actdef.plugin_fullname =
    plugin.fullname
    ||
    actdef.plugin_fullname
    ||
    '-'
    ;
    3964129 seneca.add.apply(delegate, argsarr);403
    290 });397 // FIX: should be this405
    291 };3984128 return delegate;406
    292 504 delegate.init = function (init) {400 };407
    293 // TODO: validate init_action is function401
    504 delegate.__update_plugin__ = function (plugin) {409
    294 var pat = {403
    delegate.context.name =
    plugin.name
    ||
    '-'
    ;
    410
    295 role: 'seneca',404
    455 delegate.context.tag = plugin.tag || '-';411
    296 plugin: 'init',405
    delegate.context.full =
    plugin.fullname
    ||
    '-'
    ;
    412
    297 init: plugin.name,406
    455 actdeflist.forEach(function (actdef) {414
    298 };407
    actdef.plugin_name =
    plugin.name
    ||
    actdef.plugin_name
    ||
    '-'
    ;
    415
    299
    if (
    null != plugin.tag
    &&
    '-' != plugin.tag
    ) {
    409
    actdef.plugin_tag = plugin.tag ||
    actdef.plugin_tag
    ||
    '-'
    ;
    416
    300 pat.tag = plugin.tag;410
    actdef.plugin_fullname =
    plugin.fullname
    ||
    actdef.plugin_fullname
    ||
    '-'
    ;
    417
    301 }411 });418
    302 6 delegate.add(pat, function (_, reply) {413 };419
    303 init.call(this, reply);414504 delegate.init = function (init) {421
    304 });415 // TODO: validate init_action is function422
    305 };416 var pat = {424
    306 504 delegate.context.plugin = plugin;418 role: 'seneca',425
    307 504 delegate.context.plugin.mark = Math.random();419 plugin: 'init',426
    308 504 return {422 init: plugin.name,427
    309 op: 'merge',423
    };428
    310 out: {424
    if (
    null != plugin.tag
    &&
    '-' != plugin.tag
    ) {
    430
    311 delegate425 pat.tag = plugin.tag;431
    312 }426432
    313 };4276 delegate.add(pat, function (_, reply) {434
    314 },428 init.call(this, reply);435
    315 call_define: (spec) => {431 });436
    316 let plugin = spec.data.plugin;432 };437
    317 461 let delegate = spec.data.delegate;433504 delegate.context.plugin = plugin;439
    318 // FIX: mutating context!!!435504 delegate.context.plugin.mark = Math.random();440
    319 461 var seq = spec.ctx.seq.index++;436504 return {443
    320 461 var plugin_define_pattern = {439 op: 'merge',444
    321 role: 'seneca',440 out: {445
    322 plugin: 'define',441 delegate446
    323 name: plugin.name,442 }447
    324 seq: seq,443 };448
    325 };444
    },449
    326
    if (
    plugin.tag !== null
    ) {
    446 call_define: (spec) => {452
    327 461 plugin_define_pattern.tag = plugin.tag;447 let plugin = spec.data.plugin;453
    328 }448461 let delegate = spec.data.delegate;454
    329 461 return new Promise(resolve => {450 // FIX: mutating context!!!456
    330 // seneca452461 var seq = spec.ctx.seq.index++;457
    331 delegate.add(plugin_define_pattern, (_, reply) => {453461 var plugin_define_pattern = {460
    332 resolve({454 role: 'seneca',461
    333 op: 'merge',455 plugin: 'define',462
    334 out: { seq, plugin_done: reply }456 name: plugin.name,463
    335 });457 seq: seq,464
    336 });458
    };465
    337 461 delegate.act({460
    if (
    plugin.tag !== null
    ) {
    467
    338 role: 'seneca',461461 plugin_define_pattern.tag = plugin.tag;468
    339 plugin: 'define',462 }469
    340 name: plugin.name,463461 return new Promise(resolve => {471
    341 tag: plugin.tag,464 // seneca473
    342 seq: seq,465 delegate.add(plugin_define_pattern, (_, reply) => {474
    343 default$: {},466 resolve({475
    344 fatal$: true,467 op: 'merge',476
    345 local$: true,468 out: { seq, plugin_done: reply }477
    346 });469 });478
    347 });470 });479
    348 },471461 delegate.act({481
    349 define: (spec) => {474 role: 'seneca',482
    350 let seneca = spec.ctx.seneca;475 plugin: 'define',483
    351 461 let so = seneca.options();476 name: plugin.name,484
    352 461 let plugin = spec.data.plugin;478 tag: plugin.tag,485
    353 461 let plugin_done = spec.data.plugin_done;479
    354 seq: seq,486
    354 //return new Promise((resolve) => {482 default$: {},487
    355 461 var plugin_seneca = spec.data.delegate;483 fatal$: true,488
    356 461 var plugin_options = resolve_options(plugin.fullname, plugin, seneca);484 local$: true,489
    357 // Update stored plugin options (NOTE . != _ !!!)486 });490
    358 460 plugin.options = { ...plugin.options, ...plugin_options };487 });491
    359 // Update plugin options data in Seneca options.489 },492
    360 460 var seneca_options = { plugin: {} };490 options: (spec) => {495
    361 460 seneca_options.plugin[plugin.fullname] = plugin.options;491 let seneca = spec.ctx.seneca;496
    362 460 seneca.options(seneca_options);492461 let plugin = spec.data.plugin;497
    363 460 plugin_seneca.log.debug({494 //let options = resolve_options(plugin.fullname, plugin, seneca)499
    364 kind: 'plugin',495461 let so = seneca.options();502
    365 case: 'DEFINE',496
    461 let fullname = plugin.fullname;503
    366 name: plugin.name,497
    let defaults =
    plugin.defaults
    ||
    {}
    ;
    504
    367 tag: plugin.tag,498461 let fullname_options = Object.assign({}, 507
    368 options: plugin_options,499 // DEPRECATED: remove in 4509
    369 callpoint: spec.ctx.callpoint,500 so[fullname], so.plugin[fullname], 512
    370 });501 // DEPRECATED: remove in 4514
    371 460 var meta = define_plugin(plugin_seneca, plugin, seneca.util.clean(plugin_options));507 so[fullname + '$' + plugin.tag], so.plugin[fullname + '$' + plugin.tag]);518
    372 455 plugin.meta = meta;509461 var shortname = fullname !== plugin.name ? plugin.name : null;520
    373 // legacy api for service function511
    461 if (!shortname && fullname.indexOf('seneca-') === 0) {521
    374
    if (
    'function' === typeof meta
    ) {
    512
    16 shortname = fullname.substring('seneca-'.length);522
    375 meta = { service: meta };513 }523
    376 }514461 var shortname_options = Object.assign({}, 526
    377 // Plugin may have changed its own name dynamically516 // DEPRECATED: remove in 4528
    378 455 plugin.name = meta.name || plugin.name;518 so[shortname], so.plugin[shortname], 531
    379 455 plugin.tag =519
    // DEPRECATED: remove in 4533
    380
    meta.tag || plugin.tag || (
    plugin.options
    &&
    plugin.options.tag$
    );
    520 so[shortname + '$' + plugin.tag], so.plugin[shortname + '$' + plugin.tag]);537
    381 455 plugin.fullname = Common.make_plugin_key(plugin);522
    461 let base = {};539
    382
    plugin.service =
    meta.service
    || plugin.service;
    523
    // NOTE: plugin error codes are in their own namespaces541
    383 455 plugin_seneca.__update_plugin__(plugin);525
    let errors =
    plugin.errors
    || (
    plugin.define
    && plugin.define.errors);
    542
    384 455 seneca.private$.plugins[plugin.fullname] = plugin;527461 if (errors) {544
    385 455 seneca.private$.plugin_order.byname.push(plugin.name);5295 base.errors = errors;545
    386 455 seneca.private$.plugin_order.byname = Uniq(seneca.private$.plugin_order.byname);532
    }546
    387 455 seneca.private$.plugin_order.byref.push(plugin.fullname);533
    let outopts = Object.assign(base, shortname_options, fullname_options,
    plugin.options
    ||
    {}
    );
    553
    388 455 var exports = spec.data.exports;535461 let resolved_options = {};555
    389 //console.log('EXPORTS', exports)536461 try {557
    390 //var exports = resolve_plugin_exports(plugin_seneca, plugin.fullname, meta)537461 resolved_options = seneca.util558
    391 // 3.x Backwards compatibility - REMOVE in 4.x539
    .Optioner(defaults, { allow_unknown: true })559
    392
    if (
    'amqp-transport' === plugin.name
    ) {
    540
    .check(outopts);560
    393 seneca.options({ legacy: { meta: true } });541 }561
    394 }542
    catch (e) {561
    395
    if (
    'function' === typeof plugin_options.defined$
    ) {
    544
    1 throw Common.error('invalid_plugin_option', {562
    396 plugin_options.defined$(plugin);545 name: fullname,563
    397 }546 err_msg: e.message,564
    398 // If init$ option false, do not execute init action.548
    options: outopts,565
    399
    if (
    false === plugin_options.init$
    ) {
    549
    });566
    400 plugin_done();550 }567
    401 //return resolve()551 //let options = { ...plugin.options, ...resolved_options }569
    402 }552460 return {572
    403 455 plugin_seneca.log.debug({554 op: 'seneca_options',573
    404 kind: 'plugin',555 out: {574
    405 case: 'INIT',556 plugin: {575
    406 name: plugin.name,557 options: resolved_options576
    407 tag: plugin.tag,558 }577
    408 exports: exports,559 }578
    409 });560 };579
    410 455 plugin_seneca.act({563 },580
    411 role: 'seneca',564 define: (spec) => {583
    412 plugin: 'init',565 let seneca = spec.ctx.seneca;584
    413 seq: spec.data.seq,566460 let so = seneca.options();585
    414 init: plugin.name,567460 let plugin = spec.data.plugin;587
    415 tag: plugin.tag,568460 let plugin_done = spec.data.plugin_done;588
    416 default$: {},569460 var plugin_seneca = spec.data.delegate;590
    417 fatal$: true,570460 var plugin_options = spec.data.plugin.options;591
    418 local$: true,571 /*594
    419 }, function (err) {573 var plugin_options = resolve_options(plugin.fullname, plugin, seneca)
    420 //try {574
    421 if (err) {575 // Update stored plugin options (NOTE . != _ !!!)
    422 2 var plugin_err_code = 'plugin_init';576 plugin.options = { ...plugin.options, ...plugin_options }
    423 2 plugin.plugin_error = err.message;578
    424
    if (
    err.code === 'action-timeout'
    ) {
    580
    // Update plugin options data in Seneca options.
    425 plugin_err_code = 'plugin_init_timeout';581
    var seneca_options: any = { plugin: {} }
    426 plugin.timeout = so.timeout;582 seneca_options.plugin[plugin.fullname] = plugin.options
    427 }583 seneca.options(seneca_options)
    428 2 return plugin_seneca.die(585 */604
    429 //internals.error(err, plugin_err_code, plugin)586460 plugin_seneca.log.debug({608
    430 seneca.error(err, plugin_err_code, plugin));588 kind: 'plugin',609
    431 }589 case: 'DEFINE',610
    432 453 var fullname = plugin.name + (plugin.tag ? '$' + plugin.tag : '');591
    name: plugin.name,611
    433
    if (
    so.debug.print
    && so.debug.print.options) {
    593 tag: plugin.tag,612
    434 2 Print.plugin_options(seneca, fullname, plugin_options);594 options: plugin_options,613
    435 }595 callpoint: spec.ctx.callpoint,614
    436 453 plugin_seneca.log.info({597 });615
    437 kind: 'plugin',598460 var meta = define_plugin(plugin_seneca, plugin, seneca.util.clean(plugin_options));621
    438 case: 'READY',599455 plugin.meta = meta;624
    439 name: plugin.name,600
    // legacy api for service function626
    440 tag: plugin.tag,601
    if (
    'function' === typeof meta
    ) {
    627
    441 });602
    meta = { service: meta };628
    442
    if (
    'function' === typeof plugin_options.inited$
    ) {
    604
    }629
    443 plugin_options.inited$(plugin);605 // Plugin may have changed its own name dynamically631
    444 }606455 plugin.name = meta.name || plugin.name;633
    445 453 plugin_done();608
    455 plugin.tag =634
    446 //return resolve()609
    meta.tag || plugin.tag || (
    plugin.options
    &&
    plugin.options.tag$
    );
    635
    447 //} catch (e) {611
    455 plugin.fullname = Common.make_plugin_key(plugin);637
    448 // console.log('QWE', e)612
    plugin.service =
    meta.service
    || plugin.service;
    638
    449 // }613455 plugin_seneca.__update_plugin__(plugin);640
    450 });615455 seneca.private$.plugins[plugin.fullname] = plugin;642
    451 // TODO: test this, with preload, explicitly617455 seneca.private$.plugin_order.byname.push(plugin.name);644
    452 455 return {618 seneca.private$.plugin_order.byname = Uniq(seneca.private$.plugin_order.byname);647
    453 op: 'merge',619455 seneca.private$.plugin_order.byref.push(plugin.fullname);648
    454 out: {620455 var exports = spec.data.exports;650
    455 meta,621 //console.log('EXPORTS', exports)651
    456 }622 //var exports = resolve_plugin_exports(plugin_seneca, plugin.fullname, meta)652
    457 };623
    // 3.x Backwards compatibility - REMOVE in 4.x654
    458 },625
    if (
    'amqp-transport' === plugin.name
    ) {
    655
    459 };626 seneca.options({ legacy: { meta: true } });656
    460 }627
    }657
    461 function resolve_options(fullname, plugindef, seneca) {629
    if (
    'function' === typeof plugin_options.defined$
    ) {
    659
    462 461 var so = seneca.options();630
    plugin_options.defined$(plugin);660
    463
    var defaults =
    plugindef.defaults
    ||
    {}
    ;
    632 }661
    464 461 var fullname_options = Object.assign({}, 635
    // If init$ option false, do not execute init action.663
    465 // DEPRECATED: remove in 4637
    if (
    false === plugin_options.init$
    ) {
    664
    466 so[fullname], so.plugin[fullname], 640 plugin_done();665
    467 // DEPRECATED: remove in 4642 //return resolve()666
    468 so[fullname + '$' + plugindef.tag], so.plugin[fullname + '$' + plugindef.tag]);646 }667
    469 461 var shortname = fullname !== plugindef.name ? plugindef.name : null;648455 plugin_seneca.log.debug({669
    470 461 if (!shortname && fullname.indexOf('seneca-') === 0) {649 kind: 'plugin',670
    471 16 shortname = fullname.substring('seneca-'.length);650 case: 'INIT',671
    472 }651 name: plugin.name,672
    473 461 var shortname_options = Object.assign({}, 654 tag: plugin.tag,673
    474 // DEPRECATED: remove in 4656 exports: exports,674
    475 so[shortname], so.plugin[shortname], 659 });675
    476 // DEPRECATED: remove in 4661455 plugin_seneca.act({678
    477 so[shortname + '$' + plugindef.tag], so.plugin[shortname + '$' + plugindef.tag]);665 role: 'seneca',679
    478 461 var base = {};667 plugin: 'init',680
    479 // NOTE: plugin error codes are in their own namespaces669
    seq: spec.data.seq,681
    480
    var errors =
    plugindef.errors
    || (
    plugindef.define
    && plugindef.define.errors);
    670 init: plugin.name,682
    481 461 if (errors) {672 tag: plugin.tag,683
    482 5 base.errors = errors;673 default$: {},684
    483 }674
    fatal$: true,685
    484
    var outopts = Object.assign(base, shortname_options, fullname_options,
    plugindef.options
    ||
    {}
    );
    681 local$: true,686
    485 461 try {683 }, function (err) {688
    486 461 return seneca.util684 //try {689
    487 .Optioner(defaults, { allow_unknown: true })685 if (err) {690
    488 .check(outopts);6862 var plugin_err_code = 'plugin_init';691
    489 }687
    2 plugin.plugin_error = err.message;693
    490 catch (e) {687
    if (
    err.code === 'action-timeout'
    ) {
    695
    491 1 throw Common.error('invalid_plugin_option', {688
    plugin_err_code = 'plugin_init_timeout';696
    492 name: fullname,689 plugin.timeout = so.timeout;697
    493 err_msg: e.message,690 }698
    494 options: outopts,6912 return plugin_seneca.die(700
    495 });692 //internals.error(err, plugin_err_code, plugin)701
    496 }693 seneca.error(err, plugin_err_code, plugin));703
    497 }694 }704
    498 function define_plugin(delegate, plugin, options) {697
    453 var fullname = plugin.name + (plugin.tag ? '$' + plugin.tag : '');706
    499 // legacy plugins698
    if (
    so.debug.print
    && so.debug.print.options) {
    708
    500 460 if (plugin.define.length > 1) {6992 Print.plugin_options(seneca, fullname, plugin_options);709
    501 1 let fnstr = plugin.define.toString();700
    }710
    502
    plugin.init_func_sig = (
    fnstr.match(/^(.*)\r*\n/)
    ||
    []
    )[1];
    701453 plugin_seneca.log.info({712
    503 1 let ex = delegate.error('unsupported_legacy_plugin', plugin);702 kind: 'plugin',713
    504 1 throw ex;703 case: 'READY',714
    505 }704 name: plugin.name,715
    506 459 if (options.errors) {706 tag: plugin.tag,716
    507 5 plugin.eraro = Eraro({707
    });717
    508 package: 'seneca',708
    if (
    'function' === typeof plugin_options.inited$
    ) {
    719
    509 msgmap: options.errors,709 plugin_options.inited$(plugin);720
    510 override: true,710 }721
    511 });711453 plugin_done();723
    512 }712 //return resolve()724
    513 459 var meta;714 //} catch (e) {726
    514 459 try {716 // console.log('QWE', e)727
    515 459 meta = plugin.define.call(delegate, options) || {};717 // }728
    516 }718 });730
    517 catch (e) {718 // TODO: test this, with preload, explicitly732
    518 4 Common.wrap_error(e, 'plugin_define_failed', {719455 return {733
    519 fullname: plugin.fullname,720 op: 'merge',734
    520 message: (e.message + (' (' + e.stack.match(/\n.*?\n/)).replace(/\n.*\//g, '')).replace(/\n/g, ''),723 out: {735
    521 options: options,724
    meta,736
    522
    repo:
    plugin.repo
    ?
    ' ' + plugin.repo + '/issues'
    : '',
    725 }737
    523 });726 };738
    524 }727
    },740
    525
    meta =
    'string' === typeof meta
    ?
    { name: meta }
    : meta;
    729 };741
    526 455 meta.options = meta.options || options;730}742
    527 455 var updated_options = {};732/*744
    528 455 updated_options[plugin.fullname] = meta.options;733function resolve_options(fullname: string, plugindef: any, seneca: any): any {
    529 455 delegate.options(updated_options);734 var so = seneca.options()
    530 455 return meta;736
    531 }737 var defaults = plugindef.defaults || {}
    532
    533 var fullname_options = Object.assign(
    534 {},
    535
    536 // DEPRECATED: remove in 4
    537 so[fullname],
    538
    539 so.plugin[fullname],
    540
    541 // DEPRECATED: remove in 4
    542 so[fullname + '$' + plugindef.tag],
    543
    544 so.plugin[fullname + '$' + plugindef.tag]
    545 )
    546
    547 var shortname = fullname !== plugindef.name ? plugindef.name : null
    548 if (!shortname && fullname.indexOf('seneca-') === 0) {
    549 shortname = fullname.substring('seneca-'.length)
    550 }
    551
    552 var shortname_options = Object.assign(
    553 {},
    554
    555 // DEPRECATED: remove in 4
    556 so[shortname],
    557
    558 so.plugin[shortname],
    559
    560 // DEPRECATED: remove in 4
    561 so[shortname + '$' + plugindef.tag],
    562
    563 so.plugin[shortname + '$' + plugindef.tag]
    564 )
    565
    566 var base: any = {}
    567
    568 // NOTE: plugin error codes are in their own namespaces
    569 var errors = plugindef.errors || (plugindef.define && plugindef.define.errors)
    570
    571 if (errors) {
    572 base.errors = errors
    573 }
    574
    575 var outopts = Object.assign(
    576 base,
    577 shortname_options,
    578 fullname_options,
    579 plugindef.options || {}
    580 )
    581
    582 try {
    583 return seneca.util
    584 .Optioner(defaults, { allow_unknown: true })
    585 .check(outopts)
    586 } catch (e) {
    587 throw Common.error('invalid_plugin_option', {
    588 name: fullname,
    589 err_msg: e.message,
    590 options: outopts,
    591 })
    592 }
    593}
    594*/811
    595function define_plugin(delegate, plugin, options) {813
    596 // legacy plugins814
    597460 if (plugin.define.length > 1) {815
    5981 let fnstr = plugin.define.toString();816
    599
    plugin.init_func_sig = (
    fnstr.match(/^(.*)\r*\n/)
    ||
    []
    )[1];
    817
    6001 let ex = delegate.error('unsupported_legacy_plugin', plugin);818
    6011 throw ex;819
    602 }820
    603459 if (options.errors) {822
    6045 plugin.eraro = Eraro({823
    605 package: 'seneca',824
    606 msgmap: options.errors,825
    607 override: true,826
    608 });827
    609 }828
    610459 var meta;830
    611459 try {832
    612459 meta = plugin.define.call(delegate, options) || {};833
    613 }834
    614 catch (e) {834
    6154 Common.wrap_error(e, 'plugin_define_failed', {835
    616 fullname: plugin.fullname,836
    617 message: (e.message + (' (' + e.stack.match(/\n.*?\n/)).replace(/\n.*\//g, '')).replace(/\n/g, ''),839
    618 options: options,840
    619
    repo:
    plugin.repo
    ?
    ' ' + plugin.repo + '/issues'
    : '',
    841
    620 });842
    621 }843
    622
    meta =
    'string' === typeof meta
    ?
    { name: meta }
    : meta;
    845
    623455 meta.options = meta.options || options;846
    624455 var updated_options = {};848
    625455 updated_options[plugin.fullname] = meta.options;849
    626455 delegate.options(updated_options);850
    627455 return meta;852
    628}853
    629 //# sourceMappingURL=use.js.map