@abyss-project/console 1.0.40 → 1.0.42
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/index.d.ts +0 -1
- package/dist/index.js +1 -2
- package/dist/types/constants/index.d.ts +1 -0
- package/dist/types/constants/index.js +1 -0
- package/dist/types/constants/workflow.constants.d.ts +9 -0
- package/dist/types/constants/workflow.constants.js +12 -0
- package/dist/types/interface/models/workflow-trigger.model.d.ts +1 -4
- package/dist/types/interface/models/workflow-webhook.model.d.ts +1 -0
- package/dist/utils/webhook-trigger.utils.d.ts +1 -6
- package/dist/utils/webhook-trigger.utils.js +33 -318
- package/dist/workflow-expressions/index.d.ts +5 -17
- package/dist/workflow-expressions/index.js +9 -58
- package/dist/workflow-expressions/resolver.d.ts +2 -6
- package/dist/workflow-expressions/resolver.js +31 -220
- package/dist/workflow-expressions/types.d.ts +21 -118
- package/dist/workflow-expressions/types.js +2 -20
- package/package.json +1 -1
- package/dist/expressions/functions/array.d.ts +0 -2
- package/dist/expressions/functions/array.js +0 -252
- package/dist/expressions/functions/crypto.d.ts +0 -2
- package/dist/expressions/functions/crypto.js +0 -101
- package/dist/expressions/functions/datetime.d.ts +0 -2
- package/dist/expressions/functions/datetime.js +0 -256
- package/dist/expressions/functions/index.d.ts +0 -7
- package/dist/expressions/functions/index.js +0 -46
- package/dist/expressions/functions/math.d.ts +0 -2
- package/dist/expressions/functions/math.js +0 -174
- package/dist/expressions/functions/string.d.ts +0 -2
- package/dist/expressions/functions/string.js +0 -301
- package/dist/expressions/functions/utility.d.ts +0 -2
- package/dist/expressions/functions/utility.js +0 -230
- package/dist/expressions/helpers.d.ts +0 -26
- package/dist/expressions/helpers.js +0 -132
- package/dist/expressions/index.d.ts +0 -5
- package/dist/expressions/index.js +0 -16
- package/dist/expressions/mapper.d.ts +0 -9
- package/dist/expressions/mapper.js +0 -88
- package/dist/expressions/parser.d.ts +0 -3
- package/dist/expressions/parser.js +0 -97
- package/dist/expressions/pipes/array-pipes.d.ts +0 -2
- package/dist/expressions/pipes/array-pipes.js +0 -248
- package/dist/expressions/pipes/index.d.ts +0 -8
- package/dist/expressions/pipes/index.js +0 -40
- package/dist/expressions/pipes/object-pipes.d.ts +0 -2
- package/dist/expressions/pipes/object-pipes.js +0 -243
- package/dist/expressions/pipes/string-pipes.d.ts +0 -9
- package/dist/expressions/pipes/string-pipes.js +0 -178
- package/dist/expressions/resolver.d.ts +0 -12
- package/dist/expressions/resolver.js +0 -88
- package/dist/expressions/types.d.ts +0 -36
- package/dist/expressions/types.js +0 -2
- package/dist/workflow-expressions/functions/array.d.ts +0 -2
- package/dist/workflow-expressions/functions/array.js +0 -252
- package/dist/workflow-expressions/functions/crypto.d.ts +0 -2
- package/dist/workflow-expressions/functions/crypto.js +0 -101
- package/dist/workflow-expressions/functions/datetime.d.ts +0 -2
- package/dist/workflow-expressions/functions/datetime.js +0 -256
- package/dist/workflow-expressions/functions/index.d.ts +0 -7
- package/dist/workflow-expressions/functions/index.js +0 -46
- package/dist/workflow-expressions/functions/math.d.ts +0 -2
- package/dist/workflow-expressions/functions/math.js +0 -174
- package/dist/workflow-expressions/functions/string.d.ts +0 -2
- package/dist/workflow-expressions/functions/string.js +0 -301
- package/dist/workflow-expressions/functions/utility.d.ts +0 -2
- package/dist/workflow-expressions/functions/utility.js +0 -230
- package/dist/workflow-expressions/helpers.d.ts +0 -71
- package/dist/workflow-expressions/helpers.js +0 -262
- package/dist/workflow-expressions/parser.d.ts +0 -8
- package/dist/workflow-expressions/parser.js +0 -456
- package/dist/workflow-expressions/pipes/array-pipes.d.ts +0 -2
- package/dist/workflow-expressions/pipes/array-pipes.js +0 -248
- package/dist/workflow-expressions/pipes/index.d.ts +0 -8
- package/dist/workflow-expressions/pipes/index.js +0 -40
- package/dist/workflow-expressions/pipes/object-pipes.d.ts +0 -2
- package/dist/workflow-expressions/pipes/object-pipes.js +0 -243
- package/dist/workflow-expressions/pipes/string-pipes.d.ts +0 -9
- package/dist/workflow-expressions/pipes/string-pipes.js +0 -178
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ import * as secretPublicApi from './api/secret-public.api';
|
|
|
13
13
|
export * from './utils/cidr.util';
|
|
14
14
|
export * from './types';
|
|
15
15
|
export * from './utils';
|
|
16
|
-
export * as GenericExpression from './expressions';
|
|
17
16
|
export * as WorkflowExpression from './workflow-expressions';
|
|
18
17
|
export declare const API_KEY_APPLICATION_HEADER = "abyss-console-api-key-application";
|
|
19
18
|
export declare const ADMIN_TOKEN_HEADER = "abyss-admin-token";
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.AbyssConsoleCore = exports.WEBHOOK_SIGNATURE_ALGORITHM = exports.HEADER_WEBHOOK_SIGNATURE_NAME = exports.ADMIN_TOKEN_HEADER = exports.API_KEY_APPLICATION_HEADER = exports.WorkflowExpression =
|
|
32
|
+
exports.AbyssConsoleCore = exports.WEBHOOK_SIGNATURE_ALGORITHM = exports.HEADER_WEBHOOK_SIGNATURE_NAME = exports.ADMIN_TOKEN_HEADER = exports.API_KEY_APPLICATION_HEADER = exports.WorkflowExpression = void 0;
|
|
33
33
|
const axios_1 = __importDefault(require("axios"));
|
|
34
34
|
const axios_retry_1 = __importStar(require("axios-retry"));
|
|
35
35
|
const domainVerificationApi = __importStar(require("./api/domain-verification.api"));
|
|
@@ -46,7 +46,6 @@ const secretPublicApi = __importStar(require("./api/secret-public.api"));
|
|
|
46
46
|
__exportStar(require("./utils/cidr.util"), exports);
|
|
47
47
|
__exportStar(require("./types"), exports);
|
|
48
48
|
__exportStar(require("./utils"), exports);
|
|
49
|
-
exports.GenericExpression = __importStar(require("./expressions"));
|
|
50
49
|
exports.WorkflowExpression = __importStar(require("./workflow-expressions"));
|
|
51
50
|
const MONITOR_DEFAULT_BASE_URL = 'https://console-api.abyss-project.fr/api/';
|
|
52
51
|
exports.API_KEY_APPLICATION_HEADER = 'abyss-console-api-key-application';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const WORKFLOW_EXECUTION_TIMEOUT: number;
|
|
2
|
+
export declare const WORKFLOW_STEP_TIMEOUT: number;
|
|
3
|
+
export declare const SLEEP_DURATION_MIN = 0;
|
|
4
|
+
export declare const SLEEP_DURATION_MAX = 900;
|
|
5
|
+
export declare const SLEEP_DURATION_DEFAULT = 1;
|
|
6
|
+
export declare const EXPRESSION_TIMEOUT_DEFAULT = 5000;
|
|
7
|
+
export declare const EXPRESSION_TIMEOUT_MAX = 30000;
|
|
8
|
+
export declare const EXPRESSION_CPU_TIMEOUT = 10000;
|
|
9
|
+
export declare const EXPRESSION_MEMORY_LIMIT = 128;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EXPRESSION_MEMORY_LIMIT = exports.EXPRESSION_CPU_TIMEOUT = exports.EXPRESSION_TIMEOUT_MAX = exports.EXPRESSION_TIMEOUT_DEFAULT = exports.SLEEP_DURATION_DEFAULT = exports.SLEEP_DURATION_MAX = exports.SLEEP_DURATION_MIN = exports.WORKFLOW_STEP_TIMEOUT = exports.WORKFLOW_EXECUTION_TIMEOUT = void 0;
|
|
4
|
+
exports.WORKFLOW_EXECUTION_TIMEOUT = 60 * 60 * 1000;
|
|
5
|
+
exports.WORKFLOW_STEP_TIMEOUT = 15 * 60 * 1000;
|
|
6
|
+
exports.SLEEP_DURATION_MIN = 0;
|
|
7
|
+
exports.SLEEP_DURATION_MAX = 900;
|
|
8
|
+
exports.SLEEP_DURATION_DEFAULT = 1;
|
|
9
|
+
exports.EXPRESSION_TIMEOUT_DEFAULT = 5000;
|
|
10
|
+
exports.EXPRESSION_TIMEOUT_MAX = 30000;
|
|
11
|
+
exports.EXPRESSION_CPU_TIMEOUT = 10000;
|
|
12
|
+
exports.EXPRESSION_MEMORY_LIMIT = 128;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { WorkflowTriggerType
|
|
1
|
+
import { WorkflowTriggerType } from '../../enum/workflow.enum';
|
|
2
2
|
import { IWorkflow } from './workflow.model';
|
|
3
3
|
export interface ITriggerFilter {
|
|
4
4
|
expression?: string;
|
|
5
|
-
field?: string;
|
|
6
|
-
operator?: FilterOperator;
|
|
7
|
-
value?: any;
|
|
8
5
|
}
|
|
9
6
|
export interface ITriggerExecutionStats {
|
|
10
7
|
total: number;
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import { WorkflowTriggerData,
|
|
2
|
-
type ExpressionValue = string | number | boolean | null | undefined | unknown[] | Record<string, unknown>;
|
|
1
|
+
import { WorkflowTriggerData, IWorkflowTrigger } from '../types';
|
|
3
2
|
export declare const matchesTriggerFilters: (trigger: IWorkflowTrigger, triggerData: WorkflowTriggerData) => boolean;
|
|
4
|
-
export declare const evaluateExpression: (expression: string, context: Record<string, unknown>) => ExpressionValue;
|
|
5
|
-
export declare const getNestedValue: (obj: Record<string, unknown>, path: string) => unknown;
|
|
6
|
-
export declare const evaluateFilter: (value: unknown, operator: FilterOperator, expected: unknown) => boolean;
|
|
7
|
-
export {};
|
|
@@ -1,25 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const types_1 = require("../types");
|
|
5
|
-
const OPERATOR_PRECEDENCE = {
|
|
6
|
-
'||': 1,
|
|
7
|
-
'&&': 2,
|
|
8
|
-
'==': 3,
|
|
9
|
-
'===': 3,
|
|
10
|
-
'!=': 3,
|
|
11
|
-
'!==': 3,
|
|
12
|
-
'<': 4,
|
|
13
|
-
'<=': 4,
|
|
14
|
-
'>': 4,
|
|
15
|
-
'>=': 4,
|
|
16
|
-
'+': 5,
|
|
17
|
-
'-': 5,
|
|
18
|
-
'*': 6,
|
|
19
|
-
'/': 6,
|
|
20
|
-
'%': 6,
|
|
21
|
-
'**': 7,
|
|
22
|
-
};
|
|
3
|
+
exports.matchesTriggerFilters = void 0;
|
|
23
4
|
const matchesTriggerFilters = (trigger, triggerData) => {
|
|
24
5
|
if (!trigger.filters || trigger.filters.length === 0) {
|
|
25
6
|
return true;
|
|
@@ -28,7 +9,7 @@ const matchesTriggerFilters = (trigger, triggerData) => {
|
|
|
28
9
|
if (filter.expression) {
|
|
29
10
|
try {
|
|
30
11
|
const context = { trigger: triggerData };
|
|
31
|
-
const result = (
|
|
12
|
+
const result = evaluateSimpleExpression(filter.expression, context);
|
|
32
13
|
return Boolean(result);
|
|
33
14
|
}
|
|
34
15
|
catch (error) {
|
|
@@ -36,304 +17,38 @@ const matchesTriggerFilters = (trigger, triggerData) => {
|
|
|
36
17
|
return false;
|
|
37
18
|
}
|
|
38
19
|
}
|
|
39
|
-
if (filter.field && filter.operator) {
|
|
40
|
-
const value = (0, exports.getNestedValue)(triggerData, filter.field);
|
|
41
|
-
return (0, exports.evaluateFilter)(value, filter.operator, filter.value);
|
|
42
|
-
}
|
|
43
20
|
return true;
|
|
44
21
|
});
|
|
45
22
|
};
|
|
46
23
|
exports.matchesTriggerFilters = matchesTriggerFilters;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
value = applyPipeOperator(value, pipe);
|
|
79
|
-
}
|
|
80
|
-
tokens.push({ type: 'reference', value: value });
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
const value = (0, exports.getNestedValue)(context, path);
|
|
84
|
-
tokens.push({ type: 'reference', value: value });
|
|
85
|
-
}
|
|
86
|
-
pos = endIdx + 2;
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
if (char === '"' || char === "'") {
|
|
90
|
-
const quote = char;
|
|
91
|
-
let str = '';
|
|
92
|
-
pos++;
|
|
93
|
-
while (pos < len && expression[pos] !== quote) {
|
|
94
|
-
if (expression[pos] === '\\' && pos + 1 < len) {
|
|
95
|
-
pos++;
|
|
96
|
-
str += expression[pos];
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
str += expression[pos];
|
|
100
|
-
}
|
|
101
|
-
pos++;
|
|
102
|
-
}
|
|
103
|
-
pos++;
|
|
104
|
-
tokens.push({ type: 'literal', value: str });
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
if (/[\d.]/.test(char)) {
|
|
108
|
-
let numStr = '';
|
|
109
|
-
while (pos < len && /[\d.eE+-]/.test(expression[pos])) {
|
|
110
|
-
numStr += expression[pos];
|
|
111
|
-
pos++;
|
|
112
|
-
}
|
|
113
|
-
tokens.push({ type: 'literal', value: parseFloat(numStr) });
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
const restExpr = expression.slice(pos);
|
|
117
|
-
if (restExpr.startsWith('true') && !/\w/.test(restExpr[4] || '')) {
|
|
118
|
-
tokens.push({ type: 'literal', value: true });
|
|
119
|
-
pos += 4;
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
if (restExpr.startsWith('false') && !/\w/.test(restExpr[5] || '')) {
|
|
123
|
-
tokens.push({ type: 'literal', value: false });
|
|
124
|
-
pos += 5;
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
if (restExpr.startsWith('null') && !/\w/.test(restExpr[4] || '')) {
|
|
128
|
-
tokens.push({ type: 'literal', value: null });
|
|
129
|
-
pos += 4;
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
const twoChar = expression.slice(pos, pos + 2);
|
|
133
|
-
const threeChar = expression.slice(pos, pos + 3);
|
|
134
|
-
if (['===', '!=='].includes(threeChar)) {
|
|
135
|
-
tokens.push({ type: 'operator', value: threeChar });
|
|
136
|
-
pos += 3;
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
if (['==', '!=', '<=', '>=', '&&', '||', '**'].includes(twoChar)) {
|
|
140
|
-
tokens.push({ type: 'operator', value: twoChar });
|
|
141
|
-
pos += 2;
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
if (['+', '-', '*', '/', '%', '<', '>', '!'].includes(char)) {
|
|
145
|
-
tokens.push({ type: 'operator', value: char });
|
|
146
|
-
pos++;
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
if (char === '(' || char === ')') {
|
|
150
|
-
tokens.push({ type: 'paren', value: char });
|
|
151
|
-
pos++;
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
if (char === '?' || char === ':') {
|
|
155
|
-
tokens.push({ type: 'operator', value: char });
|
|
156
|
-
pos++;
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
pos++;
|
|
160
|
-
}
|
|
161
|
-
return tokens;
|
|
162
|
-
};
|
|
163
|
-
const applyPipeOperator = (value, pipe) => {
|
|
164
|
-
const pipeMatch = pipe.match(/^(\w+)(?:\(([^)]*)\))?$/);
|
|
165
|
-
if (!pipeMatch)
|
|
166
|
-
return value;
|
|
167
|
-
const [, operator, args] = pipeMatch;
|
|
168
|
-
const strValue = String(value !== null && value !== void 0 ? value : '');
|
|
169
|
-
switch (operator) {
|
|
170
|
-
case 'contains':
|
|
171
|
-
return strValue.includes(args || '');
|
|
172
|
-
case 'startsWith':
|
|
173
|
-
return strValue.startsWith(args || '');
|
|
174
|
-
case 'endsWith':
|
|
175
|
-
return strValue.endsWith(args || '');
|
|
176
|
-
case 'isEmpty':
|
|
177
|
-
return (value === null ||
|
|
178
|
-
value === undefined ||
|
|
179
|
-
value === '' ||
|
|
180
|
-
(Array.isArray(value) && value.length === 0));
|
|
181
|
-
case 'isNotEmpty':
|
|
182
|
-
return (value !== null &&
|
|
183
|
-
value !== undefined &&
|
|
184
|
-
value !== '' &&
|
|
185
|
-
(!Array.isArray(value) || value.length > 0));
|
|
186
|
-
case 'length':
|
|
187
|
-
return Array.isArray(value) ? value.length : strValue.length;
|
|
188
|
-
case 'lower':
|
|
189
|
-
case 'toLowerCase':
|
|
190
|
-
return strValue.toLowerCase();
|
|
191
|
-
case 'upper':
|
|
192
|
-
case 'toUpperCase':
|
|
193
|
-
return strValue.toUpperCase();
|
|
194
|
-
case 'trim':
|
|
195
|
-
return strValue.trim();
|
|
196
|
-
default:
|
|
197
|
-
return value;
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
const evaluateTokens = (tokens) => {
|
|
201
|
-
var _a, _b;
|
|
202
|
-
if (tokens.length === 0)
|
|
203
|
-
return null;
|
|
204
|
-
if (tokens.length === 1) {
|
|
205
|
-
return tokens[0].value;
|
|
206
|
-
}
|
|
207
|
-
const questionIdx = tokens.findIndex((t) => t.type === 'operator' && t.value === '?');
|
|
208
|
-
if (questionIdx !== -1) {
|
|
209
|
-
const colonIdx = tokens.findIndex((t, i) => i > questionIdx && t.type === 'operator' && t.value === ':');
|
|
210
|
-
if (colonIdx !== -1) {
|
|
211
|
-
const condition = evaluateTokens(tokens.slice(0, questionIdx));
|
|
212
|
-
const trueValue = evaluateTokens(tokens.slice(questionIdx + 1, colonIdx));
|
|
213
|
-
const falseValue = evaluateTokens(tokens.slice(colonIdx + 1));
|
|
214
|
-
return condition ? trueValue : falseValue;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
let lowestPrecedence = Infinity;
|
|
218
|
-
let opIndex = -1;
|
|
219
|
-
let parenDepth = 0;
|
|
220
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
221
|
-
const token = tokens[i];
|
|
222
|
-
if (token.type === 'paren') {
|
|
223
|
-
parenDepth += token.value === '(' ? 1 : -1;
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
if (parenDepth > 0)
|
|
227
|
-
continue;
|
|
228
|
-
if (token.type === 'operator' && typeof token.value === 'string') {
|
|
229
|
-
const precedence = OPERATOR_PRECEDENCE[token.value];
|
|
230
|
-
if (precedence !== undefined && precedence <= lowestPrecedence) {
|
|
231
|
-
lowestPrecedence = precedence;
|
|
232
|
-
opIndex = i;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
if (opIndex !== -1) {
|
|
237
|
-
const op = tokens[opIndex].value;
|
|
238
|
-
const left = evaluateTokens(tokens.slice(0, opIndex));
|
|
239
|
-
const right = evaluateTokens(tokens.slice(opIndex + 1));
|
|
240
|
-
return applyOperator(op, left, right);
|
|
241
|
-
}
|
|
242
|
-
if (((_a = tokens[0]) === null || _a === void 0 ? void 0 : _a.type) === 'paren' && tokens[0].value === '(') {
|
|
243
|
-
let depth = 1;
|
|
244
|
-
let endIdx = 1;
|
|
245
|
-
while (endIdx < tokens.length && depth > 0) {
|
|
246
|
-
if (tokens[endIdx].type === 'paren') {
|
|
247
|
-
depth += tokens[endIdx].value === '(' ? 1 : -1;
|
|
248
|
-
}
|
|
249
|
-
endIdx++;
|
|
250
|
-
}
|
|
251
|
-
return evaluateTokens(tokens.slice(1, endIdx - 1));
|
|
252
|
-
}
|
|
253
|
-
if (((_b = tokens[0]) === null || _b === void 0 ? void 0 : _b.type) === 'operator' && tokens[0].value === '!') {
|
|
254
|
-
const operand = evaluateTokens(tokens.slice(1));
|
|
255
|
-
return !operand;
|
|
256
|
-
}
|
|
257
|
-
return tokens[0].value;
|
|
258
|
-
};
|
|
259
|
-
const applyOperator = (op, left, right) => {
|
|
260
|
-
switch (op) {
|
|
261
|
-
case '+':
|
|
262
|
-
if (typeof left === 'string' || typeof right === 'string') {
|
|
263
|
-
return String(left !== null && left !== void 0 ? left : '') + String(right !== null && right !== void 0 ? right : '');
|
|
264
|
-
}
|
|
265
|
-
return (Number(left) || 0) + (Number(right) || 0);
|
|
266
|
-
case '-':
|
|
267
|
-
return (Number(left) || 0) - (Number(right) || 0);
|
|
268
|
-
case '*':
|
|
269
|
-
return (Number(left) || 0) * (Number(right) || 0);
|
|
270
|
-
case '/':
|
|
271
|
-
return (Number(left) || 0) / (Number(right) || 1);
|
|
272
|
-
case '%':
|
|
273
|
-
return (Number(left) || 0) % (Number(right) || 1);
|
|
274
|
-
case '**':
|
|
275
|
-
return Math.pow(Number(left) || 0, Number(right) || 0);
|
|
276
|
-
case '==':
|
|
277
|
-
return left == right;
|
|
278
|
-
case '===':
|
|
279
|
-
return left === right;
|
|
280
|
-
case '!=':
|
|
281
|
-
return left != right;
|
|
282
|
-
case '!==':
|
|
283
|
-
return left !== right;
|
|
284
|
-
case '<':
|
|
285
|
-
return (Number(left) || 0) < (Number(right) || 0);
|
|
286
|
-
case '<=':
|
|
287
|
-
return (Number(left) || 0) <= (Number(right) || 0);
|
|
288
|
-
case '>':
|
|
289
|
-
return (Number(left) || 0) > (Number(right) || 0);
|
|
290
|
-
case '>=':
|
|
291
|
-
return (Number(left) || 0) >= (Number(right) || 0);
|
|
292
|
-
case '&&':
|
|
293
|
-
return Boolean(left) && Boolean(right);
|
|
294
|
-
case '||':
|
|
295
|
-
return Boolean(left) || Boolean(right);
|
|
296
|
-
default:
|
|
297
|
-
return null;
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
const getNestedValue = (obj, path) => {
|
|
301
|
-
return path
|
|
302
|
-
.split('.')
|
|
303
|
-
.reduce((current, key) => current === null || current === void 0 ? void 0 : current[key], obj);
|
|
304
|
-
};
|
|
305
|
-
exports.getNestedValue = getNestedValue;
|
|
306
|
-
const evaluateFilter = (value, operator, expected) => {
|
|
307
|
-
switch (operator) {
|
|
308
|
-
case types_1.FilterOperator.EQUALS:
|
|
309
|
-
return value === expected;
|
|
310
|
-
case types_1.FilterOperator.NOT_EQUALS:
|
|
311
|
-
return value !== expected;
|
|
312
|
-
case types_1.FilterOperator.CONTAINS:
|
|
313
|
-
return String(value).includes(String(expected));
|
|
314
|
-
case types_1.FilterOperator.NOT_CONTAINS:
|
|
315
|
-
return !String(value).includes(String(expected));
|
|
316
|
-
case types_1.FilterOperator.STARTS_WITH:
|
|
317
|
-
return String(value).startsWith(String(expected));
|
|
318
|
-
case types_1.FilterOperator.ENDS_WITH:
|
|
319
|
-
return String(value).endsWith(String(expected));
|
|
320
|
-
case types_1.FilterOperator.IN:
|
|
321
|
-
return Array.isArray(expected) && expected.includes(value);
|
|
322
|
-
case types_1.FilterOperator.NOT_IN:
|
|
323
|
-
return Array.isArray(expected) && !expected.includes(value);
|
|
324
|
-
case types_1.FilterOperator.IS_EMPTY:
|
|
325
|
-
return value === null || value === undefined || value === '';
|
|
326
|
-
case types_1.FilterOperator.IS_NOT_EMPTY:
|
|
327
|
-
return value !== null && value !== undefined && value !== '';
|
|
328
|
-
case types_1.FilterOperator.MATCHES_REGEX:
|
|
329
|
-
try {
|
|
330
|
-
return new RegExp(expected).test(String(value));
|
|
331
|
-
}
|
|
332
|
-
catch {
|
|
333
|
-
return false;
|
|
334
|
-
}
|
|
335
|
-
default:
|
|
336
|
-
return true;
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
exports.evaluateFilter = evaluateFilter;
|
|
24
|
+
function evaluateSimpleExpression(expression, context) {
|
|
25
|
+
let evaluated = expression;
|
|
26
|
+
const pattern = /\{\{([^}]+)\}\}/g;
|
|
27
|
+
const matches = [...expression.matchAll(pattern)];
|
|
28
|
+
for (const match of matches) {
|
|
29
|
+
const [fullMatch, path] = match;
|
|
30
|
+
const value = getNestedValue(context, path.trim());
|
|
31
|
+
const valueStr = typeof value === 'string'
|
|
32
|
+
? `"${value.replace(/"/g, '\\"')}"`
|
|
33
|
+
: JSON.stringify(value);
|
|
34
|
+
evaluated = evaluated.replace(fullMatch, valueStr);
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
return new Function(`return ${evaluated}`)();
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
console.error('Failed to evaluate expression:', evaluated, error);
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function getNestedValue(obj, path) {
|
|
45
|
+
const segments = path.split('.');
|
|
46
|
+
let current = obj;
|
|
47
|
+
for (const segment of segments) {
|
|
48
|
+
if (current === null || current === undefined) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
current = current[segment];
|
|
52
|
+
}
|
|
53
|
+
return current;
|
|
54
|
+
}
|
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
export { DataSourceType
|
|
2
|
-
export {
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export { BUILT_IN_FUNCTIONS, executeFunction, getFunctionsByCategory, getFunctionNames, hasFunction, getFunction, } from './functions';
|
|
7
|
-
export { PIPE_OPERATIONS, executePipeOperation, getPipesByCategory, getPipeNames, hasPipe, getPipe, } from './pipes';
|
|
8
|
-
export type { PipeDefinition } from './pipes/string-pipes';
|
|
9
|
-
import type { WorkflowContext } from './types';
|
|
10
|
-
export { buildExpressionString, buildReferenceString, hasExpressions, hasReferences, isInsideExpression, extractPaths, parseOperations, getCurrentExpressionContext, getValueType, tokenizeEnriched, validateExpression, generatePreview, convertExpressionToSaveFormat, convertExpressionToDisplayFormat, } from './helpers';
|
|
11
|
-
export type { ResourceMapping, EnrichedToken } from './helpers';
|
|
12
|
-
export declare function evaluate(expression: string, workflowContext: WorkflowContext, secretsMap?: Map<string, string>): unknown;
|
|
13
|
-
export declare function interpolate(template: string, workflowContext: WorkflowContext, secretsMap?: Map<string, string>, options?: {
|
|
14
|
-
maskSecrets?: boolean;
|
|
15
|
-
}): string;
|
|
16
|
-
export declare function hasDynamicContent(str: string): boolean;
|
|
17
|
-
export declare function extractReferences(str: string): string[];
|
|
1
|
+
export { DataSourceType } from './types';
|
|
2
|
+
export type { WorkflowContext, StepExecution, WorkflowStep, TriggerInfo, } from './types';
|
|
3
|
+
export { buildResolverContext, resolvePathValue, interpolateTemplate, } from './resolver';
|
|
4
|
+
export declare function hasTemplates(str: string): boolean;
|
|
5
|
+
export declare function extractTemplates(str: string): string[];
|
|
@@ -1,68 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.extractTemplates = exports.hasTemplates = exports.interpolateTemplate = exports.resolvePathValue = exports.buildResolverContext = exports.DataSourceType = void 0;
|
|
4
4
|
var types_1 = require("./types");
|
|
5
5
|
Object.defineProperty(exports, "DataSourceType", { enumerable: true, get: function () { return types_1.DataSourceType; } });
|
|
6
|
-
Object.defineProperty(exports, "OPERATOR_PRECEDENCE", { enumerable: true, get: function () { return types_1.OPERATOR_PRECEDENCE; } });
|
|
7
|
-
var workflow_enum_1 = require("../types/enum/workflow.enum");
|
|
8
|
-
Object.defineProperty(exports, "WorkflowTriggerType", { enumerable: true, get: function () { return workflow_enum_1.WorkflowTriggerType; } });
|
|
9
|
-
var parser_1 = require("./parser");
|
|
10
|
-
Object.defineProperty(exports, "parseExpression", { enumerable: true, get: function () { return parser_1.parseExpression; } });
|
|
11
|
-
Object.defineProperty(exports, "detectDataSource", { enumerable: true, get: function () { return parser_1.detectDataSource; } });
|
|
12
|
-
Object.defineProperty(exports, "parsePathSegments", { enumerable: true, get: function () { return parser_1.parsePathSegments; } });
|
|
13
|
-
Object.defineProperty(exports, "tokenizeTemplate", { enumerable: true, get: function () { return parser_1.tokenizeTemplate; } });
|
|
14
6
|
var resolver_1 = require("./resolver");
|
|
15
7
|
Object.defineProperty(exports, "buildResolverContext", { enumerable: true, get: function () { return resolver_1.buildResolverContext; } });
|
|
16
8
|
Object.defineProperty(exports, "resolvePathValue", { enumerable: true, get: function () { return resolver_1.resolvePathValue; } });
|
|
17
|
-
Object.defineProperty(exports, "
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(exports, "resolveExpression", { enumerable: true, get: function () { return resolver_1.resolveExpression; } });
|
|
20
|
-
var functions_1 = require("./functions");
|
|
21
|
-
Object.defineProperty(exports, "BUILT_IN_FUNCTIONS", { enumerable: true, get: function () { return functions_1.BUILT_IN_FUNCTIONS; } });
|
|
22
|
-
Object.defineProperty(exports, "executeFunction", { enumerable: true, get: function () { return functions_1.executeFunction; } });
|
|
23
|
-
Object.defineProperty(exports, "getFunctionsByCategory", { enumerable: true, get: function () { return functions_1.getFunctionsByCategory; } });
|
|
24
|
-
Object.defineProperty(exports, "getFunctionNames", { enumerable: true, get: function () { return functions_1.getFunctionNames; } });
|
|
25
|
-
Object.defineProperty(exports, "hasFunction", { enumerable: true, get: function () { return functions_1.hasFunction; } });
|
|
26
|
-
Object.defineProperty(exports, "getFunction", { enumerable: true, get: function () { return functions_1.getFunction; } });
|
|
27
|
-
var pipes_1 = require("./pipes");
|
|
28
|
-
Object.defineProperty(exports, "PIPE_OPERATIONS", { enumerable: true, get: function () { return pipes_1.PIPE_OPERATIONS; } });
|
|
29
|
-
Object.defineProperty(exports, "executePipeOperation", { enumerable: true, get: function () { return pipes_1.executePipeOperation; } });
|
|
30
|
-
Object.defineProperty(exports, "getPipesByCategory", { enumerable: true, get: function () { return pipes_1.getPipesByCategory; } });
|
|
31
|
-
Object.defineProperty(exports, "getPipeNames", { enumerable: true, get: function () { return pipes_1.getPipeNames; } });
|
|
32
|
-
Object.defineProperty(exports, "hasPipe", { enumerable: true, get: function () { return pipes_1.hasPipe; } });
|
|
33
|
-
Object.defineProperty(exports, "getPipe", { enumerable: true, get: function () { return pipes_1.getPipe; } });
|
|
34
|
-
const resolver_2 = require("./resolver");
|
|
35
|
-
var helpers_1 = require("./helpers");
|
|
36
|
-
Object.defineProperty(exports, "buildExpressionString", { enumerable: true, get: function () { return helpers_1.buildExpressionString; } });
|
|
37
|
-
Object.defineProperty(exports, "buildReferenceString", { enumerable: true, get: function () { return helpers_1.buildReferenceString; } });
|
|
38
|
-
Object.defineProperty(exports, "hasExpressions", { enumerable: true, get: function () { return helpers_1.hasExpressions; } });
|
|
39
|
-
Object.defineProperty(exports, "hasReferences", { enumerable: true, get: function () { return helpers_1.hasReferences; } });
|
|
40
|
-
Object.defineProperty(exports, "isInsideExpression", { enumerable: true, get: function () { return helpers_1.isInsideExpression; } });
|
|
41
|
-
Object.defineProperty(exports, "extractPaths", { enumerable: true, get: function () { return helpers_1.extractPaths; } });
|
|
42
|
-
Object.defineProperty(exports, "parseOperations", { enumerable: true, get: function () { return helpers_1.parseOperations; } });
|
|
43
|
-
Object.defineProperty(exports, "getCurrentExpressionContext", { enumerable: true, get: function () { return helpers_1.getCurrentExpressionContext; } });
|
|
44
|
-
Object.defineProperty(exports, "getValueType", { enumerable: true, get: function () { return helpers_1.getValueType; } });
|
|
45
|
-
Object.defineProperty(exports, "tokenizeEnriched", { enumerable: true, get: function () { return helpers_1.tokenizeEnriched; } });
|
|
46
|
-
Object.defineProperty(exports, "validateExpression", { enumerable: true, get: function () { return helpers_1.validateExpression; } });
|
|
47
|
-
Object.defineProperty(exports, "generatePreview", { enumerable: true, get: function () { return helpers_1.generatePreview; } });
|
|
48
|
-
Object.defineProperty(exports, "convertExpressionToSaveFormat", { enumerable: true, get: function () { return helpers_1.convertExpressionToSaveFormat; } });
|
|
49
|
-
Object.defineProperty(exports, "convertExpressionToDisplayFormat", { enumerable: true, get: function () { return helpers_1.convertExpressionToDisplayFormat; } });
|
|
50
|
-
function evaluate(expression, workflowContext, secretsMap) {
|
|
51
|
-
const context = (0, resolver_2.buildResolverContext)(workflowContext);
|
|
52
|
-
return (0, resolver_2.resolveExpression)(expression, context, secretsMap);
|
|
53
|
-
}
|
|
54
|
-
exports.evaluate = evaluate;
|
|
55
|
-
function interpolate(template, workflowContext, secretsMap, options) {
|
|
56
|
-
const context = (0, resolver_2.buildResolverContext)(workflowContext);
|
|
57
|
-
return (0, resolver_2.interpolateString)(template, context, secretsMap, options);
|
|
58
|
-
}
|
|
59
|
-
exports.interpolate = interpolate;
|
|
60
|
-
function hasDynamicContent(str) {
|
|
9
|
+
Object.defineProperty(exports, "interpolateTemplate", { enumerable: true, get: function () { return resolver_1.interpolateTemplate; } });
|
|
10
|
+
function hasTemplates(str) {
|
|
61
11
|
return /\{\{.+?\}\}/.test(str);
|
|
62
12
|
}
|
|
63
|
-
exports.
|
|
64
|
-
function
|
|
65
|
-
const
|
|
66
|
-
|
|
13
|
+
exports.hasTemplates = hasTemplates;
|
|
14
|
+
function extractTemplates(str) {
|
|
15
|
+
const pattern = /\{\{(.+?)\}\}/g;
|
|
16
|
+
const matches = [...str.matchAll(pattern)];
|
|
17
|
+
return matches.map(m => m[1].trim());
|
|
67
18
|
}
|
|
68
|
-
exports.
|
|
19
|
+
exports.extractTemplates = extractTemplates;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WorkflowContext } from './types';
|
|
2
2
|
export declare function buildResolverContext(workflowContext?: WorkflowContext): Record<string, unknown>;
|
|
3
3
|
export declare function resolvePathValue(path: string, context: Record<string, unknown>): unknown;
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function interpolateString(template: string, context: Record<string, unknown>, secretsMap?: Map<string, string>, options?: {
|
|
6
|
-
maskSecrets?: boolean;
|
|
7
|
-
}): string;
|
|
8
|
-
export declare function resolveExpression(expression: string, context: Record<string, unknown>, secretsMap?: Map<string, string>): unknown;
|
|
4
|
+
export declare function interpolateTemplate(template: string, context: Record<string, unknown>): string;
|