@ldsg/workflow 0.3.9 → 0.3.11
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.d.ts +2 -0
- package/dist/__tests__/unit/evaluate-variables.prefixItems.test.d.ts.map +1 -0
- package/dist/__tests__/unit/evaluate-variables.prefixItems.test.js +391 -0
- package/dist/__tests__/unit/resource.js +62 -61
- package/dist/__tests__/unit/resource.portId.test.d.ts +2 -0
- package/dist/__tests__/unit/resource.portId.test.d.ts.map +1 -0
- package/dist/__tests__/unit/resource.portId.test.js +275 -0
- 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 +23 -83
- package/dist/types/index.d.ts +6 -6
- package/dist/types/json_schema_with_expression_extension.d.ts +9 -6
- package/dist/types/json_schema_with_expression_extension.d.ts.map +1 -1
- package/dist/types/node.d.ts +15 -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 +12 -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/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 +96 -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/execute-workflow.d.ts +22 -0
- package/dist/utils/execute-workflow.d.ts.map +1 -0
- package/dist/utils/execute-workflow.js +212 -0
- package/package.json +25 -14
- package/dist/utils/evaluate-variables/index.test.d.ts +0 -2
- package/dist/utils/evaluate-variables/index.test.d.ts.map +0 -1
- package/dist/utils/evaluate-variables/index.test.js +0 -219
- 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/get-execution-levels.d.ts +0 -17
- package/dist/utils/get-execution-levels.d.ts.map +0 -1
- package/dist/utils/get-execution-levels.js +0 -136
- package/dist/utils/get-execution-levels.test.d.ts +0 -2
- package/dist/utils/get-execution-levels.test.d.ts.map +0 -1
- package/dist/utils/get-execution-levels.test.js +0 -228
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate-variables.prefixItems.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/unit/evaluate-variables.prefixItems.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const evaluate_variables_1 = require("../../utils/evaluate-variables");
|
|
4
|
+
describe('evaluateVariables with prefixItems', () => {
|
|
5
|
+
describe('basic prefixItems functionality', () => {
|
|
6
|
+
it('should return array with all evaluated expressions', async () => {
|
|
7
|
+
const variables = {
|
|
8
|
+
'694bf14e2af2addf73c8c849': {
|
|
9
|
+
data: {
|
|
10
|
+
suite_access_token: 'token_from_first_source'
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
'694c81a0f12010773020eafb': {
|
|
14
|
+
suite_access_token: 'token_from_second_source'
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const jsonSchema = {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
tokens: {
|
|
21
|
+
type: 'array',
|
|
22
|
+
prefixItems: [
|
|
23
|
+
{
|
|
24
|
+
'x-expression': '$.\"694bf14e2af2addf73c8c849\".\"data\".\"suite_access_token\"'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
'x-expression': '$.\"694c81a0f12010773020eafb\".\"suite_access_token\"'
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const result = await (0, evaluate_variables_1.evaluateVariables)({ jsonSchema, variables });
|
|
34
|
+
expect(result.variables.tokens).toEqual(['token_from_first_source', 'token_from_second_source']);
|
|
35
|
+
});
|
|
36
|
+
it('should handle single prefixItem', async () => {
|
|
37
|
+
const variables = {
|
|
38
|
+
source1: {
|
|
39
|
+
value: 'test_value'
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const jsonSchema = {
|
|
43
|
+
type: 'object',
|
|
44
|
+
properties: {
|
|
45
|
+
items: {
|
|
46
|
+
type: 'array',
|
|
47
|
+
prefixItems: [
|
|
48
|
+
{
|
|
49
|
+
'x-expression': '$.source1.value'
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const result = await (0, evaluate_variables_1.evaluateVariables)({ jsonSchema, variables });
|
|
56
|
+
expect(result.variables.items).toEqual(['test_value']);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe('handling different value types', () => {
|
|
60
|
+
it('should handle null values in prefixItems', async () => {
|
|
61
|
+
const variables = {
|
|
62
|
+
source1: {
|
|
63
|
+
value: null
|
|
64
|
+
},
|
|
65
|
+
source2: {
|
|
66
|
+
value: 'valid_value'
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const jsonSchema = {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties: {
|
|
72
|
+
items: {
|
|
73
|
+
type: 'array',
|
|
74
|
+
prefixItems: [
|
|
75
|
+
{
|
|
76
|
+
'x-expression': '$.source1.value'
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
'x-expression': '$.source2.value'
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const result = await (0, evaluate_variables_1.evaluateVariables)({ jsonSchema, variables });
|
|
86
|
+
expect(result.variables.items).toEqual([null, 'valid_value']);
|
|
87
|
+
});
|
|
88
|
+
it('should handle undefined values in prefixItems', async () => {
|
|
89
|
+
const variables = {
|
|
90
|
+
source2: {
|
|
91
|
+
value: 'valid_value'
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const jsonSchema = {
|
|
95
|
+
type: 'object',
|
|
96
|
+
properties: {
|
|
97
|
+
items: {
|
|
98
|
+
type: 'array',
|
|
99
|
+
prefixItems: [
|
|
100
|
+
{
|
|
101
|
+
'x-expression': '$.source1.value'
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
'x-expression': '$.source2.value'
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const result = await (0, evaluate_variables_1.evaluateVariables)({ jsonSchema, variables });
|
|
111
|
+
expect(result.variables.items).toEqual([undefined, 'valid_value']);
|
|
112
|
+
});
|
|
113
|
+
it('should handle number values', async () => {
|
|
114
|
+
const variables = {
|
|
115
|
+
source1: {
|
|
116
|
+
value: 42
|
|
117
|
+
},
|
|
118
|
+
source2: {
|
|
119
|
+
value: 100
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const jsonSchema = {
|
|
123
|
+
type: 'object',
|
|
124
|
+
properties: {
|
|
125
|
+
numbers: {
|
|
126
|
+
type: 'array',
|
|
127
|
+
prefixItems: [
|
|
128
|
+
{
|
|
129
|
+
'x-expression': '$.source1.value'
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
'x-expression': '$.source2.value'
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const result = await (0, evaluate_variables_1.evaluateVariables)({ jsonSchema, variables });
|
|
139
|
+
expect(result.variables.numbers).toEqual([42, 100]);
|
|
140
|
+
});
|
|
141
|
+
it('should handle boolean values', async () => {
|
|
142
|
+
const variables = {
|
|
143
|
+
source1: {
|
|
144
|
+
value: true
|
|
145
|
+
},
|
|
146
|
+
source2: {
|
|
147
|
+
value: false
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const jsonSchema = {
|
|
151
|
+
type: 'object',
|
|
152
|
+
properties: {
|
|
153
|
+
booleans: {
|
|
154
|
+
type: 'array',
|
|
155
|
+
prefixItems: [
|
|
156
|
+
{
|
|
157
|
+
'x-expression': '$.source1.value'
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
'x-expression': '$.source2.value'
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const result = await (0, evaluate_variables_1.evaluateVariables)({ jsonSchema, variables });
|
|
167
|
+
expect(result.variables.booleans).toEqual([true, false]);
|
|
168
|
+
});
|
|
169
|
+
it('should handle object values', async () => {
|
|
170
|
+
const variables = {
|
|
171
|
+
source1: {
|
|
172
|
+
data: {
|
|
173
|
+
name: 'Alice',
|
|
174
|
+
age: 30
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
source2: {
|
|
178
|
+
data: {
|
|
179
|
+
name: 'Bob',
|
|
180
|
+
age: 25
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
const jsonSchema = {
|
|
185
|
+
type: 'object',
|
|
186
|
+
properties: {
|
|
187
|
+
users: {
|
|
188
|
+
type: 'array',
|
|
189
|
+
prefixItems: [
|
|
190
|
+
{
|
|
191
|
+
'x-expression': '$.source1.data'
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
'x-expression': '$.source2.data'
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
const result = await (0, evaluate_variables_1.evaluateVariables)({ jsonSchema, variables });
|
|
201
|
+
expect(result.variables.users).toEqual([
|
|
202
|
+
{ name: 'Alice', age: 30 },
|
|
203
|
+
{ name: 'Bob', age: 25 }
|
|
204
|
+
]);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
describe('complex expressions', () => {
|
|
208
|
+
it('should handle complex jsonata expressions', async () => {
|
|
209
|
+
const variables = {
|
|
210
|
+
Account: {
|
|
211
|
+
'Account Name': 'TestAccount',
|
|
212
|
+
Order: [
|
|
213
|
+
{ OrderID: 'order1', total: 100 },
|
|
214
|
+
{ OrderID: 'order2', total: 200 }
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
const jsonSchema = {
|
|
219
|
+
type: 'object',
|
|
220
|
+
properties: {
|
|
221
|
+
results: {
|
|
222
|
+
type: 'array',
|
|
223
|
+
prefixItems: [
|
|
224
|
+
{
|
|
225
|
+
'x-expression': 'Account."Account Name"'
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
'x-expression': '$sum(Account.Order.total)'
|
|
229
|
+
}
|
|
230
|
+
]
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
const result = await (0, evaluate_variables_1.evaluateVariables)({ jsonSchema, variables });
|
|
235
|
+
expect(result.variables.results).toEqual(['TestAccount', 300]);
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
describe('mixed schema features', () => {
|
|
239
|
+
it('should work with nested objects', async () => {
|
|
240
|
+
const variables = {
|
|
241
|
+
source1: { value: 'first' },
|
|
242
|
+
source2: { value: 'second' }
|
|
243
|
+
};
|
|
244
|
+
const jsonSchema = {
|
|
245
|
+
type: 'object',
|
|
246
|
+
properties: {
|
|
247
|
+
nested: {
|
|
248
|
+
type: 'object',
|
|
249
|
+
properties: {
|
|
250
|
+
items: {
|
|
251
|
+
type: 'array',
|
|
252
|
+
prefixItems: [
|
|
253
|
+
{
|
|
254
|
+
'x-expression': '$.source1.value'
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
'x-expression': '$.source2.value'
|
|
258
|
+
}
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
const result = await (0, evaluate_variables_1.evaluateVariables)({ jsonSchema, variables });
|
|
266
|
+
expect(result.variables.nested.items).toEqual(['first', 'second']);
|
|
267
|
+
});
|
|
268
|
+
it('should work alongside regular properties', async () => {
|
|
269
|
+
const variables = {
|
|
270
|
+
source1: { value: 'a' },
|
|
271
|
+
source2: { value: 'b' },
|
|
272
|
+
source3: { value: 'c' }
|
|
273
|
+
};
|
|
274
|
+
const jsonSchema = {
|
|
275
|
+
type: 'object',
|
|
276
|
+
properties: {
|
|
277
|
+
singleValue: {
|
|
278
|
+
'x-expression': '$.source3.value'
|
|
279
|
+
},
|
|
280
|
+
arrayValue: {
|
|
281
|
+
type: 'array',
|
|
282
|
+
prefixItems: [
|
|
283
|
+
{
|
|
284
|
+
'x-expression': '$.source1.value'
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
'x-expression': '$.source2.value'
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
const result = await (0, evaluate_variables_1.evaluateVariables)({ jsonSchema, variables });
|
|
294
|
+
expect(result.variables.singleValue).toBe('c');
|
|
295
|
+
expect(result.variables.arrayValue).toEqual(['a', 'b']);
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
describe('user schema example', () => {
|
|
299
|
+
it('should handle the exact schema from user requirement', async () => {
|
|
300
|
+
const variables = {
|
|
301
|
+
'694bf14e2af2addf73c8c849': {
|
|
302
|
+
data: {
|
|
303
|
+
suite_access_token: 'token_from_first_source'
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
'694c81a0f12010773020eafb': {
|
|
307
|
+
suite_access_token: 'token_from_second_source'
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
const jsonSchema = {
|
|
311
|
+
type: 'object',
|
|
312
|
+
properties: {
|
|
313
|
+
input: {
|
|
314
|
+
type: 'object',
|
|
315
|
+
properties: {
|
|
316
|
+
value: {
|
|
317
|
+
title: '值',
|
|
318
|
+
description: '取首个有效值',
|
|
319
|
+
type: 'array',
|
|
320
|
+
prefixItems: [
|
|
321
|
+
{
|
|
322
|
+
'x-expression': '$.\"694bf14e2af2addf73c8c849\".\"data\".\"suite_access_token\"'
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
'x-expression': '$.\"694c81a0f12010773020eafb\".\"suite_access_token\"'
|
|
326
|
+
}
|
|
327
|
+
]
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
output: {
|
|
332
|
+
type: 'object',
|
|
333
|
+
properties: {
|
|
334
|
+
value: {
|
|
335
|
+
title: '值',
|
|
336
|
+
type: 'object'
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
'x-expression': '$',
|
|
340
|
+
'x-expression-const': '$'
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
const result = await (0, evaluate_variables_1.evaluateVariables)({ jsonSchema, variables });
|
|
345
|
+
expect(result.variables.input.value).toEqual(['token_from_first_source', 'token_from_second_source']);
|
|
346
|
+
expect(result.variables.output).toBeDefined();
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
describe('edge cases', () => {
|
|
350
|
+
it('should handle empty prefixItems array', async () => {
|
|
351
|
+
const variables = {};
|
|
352
|
+
const jsonSchema = {
|
|
353
|
+
type: 'object',
|
|
354
|
+
properties: {
|
|
355
|
+
items: {
|
|
356
|
+
type: 'array',
|
|
357
|
+
prefixItems: []
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
const result = await (0, evaluate_variables_1.evaluateVariables)({ jsonSchema, variables });
|
|
362
|
+
expect(result.variables.items).toEqual([]);
|
|
363
|
+
});
|
|
364
|
+
it('should handle multiple prefixItems with same expression', async () => {
|
|
365
|
+
const variables = {
|
|
366
|
+
source: { value: 'same_value' }
|
|
367
|
+
};
|
|
368
|
+
const jsonSchema = {
|
|
369
|
+
type: 'object',
|
|
370
|
+
properties: {
|
|
371
|
+
items: {
|
|
372
|
+
type: 'array',
|
|
373
|
+
prefixItems: [
|
|
374
|
+
{
|
|
375
|
+
'x-expression': '$.source.value'
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
'x-expression': '$.source.value'
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
'x-expression': '$.source.value'
|
|
382
|
+
}
|
|
383
|
+
]
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
const result = await (0, evaluate_variables_1.evaluateVariables)({ jsonSchema, variables });
|
|
388
|
+
expect(result.variables.items).toEqual(['same_value', 'same_value', 'same_value']);
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
});
|
|
@@ -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
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.portId.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/unit/resource.portId.test.ts"],"names":[],"mappings":""}
|