@logicflow/engine 0.0.9 → 0.0.10-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/README.md +5 -2
  2. package/dist/index.js +2 -0
  3. package/dist/index.js.map +1 -0
  4. package/es/EventEmitter.d.ts +34 -4
  5. package/es/EventEmitter.js +70 -48
  6. package/es/EventEmitter.js.map +1 -0
  7. package/es/FlowModel.d.ts +75 -73
  8. package/es/FlowModel.js +130 -173
  9. package/es/FlowModel.js.map +1 -0
  10. package/es/Scheduler.d.ts +50 -34
  11. package/es/Scheduler.js +134 -209
  12. package/es/Scheduler.js.map +1 -0
  13. package/es/constant/{constant.js → index.js} +8 -7
  14. package/es/constant/index.js.map +1 -0
  15. package/es/constant/logCode.js +29 -0
  16. package/es/constant/logCode.js.map +1 -0
  17. package/es/expression/brewserVm.d.ts +2 -0
  18. package/es/expression/brewserVm.js +30 -0
  19. package/es/expression/brewserVm.js.map +1 -0
  20. package/es/expression/index.d.ts +1 -1
  21. package/es/expression/index.js +16 -59
  22. package/es/expression/index.js.map +1 -0
  23. package/es/expression/nodeVm.d.ts +4 -2
  24. package/es/expression/nodeVm.js +10 -50
  25. package/es/expression/nodeVm.js.map +1 -0
  26. package/es/index.d.ts +135 -38
  27. package/es/index.js +92 -144
  28. package/es/index.js.map +1 -0
  29. package/es/nodes/base.d.ts +108 -0
  30. package/es/nodes/base.js +149 -0
  31. package/es/nodes/base.js.map +1 -0
  32. package/es/nodes/index.d.ts +3 -0
  33. package/es/nodes/index.js +4 -0
  34. package/es/nodes/index.js.map +1 -0
  35. package/es/nodes/{StartNode.d.ts → start.d.ts} +3 -2
  36. package/es/nodes/start.js +11 -0
  37. package/es/nodes/start.js.map +1 -0
  38. package/es/nodes/{TaskNode.d.ts → task.d.ts} +3 -2
  39. package/es/nodes/task.js +11 -0
  40. package/es/nodes/task.js.map +1 -0
  41. package/es/platform/browser/browserVm.d.ts +4 -0
  42. package/es/platform/browser/browserVm.js +44 -0
  43. package/es/platform/browser/browserVm.js.map +1 -0
  44. package/es/platform/browser/index.d.ts +4 -0
  45. package/es/platform/browser/index.js +23 -0
  46. package/es/platform/browser/index.js.map +1 -0
  47. package/es/platform/index.d.ts +1 -0
  48. package/es/platform/index.js +2 -0
  49. package/es/platform/index.js.map +1 -0
  50. package/es/platform/node/index.d.ts +4 -0
  51. package/es/platform/node/index.js +23 -0
  52. package/es/platform/node/index.js.map +1 -0
  53. package/es/platform/node/nodeVm.d.ts +1 -0
  54. package/es/platform/node/nodeVm.js +9 -0
  55. package/es/platform/node/nodeVm.js.map +1 -0
  56. package/es/recorder/index.d.ts +36 -10
  57. package/es/recorder/index.js +82 -135
  58. package/es/recorder/index.js.map +1 -0
  59. package/es/utils/global.d.ts +5 -0
  60. package/es/utils/global.js +27 -0
  61. package/es/utils/global.js.map +1 -0
  62. package/es/utils/id.js +14 -0
  63. package/es/utils/id.js.map +1 -0
  64. package/es/utils/index.d.ts +4 -0
  65. package/es/utils/index.js +5 -0
  66. package/es/utils/index.js.map +1 -0
  67. package/es/{util → utils}/storage.js +17 -16
  68. package/es/utils/storage.js.map +1 -0
  69. package/lib/EventEmitter.d.ts +37 -0
  70. package/lib/EventEmitter.js +94 -0
  71. package/lib/EventEmitter.js.map +1 -0
  72. package/lib/FlowModel.d.ts +146 -0
  73. package/lib/FlowModel.js +236 -0
  74. package/lib/FlowModel.js.map +1 -0
  75. package/lib/Scheduler.d.ts +78 -0
  76. package/lib/Scheduler.js +179 -0
  77. package/lib/Scheduler.js.map +1 -0
  78. package/lib/constant/index.d.ts +16 -0
  79. package/{cjs/constant/constant.js → lib/constant/index.js} +4 -3
  80. package/lib/constant/index.js.map +1 -0
  81. package/lib/constant/logCode.d.ts +12 -0
  82. package/{cjs/constant/LogCode.js → lib/constant/logCode.js} +16 -13
  83. package/lib/constant/logCode.js.map +1 -0
  84. package/lib/expression/brewserVm.d.ts +2 -0
  85. package/lib/expression/brewserVm.js +33 -0
  86. package/lib/expression/brewserVm.js.map +1 -0
  87. package/lib/expression/index.d.ts +2 -0
  88. package/lib/expression/index.js +20 -0
  89. package/lib/expression/index.js.map +1 -0
  90. package/lib/expression/nodeVm.d.ts +4 -0
  91. package/lib/expression/nodeVm.js +13 -0
  92. package/lib/expression/nodeVm.js.map +1 -0
  93. package/lib/index.d.ts +157 -0
  94. package/lib/index.js +159 -0
  95. package/lib/index.js.map +1 -0
  96. package/lib/nodes/base.d.ts +108 -0
  97. package/lib/nodes/base.js +152 -0
  98. package/lib/nodes/base.js.map +1 -0
  99. package/lib/nodes/index.d.ts +3 -0
  100. package/lib/nodes/index.js +7 -0
  101. package/lib/nodes/index.js.map +1 -0
  102. package/lib/nodes/start.d.ts +6 -0
  103. package/lib/nodes/start.js +15 -0
  104. package/lib/nodes/start.js.map +1 -0
  105. package/lib/nodes/task.d.ts +6 -0
  106. package/lib/nodes/task.js +15 -0
  107. package/lib/nodes/task.js.map +1 -0
  108. package/lib/platform/browser/browserVm.d.ts +4 -0
  109. package/lib/platform/browser/browserVm.js +49 -0
  110. package/lib/platform/browser/browserVm.js.map +1 -0
  111. package/lib/platform/browser/index.d.ts +4 -0
  112. package/lib/platform/browser/index.js +28 -0
  113. package/lib/platform/browser/index.js.map +1 -0
  114. package/lib/platform/index.d.ts +1 -0
  115. package/lib/platform/index.js +5 -0
  116. package/lib/platform/index.js.map +1 -0
  117. package/lib/platform/node/index.d.ts +4 -0
  118. package/lib/platform/node/index.js +28 -0
  119. package/lib/platform/node/index.js.map +1 -0
  120. package/lib/platform/node/nodeVm.d.ts +1 -0
  121. package/lib/platform/node/nodeVm.js +13 -0
  122. package/lib/platform/node/nodeVm.js.map +1 -0
  123. package/lib/recorder/index.d.ts +46 -0
  124. package/lib/recorder/index.js +117 -0
  125. package/lib/recorder/index.js.map +1 -0
  126. package/lib/utils/global.d.ts +5 -0
  127. package/lib/utils/global.js +31 -0
  128. package/lib/utils/global.js.map +1 -0
  129. package/lib/utils/id.d.ts +3 -0
  130. package/lib/utils/id.js +20 -0
  131. package/lib/utils/id.js.map +1 -0
  132. package/lib/utils/index.d.ts +4 -0
  133. package/lib/utils/index.js +9 -0
  134. package/lib/utils/index.js.map +1 -0
  135. package/lib/utils/storage.d.ts +7 -0
  136. package/{cjs/util → lib/utils}/storage.js +18 -17
  137. package/lib/utils/storage.js.map +1 -0
  138. package/package.json +30 -71
  139. package/src/EventEmitter.ts +103 -0
  140. package/src/FlowModel.ts +325 -0
  141. package/src/Scheduler.ts +244 -0
  142. package/src/constant/index.ts +23 -0
  143. package/src/constant/logCode.ts +34 -0
  144. package/src/expression/brewserVm.ts +36 -0
  145. package/src/expression/index.ts +17 -0
  146. package/src/expression/nodeVm.ts +14 -0
  147. package/src/index.ts +300 -0
  148. package/src/nodes/base.ts +234 -0
  149. package/src/nodes/index.ts +3 -0
  150. package/src/nodes/start.ts +8 -0
  151. package/src/nodes/task.ts +8 -0
  152. package/src/platform/browser/browserVm.ts +52 -0
  153. package/src/platform/browser/index.ts +28 -0
  154. package/src/platform/index.ts +1 -0
  155. package/src/platform/node/index.ts +28 -0
  156. package/src/platform/node/nodeVm.ts +12 -0
  157. package/src/recorder/index.ts +137 -0
  158. package/src/typings.d.ts +0 -0
  159. package/src/utils/global.ts +41 -0
  160. package/src/utils/id.ts +16 -0
  161. package/src/utils/index.ts +5 -0
  162. package/src/utils/storage.ts +55 -0
  163. package/cjs/EventEmitter.js +0 -70
  164. package/cjs/FlowModel.js +0 -277
  165. package/cjs/Scheduler.js +0 -252
  166. package/cjs/expression/browserVm.js +0 -81
  167. package/cjs/expression/index.js +0 -63
  168. package/cjs/expression/nodeVm.js +0 -53
  169. package/cjs/index.js +0 -210
  170. package/cjs/nodes/BaseNode.js +0 -252
  171. package/cjs/nodes/StartNode.js +0 -27
  172. package/cjs/nodes/TaskNode.js +0 -27
  173. package/cjs/recorder/index.js +0 -168
  174. package/cjs/util/ID.js +0 -16
  175. package/cjs/util/global.js +0 -32
  176. package/es/constant/LogCode.js +0 -28
  177. package/es/expression/browserVm.d.ts +0 -4
  178. package/es/expression/browserVm.js +0 -76
  179. package/es/nodes/BaseNode.d.ts +0 -110
  180. package/es/nodes/BaseNode.js +0 -250
  181. package/es/nodes/StartNode.js +0 -25
  182. package/es/nodes/TaskNode.js +0 -25
  183. package/es/util/ID.js +0 -13
  184. package/es/util/global.d.ts +0 -5
  185. package/es/util/global.js +0 -26
  186. package/lib/main.js +0 -1
  187. /package/es/constant/{constant.d.ts → index.d.ts} +0 -0
  188. /package/es/constant/{LogCode.d.ts → logCode.d.ts} +0 -0
  189. /package/es/{util/ID.d.ts → utils/id.d.ts} +0 -0
  190. /package/es/{util → utils}/storage.d.ts +0 -0
@@ -0,0 +1,108 @@
1
+ import { Engine } from '..';
2
+ import { ActionStatus } from '../constant';
3
+ export interface IBaseNodeProps {
4
+ nodeConfig: BaseNode.NodeConfig;
5
+ context: Record<string, any>;
6
+ globalData: Record<string, unknown>;
7
+ }
8
+ export declare class BaseNode implements BaseNode.Base {
9
+ readonly baseType: string;
10
+ static nodeTypeName: string;
11
+ /**
12
+ * 节点的入边
13
+ */
14
+ incoming: BaseNode.IncomingConfig[];
15
+ /**
16
+ * 节点的出边
17
+ */
18
+ outgoing: BaseNode.OutgoingConfig[];
19
+ /**
20
+ * 节点的属性
21
+ */
22
+ properties?: Record<string, unknown>;
23
+ nodeId: Engine.Key;
24
+ type: string;
25
+ /**
26
+ * 节点的上下文,是调用流程时传入的上下文
27
+ */
28
+ context: Record<string, any>;
29
+ /**
30
+ * 节点的全局数据,是调用流程时传入的全局数据
31
+ * 在计算表达式时,即基于全局数据进行计算
32
+ */
33
+ globalData: Record<string, unknown>;
34
+ constructor({ nodeConfig, context, globalData }: IBaseNodeProps);
35
+ /**
36
+ * 节点的执行逻辑
37
+ * @overridable 可以自定义节点重写此方法
38
+ * @param param.executionId 流程执行记录 ID
39
+ * @param param.actionId 此节点执行记录 ID
40
+ * @param param.nodeId 节点 ID
41
+ * @return 返回下一步的执行参数
42
+ * 当不返回时,表示此节点执行成功,流程会继续执行下一步。
43
+ * 当返回时,返回格式为
44
+ */
45
+ action(param?: Engine.ActionParam): Promise<BaseNode.ActionResult | undefined>;
46
+ /**
47
+ * 节点重新恢复执行的逻辑
48
+ * @overridable 可以自定义节点重写此方法
49
+ * @param params.executionId 流程执行记录 ID
50
+ * @param params.actionId 此节点执行记录 ID
51
+ * @param params.nodeId 节点 ID
52
+ */
53
+ onResume(params: Engine.ResumeParam): Promise<void>;
54
+ /**
55
+ * 判断该节点是否满足条件
56
+ */
57
+ private isPass;
58
+ /**
59
+ * 获取当前节点执行的下一个节点
60
+ */
61
+ private getOutgoing;
62
+ /**
63
+ * 节点的每一次执行都会生成一个唯一的 actionId
64
+ */
65
+ execute(params: Engine.ExecParam): Promise<Engine.NextActionParam>;
66
+ resume(params: Engine.ExecResumeParam): Promise<undefined>;
67
+ }
68
+ export declare namespace BaseNode {
69
+ interface Base {
70
+ incoming: IncomingConfig[];
71
+ outgoing: OutgoingConfig[];
72
+ properties?: Record<string, unknown>;
73
+ nodeId: Engine.Key;
74
+ type: string;
75
+ readonly baseType: string;
76
+ execute(actionParam: Engine.ActionParam): Promise<Engine.NextActionParam>;
77
+ }
78
+ type IncomingConfig = {
79
+ id: Engine.Key;
80
+ source: string;
81
+ properties?: Record<string, unknown>;
82
+ };
83
+ type OutgoingConfig = {
84
+ id: Engine.Key;
85
+ target: string;
86
+ properties?: Record<string, unknown>;
87
+ result?: string | boolean;
88
+ };
89
+ type NodeConfig = {
90
+ id: Engine.Key;
91
+ type: string;
92
+ properties?: Record<string, unknown>;
93
+ incoming: IncomingConfig[];
94
+ outgoing: OutgoingConfig[];
95
+ };
96
+ type NodeConstructor = {
97
+ new (config: {
98
+ nodeConfig: NodeConfig;
99
+ context: Record<string, any>;
100
+ globalData: Record<string, unknown>;
101
+ }): BaseNode;
102
+ };
103
+ type ActionResult = {
104
+ status: ActionStatus;
105
+ detail?: Record<string, unknown>;
106
+ };
107
+ }
108
+ export default BaseNode;
@@ -0,0 +1,149 @@
1
+ import { __awaiter } from "tslib";
2
+ import { ActionStatus } from '../constant';
3
+ import { getExpressionResult } from '../platform';
4
+ class BaseNode {
5
+ constructor({ nodeConfig, context, globalData }) {
6
+ const { outgoing, incoming, id, type, properties } = nodeConfig;
7
+ this.baseType = 'base';
8
+ this.outgoing = outgoing;
9
+ this.incoming = incoming;
10
+ this.nodeId = id;
11
+ this.type = type;
12
+ this.properties = properties;
13
+ this.context = context;
14
+ this.globalData = globalData;
15
+ }
16
+ /**
17
+ * 节点的执行逻辑
18
+ * @overridable 可以自定义节点重写此方法
19
+ * @param param.executionId 流程执行记录 ID
20
+ * @param param.actionId 此节点执行记录 ID
21
+ * @param param.nodeId 节点 ID
22
+ * @return 返回下一步的执行参数
23
+ * 当不返回时,表示此节点执行成功,流程会继续执行下一步。
24
+ * 当返回时,返回格式为
25
+ */
26
+ action(param) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ console.log('action param --->>>', param);
29
+ return undefined;
30
+ });
31
+ }
32
+ /**
33
+ * 节点重新恢复执行的逻辑
34
+ * @overridable 可以自定义节点重写此方法
35
+ * @param params.executionId 流程执行记录 ID
36
+ * @param params.actionId 此节点执行记录 ID
37
+ * @param params.nodeId 节点 ID
38
+ */
39
+ onResume(params) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ console.log('onResume params --->>>', params);
42
+ return undefined;
43
+ });
44
+ }
45
+ /**
46
+ * 判断该节点是否满足条件
47
+ */
48
+ isPass(properties) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ if (!properties)
51
+ return true;
52
+ const { conditionExpression } = properties;
53
+ if (!conditionExpression)
54
+ return true;
55
+ try {
56
+ // bug:uuid 创建的 NodeId 为 xxxx-xxxx-xxxx-zzzz 格式,eval 执行时会将 - 识别为数学减号,导致执行报错
57
+ // 解决方案: 赋值变量直接命名为 isPassResult, 因为每次执行 getExpressionResult 时,都会重新射程一个 context
58
+ const result = yield getExpressionResult(`isPassResult = (${conditionExpression})`, Object.assign({}, this.globalData));
59
+ return result.isPassResult;
60
+ }
61
+ catch (error) {
62
+ return false;
63
+ }
64
+ });
65
+ }
66
+ /**
67
+ * 获取当前节点执行的下一个节点
68
+ */
69
+ getOutgoing() {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ const outgoing = [];
72
+ const expressions = [];
73
+ for (const item of this.outgoing) {
74
+ const { properties } = item;
75
+ expressions.push(this.isPass(properties));
76
+ }
77
+ const result = yield Promise.all(expressions);
78
+ result.forEach((item, index) => {
79
+ const out = this.outgoing[index];
80
+ out.result = item;
81
+ outgoing.push(out);
82
+ });
83
+ return outgoing;
84
+ });
85
+ }
86
+ /**
87
+ * 节点的每一次执行都会生成一个唯一的 actionId
88
+ */
89
+ execute(params) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ const { executionId, actionId } = params;
92
+ const res = yield this.action({
93
+ nodeId: this.nodeId,
94
+ executionId,
95
+ actionId,
96
+ });
97
+ const status = res ? res.status : 'success';
98
+ if (status === ActionStatus.SUCCESS) {
99
+ const outgoing = yield this.getOutgoing();
100
+ const detail = res ? res.detail : {};
101
+ params.next({
102
+ status: ActionStatus.SUCCESS,
103
+ detail,
104
+ nodeId: this.nodeId,
105
+ nodeType: this.type,
106
+ properties: this.properties,
107
+ executionId,
108
+ actionId,
109
+ outgoing,
110
+ });
111
+ }
112
+ return {
113
+ status,
114
+ detail: res === null || res === void 0 ? void 0 : res.detail,
115
+ executionId,
116
+ actionId,
117
+ nodeId: this.nodeId,
118
+ nodeType: this.type,
119
+ properties: this.properties,
120
+ outgoing: [],
121
+ };
122
+ });
123
+ }
124
+ resume(params) {
125
+ return __awaiter(this, void 0, void 0, function* () {
126
+ const outgoing = yield this.getOutgoing();
127
+ yield this.onResume({
128
+ executionId: params.executionId,
129
+ actionId: params.actionId,
130
+ nodeId: params.nodeId,
131
+ data: params.data,
132
+ });
133
+ params.next({
134
+ executionId: params.executionId,
135
+ actionId: params.actionId,
136
+ nodeId: this.nodeId,
137
+ nodeType: this.type,
138
+ properties: this.properties,
139
+ outgoing,
140
+ status: ActionStatus.SUCCESS,
141
+ });
142
+ return undefined;
143
+ });
144
+ }
145
+ }
146
+ BaseNode.nodeTypeName = 'BaseNode';
147
+ export { BaseNode };
148
+ export default BaseNode;
149
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/nodes/base.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAQjD,MAAa,QAAQ;IA4BnB,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAkB;QAC7D,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,UAAU,CAAA;QAC/D,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAA;QACtB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAE5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAED;;;;;;;;;OASG;IACU,MAAM,CACjB,KAA0B;;YAE1B,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAA;YACzC,OAAO,SAAS,CAAA;QAClB,CAAC;KAAA;IAED;;;;;;OAMG;IACU,QAAQ,CAAC,MAA0B;;YAC9C,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAA;YAC7C,OAAO,SAAS,CAAA;QA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AAE,MAAM,CAAC,IAAI;aAClB,CAAC,CAAA;YAEF,MAAM,CAAC,IAAI,CAAC;gBACV,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,QAAQ,EAAE,IAAI,CAAC,IAAI;gBACnB,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,QAAQ;gBACR,MAAM,EAAE,YAAY,CAAC,OAAO;aAC7B,CAAC,CAAA;YACF,OAAO,SAAS,CAAA;QAClB,CAAC;KAAA;;AA5KM,qBAAY,GAAG,UAAU,CAAA;SAFrB,QAAQ;AA+NrB,eAAe,QAAQ,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './base';
2
+ export * from './start';
3
+ export * from './task';
@@ -0,0 +1,4 @@
1
+ export * from './base';
2
+ export * from './start';
3
+ export * from './task';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/nodes/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA"}
@@ -1,5 +1,6 @@
1
- import BaseNode from './BaseNode';
1
+ import BaseNode from './base';
2
2
  export default class StartNode extends BaseNode {
3
- static nodeTypeName: string;
4
3
  readonly baseType = "start";
4
+ static nodeTypeName: string;
5
5
  }
6
+ export { StartNode };
@@ -0,0 +1,11 @@
1
+ import BaseNode from './base';
2
+ class StartNode extends BaseNode {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.baseType = 'start';
6
+ }
7
+ }
8
+ StartNode.nodeTypeName = 'StartNode';
9
+ export default StartNode;
10
+ export { StartNode };
11
+ //# sourceMappingURL=start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/nodes/start.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,QAAQ,CAAA;AAE7B,MAAqB,SAAU,SAAQ,QAAQ;IAA/C;;QACW,aAAQ,GAAG,OAAO,CAAA;IAE7B,CAAC;;AADQ,sBAAY,GAAG,WAAW,AAAd,CAAc;eAFd,SAAS;AAK9B,OAAO,EAAE,SAAS,EAAE,CAAA"}
@@ -1,5 +1,6 @@
1
- import BaseNode from './BaseNode';
1
+ import BaseNode from './base';
2
2
  export default class TaskNode extends BaseNode {
3
- static nodeTypeName: string;
4
3
  readonly baseType = "task";
4
+ static nodeTypeName: string;
5
5
  }
6
+ export { TaskNode };
@@ -0,0 +1,11 @@
1
+ import BaseNode from './base';
2
+ class TaskNode extends BaseNode {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.baseType = 'task';
6
+ }
7
+ }
8
+ TaskNode.nodeTypeName = 'TaskNode';
9
+ export default TaskNode;
10
+ export { TaskNode };
11
+ //# sourceMappingURL=task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/nodes/task.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,QAAQ,CAAA;AAE7B,MAAqB,QAAS,SAAQ,QAAQ;IAA9C;;QACW,aAAQ,GAAG,MAAM,CAAA;IAE5B,CAAC;;AADQ,qBAAY,GAAG,UAAU,AAAb,CAAa;eAFb,QAAQ;AAK7B,OAAO,EAAE,QAAQ,EAAE,CAAA"}
@@ -0,0 +1,4 @@
1
+ declare const createContext: (globalData: Record<string, unknown>) => Window | null;
2
+ declare const runInContext: (code: string, context: any) => void;
3
+ declare const runInBrowserContext: (code: string, globalData?: {}) => Promise<any>;
4
+ export { createContext, runInContext, runInBrowserContext };
@@ -0,0 +1,44 @@
1
+ import { __awaiter } from "tslib";
2
+ import { ErrorCode, getErrorMsg, getWarningMsg, WarningCode, } from '../../constant/logCode';
3
+ const createContext = (globalData) => {
4
+ const iframe = document.createElement('iframe');
5
+ iframe.style.display = 'none';
6
+ if (!document || !document.body) {
7
+ console.error(getErrorMsg(ErrorCode.NO_DOCUMENT_BODY));
8
+ }
9
+ document.body.appendChild(iframe);
10
+ const iframeWindow = iframe.contentWindow;
11
+ if (iframeWindow) {
12
+ // TODO: 确认是否需要该代码,parent 置为空是为了解决什么问题
13
+ // @ts-ignore
14
+ ;
15
+ iframeWindow.parent = null;
16
+ Object.keys(globalData).forEach((key) => {
17
+ iframeWindow[key] = globalData[key];
18
+ });
19
+ }
20
+ return iframeWindow;
21
+ };
22
+ const runInContext = (code, context) => {
23
+ try {
24
+ const iframeEval = context.eval;
25
+ iframeEval.call(context, code);
26
+ if (context.iframeElement) {
27
+ document.body.removeChild(context.iframeElement);
28
+ }
29
+ }
30
+ catch (e) {
31
+ console.warn(getWarningMsg(WarningCode.EXPRESSION_EXEC_ERROR), {
32
+ code,
33
+ context,
34
+ e,
35
+ });
36
+ }
37
+ };
38
+ const runInBrowserContext = (code, globalData = {}) => __awaiter(void 0, void 0, void 0, function* () {
39
+ const context = createContext(globalData);
40
+ runInContext(code, context);
41
+ return context;
42
+ });
43
+ export { createContext, runInContext, runInBrowserContext };
44
+ //# sourceMappingURL=browserVm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browserVm.js","sourceRoot":"","sources":["../../../src/platform/browser/browserVm.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,EACT,WAAW,EACX,aAAa,EACb,WAAW,GACZ,MAAM,wBAAwB,CAAA;AAE/B,MAAM,aAAa,GAAG,CAAC,UAAmC,EAAE,EAAE;IAC5D,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC/C,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAA;IAC7B,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;QAC/B,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAA;KACvD;IACD,QAAQ,CAAC,IAAI,CAAC,WAA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pressionResult: (code: string, context: any) => Promise<any>;
4
+ export { isInBrowser, globalScope, getExpressionResult };
@@ -0,0 +1,23 @@
1
+ import { __awaiter } from "tslib";
2
+ import { runInBrowserContext } from './browserVm';
3
+ const isInBrowser = typeof window === 'object' && window.window === window;
4
+ const globalScope = (() => {
5
+ if (isInBrowser) {
6
+ return window;
7
+ }
8
+ if (typeof self === 'object' && self.self === self) {
9
+ return self;
10
+ }
11
+ if (typeof globalThis === 'object') {
12
+ return globalThis;
13
+ }
14
+ return {
15
+ eval: () => undefined,
16
+ };
17
+ })();
18
+ const getExpressionResult = (code, context) => __awaiter(void 0, void 0, void 0, function* () {
19
+ const r = yield runInBrowserContext(code, context);
20
+ return r;
21
+ });
22
+ export { isInBrowser, globalScope, getExpressionResult };
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/platform/browser/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEjD,MAAM,WAAW,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAA;AAE1E,MAAM,WAAW,GAAQ,CAAC,GAAG,EAAE;IAC7B,IAAI,WAAW,EAAE;QACf,OAAO,MAAM,CAAA;KACd;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;QAClD,OAAO,IAAI,CAAA;KACZ;IAED,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAA;KAClB;IAED,OAAO;QACL,IAAI,EAAE,GAAG,EAAE,CAAC,SAAS;KACK,CAAA;AAC9B,CAAC,CAAC,EAAE,CAAA;AAEJ,MAAM,mBAAmB,GAAG,CAAO,IAAY,EAAE,OAAY,EAAE,EAAE;IAC/D,MAAM,CAAC,GAAG,MAAM,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAClD,OAAO,CAAC,CAAA;AACV,CAAC,CAAA,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAA"}
@@ -0,0 +1 @@
1
+ export * from './node';
@@ -0,0 +1,2 @@
1
+ export * from './node';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/platform/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA"}
@@ -0,0 +1,4 @@
1
+ declare const isInNodeJS: boolean;
2
+ declare const globalScope: any;
3
+ declare const getExpressionResult: (code: string, context: any) => Promise<any>;
4
+ export { isInNodeJS, globalScope, getExpressionResult };
@@ -0,0 +1,23 @@
1
+ import { __awaiter } from "tslib";
2
+ import { runInNodeContext } from './nodeVm';
3
+ const isInNodeJS = typeof global === 'object' && global.global === global;
4
+ const globalScope = (() => {
5
+ if (typeof self === 'object' && self.self === self) {
6
+ return self;
7
+ }
8
+ if (isInNodeJS) {
9
+ return global;
10
+ }
11
+ if (typeof globalThis === 'object') {
12
+ return globalThis;
13
+ }
14
+ return {
15
+ eval: () => undefined,
16
+ };
17
+ })();
18
+ const getExpressionResult = (code, context) => __awaiter(void 0, void 0, void 0, function* () {
19
+ const r = yield runInNodeContext(code, context);
20
+ return r;
21
+ });
22
+ export { isInNodeJS, globalScope, getExpressionResult };
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/platform/node/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAA;AAEzE,MAAM,WAAW,GAAQ,CAAC,GAAG,EAAE;IAC7B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;QAClD,OAAO,IAAI,CAAA;KACZ;IAED,IAAI,UAAU,EAAE;QACd,OAAO,MAAM,CAAA;KACd;IAED,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAA;KAClB;IAED,OAAO;QACL,IAAI,EAAE,GAAG,EAAE,CAAC,SAAS;KACK,CAAA;AAC9B,CAAC,CAAC,EAAE,CAAA;AAEJ,MAAM,mBAAmB,GAAG,CAAO,IAAY,EAAE,OAAY,EAAE,EAAE;IAC/D,MAAM,CAAC,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAC/C,OAAO,CAAC,CAAA;AACV,CAAC,CAAA,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const runInNodeContext: (code: string, globalData?: Record<string, unknown>) => Promise<any>;
@@ -0,0 +1,9 @@
1
+ import { __awaiter } from "tslib";
2
+ import vm from 'node:vm';
3
+ // const vm = require('node:vm');
4
+ export const runInNodeContext = (code, globalData = {}) => __awaiter(void 0, void 0, void 0, function* () {
5
+ const context = vm.createContext(globalData);
6
+ vm.runInContext(code, context);
7
+ return context;
8
+ });
9
+ //# sourceMappingURL=nodeVm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeVm.js","sourceRoot":"","sources":["../../../src/platform/node/nodeVm.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,iCAAiC;AAEjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,IAAY,EACZ,aAAsC,EAAE,EAC1B,EAAE;IAChB,MAAM,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;IAC5C,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAE9B,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA,CAAA"}
@@ -1,20 +1,46 @@
1
- import type { RecorderData, RecorderInterface } from '../types.d';
2
- export default class Recorder implements RecorderInterface {
1
+ import { Engine } from '..';
2
+ export declare const MAX_RECORDER = 100;
3
+ export declare const MAX_INSTANCE = 100;
4
+ export declare const LOGICFLOW_ENGINE_INSTANCES = "LOGICFLOW_ENGINE_INSTANCES";
5
+ export declare class Recorder implements Recorder.Base {
6
+ instanceId: Engine.Key;
3
7
  maxRecorder: number;
4
- instanceId: number;
5
8
  constructor({ instanceId }: {
6
9
  instanceId: any;
7
10
  });
8
- setMaxRecorderNumber(maxRecorder: number): void;
11
+ setMaxRecorderNumber(max: number): void;
9
12
  setItem(key: string | number, value: unknown): void;
10
13
  getItem(key: string | number): any;
11
- addActionRecord(action: RecorderData): Promise<void>;
12
- getActionRecord(actionId: string): Promise<RecorderData>;
13
- getExecutionActions(executionId: any): Promise<any>;
14
+ getExecutionActions(executionId: Engine.Key): Promise<any>;
14
15
  getExecutionList(): Promise<any>;
15
- clear(): void;
16
- clearInstance(instanceId: any): void;
17
- private pushExecution;
16
+ private addExecution;
18
17
  private popExecution;
19
18
  private pushActionToExecution;
19
+ /**
20
+ * @param {Object} action
21
+ * {
22
+ * actionId: '',
23
+ * nodeId: '',
24
+ * executionId: '',
25
+ * nodeType: '',
26
+ * timestamp: '',
27
+ * properties: {},
28
+ * }
29
+ */
30
+ addActionRecord(action: Recorder.Info): Promise<void>;
31
+ getActionRecord(actionId: Engine.Key): Promise<Recorder.Info>;
32
+ clear(): void;
33
+ clearInstance(instanceId: Engine.Key): void;
34
+ }
35
+ export declare namespace Recorder {
36
+ interface Base {
37
+ addActionRecord: (action: Info) => Promise<void>;
38
+ getActionRecord: (actionId: Engine.Key) => Promise<Info>;
39
+ getExecutionActions: (executionId: Engine.Key) => Promise<string[]>;
40
+ clear: () => void;
41
+ }
42
+ type Info = {
43
+ timestamp: number;
44
+ } & Engine.NextActionParam;
20
45
  }
46
+ export default Recorder;