@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,219 +0,0 @@
|
|
|
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 subJsonSchema = {
|
|
78
|
-
type: "object",
|
|
79
|
-
properties: {
|
|
80
|
-
CurrentAccount: {
|
|
81
|
-
type: "string",
|
|
82
|
-
/**
|
|
83
|
-
* 从默认值内取值
|
|
84
|
-
*/
|
|
85
|
-
default: "Current Account",
|
|
86
|
-
const: "Current Account",
|
|
87
|
-
},
|
|
88
|
-
type: {
|
|
89
|
-
type: "string",
|
|
90
|
-
default: "order",
|
|
91
|
-
},
|
|
92
|
-
AccountName: {
|
|
93
|
-
type: "string",
|
|
94
|
-
/**
|
|
95
|
-
* 根据 jsonata 取值
|
|
96
|
-
*/
|
|
97
|
-
"x-expression": `Account."Account Name"`,
|
|
98
|
-
},
|
|
99
|
-
CurrentOrder: {
|
|
100
|
-
type: "string",
|
|
101
|
-
/**
|
|
102
|
-
* 根据 jsonata 取值
|
|
103
|
-
*/
|
|
104
|
-
"x-expression": `"Current Order"`,
|
|
105
|
-
},
|
|
106
|
-
OrderPrice: {
|
|
107
|
-
type: "number",
|
|
108
|
-
"x-expression": "$sum(Account.Order.Product.(Price * Quantity))",
|
|
109
|
-
},
|
|
110
|
-
ProductIds: {
|
|
111
|
-
type: "array",
|
|
112
|
-
items: {
|
|
113
|
-
type: "number",
|
|
114
|
-
},
|
|
115
|
-
"x-expression": "Account.Order.Product.ProductID",
|
|
116
|
-
},
|
|
117
|
-
ordersWithProductIds: {
|
|
118
|
-
type: "array",
|
|
119
|
-
title: "具有产品 ID 的订单列表",
|
|
120
|
-
items: {
|
|
121
|
-
type: "object",
|
|
122
|
-
properties: {
|
|
123
|
-
CurrentOrdersWithProductIdsTitle: {
|
|
124
|
-
type: "string",
|
|
125
|
-
/**
|
|
126
|
-
* 从默认值内取值
|
|
127
|
-
*/
|
|
128
|
-
default: "CurrentOrdersWithProductIdsTitle",
|
|
129
|
-
const: "CurrentOrdersWithProductIdsTitle",
|
|
130
|
-
},
|
|
131
|
-
productIds: {
|
|
132
|
-
type: "array",
|
|
133
|
-
items: {
|
|
134
|
-
type: "number",
|
|
135
|
-
},
|
|
136
|
-
"x-expression": "$v.Product.ProductID",
|
|
137
|
-
},
|
|
138
|
-
AccountName: {
|
|
139
|
-
type: "string",
|
|
140
|
-
/**
|
|
141
|
-
* 根据 jsonata 取值
|
|
142
|
-
*/
|
|
143
|
-
"x-expression": `Account."Account Name"`,
|
|
144
|
-
},
|
|
145
|
-
orderId: {
|
|
146
|
-
type: "string",
|
|
147
|
-
"x-expression": "$v.OrderID",
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
"x-expression": "$map($.Account.Order, function($v, $i, $a) {{}})",
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
const jsonSchema = {
|
|
156
|
-
type: "object",
|
|
157
|
-
properties: {
|
|
158
|
-
...subJsonSchema.properties,
|
|
159
|
-
nestd: {
|
|
160
|
-
type: "object",
|
|
161
|
-
properties: {
|
|
162
|
-
...subJsonSchema.properties,
|
|
163
|
-
nestd: {
|
|
164
|
-
type: "object",
|
|
165
|
-
properties: {
|
|
166
|
-
...subJsonSchema.properties,
|
|
167
|
-
nestd: {
|
|
168
|
-
type: "object",
|
|
169
|
-
properties: {
|
|
170
|
-
...subJsonSchema.properties,
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
};
|
|
179
|
-
test("evaluate variables", async () => {
|
|
180
|
-
const evaluateVariablesRes = await (0, evaluate_variables_1.evaluateVariables)({
|
|
181
|
-
jsonSchema,
|
|
182
|
-
variables: input,
|
|
183
|
-
});
|
|
184
|
-
const expectedObject = {
|
|
185
|
-
variables: {
|
|
186
|
-
CurrentAccount: "Current Account",
|
|
187
|
-
type: "order",
|
|
188
|
-
AccountName: "Firefly",
|
|
189
|
-
CurrentOrder: "Current Order",
|
|
190
|
-
OrderPrice: 336.36,
|
|
191
|
-
ProductIds: [858383, 858236, 858383, 345664],
|
|
192
|
-
nestd: {
|
|
193
|
-
CurrentAccount: "Current Account",
|
|
194
|
-
type: "order",
|
|
195
|
-
AccountName: "Firefly",
|
|
196
|
-
CurrentOrder: "Current Order",
|
|
197
|
-
OrderPrice: 336.36,
|
|
198
|
-
ProductIds: [858383, 858236, 858383, 345664],
|
|
199
|
-
nestd: {
|
|
200
|
-
CurrentAccount: "Current Account",
|
|
201
|
-
type: "order",
|
|
202
|
-
AccountName: "Firefly",
|
|
203
|
-
CurrentOrder: "Current Order",
|
|
204
|
-
OrderPrice: 336.36,
|
|
205
|
-
ProductIds: [858383, 858236, 858383, 345664],
|
|
206
|
-
nestd: {
|
|
207
|
-
CurrentAccount: "Current Account",
|
|
208
|
-
type: "order",
|
|
209
|
-
AccountName: "Firefly",
|
|
210
|
-
CurrentOrder: "Current Order",
|
|
211
|
-
OrderPrice: 336.36,
|
|
212
|
-
ProductIds: [858383, 858236, 858383, 345664],
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
};
|
|
218
|
-
expect(evaluateVariablesRes).toMatchObject(expectedObject);
|
|
219
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { WorkflowData, WorkflowNodeInfo } from "../types";
|
|
2
|
-
interface GetOrderedNodeListParams {
|
|
3
|
-
workflowData: WorkflowData;
|
|
4
|
-
startNode: WorkflowNodeInfo;
|
|
5
|
-
endNode: WorkflowNodeInfo;
|
|
6
|
-
}
|
|
7
|
-
interface GetOrderedNodeListRes {
|
|
8
|
-
orderedNodeList: WorkflowNodeInfo[];
|
|
9
|
-
}
|
|
10
|
-
type GetOrderedNodeList = (params: GetOrderedNodeListParams) => GetOrderedNodeListRes;
|
|
11
|
-
/**
|
|
12
|
-
* 获取有序的节点列表
|
|
13
|
-
* 暂时先实现单线工作流,且节点只有开始与目标端口各一个。
|
|
14
|
-
* 1. 找到开始与结束节点
|
|
15
|
-
* 2. 从开始节点逐一向后查找
|
|
16
|
-
*/
|
|
17
|
-
export declare const getOrderedNodeList: GetOrderedNodeList;
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=get-ordered-node-list.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-ordered-node-list.d.ts","sourceRoot":"","sources":["../../src/utils/get-ordered-node-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE1D,UAAU,wBAAwB;IAChC,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,gBAAgB,CAAC;IAC5B,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED,UAAU,qBAAqB;IAC7B,eAAe,EAAE,gBAAgB,EAAE,CAAC;CACrC;AAED,KAAK,kBAAkB,GAAG,CACxB,MAAM,EAAE,wBAAwB,KAC7B,qBAAqB,CAAC;AAE3B;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBA4ChC,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOrderedNodeList = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 获取有序的节点列表
|
|
6
|
-
* 暂时先实现单线工作流,且节点只有开始与目标端口各一个。
|
|
7
|
-
* 1. 找到开始与结束节点
|
|
8
|
-
* 2. 从开始节点逐一向后查找
|
|
9
|
-
*/
|
|
10
|
-
const getOrderedNodeList = (params) => {
|
|
11
|
-
const { workflowData, startNode, endNode } = params;
|
|
12
|
-
const { edges, nodes } = workflowData;
|
|
13
|
-
const orderedNodeList = [startNode, endNode];
|
|
14
|
-
let currentNodeId = startNode.id;
|
|
15
|
-
let pending = true;
|
|
16
|
-
do {
|
|
17
|
-
const currentEdge = edges.find((edge) => edge.sourceWorkflowNodeResourceId === currentNodeId);
|
|
18
|
-
if (!currentEdge) {
|
|
19
|
-
throw new Error("invalid edge");
|
|
20
|
-
}
|
|
21
|
-
const { targetWorkflowNodeResourceId } = currentEdge;
|
|
22
|
-
const targetWorkflowNode = nodes.find((node) => node.id === targetWorkflowNodeResourceId);
|
|
23
|
-
if (targetWorkflowNode) {
|
|
24
|
-
currentNodeId = targetWorkflowNode.id;
|
|
25
|
-
if (currentNodeId === endNode.id) {
|
|
26
|
-
pending = false;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
orderedNodeList.splice(-1, 0, targetWorkflowNode);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
throw new Error("invalid edge");
|
|
34
|
-
}
|
|
35
|
-
} while (pending);
|
|
36
|
-
const res = {
|
|
37
|
-
orderedNodeList,
|
|
38
|
-
};
|
|
39
|
-
return res;
|
|
40
|
-
};
|
|
41
|
-
exports.getOrderedNodeList = getOrderedNodeList;
|
package/dist/utils/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
package/dist/utils/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./get-ordered-node-list"), exports);
|