@abyss-project/console 1.0.41 → 1.0.43
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/constants/abyss-services.d.ts +0 -0
- package/dist/constants/abyss-services.js +1 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1 -3
- package/dist/types/constants/workflow.constants.d.ts +4 -0
- package/dist/types/constants/workflow.constants.js +5 -1
- package/dist/types/dto/workflow.dto.d.ts +5 -1
- package/dist/types/enum/workflow.enum.d.ts +2 -1
- package/dist/types/enum/workflow.enum.js +1 -0
- package/dist/types/interface/models/workflow-webhook.model.d.ts +1 -0
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.js +1 -2
- package/dist/utils/webhook-trigger.utils.d.ts +0 -7
- package/dist/utils/webhook-trigger.utils.js +0 -334
- 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 +46 -229
- package/dist/workflow-expressions/types.d.ts +25 -142
- package/dist/workflow-expressions/types.js +3 -21
- 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
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/index.d.ts
CHANGED
|
@@ -10,10 +10,8 @@ import * as projectAdminApi from './api/project.admin.api';
|
|
|
10
10
|
import * as secretApi from './api/secret.api';
|
|
11
11
|
import * as secretAccessApi from './api/secret-access.api';
|
|
12
12
|
import * as secretPublicApi from './api/secret-public.api';
|
|
13
|
-
export * from './utils/cidr.util';
|
|
14
13
|
export * from './types';
|
|
15
14
|
export * from './utils';
|
|
16
|
-
export * as GenericExpression from './expressions';
|
|
17
15
|
export * as WorkflowExpression from './workflow-expressions';
|
|
18
16
|
export declare const API_KEY_APPLICATION_HEADER = "abyss-console-api-key-application";
|
|
19
17
|
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"));
|
|
@@ -43,10 +43,8 @@ const projectAdminApi = __importStar(require("./api/project.admin.api"));
|
|
|
43
43
|
const secretApi = __importStar(require("./api/secret.api"));
|
|
44
44
|
const secretAccessApi = __importStar(require("./api/secret-access.api"));
|
|
45
45
|
const secretPublicApi = __importStar(require("./api/secret-public.api"));
|
|
46
|
-
__exportStar(require("./utils/cidr.util"), exports);
|
|
47
46
|
__exportStar(require("./types"), exports);
|
|
48
47
|
__exportStar(require("./utils"), exports);
|
|
49
|
-
exports.GenericExpression = __importStar(require("./expressions"));
|
|
50
48
|
exports.WorkflowExpression = __importStar(require("./workflow-expressions"));
|
|
51
49
|
const MONITOR_DEFAULT_BASE_URL = 'https://console-api.abyss-project.fr/api/';
|
|
52
50
|
exports.API_KEY_APPLICATION_HEADER = 'abyss-console-api-key-application';
|
|
@@ -3,6 +3,10 @@ export declare const WORKFLOW_STEP_TIMEOUT: number;
|
|
|
3
3
|
export declare const SLEEP_DURATION_MIN = 0;
|
|
4
4
|
export declare const SLEEP_DURATION_MAX = 900;
|
|
5
5
|
export declare const SLEEP_DURATION_DEFAULT = 1;
|
|
6
|
+
export declare const CODE_STEP_TIMEOUT_MIN = 100;
|
|
7
|
+
export declare const CODE_STEP_TIMEOUT_MAX = 60000;
|
|
8
|
+
export declare const CODE_STEP_TIMEOUT_DEFAULT = 5000;
|
|
6
9
|
export declare const EXPRESSION_TIMEOUT_DEFAULT = 5000;
|
|
7
10
|
export declare const EXPRESSION_TIMEOUT_MAX = 30000;
|
|
11
|
+
export declare const EXPRESSION_CPU_TIMEOUT = 10000;
|
|
8
12
|
export declare const EXPRESSION_MEMORY_LIMIT = 128;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EXPRESSION_MEMORY_LIMIT = 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;
|
|
3
|
+
exports.EXPRESSION_MEMORY_LIMIT = exports.EXPRESSION_CPU_TIMEOUT = exports.EXPRESSION_TIMEOUT_MAX = exports.EXPRESSION_TIMEOUT_DEFAULT = exports.CODE_STEP_TIMEOUT_DEFAULT = exports.CODE_STEP_TIMEOUT_MAX = exports.CODE_STEP_TIMEOUT_MIN = exports.SLEEP_DURATION_DEFAULT = exports.SLEEP_DURATION_MAX = exports.SLEEP_DURATION_MIN = exports.WORKFLOW_STEP_TIMEOUT = exports.WORKFLOW_EXECUTION_TIMEOUT = void 0;
|
|
4
4
|
exports.WORKFLOW_EXECUTION_TIMEOUT = 60 * 60 * 1000;
|
|
5
5
|
exports.WORKFLOW_STEP_TIMEOUT = 15 * 60 * 1000;
|
|
6
6
|
exports.SLEEP_DURATION_MIN = 0;
|
|
7
7
|
exports.SLEEP_DURATION_MAX = 900;
|
|
8
8
|
exports.SLEEP_DURATION_DEFAULT = 1;
|
|
9
|
+
exports.CODE_STEP_TIMEOUT_MIN = 100;
|
|
10
|
+
exports.CODE_STEP_TIMEOUT_MAX = 60000;
|
|
11
|
+
exports.CODE_STEP_TIMEOUT_DEFAULT = 5000;
|
|
9
12
|
exports.EXPRESSION_TIMEOUT_DEFAULT = 5000;
|
|
10
13
|
exports.EXPRESSION_TIMEOUT_MAX = 30000;
|
|
14
|
+
exports.EXPRESSION_CPU_TIMEOUT = 10000;
|
|
11
15
|
exports.EXPRESSION_MEMORY_LIMIT = 128;
|
|
@@ -25,6 +25,10 @@ export interface ISwitchCondition {
|
|
|
25
25
|
export interface ISwitchStepConfig {
|
|
26
26
|
expression: string;
|
|
27
27
|
}
|
|
28
|
+
export interface ICodeStepConfig {
|
|
29
|
+
code: string;
|
|
30
|
+
timeout?: number;
|
|
31
|
+
}
|
|
28
32
|
export interface ICallWebhookActionConfig {
|
|
29
33
|
actionType: WorkflowActionType.CALL_WEBHOOK;
|
|
30
34
|
url: string;
|
|
@@ -40,7 +44,7 @@ export interface IInviteToProjectActionConfig {
|
|
|
40
44
|
permissions: string[];
|
|
41
45
|
}
|
|
42
46
|
export type IActionStepConfig = ICallWebhookActionConfig | IInviteToProjectActionConfig;
|
|
43
|
-
export type StepConfig = IFilterStepConfig | ISleepStepConfig | ISwitchStepConfig | IActionStepConfig;
|
|
47
|
+
export type StepConfig = IFilterStepConfig | ISleepStepConfig | ISwitchStepConfig | ICodeStepConfig | IActionStepConfig;
|
|
44
48
|
export interface IWorkflowSettings {
|
|
45
49
|
maxExecutionsPerHour?: number;
|
|
46
50
|
maxExecutionsPerDay?: number;
|
|
@@ -24,6 +24,7 @@ var WorkflowStepType;
|
|
|
24
24
|
WorkflowStepType["SLEEP"] = "SLEEP";
|
|
25
25
|
WorkflowStepType["SWITCH"] = "SWITCH";
|
|
26
26
|
WorkflowStepType["ACTION"] = "ACTION";
|
|
27
|
+
WorkflowStepType["CODE"] = "CODE";
|
|
27
28
|
})(WorkflowStepType || (exports.WorkflowStepType = WorkflowStepType = {}));
|
|
28
29
|
var WorkflowActionType;
|
|
29
30
|
(function (WorkflowActionType) {
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -15,6 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./error.utils"), exports);
|
|
18
|
-
__exportStar(require("./reference-resolver.utils"), exports);
|
|
19
18
|
__exportStar(require("./ip-address-validator.utils"), exports);
|
|
20
|
-
__exportStar(require("./
|
|
19
|
+
__exportStar(require("./cidr.util"), exports);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { WorkflowTriggerData, FilterOperator, IWorkflowTrigger } from '../types';
|
|
2
|
-
type ExpressionValue = string | number | boolean | null | undefined | unknown[] | Record<string, unknown>;
|
|
3
|
-
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,335 +1 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.evaluateFilter = exports.getNestedValue = exports.evaluateExpression = exports.matchesTriggerFilters = void 0;
|
|
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
|
-
};
|
|
23
|
-
const matchesTriggerFilters = (trigger, triggerData) => {
|
|
24
|
-
if (!trigger.filters || trigger.filters.length === 0) {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
return trigger.filters.every((filter) => {
|
|
28
|
-
if (filter.expression) {
|
|
29
|
-
try {
|
|
30
|
-
const context = { trigger: triggerData };
|
|
31
|
-
const result = (0, exports.evaluateExpression)(filter.expression, context);
|
|
32
|
-
return Boolean(result);
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
console.error('Expression evaluation error:', error);
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return true;
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
exports.matchesTriggerFilters = matchesTriggerFilters;
|
|
43
|
-
const evaluateExpression = (expression, context) => {
|
|
44
|
-
const trimmed = expression.trim();
|
|
45
|
-
const simpleRefMatch = trimmed.match(/^\{\{([^}]+)\}\}$/);
|
|
46
|
-
if (simpleRefMatch) {
|
|
47
|
-
return (0, exports.getNestedValue)(context, simpleRefMatch[1].trim());
|
|
48
|
-
}
|
|
49
|
-
const tokens = tokenizeExpression(trimmed, context);
|
|
50
|
-
return evaluateTokens(tokens);
|
|
51
|
-
};
|
|
52
|
-
exports.evaluateExpression = evaluateExpression;
|
|
53
|
-
const tokenizeExpression = (expression, context) => {
|
|
54
|
-
const tokens = [];
|
|
55
|
-
let pos = 0;
|
|
56
|
-
const len = expression.length;
|
|
57
|
-
while (pos < len) {
|
|
58
|
-
while (pos < len && /\s/.test(expression[pos])) {
|
|
59
|
-
pos++;
|
|
60
|
-
}
|
|
61
|
-
if (pos >= len)
|
|
62
|
-
break;
|
|
63
|
-
const char = expression[pos];
|
|
64
|
-
if (expression.slice(pos, pos + 2) === '{{') {
|
|
65
|
-
const endIdx = expression.indexOf('}}', pos + 2);
|
|
66
|
-
if (endIdx === -1) {
|
|
67
|
-
throw new Error(`Unclosed expression at position ${pos}`);
|
|
68
|
-
}
|
|
69
|
-
const path = expression.slice(pos + 2, endIdx).trim();
|
|
70
|
-
if (path.includes('|')) {
|
|
71
|
-
const [refPath, ...pipes] = path.split('|').map((s) => s.trim());
|
|
72
|
-
let value = (0, exports.getNestedValue)(context, refPath);
|
|
73
|
-
for (const pipe of pipes) {
|
|
74
|
-
value = applyPipeOperator(value, pipe);
|
|
75
|
-
}
|
|
76
|
-
tokens.push({ type: 'reference', value: value });
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
const value = (0, exports.getNestedValue)(context, path);
|
|
80
|
-
tokens.push({ type: 'reference', value: value });
|
|
81
|
-
}
|
|
82
|
-
pos = endIdx + 2;
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
if (char === '"' || char === "'") {
|
|
86
|
-
const quote = char;
|
|
87
|
-
let str = '';
|
|
88
|
-
pos++;
|
|
89
|
-
while (pos < len && expression[pos] !== quote) {
|
|
90
|
-
if (expression[pos] === '\\' && pos + 1 < len) {
|
|
91
|
-
pos++;
|
|
92
|
-
str += expression[pos];
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
str += expression[pos];
|
|
96
|
-
}
|
|
97
|
-
pos++;
|
|
98
|
-
}
|
|
99
|
-
pos++;
|
|
100
|
-
tokens.push({ type: 'literal', value: str });
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
if (/[\d.]/.test(char)) {
|
|
104
|
-
let numStr = '';
|
|
105
|
-
while (pos < len && /[\d.eE+-]/.test(expression[pos])) {
|
|
106
|
-
numStr += expression[pos];
|
|
107
|
-
pos++;
|
|
108
|
-
}
|
|
109
|
-
tokens.push({ type: 'literal', value: parseFloat(numStr) });
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
const restExpr = expression.slice(pos);
|
|
113
|
-
if (restExpr.startsWith('true') && !/\w/.test(restExpr[4] || '')) {
|
|
114
|
-
tokens.push({ type: 'literal', value: true });
|
|
115
|
-
pos += 4;
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
if (restExpr.startsWith('false') && !/\w/.test(restExpr[5] || '')) {
|
|
119
|
-
tokens.push({ type: 'literal', value: false });
|
|
120
|
-
pos += 5;
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
if (restExpr.startsWith('null') && !/\w/.test(restExpr[4] || '')) {
|
|
124
|
-
tokens.push({ type: 'literal', value: null });
|
|
125
|
-
pos += 4;
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
const twoChar = expression.slice(pos, pos + 2);
|
|
129
|
-
const threeChar = expression.slice(pos, pos + 3);
|
|
130
|
-
if (['===', '!=='].includes(threeChar)) {
|
|
131
|
-
tokens.push({ type: 'operator', value: threeChar });
|
|
132
|
-
pos += 3;
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
if (['==', '!=', '<=', '>=', '&&', '||', '**'].includes(twoChar)) {
|
|
136
|
-
tokens.push({ type: 'operator', value: twoChar });
|
|
137
|
-
pos += 2;
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
if (['+', '-', '*', '/', '%', '<', '>', '!'].includes(char)) {
|
|
141
|
-
tokens.push({ type: 'operator', value: char });
|
|
142
|
-
pos++;
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
if (char === '(' || char === ')') {
|
|
146
|
-
tokens.push({ type: 'paren', value: char });
|
|
147
|
-
pos++;
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
if (char === '?' || char === ':') {
|
|
151
|
-
tokens.push({ type: 'operator', value: char });
|
|
152
|
-
pos++;
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
pos++;
|
|
156
|
-
}
|
|
157
|
-
return tokens;
|
|
158
|
-
};
|
|
159
|
-
const applyPipeOperator = (value, pipe) => {
|
|
160
|
-
const pipeMatch = pipe.match(/^(\w+)(?:\(([^)]*)\))?$/);
|
|
161
|
-
if (!pipeMatch)
|
|
162
|
-
return value;
|
|
163
|
-
const [, operator, args] = pipeMatch;
|
|
164
|
-
const strValue = String(value !== null && value !== void 0 ? value : '');
|
|
165
|
-
switch (operator) {
|
|
166
|
-
case 'contains':
|
|
167
|
-
return strValue.includes(args || '');
|
|
168
|
-
case 'startsWith':
|
|
169
|
-
return strValue.startsWith(args || '');
|
|
170
|
-
case 'endsWith':
|
|
171
|
-
return strValue.endsWith(args || '');
|
|
172
|
-
case 'isEmpty':
|
|
173
|
-
return (value === null ||
|
|
174
|
-
value === undefined ||
|
|
175
|
-
value === '' ||
|
|
176
|
-
(Array.isArray(value) && value.length === 0));
|
|
177
|
-
case 'isNotEmpty':
|
|
178
|
-
return (value !== null &&
|
|
179
|
-
value !== undefined &&
|
|
180
|
-
value !== '' &&
|
|
181
|
-
(!Array.isArray(value) || value.length > 0));
|
|
182
|
-
case 'length':
|
|
183
|
-
return Array.isArray(value) ? value.length : strValue.length;
|
|
184
|
-
case 'lower':
|
|
185
|
-
case 'toLowerCase':
|
|
186
|
-
return strValue.toLowerCase();
|
|
187
|
-
case 'upper':
|
|
188
|
-
case 'toUpperCase':
|
|
189
|
-
return strValue.toUpperCase();
|
|
190
|
-
case 'trim':
|
|
191
|
-
return strValue.trim();
|
|
192
|
-
default:
|
|
193
|
-
return value;
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
const evaluateTokens = (tokens) => {
|
|
197
|
-
var _a, _b;
|
|
198
|
-
if (tokens.length === 0)
|
|
199
|
-
return null;
|
|
200
|
-
if (tokens.length === 1) {
|
|
201
|
-
return tokens[0].value;
|
|
202
|
-
}
|
|
203
|
-
const questionIdx = tokens.findIndex((t) => t.type === 'operator' && t.value === '?');
|
|
204
|
-
if (questionIdx !== -1) {
|
|
205
|
-
const colonIdx = tokens.findIndex((t, i) => i > questionIdx && t.type === 'operator' && t.value === ':');
|
|
206
|
-
if (colonIdx !== -1) {
|
|
207
|
-
const condition = evaluateTokens(tokens.slice(0, questionIdx));
|
|
208
|
-
const trueValue = evaluateTokens(tokens.slice(questionIdx + 1, colonIdx));
|
|
209
|
-
const falseValue = evaluateTokens(tokens.slice(colonIdx + 1));
|
|
210
|
-
return condition ? trueValue : falseValue;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
let lowestPrecedence = Infinity;
|
|
214
|
-
let opIndex = -1;
|
|
215
|
-
let parenDepth = 0;
|
|
216
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
217
|
-
const token = tokens[i];
|
|
218
|
-
if (token.type === 'paren') {
|
|
219
|
-
parenDepth += token.value === '(' ? 1 : -1;
|
|
220
|
-
continue;
|
|
221
|
-
}
|
|
222
|
-
if (parenDepth > 0)
|
|
223
|
-
continue;
|
|
224
|
-
if (token.type === 'operator' && typeof token.value === 'string') {
|
|
225
|
-
const precedence = OPERATOR_PRECEDENCE[token.value];
|
|
226
|
-
if (precedence !== undefined && precedence <= lowestPrecedence) {
|
|
227
|
-
lowestPrecedence = precedence;
|
|
228
|
-
opIndex = i;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
if (opIndex !== -1) {
|
|
233
|
-
const op = tokens[opIndex].value;
|
|
234
|
-
const left = evaluateTokens(tokens.slice(0, opIndex));
|
|
235
|
-
const right = evaluateTokens(tokens.slice(opIndex + 1));
|
|
236
|
-
return applyOperator(op, left, right);
|
|
237
|
-
}
|
|
238
|
-
if (((_a = tokens[0]) === null || _a === void 0 ? void 0 : _a.type) === 'paren' && tokens[0].value === '(') {
|
|
239
|
-
let depth = 1;
|
|
240
|
-
let endIdx = 1;
|
|
241
|
-
while (endIdx < tokens.length && depth > 0) {
|
|
242
|
-
if (tokens[endIdx].type === 'paren') {
|
|
243
|
-
depth += tokens[endIdx].value === '(' ? 1 : -1;
|
|
244
|
-
}
|
|
245
|
-
endIdx++;
|
|
246
|
-
}
|
|
247
|
-
return evaluateTokens(tokens.slice(1, endIdx - 1));
|
|
248
|
-
}
|
|
249
|
-
if (((_b = tokens[0]) === null || _b === void 0 ? void 0 : _b.type) === 'operator' && tokens[0].value === '!') {
|
|
250
|
-
const operand = evaluateTokens(tokens.slice(1));
|
|
251
|
-
return !operand;
|
|
252
|
-
}
|
|
253
|
-
return tokens[0].value;
|
|
254
|
-
};
|
|
255
|
-
const applyOperator = (op, left, right) => {
|
|
256
|
-
switch (op) {
|
|
257
|
-
case '+':
|
|
258
|
-
if (typeof left === 'string' || typeof right === 'string') {
|
|
259
|
-
return String(left !== null && left !== void 0 ? left : '') + String(right !== null && right !== void 0 ? right : '');
|
|
260
|
-
}
|
|
261
|
-
return (Number(left) || 0) + (Number(right) || 0);
|
|
262
|
-
case '-':
|
|
263
|
-
return (Number(left) || 0) - (Number(right) || 0);
|
|
264
|
-
case '*':
|
|
265
|
-
return (Number(left) || 0) * (Number(right) || 0);
|
|
266
|
-
case '/':
|
|
267
|
-
return (Number(left) || 0) / (Number(right) || 1);
|
|
268
|
-
case '%':
|
|
269
|
-
return (Number(left) || 0) % (Number(right) || 1);
|
|
270
|
-
case '**':
|
|
271
|
-
return Math.pow(Number(left) || 0, Number(right) || 0);
|
|
272
|
-
case '==':
|
|
273
|
-
return left == right;
|
|
274
|
-
case '===':
|
|
275
|
-
return left === right;
|
|
276
|
-
case '!=':
|
|
277
|
-
return left != right;
|
|
278
|
-
case '!==':
|
|
279
|
-
return left !== right;
|
|
280
|
-
case '<':
|
|
281
|
-
return (Number(left) || 0) < (Number(right) || 0);
|
|
282
|
-
case '<=':
|
|
283
|
-
return (Number(left) || 0) <= (Number(right) || 0);
|
|
284
|
-
case '>':
|
|
285
|
-
return (Number(left) || 0) > (Number(right) || 0);
|
|
286
|
-
case '>=':
|
|
287
|
-
return (Number(left) || 0) >= (Number(right) || 0);
|
|
288
|
-
case '&&':
|
|
289
|
-
return Boolean(left) && Boolean(right);
|
|
290
|
-
case '||':
|
|
291
|
-
return Boolean(left) || Boolean(right);
|
|
292
|
-
default:
|
|
293
|
-
return null;
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
const getNestedValue = (obj, path) => {
|
|
297
|
-
return path
|
|
298
|
-
.split('.')
|
|
299
|
-
.reduce((current, key) => current === null || current === void 0 ? void 0 : current[key], obj);
|
|
300
|
-
};
|
|
301
|
-
exports.getNestedValue = getNestedValue;
|
|
302
|
-
const evaluateFilter = (value, operator, expected) => {
|
|
303
|
-
switch (operator) {
|
|
304
|
-
case types_1.FilterOperator.EQUALS:
|
|
305
|
-
return value === expected;
|
|
306
|
-
case types_1.FilterOperator.NOT_EQUALS:
|
|
307
|
-
return value !== expected;
|
|
308
|
-
case types_1.FilterOperator.CONTAINS:
|
|
309
|
-
return String(value).includes(String(expected));
|
|
310
|
-
case types_1.FilterOperator.NOT_CONTAINS:
|
|
311
|
-
return !String(value).includes(String(expected));
|
|
312
|
-
case types_1.FilterOperator.STARTS_WITH:
|
|
313
|
-
return String(value).startsWith(String(expected));
|
|
314
|
-
case types_1.FilterOperator.ENDS_WITH:
|
|
315
|
-
return String(value).endsWith(String(expected));
|
|
316
|
-
case types_1.FilterOperator.IN:
|
|
317
|
-
return Array.isArray(expected) && expected.includes(value);
|
|
318
|
-
case types_1.FilterOperator.NOT_IN:
|
|
319
|
-
return Array.isArray(expected) && !expected.includes(value);
|
|
320
|
-
case types_1.FilterOperator.IS_EMPTY:
|
|
321
|
-
return value === null || value === undefined || value === '';
|
|
322
|
-
case types_1.FilterOperator.IS_NOT_EMPTY:
|
|
323
|
-
return value !== null && value !== undefined && value !== '';
|
|
324
|
-
case types_1.FilterOperator.MATCHES_REGEX:
|
|
325
|
-
try {
|
|
326
|
-
return new RegExp(expected).test(String(value));
|
|
327
|
-
}
|
|
328
|
-
catch {
|
|
329
|
-
return false;
|
|
330
|
-
}
|
|
331
|
-
default:
|
|
332
|
-
return true;
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
exports.evaluateFilter = evaluateFilter;
|
|
@@ -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 } 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;
|