@abyss-project/console 1.0.41 → 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.
Files changed (74) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +1 -2
  3. package/dist/types/constants/workflow.constants.d.ts +1 -0
  4. package/dist/types/constants/workflow.constants.js +2 -1
  5. package/dist/types/interface/models/workflow-webhook.model.d.ts +1 -0
  6. package/dist/utils/webhook-trigger.utils.d.ts +1 -6
  7. package/dist/utils/webhook-trigger.utils.js +33 -314
  8. package/dist/workflow-expressions/index.d.ts +5 -17
  9. package/dist/workflow-expressions/index.js +9 -58
  10. package/dist/workflow-expressions/resolver.d.ts +2 -6
  11. package/dist/workflow-expressions/resolver.js +31 -220
  12. package/dist/workflow-expressions/types.d.ts +21 -118
  13. package/dist/workflow-expressions/types.js +2 -20
  14. package/package.json +1 -1
  15. package/dist/expressions/functions/array.d.ts +0 -2
  16. package/dist/expressions/functions/array.js +0 -252
  17. package/dist/expressions/functions/crypto.d.ts +0 -2
  18. package/dist/expressions/functions/crypto.js +0 -101
  19. package/dist/expressions/functions/datetime.d.ts +0 -2
  20. package/dist/expressions/functions/datetime.js +0 -256
  21. package/dist/expressions/functions/index.d.ts +0 -7
  22. package/dist/expressions/functions/index.js +0 -46
  23. package/dist/expressions/functions/math.d.ts +0 -2
  24. package/dist/expressions/functions/math.js +0 -174
  25. package/dist/expressions/functions/string.d.ts +0 -2
  26. package/dist/expressions/functions/string.js +0 -301
  27. package/dist/expressions/functions/utility.d.ts +0 -2
  28. package/dist/expressions/functions/utility.js +0 -230
  29. package/dist/expressions/helpers.d.ts +0 -26
  30. package/dist/expressions/helpers.js +0 -132
  31. package/dist/expressions/index.d.ts +0 -5
  32. package/dist/expressions/index.js +0 -16
  33. package/dist/expressions/mapper.d.ts +0 -9
  34. package/dist/expressions/mapper.js +0 -88
  35. package/dist/expressions/parser.d.ts +0 -3
  36. package/dist/expressions/parser.js +0 -97
  37. package/dist/expressions/pipes/array-pipes.d.ts +0 -2
  38. package/dist/expressions/pipes/array-pipes.js +0 -248
  39. package/dist/expressions/pipes/index.d.ts +0 -8
  40. package/dist/expressions/pipes/index.js +0 -40
  41. package/dist/expressions/pipes/object-pipes.d.ts +0 -2
  42. package/dist/expressions/pipes/object-pipes.js +0 -243
  43. package/dist/expressions/pipes/string-pipes.d.ts +0 -9
  44. package/dist/expressions/pipes/string-pipes.js +0 -178
  45. package/dist/expressions/resolver.d.ts +0 -12
  46. package/dist/expressions/resolver.js +0 -88
  47. package/dist/expressions/types.d.ts +0 -36
  48. package/dist/expressions/types.js +0 -2
  49. package/dist/workflow-expressions/functions/array.d.ts +0 -2
  50. package/dist/workflow-expressions/functions/array.js +0 -252
  51. package/dist/workflow-expressions/functions/crypto.d.ts +0 -2
  52. package/dist/workflow-expressions/functions/crypto.js +0 -101
  53. package/dist/workflow-expressions/functions/datetime.d.ts +0 -2
  54. package/dist/workflow-expressions/functions/datetime.js +0 -256
  55. package/dist/workflow-expressions/functions/index.d.ts +0 -7
  56. package/dist/workflow-expressions/functions/index.js +0 -46
  57. package/dist/workflow-expressions/functions/math.d.ts +0 -2
  58. package/dist/workflow-expressions/functions/math.js +0 -174
  59. package/dist/workflow-expressions/functions/string.d.ts +0 -2
  60. package/dist/workflow-expressions/functions/string.js +0 -301
  61. package/dist/workflow-expressions/functions/utility.d.ts +0 -2
  62. package/dist/workflow-expressions/functions/utility.js +0 -230
  63. package/dist/workflow-expressions/helpers.d.ts +0 -71
  64. package/dist/workflow-expressions/helpers.js +0 -262
  65. package/dist/workflow-expressions/parser.d.ts +0 -8
  66. package/dist/workflow-expressions/parser.js +0 -456
  67. package/dist/workflow-expressions/pipes/array-pipes.d.ts +0 -2
  68. package/dist/workflow-expressions/pipes/array-pipes.js +0 -248
  69. package/dist/workflow-expressions/pipes/index.d.ts +0 -8
  70. package/dist/workflow-expressions/pipes/index.js +0 -40
  71. package/dist/workflow-expressions/pipes/object-pipes.d.ts +0 -2
  72. package/dist/workflow-expressions/pipes/object-pipes.js +0 -243
  73. package/dist/workflow-expressions/pipes/string-pipes.d.ts +0 -9
  74. package/dist/workflow-expressions/pipes/string-pipes.js +0 -178
@@ -1,18 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveExpression = exports.interpolateString = exports.evaluateExpression = exports.resolvePathValue = exports.buildResolverContext = void 0;
4
- const parser_1 = require("./parser");
5
- const functions_1 = require("./functions");
6
- const pipes_1 = require("./pipes");
3
+ exports.interpolateTemplate = exports.resolvePathValue = exports.buildResolverContext = void 0;
7
4
  function buildResolverContext(workflowContext) {
8
5
  var _a;
9
6
  if (!workflowContext) {
10
7
  return {};
11
8
  }
12
9
  const context = {};
13
- if (workflowContext.triggerData) {
14
- context.trigger = workflowContext.triggerData;
15
- context.triggerData = workflowContext.triggerData;
10
+ if (workflowContext.trigger) {
11
+ context.trigger = workflowContext.trigger;
16
12
  }
17
13
  if (workflowContext.triggers) {
18
14
  context.triggers = workflowContext.triggers;
@@ -41,235 +37,50 @@ function buildResolverContext(workflowContext) {
41
37
  if (workflowContext.secrets) {
42
38
  context.secret = workflowContext.secrets;
43
39
  }
44
- context.project = {
45
- id: workflowContext.projectId,
46
- ...(workflowContext.projectName ? { name: workflowContext.projectName } : {}),
47
- };
48
- if (workflowContext.workflowId) {
49
- context.workflow = {
50
- id: workflowContext.workflowId,
51
- };
40
+ if (workflowContext.project) {
41
+ context.project = workflowContext.project;
42
+ }
43
+ if (workflowContext.workflow) {
44
+ context.workflow = workflowContext.workflow;
52
45
  }
53
46
  return context;
54
47
  }
55
48
  exports.buildResolverContext = buildResolverContext;
56
49
  function resolvePathValue(path, context) {
57
- const segments = (0, parser_1.parsePathSegments)(path);
50
+ if (!path)
51
+ return undefined;
52
+ const segments = path.split('.');
58
53
  let current = context;
59
54
  for (const segment of segments) {
60
55
  if (current === null || current === undefined) {
61
56
  return undefined;
62
57
  }
63
- if (/^\d+$/.test(segment) && Array.isArray(current)) {
64
- current = current[Number(segment)];
65
- }
66
- else if (typeof current === 'object') {
67
- current = current[segment];
68
- }
69
- else {
70
- return undefined;
71
- }
58
+ current = current[segment];
72
59
  }
73
60
  return current;
74
61
  }
75
62
  exports.resolvePathValue = resolvePathValue;
76
- function evaluateExpression(parsed, context, secretsMap) {
77
- switch (parsed.type) {
78
- case 'literal':
79
- return parsed.literalValue;
80
- case 'path':
81
- return evaluatePathExpression(parsed, context, secretsMap);
82
- case 'function':
83
- return evaluateFunctionExpression(parsed, context, secretsMap);
84
- case 'binary':
85
- return evaluateBinaryExpression(parsed, context, secretsMap);
86
- case 'unary':
87
- return evaluateUnaryExpression(parsed, context, secretsMap);
88
- case 'ternary':
89
- return evaluateTernaryExpression(parsed, context, secretsMap);
90
- case 'group':
91
- return evaluateExpression(parsed.expression, context, secretsMap);
92
- default:
93
- return undefined;
94
- }
95
- }
96
- exports.evaluateExpression = evaluateExpression;
97
- function evaluatePathExpression(parsed, context, secretsMap) {
98
- var _a;
99
- if (parsed.source === 'secret' && secretsMap && parsed.path) {
100
- const secretKey = parsed.path.replace('secret.', '');
101
- let value = (_a = secretsMap.get(secretKey)) !== null && _a !== void 0 ? _a : `[Secret: ${secretKey}]`;
102
- if (parsed.operations && parsed.operations.length > 0) {
103
- for (const op of parsed.operations) {
104
- try {
105
- const resolvedArgs = op.args.map((arg) => {
106
- if (typeof arg === 'string' && arg.includes('.')) {
107
- const resolved = resolvePathValue(arg, context);
108
- return resolved !== undefined ? resolved : arg;
109
- }
110
- return arg;
111
- });
112
- value = (0, pipes_1.executePipeOperation)(op.name, value, resolvedArgs);
113
- }
114
- catch (error) {
115
- return `[Error: ${error.message}]`;
116
- }
117
- }
118
- }
119
- return value;
120
- }
121
- let value = parsed.path ? resolvePathValue(parsed.path, context) : undefined;
122
- if (parsed.operations && parsed.operations.length > 0) {
123
- for (const op of parsed.operations) {
124
- try {
125
- const resolvedArgs = op.args.map((arg) => {
126
- if (typeof arg === 'string' && arg.includes('.')) {
127
- const resolved = resolvePathValue(arg, context);
128
- return resolved !== undefined ? resolved : arg;
129
- }
130
- return arg;
131
- });
132
- value = (0, pipes_1.executePipeOperation)(op.name, value, resolvedArgs);
133
- }
134
- catch (error) {
135
- return `[Error: ${error.message}]`;
136
- }
137
- }
138
- }
139
- return value;
140
- }
141
- function evaluateFunctionExpression(parsed, context, secretsMap) {
142
- if (!parsed.functionName) {
143
- return undefined;
144
- }
145
- const resolvedArgs = (parsed.functionArgs || []).map((arg) => {
146
- if (typeof arg === 'string' && arg.includes('.')) {
147
- const resolved = resolvePathValue(arg, context);
148
- return resolved !== undefined ? resolved : arg;
149
- }
150
- return arg;
151
- });
152
- try {
153
- let value = (0, functions_1.executeFunction)(parsed.functionName, resolvedArgs);
154
- if (parsed.operations && parsed.operations.length > 0) {
155
- for (const op of parsed.operations) {
156
- try {
157
- const resolvedPipeArgs = op.args.map((arg) => {
158
- if (typeof arg === 'string' && arg.includes('.')) {
159
- const resolved = resolvePathValue(arg, context);
160
- return resolved !== undefined ? resolved : arg;
161
- }
162
- return arg;
163
- });
164
- value = (0, pipes_1.executePipeOperation)(op.name, value, resolvedPipeArgs);
165
- }
166
- catch (error) {
167
- return `[Error: ${error.message}]`;
168
- }
169
- }
170
- }
171
- return value;
172
- }
173
- catch (error) {
174
- return `[Error: ${error.message}]`;
175
- }
176
- }
177
- function evaluateBinaryExpression(parsed, context, secretsMap) {
178
- const left = evaluateExpression(parsed.left, context, secretsMap);
179
- const right = evaluateExpression(parsed.right, context, secretsMap);
180
- switch (parsed.operator) {
181
- case '+':
182
- return left + right;
183
- case '-':
184
- return left - right;
185
- case '*':
186
- return left * right;
187
- case '/':
188
- return left / right;
189
- case '%':
190
- return left % right;
191
- case '**':
192
- return Math.pow(left, right);
193
- case '==':
194
- case '===':
195
- return left === right;
196
- case '!=':
197
- case '!==':
198
- return left !== right;
199
- case '<':
200
- return left < right;
201
- case '>':
202
- return left > right;
203
- case '<=':
204
- return left <= right;
205
- case '>=':
206
- return left >= right;
207
- case '&&':
208
- return left && right;
209
- case '||':
210
- return left || right;
211
- default:
212
- return undefined;
213
- }
214
- }
215
- function evaluateUnaryExpression(parsed, context, secretsMap) {
216
- const operand = evaluateExpression(parsed.operand, context, secretsMap);
217
- switch (parsed.operator) {
218
- case '!':
219
- return !operand;
220
- case '-':
221
- return -operand;
222
- default:
223
- return undefined;
224
- }
225
- }
226
- function evaluateTernaryExpression(parsed, context, secretsMap) {
227
- const condition = evaluateExpression(parsed.condition, context, secretsMap);
228
- return condition
229
- ? evaluateExpression(parsed.consequent, context, secretsMap)
230
- : evaluateExpression(parsed.alternate, context, secretsMap);
231
- }
232
- function interpolateString(template, context, secretsMap, options = {}) {
233
- const tokens = (0, parser_1.tokenizeTemplate)(template);
234
- let result = '';
235
- for (const token of tokens) {
236
- if (token.type === 'text') {
237
- result += token.value;
63
+ function interpolateTemplate(template, context) {
64
+ if (!template || typeof template !== 'string') {
65
+ return String(template || '');
66
+ }
67
+ const pattern = /\{\{(.+?)\}\}/g;
68
+ const matches = [...template.matchAll(pattern)];
69
+ if (matches.length === 0) {
70
+ return template;
71
+ }
72
+ let result = template;
73
+ for (const match of matches) {
74
+ const [fullMatch, expression] = match;
75
+ try {
76
+ const value = resolvePathValue(expression.trim(), context);
77
+ result = result.replace(fullMatch, String(value !== null && value !== void 0 ? value : ''));
238
78
  }
239
- else if (token.type === 'expression') {
240
- try {
241
- const parsed = (0, parser_1.parseExpression)(token.value);
242
- const value = evaluateExpression(parsed, context, secretsMap);
243
- if (parsed.type === 'path' &&
244
- parsed.source === 'secret' &&
245
- options.maskSecrets) {
246
- result += '••••••••';
247
- }
248
- else if (value !== undefined && value !== null) {
249
- result += typeof value === 'object' ? JSON.stringify(value) : String(value);
250
- }
251
- else {
252
- result += `{{${token.value}}}`;
253
- }
254
- }
255
- catch (error) {
256
- result += `[Error: ${error.message}]`;
257
- }
79
+ catch (error) {
80
+ console.error(`Failed to interpolate ${expression}:`, error);
81
+ result = result.replace(fullMatch, `{{${expression}}}`);
258
82
  }
259
83
  }
260
84
  return result;
261
85
  }
262
- exports.interpolateString = interpolateString;
263
- function resolveExpression(expression, context, secretsMap) {
264
- if (expression.includes('{{') && expression.includes('}}')) {
265
- const tokens = (0, parser_1.tokenizeTemplate)(expression);
266
- if (tokens.length === 1 && tokens[0].type === 'expression') {
267
- const parsed = (0, parser_1.parseExpression)(tokens[0].value);
268
- return evaluateExpression(parsed, context, secretsMap);
269
- }
270
- return interpolateString(expression, context, secretsMap);
271
- }
272
- const parsed = (0, parser_1.parseExpression)(expression);
273
- return evaluateExpression(parsed, context, secretsMap);
274
- }
275
- exports.resolveExpression = resolveExpression;
86
+ exports.interpolateTemplate = interpolateTemplate;
@@ -1,5 +1,5 @@
1
- import type { ResourceMapping as GenericResourceMapping } from '../expressions/types';
2
- import type { WorkflowTriggerType } from '../types/enum/workflow.enum';
1
+ import type { WorkflowStatus, WorkflowTemplate, WorkflowTriggerType } from '../types/enum/workflow.enum';
2
+ import type { IWorkflowSettings } from '../types';
3
3
  export declare enum DataSourceType {
4
4
  WORKFLOW_TRIGGER = "trigger",
5
5
  WORKFLOW_STEPS = "steps",
@@ -9,93 +9,22 @@ export declare enum DataSourceType {
9
9
  APPLICATIONS = "app",
10
10
  SECRETS = "secret",
11
11
  PROJECT = "project",
12
- ABYSS_CONFIG = "abyss",
13
- FUNCTIONS = "fn",
14
- OPERATORS = "op"
15
- }
16
- export interface TriggerInfo {
17
- id: string;
18
- name: string;
19
- type: WorkflowTriggerType;
20
- isActive: boolean;
21
- }
22
- export declare const OPERATOR_PRECEDENCE: Record<string, number>;
23
- export type ParsedExpression = PathExpression | FunctionExpression | BinaryExpression | UnaryExpression | TernaryExpression | LiteralExpression | GroupExpression;
24
- export interface BaseExpression {
25
- type: string;
26
- isValid: boolean;
27
- error?: string;
28
- }
29
- export interface PathExpression extends BaseExpression {
30
- type: 'path';
31
- path: string;
32
- source: DataSourceType | null;
33
- operations?: PipeOperation[];
34
- resolvedValue?: unknown;
35
- }
36
- export interface FunctionExpression extends BaseExpression {
37
- type: 'function';
38
- isFunction: true;
39
- functionName: string;
40
- functionArgs: unknown[];
41
- operations?: PipeOperation[];
42
- resolvedValue?: unknown;
43
- }
44
- export interface BinaryExpression extends BaseExpression {
45
- type: 'binary';
46
- operator: string;
47
- left: ParsedExpression;
48
- right: ParsedExpression;
49
- }
50
- export interface UnaryExpression extends BaseExpression {
51
- type: 'unary';
52
- operator: string;
53
- operand: ParsedExpression;
54
- }
55
- export interface TernaryExpression extends BaseExpression {
56
- type: 'ternary';
57
- condition: ParsedExpression;
58
- consequent: ParsedExpression;
59
- alternate: ParsedExpression;
60
- }
61
- export interface LiteralExpression extends BaseExpression {
62
- type: 'literal';
63
- literalType: 'string' | 'number' | 'boolean' | 'null';
64
- literalValue: unknown;
65
- }
66
- export interface GroupExpression extends BaseExpression {
67
- type: 'group';
68
- expression: ParsedExpression;
69
- }
70
- export interface PipeOperation {
71
- name: string;
72
- args: unknown[];
73
- description?: string;
74
- category?: OperationCategory;
75
- }
76
- export type OperationCategory = 'string' | 'array' | 'object' | 'number' | 'date' | 'encoding' | 'formatting';
77
- export interface BuiltInFunction {
78
- name: string;
79
- description: string;
80
- category: FunctionCategory;
81
- signature: string;
82
- args: FunctionArg[];
83
- returnType: string;
84
- examples: string[];
85
- execute: (...args: unknown[]) => unknown;
86
- }
87
- export type FunctionCategory = 'datetime' | 'string' | 'math' | 'crypto' | 'array' | 'utility' | 'encoding';
88
- export interface FunctionArg {
89
- name: string;
90
- type: string;
91
- required: boolean;
92
- description: string;
12
+ WORKFLOW = "workflow"
93
13
  }
94
14
  export interface WorkflowContext {
95
- projectId: string;
96
- projectName?: string;
97
- workflowId?: string;
98
- triggerData?: Record<string, unknown>;
15
+ project: {
16
+ id: string;
17
+ name: string;
18
+ };
19
+ workflow: {
20
+ id: string;
21
+ name: string;
22
+ description: string | null;
23
+ template: WorkflowTemplate | null;
24
+ status: WorkflowStatus;
25
+ settings: IWorkflowSettings;
26
+ };
27
+ trigger?: Record<string, unknown>;
99
28
  triggers?: Record<string, Record<string, unknown>>;
100
29
  stepExecutions?: Record<string, StepExecution>;
101
30
  variables?: Record<string, unknown>;
@@ -119,35 +48,9 @@ export interface WorkflowStep {
119
48
  type: string;
120
49
  config?: Record<string, unknown>;
121
50
  }
122
- export interface ExpressionToken {
123
- type: 'text' | 'expression' | 'reference' | 'function' | 'error';
124
- value: string;
125
- rawValue: string;
126
- start: number;
127
- end: number;
128
- parsed?: ParsedExpression;
129
- isSecret?: boolean;
130
- }
131
- export interface ValidationResult {
132
- isValid: boolean;
133
- errors: ValidationError[];
134
- warnings: ValidationWarning[];
135
- }
136
- export interface ValidationError {
137
- type: 'error';
138
- message: string;
139
- start: number;
140
- end: number;
141
- path?: string;
142
- }
143
- export interface ValidationWarning {
144
- type: 'warning';
145
- message: string;
146
- start: number;
147
- end: number;
148
- path?: string;
149
- suggestion?: string;
150
- }
151
- export interface WorkflowResourceMapping extends Omit<GenericResourceMapping<DataSourceType>, 'source'> {
152
- source: DataSourceType;
51
+ export interface TriggerInfo {
52
+ id: string;
53
+ name: string;
54
+ type: WorkflowTriggerType;
55
+ isActive: boolean;
153
56
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OPERATOR_PRECEDENCE = exports.DataSourceType = void 0;
3
+ exports.DataSourceType = void 0;
4
4
  var DataSourceType;
5
5
  (function (DataSourceType) {
6
6
  DataSourceType["WORKFLOW_TRIGGER"] = "trigger";
@@ -11,23 +11,5 @@ var DataSourceType;
11
11
  DataSourceType["APPLICATIONS"] = "app";
12
12
  DataSourceType["SECRETS"] = "secret";
13
13
  DataSourceType["PROJECT"] = "project";
14
- DataSourceType["ABYSS_CONFIG"] = "abyss";
15
- DataSourceType["FUNCTIONS"] = "fn";
16
- DataSourceType["OPERATORS"] = "op";
14
+ DataSourceType["WORKFLOW"] = "workflow";
17
15
  })(DataSourceType || (exports.DataSourceType = DataSourceType = {}));
18
- exports.OPERATOR_PRECEDENCE = {
19
- '||': 1,
20
- '&&': 2,
21
- '==': 3,
22
- '!=': 3,
23
- '<': 4,
24
- '>': 4,
25
- '<=': 4,
26
- '>=': 4,
27
- '+': 5,
28
- '-': 5,
29
- '*': 6,
30
- '/': 6,
31
- '%': 6,
32
- '**': 7,
33
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abyss-project/console",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "description": "Core package to interact with AbyssConsole",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,2 +0,0 @@
1
- import type { BuiltInFunction } from '../types';
2
- export declare const arrayFunctions: Record<string, BuiltInFunction>;