@uipath/maestro-builder-sdk 6.120.11 → 6.120.13
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/api-index.md +10 -9
- package/dist/api-members.md +15 -15
- package/dist/case/connector-saved-rows.js +20 -3
- package/dist/case/decompile.d.ts +6 -0
- package/dist/case/decompile.js +97 -21
- package/dist/case/preserve.d.ts +17 -3
- package/dist/case/preserve.js +11 -3
- package/dist/case/rule-names.d.ts +14 -6
- package/dist/case/rule-names.js +88 -17
- package/dist/case/serialize.js +158 -19
- package/dist/case/subscription.js +2 -0
- package/dist/core/actions.d.ts +22 -7
- package/dist/core/event-filters.d.ts +68 -6
- package/dist/core/event-filters.js +120 -12
- package/package.json +2 -2
|
@@ -72,6 +72,44 @@ export const EVENT_FILTER_OPERATORS = {
|
|
|
72
72
|
is: { designer: 'Is', kind: 'boolean', jmes: '==' },
|
|
73
73
|
isNot: { designer: 'IsNot', kind: 'boolean', jmes: '!=' },
|
|
74
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* The Case designer's operators beyond {@link EVENT_FILTER_OPERATORS}, read and
|
|
77
|
+
* written in the `'case'` dialect only. Studio Web's Case canvas offers them on
|
|
78
|
+
* a Data Fabric entity event, and its filter compiler (`@uipath/maestro-sdk`
|
|
79
|
+
* `JmesHelper._buildJmesPathExpression`) lowers them as:
|
|
80
|
+
*
|
|
81
|
+
* | authored | designer operator | JMESPath |
|
|
82
|
+
* |--------------------------------|-------------------|--------------------------------------------|
|
|
83
|
+
* | `isOneOf: [5, 6]` (numbers) | `IsOneOf` | `` contains(`[5,6]`, f) `` |
|
|
84
|
+
* | `isOneOf: ['a', 'b']` (text) | `IsOneOf` | `` contains(`["a","b"]`, f) `` |
|
|
85
|
+
* | `isOneOf: [1]` on `f[*]` | `IsOneOf` | `` f[?contains(`[1]`, @)] `` |
|
|
86
|
+
* | `isEmpty: true` | `IsEmpty` | `not_null(f, '')==''` |
|
|
87
|
+
* | `isNotEmpty: true` | `IsNotEmpty` | `not_null(f, '')!=''` |
|
|
88
|
+
*
|
|
89
|
+
* The designer decides numbers or text from the field's type (a choice set's
|
|
90
|
+
* option values are numbers); offline the SDK has no field types, so the
|
|
91
|
+
* authored values decide, as they do for a date. The canvas tree stores the
|
|
92
|
+
* values as text either way (`value: ["5"]`). Flow and BPMN do not read these
|
|
93
|
+
* keys: their designers' saved shape is not measured.
|
|
94
|
+
*/
|
|
95
|
+
export const CASE_EVENT_FILTER_OPERATORS = {
|
|
96
|
+
isOneOf: { designer: 'IsOneOf', kind: 'list', jmes: 'contains' },
|
|
97
|
+
isEmpty: { designer: 'IsEmpty', kind: 'presence', jmes: '==' },
|
|
98
|
+
isNotEmpty: { designer: 'IsNotEmpty', kind: 'presence', jmes: '!=' },
|
|
99
|
+
};
|
|
100
|
+
/** The spec of an operator key, from either table; `undefined` for any other key. */
|
|
101
|
+
export function eventFilterOperator(key) {
|
|
102
|
+
return ownEntry(EVENT_FILTER_OPERATORS, key) ?? ownEntry(CASE_EVENT_FILTER_OPERATORS, key);
|
|
103
|
+
}
|
|
104
|
+
/** The operator keys a dialect reads: Case reads {@link CASE_EVENT_FILTER_OPERATORS} too. */
|
|
105
|
+
function operatorKeys(dialect) {
|
|
106
|
+
return [
|
|
107
|
+
...Object.keys(EVENT_FILTER_OPERATORS),
|
|
108
|
+
...(dialect === 'case' ? Object.keys(CASE_EVENT_FILTER_OPERATORS) : []),
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
/** The `[*]` marker the designer puts in an array field's name (`boardDecision[*]`, `items[*].sku`). */
|
|
112
|
+
const FIELD_ARRAY_MARKER = '[*]';
|
|
75
113
|
/** The designer operator names that come back as each authored key on decompile. */
|
|
76
114
|
const DESIGNER_TO_KEY = {
|
|
77
115
|
Contains: 'contains',
|
|
@@ -92,6 +130,17 @@ const DESIGNER_TO_KEY = {
|
|
|
92
130
|
Is: 'is',
|
|
93
131
|
IsNot: 'isNot',
|
|
94
132
|
};
|
|
133
|
+
/** The Case-only designer names ({@link CASE_EVENT_FILTER_OPERATORS}). */
|
|
134
|
+
const CASE_DESIGNER_TO_KEY = {
|
|
135
|
+
IsOneOf: 'isOneOf',
|
|
136
|
+
IsEmpty: 'isEmpty',
|
|
137
|
+
IsNotEmpty: 'isNotEmpty',
|
|
138
|
+
};
|
|
139
|
+
/** Whether a value is an {@link EventFilterList}: a non-empty array of all numbers or all strings. */
|
|
140
|
+
export function isEventFilterList(value) {
|
|
141
|
+
return Array.isArray(value) && value.length > 0
|
|
142
|
+
&& (value.every((v) => typeof v === 'string') || value.every((v) => typeof v === 'number'));
|
|
143
|
+
}
|
|
95
144
|
/** The operators an expression-valued filter takes: the ones that compare a string. */
|
|
96
145
|
export const EXPRESSION_FILTER_OPERATORS = new Set([
|
|
97
146
|
'contains', 'startsWith', 'endsWith', 'equals', 'notEquals',
|
|
@@ -127,10 +176,15 @@ export function eventFilterExpressionOf(source) {
|
|
|
127
176
|
*/
|
|
128
177
|
export function readEventFilter(leaf, dialect = 'flow') {
|
|
129
178
|
const f = (leaf ?? {});
|
|
130
|
-
const keys =
|
|
179
|
+
const keys = operatorKeys(dialect).filter((k) => f[k] !== undefined);
|
|
131
180
|
if (keys.length !== 1)
|
|
132
181
|
return { keys };
|
|
133
182
|
const value = f[keys[0]];
|
|
183
|
+
if (eventFilterOperator(keys[0])?.kind === 'list') {
|
|
184
|
+
if (!isEventFilterList(value))
|
|
185
|
+
return { keys };
|
|
186
|
+
return { keys, read: { field: String(f.field ?? ''), operator: keys[0], value } };
|
|
187
|
+
}
|
|
134
188
|
if (isEventFilterExpression(value)) {
|
|
135
189
|
const source = eventFilterExpressionSource(value.expression);
|
|
136
190
|
if (dialect !== 'case' || source === undefined)
|
|
@@ -144,7 +198,7 @@ export function readEventFilter(leaf, dialect = 'flow') {
|
|
|
144
198
|
/** Why an expression-valued filter leaf is refused, for the artifact that reads it. */
|
|
145
199
|
export function eventFilterExpressionRefusal(leaf, dialect = 'flow') {
|
|
146
200
|
const f = (leaf ?? {});
|
|
147
|
-
const key =
|
|
201
|
+
const key = operatorKeys(dialect).find((k) => f[k] !== undefined) ?? 'equals';
|
|
148
202
|
const expression = f[key]?.expression;
|
|
149
203
|
if (dialect !== 'case')
|
|
150
204
|
return `\`${key}: { expression }\` (a filter value computed at runtime) is supported in Case only; this artifact's `
|
|
@@ -216,7 +270,27 @@ export function isIsoDateString(value) {
|
|
|
216
270
|
* value with a backslash the engines read differently (`jmesStringProblem`).
|
|
217
271
|
*/
|
|
218
272
|
export function eventFilterProblem(read) {
|
|
219
|
-
const op =
|
|
273
|
+
const op = eventFilterOperator(read.operator);
|
|
274
|
+
if (op.kind === 'list') {
|
|
275
|
+
if (read.expression !== undefined || !isEventFilterList(read.value))
|
|
276
|
+
return `\`${read.operator}\` takes a non-empty list of numbers or of strings (\`${read.operator}: [0, 5]\`, `
|
|
277
|
+
+ `\`${read.operator}: ['Open', 'Closed']\`) — got ${JSON.stringify(read.expression !== undefined ? { expression: read.expression } : read.value)}.`;
|
|
278
|
+
const bad = read.value.find((v) => typeof v === 'number' ? !Number.isFinite(v) : /["\\`]/.test(v));
|
|
279
|
+
if (bad !== undefined)
|
|
280
|
+
return `\`${read.operator}\` value ${JSON.stringify(bad)} cannot be written: the designer splices each value unescaped `
|
|
281
|
+
+ `into a JMESPath list literal, so a number must be finite and text must have no double quote, backslash or `
|
|
282
|
+
+ `backtick.`;
|
|
283
|
+
return undefined;
|
|
284
|
+
}
|
|
285
|
+
if (op.kind === 'presence') {
|
|
286
|
+
if (read.value !== true)
|
|
287
|
+
return `\`${read.operator}\` tests whether a field has a value, so its value is always \`true\` (\`${read.operator}: true\`) — got `
|
|
288
|
+
+ `${JSON.stringify(read.value)}.`;
|
|
289
|
+
if (read.field.includes(FIELD_ARRAY_MARKER))
|
|
290
|
+
return `\`${read.operator}\` on an array field (\`${read.field}\`) has no spelling the designer writes correctly. `
|
|
291
|
+
+ `Test the array's own field, or match an element with \`isOneOf\`.`;
|
|
292
|
+
return undefined;
|
|
293
|
+
}
|
|
220
294
|
if (read.expression !== undefined) {
|
|
221
295
|
if (!EXPRESSION_FILTER_OPERATORS.has(read.operator))
|
|
222
296
|
return `\`${read.operator}\` does not take an expression value: only ${[...EXPRESSION_FILTER_OPERATORS].join(', ')} `
|
|
@@ -290,14 +364,34 @@ export function jmesStringProblem(value) {
|
|
|
290
364
|
}
|
|
291
365
|
/** The JMESPath literal for one filter value, per the designer's `_formatLiteral`. */
|
|
292
366
|
function jmesLiteral(value) {
|
|
367
|
+
if (typeof value === 'object')
|
|
368
|
+
throw new Error('internal SDK error: a list filter value has no scalar JMESPath literal.');
|
|
293
369
|
return typeof value === 'string' ? jmesString(value) : `\`${JSON.stringify(value)}\``;
|
|
294
370
|
}
|
|
371
|
+
/**
|
|
372
|
+
* An `isOneOf` filter as the designer writes it (`JmesHelper._composeInExpression`):
|
|
373
|
+
* the values as a JSON list literal, numbers bare and text double-quoted, then
|
|
374
|
+
* `contains(<list>, f)`; on an array field (`f[*]`, `f[*].sub`) the element
|
|
375
|
+
* test `f[?contains(<list>, @)]` (`composeArrayInExpression`).
|
|
376
|
+
*/
|
|
377
|
+
function isOneOfJmes(field, values) {
|
|
378
|
+
const list = `\`[${values.map((v) => (typeof v === 'number' ? String(v) : `"${v}"`)).join(',')}]\``;
|
|
379
|
+
const marker = field.lastIndexOf(FIELD_ARRAY_MARKER);
|
|
380
|
+
if (marker < 0)
|
|
381
|
+
return `contains(${list}, ${field})`;
|
|
382
|
+
const sub = field.slice(marker + FIELD_ARRAY_MARKER.length).replace(/^\.+|\.+$/g, '');
|
|
383
|
+
return `${field.slice(0, marker)}[?contains(${list}, ${sub || '@'})]`;
|
|
384
|
+
}
|
|
295
385
|
/**
|
|
296
386
|
* The JMESPath condition for one filter — the grammar the designer emits,
|
|
297
387
|
* without the outer parentheses (the caller groups conditions).
|
|
298
388
|
*/
|
|
299
389
|
export function eventFilterJmes(read) {
|
|
300
|
-
const op =
|
|
390
|
+
const op = eventFilterOperator(read.operator);
|
|
391
|
+
if (op.kind === 'list')
|
|
392
|
+
return isOneOfJmes(read.field, read.value);
|
|
393
|
+
if (op.kind === 'presence')
|
|
394
|
+
return `not_null(${read.field}, '')${op.jmes}''`;
|
|
301
395
|
if (op.kind === 'boolean')
|
|
302
396
|
return `${read.field}${op.jmes}\`true\``;
|
|
303
397
|
if (op.kind === 'function')
|
|
@@ -312,33 +406,47 @@ export function eventFilterJmes(read) {
|
|
|
312
406
|
* filter (Case) carries `isLiteral: false` in the `form` its plan used.
|
|
313
407
|
*/
|
|
314
408
|
export function eventFilterTreeLeaf(read, form = 'path') {
|
|
315
|
-
|
|
316
|
-
|
|
409
|
+
const op = eventFilterOperator(read.operator);
|
|
410
|
+
if (op.kind === 'boolean' || op.kind === 'presence')
|
|
411
|
+
return { id: read.field, operator: op.designer, value: null };
|
|
412
|
+
if (op.kind === 'list') {
|
|
413
|
+
const values = read.value.map(String);
|
|
414
|
+
return { id: read.field, operator: op.designer, value: { value: values, rawString: JSON.stringify(values), isLiteral: true } };
|
|
415
|
+
}
|
|
317
416
|
if (read.expression !== undefined) {
|
|
318
417
|
const value = form === 'js' ? `=js:(${read.expression})` : read.expression;
|
|
319
418
|
return {
|
|
320
419
|
id: read.field,
|
|
321
|
-
operator:
|
|
420
|
+
operator: op.designer,
|
|
322
421
|
value: { value, rawString: form === 'js' ? value : JSON.stringify(value), isLiteral: false },
|
|
323
422
|
};
|
|
324
423
|
}
|
|
325
424
|
return {
|
|
326
425
|
id: read.field,
|
|
327
|
-
operator:
|
|
426
|
+
operator: op.designer,
|
|
328
427
|
value: { value: read.value, rawString: JSON.stringify(read.value), isLiteral: true },
|
|
329
428
|
};
|
|
330
429
|
}
|
|
331
430
|
/**
|
|
332
431
|
* Read a designer tree leaf back into the authored key + value (decompile).
|
|
333
|
-
* Returns `undefined` for an operator this SDK does not author (`In`, `
|
|
432
|
+
* Returns `undefined` for an operator this SDK does not author (`In`, `DateTimeEquals` as its own key, …).
|
|
433
|
+
* The `'case'` dialect also reads {@link CASE_EVENT_FILTER_OPERATORS}; an
|
|
434
|
+
* `isOneOf` list reads back as the tree's text values (the caller decides
|
|
435
|
+
* whether the plan's expression compared them as numbers).
|
|
334
436
|
*/
|
|
335
|
-
export function eventFilterFromTreeLeaf(leaf) {
|
|
437
|
+
export function eventFilterFromTreeLeaf(leaf, dialect = 'flow') {
|
|
336
438
|
const op = String(leaf?.operator ?? '');
|
|
337
|
-
const key = ownEntry(DESIGNER_TO_KEY, op);
|
|
439
|
+
const key = ownEntry(DESIGNER_TO_KEY, op) ?? (dialect === 'case' ? ownEntry(CASE_DESIGNER_TO_KEY, op) : undefined);
|
|
338
440
|
if (!key || typeof leaf?.id !== 'string')
|
|
339
441
|
return undefined;
|
|
340
|
-
|
|
442
|
+
const kind = eventFilterOperator(key).kind;
|
|
443
|
+
if (kind === 'boolean' || kind === 'presence')
|
|
341
444
|
return { field: leaf.id, operator: key, value: true };
|
|
445
|
+
if (kind === 'list') {
|
|
446
|
+
const values = leaf.value?.value;
|
|
447
|
+
return Array.isArray(values) && values.length > 0 && values.every((v) => typeof v === 'string')
|
|
448
|
+
? { field: leaf.id, operator: key, value: values } : undefined;
|
|
449
|
+
}
|
|
342
450
|
const raw = leaf.value?.value;
|
|
343
451
|
const value = typeof raw === 'number' || typeof raw === 'boolean' ? raw : String(raw ?? '');
|
|
344
452
|
return { field: leaf.id, operator: key, value };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.120.
|
|
3
|
+
"version": "6.120.13",
|
|
4
4
|
"description": "Build UiPath Flow, Case, and BPMN artifacts by writing TypeScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://docs.uipath.com/maestro",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"@types/node": "^22.7.0",
|
|
125
125
|
"esbuild": "^0.28.1"
|
|
126
126
|
},
|
|
127
|
-
"gitref": "
|
|
127
|
+
"gitref": "265277b8bbf1f2fb15a625631533026b7a7ca33c"
|
|
128
128
|
}
|