@ldsg/workflow 0.3.35 → 0.3.36
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldsg/workflow",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.36",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"jsonata": "2.2.2",
|
|
21
21
|
"lodash": "^4.17.21",
|
|
22
22
|
"zod": "^4.1.11",
|
|
23
|
-
"@ldsg/constants": "0.3.
|
|
24
|
-
"@ldsg/handler": "0.3.
|
|
25
|
-
"@ldsg/resource": "0.3.
|
|
26
|
-
"@ldsg/resource-definition": "0.3.
|
|
23
|
+
"@ldsg/constants": "0.3.36",
|
|
24
|
+
"@ldsg/handler": "0.3.36",
|
|
25
|
+
"@ldsg/resource": "0.3.36",
|
|
26
|
+
"@ldsg/resource-definition": "0.3.36"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"ts-jest": "^29.1.5",
|
|
39
39
|
"ts-node": "^10.9.2",
|
|
40
40
|
"typescript": "^5.8.3",
|
|
41
|
-
"@ldsg/types": "0.3.
|
|
41
|
+
"@ldsg/types": "0.3.36"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsc --project tsconfig.build.json",
|
|
@@ -1,96 +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 jsonata_1 = __importDefault(require("jsonata"));
|
|
8
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
-
const resolveJsonSchema = async (params) => {
|
|
10
|
-
var _a;
|
|
11
|
-
const { input, jsonSchema, source } = params;
|
|
12
|
-
const { type: jsonSchemaType, 'x-expression': jsonSchemaExpression, const: jsonSchemaConst, prefixItems: jsonSchemaPrefixItems } = jsonSchema;
|
|
13
|
-
let data;
|
|
14
|
-
/**
|
|
15
|
-
* 若常量值存在,则直接返回
|
|
16
|
-
*/
|
|
17
|
-
if (jsonSchemaConst) {
|
|
18
|
-
data = jsonSchemaConst;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
data = source;
|
|
22
|
-
/**
|
|
23
|
-
* 若表达式存在,则尝试获取表达式值
|
|
24
|
-
*/
|
|
25
|
-
if (jsonSchemaExpression) {
|
|
26
|
-
const expression = (0, jsonata_1.default)(jsonSchemaExpression);
|
|
27
|
-
data = await expression.evaluate(input);
|
|
28
|
-
}
|
|
29
|
-
switch (jsonSchemaType) {
|
|
30
|
-
case 'object': {
|
|
31
|
-
data = data !== null && data !== void 0 ? data : {};
|
|
32
|
-
const jsonSchemaProperties = (_a = jsonSchema.properties) !== null && _a !== void 0 ? _a : {};
|
|
33
|
-
const keys = lodash_1.default.keys(jsonSchemaProperties);
|
|
34
|
-
const keysMapResPromises = keys.map(async (key) => {
|
|
35
|
-
const source = lodash_1.default.get(data, key);
|
|
36
|
-
const resolveJsonSchemaRes = await (0, exports.resolveJsonSchema)({
|
|
37
|
-
jsonSchema: jsonSchemaProperties[key],
|
|
38
|
-
input,
|
|
39
|
-
source
|
|
40
|
-
});
|
|
41
|
-
const res = {
|
|
42
|
-
key,
|
|
43
|
-
resolveJsonSchemaRes
|
|
44
|
-
};
|
|
45
|
-
return res;
|
|
46
|
-
});
|
|
47
|
-
const keysMapRes = await Promise.all(keysMapResPromises);
|
|
48
|
-
lodash_1.default.each(keysMapRes, ({ key, resolveJsonSchemaRes }) => {
|
|
49
|
-
lodash_1.default.set(data, key, resolveJsonSchemaRes.data);
|
|
50
|
-
});
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
case 'array': {
|
|
54
|
-
/**
|
|
55
|
-
* 如果 prefixItems 存在,则转为数组结果
|
|
56
|
-
*/
|
|
57
|
-
if (jsonSchemaPrefixItems) {
|
|
58
|
-
if (jsonSchemaPrefixItems.length > 0) {
|
|
59
|
-
const itemsDataPromises = jsonSchemaPrefixItems.map(async (prefixItem) => {
|
|
60
|
-
const resolveJsonSchemaRes = await (0, exports.resolveJsonSchema)({
|
|
61
|
-
jsonSchema: prefixItem,
|
|
62
|
-
input,
|
|
63
|
-
source
|
|
64
|
-
});
|
|
65
|
-
return resolveJsonSchemaRes.data;
|
|
66
|
-
});
|
|
67
|
-
const itemsData = await Promise.all(itemsDataPromises);
|
|
68
|
-
data = itemsData;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
/**
|
|
72
|
-
* 空数组时,初始化为空数组
|
|
73
|
-
*/
|
|
74
|
-
data = [];
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
case 'boolean':
|
|
80
|
-
case 'integer':
|
|
81
|
-
case 'number':
|
|
82
|
-
case 'string': {
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
case 'null': {
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
default: {
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const res = { data };
|
|
94
|
-
return res;
|
|
95
|
-
};
|
|
96
|
-
exports.resolveJsonSchema = resolveJsonSchema;
|