blueprint-runtime 0.0.0-stage → 0.3.1
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/LICENSE +21 -0
- package/README.md +224 -3
- package/dist/src/blueprint/load.js +83 -0
- package/dist/src/blueprint/load.js.map +1 -0
- package/dist/src/blueprint/plan.js +202 -0
- package/dist/src/blueprint/plan.js.map +1 -0
- package/dist/src/cli.js +182 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/expr/dates.js +152 -0
- package/dist/src/expr/dates.js.map +1 -0
- package/dist/src/expr/decimal.js +66 -0
- package/dist/src/expr/decimal.js.map +1 -0
- package/dist/src/expr/errors.js +31 -0
- package/dist/src/expr/errors.js.map +1 -0
- package/dist/src/expr/evaluate.js +250 -0
- package/dist/src/expr/evaluate.js.map +1 -0
- package/dist/src/expr/functions.js +460 -0
- package/dist/src/expr/functions.js.map +1 -0
- package/dist/src/expr/parser.js +228 -0
- package/dist/src/expr/parser.js.map +1 -0
- package/dist/src/expr/scan.js +101 -0
- package/dist/src/expr/scan.js.map +1 -0
- package/dist/src/expr/values.js +118 -0
- package/dist/src/expr/values.js.map +1 -0
- package/dist/src/findings.js +10 -0
- package/dist/src/findings.js.map +1 -0
- package/dist/src/inspect.js +313 -0
- package/dist/src/inspect.js.map +1 -0
- package/dist/src/json/parse.js +225 -0
- package/dist/src/json/parse.js.map +1 -0
- package/dist/src/registry.js +39 -0
- package/dist/src/registry.js.map +1 -0
- package/dist/src/run/case.js +122 -0
- package/dist/src/run/case.js.map +1 -0
- package/dist/src/run/compare.js +94 -0
- package/dist/src/run/compare.js.map +1 -0
- package/dist/src/run/fixtures.js +122 -0
- package/dist/src/run/fixtures.js.map +1 -0
- package/dist/src/run/modules.js +380 -0
- package/dist/src/run/modules.js.map +1 -0
- package/dist/src/run/operators.js +151 -0
- package/dist/src/run/operators.js.map +1 -0
- package/dist/src/run/scheduler.js +306 -0
- package/dist/src/run/scheduler.js.map +1 -0
- package/dist/src/run/trace.js +2 -0
- package/dist/src/run/trace.js.map +1 -0
- package/package.json +60 -6
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { DataError, UnsupportedError } from '../expr/errors.js';
|
|
2
|
+
import { evaluateMapper } from '../expr/evaluate.js';
|
|
3
|
+
import { MISSING, toJson, toText } from '../expr/values.js';
|
|
4
|
+
import { isObject, JsonParseError, parseJson } from '../json/parse.js';
|
|
5
|
+
/** A mapper value that is fixed in the blueprint (no {{…}} anywhere inside), or undefined. */
|
|
6
|
+
function literal(v) {
|
|
7
|
+
if (v === undefined)
|
|
8
|
+
return undefined;
|
|
9
|
+
return JSON.stringify(v).includes('{{') ? undefined : v;
|
|
10
|
+
}
|
|
11
|
+
const mapperIsObject = (module) => {
|
|
12
|
+
if (!isObject(module.mapper))
|
|
13
|
+
throw new UnsupportedError(`module ${module.id}: a mapper that is not an object has not been observed in Make`);
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Evaluate a mapper into the module's input bundle. Each top-level field is evaluated
|
|
17
|
+
* on its own so a failure names it, as Make does: "Failed to map 'body': ..." (corpus D-05).
|
|
18
|
+
* A field that comes out as empty text, missing or null is recorded as null
|
|
19
|
+
* (upper("") gave {"value": null} in corpus A-004, A-005, A-006).
|
|
20
|
+
*/
|
|
21
|
+
export function mapInput(mapper, ctx) {
|
|
22
|
+
if (!isObject(mapper))
|
|
23
|
+
throw new UnsupportedError(`a mapper that is not an object (${typeof mapper}) has not been observed in Make`);
|
|
24
|
+
const out = {};
|
|
25
|
+
for (const key of Object.keys(mapper)) {
|
|
26
|
+
let v;
|
|
27
|
+
try {
|
|
28
|
+
v = evaluateMapper(mapper[key], ctx);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
if (e instanceof DataError)
|
|
32
|
+
throw new DataError(`Failed to map '${key}': ${e.message}`);
|
|
33
|
+
throw e;
|
|
34
|
+
}
|
|
35
|
+
out[key] = v.kind === 'string' && v.value === '' ? null : toJson(v);
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
const webhookTrigger = {
|
|
40
|
+
run() {
|
|
41
|
+
throw new Error('the trigger is handled by the scheduler');
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
/** Set variable: input {name, value}, output {[name]: value} (corpus A-001..A-009). */
|
|
45
|
+
const setVariable = {
|
|
46
|
+
check: mapperIsObject,
|
|
47
|
+
run(module, ctx) {
|
|
48
|
+
const input = mapInput(module.mapper, ctx);
|
|
49
|
+
const name = input['name'];
|
|
50
|
+
if (typeof name !== 'string' || name === '')
|
|
51
|
+
throw new UnsupportedError(`Set variable ${module.id}: a variable name of ${JSON.stringify(name)} has not been observed in Make`);
|
|
52
|
+
return { input: [input], output: [{ [name]: input['value'] ?? null }] };
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Webhook response: input {body, status, headers}. Make turns the mapped status "200"
|
|
57
|
+
* into the number 200, and records one null output bundle. A null body reaches the
|
|
58
|
+
* caller as "Accepted" (corpus A-004).
|
|
59
|
+
*/
|
|
60
|
+
const webhookRespond = {
|
|
61
|
+
check(module) {
|
|
62
|
+
mapperIsObject(module);
|
|
63
|
+
const headers = literal(module.mapper['headers']);
|
|
64
|
+
if (Array.isArray(headers) && headers.length > 0)
|
|
65
|
+
throw new UnsupportedError(`Webhook response ${module.id}: custom headers have not been observed in Make`);
|
|
66
|
+
},
|
|
67
|
+
run(module, ctx) {
|
|
68
|
+
const input = mapInput(module.mapper, ctx);
|
|
69
|
+
const status = input['status'];
|
|
70
|
+
const code = typeof status === 'number' ? status : typeof status === 'string' && /^\d+$/.test(status) ? Number(status) : NaN;
|
|
71
|
+
if (!Number.isInteger(code) || code < 100)
|
|
72
|
+
throw new UnsupportedError(`Webhook response ${module.id}: status ${JSON.stringify(status)} has not been observed in Make`);
|
|
73
|
+
input['status'] = code;
|
|
74
|
+
const headers = input['headers'] ?? [];
|
|
75
|
+
if (!Array.isArray(headers) || headers.length > 0)
|
|
76
|
+
throw new UnsupportedError(`Webhook response ${module.id}: custom headers have not been observed in Make`);
|
|
77
|
+
input['headers'] = headers;
|
|
78
|
+
const body = input['body'] ?? null;
|
|
79
|
+
if (body !== null && typeof body !== 'string')
|
|
80
|
+
throw new UnsupportedError(`Webhook response ${module.id}: a body that is not text (${JSON.stringify(body).slice(0, 40)}) has not been observed in Make`);
|
|
81
|
+
return { input: [input], output: [null], response: { status: code, body: body ?? 'Accepted' } };
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
const onlyKeys = (module, what, allowed) => {
|
|
85
|
+
const v = module[what];
|
|
86
|
+
if (what === 'mapper' && !isObject(v))
|
|
87
|
+
return;
|
|
88
|
+
for (const k of Object.keys(isObject(v) ? v : {})) {
|
|
89
|
+
if (!allowed.includes(k))
|
|
90
|
+
throw new UnsupportedError(`module ${module.id} (${module.module}): the ${what} field "${k}" has not been observed in Make`);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* A module that started (its input was mapped) and then failed inside Make. Recorded
|
|
95
|
+
* with its input, one null output and Make's error name (corpus C2-nl-03).
|
|
96
|
+
*/
|
|
97
|
+
export class ModuleFailure extends Error {
|
|
98
|
+
errorName;
|
|
99
|
+
input;
|
|
100
|
+
constructor(errorName, message, input) {
|
|
101
|
+
super(message);
|
|
102
|
+
this.name = 'ModuleFailure';
|
|
103
|
+
this.errorName = errorName;
|
|
104
|
+
this.input = input;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Iterator: input {array}, one output bundle per element; the scheduler sends each
|
|
109
|
+
* bundle down the flow on its own. 1 operation however many bundles (corpus C).
|
|
110
|
+
* - array of collections: each bundle is the collection plus __IMTINDEX__ (1-based) and __IMTLENGTH__ (C-01)
|
|
111
|
+
* - array of plain values or of arrays: each bundle is the bare element, 0 included (C2-nl-01, -02, -05)
|
|
112
|
+
* - an array with a null element: TypeError, the run fails (C2-nl-03)
|
|
113
|
+
* - a single collection: treated as a 1-element array (C-14)
|
|
114
|
+
* - text (empty text too), a number or a boolean: one bundle, the bare value (C-13, C2-nl-06..08)
|
|
115
|
+
* - [], null or missing: no bundles (C-04, C-05; missing is recorded as null)
|
|
116
|
+
* Unlike other modules, empty text stays "" in the input bundle (C2-nl-06).
|
|
117
|
+
*/
|
|
118
|
+
const iterator = {
|
|
119
|
+
check: mapperIsObject,
|
|
120
|
+
run(module, ctx) {
|
|
121
|
+
onlyKeys(module, 'mapper', ['array']);
|
|
122
|
+
const mapper = isObject(module.mapper) ? module.mapper : {};
|
|
123
|
+
let raw;
|
|
124
|
+
try {
|
|
125
|
+
raw = mapper['array'] === undefined ? MISSING : evaluateMapper(mapper['array'], ctx);
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
if (e instanceof DataError)
|
|
129
|
+
throw new DataError(`Failed to map 'array': ${e.message}`);
|
|
130
|
+
throw e;
|
|
131
|
+
}
|
|
132
|
+
const source = raw.kind === 'missing' ? null : toJson(raw);
|
|
133
|
+
const input = [{ array: source }];
|
|
134
|
+
let output;
|
|
135
|
+
if (source === null)
|
|
136
|
+
output = [];
|
|
137
|
+
else if (Array.isArray(source)) {
|
|
138
|
+
if (source.includes(null))
|
|
139
|
+
throw new ModuleFailure('TypeError', 'Cannot convert undefined or null to object', input);
|
|
140
|
+
if (source.every(isObject))
|
|
141
|
+
output = source.map((item, i) => ({ ...item, __IMTINDEX__: i + 1, __IMTLENGTH__: source.length }));
|
|
142
|
+
else if (source.some(isObject))
|
|
143
|
+
throw new UnsupportedError(`Iterator ${module.id}: an array that mixes collections and other values has not been observed in Make`);
|
|
144
|
+
else
|
|
145
|
+
output = source;
|
|
146
|
+
}
|
|
147
|
+
else if (isObject(source))
|
|
148
|
+
output = [{ ...source, __IMTINDEX__: 1, __IMTLENGTH__: 1 }];
|
|
149
|
+
else
|
|
150
|
+
output = [source];
|
|
151
|
+
return { input, output };
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
/** Validates a Text aggregator's settings and returns its row separator. */
|
|
155
|
+
export function textAggregatorSeparator(module) {
|
|
156
|
+
onlyKeys(module, 'mapper', ['value']);
|
|
157
|
+
onlyKeys(module, 'parameters', ['rowSeparator', 'otherRowSeparator', 'feeder']);
|
|
158
|
+
const p = module.parameters;
|
|
159
|
+
// "\n" and "\t" are the separator itself (C2-nl, C2-tab); "other" uses otherRowSeparator (C).
|
|
160
|
+
if (p['rowSeparator'] === '\n' || p['rowSeparator'] === '\t')
|
|
161
|
+
return p['rowSeparator'];
|
|
162
|
+
if (p['rowSeparator'] !== 'other')
|
|
163
|
+
throw new UnsupportedError(`Text aggregator ${module.id}: row separator ${JSON.stringify(p['rowSeparator'] ?? null)} has not been observed in Make`);
|
|
164
|
+
const sep = p['otherRowSeparator'];
|
|
165
|
+
if (typeof sep !== 'string')
|
|
166
|
+
throw new UnsupportedError(`Text aggregator ${module.id}: separator ${JSON.stringify(sep ?? null)} has not been observed in Make`);
|
|
167
|
+
return sep;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Text aggregator, one bundle collected: input {value}, the value written as text
|
|
171
|
+
* (1 → "1", true → "true", {"k":1} → JSON, [1,"b"] → "1, b" with a no-break space;
|
|
172
|
+
* C2-nl-02, -08, -09). Empty, null and missing are stored as null and become an
|
|
173
|
+
* empty row (C2-nl-04, -05).
|
|
174
|
+
*/
|
|
175
|
+
export function textAggregatorRow(module, ctx) {
|
|
176
|
+
const mapper = isObject(module.mapper) ? module.mapper['value'] : undefined;
|
|
177
|
+
let v;
|
|
178
|
+
try {
|
|
179
|
+
v = mapper === undefined ? MISSING : evaluateMapper(mapper, ctx);
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
if (e instanceof DataError)
|
|
183
|
+
throw new DataError(`Failed to map 'value': ${e.message}`);
|
|
184
|
+
throw e;
|
|
185
|
+
}
|
|
186
|
+
const text = v.kind === 'missing' || v.kind === 'null' ? '' : toText(v);
|
|
187
|
+
return { value: text === '' ? null : text };
|
|
188
|
+
}
|
|
189
|
+
/** Text aggregator output: the rows joined, one bundle {text}, "" when no bundle arrived (C-03, C-04). */
|
|
190
|
+
export function textAggregatorResult(rows, separator) {
|
|
191
|
+
return { input: rows, output: [{ text: rows.map((r) => r['value'] ?? '').join(separator) }] };
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* HTTP "Make a request" (http:ActionSendData v3), served from an HTTP fixture. The
|
|
195
|
+
* request is built from the mapped input and must match the fixture; the fixture's
|
|
196
|
+
* response becomes the output bundle the way Make recorded it (corpus E):
|
|
197
|
+
* {statusCode, headers: [{name, value}] (names lowercased, in order),
|
|
198
|
+
* cookieHeaders: [every set-cookie value], data, fileSize}
|
|
199
|
+
* - data is the parsed JSON when parseResponse is on and the response is JSON
|
|
200
|
+
* (E-json-01, E-get-01), the body text when it is off (E-text-01)
|
|
201
|
+
* - fileSize is the body length (33 for a 33-character ASCII body)
|
|
202
|
+
* - 200 and 201 succeed; 404 fails the module with DataError "Error: 404 Not Found",
|
|
203
|
+
* recorded with its input (E-json-03)
|
|
204
|
+
* Inferred, not observed: cookieHeaders is [] when no set-cookie header came back
|
|
205
|
+
* (every recorded response had one).
|
|
206
|
+
*/
|
|
207
|
+
const HTTP_OPTIONS = {
|
|
208
|
+
ca: null, qs: [], headers: [], gzip: true, timeout: null, useMtls: false, authPass: null, authUser: null,
|
|
209
|
+
serializeUrl: false, shareCookies: false, followRedirect: true, useQuerystring: false, followAllRedirects: false, rejectUnauthorized: true,
|
|
210
|
+
};
|
|
211
|
+
const httpRequest = {
|
|
212
|
+
check(module) {
|
|
213
|
+
onlyKeys(module, 'parameters', ['handleErrors', 'useNewZLibDeCompress']);
|
|
214
|
+
if (module.parameters['handleErrors'] !== true)
|
|
215
|
+
throw new UnsupportedError(`HTTP ${module.id}: "Evaluate all states as errors" switched off has not been observed in Make`);
|
|
216
|
+
mapperIsObject(module);
|
|
217
|
+
onlyKeys(module, 'mapper', [...Object.keys(HTTP_OPTIONS), 'url', 'method', 'bodyType', 'contentType', 'data', 'parseResponse']);
|
|
218
|
+
const mapper = module.mapper;
|
|
219
|
+
for (const [k, v] of Object.entries(HTTP_OPTIONS)) {
|
|
220
|
+
const fixed = literal(mapper[k]);
|
|
221
|
+
if (fixed !== undefined && JSON.stringify(fixed === '' ? null : fixed) !== JSON.stringify(v))
|
|
222
|
+
throw new UnsupportedError(`HTTP ${module.id}: ${k} = ${JSON.stringify(fixed).slice(0, 60)} has not been observed in Make`);
|
|
223
|
+
}
|
|
224
|
+
const bodyType = literal(mapper['bodyType']);
|
|
225
|
+
if (bodyType !== undefined && bodyType !== '' && bodyType !== 'raw')
|
|
226
|
+
throw new UnsupportedError(`HTTP ${module.id}: body type ${JSON.stringify(bodyType)} has not been observed in Make`);
|
|
227
|
+
},
|
|
228
|
+
run(module, ctx, call) {
|
|
229
|
+
httpRequest.check(module);
|
|
230
|
+
const input = mapInput(module.mapper, ctx);
|
|
231
|
+
const unobserved = (what) => new UnsupportedError(`HTTP ${module.id}: ${what} has not been observed in Make`);
|
|
232
|
+
for (const [k, v] of Object.entries(HTTP_OPTIONS)) {
|
|
233
|
+
if (k in input && JSON.stringify(input[k]) !== JSON.stringify(v))
|
|
234
|
+
throw unobserved(`${k} = ${JSON.stringify(input[k]).slice(0, 60)}`);
|
|
235
|
+
}
|
|
236
|
+
const { url, method, bodyType, parseResponse } = input;
|
|
237
|
+
if (typeof url !== 'string' || !/^https?:\/\//.test(url))
|
|
238
|
+
throw unobserved(`the URL ${JSON.stringify(url ?? null)}`);
|
|
239
|
+
if (typeof method !== 'string' || !['get', 'post', 'put', 'patch', 'delete'].includes(method))
|
|
240
|
+
throw unobserved(`method ${JSON.stringify(method ?? null)}`);
|
|
241
|
+
if (typeof parseResponse !== 'boolean')
|
|
242
|
+
throw unobserved(`parseResponse = ${JSON.stringify(parseResponse ?? null)}`);
|
|
243
|
+
let contentType = null;
|
|
244
|
+
let body = null;
|
|
245
|
+
if (bodyType === 'raw') {
|
|
246
|
+
if (typeof input['contentType'] !== 'string' || typeof input['data'] !== 'string')
|
|
247
|
+
throw unobserved('a raw body without a content type or with empty data');
|
|
248
|
+
contentType = input['contentType'];
|
|
249
|
+
body = input['data'];
|
|
250
|
+
}
|
|
251
|
+
else if (bodyType !== null && bodyType !== undefined) {
|
|
252
|
+
throw unobserved(`body type ${JSON.stringify(bodyType)}`);
|
|
253
|
+
}
|
|
254
|
+
const fixture = call.fixtures.http(module.id, call.operation, { method: method.toUpperCase(), url, contentType, body });
|
|
255
|
+
const { status, headers, body: text } = fixture.response;
|
|
256
|
+
if (status === 404)
|
|
257
|
+
throw new ModuleFailure('DataError', 'Error: 404 Not Found', [input]);
|
|
258
|
+
if (status !== 200 && status !== 201)
|
|
259
|
+
throw unobserved(`a response with status ${status} (recorded: 200, 201, 404)`);
|
|
260
|
+
if (text === '' || /[^\x00-\x7f]/.test(text))
|
|
261
|
+
throw unobserved('an empty or non-ASCII response body (fileSize is only known for ASCII)');
|
|
262
|
+
let data = text;
|
|
263
|
+
if (parseResponse) {
|
|
264
|
+
const type = headers.find(([n]) => n.toLowerCase() === 'content-type')?.[1] ?? '';
|
|
265
|
+
if (!/^application\/json\b/i.test(type))
|
|
266
|
+
throw unobserved(`parsing a "${type}" response`);
|
|
267
|
+
try {
|
|
268
|
+
data = parseJson(text, 64).value;
|
|
269
|
+
}
|
|
270
|
+
catch (e) {
|
|
271
|
+
if (e instanceof JsonParseError)
|
|
272
|
+
throw unobserved(`parsing a response that is not valid JSON (${e.message})`);
|
|
273
|
+
throw e;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const output = {
|
|
277
|
+
statusCode: status,
|
|
278
|
+
headers: headers.map(([name, value]) => ({ name: name.toLowerCase(), value })),
|
|
279
|
+
cookieHeaders: headers.filter(([n]) => n.toLowerCase() === 'set-cookie').map(([, v]) => v),
|
|
280
|
+
data,
|
|
281
|
+
fileSize: text.length,
|
|
282
|
+
};
|
|
283
|
+
return { input: [input], output: [output] };
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Apps whose modules run inside Make. They are engine behavior and must be
|
|
288
|
+
* implemented and recorded, never replaced by a fixture.
|
|
289
|
+
*/
|
|
290
|
+
const LOCAL_APPS = new Set(['builtin', 'util', 'gateway', 'json', 'regexp', 'http', 'datastore', 'tools', 'csv', 'xml', 'markdown', 'code', 'scenario-service', 'placeholder']);
|
|
291
|
+
/** A third-party app module (e.g. google-sheets:addRow): runs only from an opaque module fixture. */
|
|
292
|
+
export const isOpaqueModule = (module) => !LOCAL_APPS.has(module.slice(0, module.indexOf(':')));
|
|
293
|
+
/**
|
|
294
|
+
* Opaque module fixture (spec 7: the connector stays unverified). The mapped input
|
|
295
|
+
* must equal the fixture's; the fixture's output, or its error, stands in for the
|
|
296
|
+
* service. Exactly one output bundle: modules that return several act like
|
|
297
|
+
* iterators, which has not been observed.
|
|
298
|
+
*/
|
|
299
|
+
const opaqueModule = {
|
|
300
|
+
check: mapperIsObject,
|
|
301
|
+
run(module, ctx, call) {
|
|
302
|
+
const input = mapInput(module.mapper, ctx);
|
|
303
|
+
const fixture = call.fixtures.module(module.id, call.operation, input);
|
|
304
|
+
if (fixture.error)
|
|
305
|
+
throw new ModuleFailure(fixture.error.name, fixture.error.message, [input]);
|
|
306
|
+
if (fixture.output.length !== 1)
|
|
307
|
+
throw new UnsupportedError(`module ${module.id} (${module.module}): a fixture with ${fixture.output.length} output bundles; only 1 is supported (several would fan out like an iterator)`);
|
|
308
|
+
return { input: [input], output: fixture.output };
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Basic trigger (Tools): emits the bundles written in its settings, each a collection of
|
|
313
|
+
* name/value text pairs, in order. Values stay text, empty text included (T-08); no
|
|
314
|
+
* __IMTINDEX__ is added (T-01). Only text values have been recorded.
|
|
315
|
+
*/
|
|
316
|
+
export function basicTriggerBundles(module) {
|
|
317
|
+
onlyKeys(module, 'parameters', ['values']);
|
|
318
|
+
if (isObject(module.mapper) && Object.keys(module.mapper).length > 0)
|
|
319
|
+
throw new UnsupportedError(`Basic trigger ${module.id}: mapped fields have not been observed in Make`);
|
|
320
|
+
const values = module.parameters['values'];
|
|
321
|
+
if (!Array.isArray(values))
|
|
322
|
+
throw new UnsupportedError(`Basic trigger ${module.id}: bundles that are not a list have not been observed in Make`);
|
|
323
|
+
return values.map((item, i) => {
|
|
324
|
+
const spec = isObject(item) ? item['spec'] : undefined;
|
|
325
|
+
if (!Array.isArray(spec))
|
|
326
|
+
throw new UnsupportedError(`Basic trigger ${module.id}: bundle ${i + 1} has no item list`);
|
|
327
|
+
const bundle = {};
|
|
328
|
+
for (const s of spec) {
|
|
329
|
+
if (!isObject(s) || typeof s['name'] !== 'string' || typeof s['value'] !== 'string')
|
|
330
|
+
throw new UnsupportedError(`Basic trigger ${module.id}: bundle ${i + 1} has an item that is not a text name and value; only text has been observed in Make`);
|
|
331
|
+
if (s['name'] in bundle)
|
|
332
|
+
throw new UnsupportedError(`Basic trigger ${module.id}: bundle ${i + 1} repeats the name "${s['name']}"; that has not been observed in Make`);
|
|
333
|
+
bundle[s['name']] = s['value'];
|
|
334
|
+
}
|
|
335
|
+
return bundle;
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
const basicTrigger = {
|
|
339
|
+
check(module) {
|
|
340
|
+
basicTriggerBundles(module);
|
|
341
|
+
},
|
|
342
|
+
run() {
|
|
343
|
+
throw new Error('the trigger is handled by the scheduler');
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Sleep (Tools): input {duration} as a number of seconds, one null output bundle (corpus
|
|
348
|
+
* N-01: the mapped "3" was recorded as 3). Offline it does not wait; the clock for `now`
|
|
349
|
+
* comes from the case, not from the wall.
|
|
350
|
+
*/
|
|
351
|
+
const sleep = {
|
|
352
|
+
check(module) {
|
|
353
|
+
mapperIsObject(module);
|
|
354
|
+
onlyKeys(module, 'mapper', ['duration']);
|
|
355
|
+
},
|
|
356
|
+
run(module, ctx) {
|
|
357
|
+
sleep.check(module);
|
|
358
|
+
const input = mapInput(module.mapper, ctx);
|
|
359
|
+
const d = input['duration'];
|
|
360
|
+
const seconds = typeof d === 'number' ? d : typeof d === 'string' && /^\d+$/.test(d) ? Number(d) : NaN;
|
|
361
|
+
if (!Number.isInteger(seconds) || seconds < 1)
|
|
362
|
+
throw new UnsupportedError(`Sleep ${module.id}: a duration of ${JSON.stringify(d ?? null)} has not been observed in Make`);
|
|
363
|
+
input['duration'] = seconds;
|
|
364
|
+
return { input: [input], output: [null] };
|
|
365
|
+
},
|
|
366
|
+
};
|
|
367
|
+
/** The handler for a module, or undefined if it cannot run. */
|
|
368
|
+
export function handlerFor(module) {
|
|
369
|
+
return HANDLERS[module] ?? (isOpaqueModule(module) ? opaqueModule : undefined);
|
|
370
|
+
}
|
|
371
|
+
export const HANDLERS = {
|
|
372
|
+
'gateway:CustomWebHook': webhookTrigger,
|
|
373
|
+
'util:SetVariable2': setVariable,
|
|
374
|
+
'gateway:WebhookRespond': webhookRespond,
|
|
375
|
+
'builtin:BasicFeeder': iterator,
|
|
376
|
+
'http:ActionSendData': httpRequest,
|
|
377
|
+
'util:BasicTrigger': basicTrigger,
|
|
378
|
+
'util:FunctionSleep': sleep,
|
|
379
|
+
};
|
|
380
|
+
//# sourceMappingURL=modules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../../src/run/modules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAoB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAc,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAmC,MAAM,kBA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wBAAwB,EAAE,cAAc;IACxC,qBAAqB,EAAE,QAAQ;IAC/B,qBAAqB,EAAE,WAAW;IAClC,mBAAmB,EAAE,YAAY;IACjC,oBAAoB,EAAE,KAAK;CAC5B,CAAC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import * as dates from '../expr/dates.js';
|
|
2
|
+
import { UnsupportedError } from '../expr/errors.js';
|
|
3
|
+
import { describe, toText } from '../expr/values.js';
|
|
4
|
+
const refuse = (op, v, why = '') => {
|
|
5
|
+
throw new UnsupportedError(`filter "${op}" with ${describe(v)}${why ? ` (${why})` : ''} has not been observed in Make`);
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Text form for text operators: numbers become text (42 equals "42"), and missing
|
|
9
|
+
* and null are "" (missing equals "", null equals ""). F1: te_num_text, te_missing_empty, te_null_empty.
|
|
10
|
+
*/
|
|
11
|
+
function text(op, v) {
|
|
12
|
+
if (v.kind === 'missing' || v.kind === 'null')
|
|
13
|
+
return '';
|
|
14
|
+
if (v.kind === 'string' || v.kind === 'number')
|
|
15
|
+
return toText(v);
|
|
16
|
+
return refuse(op, v);
|
|
17
|
+
}
|
|
18
|
+
/** Case-insensitive variants: only ASCII text has been observed. */
|
|
19
|
+
function lower(op, s) {
|
|
20
|
+
if (/[^\x00-\x7F]/.test(s))
|
|
21
|
+
throw new UnsupportedError(`filter "${op}" on non-ASCII text has not been observed in Make`);
|
|
22
|
+
return s.toLowerCase();
|
|
23
|
+
}
|
|
24
|
+
const DECIMAL = /^-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;
|
|
25
|
+
/**
|
|
26
|
+
* Number form for number operators. Observed: "150" → 150, "1e3" → 1000, true → 1,
|
|
27
|
+
* false → 0; "", "abc", "150abc", null and missing are not numbers, so every
|
|
28
|
+
* comparison with them is false (corpus B, F1: ng_empty, ng_null, ng_suffix, ng_bool).
|
|
29
|
+
*/
|
|
30
|
+
function number(op, v) {
|
|
31
|
+
switch (v.kind) {
|
|
32
|
+
case 'number':
|
|
33
|
+
return v.value;
|
|
34
|
+
case 'boolean':
|
|
35
|
+
return v.value ? 1 : 0;
|
|
36
|
+
case 'missing':
|
|
37
|
+
case 'null':
|
|
38
|
+
return NaN;
|
|
39
|
+
case 'string':
|
|
40
|
+
if (DECIMAL.test(v.value))
|
|
41
|
+
return Number(v.value);
|
|
42
|
+
if (Number.isNaN(Number(v.value)) || v.value.trim() === '')
|
|
43
|
+
return NaN;
|
|
44
|
+
return refuse(op, v, 'a number format other than plain decimal');
|
|
45
|
+
default:
|
|
46
|
+
return refuse(op, v);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** "true" and "false" as text count as booleans (F1: be_text). */
|
|
50
|
+
function bool(op, v) {
|
|
51
|
+
if (v.kind === 'boolean')
|
|
52
|
+
return v.value;
|
|
53
|
+
if (v.kind === 'string' && (v.value === 'true' || v.value === 'false'))
|
|
54
|
+
return v.value === 'true';
|
|
55
|
+
return refuse(op, v);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* An instant for date operators. Full ISO timestamps compare as instants (F1: dg_same).
|
|
59
|
+
* A date without a time is midnight in some timezone; when the scenario timezone and UTC
|
|
60
|
+
* would decide differently, the comparison is refused.
|
|
61
|
+
*/
|
|
62
|
+
function instants(op, v, ctx) {
|
|
63
|
+
if (v.kind === 'date')
|
|
64
|
+
return [v.value];
|
|
65
|
+
if (v.kind === 'string') {
|
|
66
|
+
const t = dates.parseIsoInstant(v.value);
|
|
67
|
+
if (t !== null)
|
|
68
|
+
return [t];
|
|
69
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(v.value)) {
|
|
70
|
+
const utc = Date.parse(`${v.value}T00:00:00.000Z`);
|
|
71
|
+
if (!ctx.timezone)
|
|
72
|
+
return [utc];
|
|
73
|
+
return [utc, dates.parseDate(v.value, 'YYYY-MM-DD', ctx.timezone)];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return refuse(op, v, 'not an ISO date');
|
|
77
|
+
}
|
|
78
|
+
function dateCompare(op, cmp) {
|
|
79
|
+
return (a, b, ctx) => {
|
|
80
|
+
const results = new Set(instants(op, a, ctx).flatMap((x) => instants(op, b, ctx).map((y) => cmp(x, y))));
|
|
81
|
+
if (results.size > 1)
|
|
82
|
+
throw new UnsupportedError(`filter "${op}": the result depends on whether a date without a time is read in UTC or the scenario timezone, which has not been observed`);
|
|
83
|
+
return [...results][0];
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function regex(op, source, flags) {
|
|
87
|
+
try {
|
|
88
|
+
return new RegExp(source, flags);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
throw new UnsupportedError(`filter "${op}": the pattern ${JSON.stringify(source)} is not a valid regular expression`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const textOp = (op, f, ci = false) => (a, b) => {
|
|
95
|
+
const x = text(op, a);
|
|
96
|
+
const y = text(op, b);
|
|
97
|
+
return ci ? f(lower(op, x), lower(op, y)) : f(x, y);
|
|
98
|
+
};
|
|
99
|
+
const numOp = (op, f) => (a, b) => f(number(op, a), number(op, b));
|
|
100
|
+
/** Existence: missing, null and "" do not exist; 0, false and [] do (F1: ex_*). */
|
|
101
|
+
const exists = (v) => !(v.kind === 'missing' || v.kind === 'null' || (v.kind === 'string' && v.value === ''));
|
|
102
|
+
function arrayContains(op, a, b) {
|
|
103
|
+
if (a.kind !== 'array')
|
|
104
|
+
return refuse(op, a, 'not an array');
|
|
105
|
+
const needle = text(op, b);
|
|
106
|
+
return a.value.some((el) => (el.kind === 'string' ? el.value === needle : refuse(op, el, 'array elements that are not text')));
|
|
107
|
+
}
|
|
108
|
+
export const OPERATORS = {
|
|
109
|
+
// Text: case-sensitive unless :ci, no trimming (corpus B, F1).
|
|
110
|
+
'text:equal': textOp('text:equal', (x, y) => x === y),
|
|
111
|
+
'text:equal:ci': textOp('text:equal:ci', (x, y) => x === y, true),
|
|
112
|
+
'text:notequal': textOp('text:notequal', (x, y) => x !== y),
|
|
113
|
+
'text:notequal:ci': textOp('text:notequal:ci', (x, y) => x !== y, true),
|
|
114
|
+
'text:contain': textOp('text:contain', (x, y) => x.includes(y)),
|
|
115
|
+
'text:contain:ci': textOp('text:contain:ci', (x, y) => x.includes(y), true),
|
|
116
|
+
'text:notcontain': textOp('text:notcontain', (x, y) => !x.includes(y)),
|
|
117
|
+
'text:notcontain:ci': textOp('text:notcontain:ci', (x, y) => !x.includes(y), true),
|
|
118
|
+
'text:startwith': textOp('text:startwith', (x, y) => x.startsWith(y)),
|
|
119
|
+
'text:startwith:ci': textOp('text:startwith:ci', (x, y) => x.startsWith(y), true),
|
|
120
|
+
'text:notstartwith': textOp('text:notstartwith', (x, y) => !x.startsWith(y)),
|
|
121
|
+
'text:endwith': textOp('text:endwith', (x, y) => x.endsWith(y)),
|
|
122
|
+
'text:endwith:ci': textOp('text:endwith:ci', (x, y) => x.endsWith(y), true),
|
|
123
|
+
'text:notendwith': textOp('text:notendwith', (x, y) => !x.endsWith(y)),
|
|
124
|
+
'text:pattern': textOp('text:pattern', (x, y) => regex('text:pattern', y, '').test(x)),
|
|
125
|
+
'text:pattern:ci': (a, b) => regex('text:pattern:ci', text('text:pattern:ci', b), 'i').test(text('text:pattern:ci', a)),
|
|
126
|
+
'text:notpattern': textOp('text:notpattern', (x, y) => !regex('text:notpattern', y, '').test(x)),
|
|
127
|
+
// Numbers (corpus B, C, F1).
|
|
128
|
+
'number:equal': numOp('number:equal', (x, y) => x === y),
|
|
129
|
+
'number:notequal': numOp('number:notequal', (x, y) => {
|
|
130
|
+
if (Number.isNaN(x) || Number.isNaN(y))
|
|
131
|
+
throw new UnsupportedError('filter "number:notequal" with a value that is not a number has not been observed in Make');
|
|
132
|
+
return x !== y;
|
|
133
|
+
}),
|
|
134
|
+
'number:greater': numOp('number:greater', (x, y) => x > y),
|
|
135
|
+
'number:less': numOp('number:less', (x, y) => x < y),
|
|
136
|
+
'number:greaterorequal': numOp('number:greaterorequal', (x, y) => x >= y),
|
|
137
|
+
'number:lessorequal': numOp('number:lessorequal', (x, y) => x <= y),
|
|
138
|
+
// Existence (F1). The second operand is ignored.
|
|
139
|
+
exist: (a) => exists(a),
|
|
140
|
+
notexist: (a) => !exists(a),
|
|
141
|
+
// Booleans (F1).
|
|
142
|
+
'boolean:equal': (a, b) => bool('boolean:equal', a) === bool('boolean:equal', b),
|
|
143
|
+
'boolean:notequal': (a, b) => bool('boolean:notequal', a) !== bool('boolean:notequal', b),
|
|
144
|
+
// Arrays of text, case-sensitive (F1).
|
|
145
|
+
'array:contain': (a, b) => arrayContains('array:contain', a, b),
|
|
146
|
+
'array:notcontain': (a, b) => !arrayContains('array:notcontain', a, b),
|
|
147
|
+
// Dates (F1).
|
|
148
|
+
'date:greater': dateCompare('date:greater', (x, y) => x > y),
|
|
149
|
+
'date:less': dateCompare('date:less', (x, y) => x < y),
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=operators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators.js","sourceRoot":"","sources":["../../../src/run/operators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAc,MAAM,mBAAmB,CAAC;AAcjE,MAAM,MAAM,GAAG,CAAC,EAAU,EAAE,CAAQ,EAAE,GAAG,GAAG,EAAE,EAAS,EAAE;IACvD,MAAM,IAAI,gBAAgB,CAAC,WAAW,EAAE,UAAU,QAAQ,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,gCAAgC,CAAC,CAAC;AAC1H,CAAC,CAAC;AAEF;;;GAGG;AACH,SAAS,IAAI,CAAC,EAAU,EAAE,CAAQ;IAChC,IAAI,CAAC,CAAC,IAAI,KAA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