@abyss-project/main 1.0.93 → 1.0.95
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/expressions/index.d.ts +5 -0
- package/dist/expressions/index.js +16 -0
- package/dist/expressions/mapper.d.ts +9 -0
- package/dist/expressions/mapper.js +90 -0
- package/dist/expressions/parser.d.ts +3 -0
- package/dist/expressions/parser.js +97 -0
- package/dist/expressions/resolver.d.ts +12 -0
- package/dist/expressions/resolver.js +88 -0
- package/dist/expressions/types.d.ts +36 -0
- package/dist/types/enum/abyss-application-event.enum.d.ts +5 -1
- package/dist/types/enum/abyss-application-event.enum.js +4 -0
- package/dist/types/enum/project-access-permission.enum.d.ts +5 -1
- package/dist/types/enum/project-access-permission.enum.js +4 -0
- package/dist/workflow/expression/expression-functions.utils.d.ts +6 -0
- package/dist/workflow/expression/expression-functions.utils.js +61 -0
- package/dist/workflow/expression/expression-mapper.d.ts +11 -0
- package/dist/workflow/expression/expression-mapper.js +32 -0
- package/dist/workflow/expression/expression-mapping.utils.d.ts +4 -0
- package/dist/workflow/expression/expression-mapping.utils.js +43 -0
- package/dist/workflow/expression/expression-resolver.utils.d.ts +3 -0
- package/dist/workflow/expression/expression-resolver.utils.js +54 -0
- package/dist/workflow/expression/expression-tokenizer.utils.d.ts +4 -0
- package/dist/workflow/expression/expression-tokenizer.utils.js +123 -0
- package/dist/workflow/expression/expression.types.d.ts +33 -0
- package/dist/workflow/expression/expression.types.js +17 -0
- package/dist/workflow/expression/index.d.ts +10 -0
- package/dist/workflow/expression/index.js +40 -0
- package/dist/workflow/expression/workflow-resolver.d.ts +9 -0
- package/dist/workflow/expression/workflow-resolver.js +102 -0
- package/dist/workflow/expressions/functions/array.d.ts +2 -0
- package/dist/workflow/expressions/functions/array.js +252 -0
- package/dist/workflow/expressions/functions/crypto.d.ts +2 -0
- package/dist/workflow/expressions/functions/crypto.js +101 -0
- package/dist/workflow/expressions/functions/datetime.d.ts +2 -0
- package/dist/workflow/expressions/functions/datetime.js +256 -0
- package/dist/workflow/expressions/functions/index.d.ts +7 -0
- package/dist/workflow/expressions/functions/index.js +46 -0
- package/dist/workflow/expressions/functions/math.d.ts +2 -0
- package/dist/workflow/expressions/functions/math.js +174 -0
- package/dist/workflow/expressions/functions/string.d.ts +2 -0
- package/dist/workflow/expressions/functions/string.js +301 -0
- package/dist/workflow/expressions/functions/utility.d.ts +2 -0
- package/dist/workflow/expressions/functions/utility.js +230 -0
- package/dist/workflow/expressions/helpers.d.ts +26 -0
- package/dist/workflow/expressions/helpers.js +132 -0
- package/dist/workflow/expressions/index.d.ts +15 -0
- package/dist/workflow/expressions/index.js +61 -0
- package/dist/workflow/expressions/parser.d.ts +8 -0
- package/dist/workflow/expressions/parser.js +436 -0
- package/dist/workflow/expressions/pipes/array-pipes.d.ts +2 -0
- package/dist/workflow/expressions/pipes/array-pipes.js +248 -0
- package/dist/workflow/expressions/pipes/index.d.ts +8 -0
- package/dist/workflow/expressions/pipes/index.js +40 -0
- package/dist/workflow/expressions/pipes/object-pipes.d.ts +2 -0
- package/dist/workflow/expressions/pipes/object-pipes.js +243 -0
- package/dist/workflow/expressions/pipes/string-pipes.d.ts +9 -0
- package/dist/workflow/expressions/pipes/string-pipes.js +178 -0
- package/dist/workflow/expressions/resolver.d.ts +8 -0
- package/dist/workflow/expressions/resolver.js +263 -0
- package/dist/workflow/expressions/types.d.ts +144 -0
- package/dist/workflow/expressions/types.js +33 -0
- package/dist/workflow/index.d.ts +1 -0
- package/dist/workflow/index.js +17 -0
- package/package.json +1 -1
- package/dist/api/domain-verification.admin.api.d.ts +0 -4
- package/dist/api/domain-verification.admin.api.js +0 -10
- package/dist/api/domain-verification.api.d.ts +0 -7
- package/dist/api/domain-verification.api.js +0 -28
- package/dist/api/workflow.api.d.ts +0 -26
- package/dist/api/workflow.api.js +0 -60
- package/dist/types/dto/domain-verification.dto.d.ts +0 -19
- package/dist/types/interface/api/bodies/domain-verification.body.d.ts +0 -7
- package/dist/types/interface/api/bodies/domain-verification.body.js +0 -2
- package/dist/types/interface/api/params/domain-verification.params.d.ts +0 -18
- package/dist/types/interface/api/params/domain-verification.params.js +0 -2
- package/dist/types/interface/api/requests/domain-verification.admin.request.d.ts +0 -5
- package/dist/types/interface/api/requests/domain-verification.admin.request.js +0 -2
- package/dist/types/interface/api/requests/domain-verification.request.d.ts +0 -29
- package/dist/types/interface/api/requests/domain-verification.request.js +0 -2
- package/dist/types/interface/api/requests/workflow.request.d.ts +0 -119
- package/dist/types/interface/api/requests/workflow.request.js +0 -2
- package/dist/types/interface/api/responses/domain-verification.admin.response.d.ts +0 -6
- package/dist/types/interface/api/responses/domain-verification.admin.response.js +0 -2
- package/dist/types/interface/api/responses/domain-verification.response.d.ts +0 -29
- package/dist/types/interface/api/responses/domain-verification.response.js +0 -2
- package/dist/types/interface/api/responses/project-domain-verification.response.d.ts +0 -55
- package/dist/types/interface/api/responses/project-domain-verification.response.js +0 -2
- package/dist/types/interface/api/responses/workflow.response.d.ts +0 -124
- package/dist/types/interface/api/responses/workflow.response.js +0 -2
- package/dist/types/interface/models/domain-verification.model.d.ts +0 -42
- package/dist/types/interface/models/domain-verification.model.js +0 -14
- package/dist/types/interface/models/project-domain-verification.model.d.ts +0 -27
- package/dist/types/interface/models/project-domain-verification.model.js +0 -15
- package/dist/types/interface/models/workflow-execution-step.model.d.ts +0 -59
- package/dist/types/interface/models/workflow-execution-step.model.js +0 -12
- package/dist/types/interface/models/workflow-execution.model.d.ts +0 -78
- package/dist/types/interface/models/workflow-execution.model.js +0 -13
- package/dist/types/interface/models/workflow-step.model.d.ts +0 -106
- package/dist/types/interface/models/workflow-step.model.js +0 -44
- package/dist/types/interface/models/workflow-template.model.d.ts +0 -41
- package/dist/types/interface/models/workflow-template.model.js +0 -2
- package/dist/types/interface/models/workflow.model.d.ts +0 -72
- package/dist/types/interface/models/workflow.model.js +0 -23
- /package/dist/{types/dto/domain-verification.dto.js → expressions/types.js} +0 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePathSegments = exports.tokenize = exports.detectDataSource = void 0;
|
|
4
|
+
const expression_types_1 = require("./expression.types");
|
|
5
|
+
const EXPRESSION_PATTERN = /\{\{(.+?)\}\}/g;
|
|
6
|
+
const REFERENCE_PATTERN = /@(\w+):([a-zA-Z0-9-_]+)/g;
|
|
7
|
+
const DATA_SOURCE_PREFIXES = {
|
|
8
|
+
trigger: expression_types_1.DataSourceType.WORKFLOW_TRIGGER,
|
|
9
|
+
triggerData: expression_types_1.DataSourceType.WORKFLOW_TRIGGER,
|
|
10
|
+
steps: expression_types_1.DataSourceType.WORKFLOW_STEPS,
|
|
11
|
+
variables: expression_types_1.DataSourceType.WORKFLOW_VARIABLES,
|
|
12
|
+
secret: expression_types_1.DataSourceType.SECRETS,
|
|
13
|
+
ipAddress: expression_types_1.DataSourceType.IP_ADDRESSES,
|
|
14
|
+
domain: expression_types_1.DataSourceType.DOMAINS,
|
|
15
|
+
abyss: expression_types_1.DataSourceType.ABYSS_CONFIG,
|
|
16
|
+
app: expression_types_1.DataSourceType.APPLICATIONS,
|
|
17
|
+
project: expression_types_1.DataSourceType.PROJECT,
|
|
18
|
+
env: expression_types_1.DataSourceType.ENV,
|
|
19
|
+
fn: expression_types_1.DataSourceType.FUNCTIONS,
|
|
20
|
+
};
|
|
21
|
+
function detectDataSource(path) {
|
|
22
|
+
const firstDot = path.indexOf('.');
|
|
23
|
+
const firstBracket = path.indexOf('[');
|
|
24
|
+
let prefix;
|
|
25
|
+
if (firstDot === -1 && firstBracket === -1) {
|
|
26
|
+
prefix = path;
|
|
27
|
+
}
|
|
28
|
+
else if (firstDot === -1) {
|
|
29
|
+
prefix = path.substring(0, firstBracket);
|
|
30
|
+
}
|
|
31
|
+
else if (firstBracket === -1) {
|
|
32
|
+
prefix = path.substring(0, firstDot);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
prefix = path.substring(0, Math.min(firstDot, firstBracket));
|
|
36
|
+
}
|
|
37
|
+
return DATA_SOURCE_PREFIXES[prefix] || null;
|
|
38
|
+
}
|
|
39
|
+
exports.detectDataSource = detectDataSource;
|
|
40
|
+
function tokenize(text) {
|
|
41
|
+
const tokens = [];
|
|
42
|
+
let lastIndex = 0;
|
|
43
|
+
const expressionMatches = Array.from(text.matchAll(EXPRESSION_PATTERN));
|
|
44
|
+
for (const match of expressionMatches) {
|
|
45
|
+
const matchIndex = match.index;
|
|
46
|
+
if (matchIndex > lastIndex) {
|
|
47
|
+
tokens.push({
|
|
48
|
+
type: 'text',
|
|
49
|
+
value: text.substring(lastIndex, matchIndex),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
tokens.push({
|
|
53
|
+
type: 'expression',
|
|
54
|
+
value: match[1].trim(),
|
|
55
|
+
raw: match[0],
|
|
56
|
+
});
|
|
57
|
+
lastIndex = matchIndex + match[0].length;
|
|
58
|
+
}
|
|
59
|
+
if (lastIndex < text.length) {
|
|
60
|
+
tokens.push({
|
|
61
|
+
type: 'text',
|
|
62
|
+
value: text.substring(lastIndex),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const referenceMatches = Array.from(text.matchAll(REFERENCE_PATTERN));
|
|
66
|
+
for (const match of referenceMatches) {
|
|
67
|
+
tokens.push({
|
|
68
|
+
type: 'reference',
|
|
69
|
+
entityType: match[1],
|
|
70
|
+
entityId: match[2],
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return tokens;
|
|
74
|
+
}
|
|
75
|
+
exports.tokenize = tokenize;
|
|
76
|
+
function parsePathSegments(path) {
|
|
77
|
+
const segments = [];
|
|
78
|
+
let current = '';
|
|
79
|
+
let inBrackets = false;
|
|
80
|
+
let quoteChar = null;
|
|
81
|
+
for (let i = 0; i < path.length; i++) {
|
|
82
|
+
const char = path[i];
|
|
83
|
+
if (quoteChar) {
|
|
84
|
+
if (char === quoteChar && path[i - 1] !== '\\') {
|
|
85
|
+
quoteChar = null;
|
|
86
|
+
}
|
|
87
|
+
else if (char !== quoteChar) {
|
|
88
|
+
current += char;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else if (char === '"' || char === "'") {
|
|
92
|
+
quoteChar = char;
|
|
93
|
+
}
|
|
94
|
+
else if (char === '[') {
|
|
95
|
+
if (current) {
|
|
96
|
+
segments.push(current);
|
|
97
|
+
current = '';
|
|
98
|
+
}
|
|
99
|
+
inBrackets = true;
|
|
100
|
+
}
|
|
101
|
+
else if (char === ']') {
|
|
102
|
+
if (current) {
|
|
103
|
+
segments.push(current);
|
|
104
|
+
current = '';
|
|
105
|
+
}
|
|
106
|
+
inBrackets = false;
|
|
107
|
+
}
|
|
108
|
+
else if (char === '.' && !inBrackets) {
|
|
109
|
+
if (current) {
|
|
110
|
+
segments.push(current);
|
|
111
|
+
current = '';
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
current += char;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (current) {
|
|
119
|
+
segments.push(current);
|
|
120
|
+
}
|
|
121
|
+
return segments;
|
|
122
|
+
}
|
|
123
|
+
exports.parsePathSegments = parsePathSegments;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ResourceMapping as GenericResourceMapping } from '../../expressions';
|
|
2
|
+
export declare enum DataSourceType {
|
|
3
|
+
WORKFLOW_TRIGGER = "trigger",
|
|
4
|
+
WORKFLOW_STEPS = "steps",
|
|
5
|
+
WORKFLOW_VARIABLES = "variables",
|
|
6
|
+
SECRETS = "secret",
|
|
7
|
+
IP_ADDRESSES = "ipAddress",
|
|
8
|
+
DOMAINS = "domain",
|
|
9
|
+
APPLICATIONS = "app",
|
|
10
|
+
ABYSS_CONFIG = "abyss",
|
|
11
|
+
PROJECT = "project",
|
|
12
|
+
ENV = "env",
|
|
13
|
+
FUNCTIONS = "fn"
|
|
14
|
+
}
|
|
15
|
+
export type WorkflowResourceMapping = GenericResourceMapping<DataSourceType>;
|
|
16
|
+
export interface WorkflowExpressionContext {
|
|
17
|
+
trigger?: Record<string, unknown>;
|
|
18
|
+
steps?: Record<string, unknown>;
|
|
19
|
+
variables?: Record<string, unknown>;
|
|
20
|
+
secret?: Record<string, unknown>;
|
|
21
|
+
ipAddress?: Record<string, unknown>;
|
|
22
|
+
domain?: Record<string, unknown>;
|
|
23
|
+
app?: Record<string, unknown>;
|
|
24
|
+
abyss?: Record<string, unknown>;
|
|
25
|
+
project?: Record<string, unknown>;
|
|
26
|
+
env?: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
export interface WorkflowExpressionResult {
|
|
29
|
+
value: unknown;
|
|
30
|
+
success: boolean;
|
|
31
|
+
error?: string;
|
|
32
|
+
accessedSources: DataSourceType[];
|
|
33
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataSourceType = void 0;
|
|
4
|
+
var DataSourceType;
|
|
5
|
+
(function (DataSourceType) {
|
|
6
|
+
DataSourceType["WORKFLOW_TRIGGER"] = "trigger";
|
|
7
|
+
DataSourceType["WORKFLOW_STEPS"] = "steps";
|
|
8
|
+
DataSourceType["WORKFLOW_VARIABLES"] = "variables";
|
|
9
|
+
DataSourceType["SECRETS"] = "secret";
|
|
10
|
+
DataSourceType["IP_ADDRESSES"] = "ipAddress";
|
|
11
|
+
DataSourceType["DOMAINS"] = "domain";
|
|
12
|
+
DataSourceType["APPLICATIONS"] = "app";
|
|
13
|
+
DataSourceType["ABYSS_CONFIG"] = "abyss";
|
|
14
|
+
DataSourceType["PROJECT"] = "project";
|
|
15
|
+
DataSourceType["ENV"] = "env";
|
|
16
|
+
DataSourceType["FUNCTIONS"] = "fn";
|
|
17
|
+
})(DataSourceType || (exports.DataSourceType = DataSourceType = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { WorkflowResourceMapping, WorkflowExpressionContext, WorkflowExpressionResult, } from './expression.types';
|
|
2
|
+
export { DataSourceType } from './expression.types';
|
|
3
|
+
export { convertToDisplayFormat, convertToSaveFormat, extractMappings, validateExpression, createWorkflowResourceMapping, buildPathSegment, } from './expression-mapper';
|
|
4
|
+
export { resolveWorkflowExpression, isWorkflowExpressionDynamic, extractDataSources, validateWorkflowExpression, } from './workflow-resolver';
|
|
5
|
+
export type { ExpressionMappingOptions, ExpressionParserConfig, ResolverOptions, } from '../../expressions';
|
|
6
|
+
export { parseExpression, stringifyExpression, isDynamicExpression, extractPaths, } from '../../expressions';
|
|
7
|
+
export * from './expression-resolver.utils';
|
|
8
|
+
export * from './expression-tokenizer.utils';
|
|
9
|
+
export * from './expression-functions.utils';
|
|
10
|
+
export * from './expression-mapping.utils';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.extractPaths = exports.isDynamicExpression = exports.stringifyExpression = exports.parseExpression = exports.validateWorkflowExpression = exports.extractDataSources = exports.isWorkflowExpressionDynamic = exports.resolveWorkflowExpression = exports.buildPathSegment = exports.createWorkflowResourceMapping = exports.validateExpression = exports.extractMappings = exports.convertToSaveFormat = exports.convertToDisplayFormat = exports.DataSourceType = void 0;
|
|
18
|
+
var expression_types_1 = require("./expression.types");
|
|
19
|
+
Object.defineProperty(exports, "DataSourceType", { enumerable: true, get: function () { return expression_types_1.DataSourceType; } });
|
|
20
|
+
var expression_mapper_1 = require("./expression-mapper");
|
|
21
|
+
Object.defineProperty(exports, "convertToDisplayFormat", { enumerable: true, get: function () { return expression_mapper_1.convertToDisplayFormat; } });
|
|
22
|
+
Object.defineProperty(exports, "convertToSaveFormat", { enumerable: true, get: function () { return expression_mapper_1.convertToSaveFormat; } });
|
|
23
|
+
Object.defineProperty(exports, "extractMappings", { enumerable: true, get: function () { return expression_mapper_1.extractMappings; } });
|
|
24
|
+
Object.defineProperty(exports, "validateExpression", { enumerable: true, get: function () { return expression_mapper_1.validateExpression; } });
|
|
25
|
+
Object.defineProperty(exports, "createWorkflowResourceMapping", { enumerable: true, get: function () { return expression_mapper_1.createWorkflowResourceMapping; } });
|
|
26
|
+
Object.defineProperty(exports, "buildPathSegment", { enumerable: true, get: function () { return expression_mapper_1.buildPathSegment; } });
|
|
27
|
+
var workflow_resolver_1 = require("./workflow-resolver");
|
|
28
|
+
Object.defineProperty(exports, "resolveWorkflowExpression", { enumerable: true, get: function () { return workflow_resolver_1.resolveWorkflowExpression; } });
|
|
29
|
+
Object.defineProperty(exports, "isWorkflowExpressionDynamic", { enumerable: true, get: function () { return workflow_resolver_1.isWorkflowExpressionDynamic; } });
|
|
30
|
+
Object.defineProperty(exports, "extractDataSources", { enumerable: true, get: function () { return workflow_resolver_1.extractDataSources; } });
|
|
31
|
+
Object.defineProperty(exports, "validateWorkflowExpression", { enumerable: true, get: function () { return workflow_resolver_1.validateWorkflowExpression; } });
|
|
32
|
+
var expressions_1 = require("../../expressions");
|
|
33
|
+
Object.defineProperty(exports, "parseExpression", { enumerable: true, get: function () { return expressions_1.parseExpression; } });
|
|
34
|
+
Object.defineProperty(exports, "stringifyExpression", { enumerable: true, get: function () { return expressions_1.stringifyExpression; } });
|
|
35
|
+
Object.defineProperty(exports, "isDynamicExpression", { enumerable: true, get: function () { return expressions_1.isDynamicExpression; } });
|
|
36
|
+
Object.defineProperty(exports, "extractPaths", { enumerable: true, get: function () { return expressions_1.extractPaths; } });
|
|
37
|
+
__exportStar(require("./expression-resolver.utils"), exports);
|
|
38
|
+
__exportStar(require("./expression-tokenizer.utils"), exports);
|
|
39
|
+
__exportStar(require("./expression-functions.utils"), exports);
|
|
40
|
+
__exportStar(require("./expression-mapping.utils"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ResolverOptions } from '../../expressions';
|
|
2
|
+
import type { WorkflowExpressionContext, WorkflowExpressionResult, DataSourceType } from './expression.types';
|
|
3
|
+
export declare function resolveWorkflowExpression(expression: string, context: WorkflowExpressionContext, options?: ResolverOptions): WorkflowExpressionResult;
|
|
4
|
+
export declare function isWorkflowExpressionDynamic(expression: string): boolean;
|
|
5
|
+
export declare function extractDataSources(expression: string): DataSourceType[];
|
|
6
|
+
export declare function validateWorkflowExpression(expression: string): {
|
|
7
|
+
valid: boolean;
|
|
8
|
+
error?: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateWorkflowExpression = exports.extractDataSources = exports.isWorkflowExpressionDynamic = exports.resolveWorkflowExpression = void 0;
|
|
4
|
+
const expressions_1 = require("../../expressions");
|
|
5
|
+
function resolveWorkflowExpression(expression, context, options) {
|
|
6
|
+
try {
|
|
7
|
+
const paths = (0, expressions_1.extractPaths)(expression);
|
|
8
|
+
const accessedSources = new Set();
|
|
9
|
+
for (const path of paths) {
|
|
10
|
+
const source = path.split('.')[0];
|
|
11
|
+
accessedSources.add(source);
|
|
12
|
+
}
|
|
13
|
+
const value = (0, expressions_1.resolveExpression)(expression, context, {
|
|
14
|
+
...options,
|
|
15
|
+
functions: {
|
|
16
|
+
...workflowFunctions,
|
|
17
|
+
...((options === null || options === void 0 ? void 0 : options.functions) || {}),
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
value,
|
|
22
|
+
success: true,
|
|
23
|
+
accessedSources: Array.from(accessedSources),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
return {
|
|
28
|
+
value: undefined,
|
|
29
|
+
success: false,
|
|
30
|
+
error: error instanceof Error ? error.message : String(error),
|
|
31
|
+
accessedSources: [],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.resolveWorkflowExpression = resolveWorkflowExpression;
|
|
36
|
+
const workflowFunctions = {
|
|
37
|
+
upper: (str) => String(str).toUpperCase(),
|
|
38
|
+
lower: (str) => String(str).toLowerCase(),
|
|
39
|
+
trim: (str) => String(str).trim(),
|
|
40
|
+
length: (str) => String(str).length,
|
|
41
|
+
join: (arr, separator = ',') => {
|
|
42
|
+
if (!Array.isArray(arr))
|
|
43
|
+
return String(arr);
|
|
44
|
+
return arr.join(String(separator));
|
|
45
|
+
},
|
|
46
|
+
first: (arr) => {
|
|
47
|
+
if (!Array.isArray(arr))
|
|
48
|
+
return arr;
|
|
49
|
+
return arr[0];
|
|
50
|
+
},
|
|
51
|
+
last: (arr) => {
|
|
52
|
+
if (!Array.isArray(arr))
|
|
53
|
+
return arr;
|
|
54
|
+
return arr[arr.length - 1];
|
|
55
|
+
},
|
|
56
|
+
now: () => new Date().toISOString(),
|
|
57
|
+
timestamp: () => Date.now(),
|
|
58
|
+
json: (obj) => JSON.stringify(obj),
|
|
59
|
+
default: (value, defaultValue) => {
|
|
60
|
+
return value === undefined || value === null ? defaultValue : value;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
function isWorkflowExpressionDynamic(expression) {
|
|
64
|
+
return (0, expressions_1.isDynamicExpression)(expression);
|
|
65
|
+
}
|
|
66
|
+
exports.isWorkflowExpressionDynamic = isWorkflowExpressionDynamic;
|
|
67
|
+
function extractDataSources(expression) {
|
|
68
|
+
const paths = (0, expressions_1.extractPaths)(expression);
|
|
69
|
+
const sources = new Set();
|
|
70
|
+
for (const path of paths) {
|
|
71
|
+
const source = path.split('.')[0];
|
|
72
|
+
sources.add(source);
|
|
73
|
+
}
|
|
74
|
+
return Array.from(sources);
|
|
75
|
+
}
|
|
76
|
+
exports.extractDataSources = extractDataSources;
|
|
77
|
+
function validateWorkflowExpression(expression) {
|
|
78
|
+
try {
|
|
79
|
+
const openCount = (expression.match(/\{\{/g) || []).length;
|
|
80
|
+
const closeCount = (expression.match(/\}\}/g) || []).length;
|
|
81
|
+
if (openCount !== closeCount) {
|
|
82
|
+
return {
|
|
83
|
+
valid: false,
|
|
84
|
+
error: 'Mismatched expression delimiters',
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (/\{\{\s*\}\}/.test(expression)) {
|
|
88
|
+
return {
|
|
89
|
+
valid: false,
|
|
90
|
+
error: 'Empty expression found',
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return { valid: true };
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
return {
|
|
97
|
+
valid: false,
|
|
98
|
+
error: error instanceof Error ? error.message : String(error),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.validateWorkflowExpression = validateWorkflowExpression;
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.arrayFunctions = void 0;
|
|
4
|
+
exports.arrayFunctions = {
|
|
5
|
+
length: {
|
|
6
|
+
name: 'length',
|
|
7
|
+
description: 'Returns the length of a string or array',
|
|
8
|
+
category: 'array',
|
|
9
|
+
signature: 'length(value)',
|
|
10
|
+
args: [
|
|
11
|
+
{
|
|
12
|
+
name: 'value',
|
|
13
|
+
type: 'string|array',
|
|
14
|
+
required: true,
|
|
15
|
+
description: 'String or array',
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
returnType: 'number',
|
|
19
|
+
examples: ['{{fn.length(trigger.items)}}'],
|
|
20
|
+
execute: (value) => {
|
|
21
|
+
if (typeof value === 'string') {
|
|
22
|
+
return value.length;
|
|
23
|
+
}
|
|
24
|
+
if (Array.isArray(value)) {
|
|
25
|
+
return value.length;
|
|
26
|
+
}
|
|
27
|
+
return 0;
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
first: {
|
|
31
|
+
name: 'first',
|
|
32
|
+
description: 'Returns the first element of an array',
|
|
33
|
+
category: 'array',
|
|
34
|
+
signature: 'first(arr)',
|
|
35
|
+
args: [
|
|
36
|
+
{
|
|
37
|
+
name: 'arr',
|
|
38
|
+
type: 'array',
|
|
39
|
+
required: true,
|
|
40
|
+
description: 'Input array',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
returnType: 'any',
|
|
44
|
+
examples: ['{{fn.first(trigger.items)}}'],
|
|
45
|
+
execute: (arr) => {
|
|
46
|
+
if (Array.isArray(arr) && arr.length > 0) {
|
|
47
|
+
return arr[0];
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
last: {
|
|
53
|
+
name: 'last',
|
|
54
|
+
description: 'Returns the last element of an array',
|
|
55
|
+
category: 'array',
|
|
56
|
+
signature: 'last(arr)',
|
|
57
|
+
args: [
|
|
58
|
+
{
|
|
59
|
+
name: 'arr',
|
|
60
|
+
type: 'array',
|
|
61
|
+
required: true,
|
|
62
|
+
description: 'Input array',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
returnType: 'any',
|
|
66
|
+
examples: ['{{fn.last(trigger.items)}}'],
|
|
67
|
+
execute: (arr) => {
|
|
68
|
+
if (Array.isArray(arr) && arr.length > 0) {
|
|
69
|
+
return arr[arr.length - 1];
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
join: {
|
|
75
|
+
name: 'join',
|
|
76
|
+
description: 'Joins array elements into a string',
|
|
77
|
+
category: 'array',
|
|
78
|
+
signature: 'join(arr, separator)',
|
|
79
|
+
args: [
|
|
80
|
+
{
|
|
81
|
+
name: 'arr',
|
|
82
|
+
type: 'array',
|
|
83
|
+
required: true,
|
|
84
|
+
description: 'Input array',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'separator',
|
|
88
|
+
type: 'string',
|
|
89
|
+
required: false,
|
|
90
|
+
description: 'Separator (default: ",")',
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
returnType: 'string',
|
|
94
|
+
examples: ['{{fn.join(trigger.tags, ", ")}}'],
|
|
95
|
+
execute: (arr, separator) => {
|
|
96
|
+
if (!Array.isArray(arr)) {
|
|
97
|
+
return '';
|
|
98
|
+
}
|
|
99
|
+
return arr.join(separator !== undefined ? String(separator) : ',');
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
slice: {
|
|
103
|
+
name: 'slice',
|
|
104
|
+
description: 'Extracts a section of an array',
|
|
105
|
+
category: 'array',
|
|
106
|
+
signature: 'slice(arr, start, end?)',
|
|
107
|
+
args: [
|
|
108
|
+
{
|
|
109
|
+
name: 'arr',
|
|
110
|
+
type: 'array',
|
|
111
|
+
required: true,
|
|
112
|
+
description: 'Input array',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'start',
|
|
116
|
+
type: 'number',
|
|
117
|
+
required: true,
|
|
118
|
+
description: 'Start index',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'end',
|
|
122
|
+
type: 'number',
|
|
123
|
+
required: false,
|
|
124
|
+
description: 'End index',
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
returnType: 'array',
|
|
128
|
+
examples: ['{{fn.slice(trigger.items, 0, 3)}}'],
|
|
129
|
+
execute: (arr, start, end) => {
|
|
130
|
+
if (!Array.isArray(arr)) {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
return arr.slice(Number(start), end !== undefined ? Number(end) : undefined);
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
includes: {
|
|
137
|
+
name: 'includes',
|
|
138
|
+
description: 'Checks if an array includes a value',
|
|
139
|
+
category: 'array',
|
|
140
|
+
signature: 'includes(arr, value)',
|
|
141
|
+
args: [
|
|
142
|
+
{
|
|
143
|
+
name: 'arr',
|
|
144
|
+
type: 'array',
|
|
145
|
+
required: true,
|
|
146
|
+
description: 'Input array',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'value',
|
|
150
|
+
type: 'any',
|
|
151
|
+
required: true,
|
|
152
|
+
description: 'Value to search for',
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
returnType: 'boolean',
|
|
156
|
+
examples: ['{{fn.includes(trigger.roles, "admin")}}'],
|
|
157
|
+
execute: (arr, value) => {
|
|
158
|
+
if (!Array.isArray(arr)) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return arr.includes(value);
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
reverse: {
|
|
165
|
+
name: 'reverse',
|
|
166
|
+
description: 'Reverses the order of array elements',
|
|
167
|
+
category: 'array',
|
|
168
|
+
signature: 'reverse(arr)',
|
|
169
|
+
args: [
|
|
170
|
+
{
|
|
171
|
+
name: 'arr',
|
|
172
|
+
type: 'array',
|
|
173
|
+
required: true,
|
|
174
|
+
description: 'Input array',
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
returnType: 'array',
|
|
178
|
+
examples: ['{{fn.reverse(trigger.items)}}'],
|
|
179
|
+
execute: (arr) => {
|
|
180
|
+
if (!Array.isArray(arr)) {
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
return [...arr].reverse();
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
unique: {
|
|
187
|
+
name: 'unique',
|
|
188
|
+
description: 'Returns unique elements from an array',
|
|
189
|
+
category: 'array',
|
|
190
|
+
signature: 'unique(arr)',
|
|
191
|
+
args: [
|
|
192
|
+
{
|
|
193
|
+
name: 'arr',
|
|
194
|
+
type: 'array',
|
|
195
|
+
required: true,
|
|
196
|
+
description: 'Input array',
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
returnType: 'array',
|
|
200
|
+
examples: ['{{fn.unique(trigger.tags)}}'],
|
|
201
|
+
execute: (arr) => {
|
|
202
|
+
if (!Array.isArray(arr)) {
|
|
203
|
+
return [];
|
|
204
|
+
}
|
|
205
|
+
return Array.from(new Set(arr));
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
flatten: {
|
|
209
|
+
name: 'flatten',
|
|
210
|
+
description: 'Flattens a nested array by one level',
|
|
211
|
+
category: 'array',
|
|
212
|
+
signature: 'flatten(arr)',
|
|
213
|
+
args: [
|
|
214
|
+
{
|
|
215
|
+
name: 'arr',
|
|
216
|
+
type: 'array',
|
|
217
|
+
required: true,
|
|
218
|
+
description: 'Input array',
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
returnType: 'array',
|
|
222
|
+
examples: ['{{fn.flatten([[1, 2], [3, 4]])}}'],
|
|
223
|
+
execute: (arr) => {
|
|
224
|
+
if (!Array.isArray(arr)) {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
return arr.flat();
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
compact: {
|
|
231
|
+
name: 'compact',
|
|
232
|
+
description: 'Removes falsy values from an array',
|
|
233
|
+
category: 'array',
|
|
234
|
+
signature: 'compact(arr)',
|
|
235
|
+
args: [
|
|
236
|
+
{
|
|
237
|
+
name: 'arr',
|
|
238
|
+
type: 'array',
|
|
239
|
+
required: true,
|
|
240
|
+
description: 'Input array',
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
returnType: 'array',
|
|
244
|
+
examples: ['{{fn.compact([0, 1, false, 2, "", 3])}}'],
|
|
245
|
+
execute: (arr) => {
|
|
246
|
+
if (!Array.isArray(arr)) {
|
|
247
|
+
return [];
|
|
248
|
+
}
|
|
249
|
+
return arr.filter(Boolean);
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
};
|