@ldsg/workflow 0.3.9 → 0.3.10

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 (45) hide show
  1. package/dist/__tests__/unit/resource.js +62 -61
  2. package/dist/constants.d.ts +3 -3
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +11 -11
  5. package/dist/handler.d.ts +5 -7
  6. package/dist/handler.d.ts.map +1 -1
  7. package/dist/index.d.ts +5 -5
  8. package/dist/instantiate-resource.d.ts +4 -4
  9. package/dist/instantiate-resource.js +1 -1
  10. package/dist/resource.d.ts +2 -2
  11. package/dist/resource.d.ts.map +1 -1
  12. package/dist/resource.js +30 -30
  13. package/dist/types/index.d.ts +6 -6
  14. package/dist/types/json_schema_with_expression_extension.d.ts +8 -6
  15. package/dist/types/json_schema_with_expression_extension.d.ts.map +1 -1
  16. package/dist/types/node.d.ts +11 -11
  17. package/dist/types/node.d.ts.map +1 -1
  18. package/dist/types/specific-resource-settings.d.ts +1 -1
  19. package/dist/types/specific-resource-settings.d.ts.map +1 -1
  20. package/dist/types/workflow.d.ts +7 -3
  21. package/dist/types/workflow.d.ts.map +1 -1
  22. package/dist/utils/evaluate-variables/constants.d.ts.map +1 -1
  23. package/dist/utils/evaluate-variables/constants.js +17 -17
  24. package/dist/utils/evaluate-variables/index.d.ts +2 -2
  25. package/dist/utils/evaluate-variables/index.d.ts.map +1 -1
  26. package/dist/utils/evaluate-variables/index.debug.d.ts +2 -0
  27. package/dist/utils/evaluate-variables/index.debug.d.ts.map +1 -0
  28. package/dist/utils/evaluate-variables/index.debug.js +194 -0
  29. package/dist/utils/evaluate-variables/index.js +5 -5
  30. package/dist/utils/evaluate-variables/index.test.js +98 -98
  31. package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/index.d.ts +21 -0
  32. package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/index.d.ts.map +1 -0
  33. package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/index.js +17 -0
  34. package/dist/utils/evaluate-variables/utils/{resolve-json-schema.d.ts → get-data-with-json-schema-and-input/resolve-json-schema.d.ts} +10 -7
  35. package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/resolve-json-schema.d.ts.map +1 -0
  36. package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/resolve-json-schema.js +73 -0
  37. package/dist/utils/evaluate-variables/utils/get-field-path-by-field-type-key.d.ts.map +1 -1
  38. package/dist/utils/evaluate-variables/utils/get-field-path-by-field-type-key.js +3 -3
  39. package/dist/utils/get-execution-levels.d.ts +1 -1
  40. package/dist/utils/get-execution-levels.d.ts.map +1 -1
  41. package/dist/utils/get-execution-levels.js +5 -5
  42. package/dist/utils/get-execution-levels.test.js +86 -86
  43. package/package.json +22 -13
  44. package/dist/utils/evaluate-variables/utils/resolve-json-schema.d.ts.map +0 -1
  45. package/dist/utils/evaluate-variables/utils/resolve-json-schema.js +0 -112
@@ -1,80 +1,80 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const resource_1 = require("../../resource");
4
- const numberIdList = ["1", "2", "3", "4", "5"];
4
+ const numberIdList = ['1', '2', '3', '4', '5'];
5
5
  const nodeIdList = numberIdList.map((id) => `node-${id}`);
6
6
  const nodes = nodeIdList.map((nodeId) => {
7
7
  const workflowNodeExecute = async (params) => {
8
8
  const { variables: workflowNodeInputVariables } = params;
9
9
  const workflowNodeOutputVariables = workflowNodeInputVariables;
10
10
  const res = {
11
- variables: workflowNodeOutputVariables,
11
+ variables: workflowNodeOutputVariables
12
12
  };
13
13
  return res;
14
14
  };
15
15
  let input;
16
16
  let output;
17
17
  switch (nodeId) {
18
- case "node-1": {
18
+ case 'node-1': {
19
19
  input = {
20
- type: "object",
20
+ type: 'object',
21
21
  properties: {
22
22
  hello: {
23
- type: "string",
24
- "x-expression": "hello",
25
- },
26
- },
23
+ type: 'string',
24
+ 'x-expression': 'hello'
25
+ }
26
+ }
27
27
  };
28
28
  output = {
29
- type: "object",
29
+ type: 'object',
30
30
  properties: {
31
31
  hello: {
32
- type: "string",
33
- "x-expression": "hello",
34
- },
35
- },
32
+ type: 'string',
33
+ 'x-expression': 'hello'
34
+ }
35
+ }
36
36
  };
37
37
  break;
38
38
  }
39
- case "node-5": {
39
+ case 'node-5': {
40
40
  input = {
41
- type: "object",
41
+ type: 'object',
42
42
  properties: {
43
43
  hello: {
44
- type: "string",
45
- "x-expression": `$."node-1".hello`,
46
- },
47
- },
44
+ type: 'string',
45
+ 'x-expression': `$."node-1".hello`
46
+ }
47
+ }
48
48
  };
49
49
  output = {
50
- type: "object",
50
+ type: 'object',
51
51
  properties: {
52
52
  hello: {
53
- type: "string",
54
- "x-expression": "hello",
55
- },
56
- },
53
+ type: 'string',
54
+ 'x-expression': 'hello'
55
+ }
56
+ }
57
57
  };
58
58
  break;
59
59
  }
60
60
  default: {
61
61
  input = {
62
- type: "object",
62
+ type: 'object',
63
63
  properties: {
64
64
  hello: {
65
- type: "string",
66
- default: "other",
67
- },
68
- },
65
+ type: 'string',
66
+ default: 'other'
67
+ }
68
+ }
69
69
  };
70
70
  output = {
71
- type: "object",
71
+ type: 'object',
72
72
  properties: {
73
73
  hello: {
74
- type: "string",
75
- default: "other",
76
- },
77
- },
74
+ type: 'string',
75
+ default: 'other'
76
+ }
77
+ }
78
78
  };
79
79
  break;
80
80
  }
@@ -82,39 +82,39 @@ const nodes = nodeIdList.map((nodeId) => {
82
82
  const res = {
83
83
  id: nodeId,
84
84
  propertiesSchema: {
85
- type: "object",
85
+ type: 'object',
86
86
  properties: {
87
87
  input,
88
- output,
89
- },
88
+ output
89
+ }
90
90
  },
91
- execute: workflowNodeExecute,
91
+ execute: workflowNodeExecute
92
92
  };
93
93
  return res;
94
94
  });
95
95
  const workflowData = {
96
96
  edges: [
97
97
  {
98
- sourceWorkflowNodeResourceId: "node-1",
99
- targetWorkflowNodeResourceId: "node-2",
98
+ sourceWorkflowNodeResourceId: 'node-1',
99
+ targetWorkflowNodeResourceId: 'node-2'
100
100
  },
101
101
  {
102
- sourceWorkflowNodeResourceId: "node-2",
103
- targetWorkflowNodeResourceId: "node-3",
102
+ sourceWorkflowNodeResourceId: 'node-2',
103
+ targetWorkflowNodeResourceId: 'node-3'
104
104
  },
105
105
  {
106
- sourceWorkflowNodeResourceId: "node-3",
107
- targetWorkflowNodeResourceId: "node-4",
106
+ sourceWorkflowNodeResourceId: 'node-3',
107
+ targetWorkflowNodeResourceId: 'node-4'
108
108
  },
109
109
  {
110
- sourceWorkflowNodeResourceId: "node-4",
111
- targetWorkflowNodeResourceId: "node-5",
112
- },
110
+ sourceWorkflowNodeResourceId: 'node-4',
111
+ targetWorkflowNodeResourceId: 'node-5'
112
+ }
113
113
  ],
114
- nodes,
114
+ nodes
115
115
  };
116
116
  const getWorkflowDataRes = {
117
- workflowData,
117
+ workflowData
118
118
  };
119
119
  class TestWorkflowResource extends resource_1.WorkflowResource {
120
120
  constructor() {
@@ -124,26 +124,27 @@ class TestWorkflowResource extends resource_1.WorkflowResource {
124
124
  };
125
125
  }
126
126
  }
127
- test("WorkflowResource execute", async () => {
127
+ test('WorkflowResource execute', async () => {
128
128
  const testWorkflowResource = new TestWorkflowResource({
129
- id: "test",
130
- kind: "workflow",
131
- parentId: "root",
129
+ id: 'test',
130
+ kind: 'workflow',
131
+ parentId: 'root',
132
132
  settings: {
133
- title: "",
134
- description: "",
135
- startWorkflowNodeResourceId: "node-1",
136
- endWorkflowNodeResourceId: "node-5",
137
- },
133
+ title: '',
134
+ description: '',
135
+ startWorkflowNodeResourceId: 'node-1',
136
+ endWorkflowNodeResourceId: 'node-5'
137
+ }
138
138
  });
139
139
  const workflowInputVariables = {
140
- hello: "world",
140
+ hello: 'world'
141
141
  };
142
142
  const workflowOutputVariables = {
143
- hello: "world",
143
+ hello: 'world'
144
144
  };
145
145
  const { variables } = await testWorkflowResource.execute({
146
- variables: workflowInputVariables,
146
+ context: {},
147
+ variables: workflowInputVariables
147
148
  });
148
149
  expect(variables).toMatchObject(workflowOutputVariables);
149
150
  });
@@ -1,6 +1,6 @@
1
- import { HandlerSpecificResourceSettings } from "@ldsg/handler";
2
- import { ResourceDefinitionSpecificResourceSettings } from "@ldsg/resource-definition";
3
- import { GeneralResourceSettings } from "@ldsg/types";
1
+ import { HandlerSpecificResourceSettings } from '@ldsg/handler';
2
+ import { ResourceDefinitionSpecificResourceSettings } from '@ldsg/resource-definition';
3
+ import { GeneralResourceSettings } from '@ldsg/types';
4
4
  /**
5
5
  * Instantiate Resource Handler General Resource Settings
6
6
  * 实例化资源处理程序普通资源配置
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,0CAA0C,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,sDAAsD,EAAE,uBAIlE,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,uDAAuD,EAAE,+BAQnE,CAAC;AAEJ,eAAO,MAAM,6CAA6C,EAAE,uBAIzD,CAAC;AAEJ,eAAO,MAAM,8CAA8C,EAAE,0CAI1D,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,iEAAiE;;;CAIlE,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,0CAA0C,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,sDAAsD,EAAE,uBAGpE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uDAAuD,EAAE,+BAOrE,CAAC;AAEF,eAAO,MAAM,6CAA6C,EAAE,uBAG3D,CAAC;AAEF,eAAO,MAAM,8CAA8C,EAAE,0CAG5D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iEAAiE;;;CAGpE,CAAC"}
package/dist/constants.js CHANGED
@@ -7,8 +7,8 @@ const constants_1 = require("@ldsg/constants");
7
7
  * 实例化资源处理程序普通资源配置
8
8
  */
9
9
  exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = {
10
- title: "工作流实例化资源处理程序",
11
- description: "",
10
+ title: '工作流实例化资源处理程序',
11
+ description: ''
12
12
  };
13
13
  /**
14
14
  * Instantiate Resource Handler Specific Resource Settings
@@ -19,22 +19,22 @@ exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = {
19
19
  code: `export * from "@ldsg/workflow";`,
20
20
  dependencies: [
21
21
  {
22
- name: "@ldsg/workflow",
23
- },
24
- ],
22
+ name: '@ldsg/workflow'
23
+ }
24
+ ]
25
25
  };
26
26
  exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = {
27
- title: "工作流资源定义",
28
- description: "",
27
+ title: '工作流资源定义',
28
+ description: ''
29
29
  };
30
30
  exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = {
31
- kind: "workflow",
32
- parentKind: constants_1.ROOT_RESOURCE_KIND,
31
+ kind: 'workflow',
32
+ parentKind: constants_1.ROOT_RESOURCE_KIND
33
33
  };
34
34
  /**
35
35
  * Specific Workflow Node Type Id Map
36
36
  */
37
37
  exports.SPECIFIC_WORKFLOW_NODE_TYPE_TO_WORKFLOW_NODE_TYPE_RESOURCE_ID_MAP = {
38
- start: "start-workflow-node-type",
39
- end: "end-workflow-node-type",
38
+ start: 'start-workflow-node-type',
39
+ end: 'end-workflow-node-type'
40
40
  };
package/dist/handler.d.ts CHANGED
@@ -1,8 +1,6 @@
1
- import { Handler, HandlerExtendedResourceSettings } from "@ldsg/handler";
2
- import { InstantiateResourceParams, InstantiateResourceRes } from "@ldsg/resource";
3
- import { WorkflowResource } from "./resource";
4
- import { WorkflowSpecificResourceSettings } from "./types";
5
- export declare const handler: Handler<[
6
- InstantiateResourceParams<HandlerExtendedResourceSettings<WorkflowSpecificResourceSettings>>
7
- ], InstantiateResourceRes<WorkflowResource>>;
1
+ import { Handler, HandlerExtendedResourceSettings } from '@ldsg/handler';
2
+ import { InstantiateResourceParams, InstantiateResourceRes } from '@ldsg/resource';
3
+ import { WorkflowResource } from './resource';
4
+ import { WorkflowSpecificResourceSettings } from './types';
5
+ export declare const handler: Handler<InstantiateResourceParams<HandlerExtendedResourceSettings<WorkflowSpecificResourceSettings>>, InstantiateResourceRes<WorkflowResource>>;
8
6
  //# sourceMappingURL=handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAC;AAE3D,eAAO,MAAM,OAAO,EAAE,OAAO,CAC3B;IACE,yBAAyB,CACvB,+BAA+B,CAAC,gCAAgC,CAAC,CAClE;CACF,EACD,sBAAsB,CAAC,gBAAgB,CAAC,CACnB,CAAC"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAC;AAE3D,eAAO,MAAM,OAAO,EAAE,OAAO,CAC3B,yBAAyB,CAAC,+BAA+B,CAAC,gCAAgC,CAAC,CAAC,EAC5F,sBAAsB,CAAC,gBAAgB,CAAC,CACnB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from "./constants";
2
- export * from "./handler";
3
- export * from "./instantiate-resource";
4
- export * from "./resource";
5
- export * from "./types";
1
+ export * from './constants';
2
+ export * from './handler';
3
+ export * from './instantiate-resource';
4
+ export * from './resource';
5
+ export * from './types';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
- import { HandlerExtendedResourceSettings } from "@ldsg/handler";
2
- import { InstantiateResource } from "@ldsg/resource";
3
- import { WorkflowResource } from "./resource";
4
- import { WorkflowSpecificResourceSettings } from "./types";
1
+ import { HandlerExtendedResourceSettings } from '@ldsg/handler';
2
+ import { InstantiateResource } from '@ldsg/resource';
3
+ import { WorkflowResource } from './resource';
4
+ import { WorkflowSpecificResourceSettings } from './types';
5
5
  export declare const instantiateResource: InstantiateResource<HandlerExtendedResourceSettings<WorkflowSpecificResourceSettings>, WorkflowResource>;
6
6
  //# sourceMappingURL=instantiate-resource.d.ts.map
@@ -6,7 +6,7 @@ const instantiateResource = (params) => {
6
6
  const { resourceConstructorParams } = params;
7
7
  const resource = new resource_1.WorkflowResource(resourceConstructorParams);
8
8
  const res = {
9
- resource,
9
+ resource
10
10
  };
11
11
  return res;
12
12
  };
@@ -1,5 +1,5 @@
1
- import { Resource } from "@ldsg/resource";
2
- import { WorkflowData, WorkflowEdgeInfo, WorkflowExecute, WorkflowInfo, WorkflowNodeInfo, WorkflowSpecificResourceSettings } from "./types";
1
+ import { Resource } from '@ldsg/resource';
2
+ import { WorkflowData, WorkflowEdgeInfo, WorkflowExecute, WorkflowInfo, WorkflowNodeInfo, WorkflowSpecificResourceSettings } from './types';
3
3
  export interface GetWorkflowEdgeInfoListRes {
4
4
  workflowEdgeInfoList: WorkflowEdgeInfo[];
5
5
  }
@@ -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,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,CAiItB;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,CAsB9C;IAEF,uBAAuB,EAAE,uBAAuB,CAsB9C;IAEF,eAAe,EAAE,eAAe,CAiB9B;IAEF,OAAO,EAAE,eAAe,CAgHtB;IAEF,eAAe,EAAE,eAAe,CAY9B;CACH"}
package/dist/resource.js CHANGED
@@ -14,32 +14,32 @@ class WorkflowResource extends resource_1.Resource {
14
14
  this.getWorkflowEdgeInfoList = () => {
15
15
  const { id, getFilteredResources } = this;
16
16
  const { resources } = getFilteredResources({
17
- parentId: id,
17
+ parentId: id
18
18
  });
19
19
  const mapRes = resources.map((resource) => {
20
20
  var _a;
21
21
  return (_a = resource.getWorkflowEdgeInfo) === null || _a === void 0 ? void 0 : _a.call(resource);
22
22
  });
23
23
  const getWorkflowEdgeInfoResList = lodash_1.default.filter(mapRes, (value) => !lodash_1.default.isUndefined(value));
24
- const workflowEdgeInfoList = lodash_1.default.map(getWorkflowEdgeInfoResList, "workflowEdgeInfo");
24
+ const workflowEdgeInfoList = lodash_1.default.map(getWorkflowEdgeInfoResList, 'workflowEdgeInfo');
25
25
  const res = {
26
- workflowEdgeInfoList,
26
+ workflowEdgeInfoList
27
27
  };
28
28
  return res;
29
29
  };
30
30
  this.getWorkflowNodeInfoList = () => {
31
31
  const { id, getFilteredResources } = this;
32
32
  const { resources } = getFilteredResources({
33
- parentId: id,
33
+ parentId: id
34
34
  });
35
35
  const mapRes = resources.map((resource) => {
36
36
  var _a;
37
37
  return (_a = resource.getWorkflowNodeInfo) === null || _a === void 0 ? void 0 : _a.call(resource);
38
38
  });
39
39
  const filterRes = lodash_1.default.filter(mapRes, (value) => !lodash_1.default.isUndefined(value));
40
- const workflowNodeInfoList = lodash_1.default.map(filterRes, "workflowNodeInfo");
40
+ const workflowNodeInfoList = lodash_1.default.map(filterRes, 'workflowNodeInfo');
41
41
  const res = {
42
- workflowNodeInfoList,
42
+ workflowNodeInfoList
43
43
  };
44
44
  return res;
45
45
  };
@@ -49,31 +49,31 @@ class WorkflowResource extends resource_1.Resource {
49
49
  const { workflowNodeInfoList } = getWorkflowNodeInfoList();
50
50
  const workflowData = {
51
51
  edges: workflowEdgeInfoList,
52
- nodes: workflowNodeInfoList,
52
+ nodes: workflowNodeInfoList
53
53
  };
54
54
  const res = {
55
- workflowData,
55
+ workflowData
56
56
  };
57
57
  return res;
58
58
  };
59
59
  this.execute = async (params) => {
60
- const { presetWorkflowVariables = {}, variables: workflowInputVariables } = params;
61
- const { getWorkflowData, settings: { startWorkflowNodeResourceId, endWorkflowNodeResourceId }, } = this;
60
+ const { context, presetWorkflowVariables = {}, variables: workflowInputVariables } = params;
61
+ const { getWorkflowData, settings: { startWorkflowNodeResourceId, endWorkflowNodeResourceId } } = this;
62
62
  const workflowVariablesMap = new Map(Object.entries(presetWorkflowVariables));
63
63
  const { workflowData } = getWorkflowData();
64
64
  const { nodes } = workflowData;
65
65
  const startNode = nodes.find((value) => value.id === startWorkflowNodeResourceId);
66
66
  const endNode = nodes.find((value) => value.id === endWorkflowNodeResourceId);
67
67
  if (!startNode || !endNode) {
68
- throw new Error("invalid workflow nodes");
68
+ throw new Error('invalid workflow nodes');
69
69
  }
70
70
  const { executionLevels } = (0, get_execution_levels_1.getExecutionLevels)({
71
71
  workflowData,
72
72
  startNode,
73
- endNode,
73
+ endNode
74
74
  });
75
75
  if (executionLevels.length < 1) {
76
- throw new Error("invalid workflow execution levels");
76
+ throw new Error('invalid workflow execution levels');
77
77
  }
78
78
  let workflowOutputVariables;
79
79
  // 按层级执行,同一层级的节点可以并行执行
@@ -84,24 +84,23 @@ class WorkflowResource extends resource_1.Resource {
84
84
  const { id, propertiesSchema, execute: nodeExecute } = node;
85
85
  const workflowVariables = Object.fromEntries(workflowVariablesMap);
86
86
  // 输入变量从工作流变量中使用表达式获取
87
- const workflowNodePropertiesInputSchema = lodash_1.default.get(propertiesSchema, "properties.input");
88
- const workflowNodePropertiesOutputSchema = lodash_1.default.get(propertiesSchema, "properties.output");
87
+ const workflowNodePropertiesInputSchema = lodash_1.default.get(propertiesSchema, 'properties.input');
88
+ const workflowNodePropertiesOutputSchema = lodash_1.default.get(propertiesSchema, 'properties.output');
89
89
  if (!lodash_1.default.isObject(workflowNodePropertiesInputSchema) ||
90
90
  !lodash_1.default.isObject(workflowNodePropertiesOutputSchema)) {
91
- throw new Error("invalid workflow node properties schema");
91
+ throw new Error('invalid workflow node properties schema');
92
92
  }
93
+ /**
94
+ * 对于开始节点,不忽略 input 表达式,但替换工作流内部变量为工作流输入变量。
95
+ */
96
+ const workflowNodeInputExpressionEvaluateInput = levelIndex === 0 ? workflowInputVariables : workflowVariables;
93
97
  const { variables: workflowNodeInputVariables } = await (0, evaluate_variables_1.evaluateVariables)({
94
98
  jsonSchema: workflowNodePropertiesInputSchema,
95
- /**
96
- * 对于开始节点,不忽略 input 表达式,但替换工作流内部变量为工作流输入变量。
97
- */
98
- variables: levelIndex === 0 ? workflowInputVariables : workflowVariables,
99
+ variables: workflowNodeInputExpressionEvaluateInput
99
100
  });
100
101
  const { variables: workflowNodeOutputExpressionEvaluateInput } = await nodeExecute({
101
- variables: workflowNodeInputVariables,
102
- context: {
103
- workflowResourceInstance: this,
104
- },
102
+ context,
103
+ variables: workflowNodeInputVariables
105
104
  });
106
105
  /**
107
106
  * 输出变量从结果中使用表达式获取
@@ -109,12 +108,13 @@ class WorkflowResource extends resource_1.Resource {
109
108
  */
110
109
  const { variables: workflowNodeOutputVariables } = await (0, evaluate_variables_1.evaluateVariables)({
111
110
  jsonSchema: workflowNodePropertiesOutputSchema,
112
- variables: workflowNodeOutputExpressionEvaluateInput,
111
+ variables: workflowNodeOutputExpressionEvaluateInput
113
112
  });
114
- return {
113
+ const res = {
115
114
  nodeId: id,
116
- variables: workflowNodeOutputVariables,
115
+ variables: workflowNodeOutputVariables
117
116
  };
117
+ return res;
118
118
  });
119
119
  // 等待当前层级的所有节点执行完成
120
120
  const levelResults = await Promise.all(levelPromises);
@@ -128,17 +128,17 @@ class WorkflowResource extends resource_1.Resource {
128
128
  });
129
129
  }
130
130
  const res = {
131
- variables: workflowOutputVariables,
131
+ variables: workflowOutputVariables
132
132
  };
133
133
  return res;
134
134
  };
135
135
  this.getWorkflowInfo = () => {
136
136
  const { execute } = this;
137
137
  const workflowInfo = {
138
- execute,
138
+ execute
139
139
  };
140
140
  const res = {
141
- workflowInfo,
141
+ workflowInfo
142
142
  };
143
143
  return res;
144
144
  };
@@ -1,7 +1,7 @@
1
- export * from "./edge";
2
- export * from "./json_schema_with_expression_extension";
3
- export * from "./node";
4
- export * from "./specific-resource-settings";
5
- export * from "./variables";
6
- export * from "./workflow";
1
+ export * from './edge';
2
+ export * from './json_schema_with_expression_extension';
3
+ export * from './node';
4
+ export * from './specific-resource-settings';
5
+ export * from './variables';
6
+ export * from './workflow';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,14 +1,16 @@
1
- import { JSONSchema7 } from "json-schema";
1
+ import { JSONSchema7, JSONSchema7TypeName } from 'json-schema';
2
+ export type JSONSchemaWithExpressionExtensionType = JSONSchema7TypeName | 'any';
2
3
  /**
3
4
  * JSON Schema with Expression Extension
4
5
  */
5
- export interface JSONSchemaWithExpressionExtension extends JSONSchema7 {
6
- "x-expression"?: string;
7
- "x-expression-const"?: string;
8
- "x-expression-default"?: string;
6
+ export interface JSONSchemaWithExpressionExtension extends Omit<JSONSchema7, 'type' | 'items' | 'properties'> {
7
+ type?: JSONSchemaWithExpressionExtensionType;
9
8
  properties?: {
10
9
  [key: string]: JSONSchemaWithExpressionExtension;
11
10
  };
12
- items?: JSONSchemaWithExpressionExtension | JSONSchemaWithExpressionExtension[];
11
+ items?: JSONSchemaWithExpressionExtension;
12
+ 'x-expression'?: string;
13
+ 'x-expression-const'?: string;
14
+ 'x-expression-default'?: string;
13
15
  }
14
16
  //# sourceMappingURL=json_schema_with_expression_extension.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"json_schema_with_expression_extension.d.ts","sourceRoot":"","sources":["../../src/types/json_schema_with_expression_extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,iCAAkC,SAAQ,WAAW;IACpE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC,UAAU,CAAC,EAAE;QACX,CAAC,GAAG,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAClD,CAAC;IAEF,KAAK,CAAC,EACF,iCAAiC,GACjC,iCAAiC,EAAE,CAAC;CACzC"}
1
+ {"version":3,"file":"json_schema_with_expression_extension.d.ts","sourceRoot":"","sources":["../../src/types/json_schema_with_expression_extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE/D,MAAM,MAAM,qCAAqC,GAAG,mBAAmB,GAAG,KAAK,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,iCACf,SAAQ,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC;IAC1D,IAAI,CAAC,EAAE,qCAAqC,CAAC;IAE7C,UAAU,CAAC,EAAE;QACX,CAAC,GAAG,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAClD,CAAC;IAEF,KAAK,CAAC,EAAE,iCAAiC,CAAC;IAE1C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC"}
@@ -1,28 +1,28 @@
1
- import { JSONSchema7 } from "json-schema";
2
- import { WorkflowResource } from "../resource";
1
+ import { JSONSchemaWithExpressionExtension } from './json_schema_with_expression_extension';
3
2
  export type WorkflowNodeExecuterExecute = () => void | Promise<void>;
4
- export interface WorkflowNodeExecuteParams {
3
+ export interface WorkflowNodeExecuteParams<Variables = any, Context = any> {
4
+ /**
5
+ * 上下文
6
+ */
7
+ context: Context;
5
8
  /**
6
9
  * (输入)变量
7
10
  * 由工作流向工作流节点内输入
8
11
  */
9
- variables: any;
10
- context: {
11
- workflowResourceInstance: WorkflowResource;
12
- };
12
+ variables: Variables;
13
13
  }
14
- export interface WorkflowNodeExecuteRes {
14
+ export interface WorkflowNodeExecuteRes<Variables = any> {
15
15
  /**
16
16
  * (输出)变量
17
17
  * 由工作流节点向工作流内输入
18
18
  */
19
- variables: any;
19
+ variables: Variables;
20
20
  }
21
21
  /**
22
22
  * 工作流执行方法
23
23
  * 工作执行时,实际运行的方法
24
24
  */
25
- export type WorkflowNodeExecute = (params: WorkflowNodeExecuteParams) => Promise<WorkflowNodeExecuteRes>;
25
+ export type WorkflowNodeExecute<Variables = any, Context = any> = (params: WorkflowNodeExecuteParams<Variables, Context>) => Promise<WorkflowNodeExecuteRes<Variables>>;
26
26
  export interface WorkflowNodeInfo {
27
27
  /**
28
28
  * ID
@@ -32,7 +32,7 @@ export interface WorkflowNodeInfo {
32
32
  * Workflow Node Properties Schema
33
33
  * 在运行时,可用于检验数据,默认不开启,仅开启调试模式时开启
34
34
  */
35
- propertiesSchema: JSONSchema7;
35
+ propertiesSchema: JSONSchemaWithExpressionExtension;
36
36
  /**
37
37
  * 工作流节点执行方法
38
38
  * 工作流节点执行时,实际运行的方法
@@ -1 +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;;;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"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/types/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,yCAAyC,CAAC;AAE5F,MAAM,MAAM,2BAA2B,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAErE,MAAM,WAAW,yBAAyB,CAAC,SAAS,GAAG,GAAG,EAAE,OAAO,GAAG,GAAG;IACvE;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,sBAAsB,CAAC,SAAS,GAAG,GAAG;IACrD;;;OAGG;IACH,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,CAAC,SAAS,GAAG,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,CAChE,MAAM,EAAE,yBAAyB,CAAC,SAAS,EAAE,OAAO,CAAC,KAClD,OAAO,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;OAGG;IACH,gBAAgB,EAAE,iCAAiC,CAAC;IAEpD;;;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"}
@@ -1,4 +1,4 @@
1
- import { SpecificResourceSettings } from "@ldsg/types";
1
+ import { SpecificResourceSettings } from '@ldsg/types';
2
2
  export interface WorkflowSpecificResourceSettings extends SpecificResourceSettings {
3
3
  /**
4
4
  * Start Workflow Node Resource ID
@@ -1 +1 @@
1
- {"version":3,"file":"specific-resource-settings.d.ts","sourceRoot":"","sources":["../../src/types/specific-resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,WAAW,gCACf,SAAQ,wBAAwB;IAChC;;OAEG;IACH,2BAA2B,EAAE,MAAM,CAAC;IAEpC;;OAEG;IACH,yBAAyB,EAAE,MAAM,CAAC;CACnC"}
1
+ {"version":3,"file":"specific-resource-settings.d.ts","sourceRoot":"","sources":["../../src/types/specific-resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,WAAW,gCAAiC,SAAQ,wBAAwB;IAChF;;OAEG;IACH,2BAA2B,EAAE,MAAM,CAAC;IAEpC;;OAEG;IACH,yBAAyB,EAAE,MAAM,CAAC;CACnC"}
@@ -1,11 +1,15 @@
1
- import { WorkflowEdgeInfo } from "./edge";
2
- import { WorkflowNodeInfo } from "./node";
3
- import { WorkflowVariables } from "./variables";
1
+ import { WorkflowEdgeInfo } from './edge';
2
+ import { WorkflowNodeInfo } from './node';
3
+ import { WorkflowVariables } from './variables';
4
4
  export interface WorkflowData {
5
5
  edges: WorkflowEdgeInfo[];
6
6
  nodes: WorkflowNodeInfo[];
7
7
  }
8
8
  export interface WorkflowExecuteParams {
9
+ /**
10
+ * 上下文
11
+ */
12
+ context: any;
9
13
  /**
10
14
  * 工作流输入变量
11
15
  */
@@ -1 +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;IAE7B;;OAEG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAC7D;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"}
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,OAAO,EAAE,GAAG,CAAC;IAEb;;OAEG;IACH,SAAS,EAAE,iBAAiB,CAAC;IAE7B;;OAEG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,SAAS,EAAE,iBAAiB,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAE7F,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,eAAe,CAAC;CAC1B"}