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

seneca

Package Overview
Dependencies
Maintainers
1
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seneca - npm Package Compare versions

Comparing version 3.9.0 to 3.10.0

5

CHANGES.md

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

## 3.10.0 2019-05-12
* Added explain$ directive to seneca.act - see test/explain.test.js - allows message actions to provide context-specific explanation data for behaviour on an ad hoc basis.
## 3.9.0 2019-05-06

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

@@ -16,2 +16,12 @@ /* Copyright © 2010-2018 Richard Rodger and other contributors, MIT License. */

exports.explain = function(toggle) {
if (true === toggle) {
return (this.private$.explain = [])
} else if (false === toggle) {
var out = this.private$.explain
delete this.private$.explain
return out
}
}
// Create a Seneca Error, OR set a global error handler function

@@ -419,2 +429,17 @@ exports.error = function(first) {

if (item) {
// Add any additional explain items from responder
if (
item.meta.explain &&
spec.meta.explain &&
item.meta.explain.length < spec.meta.explain.length
) {
for (
var i = item.meta.explain.length;
i < spec.meta.explain.length;
i++
) {
item.meta.explain.push(spec.meta.explain[i])
}
}
item.reply(spec.err, spec.out, spec.meta)

@@ -421,0 +446,0 @@ }

88

lib/inward.js
/* Copyright © 2010-2019 Richard Rodger and other contributors, MIT License. */
'use strict'
var Util = require('util')
var Assert = require('assert')
const Util = require('util')
var _ = require('lodash')
// TODO: remove
const _ = require('lodash')
var Common = require('./common')
const Common = require('./common')
const intern = {}
module.exports = {

@@ -23,3 +25,4 @@ msg_modify: inward_msg_modify,

prepare_delegate: inward_prepare_delegate,
announce: inward_announce
announce: inward_announce,
intern: intern
}

@@ -163,4 +166,2 @@

Assert(ctxt.actdef)
if (!_.isFunction(ctxt.actdef.validate)) {

@@ -241,4 +242,2 @@ return

Assert(ctxt.actdef)
if (so.debug.deprecation && ctxt.actdef.deprecate) {

@@ -259,2 +258,4 @@ ctxt.seneca.log.warn({

// console.log('MSG', data.msg)
meta.pattern = ctxt.actdef.pattern

@@ -285,6 +286,20 @@ meta.action = ctxt.actdef.id

)
// meta.explain is an array that explanation objects can be appended to.
// The same array is used through the action call tree, and must be provided by
// calling code at the top level via the explain$ directive.
if (data.msg.explain$ && Array.isArray(data.msg.explain$)) {
meta.explain = data.msg.explain$
} else if (parent && parent.explain) {
meta.explain = parent.explain
}
if (ctxt.seneca.private$.explain) {
meta.explain = meta.explain || []
ctxt.seneca.private$.explain.push(meta.explain)
}
}
function inward_prepare_delegate(ctxt, data) {
Assert(data.reply)
var meta = data.meta

@@ -317,2 +332,55 @@ ctxt.seneca.fixedargs.tx$ = data.meta.tx

}
ctxt.seneca.explain = intern.explain.bind(ctxt.seneca, meta)
if (meta.explain) {
ctxt.seneca.explain({ explain$: true, msg$: Common.clean(data.msg) })
}
}
intern.explain = function(meta, entry) {
var orig_explain = this.explain
var explain = meta.explain
if (true === entry || false === entry) {
return orig_explain.call(this, entry)
} else if (explain) {
if (null != entry) {
if (entry.explain$) {
entry.explain$ = {
start: meta.start,
pattern: meta.pattern,
action: meta.action,
id: meta.id,
instance: meta.instance,
tag: meta.tag,
seneca: meta.seneca,
version: meta.version,
gate: meta.gate,
fatal: meta.fatal,
local: meta.local,
closing: meta.closing,
timeout: meta.timeout,
dflt: meta.dflt,
custom: meta.custom,
plugin: meta.plugin,
prior: meta.prior,
caller: meta.caller,
parents: meta.parents,
remote: meta.remote,
sync: meta.sync,
trace: meta.trace,
sub: meta.sub,
data: meta.data,
err: meta.err,
err_trace: meta.err_trace,
error: meta.error,
empty: meta.empty
}
}
explain.push('object' === typeof entry ? entry : { content: entry })
}
}
return explain && this.explain
}

@@ -101,2 +101,3 @@ /* Copyright © 2015-2018 Richard Rodger and other contributors, MIT License. */

msg.custom$ = meta.custom
msg.explain$ = meta.explain

@@ -103,0 +104,0 @@ msg.parents$ = meta.parents || []

2

package.json
{
"name": "seneca",
"description": "A Microservices Framework for Node.js",
"version": "3.9.0",
"version": "3.10.0",
"license": "MIT",

@@ -6,0 +6,0 @@ "homepage": "http://senecajs.org",

@@ -429,2 +429,3 @@ /* Copyright © 2010-2018 Richard Rodger and other contributors, MIT License. */

root$.fail = opts.$.legacy.fail ? Legacy.make_legacy_fail(opts.$) : API.fail // Throw a Seneca error
root$.explain = API.explain // Toggle top level explain capture

@@ -431,0 +432,0 @@ root$.add = api_add // Add a pattern an associated action.

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc