@ldsg/workflow 0.3.8 → 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.
- package/dist/__tests__/unit/resource.js +62 -61
- package/dist/constants.d.ts +3 -3
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +11 -11
- package/dist/handler.d.ts +5 -7
- package/dist/handler.d.ts.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/instantiate-resource.d.ts +4 -4
- package/dist/instantiate-resource.js +1 -1
- package/dist/resource.d.ts +2 -2
- package/dist/resource.d.ts.map +1 -1
- package/dist/resource.js +64 -51
- package/dist/types/index.d.ts +6 -6
- package/dist/types/json_schema_with_expression_extension.d.ts +8 -6
- package/dist/types/json_schema_with_expression_extension.d.ts.map +1 -1
- package/dist/types/node.d.ts +11 -11
- package/dist/types/node.d.ts.map +1 -1
- package/dist/types/specific-resource-settings.d.ts +1 -1
- package/dist/types/specific-resource-settings.d.ts.map +1 -1
- package/dist/types/workflow.d.ts +7 -3
- package/dist/types/workflow.d.ts.map +1 -1
- package/dist/utils/evaluate-variables/constants.d.ts.map +1 -1
- package/dist/utils/evaluate-variables/constants.js +17 -17
- package/dist/utils/evaluate-variables/index.d.ts +2 -2
- package/dist/utils/evaluate-variables/index.d.ts.map +1 -1
- package/dist/utils/evaluate-variables/index.debug.d.ts +2 -0
- package/dist/utils/evaluate-variables/index.debug.d.ts.map +1 -0
- package/dist/utils/evaluate-variables/index.debug.js +194 -0
- package/dist/utils/evaluate-variables/index.js +5 -5
- package/dist/utils/evaluate-variables/index.test.d.ts +2 -0
- package/dist/utils/evaluate-variables/index.test.d.ts.map +1 -0
- package/dist/utils/evaluate-variables/index.test.js +219 -0
- package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/index.d.ts +21 -0
- package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/index.d.ts.map +1 -0
- package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/index.js +17 -0
- 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
- package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/resolve-json-schema.d.ts.map +1 -0
- package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/resolve-json-schema.js +73 -0
- package/dist/utils/evaluate-variables/utils/get-field-path-by-field-type-key.d.ts.map +1 -1
- package/dist/utils/evaluate-variables/utils/get-field-path-by-field-type-key.js +3 -3
- package/dist/utils/get-execution-levels.d.ts +17 -0
- package/dist/utils/get-execution-levels.d.ts.map +1 -0
- package/dist/utils/get-execution-levels.js +136 -0
- package/dist/utils/get-execution-levels.test.d.ts +2 -0
- package/dist/utils/get-execution-levels.test.d.ts.map +1 -0
- package/dist/utils/get-execution-levels.test.js +228 -0
- package/package.json +22 -13
- package/dist/utils/evaluate-variables/utils/resolve-json-schema.d.ts.map +0 -1
- package/dist/utils/evaluate-variables/utils/resolve-json-schema.js +0 -112
- package/dist/utils/evaluate-variables.test.d.ts +0 -2
- package/dist/utils/evaluate-variables.test.d.ts.map +0 -1
- package/dist/utils/evaluate-variables.test.js +0 -219
- package/dist/utils/get-ordered-node-list.d.ts +0 -19
- package/dist/utils/get-ordered-node-list.d.ts.map +0 -1
- package/dist/utils/get-ordered-node-list.js +0 -41
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -17
|
@@ -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 = [
|
|
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
|
|
18
|
+
case 'node-1': {
|
|
19
19
|
input = {
|
|
20
|
-
type:
|
|
20
|
+
type: 'object',
|
|
21
21
|
properties: {
|
|
22
22
|
hello: {
|
|
23
|
-
type:
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
}
|
|
23
|
+
type: 'string',
|
|
24
|
+
'x-expression': 'hello'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
27
|
};
|
|
28
28
|
output = {
|
|
29
|
-
type:
|
|
29
|
+
type: 'object',
|
|
30
30
|
properties: {
|
|
31
31
|
hello: {
|
|
32
|
-
type:
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
}
|
|
32
|
+
type: 'string',
|
|
33
|
+
'x-expression': 'hello'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
36
|
};
|
|
37
37
|
break;
|
|
38
38
|
}
|
|
39
|
-
case
|
|
39
|
+
case 'node-5': {
|
|
40
40
|
input = {
|
|
41
|
-
type:
|
|
41
|
+
type: 'object',
|
|
42
42
|
properties: {
|
|
43
43
|
hello: {
|
|
44
|
-
type:
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
}
|
|
44
|
+
type: 'string',
|
|
45
|
+
'x-expression': `$."node-1".hello`
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
48
|
};
|
|
49
49
|
output = {
|
|
50
|
-
type:
|
|
50
|
+
type: 'object',
|
|
51
51
|
properties: {
|
|
52
52
|
hello: {
|
|
53
|
-
type:
|
|
54
|
-
|
|
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:
|
|
62
|
+
type: 'object',
|
|
63
63
|
properties: {
|
|
64
64
|
hello: {
|
|
65
|
-
type:
|
|
66
|
-
default:
|
|
67
|
-
}
|
|
68
|
-
}
|
|
65
|
+
type: 'string',
|
|
66
|
+
default: 'other'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
69
|
};
|
|
70
70
|
output = {
|
|
71
|
-
type:
|
|
71
|
+
type: 'object',
|
|
72
72
|
properties: {
|
|
73
73
|
hello: {
|
|
74
|
-
type:
|
|
75
|
-
default:
|
|
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:
|
|
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:
|
|
99
|
-
targetWorkflowNodeResourceId:
|
|
98
|
+
sourceWorkflowNodeResourceId: 'node-1',
|
|
99
|
+
targetWorkflowNodeResourceId: 'node-2'
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
|
-
sourceWorkflowNodeResourceId:
|
|
103
|
-
targetWorkflowNodeResourceId:
|
|
102
|
+
sourceWorkflowNodeResourceId: 'node-2',
|
|
103
|
+
targetWorkflowNodeResourceId: 'node-3'
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
|
-
sourceWorkflowNodeResourceId:
|
|
107
|
-
targetWorkflowNodeResourceId:
|
|
106
|
+
sourceWorkflowNodeResourceId: 'node-3',
|
|
107
|
+
targetWorkflowNodeResourceId: 'node-4'
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
|
-
sourceWorkflowNodeResourceId:
|
|
111
|
-
targetWorkflowNodeResourceId:
|
|
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(
|
|
127
|
+
test('WorkflowResource execute', async () => {
|
|
128
128
|
const testWorkflowResource = new TestWorkflowResource({
|
|
129
|
-
id:
|
|
130
|
-
kind:
|
|
131
|
-
parentId:
|
|
129
|
+
id: 'test',
|
|
130
|
+
kind: 'workflow',
|
|
131
|
+
parentId: 'root',
|
|
132
132
|
settings: {
|
|
133
|
-
title:
|
|
134
|
-
description:
|
|
135
|
-
startWorkflowNodeResourceId:
|
|
136
|
-
endWorkflowNodeResourceId:
|
|
137
|
-
}
|
|
133
|
+
title: '',
|
|
134
|
+
description: '',
|
|
135
|
+
startWorkflowNodeResourceId: 'node-1',
|
|
136
|
+
endWorkflowNodeResourceId: 'node-5'
|
|
137
|
+
}
|
|
138
138
|
});
|
|
139
139
|
const workflowInputVariables = {
|
|
140
|
-
hello:
|
|
140
|
+
hello: 'world'
|
|
141
141
|
};
|
|
142
142
|
const workflowOutputVariables = {
|
|
143
|
-
hello:
|
|
143
|
+
hello: 'world'
|
|
144
144
|
};
|
|
145
145
|
const { variables } = await testWorkflowResource.execute({
|
|
146
|
-
|
|
146
|
+
context: {},
|
|
147
|
+
variables: workflowInputVariables
|
|
147
148
|
});
|
|
148
149
|
expect(variables).toMatchObject(workflowOutputVariables);
|
|
149
150
|
});
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HandlerSpecificResourceSettings } from
|
|
2
|
-
import { ResourceDefinitionSpecificResourceSettings } from
|
|
3
|
-
import { GeneralResourceSettings } from
|
|
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
|
* 实例化资源处理程序普通资源配置
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -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,
|
|
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:
|
|
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:
|
|
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:
|
|
39
|
-
end:
|
|
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
|
|
2
|
-
import { InstantiateResourceParams, InstantiateResourceRes } from
|
|
3
|
-
import { WorkflowResource } from
|
|
4
|
-
import { WorkflowSpecificResourceSettings } from
|
|
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
|
package/dist/handler.d.ts.map
CHANGED
|
@@ -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,
|
|
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
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
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
|
|
2
|
-
import { InstantiateResource } from
|
|
3
|
-
import { WorkflowResource } from
|
|
4
|
-
import { WorkflowSpecificResourceSettings } from
|
|
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
|
package/dist/resource.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Resource } from
|
|
2
|
-
import { WorkflowData, WorkflowEdgeInfo, WorkflowExecute, WorkflowInfo, WorkflowNodeInfo, WorkflowSpecificResourceSettings } from
|
|
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
|
}
|
package/dist/resource.d.ts.map
CHANGED
|
@@ -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,
|
|
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
|
@@ -6,40 +6,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.WorkflowResource = void 0;
|
|
7
7
|
const resource_1 = require("@ldsg/resource");
|
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
-
const utils_1 = require("./utils");
|
|
10
9
|
const evaluate_variables_1 = require("./utils/evaluate-variables");
|
|
10
|
+
const get_execution_levels_1 = require("./utils/get-execution-levels");
|
|
11
11
|
class WorkflowResource extends resource_1.Resource {
|
|
12
12
|
constructor() {
|
|
13
13
|
super(...arguments);
|
|
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,
|
|
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,
|
|
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,83 +49,96 @@ 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 }
|
|
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(
|
|
68
|
+
throw new Error('invalid workflow nodes');
|
|
69
69
|
}
|
|
70
|
-
const {
|
|
70
|
+
const { executionLevels } = (0, get_execution_levels_1.getExecutionLevels)({
|
|
71
71
|
workflowData,
|
|
72
72
|
startNode,
|
|
73
|
-
endNode
|
|
73
|
+
endNode
|
|
74
74
|
});
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
throw new Error("invalid workflow nodes count");
|
|
75
|
+
if (executionLevels.length < 1) {
|
|
76
|
+
throw new Error('invalid workflow execution levels');
|
|
78
77
|
}
|
|
79
78
|
let workflowOutputVariables;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
79
|
+
// 按层级执行,同一层级的节点可以并行执行
|
|
80
|
+
for (let levelIndex = 0; levelIndex < executionLevels.length; levelIndex++) {
|
|
81
|
+
const currentLevel = executionLevels[levelIndex];
|
|
82
|
+
// 并行执行当前层级的所有节点
|
|
83
|
+
const levelPromises = currentLevel.map(async (node) => {
|
|
84
|
+
const { id, propertiesSchema, execute: nodeExecute } = node;
|
|
85
|
+
const workflowVariables = Object.fromEntries(workflowVariablesMap);
|
|
86
|
+
// 输入变量从工作流变量中使用表达式获取
|
|
87
|
+
const workflowNodePropertiesInputSchema = lodash_1.default.get(propertiesSchema, 'properties.input');
|
|
88
|
+
const workflowNodePropertiesOutputSchema = lodash_1.default.get(propertiesSchema, 'properties.output');
|
|
89
|
+
if (!lodash_1.default.isObject(workflowNodePropertiesInputSchema) ||
|
|
90
|
+
!lodash_1.default.isObject(workflowNodePropertiesOutputSchema)) {
|
|
91
|
+
throw new Error('invalid workflow node properties schema');
|
|
92
|
+
}
|
|
93
93
|
/**
|
|
94
94
|
* 对于开始节点,不忽略 input 表达式,但替换工作流内部变量为工作流输入变量。
|
|
95
95
|
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
const workflowNodeInputExpressionEvaluateInput = levelIndex === 0 ? workflowInputVariables : workflowVariables;
|
|
97
|
+
const { variables: workflowNodeInputVariables } = await (0, evaluate_variables_1.evaluateVariables)({
|
|
98
|
+
jsonSchema: workflowNodePropertiesInputSchema,
|
|
99
|
+
variables: workflowNodeInputExpressionEvaluateInput
|
|
100
|
+
});
|
|
101
|
+
const { variables: workflowNodeOutputExpressionEvaluateInput } = await nodeExecute({
|
|
102
|
+
context,
|
|
103
|
+
variables: workflowNodeInputVariables
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
* 输出变量从结果中使用表达式获取
|
|
107
|
+
* 对于结束节点,不忽略 output 表达式,但表达式固定为取返回变量。
|
|
108
|
+
*/
|
|
109
|
+
const { variables: workflowNodeOutputVariables } = await (0, evaluate_variables_1.evaluateVariables)({
|
|
110
|
+
jsonSchema: workflowNodePropertiesOutputSchema,
|
|
111
|
+
variables: workflowNodeOutputExpressionEvaluateInput
|
|
112
|
+
});
|
|
113
|
+
const res = {
|
|
114
|
+
nodeId: id,
|
|
115
|
+
variables: workflowNodeOutputVariables
|
|
116
|
+
};
|
|
117
|
+
return res;
|
|
103
118
|
});
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
119
|
+
// 等待当前层级的所有节点执行完成
|
|
120
|
+
const levelResults = await Promise.all(levelPromises);
|
|
121
|
+
// 将当前层级的结果更新到工作流变量映射中
|
|
122
|
+
levelResults.forEach((result) => {
|
|
123
|
+
workflowVariablesMap.set(result.nodeId, result.variables);
|
|
124
|
+
// 如果是结束节点,保存输出变量
|
|
125
|
+
if (result.nodeId === endNode.id) {
|
|
126
|
+
workflowOutputVariables = result.variables;
|
|
127
|
+
}
|
|
111
128
|
});
|
|
112
|
-
workflowVariablesMap.set(id, workflowNodeOutputVariables);
|
|
113
|
-
if (index === orderedNodeListLength - 1) {
|
|
114
|
-
workflowOutputVariables = workflowNodeOutputVariables;
|
|
115
|
-
}
|
|
116
129
|
}
|
|
117
130
|
const res = {
|
|
118
|
-
variables: workflowOutputVariables
|
|
131
|
+
variables: workflowOutputVariables
|
|
119
132
|
};
|
|
120
133
|
return res;
|
|
121
134
|
};
|
|
122
135
|
this.getWorkflowInfo = () => {
|
|
123
136
|
const { execute } = this;
|
|
124
137
|
const workflowInfo = {
|
|
125
|
-
execute
|
|
138
|
+
execute
|
|
126
139
|
};
|
|
127
140
|
const res = {
|
|
128
|
-
workflowInfo
|
|
141
|
+
workflowInfo
|
|
129
142
|
};
|
|
130
143
|
return res;
|
|
131
144
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
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
|
|
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
|
-
|
|
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
|
|
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;
|
|
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"}
|
package/dist/types/node.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import {
|
|
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:
|
|
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:
|
|
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:
|
|
35
|
+
propertiesSchema: JSONSchemaWithExpressionExtension;
|
|
36
36
|
/**
|
|
37
37
|
* 工作流节点执行方法
|
|
38
38
|
* 工作流节点执行时,实际运行的方法
|
package/dist/types/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/types/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
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"}
|