@uipath/maestro-builder-sdk 6.124.7 → 6.124.8

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.
@@ -294,6 +294,24 @@ export declare function jmesString(value: string): string;
294
294
  * `undefined` when it has one. See `jmesString`.
295
295
  */
296
296
  export declare function jmesStringProblem(value: string): string | undefined;
297
+ /**
298
+ * `test` applied to a field. On a plain field that is `test(field)`. On an
299
+ * array field it is a filter projection, which keeps the elements that pass
300
+ * and is truthy when any does; a plain comparison against `f[*].sub` would
301
+ * compare the projected LIST with a scalar, which is never equal.
302
+ *
303
+ * One `[*]` gives the designer's form (`JmesHelper.composeArrayJmesPathExpression`).
304
+ * Each further `[*]` nests one more filter, so the outer filter keeps an element
305
+ * only when its inner list has a match. The designer splits a nested path at its
306
+ * last `[*]` only (`a[*].b[?c=='x']`), which evaluates to `[[]]` for an element
307
+ * with no match: a non-empty, truthy list.
308
+ *
309
+ * @example
310
+ * onField('ParentFolders[*].ID', (f) => `${f}=='INBOX'`) // ParentFolders[?ID=='INBOX']
311
+ * onField('tags[*]', (f) => `${f}=='urgent'`) // tags[?@=='urgent']
312
+ * onField('a[*].b[*].c', (f) => `${f}=='x'`) // a[?b[?c=='x']]
313
+ */
314
+ export declare function onField(field: string, test: (lhs: string) => string): string;
297
315
  /**
298
316
  * The JMESPath condition for one filter — the grammar the designer emits,
299
317
  * without the outer parentheses (the caller groups conditions).
@@ -376,11 +376,34 @@ function jmesLiteral(value) {
376
376
  */
377
377
  function isOneOfJmes(field, values) {
378
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 || '@'})]`;
379
+ return onField(field, (f) => `contains(${list}, ${f})`);
380
+ }
381
+ /**
382
+ * `test` applied to a field. On a plain field that is `test(field)`. On an
383
+ * array field it is a filter projection, which keeps the elements that pass
384
+ * and is truthy when any does; a plain comparison against `f[*].sub` would
385
+ * compare the projected LIST with a scalar, which is never equal.
386
+ *
387
+ * One `[*]` gives the designer's form (`JmesHelper.composeArrayJmesPathExpression`).
388
+ * Each further `[*]` nests one more filter, so the outer filter keeps an element
389
+ * only when its inner list has a match. The designer splits a nested path at its
390
+ * last `[*]` only (`a[*].b[?c=='x']`), which evaluates to `[[]]` for an element
391
+ * with no match: a non-empty, truthy list.
392
+ *
393
+ * @example
394
+ * onField('ParentFolders[*].ID', (f) => `${f}=='INBOX'`) // ParentFolders[?ID=='INBOX']
395
+ * onField('tags[*]', (f) => `${f}=='urgent'`) // tags[?@=='urgent']
396
+ * onField('a[*].b[*].c', (f) => `${f}=='x'`) // a[?b[?c=='x']]
397
+ */
398
+ export function onField(field, test) {
399
+ const parts = field.split(FIELD_ARRAY_MARKER);
400
+ if (parts.length === 1)
401
+ return test(field);
402
+ const path = (i) => parts[i].replace(/^\.+|\.+$/g, '') || '@';
403
+ let expr = test(path(parts.length - 1));
404
+ for (let i = parts.length - 2; i >= 1; i--)
405
+ expr = `${path(i)}[?${expr}]`;
406
+ return `${parts[0]}[?${expr}]`;
384
407
  }
385
408
  /**
386
409
  * The JMESPath condition for one filter — the grammar the designer emits,
@@ -390,15 +413,16 @@ export function eventFilterJmes(read) {
390
413
  const op = eventFilterOperator(read.operator);
391
414
  if (op.kind === 'list')
392
415
  return isOneOfJmes(read.field, read.value);
416
+ // Presence on an array field is refused (`eventFilterProblem`).
393
417
  if (op.kind === 'presence')
394
418
  return `not_null(${read.field}, '')${op.jmes}''`;
395
419
  if (op.kind === 'boolean')
396
- return `${read.field}${op.jmes}\`true\``;
420
+ return onField(read.field, (f) => `${f}${op.jmes}\`true\``);
397
421
  if (op.kind === 'function')
398
- return `${op.jmes}(${read.field},${jmesLiteral(read.value)})`;
422
+ return onField(read.field, (f) => `${op.jmes}(${f},${jmesLiteral(read.value)})`);
399
423
  if (isIsoDateString(read.value))
400
- return `to_number(${read.field})${op.jmes}to_number(${jmesString(read.value)})`;
401
- return `${read.field}${op.jmes}${jmesLiteral(read.value)}`;
424
+ return onField(read.field, (f) => `to_number(${f})${op.jmes}to_number(${jmesString(read.value)})`);
425
+ return onField(read.field, (f) => `${f}${op.jmes}${jmesLiteral(read.value)}`);
402
426
  }
403
427
  /**
404
428
  * The designer's tree leaf for one filter — `uiId` is the caller's (it is what keeps a rebuild byte-identical).
@@ -115,6 +115,9 @@ export declare function eventFilterReads(filters: unknown, nodeId: string): Arra
115
115
  * apart is EVENT_FILTER_BACKSLASH. An absent or empty value (`''` or `[]`, so a
116
116
  * `where` built from a possibly-empty list) writes no clause.
117
117
  *
118
+ * An array parameter (`ParentFolders[*].ID`) is the filter projection
119
+ * `ParentFolders[?ID=='INBOX']`, as the designer writes it.
120
+ *
118
121
  * Only event parameters fold into the expression; a query or path parameter is
119
122
  * sent with the request that registers the subscription and is never read as
120
123
  * JMESPath, so neither rule applies to it.
@@ -2,7 +2,7 @@ import { BindingRefusal, bindingMissingMessage, missingBindingLabels } from './b
2
2
  import { ByoaRefusal, byoaUnverified } from './byoa.js';
3
3
  import { CompileRefusal, LibraryRequiredRefusal } from './compile-refusal.js';
4
4
  import { genericEventObjectRefusal } from './event-checks.js';
5
- import { EVENT_FILTER_OPERATORS, eventFilterExpressionRefusal, eventFilterJmes, eventFilterProblem, eventFiltersNotArray, eventFilterTreeLeaf, jmesString, jmesStringProblem, readEventFilter, } from './event-filters.js';
5
+ import { EVENT_FILTER_OPERATORS, eventFilterExpressionRefusal, eventFilterJmes, eventFilterProblem, eventFiltersNotArray, eventFilterTreeLeaf, jmesString, onField, jmesStringProblem, readEventFilter, } from './event-filters.js';
6
6
  import { isLookupToken, resolveEventWhere } from './lookups.js';
7
7
  import { stableId } from './stable-id.js';
8
8
  /** What `registry prepare` takes for an event subscription: its connector key and curated event name. */
@@ -180,6 +180,9 @@ export function eventFilterReads(filters, nodeId) {
180
180
  * apart is EVENT_FILTER_BACKSLASH. An absent or empty value (`''` or `[]`, so a
181
181
  * `where` built from a possibly-empty list) writes no clause.
182
182
  *
183
+ * An array parameter (`ParentFolders[*].ID`) is the filter projection
184
+ * `ParentFolders[?ID=='INBOX']`, as the designer writes it.
185
+ *
183
186
  * Only event parameters fold into the expression; a query or path parameter is
184
187
  * sent with the request that registers the subscription and is never read as
185
188
  * JMESPath, so neither rule applies to it.
@@ -197,6 +200,8 @@ export function eventScopeClauses(eventParameters, nodeId) {
197
200
  const problem = jmesStringProblem(String(v));
198
201
  if (problem)
199
202
  throw new CompileRefusal('EVENT_FILTER_BACKSLASH', `event node "${nodeId}": \`where.${k}\`: ${problem}`);
203
+ if (k.includes('[*]'))
204
+ return onField(k, (f) => `${f}==${jmesString(String(v))}`);
200
205
  return `${k} == ${jmesString(String(v))}`;
201
206
  });
202
207
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.124.7",
3
+ "version": "6.124.8",
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",
@@ -127,5 +127,5 @@
127
127
  "@types/node": "^22.7.0",
128
128
  "esbuild": "^0.28.1"
129
129
  },
130
- "gitref": "f3fce2ed3e8035246ce94b916f07b6b979623d81"
130
+ "gitref": "cf51d4b7c890c02a980223cc9a8d86c8964b203a"
131
131
  }