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