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

@logicflow/engine

Package Overview
Dependencies
Maintainers
6
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@logicflow/engine - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

31

cjs/index.js

@@ -63,5 +63,7 @@ "use strict";

this.instanceId = ID_1.createEngineId();
this.recorder = new recorder_1.default({
instanceId: this.instanceId,
});
if (!(options === null || options === void 0 ? void 0 : options.debug)) {
this.recorder = new recorder_1.default({
instanceId: this.instanceId,
});
}
this.register({

@@ -154,9 +156,10 @@ type: StartNode_1.default.nodeTypeName,

Engine.prototype.getExecutionList = function () {
var _a;
return __awaiter(this, void 0, void 0, function () {
var executionIds;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.recorder.getExecutionList()];
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, ((_a = this.recorder) === null || _a === void 0 ? void 0 : _a.getExecutionList())];
case 1:
executionIds = _a.sent();
executionIds = _b.sent();
return [2 /*return*/, executionIds];

@@ -168,9 +171,10 @@ }

Engine.prototype.getExecutionRecord = function (executionId) {
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var tasks, records, i;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.recorder.getExecutionActions(executionId)];
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, ((_a = this.recorder) === null || _a === void 0 ? void 0 : _a.getExecutionActions(executionId))];
case 1:
tasks = _a.sent();
tasks = _c.sent();
if (!tasks) {

@@ -181,3 +185,3 @@ return [2 /*return*/, null];

for (i = 0; i < tasks.length; i++) {
records.push(this.recorder.getActionRecord(tasks[i]));
records.push((_b = this.recorder) === null || _b === void 0 ? void 0 : _b.getActionRecord(tasks[i]));
}

@@ -190,3 +194,4 @@ return [2 /*return*/, Promise.all(records)];

Engine.prototype.destroy = function () {
this.recorder.clear();
var _a;
(_a = this.recorder) === null || _a === void 0 ? void 0 : _a.clear();
};

@@ -193,0 +198,0 @@ Engine.prototype.getGlobalData = function () {

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

this.instanceId = instanceId;
var instances = storage_1.default.getItem(LOGICFLOW_ENGINE_INSTANCES) || [];
var instances = this.getItem(LOGICFLOW_ENGINE_INSTANCES) || [];
if (instances.indexOf(instanceId) === -1) {

@@ -57,3 +57,3 @@ instances.push(instanceId);

}
storage_1.default.setItem(LOGICFLOW_ENGINE_INSTANCES, instances);
this.setItem(LOGICFLOW_ENGINE_INSTANCES, instances);
}

@@ -63,2 +63,17 @@ Recorder.prototype.setMaxRecorderNumber = function (maxRecorder) {

};
// 将存储 storage 的方法收敛到此处,并在此处做异常处理 - setItem
Recorder.prototype.setItem = function (key, value) {
try {
storage_1.default.setItem(key, value);
}
catch (error) {
console.log('Ops, something wrong with storage.setItem');
storage_1.default.clear();
storage_1.default.setItem(key, value);
}
};
// getItem 方法
Recorder.prototype.getItem = function (key) {
return storage_1.default.getItem(key);
};
/*

@@ -89,3 +104,3 @@ * @param {Object} action

this.pushActionToExecution(executionId, actionId);
storage_1.default.setItem(actionId, action);
this.setItem(actionId, action);
return [2 /*return*/];

@@ -99,3 +114,3 @@ }

return __generator(this, function (_a) {
return [2 /*return*/, storage_1.default.getItem(actionId)];
return [2 /*return*/, this.getItem(actionId)];
});

@@ -107,3 +122,3 @@ });

return __generator(this, function (_a) {
return [2 /*return*/, storage_1.default.getItem(executionId)];
return [2 /*return*/, this.getItem(executionId)];
});

@@ -116,3 +131,3 @@ });

return __generator(this, function (_a) {
instances = storage_1.default.getItem(this.instanceId) || [];
instances = this.getItem(this.instanceId) || [];
return [2 /*return*/, instances];

@@ -126,6 +141,7 @@ });

Recorder.prototype.clearInstance = function (instanceId) {
var instanceExecutions = storage_1.default.getItem(instanceId) || [];
var _this = this;
var instanceExecutions = this.getItem(instanceId) || [];
instanceExecutions.forEach(function (executionId) {
storage_1.default.removeItem(executionId);
var instanceData = storage_1.default.getItem(executionId) || [];
var instanceData = _this.getItem(executionId) || [];
instanceData.forEach(function (actionId) {

@@ -138,3 +154,3 @@ storage_1.default.removeItem(actionId);

Recorder.prototype.pushExecution = function (executionId) {
var instanceExecutions = storage_1.default.getItem(this.instanceId) || [];
var instanceExecutions = this.getItem(this.instanceId) || [];
if (instanceExecutions.length >= this.maxRecorder) {

@@ -145,6 +161,6 @@ var removeItem = instanceExecutions.shift();

instanceExecutions.push(executionId);
storage_1.default.setItem(this.instanceId, instanceExecutions);
this.setItem(this.instanceId, instanceExecutions);
};
Recorder.prototype.popExecution = function (executionId) {
var instanceData = storage_1.default.getItem(executionId) || [];
var instanceData = this.getItem(executionId) || [];
instanceData.forEach(function (actionId) {

@@ -156,5 +172,5 @@ storage_1.default.removeItem(actionId);

Recorder.prototype.pushActionToExecution = function (executionId, actionId) {
var actions = storage_1.default.getItem(executionId) || [];
var actions = this.getItem(executionId) || [];
actions.push(actionId);
storage_1.default.setItem(executionId, actions);
this.setItem(executionId, actions);
};

@@ -161,0 +177,0 @@ return Recorder;

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

Scheduler.prototype.saveActionResult = function (data) {
this.recorder.addActionRecord({
var _a;
(_a = this.recorder) === null || _a === void 0 ? void 0 : _a.addActionRecord({
executionId: data.executionId,

@@ -240,0 +241,0 @@ actionId: data.actionId,

@@ -19,2 +19,5 @@ "use strict";

},
clear: function () {
storage_1.data = {};
},
};

@@ -42,2 +45,5 @@ global_1.globalScope.sessionStorage = storage_1;

},
clear: function () {
global_1.globalScope.sessionStorage.clear();
},
};

@@ -13,3 +13,3 @@ import type { ResumeParams, GraphConfigData, EngineConstructorOptions, NextActionParam } from './types.d';

flowModel: FlowModel;
recorder: Recorder;
recorder?: Recorder;
context: Record<string, any>;

@@ -16,0 +16,0 @@ constructor(options?: EngineConstructorOptions);

@@ -57,5 +57,7 @@ var __assign = (this && this.__assign) || function () {

this.instanceId = createEngineId();
this.recorder = new Recorder({
instanceId: this.instanceId,
});
if (!(options === null || options === void 0 ? void 0 : options.debug)) {
this.recorder = new Recorder({
instanceId: this.instanceId,
});
}
this.register({

@@ -148,9 +150,10 @@ type: StartNode.nodeTypeName,

Engine.prototype.getExecutionList = function () {
var _a;
return __awaiter(this, void 0, void 0, function () {
var executionIds;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.recorder.getExecutionList()];
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, ((_a = this.recorder) === null || _a === void 0 ? void 0 : _a.getExecutionList())];
case 1:
executionIds = _a.sent();
executionIds = _b.sent();
return [2 /*return*/, executionIds];

@@ -162,9 +165,10 @@ }

Engine.prototype.getExecutionRecord = function (executionId) {
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var tasks, records, i;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.recorder.getExecutionActions(executionId)];
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, ((_a = this.recorder) === null || _a === void 0 ? void 0 : _a.getExecutionActions(executionId))];
case 1:
tasks = _a.sent();
tasks = _c.sent();
if (!tasks) {

@@ -175,3 +179,3 @@ return [2 /*return*/, null];

for (i = 0; i < tasks.length; i++) {
records.push(this.recorder.getActionRecord(tasks[i]));
records.push((_b = this.recorder) === null || _b === void 0 ? void 0 : _b.getActionRecord(tasks[i]));
}

@@ -184,3 +188,4 @@ return [2 /*return*/, Promise.all(records)];

Engine.prototype.destroy = function () {
this.recorder.clear();
var _a;
(_a = this.recorder) === null || _a === void 0 ? void 0 : _a.clear();
};

@@ -187,0 +192,0 @@ Engine.prototype.getGlobalData = function () {

@@ -9,2 +9,4 @@ import type { RecorderData, RecorderInterface } from '../types.d';

setMaxRecorderNumber(maxRecorder: number): void;
setItem(key: string | number, value: unknown): void;
getItem(key: string | number): any;
addActionRecord(action: RecorderData): Promise<void>;

@@ -11,0 +13,0 @@ getActionRecord(actionId: string): Promise<RecorderData>;

@@ -46,3 +46,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

this.instanceId = instanceId;
var instances = storage.getItem(LOGICFLOW_ENGINE_INSTANCES) || [];
var instances = this.getItem(LOGICFLOW_ENGINE_INSTANCES) || [];
if (instances.indexOf(instanceId) === -1) {

@@ -55,3 +55,3 @@ instances.push(instanceId);

}
storage.setItem(LOGICFLOW_ENGINE_INSTANCES, instances);
this.setItem(LOGICFLOW_ENGINE_INSTANCES, instances);
}

@@ -61,2 +61,17 @@ Recorder.prototype.setMaxRecorderNumber = function (maxRecorder) {

};
// 将存储 storage 的方法收敛到此处,并在此处做异常处理 - setItem
Recorder.prototype.setItem = function (key, value) {
try {
storage.setItem(key, value);
}
catch (error) {
console.log('Ops, something wrong with storage.setItem');
storage.clear();
storage.setItem(key, value);
}
};
// getItem 方法
Recorder.prototype.getItem = function (key) {
return storage.getItem(key);
};
/*

@@ -87,3 +102,3 @@ * @param {Object} action

this.pushActionToExecution(executionId, actionId);
storage.setItem(actionId, action);
this.setItem(actionId, action);
return [2 /*return*/];

@@ -97,3 +112,3 @@ }

return __generator(this, function (_a) {
return [2 /*return*/, storage.getItem(actionId)];
return [2 /*return*/, this.getItem(actionId)];
});

@@ -105,3 +120,3 @@ });

return __generator(this, function (_a) {
return [2 /*return*/, storage.getItem(executionId)];
return [2 /*return*/, this.getItem(executionId)];
});

@@ -114,3 +129,3 @@ });

return __generator(this, function (_a) {
instances = storage.getItem(this.instanceId) || [];
instances = this.getItem(this.instanceId) || [];
return [2 /*return*/, instances];

@@ -124,6 +139,7 @@ });

Recorder.prototype.clearInstance = function (instanceId) {
var instanceExecutions = storage.getItem(instanceId) || [];
var _this = this;
var instanceExecutions = this.getItem(instanceId) || [];
instanceExecutions.forEach(function (executionId) {
storage.removeItem(executionId);
var instanceData = storage.getItem(executionId) || [];
var instanceData = _this.getItem(executionId) || [];
instanceData.forEach(function (actionId) {

@@ -136,3 +152,3 @@ storage.removeItem(actionId);

Recorder.prototype.pushExecution = function (executionId) {
var instanceExecutions = storage.getItem(this.instanceId) || [];
var instanceExecutions = this.getItem(this.instanceId) || [];
if (instanceExecutions.length >= this.maxRecorder) {

@@ -143,6 +159,6 @@ var removeItem = instanceExecutions.shift();

instanceExecutions.push(executionId);
storage.setItem(this.instanceId, instanceExecutions);
this.setItem(this.instanceId, instanceExecutions);
};
Recorder.prototype.popExecution = function (executionId) {
var instanceData = storage.getItem(executionId) || [];
var instanceData = this.getItem(executionId) || [];
instanceData.forEach(function (actionId) {

@@ -154,5 +170,5 @@ storage.removeItem(actionId);

Recorder.prototype.pushActionToExecution = function (executionId, actionId) {
var actions = storage.getItem(executionId) || [];
var actions = this.getItem(executionId) || [];
actions.push(actionId);
storage.setItem(executionId, actions);
this.setItem(executionId, actions);
};

@@ -159,0 +175,0 @@ return Recorder;

@@ -235,3 +235,4 @@ var __extends = (this && this.__extends) || (function () {

Scheduler.prototype.saveActionResult = function (data) {
this.recorder.addActionRecord({
var _a;
(_a = this.recorder) === null || _a === void 0 ? void 0 : _a.addActionRecord({
executionId: data.executionId,

@@ -238,0 +239,0 @@ actionId: data.actionId,

@@ -5,3 +5,4 @@ declare const _default: {

removeItem(key: any): void;
clear(): void;
};
export default _default;

@@ -17,2 +17,5 @@ /**

},
clear: function () {
storage_1.data = {};
},
};

@@ -40,2 +43,5 @@ globalScope.sessionStorage = storage_1;

},
clear: function () {
globalScope.sessionStorage.clear();
},
};
{
"name": "@logicflow/engine",
"version": "0.0.7",
"version": "0.0.8",
"description": "a process engine for javascript",

@@ -5,0 +5,0 @@ "main": "cjs/index.js",

Sorry, the diff of this file is too big to display

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