@ldsg/workflow 0.3.9 → 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.
Files changed (45) hide show
  1. package/dist/__tests__/unit/resource.js +62 -61
  2. package/dist/constants.d.ts +3 -3
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +11 -11
  5. package/dist/handler.d.ts +5 -7
  6. package/dist/handler.d.ts.map +1 -1
  7. package/dist/index.d.ts +5 -5
  8. package/dist/instantiate-resource.d.ts +4 -4
  9. package/dist/instantiate-resource.js +1 -1
  10. package/dist/resource.d.ts +2 -2
  11. package/dist/resource.d.ts.map +1 -1
  12. package/dist/resource.js +30 -30
  13. package/dist/types/index.d.ts +6 -6
  14. package/dist/types/json_schema_with_expression_extension.d.ts +8 -6
  15. package/dist/types/json_schema_with_expression_extension.d.ts.map +1 -1
  16. package/dist/types/node.d.ts +11 -11
  17. package/dist/types/node.d.ts.map +1 -1
  18. package/dist/types/specific-resource-settings.d.ts +1 -1
  19. package/dist/types/specific-resource-settings.d.ts.map +1 -1
  20. package/dist/types/workflow.d.ts +7 -3
  21. package/dist/types/workflow.d.ts.map +1 -1
  22. package/dist/utils/evaluate-variables/constants.d.ts.map +1 -1
  23. package/dist/utils/evaluate-variables/constants.js +17 -17
  24. package/dist/utils/evaluate-variables/index.d.ts +2 -2
  25. package/dist/utils/evaluate-variables/index.d.ts.map +1 -1
  26. package/dist/utils/evaluate-variables/index.debug.d.ts +2 -0
  27. package/dist/utils/evaluate-variables/index.debug.d.ts.map +1 -0
  28. package/dist/utils/evaluate-variables/index.debug.js +194 -0
  29. package/dist/utils/evaluate-variables/index.js +5 -5
  30. package/dist/utils/evaluate-variables/index.test.js +98 -98
  31. package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/index.d.ts +21 -0
  32. package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/index.d.ts.map +1 -0
  33. package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/index.js +17 -0
  34. 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
  35. package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/resolve-json-schema.d.ts.map +1 -0
  36. package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/resolve-json-schema.js +73 -0
  37. package/dist/utils/evaluate-variables/utils/get-field-path-by-field-type-key.d.ts.map +1 -1
  38. package/dist/utils/evaluate-variables/utils/get-field-path-by-field-type-key.js +3 -3
  39. package/dist/utils/get-execution-levels.d.ts +1 -1
  40. package/dist/utils/get-execution-levels.d.ts.map +1 -1
  41. package/dist/utils/get-execution-levels.js +5 -5
  42. package/dist/utils/get-execution-levels.test.js +86 -86
  43. package/package.json +22 -13
  44. package/dist/utils/evaluate-variables/utils/resolve-json-schema.d.ts.map +0 -1
  45. package/dist/utils/evaluate-variables/utils/resolve-json-schema.js +0 -112
@@ -1,112 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.resolveJsonSchema = void 0;
7
- const lodash_1 = __importDefault(require("lodash"));
8
- const constants_1 = require("../constants");
9
- const resolveJsonSchema = async (params) => {
10
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
11
- const { input, jsonSchema, returnExpressionAsData } = params;
12
- const { type } = jsonSchema;
13
- const res = {};
14
- switch (type) {
15
- case "object": {
16
- const properties = lodash_1.default.get(jsonSchema, "properties");
17
- const promises = lodash_1.default.keys(properties).map(async (propertyKey) => {
18
- const propertyValue = lodash_1.default.get(properties, propertyKey);
19
- if (!lodash_1.default.isObject(propertyValue)) {
20
- return;
21
- }
22
- const resolveJsonSchemaRes = await (0, exports.resolveJsonSchema)({
23
- jsonSchema: propertyValue,
24
- input,
25
- returnExpressionAsData,
26
- });
27
- lodash_1.default.set(res, `data.${propertyKey}`, resolveJsonSchemaRes.data);
28
- lodash_1.default.set(res, `const.${propertyKey}`, resolveJsonSchemaRes.const);
29
- lodash_1.default.set(res, `default.${propertyKey}`, resolveJsonSchemaRes.default);
30
- lodash_1.default.set(res, `expression.${propertyKey}`, resolveJsonSchemaRes.expression);
31
- });
32
- await Promise.all(promises);
33
- break;
34
- }
35
- case "array": {
36
- const itemsType = (_a = jsonSchema.items) === null || _a === void 0 ? void 0 : _a.type;
37
- let objectExpression;
38
- if (itemsType === "object") {
39
- const resolveJsonSchemaRes = await (0, exports.resolveJsonSchema)({
40
- jsonSchema: jsonSchema.items,
41
- input,
42
- returnExpressionAsData: true,
43
- });
44
- const expressionSubstrings = [];
45
- lodash_1.default.each(resolveJsonSchemaRes.expression, (value, key) => {
46
- if (value) {
47
- expressionSubstrings.push(`"${key}": ${value}`);
48
- }
49
- });
50
- objectExpression = `{${expressionSubstrings.join(",")}}`;
51
- }
52
- const promises = constants_1.FIELD_VALUE_RETRIEVAL_METHODS.map(async (fieldValueRetrievalMethod) => {
53
- const { name, handle } = fieldValueRetrievalMethod;
54
- /**
55
- * 字段的真实 path 是 key 去除类型
56
- */
57
- const value = lodash_1.default.get(jsonSchema, name);
58
- let res;
59
- if (!lodash_1.default.isNil(value)) {
60
- res = await handle({
61
- input,
62
- retrievalMethodValue: value,
63
- objectExpression,
64
- returnExpressionAsData,
65
- });
66
- }
67
- return res;
68
- });
69
- const fieldValues = await Promise.all(promises);
70
- res.const = (_b = fieldValues.find((value) => !lodash_1.default.isNil(value === null || value === void 0 ? void 0 : value.const))) === null || _b === void 0 ? void 0 : _b.const;
71
- res.data = (_c = fieldValues.find((value) => !lodash_1.default.isNil(value === null || value === void 0 ? void 0 : value.data))) === null || _c === void 0 ? void 0 : _c.data;
72
- res.default = (_d = fieldValues.find((value) => !lodash_1.default.isNil(value === null || value === void 0 ? void 0 : value.default))) === null || _d === void 0 ? void 0 : _d.default;
73
- res.expression = (_e = fieldValues.find((value) => !lodash_1.default.isNil(value === null || value === void 0 ? void 0 : value.expression))) === null || _e === void 0 ? void 0 : _e.expression;
74
- break;
75
- }
76
- case "boolean":
77
- case "integer":
78
- case "number":
79
- case "string": {
80
- const promises = constants_1.FIELD_VALUE_RETRIEVAL_METHODS.map(async (fieldValueRetrievalMethod) => {
81
- const { name, handle } = fieldValueRetrievalMethod;
82
- /**
83
- * 字段的真实 path 是 key 去除类型
84
- */
85
- const value = lodash_1.default.get(jsonSchema, name);
86
- let res;
87
- if (!lodash_1.default.isNil(value)) {
88
- res = await handle({
89
- input,
90
- retrievalMethodValue: value,
91
- returnExpressionAsData,
92
- });
93
- }
94
- return res;
95
- });
96
- const fieldValues = await Promise.all(promises);
97
- res.const = (_f = fieldValues.find((value) => !lodash_1.default.isNil(value === null || value === void 0 ? void 0 : value.const))) === null || _f === void 0 ? void 0 : _f.const;
98
- res.data = (_g = fieldValues.find((value) => !lodash_1.default.isNil(value === null || value === void 0 ? void 0 : value.data))) === null || _g === void 0 ? void 0 : _g.data;
99
- res.default = (_h = fieldValues.find((value) => !lodash_1.default.isNil(value === null || value === void 0 ? void 0 : value.default))) === null || _h === void 0 ? void 0 : _h.default;
100
- res.expression = (_j = fieldValues.find((value) => !lodash_1.default.isNil(value === null || value === void 0 ? void 0 : value.expression))) === null || _j === void 0 ? void 0 : _j.expression;
101
- break;
102
- }
103
- case "null": {
104
- break;
105
- }
106
- default: {
107
- throw new Error("invalid field type");
108
- }
109
- }
110
- return res;
111
- };
112
- exports.resolveJsonSchema = resolveJsonSchema;