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

seneca

Package Overview
Dependencies
Maintainers
2
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 0.5.21 to 0.6.0

29

lib/common.js

@@ -1,2 +0,2 @@

/* Copyright (c) 2010-2013 Richard Rodger, MIT License */
/* Copyright (c) 2010-2015 Richard Rodger, MIT License */
/* jshint node:true, asi:true, eqnull:true */

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

var _ = require('underscore')
var _ = require('lodash')

@@ -193,2 +193,4 @@

_.each(Array.prototype.slice.call(arguments, 1), function(src) {
next_prop:
for (var p in src) {

@@ -198,3 +200,9 @@ var v = src[p]

if( _.isString(v) || _.isNumber(v) || _.isBoolean(v) || _.isDate(v) || _.isFunction(v) || _.isRegExp(v) ) {
if( _.isString(v) ||
_.isNumber(v) ||
_.isBoolean(v) ||
_.isDate(v) ||
_.isFunction(v) ||
_.isArguments(v) ||
_.isRegExp(v) ) {
tar[p] = v

@@ -214,8 +222,15 @@ }

// objects with methods
else if( _.find(v,function(f){return _.isFunction(f)}) ) {
tar[p] = v
//else if( _.find(v,function(f){return _.isFunction(f)}) ) {
// tar[p] = v
//}
for( var f in v ) {
if( _.isFunction(f) ) {
tar[p] = v
break next_prop;
}
}
// else it's just a pure data object
else {
//else {
tar[p] = _.isObject( tar[p] ) ? tar[p] : (_.isArray(v) ? [] : {})

@@ -229,3 +244,3 @@

tar[p] = deepextend_impl( tar[p], src[p] )
}
//}
}

@@ -232,0 +247,0 @@ else {

@@ -1,2 +0,2 @@

/* Copyright (c) 2010-2014 Richard Rodger, MIT License */
/* Copyright (c) 2010-2015 Richard Rodger, MIT License */
/* jshint node:true, asi:true, eqnull:true */

@@ -7,9 +7,12 @@ "use strict";

var util = require('util')
var _ = require('underscore')
var _ = require('lodash')
var error = require('eraro')({package:'seneca',msgmap:ERRMSGMAP()})
var common = require('./common')
var noop = common.noop
function noop(){}

@@ -25,4 +28,2 @@

var private$ = self.private$ = function(){};

@@ -51,7 +52,2 @@

// Properties without '$' suffix are persisted

@@ -71,6 +67,7 @@ // id property is special: created if not present when saving

var self = this
var args = common.arrayify(arguments)
// set seneca instance, if provided as first arg
var canon, name, base, zone
// Set seneca instance, if provided as first arg.
if( args[0] && args[0].seneca ) {

@@ -80,4 +77,3 @@ self.private$.seneca = args.shift()

var canon
// Pull out props, if present.
var argprops = args[args.length-1]

@@ -90,2 +86,3 @@ var props = {}

// Normalize args.
while(args.length < 3 ) {

@@ -95,3 +92,2 @@ args.unshift(null)

var name, base, zone

@@ -150,2 +146,14 @@ if( _.isString(props.entity$) ) {

var entopts = self.private$.seneca.options().entity || {}
if( entopts.hide ) {
_.each( entopts.hide, function(hidden_fields,canon){
if( entity.is$(canon) ) {
entity.toString = hideToString(hidden_fields,entity.toString)
entity.inspect = entity.toString
}
})
}
self.log$('make',entity.canon$({string:true}),entity)

@@ -267,2 +275,3 @@ return entity

/* TODO: is this still needed? */
Entity.prototype.close$ = function(cb) {

@@ -277,5 +286,18 @@ var self = this

Entity.prototype.is$ = function( canonspec ) {
var self = this
var canon = canonspec ?
canonspec.entity$ ? canonspec.canon$({object:true}) :
parsecanon(canonspec) :
null;
if( !canon ) return false;
return util.inspect(self.canon$({object:true})) == util.inspect(canon)
}
Entity.prototype.canon$ = function(opt) {
var self = this
var si = self.private$.seneca

@@ -296,14 +318,21 @@ var canon = self.private$.canon

else if( opt.parse ) {
return parsecanon( opt.parse )
}
// change type, undef leaves untouched
canon.zone = void 0==opt.zone ? canon.zone : opt.zone
canon.base = void 0==opt.base ? canon.base : opt.base
canon.name = void 0==opt.name ? canon.name : opt.name
// DEPRECATED
else if( opt.change ) {
// explicit nulls delete
if( null === opt.zone ) delete canon.zone;
if( null === opt.base ) delete canon.base;
if( null === opt.name ) delete canon.name;
// change type, undef leaves untouched
canon.zone = void 0==opt.change.zone ? canon.zone : opt.change.zone
canon.base = void 0==opt.change.base ? canon.base : opt.change.base
canon.name = void 0==opt.change.name ? canon.name : opt.change.name
self.entity$ = self.canon$()
// explicit nulls delete
if( null === opt.zone ) delete canon.zone;
if( null === opt.base ) delete canon.base;
if( null === opt.name ) delete canon.name;
self.entity$ = self.canon$()
}
}

@@ -387,5 +416,18 @@

function hideToString(hidden,toString) {
return function(){
var entdata = this.data$()
entdata.canon$ = this.canon$
entdata.fields$ = this.fields$
entdata.private$ = this.private$
_.each(hidden,function(hide,field){
if( hide ) delete entdata[field];
})
return toString.call(entdata)
}
}
Entity.prototype.toString = function() {
var self = this
var si = self.private$.seneca

@@ -432,3 +474,3 @@ var sb = ['$',self.canon$({string:true}),':{id=',self.id,';']

}
else if( _.isString(qin) ) {
else if( _.isString(qin) || _.isNumber(qin) ) {
q = '' === qin ? null : {id:qin}

@@ -472,3 +514,3 @@ }

}
else throw new Error('invalid entity canon: "'+str+'"');
else throw error('invalid_canon',{str:str});

@@ -479,6 +521,14 @@ return out

Entity.parsecanon = parsecanon
function ERRMSGMAP() {
return {
invalid_canon: "Invalid entity canon: <%=str%>; expected format: zone/base/name."
}
}
exports.Entity = Entity
module.exports = function make_entity( canon, seneca ) {
return new Entity( canon, seneca )
}
module.exports.parsecanon = parsecanon

@@ -1,2 +0,2 @@

/* Copyright (c) 2013 Richard Rodger, MIT License */
/* Copyright (c) 2013-2015 Richard Rodger, MIT License */
/* jshint node:true, asi:true, eqnull:true */

@@ -9,6 +9,7 @@ "use strict";

var _ = require('underscore')
var gex = require('gex')
var _ = require('lodash')
var patrun = require('patrun')
var error = require('eraro')({package:'seneca',msgmap:ERRMSGMAP()})
var common = require('./common')

@@ -113,4 +114,2 @@

//console.log( 'MAKE', logspec, map )
var logrouter = new patrun()

@@ -155,4 +154,2 @@

var makelogroute = exports.makelogroute = function(entry,logrouter) {
//console.log('RAW-ENTRY',entry)
var propnames = ['level','type','plugin','tag','case']

@@ -201,3 +198,3 @@ var loglevels = ['debug', 'info', 'warn', 'error', 'fatal']

if( -1==loglevels.indexOf(level) ) {
throw new Error('unknown log level: '+level+', must be one of debug, info, warn, error, fatal')
throw error('invalid_log_level', {level:level})
}

@@ -370,2 +367,3 @@ })

var args = common.arrayify(arguments,2)
args.unshift(type)

@@ -375,2 +373,3 @@ args.unshift(level)

args.unshift(new Date())
var routing = {

@@ -387,4 +386,11 @@ level: args[2],

if( handler ) {
if( _.isFunction(args[args.length-1]) ) {
var logvals = args[args.length-1]()
var lastval = args[args.length-1]
if( _.isFunction(lastval) ) {
var logvals = []
try {
logvals = lastval()
}
catch(e) {
logvals = [e,e.stack]
}
args = args.slice(0,args.length-1).concat(logvals)

@@ -415,4 +421,2 @@ }

//console.log('SE',shortentries)
if( 0 < shortentries.length ) {

@@ -480,3 +484,149 @@ shortentries.forEach( function(shortentry) {

exports.parse_command_line = parse_command_line;
exports.parse_command_line = parse_command_line;
exports.log_act_in = function( instance, actinfo, actmeta, args, prior_ctxt ) {
if( actmeta.sub ) return;
instance.log.debug(
'act',
actmeta.plugin_name,
actmeta.plugin_tag,
'IN',
actinfo.actid,
actmeta.argpattern,
function() {
return [
actmeta.descdata ? actmeta.descdata(args) : common.descdata(args),
prior_ctxt.entry ? 'ENTRY' :
'PRIOR;'+(prior_ctxt.chain.slice(0,prior_ctxt.depth)).join(','),
'A;'+actmeta.id,
args.gate$ ? 'GATE' : '-'
]
})
}
exports.log_act_out =
function( instance, actinfo, actmeta, args, result, prior_ctxt )
{
if( actmeta.sub ) return;
instance.log.debug(
'act',
actmeta.plugin_name,
actmeta.plugin_tag,
'OUT',
actinfo.actid,
actmeta.argpattern,
actinfo.duration,
function() {
return _.flatten( [
_.flatten([
actmeta.descdata ?
actmeta.descdata(result.slice(1)) :
common.descdata(result.slice(1)) ],
true),
prior_ctxt.entry ? 'EXIT' :
'PRIOR;'+(prior_ctxt.chain.slice(0,prior_ctxt.depth)).join(','),
'A;'+actmeta.id,
args.gate$ ? 'GATE' : '-'
])
})
}
exports.log_act_err = function( instance, actinfo, actmeta, args, prior_ctxt, err ) {
if( false === err.log ) return;
// TODO err.log could be a log level
instance.log.error(
'act',
actmeta.plugin_name || '-',
actmeta.plugin_tag || '-',
'OUT',
actinfo.actid,
actmeta.pattern || '-',
actinfo.duration,
( actmeta.descdata ?
actmeta.descdata(args) : common.descdata(args) ),
prior_ctxt.entry ? 'ENTRY' :
'PRIOR;'+(prior_ctxt.chain.slice(0,prior_ctxt.depth)).join(','),
'A;'+actmeta.id,
args.gate$ ? 'GATE' : '-',
err.message,
err.code,
common.descdata(err.details),
err.stack
)
}
exports.log_act_cache = function( instance, actinfo, actmeta, args, prior_ctxt ) {
instance.log.debug(
'act',
actmeta.plugin_name,
actmeta.plugin_tag,
'OUT',
actinfo.actid,
actmeta.argpattern,
'CACHE',
prior_ctxt.entry ? 'ENTRY' :
'PRIOR;'+(prior_ctxt.chain.slice(0,prior_ctxt.depth)).join(','),
function() {
return [actmeta.descdata ?
actmeta.descdata(args) :
common.descdata(args),
'A='+actmeta.id]
})
}
exports.log_exec_err = function( instance, err ) {
if( false === err.log ) return;
err.details = err.details || {}
err.details.plugin = err.details.plugin || {}
instance.log.error(
'act',
err.details.plugin.name || '-',
err.details.plugin.tag || '-',
err.details.id || '-',
err.details.pattern || '-',
err.message,
err.code,
common.descdata(err.details),
err.stack )
}
exports.log_act_not_found = function( instance, err, loglevel ) {
if( false === err.log ) return;
loglevel = loglevel || 'warn'
if( 'ignore' == loglevel ) return;
err.details = err.details || {}
err.details.plugin = err.details.plugin || {}
instance.log(
loglevel,
'act',
err.details.plugin.name || '-',
err.details.plugin.tag || '-',
err.details.id || '-',
err.details.pattern || '-',
err.message,
err.code,
common.descdata(err.details),
err.stack )
}
function ERRMSGMAP() {
return {
invalid_log_level: "Unknown log level: <%=level%>; must be one of debug, info, warn, error, fatal."
}
}

@@ -1,2 +0,2 @@

/* Copyright (c) 2014 Richard Rodger, MIT License */
/* Copyright (c) 2014-2015 Richard Rodger, MIT License */
/* jshint node:true, asi:true, eqnull:true */

@@ -9,5 +9,5 @@ "use strict";

var _ = require('underscore')
var _ = require('lodash')
var jsonic = require('jsonic')
var error = require('eraro')({package:'optioner'})
var error = require('eraro')({package:'seneca',msgmap:ERRMSGMAP()})

@@ -35,3 +35,3 @@

if( fs.existsSync(FATAL_OPTIONS_FILE) ) {
throw error('Please use seneca.options.js as the defaults options file name. The alternate name options.seneca.js is not supported.',{from:FATAL_OPTIONS_FILE, module:callmodule});
throw error('inverted_file_name',{from:FATAL_OPTIONS_FILE, module:callmodule})
}

@@ -45,3 +45,5 @@

if( 'MODULE_NOT_FOUND' != e.code )
throw error(e,'require_default_options',{from:DEFAULT_OPTIONS_FILE, module:callmodule});
throw error(
e,'require_default_options',
{errmsg:e.message, from:DEFAULT_OPTIONS_FILE, module:callmodule});
}

@@ -70,7 +72,6 @@

}
/*
else if( _.isString(argv.seneca.options) ) {
// TODO: needs error msg as options must be object
// needs error msg as options must be object
throw error('cmd_line_seneca_options',{val:argv.seneca.options})
}
*/

@@ -181,1 +182,7 @@ if( _.isString(sourcemap.argv.from) ) {

function ERRMSGMAP() {
return {
inverted_file_name:'Please use seneca.options.js as the default options file name. The alternate name options.seneca.js is not supported.',
require_default_options: 'Call to require failed for <%=from%>: <%=errmsg%>.'
}
}

@@ -1,2 +0,2 @@

/* Copyright (c) 2014 Richard Rodger, MIT License */
/* Copyright (c) 2014-2015 Richard Rodger, MIT License */
/* jshint node:true, asi:true, eqnull:true */

@@ -6,4 +6,3 @@ "use strict";

var _ = require('underscore')
var async = require('async')
var _ = require('lodash')
var error = require('eraro')({package:'seneca'})

@@ -52,3 +51,3 @@

function make_delegate( instance, plugin, derived, options ) {
function make_delegate( instance, plugin, options ) {

@@ -63,3 +62,4 @@ // Adjust Seneca API to be plugin specific.

// Act calls inside the plugin definition function are not gated.
ungate$:true
ungate$:true,
fatal$:true,
})

@@ -71,3 +71,5 @@

args.splice(1,0,'plugin',plugin.name,derived.tag)
//args.splice(1,0,'plugin',plugin.name,derived.tag)
args.splice(1,0,'plugin',plugin.name,plugin.tag)
instance.log.apply(instance,args)

@@ -79,3 +81,2 @@ }

sd.die = options.makedie( sd, {type:'plugin',plugin:plugin.name} )
sd.fail = options.makefail( sd, {type:'plugin',plugin:plugin.name} )

@@ -86,3 +87,3 @@

var actmeta = args[args.length-1]
var actmeta = args[args.length-1] || {}

@@ -94,5 +95,5 @@ if( _.isFunction(actmeta) ) {

actmeta.plugin_nameref = derived.nameref
actmeta.plugin_name = plugin.name || '-'
actmeta.plugin_tag = plugin.tag || '-'
actmeta.plugin_fullname = plugin.fullname
actmeta.plugin_tag = derived.tag
actmeta.log = sd.log

@@ -116,18 +117,12 @@

function define_plugin( sd, plugin, options, done ) {
var init_args = [options]
function define_plugin( sd, plugin, options ) {
var is_normal = plugin.init.length <= 1
// legacy plugins with function(opts,cb)
if( !is_normal ) {
init_args.push( done )
// legacy plugins
if( 1 < plugin.init.length ) {
throw error('unsupported-legacy-plugin',plugin)
}
// legacy plugins with function(seneca,opts,cb)
if( 3 == plugin.init.length ) {
init_args.unshift(sd)
}
var meta = plugin.init.call(sd,options) || {}
var meta = plugin.init.apply(sd,init_args) || {}
meta = _.isString( meta ) ? {name:meta} : meta

@@ -140,5 +135,3 @@ meta.options = meta.options || options

if( is_normal ) {
return done(null,meta)
}
return meta;
}

@@ -145,0 +138,0 @@

@@ -1,2 +0,2 @@

/* Copyright (c) 2012-2013 Richard Rodger, BSD License */
/* Copyright (c) 2012-2015 Richard Rodger, MIT License */
/* jshint node:true, asi:true */

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

var _ = require('underscore')
var _ = require('lodash')
var nid = require('nid')

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

@@ -7,2 +7,9 @@ {

"service",
"microservice",
"micro-service",
"microservices",
"micro-services",
"services",
"micro services",
"micro service",
"framework",

@@ -15,3 +22,3 @@ "minimum",

],
"version": "0.5.21",
"version": "0.6.0",
"license": "MIT",

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

"Maciej Małecki (http://mmalecki.com)",
"Jake Pruitt",
"Jake Pruitt",
"Marian Radulescu",

@@ -35,5 +42,7 @@ "Alexandru Mircea"

"async": "~0.9.0",
"eraro": "~0.1.6",
"gex": "~0.1.3",
"eraro": "~0.4.0",
"gate-executor": "~0.2.0",
"gex": "~0.1.4",
"jsonic": "~0.1.1",
"lodash": "~2.4.1",
"lru-cache": "~2.5.0",

@@ -44,4 +53,4 @@ "minimist": "~0.1.0",

"optimist": "~0.6.1",
"parambulator": "~1.2.1",
"patrun": "~0.2.0",
"parambulator": "~1.4.0",
"patrun": "~0.4.2",
"rolling-stats": "~0.1.1",

@@ -51,8 +60,8 @@ "seneca-basic": "~0.1.0",

"seneca-mem-store": "~0.1.1",
"seneca-transport": "~0.2.5",
"seneca-transport": "~0.6.0",
"seneca-web": "~0.2.1",
"underscore": "~1.6.0",
"use-plugin": "~0.2.0"
"use-plugin": "~0.2.0",
"zig": "~0.0.2"
},
"main": "lib/seneca",
"main": "seneca.js",
"files": [

@@ -75,12 +84,11 @@ "LICENSE.txt",

"body-parser": "~1.4.3",
"chai": "~1.9.1",
"connect": "~3.0.1",
"connect-query": "~0.1.0",
"connect": "~3.0.2",
"connect-query": "~0.2.0",
"docco": "~0.6.2",
"fixture-stdout": "~0.2.1",
"jshint": "~2.1.11",
"jshint": "~2.6.0",
"mocha": "~1.20.1",
"seneca-error-test": "~0.1.0",
"seneca-error-test": "~0.2.2",
"timerstub": "~1.0.3"
}
}
# seneca - Node.js module
## A Node.js toolkit for Micro-Service Architctures
## A Node.js toolkit for Micro-Service Architectures
[![Gitter chat](https://badges.gitter.im/rjrodger/seneca.png)](https://gitter.im/rjrodger/seneca)
[![NPM](https://nodei.co/npm/seneca.png)](https://nodei.co/npm/seneca/)
[![NPM](https://nodei.co/npm-dl/seneca.png)](https://nodei.co/npm-dl/seneca/)
Seneca is a toolkit for organizing the business logic of your app. You

@@ -17,7 +14,6 @@ can break down your app into "stuff that happens", rather than

If you're using this module, feel free to contact me on twitter if you
have any questions! :) [@rjrodger](http://twitter.com/rjrodger)
Current Version: 0.5.21
Current Version: 0.6.0 (DEV)

@@ -24,0 +20,0 @@ Tested on: Node 0.10.31, and 0.11.13

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