@ldsg/workflow 0.3.31 → 0.3.33
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/evaluate-variables.prefixItems.test.js +197 -191
- package/dist/__tests__/unit/resource.js +61 -61
- package/dist/__tests__/unit/resource.portId.test.js +144 -144
- package/dist/constants.d.ts +3 -3
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +10 -10
- package/dist/handler.d.ts +4 -4
- 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.js +12 -12
- package/dist/types/index.d.ts +6 -6
- package/dist/types/json_schema_with_expression_extension.d.ts +6 -6
- package/dist/types/json_schema_with_expression_extension.d.ts.map +1 -1
- package/dist/types/node.d.ts +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/specific-resource-settings.js +1 -1
- package/dist/types/workflow.d.ts +3 -3
- package/dist/utils/evaluate-variables/constants.js +17 -17
- package/dist/utils/evaluate-variables/index.d.ts +1 -1
- package/dist/utils/evaluate-variables/index.debug.js +79 -79
- package/dist/utils/evaluate-variables/index.js +2 -2
- package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/index.d.ts +1 -1
- package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/index.js +2 -2
- package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/resolve-json-schema.d.ts +1 -1
- package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/resolve-json-schema.js +11 -11
- package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/resolve-json-schema.js.bak +96 -0
- package/dist/utils/evaluate-variables/utils/get-field-path-by-field-type-key.js +3 -3
- package/dist/utils/execute-workflow.d.ts +2 -2
- package/dist/utils/execute-workflow.d.ts.map +1 -1
- package/dist/utils/execute-workflow.js +75 -39
- package/package.json +16 -12
|
@@ -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,27 +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
|
+
variables: workflowInputVariables,
|
|
148
148
|
});
|
|
149
149
|
expect(variables).toMatchObject(workflowOutputVariables);
|
|
150
150
|
});
|
|
@@ -5,93 +5,93 @@ const resource_1 = require("../../resource");
|
|
|
5
5
|
const createNode = (nodeId, inputSchema, outputSchema, execute) => ({
|
|
6
6
|
id: nodeId,
|
|
7
7
|
propertiesSchema: {
|
|
8
|
-
type:
|
|
8
|
+
type: "object",
|
|
9
9
|
properties: {
|
|
10
10
|
input: inputSchema,
|
|
11
|
-
output: outputSchema
|
|
12
|
-
}
|
|
11
|
+
output: outputSchema,
|
|
12
|
+
},
|
|
13
13
|
},
|
|
14
|
-
execute
|
|
14
|
+
execute,
|
|
15
15
|
});
|
|
16
16
|
// 测试 portId 功能
|
|
17
|
-
test(
|
|
17
|
+
test("WorkflowResource execute with portId", async () => {
|
|
18
18
|
// 创建节点
|
|
19
|
-
const startNode = createNode(
|
|
20
|
-
type:
|
|
19
|
+
const startNode = createNode("start", {
|
|
20
|
+
type: "object",
|
|
21
21
|
properties: {
|
|
22
22
|
value: {
|
|
23
|
-
type:
|
|
24
|
-
default:
|
|
25
|
-
}
|
|
26
|
-
}
|
|
23
|
+
type: "string",
|
|
24
|
+
default: "start",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
27
|
}, {
|
|
28
|
-
type:
|
|
28
|
+
type: "object",
|
|
29
29
|
properties: {
|
|
30
30
|
value: {
|
|
31
|
-
type:
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
}
|
|
31
|
+
type: "string",
|
|
32
|
+
"x-expression": "value",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
35
|
}, async ({ variables }) => ({
|
|
36
|
-
variables: { value: variables.value ||
|
|
37
|
-
portId:
|
|
36
|
+
variables: { value: variables.value || "start" }, // 确保输出有 value 字段
|
|
37
|
+
portId: "port-success", // 返回成功端口
|
|
38
38
|
}));
|
|
39
|
-
const successNode = createNode(
|
|
40
|
-
type:
|
|
39
|
+
const successNode = createNode("success", {
|
|
40
|
+
type: "object",
|
|
41
41
|
properties: {
|
|
42
42
|
value: {
|
|
43
|
-
type:
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
}
|
|
43
|
+
type: "string",
|
|
44
|
+
"x-expression": `$."start".value`,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
47
|
}, {
|
|
48
|
-
type:
|
|
48
|
+
type: "object",
|
|
49
49
|
properties: {
|
|
50
50
|
result: {
|
|
51
|
-
type:
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
}
|
|
51
|
+
type: "string",
|
|
52
|
+
"x-expression": "result",
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
55
|
}, async ({ variables }) => ({
|
|
56
|
-
variables: { result: `success: ${variables.value}` }
|
|
56
|
+
variables: { result: `success: ${variables.value}` },
|
|
57
57
|
}));
|
|
58
|
-
const failureNode = createNode(
|
|
59
|
-
type:
|
|
58
|
+
const failureNode = createNode("failure", {
|
|
59
|
+
type: "object",
|
|
60
60
|
properties: {
|
|
61
61
|
value: {
|
|
62
|
-
type:
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
}
|
|
62
|
+
type: "string",
|
|
63
|
+
"x-expression": `$."start".value`,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
66
|
}, {
|
|
67
|
-
type:
|
|
67
|
+
type: "object",
|
|
68
68
|
properties: {
|
|
69
69
|
result: {
|
|
70
|
-
type:
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
}
|
|
70
|
+
type: "string",
|
|
71
|
+
"x-expression": "value",
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
74
|
}, async ({ variables }) => ({
|
|
75
|
-
variables: { result: `failure: ${variables.value}` }
|
|
75
|
+
variables: { result: `failure: ${variables.value}` },
|
|
76
76
|
}));
|
|
77
|
-
const endNode = createNode(
|
|
78
|
-
type:
|
|
77
|
+
const endNode = createNode("end", {
|
|
78
|
+
type: "object",
|
|
79
79
|
properties: {
|
|
80
80
|
result: {
|
|
81
|
-
type:
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
}
|
|
81
|
+
type: "string",
|
|
82
|
+
"x-expression": '$."success".result',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
85
|
}, {
|
|
86
|
-
type:
|
|
86
|
+
type: "object",
|
|
87
87
|
properties: {
|
|
88
88
|
result: {
|
|
89
|
-
type:
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
}
|
|
89
|
+
type: "string",
|
|
90
|
+
"x-expression": "result",
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
93
|
}, async ({ variables }) => ({
|
|
94
|
-
variables // 直接返回评估后的变量
|
|
94
|
+
variables, // 直接返回评估后的变量
|
|
95
95
|
}));
|
|
96
96
|
// 创建工作流数据
|
|
97
97
|
// start -> success -> end (使用 port-success)
|
|
@@ -99,24 +99,24 @@ test('WorkflowResource execute with portId', async () => {
|
|
|
99
99
|
const workflowData = {
|
|
100
100
|
edges: [
|
|
101
101
|
{
|
|
102
|
-
sourceWorkflowNodeResourceId:
|
|
103
|
-
sourceWorkflowNodePortId:
|
|
104
|
-
targetWorkflowNodeResourceId:
|
|
102
|
+
sourceWorkflowNodeResourceId: "start",
|
|
103
|
+
sourceWorkflowNodePortId: "port-success",
|
|
104
|
+
targetWorkflowNodeResourceId: "success",
|
|
105
105
|
},
|
|
106
106
|
{
|
|
107
|
-
sourceWorkflowNodeResourceId:
|
|
108
|
-
sourceWorkflowNodePortId:
|
|
109
|
-
targetWorkflowNodeResourceId:
|
|
107
|
+
sourceWorkflowNodeResourceId: "start",
|
|
108
|
+
sourceWorkflowNodePortId: "port-failure",
|
|
109
|
+
targetWorkflowNodeResourceId: "failure",
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
|
-
sourceWorkflowNodeResourceId:
|
|
113
|
-
targetWorkflowNodeResourceId:
|
|
114
|
-
}
|
|
112
|
+
sourceWorkflowNodeResourceId: "success",
|
|
113
|
+
targetWorkflowNodeResourceId: "end",
|
|
114
|
+
},
|
|
115
115
|
],
|
|
116
|
-
nodes: [startNode, successNode, failureNode, endNode]
|
|
116
|
+
nodes: [startNode, successNode, failureNode, endNode],
|
|
117
117
|
};
|
|
118
118
|
const getWorkflowDataRes = {
|
|
119
|
-
workflowData
|
|
119
|
+
workflowData,
|
|
120
120
|
};
|
|
121
121
|
class TestWorkflowResource extends resource_1.WorkflowResource {
|
|
122
122
|
constructor() {
|
|
@@ -127,125 +127,125 @@ test('WorkflowResource execute with portId', async () => {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
const testWorkflowResource = new TestWorkflowResource({
|
|
130
|
-
id:
|
|
131
|
-
kind:
|
|
132
|
-
parentId:
|
|
130
|
+
id: "test",
|
|
131
|
+
kind: "workflow",
|
|
132
|
+
parentId: "root",
|
|
133
133
|
settings: {
|
|
134
|
-
title:
|
|
135
|
-
description:
|
|
136
|
-
startWorkflowNodeResourceId:
|
|
137
|
-
endWorkflowNodeResourceId:
|
|
138
|
-
}
|
|
134
|
+
title: "",
|
|
135
|
+
description: "",
|
|
136
|
+
startWorkflowNodeResourceId: "start",
|
|
137
|
+
endWorkflowNodeResourceId: "end",
|
|
138
|
+
},
|
|
139
139
|
});
|
|
140
140
|
const { variables } = await testWorkflowResource.execute({
|
|
141
141
|
context: {},
|
|
142
|
-
variables: {}
|
|
142
|
+
variables: {},
|
|
143
143
|
});
|
|
144
144
|
// 验证只有 success 分支被执行
|
|
145
|
-
expect(variables.result).toBe(
|
|
145
|
+
expect(variables.result).toBe("success: start");
|
|
146
146
|
});
|
|
147
147
|
// 测试默认端口(无 portId)
|
|
148
|
-
test(
|
|
149
|
-
const startNode = createNode(
|
|
150
|
-
type:
|
|
148
|
+
test("WorkflowResource execute without portId", async () => {
|
|
149
|
+
const startNode = createNode("start", {
|
|
150
|
+
type: "object",
|
|
151
151
|
properties: {
|
|
152
152
|
value: {
|
|
153
|
-
type:
|
|
154
|
-
default:
|
|
155
|
-
}
|
|
156
|
-
}
|
|
153
|
+
type: "string",
|
|
154
|
+
default: "default",
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
157
|
}, {
|
|
158
|
-
type:
|
|
158
|
+
type: "object",
|
|
159
159
|
properties: {
|
|
160
160
|
value: {
|
|
161
|
-
type:
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
}
|
|
161
|
+
type: "string",
|
|
162
|
+
"x-expression": "value",
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
165
|
}, async ({ variables }) => ({
|
|
166
|
-
variables: { value: variables.value ||
|
|
166
|
+
variables: { value: variables.value || "default" },
|
|
167
167
|
// 不返回 portId,使用默认端口
|
|
168
168
|
}));
|
|
169
|
-
const defaultNode = createNode(
|
|
170
|
-
type:
|
|
169
|
+
const defaultNode = createNode("default", {
|
|
170
|
+
type: "object",
|
|
171
171
|
properties: {
|
|
172
172
|
value: {
|
|
173
|
-
type:
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
}
|
|
173
|
+
type: "string",
|
|
174
|
+
"x-expression": `$."start".value`,
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
177
|
}, {
|
|
178
|
-
type:
|
|
178
|
+
type: "object",
|
|
179
179
|
properties: {
|
|
180
180
|
result: {
|
|
181
|
-
type:
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
}
|
|
181
|
+
type: "string",
|
|
182
|
+
"x-expression": "result",
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
185
|
}, async ({ variables }) => ({
|
|
186
|
-
variables: { result: `default: ${variables.value}` }
|
|
186
|
+
variables: { result: `default: ${variables.value}` },
|
|
187
187
|
}));
|
|
188
|
-
const specificNode = createNode(
|
|
189
|
-
type:
|
|
188
|
+
const specificNode = createNode("specific", {
|
|
189
|
+
type: "object",
|
|
190
190
|
properties: {
|
|
191
191
|
value: {
|
|
192
|
-
type:
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
}
|
|
192
|
+
type: "string",
|
|
193
|
+
"x-expression": `$."start".value`,
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
196
|
}, {
|
|
197
|
-
type:
|
|
197
|
+
type: "object",
|
|
198
198
|
properties: {
|
|
199
199
|
result: {
|
|
200
|
-
type:
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
}
|
|
200
|
+
type: "string",
|
|
201
|
+
"x-expression": "result",
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
204
|
}, async ({ variables }) => ({
|
|
205
|
-
variables: { result: `specific: ${variables.value}` }
|
|
205
|
+
variables: { result: `specific: ${variables.value}` },
|
|
206
206
|
}));
|
|
207
|
-
const endNode = createNode(
|
|
208
|
-
type:
|
|
207
|
+
const endNode = createNode("end", {
|
|
208
|
+
type: "object",
|
|
209
209
|
properties: {
|
|
210
210
|
result: {
|
|
211
|
-
type:
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
}
|
|
211
|
+
type: "string",
|
|
212
|
+
"x-expression": '$."default".result',
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
215
|
}, {
|
|
216
|
-
type:
|
|
216
|
+
type: "object",
|
|
217
217
|
properties: {
|
|
218
218
|
result: {
|
|
219
|
-
type:
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
}
|
|
219
|
+
type: "string",
|
|
220
|
+
"x-expression": "result",
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
223
|
}, async ({ variables }) => ({
|
|
224
|
-
variables // 直接返回评估后的变量
|
|
224
|
+
variables, // 直接返回评估后的变量
|
|
225
225
|
}));
|
|
226
226
|
// start -> default -> end (默认端口,无 portId)
|
|
227
227
|
// start -> specific (使用 port-specific, 不会被执行)
|
|
228
228
|
const workflowData = {
|
|
229
229
|
edges: [
|
|
230
230
|
{
|
|
231
|
-
sourceWorkflowNodeResourceId:
|
|
231
|
+
sourceWorkflowNodeResourceId: "start",
|
|
232
232
|
// 无 sourceWorkflowNodePortId,表示默认端口
|
|
233
|
-
targetWorkflowNodeResourceId:
|
|
233
|
+
targetWorkflowNodeResourceId: "default",
|
|
234
234
|
},
|
|
235
235
|
{
|
|
236
|
-
sourceWorkflowNodeResourceId:
|
|
237
|
-
sourceWorkflowNodePortId:
|
|
238
|
-
targetWorkflowNodeResourceId:
|
|
236
|
+
sourceWorkflowNodeResourceId: "start",
|
|
237
|
+
sourceWorkflowNodePortId: "port-specific",
|
|
238
|
+
targetWorkflowNodeResourceId: "specific",
|
|
239
239
|
},
|
|
240
240
|
{
|
|
241
|
-
sourceWorkflowNodeResourceId:
|
|
242
|
-
targetWorkflowNodeResourceId:
|
|
243
|
-
}
|
|
241
|
+
sourceWorkflowNodeResourceId: "default",
|
|
242
|
+
targetWorkflowNodeResourceId: "end",
|
|
243
|
+
},
|
|
244
244
|
],
|
|
245
|
-
nodes: [startNode, defaultNode, specificNode, endNode]
|
|
245
|
+
nodes: [startNode, defaultNode, specificNode, endNode],
|
|
246
246
|
};
|
|
247
247
|
const getWorkflowDataRes = {
|
|
248
|
-
workflowData
|
|
248
|
+
workflowData,
|
|
249
249
|
};
|
|
250
250
|
class TestWorkflowResource extends resource_1.WorkflowResource {
|
|
251
251
|
constructor() {
|
|
@@ -256,20 +256,20 @@ test('WorkflowResource execute without portId', async () => {
|
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
const testWorkflowResource = new TestWorkflowResource({
|
|
259
|
-
id:
|
|
260
|
-
kind:
|
|
261
|
-
parentId:
|
|
259
|
+
id: "test",
|
|
260
|
+
kind: "workflow",
|
|
261
|
+
parentId: "root",
|
|
262
262
|
settings: {
|
|
263
|
-
title:
|
|
264
|
-
description:
|
|
265
|
-
startWorkflowNodeResourceId:
|
|
266
|
-
endWorkflowNodeResourceId:
|
|
267
|
-
}
|
|
263
|
+
title: "",
|
|
264
|
+
description: "",
|
|
265
|
+
startWorkflowNodeResourceId: "start",
|
|
266
|
+
endWorkflowNodeResourceId: "end",
|
|
267
|
+
},
|
|
268
268
|
});
|
|
269
269
|
const { variables } = await testWorkflowResource.execute({
|
|
270
270
|
context: {},
|
|
271
|
-
variables: {}
|
|
271
|
+
variables: {},
|
|
272
272
|
});
|
|
273
273
|
// 验证只有默认分支被执行
|
|
274
|
-
expect(variables.result).toBe(
|
|
274
|
+
expect(variables.result).toBe("default: default");
|
|
275
275
|
});
|
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":"AAAA,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,+
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,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,+BAQnE,CAAC;AAEJ,eAAO,MAAM,6CAA6C,EAAE,uBAG3D,CAAC;AAEF,eAAO,MAAM,8CAA8C,EAAE,0CAG1D,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,iEAAiE;;;CAGpE,CAAC"}
|