@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,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cryptoFunctions = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
exports.cryptoFunctions = {
|
|
6
|
+
md5: {
|
|
7
|
+
name: 'md5',
|
|
8
|
+
description: 'Generates an MD5 hash of the input string',
|
|
9
|
+
category: 'crypto',
|
|
10
|
+
signature: 'md5(str)',
|
|
11
|
+
args: [
|
|
12
|
+
{
|
|
13
|
+
name: 'str',
|
|
14
|
+
type: 'string',
|
|
15
|
+
required: true,
|
|
16
|
+
description: 'Input string',
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
returnType: 'string',
|
|
20
|
+
examples: ['{{fn.md5(trigger.password)}}'],
|
|
21
|
+
execute: (str) => {
|
|
22
|
+
return (0, crypto_1.createHash)('md5').update(String(str)).digest('hex');
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
sha1: {
|
|
26
|
+
name: 'sha1',
|
|
27
|
+
description: 'Generates a SHA-1 hash of the input string',
|
|
28
|
+
category: 'crypto',
|
|
29
|
+
signature: 'sha1(str)',
|
|
30
|
+
args: [
|
|
31
|
+
{
|
|
32
|
+
name: 'str',
|
|
33
|
+
type: 'string',
|
|
34
|
+
required: true,
|
|
35
|
+
description: 'Input string',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
returnType: 'string',
|
|
39
|
+
examples: ['{{fn.sha1(trigger.data)}}'],
|
|
40
|
+
execute: (str) => {
|
|
41
|
+
return (0, crypto_1.createHash)('sha1').update(String(str)).digest('hex');
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
sha256: {
|
|
45
|
+
name: 'sha256',
|
|
46
|
+
description: 'Generates a SHA-256 hash of the input string',
|
|
47
|
+
category: 'crypto',
|
|
48
|
+
signature: 'sha256(str)',
|
|
49
|
+
args: [
|
|
50
|
+
{
|
|
51
|
+
name: 'str',
|
|
52
|
+
type: 'string',
|
|
53
|
+
required: true,
|
|
54
|
+
description: 'Input string',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
returnType: 'string',
|
|
58
|
+
examples: ['{{fn.sha256(trigger.data)}}'],
|
|
59
|
+
execute: (str) => {
|
|
60
|
+
return (0, crypto_1.createHash)('sha256').update(String(str)).digest('hex');
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
sha512: {
|
|
64
|
+
name: 'sha512',
|
|
65
|
+
description: 'Generates a SHA-512 hash of the input string',
|
|
66
|
+
category: 'crypto',
|
|
67
|
+
signature: 'sha512(str)',
|
|
68
|
+
args: [
|
|
69
|
+
{
|
|
70
|
+
name: 'str',
|
|
71
|
+
type: 'string',
|
|
72
|
+
required: true,
|
|
73
|
+
description: 'Input string',
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
returnType: 'string',
|
|
77
|
+
examples: ['{{fn.sha512(trigger.data)}}'],
|
|
78
|
+
execute: (str) => {
|
|
79
|
+
return (0, crypto_1.createHash)('sha512').update(String(str)).digest('hex');
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
randomBytes: {
|
|
83
|
+
name: 'randomBytes',
|
|
84
|
+
description: 'Generates random bytes as a hex string',
|
|
85
|
+
category: 'crypto',
|
|
86
|
+
signature: 'randomBytes(size)',
|
|
87
|
+
args: [
|
|
88
|
+
{
|
|
89
|
+
name: 'size',
|
|
90
|
+
type: 'number',
|
|
91
|
+
required: true,
|
|
92
|
+
description: 'Number of bytes',
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
returnType: 'string',
|
|
96
|
+
examples: ['{{fn.randomBytes(16)}}'],
|
|
97
|
+
execute: (size) => {
|
|
98
|
+
return (0, crypto_1.randomBytes)(Number(size)).toString('hex');
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.datetimeFunctions = void 0;
|
|
4
|
+
const date_fns_1 = require("date-fns");
|
|
5
|
+
exports.datetimeFunctions = {
|
|
6
|
+
now: {
|
|
7
|
+
name: 'now',
|
|
8
|
+
description: 'Returns the current date and time in ISO format',
|
|
9
|
+
category: 'datetime',
|
|
10
|
+
signature: 'now()',
|
|
11
|
+
args: [],
|
|
12
|
+
returnType: 'string',
|
|
13
|
+
examples: ['{{fn.now()}}', '{{now()}}'],
|
|
14
|
+
execute: () => new Date().toISOString(),
|
|
15
|
+
},
|
|
16
|
+
timestamp: {
|
|
17
|
+
name: 'timestamp',
|
|
18
|
+
description: 'Returns the current Unix timestamp in milliseconds',
|
|
19
|
+
category: 'datetime',
|
|
20
|
+
signature: 'timestamp()',
|
|
21
|
+
args: [],
|
|
22
|
+
returnType: 'number',
|
|
23
|
+
examples: ['{{fn.timestamp()}}', '{{timestamp()}}'],
|
|
24
|
+
execute: () => Date.now(),
|
|
25
|
+
},
|
|
26
|
+
formatDate: {
|
|
27
|
+
name: 'formatDate',
|
|
28
|
+
description: 'Formats a date string with the specified format',
|
|
29
|
+
category: 'datetime',
|
|
30
|
+
signature: 'formatDate(date, format)',
|
|
31
|
+
args: [
|
|
32
|
+
{
|
|
33
|
+
name: 'date',
|
|
34
|
+
type: 'string',
|
|
35
|
+
required: true,
|
|
36
|
+
description: 'ISO date string',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'format',
|
|
40
|
+
type: 'string',
|
|
41
|
+
required: true,
|
|
42
|
+
description: 'Format pattern (e.g., yyyy-MM-dd)',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
returnType: 'string',
|
|
46
|
+
examples: ['{{fn.formatDate(trigger.createdAt, "yyyy-MM-dd")}}'],
|
|
47
|
+
execute: (date, formatStr) => {
|
|
48
|
+
const d = new Date(date);
|
|
49
|
+
return (0, date_fns_1.format)(d, formatStr);
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
addDays: {
|
|
53
|
+
name: 'addDays',
|
|
54
|
+
description: 'Adds days to a date',
|
|
55
|
+
category: 'datetime',
|
|
56
|
+
signature: 'addDays(date, days)',
|
|
57
|
+
args: [
|
|
58
|
+
{
|
|
59
|
+
name: 'date',
|
|
60
|
+
type: 'string',
|
|
61
|
+
required: true,
|
|
62
|
+
description: 'ISO date string',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'days',
|
|
66
|
+
type: 'number',
|
|
67
|
+
required: true,
|
|
68
|
+
description: 'Number of days to add',
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
returnType: 'string',
|
|
72
|
+
examples: ['{{fn.addDays(fn.now(), 7)}}'],
|
|
73
|
+
execute: (date, days) => {
|
|
74
|
+
const d = new Date(date);
|
|
75
|
+
return (0, date_fns_1.addDays)(d, days).toISOString();
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
addHours: {
|
|
79
|
+
name: 'addHours',
|
|
80
|
+
description: 'Adds hours to a date',
|
|
81
|
+
category: 'datetime',
|
|
82
|
+
signature: 'addHours(date, hours)',
|
|
83
|
+
args: [
|
|
84
|
+
{
|
|
85
|
+
name: 'date',
|
|
86
|
+
type: 'string',
|
|
87
|
+
required: true,
|
|
88
|
+
description: 'ISO date string',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'hours',
|
|
92
|
+
type: 'number',
|
|
93
|
+
required: true,
|
|
94
|
+
description: 'Number of hours to add',
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
returnType: 'string',
|
|
98
|
+
examples: ['{{fn.addHours(fn.now(), 24)}}'],
|
|
99
|
+
execute: (date, hours) => {
|
|
100
|
+
const d = new Date(date);
|
|
101
|
+
return (0, date_fns_1.addHours)(d, hours).toISOString();
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
addMinutes: {
|
|
105
|
+
name: 'addMinutes',
|
|
106
|
+
description: 'Adds minutes to a date',
|
|
107
|
+
category: 'datetime',
|
|
108
|
+
signature: 'addMinutes(date, minutes)',
|
|
109
|
+
args: [
|
|
110
|
+
{
|
|
111
|
+
name: 'date',
|
|
112
|
+
type: 'string',
|
|
113
|
+
required: true,
|
|
114
|
+
description: 'ISO date string',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'minutes',
|
|
118
|
+
type: 'number',
|
|
119
|
+
required: true,
|
|
120
|
+
description: 'Number of minutes to add',
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
returnType: 'string',
|
|
124
|
+
examples: ['{{fn.addMinutes(fn.now(), 30)}}'],
|
|
125
|
+
execute: (date, minutes) => {
|
|
126
|
+
const d = new Date(date);
|
|
127
|
+
return (0, date_fns_1.addMinutes)(d, minutes).toISOString();
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
addSeconds: {
|
|
131
|
+
name: 'addSeconds',
|
|
132
|
+
description: 'Adds seconds to a date',
|
|
133
|
+
category: 'datetime',
|
|
134
|
+
signature: 'addSeconds(date, seconds)',
|
|
135
|
+
args: [
|
|
136
|
+
{
|
|
137
|
+
name: 'date',
|
|
138
|
+
type: 'string',
|
|
139
|
+
required: true,
|
|
140
|
+
description: 'ISO date string',
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'seconds',
|
|
144
|
+
type: 'number',
|
|
145
|
+
required: true,
|
|
146
|
+
description: 'Number of seconds to add',
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
returnType: 'string',
|
|
150
|
+
examples: ['{{fn.addSeconds(fn.now(), 60)}}'],
|
|
151
|
+
execute: (date, seconds) => {
|
|
152
|
+
const d = new Date(date);
|
|
153
|
+
return (0, date_fns_1.addSeconds)(d, seconds).toISOString();
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
diffDays: {
|
|
157
|
+
name: 'diffDays',
|
|
158
|
+
description: 'Returns the difference in days between two dates',
|
|
159
|
+
category: 'datetime',
|
|
160
|
+
signature: 'diffDays(date1, date2)',
|
|
161
|
+
args: [
|
|
162
|
+
{
|
|
163
|
+
name: 'date1',
|
|
164
|
+
type: 'string',
|
|
165
|
+
required: true,
|
|
166
|
+
description: 'First ISO date string',
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: 'date2',
|
|
170
|
+
type: 'string',
|
|
171
|
+
required: true,
|
|
172
|
+
description: 'Second ISO date string',
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
returnType: 'number',
|
|
176
|
+
examples: ['{{fn.diffDays(trigger.startDate, fn.now())}}'],
|
|
177
|
+
execute: (date1, date2) => {
|
|
178
|
+
return (0, date_fns_1.differenceInDays)(new Date(date1), new Date(date2));
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
diffHours: {
|
|
182
|
+
name: 'diffHours',
|
|
183
|
+
description: 'Returns the difference in hours between two dates',
|
|
184
|
+
category: 'datetime',
|
|
185
|
+
signature: 'diffHours(date1, date2)',
|
|
186
|
+
args: [
|
|
187
|
+
{
|
|
188
|
+
name: 'date1',
|
|
189
|
+
type: 'string',
|
|
190
|
+
required: true,
|
|
191
|
+
description: 'First ISO date string',
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: 'date2',
|
|
195
|
+
type: 'string',
|
|
196
|
+
required: true,
|
|
197
|
+
description: 'Second ISO date string',
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
returnType: 'number',
|
|
201
|
+
examples: ['{{fn.diffHours(trigger.startDate, fn.now())}}'],
|
|
202
|
+
execute: (date1, date2) => {
|
|
203
|
+
return (0, date_fns_1.differenceInHours)(new Date(date1), new Date(date2));
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
diffMinutes: {
|
|
207
|
+
name: 'diffMinutes',
|
|
208
|
+
description: 'Returns the difference in minutes between two dates',
|
|
209
|
+
category: 'datetime',
|
|
210
|
+
signature: 'diffMinutes(date1, date2)',
|
|
211
|
+
args: [
|
|
212
|
+
{
|
|
213
|
+
name: 'date1',
|
|
214
|
+
type: 'string',
|
|
215
|
+
required: true,
|
|
216
|
+
description: 'First ISO date string',
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: 'date2',
|
|
220
|
+
type: 'string',
|
|
221
|
+
required: true,
|
|
222
|
+
description: 'Second ISO date string',
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
returnType: 'number',
|
|
226
|
+
examples: ['{{fn.diffMinutes(trigger.startDate, fn.now())}}'],
|
|
227
|
+
execute: (date1, date2) => {
|
|
228
|
+
return (0, date_fns_1.differenceInMinutes)(new Date(date1), new Date(date2));
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
diffSeconds: {
|
|
232
|
+
name: 'diffSeconds',
|
|
233
|
+
description: 'Returns the difference in seconds between two dates',
|
|
234
|
+
category: 'datetime',
|
|
235
|
+
signature: 'diffSeconds(date1, date2)',
|
|
236
|
+
args: [
|
|
237
|
+
{
|
|
238
|
+
name: 'date1',
|
|
239
|
+
type: 'string',
|
|
240
|
+
required: true,
|
|
241
|
+
description: 'First ISO date string',
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: 'date2',
|
|
245
|
+
type: 'string',
|
|
246
|
+
required: true,
|
|
247
|
+
description: 'Second ISO date string',
|
|
248
|
+
},
|
|
249
|
+
],
|
|
250
|
+
returnType: 'number',
|
|
251
|
+
examples: ['{{fn.diffSeconds(trigger.startDate, fn.now())}}'],
|
|
252
|
+
execute: (date1, date2) => {
|
|
253
|
+
return (0, date_fns_1.differenceInSeconds)(new Date(date1), new Date(date2));
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BuiltInFunction, FunctionCategory } from '../types';
|
|
2
|
+
export declare const BUILT_IN_FUNCTIONS: Record<string, BuiltInFunction>;
|
|
3
|
+
export declare function executeFunction(name: string, args: unknown[]): unknown;
|
|
4
|
+
export declare function getFunctionsByCategory(category: FunctionCategory): Record<string, BuiltInFunction>;
|
|
5
|
+
export declare function getFunctionNames(): string[];
|
|
6
|
+
export declare function hasFunction(name: string): boolean;
|
|
7
|
+
export declare function getFunction(name: string): BuiltInFunction | undefined;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFunction = exports.hasFunction = exports.getFunctionNames = exports.getFunctionsByCategory = exports.executeFunction = exports.BUILT_IN_FUNCTIONS = void 0;
|
|
4
|
+
const datetime_1 = require("./datetime");
|
|
5
|
+
const string_1 = require("./string");
|
|
6
|
+
const math_1 = require("./math");
|
|
7
|
+
const crypto_1 = require("./crypto");
|
|
8
|
+
const array_1 = require("./array");
|
|
9
|
+
const utility_1 = require("./utility");
|
|
10
|
+
exports.BUILT_IN_FUNCTIONS = {
|
|
11
|
+
...datetime_1.datetimeFunctions,
|
|
12
|
+
...string_1.stringFunctions,
|
|
13
|
+
...math_1.mathFunctions,
|
|
14
|
+
...crypto_1.cryptoFunctions,
|
|
15
|
+
...array_1.arrayFunctions,
|
|
16
|
+
...utility_1.utilityFunctions,
|
|
17
|
+
};
|
|
18
|
+
function executeFunction(name, args) {
|
|
19
|
+
const func = exports.BUILT_IN_FUNCTIONS[name];
|
|
20
|
+
if (!func) {
|
|
21
|
+
throw new Error(`Unknown function: ${name}`);
|
|
22
|
+
}
|
|
23
|
+
return func.execute(...args);
|
|
24
|
+
}
|
|
25
|
+
exports.executeFunction = executeFunction;
|
|
26
|
+
function getFunctionsByCategory(category) {
|
|
27
|
+
return Object.entries(exports.BUILT_IN_FUNCTIONS)
|
|
28
|
+
.filter(([, func]) => func.category === category)
|
|
29
|
+
.reduce((acc, [name, func]) => {
|
|
30
|
+
acc[name] = func;
|
|
31
|
+
return acc;
|
|
32
|
+
}, {});
|
|
33
|
+
}
|
|
34
|
+
exports.getFunctionsByCategory = getFunctionsByCategory;
|
|
35
|
+
function getFunctionNames() {
|
|
36
|
+
return Object.keys(exports.BUILT_IN_FUNCTIONS);
|
|
37
|
+
}
|
|
38
|
+
exports.getFunctionNames = getFunctionNames;
|
|
39
|
+
function hasFunction(name) {
|
|
40
|
+
return name in exports.BUILT_IN_FUNCTIONS;
|
|
41
|
+
}
|
|
42
|
+
exports.hasFunction = hasFunction;
|
|
43
|
+
function getFunction(name) {
|
|
44
|
+
return exports.BUILT_IN_FUNCTIONS[name];
|
|
45
|
+
}
|
|
46
|
+
exports.getFunction = getFunction;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mathFunctions = void 0;
|
|
4
|
+
exports.mathFunctions = {
|
|
5
|
+
abs: {
|
|
6
|
+
name: 'abs',
|
|
7
|
+
description: 'Returns the absolute value of a number',
|
|
8
|
+
category: 'math',
|
|
9
|
+
signature: 'abs(num)',
|
|
10
|
+
args: [
|
|
11
|
+
{
|
|
12
|
+
name: 'num',
|
|
13
|
+
type: 'number',
|
|
14
|
+
required: true,
|
|
15
|
+
description: 'Input number',
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
returnType: 'number',
|
|
19
|
+
examples: ['{{fn.abs(-5)}}'],
|
|
20
|
+
execute: (num) => Math.abs(Number(num)),
|
|
21
|
+
},
|
|
22
|
+
ceil: {
|
|
23
|
+
name: 'ceil',
|
|
24
|
+
description: 'Rounds a number up to the nearest integer',
|
|
25
|
+
category: 'math',
|
|
26
|
+
signature: 'ceil(num)',
|
|
27
|
+
args: [
|
|
28
|
+
{
|
|
29
|
+
name: 'num',
|
|
30
|
+
type: 'number',
|
|
31
|
+
required: true,
|
|
32
|
+
description: 'Input number',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
returnType: 'number',
|
|
36
|
+
examples: ['{{fn.ceil(4.3)}}'],
|
|
37
|
+
execute: (num) => Math.ceil(Number(num)),
|
|
38
|
+
},
|
|
39
|
+
floor: {
|
|
40
|
+
name: 'floor',
|
|
41
|
+
description: 'Rounds a number down to the nearest integer',
|
|
42
|
+
category: 'math',
|
|
43
|
+
signature: 'floor(num)',
|
|
44
|
+
args: [
|
|
45
|
+
{
|
|
46
|
+
name: 'num',
|
|
47
|
+
type: 'number',
|
|
48
|
+
required: true,
|
|
49
|
+
description: 'Input number',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
returnType: 'number',
|
|
53
|
+
examples: ['{{fn.floor(4.7)}}'],
|
|
54
|
+
execute: (num) => Math.floor(Number(num)),
|
|
55
|
+
},
|
|
56
|
+
round: {
|
|
57
|
+
name: 'round',
|
|
58
|
+
description: 'Rounds a number to the nearest integer',
|
|
59
|
+
category: 'math',
|
|
60
|
+
signature: 'round(num)',
|
|
61
|
+
args: [
|
|
62
|
+
{
|
|
63
|
+
name: 'num',
|
|
64
|
+
type: 'number',
|
|
65
|
+
required: true,
|
|
66
|
+
description: 'Input number',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
returnType: 'number',
|
|
70
|
+
examples: ['{{fn.round(4.5)}}'],
|
|
71
|
+
execute: (num) => Math.round(Number(num)),
|
|
72
|
+
},
|
|
73
|
+
min: {
|
|
74
|
+
name: 'min',
|
|
75
|
+
description: 'Returns the smallest of the given numbers',
|
|
76
|
+
category: 'math',
|
|
77
|
+
signature: 'min(...nums)',
|
|
78
|
+
args: [
|
|
79
|
+
{
|
|
80
|
+
name: 'numbers',
|
|
81
|
+
type: 'number',
|
|
82
|
+
required: true,
|
|
83
|
+
description: 'Numbers to compare',
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
returnType: 'number',
|
|
87
|
+
examples: ['{{fn.min(5, 10, 2, 8)}}'],
|
|
88
|
+
execute: (...args) => Math.min(...args.map(Number)),
|
|
89
|
+
},
|
|
90
|
+
max: {
|
|
91
|
+
name: 'max',
|
|
92
|
+
description: 'Returns the largest of the given numbers',
|
|
93
|
+
category: 'math',
|
|
94
|
+
signature: 'max(...nums)',
|
|
95
|
+
args: [
|
|
96
|
+
{
|
|
97
|
+
name: 'numbers',
|
|
98
|
+
type: 'number',
|
|
99
|
+
required: true,
|
|
100
|
+
description: 'Numbers to compare',
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
returnType: 'number',
|
|
104
|
+
examples: ['{{fn.max(5, 10, 2, 8)}}'],
|
|
105
|
+
execute: (...args) => Math.max(...args.map(Number)),
|
|
106
|
+
},
|
|
107
|
+
pow: {
|
|
108
|
+
name: 'pow',
|
|
109
|
+
description: 'Returns the base to the exponent power',
|
|
110
|
+
category: 'math',
|
|
111
|
+
signature: 'pow(base, exponent)',
|
|
112
|
+
args: [
|
|
113
|
+
{
|
|
114
|
+
name: 'base',
|
|
115
|
+
type: 'number',
|
|
116
|
+
required: true,
|
|
117
|
+
description: 'Base number',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'exponent',
|
|
121
|
+
type: 'number',
|
|
122
|
+
required: true,
|
|
123
|
+
description: 'Exponent',
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
returnType: 'number',
|
|
127
|
+
examples: ['{{fn.pow(2, 3)}}'],
|
|
128
|
+
execute: (base, exponent) => Math.pow(Number(base), Number(exponent)),
|
|
129
|
+
},
|
|
130
|
+
sqrt: {
|
|
131
|
+
name: 'sqrt',
|
|
132
|
+
description: 'Returns the square root of a number',
|
|
133
|
+
category: 'math',
|
|
134
|
+
signature: 'sqrt(num)',
|
|
135
|
+
args: [
|
|
136
|
+
{
|
|
137
|
+
name: 'num',
|
|
138
|
+
type: 'number',
|
|
139
|
+
required: true,
|
|
140
|
+
description: 'Input number',
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
returnType: 'number',
|
|
144
|
+
examples: ['{{fn.sqrt(16)}}'],
|
|
145
|
+
execute: (num) => Math.sqrt(Number(num)),
|
|
146
|
+
},
|
|
147
|
+
random: {
|
|
148
|
+
name: 'random',
|
|
149
|
+
description: 'Generates a random integer between min and max (inclusive)',
|
|
150
|
+
category: 'math',
|
|
151
|
+
signature: 'random(min, max)',
|
|
152
|
+
args: [
|
|
153
|
+
{
|
|
154
|
+
name: 'min',
|
|
155
|
+
type: 'number',
|
|
156
|
+
required: true,
|
|
157
|
+
description: 'Minimum value',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: 'max',
|
|
161
|
+
type: 'number',
|
|
162
|
+
required: true,
|
|
163
|
+
description: 'Maximum value',
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
returnType: 'number',
|
|
167
|
+
examples: ['{{fn.random(1, 100)}}'],
|
|
168
|
+
execute: (min, max) => {
|
|
169
|
+
const minNum = Number(min);
|
|
170
|
+
const maxNum = Number(max);
|
|
171
|
+
return Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
};
|