@wenlarge/communication 1.2.2 → 1.2.4
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/generated/executor-core.d.ts +3 -0
- package/dist/generated/workflow.d.ts +8 -0
- package/dist/helpers/resolve-config-value.d.ts +1 -0
- package/dist/helpers/resolve-config-value.js +79 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -1
- package/proto/executor-core.proto +1 -0
- package/proto/workflow.proto +4 -0
- package/src/generated/executor-core.ts +1 -0
- package/src/generated/workflow.ts +4 -0
|
@@ -41,10 +41,18 @@ export interface FindFirstWorkflowRequest {
|
|
|
41
41
|
}
|
|
42
42
|
export interface TriggerWorkflowRequest {
|
|
43
43
|
workflowId: string;
|
|
44
|
+
environmentId?: string | undefined;
|
|
44
45
|
}
|
|
45
46
|
export interface TriggerNodeRequest {
|
|
46
47
|
nodeId: string;
|
|
47
48
|
workflowId: string;
|
|
49
|
+
inputSchema?: {
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
} | undefined;
|
|
52
|
+
environmentId?: string | undefined;
|
|
53
|
+
env?: {
|
|
54
|
+
[key: string]: any;
|
|
55
|
+
} | undefined;
|
|
48
56
|
}
|
|
49
57
|
export interface WorkflowNodeRequest {
|
|
50
58
|
id: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveConfigValue(value: unknown, input?: Record<string, any> | null, env?: Record<string, any> | null): unknown;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveConfigValue = resolveConfigValue;
|
|
4
|
+
const expr_eval_1 = require("expr-eval");
|
|
5
|
+
const FORBIDDEN_KEYS = new Set(["__proto__", "prototype", "constructor"]);
|
|
6
|
+
function sanitize(value) {
|
|
7
|
+
if (value == null)
|
|
8
|
+
return value;
|
|
9
|
+
if (typeof value === "function")
|
|
10
|
+
return undefined;
|
|
11
|
+
if (Array.isArray(value))
|
|
12
|
+
return value.map(sanitize);
|
|
13
|
+
if (typeof value === "object") {
|
|
14
|
+
const clean = Object.create(null);
|
|
15
|
+
for (const key of Object.keys(value)) {
|
|
16
|
+
if (FORBIDDEN_KEYS.has(key))
|
|
17
|
+
continue;
|
|
18
|
+
clean[key] = sanitize(value[key]);
|
|
19
|
+
}
|
|
20
|
+
return clean;
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
function resolveConfigValue(value, input, env) {
|
|
25
|
+
var _a;
|
|
26
|
+
if (typeof value !== "string")
|
|
27
|
+
return value;
|
|
28
|
+
const parser = new expr_eval_1.Parser();
|
|
29
|
+
parser.consts = {};
|
|
30
|
+
parser.functions = {};
|
|
31
|
+
const evaluateExpr = (exprRaw) => {
|
|
32
|
+
var _a;
|
|
33
|
+
const expr = exprRaw.trim();
|
|
34
|
+
if (!expr)
|
|
35
|
+
return undefined;
|
|
36
|
+
if (/[a-zA-Z_$][\w$]*\s*\(/.test(expr))
|
|
37
|
+
return undefined;
|
|
38
|
+
try {
|
|
39
|
+
const context = {
|
|
40
|
+
input: sanitize(input !== null && input !== void 0 ? input : null),
|
|
41
|
+
env: sanitize((_a = env !== null && env !== void 0 ? env : input === null || input === void 0 ? void 0 : input.env) !== null && _a !== void 0 ? _a : null),
|
|
42
|
+
};
|
|
43
|
+
const result = parser.parse(expr).evaluate(context);
|
|
44
|
+
return typeof result === "function" ? undefined : result;
|
|
45
|
+
}
|
|
46
|
+
catch (_b) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const stringifyInline = (resolved, fallback) => {
|
|
51
|
+
if (resolved === undefined)
|
|
52
|
+
return fallback;
|
|
53
|
+
if (resolved == null)
|
|
54
|
+
return "";
|
|
55
|
+
if (typeof resolved === "string")
|
|
56
|
+
return resolved;
|
|
57
|
+
if (typeof resolved === "number" || typeof resolved === "boolean") {
|
|
58
|
+
return String(resolved);
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
return JSON.stringify(resolved);
|
|
62
|
+
}
|
|
63
|
+
catch (_a) {
|
|
64
|
+
return String(resolved);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const exact = value.match(/^\{\{\s*(.*?)\s*\}\}$/);
|
|
68
|
+
if (exact) {
|
|
69
|
+
const resolved = evaluateExpr((_a = exact[1]) !== null && _a !== void 0 ? _a : "");
|
|
70
|
+
return resolved === undefined ? value : resolved;
|
|
71
|
+
}
|
|
72
|
+
if (value.includes("{{")) {
|
|
73
|
+
return value.replace(/\{\{\s*(.*?)\s*\}\}/g, (m, exprRaw) => {
|
|
74
|
+
const resolved = evaluateExpr(exprRaw);
|
|
75
|
+
return stringifyInline(resolved, m);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return value;
|
|
79
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.ListValue = exports.Value = exports.Struct = exports.Notification = exports.ExecutorCore = exports.Metadata = exports.Project = exports.Workflow = exports.Auth = void 0;
|
|
40
40
|
__exportStar(require("./helpers/helper"), exports);
|
|
41
|
+
__exportStar(require("./helpers/resolve-config-value"), exports);
|
|
41
42
|
exports.Auth = __importStar(require("./generated/auth"));
|
|
42
43
|
__exportStar(require("./config/auth-config"), exports);
|
|
43
44
|
exports.Workflow = __importStar(require("./generated/workflow"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wenlarge/communication",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "Shared gRPC proto interfaces and generated clients for Wenlarge microservices.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@grpc/grpc-js": "^1.14.1",
|
|
37
37
|
"@grpc/proto-loader": "^0.7.15",
|
|
38
|
+
"expr-eval": "^2.0.2",
|
|
38
39
|
"rxjs": "^7.8.1"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
package/proto/workflow.proto
CHANGED
|
@@ -63,11 +63,15 @@ message FindFirstWorkflowRequest {
|
|
|
63
63
|
|
|
64
64
|
message TriggerWorkflowRequest{
|
|
65
65
|
string workflowId = 1;
|
|
66
|
+
optional string environmentId = 2;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
message TriggerNodeRequest{
|
|
69
70
|
string nodeId = 1;
|
|
70
71
|
string workflowId = 2;
|
|
72
|
+
google.protobuf.Struct inputSchema = 3;
|
|
73
|
+
optional string environmentId = 4;
|
|
74
|
+
google.protobuf.Struct env = 5;
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
message WorkflowNodeRequest{
|
|
@@ -61,11 +61,15 @@ export interface FindFirstWorkflowRequest {
|
|
|
61
61
|
|
|
62
62
|
export interface TriggerWorkflowRequest {
|
|
63
63
|
workflowId: string;
|
|
64
|
+
environmentId?: string | undefined;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
export interface TriggerNodeRequest {
|
|
67
68
|
nodeId: string;
|
|
68
69
|
workflowId: string;
|
|
70
|
+
inputSchema?: { [key: string]: any } | undefined;
|
|
71
|
+
environmentId?: string | undefined;
|
|
72
|
+
env?: { [key: string]: any } | undefined;
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
export interface WorkflowNodeRequest {
|