@ldsg/workflow 0.2.11 → 0.3.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 (41) hide show
  1. package/dist/__tests__/unit/resource.js +110 -111
  2. package/dist/resource.d.ts.map +1 -1
  3. package/dist/resource.js +42 -22
  4. package/dist/types/{workflow-edge-info.d.ts → edge.d.ts} +1 -1
  5. package/dist/types/edge.d.ts.map +1 -0
  6. package/dist/types/index.d.ts +4 -5
  7. package/dist/types/index.d.ts.map +1 -1
  8. package/dist/types/index.js +4 -5
  9. package/dist/types/node.d.ts +53 -0
  10. package/dist/types/node.d.ts.map +1 -0
  11. package/dist/types/variables.d.ts +18 -0
  12. package/dist/types/variables.d.ts.map +1 -0
  13. package/dist/types/workflow.d.ts +28 -0
  14. package/dist/types/workflow.d.ts.map +1 -0
  15. package/dist/utils/evaluate-variables.d.ts +11 -0
  16. package/dist/utils/evaluate-variables.d.ts.map +1 -0
  17. package/dist/utils/evaluate-variables.js +35 -0
  18. package/dist/utils/evaluate-variables.test.d.ts +2 -0
  19. package/dist/utils/evaluate-variables.test.d.ts.map +1 -0
  20. package/dist/utils/evaluate-variables.test.js +141 -0
  21. package/dist/utils/index.d.ts +0 -1
  22. package/dist/utils/index.d.ts.map +1 -1
  23. package/dist/utils/index.js +0 -1
  24. package/package.json +9 -5
  25. package/dist/types/node-variables.d.ts +0 -4
  26. package/dist/types/node-variables.d.ts.map +0 -1
  27. package/dist/types/workflow-data.d.ts +0 -7
  28. package/dist/types/workflow-data.d.ts.map +0 -1
  29. package/dist/types/workflow-edge-info.d.ts.map +0 -1
  30. package/dist/types/workflow-info.d.ts +0 -13
  31. package/dist/types/workflow-info.d.ts.map +0 -1
  32. package/dist/types/workflow-node-info.d.ts +0 -53
  33. package/dist/types/workflow-node-info.d.ts.map +0 -1
  34. package/dist/types/workflow-node-info.js +0 -25
  35. package/dist/utils/get-end-node-output-variables.d.ts +0 -10
  36. package/dist/utils/get-end-node-output-variables.d.ts.map +0 -1
  37. package/dist/utils/get-end-node-output-variables.js +0 -12
  38. /package/dist/types/{node-variables.js → edge.js} +0 -0
  39. /package/dist/types/{workflow-data.js → node.js} +0 -0
  40. /package/dist/types/{workflow-edge-info.js → variables.js} +0 -0
  41. /package/dist/types/{workflow-info.js → workflow.js} +0 -0
@@ -1,132 +1,131 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const constants_1 = require("../../constants");
4
3
  const resource_1 = require("../../resource");
5
- const types_1 = require("../../types");
6
- class AWorkflowResource extends resource_1.WorkflowResource {
7
- constructor() {
8
- super(...arguments);
9
- this.getWorkflowData = () => {
10
- const workflowData = {
11
- edges: [
12
- {
13
- sourceWorkflowNodeResourceId: "1",
14
- targetWorkflowNodeResourceId: "2",
15
- },
16
- {
17
- sourceWorkflowNodeResourceId: "2",
18
- targetWorkflowNodeResourceId: "3",
19
- },
20
- {
21
- sourceWorkflowNodeResourceId: "3",
22
- targetWorkflowNodeResourceId: "4",
23
- },
24
- {
25
- sourceWorkflowNodeResourceId: "4",
26
- targetWorkflowNodeResourceId: "5",
27
- },
28
- ],
29
- nodes: [
30
- {
31
- id: "1",
32
- workflowNodeTypeResourceId: constants_1.SPECIFIC_WORKFLOW_NODE_TYPE_TO_WORKFLOW_NODE_TYPE_RESOURCE_ID_MAP.start,
33
- Executer: class AWorkflowNodeExecuter extends types_1.WorkflowNodeExecuter {
34
- constructor() {
35
- super(...arguments);
36
- this.execute = async () => {
37
- const { setVariables } = this;
38
- setVariables({
39
- variables: "abc",
40
- });
41
- };
42
- }
43
- },
44
- },
45
- {
46
- id: "2",
47
- workflowNodeTypeResourceId: "",
48
- Executer: class AWorkflowNodeExecuter extends types_1.WorkflowNodeExecuter {
49
- constructor() {
50
- super(...arguments);
51
- this.execute = async () => {
52
- const { setVariables } = this;
53
- setVariables({
54
- variables: "def",
55
- });
56
- };
57
- }
58
- },
59
- },
60
- {
61
- id: "3",
62
- workflowNodeTypeResourceId: "",
63
- Executer: class AWorkflowNodeExecuter extends types_1.WorkflowNodeExecuter {
64
- constructor() {
65
- super(...arguments);
66
- this.execute = async () => {
67
- const { setVariables } = this;
68
- setVariables({
69
- variables: "ghi",
70
- });
71
- };
72
- }
73
- },
74
- },
75
- {
76
- id: "4",
77
- workflowNodeTypeResourceId: "",
78
- Executer: class AWorkflowNodeExecuter extends types_1.WorkflowNodeExecuter {
79
- constructor() {
80
- super(...arguments);
81
- this.execute = async () => {
82
- const { setVariables } = this;
83
- setVariables({
84
- variables: "jkl",
85
- });
86
- };
87
- }
4
+ const numberIdList = ["1", "2", "3", "4", "5"];
5
+ const nodeIdList = numberIdList.map((id) => `node-${id}`);
6
+ const nodes = nodeIdList.map((nodeId) => {
7
+ const workflowNodeExecute = async (params) => {
8
+ const { variables: workflowNodeInputVariables } = params;
9
+ const workflowNodeOutputVariables = workflowNodeInputVariables;
10
+ const res = {
11
+ variables: workflowNodeOutputVariables,
12
+ };
13
+ return res;
14
+ };
15
+ let input;
16
+ let output;
17
+ switch (nodeId) {
18
+ case "node-1": {
19
+ input = {
20
+ hello: "jsonata:hello",
21
+ };
22
+ output = {
23
+ hello: "jsonata:hello",
24
+ };
25
+ break;
26
+ }
27
+ case "node-5": {
28
+ input = {
29
+ hello: `jsonata:$."node-1".hello`,
30
+ };
31
+ output = {
32
+ hello: "jsonata:hello",
33
+ };
34
+ break;
35
+ }
36
+ default: {
37
+ input = {
38
+ hello: "other",
39
+ };
40
+ output = {
41
+ hello: "other",
42
+ };
43
+ break;
44
+ }
45
+ }
46
+ const res = {
47
+ id: nodeId,
48
+ properties: {
49
+ input,
50
+ output,
51
+ },
52
+ propertiesSchema: {
53
+ type: "object",
54
+ properties: {
55
+ input: {
56
+ type: "object",
57
+ properties: {
58
+ hello: {
59
+ type: "string",
88
60
  },
89
61
  },
90
- {
91
- id: "5",
92
- workflowNodeTypeResourceId: constants_1.SPECIFIC_WORKFLOW_NODE_TYPE_TO_WORKFLOW_NODE_TYPE_RESOURCE_ID_MAP.end,
93
- Executer: class AWorkflowNodeExecuter extends types_1.WorkflowNodeExecuter {
94
- constructor() {
95
- super(...arguments);
96
- this.execute = async () => {
97
- const { setVariables } = this;
98
- setVariables({
99
- variables: "mno",
100
- });
101
- };
102
- }
62
+ },
63
+ output: {
64
+ type: "object",
65
+ properties: {
66
+ hello: {
67
+ type: "string",
103
68
  },
104
69
  },
105
- ],
106
- };
107
- const res = {
108
- workflowData,
109
- };
110
- return res;
70
+ },
71
+ },
72
+ },
73
+ execute: workflowNodeExecute,
74
+ };
75
+ return res;
76
+ });
77
+ const workflowData = {
78
+ edges: [
79
+ {
80
+ sourceWorkflowNodeResourceId: "node-1",
81
+ targetWorkflowNodeResourceId: "node-2",
82
+ },
83
+ {
84
+ sourceWorkflowNodeResourceId: "node-2",
85
+ targetWorkflowNodeResourceId: "node-3",
86
+ },
87
+ {
88
+ sourceWorkflowNodeResourceId: "node-3",
89
+ targetWorkflowNodeResourceId: "node-4",
90
+ },
91
+ {
92
+ sourceWorkflowNodeResourceId: "node-4",
93
+ targetWorkflowNodeResourceId: "node-5",
94
+ },
95
+ ],
96
+ nodes,
97
+ };
98
+ const getWorkflowDataRes = {
99
+ workflowData,
100
+ };
101
+ class TestWorkflowResource extends resource_1.WorkflowResource {
102
+ constructor() {
103
+ super(...arguments);
104
+ this.getWorkflowData = () => {
105
+ return getWorkflowDataRes;
111
106
  };
112
107
  }
113
108
  }
114
109
  test("WorkflowResource execute", async () => {
115
- const aWorkflowResource = new AWorkflowResource({
110
+ const testWorkflowResource = new TestWorkflowResource({
116
111
  id: "test",
117
112
  kind: "workflow",
118
113
  parentId: "root",
119
114
  settings: {
120
115
  title: "",
121
116
  description: "",
122
- startWorkflowNodeResourceId: "1",
123
- endWorkflowNodeResourceId: "5",
117
+ startWorkflowNodeResourceId: "node-1",
118
+ endWorkflowNodeResourceId: "node-5",
124
119
  },
125
120
  });
126
- const { endNodeOutputVariables } = await aWorkflowResource.execute({
127
- startNodeInputVariables: {
128
- hello: "world",
129
- },
121
+ const workflowInputVariables = {
122
+ hello: "world",
123
+ };
124
+ const workflowOutputVariables = {
125
+ hello: "world",
126
+ };
127
+ const { variables } = await testWorkflowResource.execute({
128
+ variables: workflowInputVariables,
130
129
  });
131
- expect(endNodeOutputVariables).toMatchSnapshot();
130
+ expect(variables).toMatchObject(workflowOutputVariables);
132
131
  });
@@ -1 +1 @@
1
- {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAML,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,gCAAgC,EACjC,MAAM,SAAS,CAAC;AAGjB,MAAM,WAAW,0BAA0B;IACzC,oBAAoB,EAAE,gBAAgB,EAAE,CAAC;CAC1C;AAED,MAAM,MAAM,uBAAuB,GAAG,MAAM,0BAA0B,CAAC;AAEvE,MAAM,WAAW,0BAA0B;IACzC,oBAAoB,EAAE,gBAAgB,EAAE,CAAC;CAC1C;AAED,MAAM,MAAM,uBAAuB,GAAG,MAAM,0BAA0B,CAAC;AAEvE,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAAC;AAEvD,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAAC;AAEvD,qBAAa,gBAAiB,SAAQ,QAAQ,CAAC,gCAAgC,CAAC;IAC9E,uBAAuB,EAAE,uBAAuB,CA4B9C;IAEF,uBAAuB,EAAE,uBAAuB,CAsB9C;IAEF,eAAe,EAAE,eAAe,CAiB9B;IAEF,OAAO,EAAE,eAAe,CAiEtB;IAEF,eAAe,EAAE,eAAe,CAY9B;CACH"}
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAGL,YAAY,EACZ,gBAAgB,EAChB,eAAe,EAEf,YAAY,EACZ,gBAAgB,EAChB,gCAAgC,EAGjC,MAAM,SAAS,CAAC;AAIjB,MAAM,WAAW,0BAA0B;IACzC,oBAAoB,EAAE,gBAAgB,EAAE,CAAC;CAC1C;AAED,MAAM,MAAM,uBAAuB,GAAG,MAAM,0BAA0B,CAAC;AAEvE,MAAM,WAAW,0BAA0B;IACzC,oBAAoB,EAAE,gBAAgB,EAAE,CAAC;CAC1C;AAED,MAAM,MAAM,uBAAuB,GAAG,MAAM,0BAA0B,CAAC;AAEvE,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAAC;AAEvD,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAAC;AAEvD,qBAAa,gBAAiB,SAAQ,QAAQ,CAAC,gCAAgC,CAAC;IAC9E,uBAAuB,EAAE,uBAAuB,CA4B9C;IAEF,uBAAuB,EAAE,uBAAuB,CAsB9C;IAEF,eAAe,EAAE,eAAe,CAiB9B;IAEF,OAAO,EAAE,eAAe,CAgGtB;IAEF,eAAe,EAAE,eAAe,CAY9B;CACH"}
package/dist/resource.js CHANGED
@@ -7,6 +7,7 @@ exports.WorkflowResource = void 0;
7
7
  const resource_1 = require("@ldsg/resource");
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
9
  const utils_1 = require("./utils");
10
+ const evaluate_variables_1 = require("./utils/evaluate-variables");
10
11
  class WorkflowResource extends resource_1.Resource {
11
12
  constructor() {
12
13
  super(...arguments);
@@ -56,9 +57,9 @@ class WorkflowResource extends resource_1.Resource {
56
57
  return res;
57
58
  };
58
59
  this.execute = async (params) => {
59
- const { startNodeInputVariables } = params;
60
+ const { variables: workflowInputVariables } = params;
60
61
  const { getWorkflowData, settings: { startWorkflowNodeResourceId, endWorkflowNodeResourceId }, } = this;
61
- const nodeIdToVariablesMap = new Map();
62
+ const workflowVariablesMap = new Map();
62
63
  const { workflowData } = getWorkflowData();
63
64
  const { nodes } = workflowData;
64
65
  const startNode = nodes.find((value) => value.id === startWorkflowNodeResourceId);
@@ -71,28 +72,47 @@ class WorkflowResource extends resource_1.Resource {
71
72
  startNode,
72
73
  endNode,
73
74
  });
74
- const executeList = orderedNodeList.map((node) => {
75
- const { id, Executer } = node;
76
- if (!Executer) {
77
- throw new Error("invalid Executer");
78
- }
79
- const executer = new Executer({
80
- nodeId: id,
81
- nodeIdToVariablesMap,
82
- ...(id === startWorkflowNodeResourceId
83
- ? { inputVariables: startNodeInputVariables }
84
- : {}),
75
+ const orderedNodeListLength = orderedNodeList.length;
76
+ if (orderedNodeListLength < 2) {
77
+ throw new Error("invalid workflow nodes count");
78
+ }
79
+ let workflowOutputVariables;
80
+ for (let index = 0; index < orderedNodeListLength; index++) {
81
+ const node = orderedNodeList[index];
82
+ const { id, properties, propertiesSchema, execute: nodeExecute } = node;
83
+ const workflowVariables = Object.fromEntries(workflowVariablesMap);
84
+ // 输入变量从工作流变量中使用表达式获取
85
+ const workflowNodeInputJsonataExpression = lodash_1.default.get(properties, "input");
86
+ const { variables: workflowNodeInputVariables } = await (0, evaluate_variables_1.evaluateVariables)({
87
+ expression: workflowNodeInputJsonataExpression,
88
+ /**
89
+ * 对于开始节点,不忽略 input 表达式,但替换工作流内部变量为工作流输入变量。
90
+ */
91
+ variables: index === 0 ? workflowInputVariables : workflowVariables,
85
92
  });
86
- const res = executer.execute;
87
- return res;
88
- });
89
- for (const execute of executeList) {
90
- await execute();
93
+ const { variables: workflowNodeOutputExpressionEvaluateInput } = await nodeExecute({
94
+ variables: workflowNodeInputVariables,
95
+ context: {
96
+ workflowResourceInstance: this,
97
+ },
98
+ });
99
+ /**
100
+ * 输出变量从结果中使用表达式获取
101
+ * 对于结束节点,不忽略 output 表达式,但表达式固定为取返回变量。
102
+ */
103
+ const workflowNodeOutputJsonataExpression = lodash_1.default.get(properties, "output");
104
+ const { variables: workflowNodeOutputVariables } = await (0, evaluate_variables_1.evaluateVariables)({
105
+ expression: workflowNodeOutputJsonataExpression,
106
+ variables: workflowNodeOutputExpressionEvaluateInput,
107
+ });
108
+ workflowVariablesMap.set(id, workflowNodeOutputVariables);
109
+ if (index === orderedNodeListLength - 1) {
110
+ workflowOutputVariables = workflowNodeOutputVariables;
111
+ }
91
112
  }
92
- const res = (0, utils_1.getEndNodeOutputVariables)({
93
- endNode,
94
- nodeIdToVariablesMap,
95
- });
113
+ const res = {
114
+ variables: workflowOutputVariables,
115
+ };
96
116
  return res;
97
117
  };
98
118
  this.getWorkflowInfo = () => {
@@ -25,4 +25,4 @@ export interface GetWorkflowEdgeInfoRes {
25
25
  workflowEdgeInfo: WorkflowEdgeInfo;
26
26
  }
27
27
  export type GetWorkflowEdgeInfo = () => GetWorkflowEdgeInfoRes;
28
- //# sourceMappingURL=workflow-edge-info.d.ts.map
28
+ //# sourceMappingURL=edge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/types/edge.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,4BAA4B,EAAE,MAAM,CAAC;IAErC;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC;;OAEG;IACH,4BAA4B,EAAE,MAAM,CAAC;IAErC;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,sBAAsB,CAAC"}
@@ -1,7 +1,6 @@
1
- export * from "./node-variables";
1
+ export * from "./edge";
2
+ export * from "./node";
2
3
  export * from "./specific-resource-settings";
3
- export * from "./workflow-data";
4
- export * from "./workflow-edge-info";
5
- export * from "./workflow-info";
6
- export * from "./workflow-node-info";
4
+ export * from "./variables";
5
+ export * from "./workflow";
7
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,8BAA8B,CAAC;AAC7C,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
@@ -14,9 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./node-variables"), exports);
17
+ __exportStar(require("./edge"), exports);
18
+ __exportStar(require("./node"), exports);
18
19
  __exportStar(require("./specific-resource-settings"), exports);
19
- __exportStar(require("./workflow-data"), exports);
20
- __exportStar(require("./workflow-edge-info"), exports);
21
- __exportStar(require("./workflow-info"), exports);
22
- __exportStar(require("./workflow-node-info"), exports);
20
+ __exportStar(require("./variables"), exports);
21
+ __exportStar(require("./workflow"), exports);
@@ -0,0 +1,53 @@
1
+ import { JSONSchema7 } from "json-schema";
2
+ import { WorkflowResource } from "../resource";
3
+ export type WorkflowNodeExecuterExecute = () => void | Promise<void>;
4
+ export interface WorkflowNodeExecuteParams {
5
+ /**
6
+ * (输入)变量
7
+ * 由工作流向工作流节点内输入
8
+ */
9
+ variables: any;
10
+ context: {
11
+ workflowResourceInstance: WorkflowResource;
12
+ };
13
+ }
14
+ export interface WorkflowNodeExecuteRes {
15
+ /**
16
+ * (输出)变量
17
+ * 由工作流节点向工作流内输入
18
+ */
19
+ variables: any;
20
+ }
21
+ /**
22
+ * 工作流执行方法
23
+ * 工作执行时,实际运行的方法
24
+ */
25
+ export type WorkflowNodeExecute = (params: WorkflowNodeExecuteParams) => Promise<WorkflowNodeExecuteRes>;
26
+ export interface WorkflowNodeInfo {
27
+ /**
28
+ * ID
29
+ */
30
+ id: string;
31
+ /**
32
+ * Workflow Node Properties
33
+ */
34
+ properties: any;
35
+ /**
36
+ * Workflow Node Properties Schema
37
+ * 在运行时,可用于检验数据,默认不开启,仅开启调试模式时开启
38
+ */
39
+ propertiesSchema: JSONSchema7;
40
+ /**
41
+ * 工作流节点执行方法
42
+ * 工作流节点执行时,实际运行的方法
43
+ */
44
+ execute: WorkflowNodeExecute;
45
+ }
46
+ export interface GetWorkflowNodeInfoRes {
47
+ /**
48
+ * Workflow Node Info
49
+ */
50
+ workflowNodeInfo: WorkflowNodeInfo;
51
+ }
52
+ export type GetWorkflowNodeInfo = () => GetWorkflowNodeInfoRes;
53
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/types/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,MAAM,2BAA2B,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAErE,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,SAAS,EAAE,GAAG,CAAC;IAEf,OAAO,EAAE;QACP,wBAAwB,EAAE,gBAAgB,CAAC;KAC5C,CAAC;CACH;AAED,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,SAAS,EAAE,GAAG,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAChC,MAAM,EAAE,yBAAyB,KAC9B,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAErC,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,UAAU,EAAE,GAAG,CAAC;IAEhB;;;OAGG;IACH,gBAAgB,EAAE,WAAW,CAAC;IAE9B;;;OAGG;IACH,OAAO,EAAE,mBAAmB,CAAC;CAC9B;AAED,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 工作流变量
3
+ */
4
+ export type WorkflowVariables = any;
5
+ /**
6
+ * 工作流变量映射
7
+ * key 为资源 ID,可以是工作流节点资源 ID,也可以是工作流资源 ID
8
+ */
9
+ export type WorkflowVariablesMap = Map<string, WorkflowVariables>;
10
+ /**
11
+ * 工作流变量记录
12
+ */
13
+ export type WorkflowVariablesRecord = Record<string, WorkflowVariables>;
14
+ export interface SetWorkflowVariablesParams {
15
+ variables: WorkflowVariables;
16
+ }
17
+ export type SetWorkflowVariables = (params: SetWorkflowVariablesParams) => void;
18
+ //# sourceMappingURL=variables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../src/types/variables.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAEpC;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAExE,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,iBAAiB,CAAC;CAC9B;AAED,MAAM,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,0BAA0B,KAAK,IAAI,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { WorkflowEdgeInfo } from "./edge";
2
+ import { WorkflowNodeInfo } from "./node";
3
+ import { WorkflowVariables } from "./variables";
4
+ export interface WorkflowData {
5
+ edges: WorkflowEdgeInfo[];
6
+ nodes: WorkflowNodeInfo[];
7
+ }
8
+ export interface WorkflowExecuteParams {
9
+ /**
10
+ * 工作流输入变量
11
+ */
12
+ variables: WorkflowVariables;
13
+ }
14
+ export interface WorkflowExecuteRes {
15
+ /**
16
+ * 工作流输出变量
17
+ */
18
+ variables: WorkflowVariables;
19
+ }
20
+ /**
21
+ * 工作流执行方法
22
+ * 工作流执行时,实际运行的方法
23
+ */
24
+ export type WorkflowExecute = (params: WorkflowExecuteParams) => Promise<WorkflowExecuteRes>;
25
+ export interface WorkflowInfo {
26
+ execute: WorkflowExecute;
27
+ }
28
+ //# sourceMappingURL=workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/types/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,KAAK,EAAE,gBAAgB,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,SAAS,EAAE,iBAAiB,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,SAAS,EAAE,iBAAiB,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAC5B,MAAM,EAAE,qBAAqB,KAC1B,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAEjC,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,eAAe,CAAC;CAC1B"}
@@ -0,0 +1,11 @@
1
+ interface EvaluateVariablesParams {
2
+ expression: any;
3
+ variables: any;
4
+ }
5
+ interface EvaluateVariablesRes {
6
+ variables: any;
7
+ }
8
+ type EvaluateVariables = (params: EvaluateVariablesParams) => Promise<EvaluateVariablesRes>;
9
+ export declare const evaluateVariables: EvaluateVariables;
10
+ export {};
11
+ //# sourceMappingURL=evaluate-variables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate-variables.d.ts","sourceRoot":"","sources":["../../src/utils/evaluate-variables.ts"],"names":[],"mappings":"AAIA,UAAU,uBAAuB;IAC/B,UAAU,EAAE,GAAG,CAAC;IAChB,SAAS,EAAE,GAAG,CAAC;CAChB;AAED,UAAU,oBAAoB;IAC5B,SAAS,EAAE,GAAG,CAAC;CAChB;AAED,KAAK,iBAAiB,GAAG,CACvB,MAAM,EAAE,uBAAuB,KAC5B,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAEnC,eAAO,MAAM,iBAAiB,EAAE,iBAkC/B,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.evaluateVariables = void 0;
7
+ const flat_1 = require("flat");
8
+ const jsonata_1 = __importDefault(require("jsonata"));
9
+ const lodash_1 = __importDefault(require("lodash"));
10
+ const evaluateVariables = async (params) => {
11
+ const { expression: paramsExpression, variables: input } = params;
12
+ const flattenRes = (0, flat_1.flatten)(paramsExpression);
13
+ const expressionSubstrings = [];
14
+ lodash_1.default.each(flattenRes, (value, key) => {
15
+ if (value.startsWith("jsonata:")) {
16
+ const { pathname } = new URL(value);
17
+ if (pathname) {
18
+ expressionSubstrings.push(`"${key}": ${pathname}`);
19
+ }
20
+ }
21
+ else {
22
+ const stringifyRes = JSON.stringify({ [key]: value });
23
+ const pushParams = stringifyRes.slice(1, -1);
24
+ expressionSubstrings.push(pushParams);
25
+ }
26
+ });
27
+ const expression = `{${expressionSubstrings.join(",")}}`;
28
+ const evaluateRes = await (0, jsonata_1.default)(expression).evaluate(input);
29
+ const variables = (0, flat_1.unflatten)(evaluateRes);
30
+ const res = {
31
+ variables: JSON.parse(JSON.stringify(variables)),
32
+ };
33
+ return res;
34
+ };
35
+ exports.evaluateVariables = evaluateVariables;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=evaluate-variables.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate-variables.test.d.ts","sourceRoot":"","sources":["../../src/utils/evaluate-variables.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const evaluate_variables_1 = require("./evaluate-variables");
4
+ const input = {
5
+ Account: {
6
+ "Account Name": "Firefly",
7
+ Order: [
8
+ {
9
+ OrderID: "order103",
10
+ Product: [
11
+ {
12
+ "Product Name": "Bowler Hat",
13
+ ProductID: 858383,
14
+ SKU: "0406654608",
15
+ Description: {
16
+ Colour: "Purple",
17
+ Width: 300,
18
+ Height: 200,
19
+ Depth: 210,
20
+ Weight: 0.75,
21
+ },
22
+ Price: 34.45,
23
+ Quantity: 2,
24
+ },
25
+ {
26
+ "Product Name": "Trilby hat",
27
+ ProductID: 858236,
28
+ SKU: "0406634348",
29
+ Description: {
30
+ Colour: "Orange",
31
+ Width: 300,
32
+ Height: 200,
33
+ Depth: 210,
34
+ Weight: 0.6,
35
+ },
36
+ Price: 21.67,
37
+ Quantity: 1,
38
+ },
39
+ ],
40
+ },
41
+ {
42
+ OrderID: "order104",
43
+ Product: [
44
+ {
45
+ "Product Name": "Bowler Hat",
46
+ ProductID: 858383,
47
+ SKU: "040657863",
48
+ Description: {
49
+ Colour: "Purple",
50
+ Width: 300,
51
+ Height: 200,
52
+ Depth: 210,
53
+ Weight: 0.75,
54
+ },
55
+ Price: 34.45,
56
+ Quantity: 4,
57
+ },
58
+ {
59
+ ProductID: 345664,
60
+ SKU: "0406654603",
61
+ "Product Name": "Cloak",
62
+ Description: {
63
+ Colour: "Black",
64
+ Width: 30,
65
+ Height: 20,
66
+ Depth: 210,
67
+ Weight: 2,
68
+ },
69
+ Price: 107.99,
70
+ Quantity: 1,
71
+ },
72
+ ],
73
+ },
74
+ ],
75
+ },
76
+ };
77
+ const expression = JSON.parse(JSON.stringify({
78
+ CurrentAccount: "Current Account",
79
+ AccountName: `jsonata:Account."Account Name"`,
80
+ CurrentOrder: `jsonata:"Current Order"`,
81
+ OrderPrice: `jsonata:$sum(Account.Order.Product.(Price * Quantity))`,
82
+ OrderIds: `jsonata:Account.Order.Product.ProductID`,
83
+ nestd: {
84
+ CurrentAccount: "Current Account",
85
+ AccountName: `jsonata:Account."Account Name"`,
86
+ CurrentOrder: `jsonata:"Current Order"`,
87
+ OrderPrice: `jsonata:$sum(Account.Order.Product.(Price * Quantity))`,
88
+ OrderIds: `jsonata:Account.Order.Product.ProductID`,
89
+ nestd: {
90
+ CurrentAccount: "Current Account",
91
+ AccountName: `jsonata:Account."Account Name"`,
92
+ CurrentOrder: `jsonata:"Current Order"`,
93
+ OrderPrice: `jsonata:$sum(Account.Order.Product.(Price * Quantity))`,
94
+ OrderIds: `jsonata:Account.Order.Product.ProductID`,
95
+ nestd: {
96
+ CurrentAccount: "Current Account",
97
+ AccountName: `jsonata:Account."Account Name"`,
98
+ CurrentOrder: `jsonata:"Current Order"`,
99
+ OrderPrice: `jsonata:$sum(Account.Order.Product.(Price * Quantity))`,
100
+ OrderIds: `jsonata:Account.Order.Product.ProductID`,
101
+ },
102
+ },
103
+ },
104
+ }));
105
+ test("evaluate variables", async () => {
106
+ const evaluateVariablesRes = await (0, evaluate_variables_1.evaluateVariables)({
107
+ expression,
108
+ variables: input,
109
+ });
110
+ const expectedObject = {
111
+ variables: {
112
+ CurrentAccount: "Current Account",
113
+ AccountName: "Firefly",
114
+ CurrentOrder: "Current Order",
115
+ OrderPrice: 336.36,
116
+ OrderIds: [858383, 858236, 858383, 345664],
117
+ nestd: {
118
+ CurrentAccount: "Current Account",
119
+ AccountName: "Firefly",
120
+ CurrentOrder: "Current Order",
121
+ OrderPrice: 336.36,
122
+ OrderIds: [858383, 858236, 858383, 345664],
123
+ nestd: {
124
+ CurrentAccount: "Current Account",
125
+ AccountName: "Firefly",
126
+ CurrentOrder: "Current Order",
127
+ OrderPrice: 336.36,
128
+ OrderIds: [858383, 858236, 858383, 345664],
129
+ nestd: {
130
+ CurrentAccount: "Current Account",
131
+ AccountName: "Firefly",
132
+ CurrentOrder: "Current Order",
133
+ OrderPrice: 336.36,
134
+ OrderIds: [858383, 858236, 858383, 345664],
135
+ },
136
+ },
137
+ },
138
+ },
139
+ };
140
+ expect(evaluateVariablesRes).toMatchObject(expectedObject);
141
+ });
@@ -1,3 +1,2 @@
1
- export * from "./get-end-node-output-variables";
2
1
  export * from "./get-ordered-node-list";
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
@@ -14,5 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./get-end-node-output-variables"), exports);
18
17
  __exportStar(require("./get-ordered-node-list"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ldsg/workflow",
3
- "version": "0.2.11",
3
+ "version": "0.3.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -14,14 +14,18 @@
14
14
  "access": "public"
15
15
  },
16
16
  "dependencies": {
17
+ "flat": "^5.0.2",
18
+ "json-schema": "0.4.0",
17
19
  "lodash": "^4.17.21",
18
- "@ldsg/resource-definition": "0.2.11",
19
- "@ldsg/resource": "0.2.11",
20
- "@ldsg/handler": "0.2.11"
20
+ "@ldsg/handler": "0.3.0",
21
+ "@ldsg/resource-definition": "0.3.0",
22
+ "@ldsg/resource": "0.3.0"
21
23
  },
22
24
  "devDependencies": {
25
+ "@types/flat": "^5.0.5",
26
+ "@types/json-schema": "^7.0.15",
23
27
  "@types/lodash": "^4.14.202",
24
- "@ldsg/types": "0.2.11"
28
+ "@ldsg/types": "0.3.0"
25
29
  },
26
30
  "scripts": {
27
31
  "build": "tsc --project tsconfig.build.json",
@@ -1,4 +0,0 @@
1
- export type NodeId = string;
2
- export type NodeVariables = any;
3
- export type NodeIdToVariablesMap = Map<NodeId, NodeVariables>;
4
- //# sourceMappingURL=node-variables.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-variables.d.ts","sourceRoot":"","sources":["../../src/types/node-variables.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC;AAEhC,MAAM,MAAM,oBAAoB,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- import { WorkflowEdgeInfo } from "./workflow-edge-info";
2
- import { WorkflowNodeInfo } from "./workflow-node-info";
3
- export interface WorkflowData {
4
- edges: WorkflowEdgeInfo[];
5
- nodes: WorkflowNodeInfo[];
6
- }
7
- //# sourceMappingURL=workflow-data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow-data.d.ts","sourceRoot":"","sources":["../../src/types/workflow-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,KAAK,EAAE,gBAAgB,EAAE,CAAC;CAC3B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow-edge-info.d.ts","sourceRoot":"","sources":["../../src/types/workflow-edge-info.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,4BAA4B,EAAE,MAAM,CAAC;IAErC;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC;;OAEG;IACH,4BAA4B,EAAE,MAAM,CAAC;IAErC;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,sBAAsB,CAAC"}
@@ -1,13 +0,0 @@
1
- import { GetEndNodeOutputVariablesRes } from "../utils";
2
- import { NodeVariables } from "./node-variables";
3
- export interface WorkflowExecuteParams {
4
- startNodeInputVariables: NodeVariables;
5
- }
6
- export interface WorkflowExecuteRes {
7
- endNodeOutputVariables: NodeVariables;
8
- }
9
- export type WorkflowExecute = (params: WorkflowExecuteParams) => Promise<GetEndNodeOutputVariablesRes>;
10
- export interface WorkflowInfo {
11
- execute: WorkflowExecute;
12
- }
13
- //# sourceMappingURL=workflow-info.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow-info.d.ts","sourceRoot":"","sources":["../../src/types/workflow-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,WAAW,qBAAqB;IACpC,uBAAuB,EAAE,aAAa,CAAC;CACxC;AAED,MAAM,WAAW,kBAAkB;IACjC,sBAAsB,EAAE,aAAa,CAAC;CACvC;AAED,MAAM,MAAM,eAAe,GAAG,CAC5B,MAAM,EAAE,qBAAqB,KAC1B,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAE3C,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,eAAe,CAAC;CAC1B"}
@@ -1,53 +0,0 @@
1
- import { NodeId, NodeIdToVariablesMap, NodeVariables } from "./node-variables";
2
- export type WorkflowNodeExecuterExecute = () => void | Promise<void>;
3
- interface WorkflowNodeExecuterConstructorParams {
4
- nodeId: NodeId;
5
- nodeIdToVariablesMap: NodeIdToVariablesMap;
6
- /**
7
- * input variables
8
- * only in start node
9
- */
10
- inputVariables?: any;
11
- }
12
- interface SetVariablesParams {
13
- variables: NodeVariables;
14
- }
15
- type SetVariables = (params: SetVariablesParams) => void;
16
- export declare class WorkflowNodeExecuter implements WorkflowNodeExecuterConstructorParams {
17
- nodeId: NodeId;
18
- nodeIdToVariablesMap: NodeIdToVariablesMap;
19
- /**
20
- * input variables
21
- * only in start node
22
- */
23
- inputVariables?: any;
24
- constructor(params: WorkflowNodeExecuterConstructorParams);
25
- /**
26
- * Set Current Node Output Variables
27
- */
28
- setVariables: SetVariables;
29
- execute: WorkflowNodeExecuterExecute;
30
- }
31
- export interface WorkflowNodeInfo {
32
- /**
33
- * ID
34
- */
35
- id: string;
36
- /**
37
- * Workflow Node Type Resource ID
38
- */
39
- workflowNodeTypeResourceId: string;
40
- /**
41
- * Executer
42
- */
43
- Executer: typeof WorkflowNodeExecuter;
44
- }
45
- export interface GetWorkflowNodeInfoRes {
46
- /**
47
- * Workflow Node Info
48
- */
49
- workflowNodeInfo: WorkflowNodeInfo;
50
- }
51
- export type GetWorkflowNodeInfo = () => GetWorkflowNodeInfoRes;
52
- export {};
53
- //# sourceMappingURL=workflow-node-info.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow-node-info.d.ts","sourceRoot":"","sources":["../../src/types/workflow-node-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE/E,MAAM,MAAM,2BAA2B,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAErE,UAAU,qCAAqC;IAC7C,MAAM,EAAE,MAAM,CAAC;IAEf,oBAAoB,EAAE,oBAAoB,CAAC;IAE3C;;;OAGG;IACH,cAAc,CAAC,EAAE,GAAG,CAAC;CACtB;AAED,UAAU,kBAAkB;IAC1B,SAAS,EAAE,aAAa,CAAC;CAC1B;AAED,KAAK,YAAY,GAAG,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;AAEzD,qBAAa,oBACX,YAAW,qCAAqC;IAEhD,MAAM,EAAE,MAAM,CAAC;IAEf,oBAAoB,EAAE,oBAAoB,CAAC;IAE3C;;;OAGG;IACH,cAAc,CAAC,EAAE,GAAG,CAAC;gBAET,MAAM,EAAE,qCAAqC;IAQzD;;OAEG;IACH,YAAY,EAAE,YAAY,CAMxB;IAEF,OAAO,EAAE,2BAA2B,CASlC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,0BAA0B,EAAE,MAAM,CAAC;IAEnC;;OAEG;IACH,QAAQ,EAAE,OAAO,oBAAoB,CAAC;CACvC;AAED,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,sBAAsB,CAAC"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WorkflowNodeExecuter = void 0;
4
- class WorkflowNodeExecuter {
5
- constructor(params) {
6
- /**
7
- * Set Current Node Output Variables
8
- */
9
- this.setVariables = (params) => {
10
- const { variables } = params;
11
- const { nodeId, nodeIdToVariablesMap } = this;
12
- nodeIdToVariablesMap.set(nodeId, variables);
13
- };
14
- this.execute = () => {
15
- const { nodeId, nodeIdToVariablesMap } = this;
16
- console.info("WorkflowNodeExecuter execute nodeId", nodeId);
17
- console.info("WorkflowNodeExecuter execute nodeIdToVariablesMap", nodeIdToVariablesMap);
18
- };
19
- const { nodeId, nodeIdToVariablesMap, inputVariables } = params;
20
- this.nodeId = nodeId;
21
- this.nodeIdToVariablesMap = nodeIdToVariablesMap;
22
- this.inputVariables = inputVariables;
23
- }
24
- }
25
- exports.WorkflowNodeExecuter = WorkflowNodeExecuter;
@@ -1,10 +0,0 @@
1
- import { NodeIdToVariablesMap, WorkflowExecuteRes, WorkflowNodeInfo } from "../types";
2
- export interface GetEndNodeOutputVariablesParams {
3
- endNode: WorkflowNodeInfo;
4
- nodeIdToVariablesMap: NodeIdToVariablesMap;
5
- }
6
- export interface GetEndNodeOutputVariablesRes extends WorkflowExecuteRes {
7
- }
8
- export type GetEndNodeOutputVariables = (params: GetEndNodeOutputVariablesParams) => GetEndNodeOutputVariablesRes;
9
- export declare const getEndNodeOutputVariables: GetEndNodeOutputVariables;
10
- //# sourceMappingURL=get-end-node-output-variables.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-end-node-output-variables.d.ts","sourceRoot":"","sources":["../../src/utils/get-end-node-output-variables.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,gBAAgB,CAAC;IAC1B,oBAAoB,EAAE,oBAAoB,CAAC;CAC5C;AAED,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;CAAG;AAE3E,MAAM,MAAM,yBAAyB,GAAG,CACtC,MAAM,EAAE,+BAA+B,KACpC,4BAA4B,CAAC;AAElC,eAAO,MAAM,yBAAyB,EAAE,yBAYvC,CAAC"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEndNodeOutputVariables = void 0;
4
- const getEndNodeOutputVariables = (params) => {
5
- const { endNode, nodeIdToVariablesMap } = params;
6
- const endNodeOutputVariables = nodeIdToVariablesMap.get(endNode.id);
7
- const res = {
8
- endNodeOutputVariables,
9
- };
10
- return res;
11
- };
12
- exports.getEndNodeOutputVariables = getEndNodeOutputVariables;
File without changes
File without changes
File without changes