New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bakeryjs

Package Overview
Dependencies
Maintainers
4
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bakeryjs - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

7

build/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServiceProvider = exports.boxFactory = exports.Program = void 0;
const Program_1 = require("./lib/bakeryjs/Program");
exports.Program = Program_1.Program;
Object.defineProperty(exports, "Program", { enumerable: true, get: function () { return Program_1.Program; } });
const Box_1 = require("./lib/bakeryjs/Box");
exports.boxFactory = Box_1.boxFactory;
Object.defineProperty(exports, "boxFactory", { enumerable: true, get: function () { return Box_1.boxFactory; } });
const ServiceProvider_1 = require("./lib/bakeryjs/ServiceProvider");
exports.ServiceProvider = ServiceProvider_1.ServiceProvider;
Object.defineProperty(exports, "ServiceProvider", { enumerable: true, get: function () { return ServiceProvider_1.ServiceProvider; } });
if (require.main === module) {

@@ -10,0 +11,0 @@ const drainCbk = (msg) => {

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

Object.defineProperty(exports, "__esModule", { value: true });
const Message_1 = require("./Message");
exports.boxFactory = exports.noopQueue = void 0;
const verror_1 = __importDefault(require("verror"));

@@ -126,3 +126,3 @@ const assert_1 = require("assert");

* @param parameters - any run-time configuration passed from the Job
* @emits 'msg_finished'
* @emits 'msg_finished', 'generation_finished'
*/

@@ -208,4 +208,14 @@ constructor(name, meta, serviceProvider, queue, parameters) {

guardedQ.revoke();
this.queue.push(value.createSentinel(siblingsCount, retValue));
return;
this.emit('generation_finished', [
{
boxName: this.name,
messageId: value.id,
parentMsgId: value.parent && value.parent.id,
generated: siblingsCount,
},
]);
// TODO: what to do with the retValue?
// I might have stopped in the middle of generation due to external problems
// (e.g. social network refuses to keep responding )
return retValue;
}

@@ -261,10 +271,6 @@ catch (error) {

*
* - the box is a *mapper*. The batch is filtered and splitted into @SentinelMessage[]
* and @DataMessage[]. The sentinels are pushed into output queue directly,
* the DataMessage batch is passed into the mapper, the response
* - the box is a *mapper*. The DataMessage batch is passed into the mapper, the response
* is awaited and pushed into the output queue.
*
* - the box is a *generator*. The batch is filtered and splitted into @SentinelMessage[]
* and @DataMessage[]. The sentinels are pushed into output queue directly.
* The DataMessages are then *sequentially* passed into the generator. The generator
* - the box is a *generator*. The DataMessages are *sequentially* passed into the generator. The generator
* is awaited, so that the processing of the batch is sequential.

@@ -286,6 +292,2 @@ *

}
if (Message_1.isSentinel(msg)) {
this.queue.push(msg);
return;
}
try {

@@ -423,10 +425,6 @@ if (isMapper) {

*
* - the box is a *mapper*. The batch is filtered and splitted into @SentinelMessage[]
* and @DataMessage[]. The sentinels are pushed into output queue directly,
* the DataMessage batch is passed into the mapper, the response
* - the box is a *mapper*. The DataMessage batch is passed into the mapper, the response
* is awaited and pushed into the output queue.
*
* - the box is a *generator*. The batch is filtered and splitted into @SentinelMessage[]
* and @DataMessage[]. The sentinels are pushed into output queue directly.
* The DataMessages are then *sequentially* passed into the generator. The generator
* - the box is a *generator*. The DataMessages are then *sequentially* passed into the generator. The generator
* is awaited, so that the processing of the batch is sequential.

@@ -447,7 +445,3 @@ *

}
const sentinels = batch.filter((msg) => Message_1.isSentinel(msg));
if (sentinels.length > 0) {
this.queue.push(sentinels);
}
const data = batch.filter((msg) => Message_1.isData(msg));
const data = batch;
if (data.length > 0) {

@@ -454,0 +448,0 @@ try {

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

parentMsgId: string | undefined;
isSentinel: boolean;
generated?: number;
};

@@ -15,0 +15,0 @@ declare type ModuleOutput = {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Message_1 = require("./Message");
exports.boxEvents = void 0;
function boxEvents(flowEmitter) {

@@ -29,3 +29,2 @@ /**

parentMsgId: { value: m.parent && m.parent.id },
isSentinel: { value: Message_1.isSentinel(m) },
}));

@@ -32,0 +31,0 @@ flowEmitter.emit('msg_finished', messagesTrace);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DAGBuilder = exports.ROOT_NODE = void 0;
const jsnetworkx_1 = require("jsnetworkx");

@@ -4,0 +5,0 @@ const joinedQueue_1 = require("./joinedQueue");

@@ -15,2 +15,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.QZip = exports.Tee = void 0;
const verror_1 = require("verror");

@@ -17,0 +18,0 @@ const assert_1 = __importDefault(require("assert"));

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultVisualBuilder = void 0;
const TERMINAL_WIDTH = 80;

@@ -4,0 +5,0 @@ class DefaultVisualBuilder {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MilanBuilder = exports.ROOT_NODE = void 0;
const MemoryPriorityQueue_1 = require("../queue/MemoryPriorityQueue");

@@ -4,0 +5,0 @@ const assert_1 = require("assert");

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MultiComponentFactory = exports.ComponentFactory = void 0;
const verror_1 = require("verror");

@@ -11,0 +24,0 @@ const scanComponentsPath_1 = require("./scanComponentsPath");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseComponentName = void 0;
const REMOVABLE_SUBSTRINGS = [

@@ -4,0 +5,0 @@ '_/',

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasProcess = exports.hasFlow = exports.FlowIdDescValidation = exports.Flow = void 0;
const Message_1 = require("./Message");

@@ -80,10 +81,7 @@ const jsnetworkx_1 = require("jsnetworkx");

const boxAttribs = boxWithAttribs[1];
boxAttribs.instance.on('msg_finished', (msgInfos) => msgInfos.forEach((msgInfo) => {
if (msgInfo.isSentinel) {
this.tracingModel.setDimensionComplete(msgInfo.parentMsgId || '-', msgInfo.boxName);
}
else {
this.tracingModel.addMsg(msgInfo.messageId, msgInfo.parentMsgId || '-', msgInfo.boxName);
}
}));
boxAttribs.instance.on('msg_finished', (msgInfos) =>
// TODO: Defer checking after all the messages of the batch have been added
msgInfos.forEach((msgInfo) => this.tracingModel.addMsg(msgInfo.messageId, msgInfo.parentMsgId || '-', msgInfo.boxName)));
// if the instance is the generator, subscribe for `generation_finished`
boxAttribs.instance.on('generation_finished', (msgInfos) => msgInfos.forEach((msgInfo) => this.tracingModel.setDimensionComplete(msgInfo.messageId || '-', msgInfo.boxName)));
}

@@ -90,0 +88,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SchemaObjectValidation = void 0;
// TODO: export this automatically from type SchemaObject

@@ -4,0 +5,0 @@ exports.SchemaObjectValidation = {

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.FlowCatalog = void 0;
const FlowFactory_1 = __importDefault(require("./FlowFactory"));

@@ -8,0 +9,0 @@ const debug = require('debug')('bakeryjs:flowCatalog');

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Job = void 0;
let jobId = 0;

@@ -4,0 +5,0 @@ class Job {

@@ -9,48 +9,12 @@ export declare type MessageData = {

*/
interface IdMessage {
export interface Message {
readonly id: string;
readonly parent: IdMessage | undefined;
create(values: MessageData): IdMessage;
createSentinel(messageCount: number, retValue?: any): IdSentinel;
readonly parent: Message | undefined;
create(values?: MessageData): Message;
getInput(requires: string[]): MessageData;
setOutput(provides: string[], output: MessageData): void;
/**
* ## Flag of the sentinel message.
*
* Denotes that this message carries generated data (and that other may follow).
*/
readonly finished: false;
}
/**
* ### Sentinel message
* One piece of data flowing inside the Flow through Boxes.
*
* Imagine generation of *Messages* which are to be aggregated down the flow. The aggregator has access to
* the *id* of the Message the bunch belongs to but can't realize whether it has process all Messages to
* the particular parent Message *id*.
*
* The *Sentinel Message* contains the information. Though it has a unique *id* (as every other *Message*)
* the information is the number of its siblings (having the same parent id) generated. We cannot rely
* on the order of Messages (due to parallel processing & prioritization) so the SentinelMessage
* cannot just mean "all the data have arrived before me".
*
* The field *data* has different semantics. You can't access to fields of the parent *Message* through it.
* It holds a *Return Value* of the generator -- `undefined`, Error instance, Warning instance, etc.
*/
interface IdSentinel {
readonly id: string;
readonly parent: IdMessage;
readonly data: any;
readonly dataMessageCount: number;
/**
* ## Flag of the sentinel message.
*
* Denotes finished generation with optional result value. The *id* of the finished dimension is available
* in the field *id*. Any relevant parent data are available in through *parent*.
*
* The result value (which can be `undefined`, instance of `TypeError`, etc.) is stored in the field `data`.
*/
readonly finished: true;
}
export declare type Message = IdMessage | IdSentinel;
/**
* # Behaviour

@@ -62,3 +26,6 @@ * 1. Object that is identified by an *id*. The *id* is unique at lest within the flow being currently executed.

* # Intended use:
* A Message is Identifiable.
* - A Message is Identifiable.
* - Message holds the computed information in fields. The information in a field is *immutable* once written.
* - As Message flows through Boxes, each Box adds one or more field with arbitrary information.
* - The trace of the Message passage is reported by the flow executor into an API passed into Program
*

@@ -72,32 +39,13 @@ * ## Joints of Edges

* A generated Message must have an (abstract) link to its *parent* for the purpose of aggregation. The *parent* *id* plays
* a role of the GROUP BY expression.
*/
declare abstract class CIdentifiable {
private readonly _id;
readonly parent: IdMessage | undefined;
get id(): string;
protected constructor(parent: IdMessage | undefined);
}
export declare class SentinelMessage extends CIdentifiable implements IdSentinel {
readonly parent: IdMessage;
readonly data: any;
readonly finished: true;
readonly dataMessageCount: number;
constructor(messageCount: number, parent: IdMessage, retValue: any);
}
/**
* One piece of data flowing inside the Flow through Boxes.
* a role of the GROUP BY expression. The trace of the Message passage is reported by the flow executor into an API passed into Program
*
* - Message holds the computed information in fields. The information in a field is *immutable* once written.
* - As Message flows through Boxes, each Box adds one or more field with arbitrary information.
* - The trace of the Message passage is reported by the flow executor into an API passed into Program
*
* @internalapi
*/
export declare class DataMessage extends CIdentifiable implements IdMessage {
export declare class DataMessage implements Message {
private readonly _id;
protected data: MessageData;
readonly finished: false;
constructor(initData?: MessageData, parent?: IdMessage);
create(values?: MessageData): IdMessage;
createSentinel(dataMessageCount: number, retValue?: any): IdSentinel;
readonly parent: Message | undefined;
constructor(initData?: MessageData, parent?: Message);
get id(): string;
create(values?: MessageData): Message;
getInput(requires: string[]): MessageData;

@@ -107,4 +55,1 @@ setOutput(provides: string[], output: MessageData): void;

}
export declare function isData(m: Message): m is IdMessage;
export declare function isSentinel(m: Message): m is SentinelMessage;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataMessage = void 0;
const debug = require('debug')('bakeryjs:message');
let messageId = 0;
/**
* One piece of data flowing inside the Flow through Boxes.
*
* # Behaviour

@@ -12,3 +15,6 @@ * 1. Object that is identified by an *id*. The *id* is unique at lest within the flow being currently executed.

* # Intended use:
* A Message is Identifiable.
* - A Message is Identifiable.
* - Message holds the computed information in fields. The information in a field is *immutable* once written.
* - As Message flows through Boxes, each Box adds one or more field with arbitrary information.
* - The trace of the Message passage is reported by the flow executor into an API passed into Program
*

@@ -22,8 +28,11 @@ * ## Joints of Edges

* A generated Message must have an (abstract) link to its *parent* for the purpose of aggregation. The *parent* *id* plays
* a role of the GROUP BY expression.
* a role of the GROUP BY expression. The trace of the Message passage is reported by the flow executor into an API passed into Program
*
* @internalapi
*/
class CIdentifiable {
constructor(parent) {
class DataMessage {
constructor(initData, parent) {
this._id = `${messageId++}`;
this.parent = parent;
this.data = initData ? initData : {};
}

@@ -33,28 +42,2 @@ get id() {

}
}
class SentinelMessage extends CIdentifiable {
constructor(messageCount, parent, retValue) {
super(parent);
this.finished = true;
this.parent = parent; // WTF!!! without this, there is an error "My property parent is not set!"
this.data = retValue;
this.dataMessageCount = messageCount;
}
}
exports.SentinelMessage = SentinelMessage;
/**
* One piece of data flowing inside the Flow through Boxes.
*
* - Message holds the computed information in fields. The information in a field is *immutable* once written.
* - As Message flows through Boxes, each Box adds one or more field with arbitrary information.
* - The trace of the Message passage is reported by the flow executor into an API passed into Program
*
* @internalapi
*/
class DataMessage extends CIdentifiable {
constructor(initData, parent) {
super(parent);
this.finished = false;
this.data = initData ? initData : Object.create(null);
}
create(values) {

@@ -66,5 +49,2 @@ const newData = values

}
createSentinel(dataMessageCount, retValue) {
return new SentinelMessage(dataMessageCount, this, retValue);
}
// TODO: (code detail) the flow executor should create a Data Access Object that will guard the fields and

@@ -102,9 +82,1 @@ // pass the DAO into the box. The factory of the DAO could be a method of the Message.

exports.DataMessage = DataMessage;
function isData(m) {
return !m.finished;
}
exports.isData = isData;
function isSentinel(m) {
return m.finished;
}
exports.isSentinel = isSentinel;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.Program = void 0;
const Flow_1 = require("./Flow");

@@ -14,3 +15,2 @@ const Job_1 = require("./Job");

const FlowSchemaReader_1 = __importDefault(require("./FlowSchemaReader"));
const Message_1 = require("./Message");
const builder_1 = require("./builders/DAGBuilder/builder");

@@ -27,5 +27,5 @@ const stats_1 = require("./stats");

if (Array.isArray(msgs)) {
msgs.filter((msg) => Message_1.isData(msg)).forEach((msg) => drainCallback(msg.export()));
msgs.forEach((msg) => drainCallback(msg.export()));
}
else if (Message_1.isData(msgs)) {
else {
drainCallback(msgs.export());

@@ -32,0 +32,0 @@ }

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.MemoryPriorityBatchQueue = exports.MemoryPrioritySingleQueue = exports.AQueue = void 0;
const stats_1 = require("../stats");

@@ -14,0 +15,0 @@ // import {qTrace, sampleStats} from '../stats';

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.scanComponentsPath = void 0;
const path_1 = require("path");

@@ -11,0 +24,0 @@ const fs = __importStar(require("fs"));

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServiceProvider = void 0;
/**

@@ -4,0 +5,0 @@ * Container for both built-in and user-defined services.

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.sampleStats = exports.qTrace = exports.eventEmitter = void 0;
const assert_1 = __importDefault(require("assert"));

@@ -8,0 +9,0 @@ const events_1 = require("events");

@@ -15,7 +15,3 @@ /**

* incoming Message form so called *Dimension* (this is the dimension declared
* in the generator's metadata `emits`). Moreover, after all children have been
* generated, the *Sentinel Message* is generated, containing information about
* the number of children. The Sentinel Message serves the possible aggregator
* boxes downstream the graph, such that it knows whether it has aggregated all
* the messages of the dimension.
* in the generator's metadata `emits`).
*

@@ -65,7 +61,2 @@ * Every consistent flow has the property that each box processes only messages

* +-+ +-+ +-+
* Sentinel Messages:
* msg3@Dim1
* msg6@Dim2
* msg9@Dim11
* msgC@Dim11
*

@@ -111,9 +102,5 @@ * ### The Flow

*
* The flow subscribes to events `msg_finish` of the boxes providing information about message id, parent message id
* and whether it is sentinel. The regular message means "a message has successfully passed the box", the sentinel
* message means "all the children of parent message have been generated".
* The flow subscribes to events `msg_finish` and `generation_finished` of the boxes providing information about message id and parent message id.
*
* Remember, we can rely on the order of events only in the generating box (especially that SentinelMessage is generated
* as **the last one**). Down the flow, the messages will shuffle due to asynchronous and parallel processing in boxes.
* Moreover, the Sentinel Messages skip the Mapper Boxes, so they usually arrive into the aggregator **before the others**.
* Remember, we can rely on the order of events only in the generating box. Down the flow, the messages will shuffle due to asynchronous and parallel processing in boxes.
* Thus, after every new information a check of `done` state must be done.

@@ -120,0 +107,0 @@ */

@@ -16,7 +16,3 @@ "use strict";

* incoming Message form so called *Dimension* (this is the dimension declared
* in the generator's metadata `emits`). Moreover, after all children have been
* generated, the *Sentinel Message* is generated, containing information about
* the number of children. The Sentinel Message serves the possible aggregator
* boxes downstream the graph, such that it knows whether it has aggregated all
* the messages of the dimension.
* in the generator's metadata `emits`).
*

@@ -66,7 +62,2 @@ * Every consistent flow has the property that each box processes only messages

* +-+ +-+ +-+
* Sentinel Messages:
* msg3@Dim1
* msg6@Dim2
* msg9@Dim11
* msgC@Dim11
*

@@ -112,12 +103,9 @@ * ### The Flow

*
* The flow subscribes to events `msg_finish` of the boxes providing information about message id, parent message id
* and whether it is sentinel. The regular message means "a message has successfully passed the box", the sentinel
* message means "all the children of parent message have been generated".
* The flow subscribes to events `msg_finish` and `generation_finished` of the boxes providing information about message id and parent message id.
*
* Remember, we can rely on the order of events only in the generating box (especially that SentinelMessage is generated
* as **the last one**). Down the flow, the messages will shuffle due to asynchronous and parallel processing in boxes.
* Moreover, the Sentinel Messages skip the Mapper Boxes, so they usually arrive into the aggregator **before the others**.
* Remember, we can rely on the order of events only in the generating box. Down the flow, the messages will shuffle due to asynchronous and parallel processing in boxes.
* Thus, after every new information a check of `done` state must be done.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.TracingModel = void 0;
const builder_1 = require("./builders/DAGBuilder/builder");

@@ -192,2 +180,3 @@ /**

// Check the completion after each new information
// TODO: Defer checking after all the messages of the batch have been added
this.checkMsgFinishState(msgId, parentMsgId, dimension);

@@ -273,3 +262,3 @@ }

}
if (!process.env.USE_EXPERIMENTAL_TRACING) {
if (process.env.BAKERYJS_DISABLE_EXPERIMENTAL_TRACING) {
// All is checked.

@@ -276,0 +265,0 @@ // Set the message as `done`

{
"name": "bakeryjs",
"version": "0.0.3",
"version": "0.1.0",
"description": "FBP-inspired library",

@@ -43,4 +43,4 @@ "main": "build/index",

"eslint": "^7.0.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-jest": "^23.0.3",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-jest": "^24.0.0",
"eslint-plugin-prettier": "^3.1.0",

@@ -51,6 +51,6 @@ "eslint-plugin-typescript": "^0.14.0",

"nodemon": "^2.0.1",
"prettier": "2.0.5",
"prettier": "2.2.1",
"ts-jest": "^25.0.0",
"ts-node": "^8.3.0",
"typedoc": "^0.18.0",
"typedoc": "^0.20.18",
"typescript": "^3.5.3",

@@ -57,0 +57,0 @@ "typescript-eslint-parser": "^22.0.0"

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