@uipath/maestro-builder-sdk 6.120.8 → 6.120.10

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.
@@ -34,7 +34,7 @@
34
34
  * for `parentFolderId` keeps both while the source still filters on that
35
35
  * folder. Point it at another folder and compile writes its own body.
36
36
  */
37
- import { caseSubscriptionOwners } from './subscription.js';
37
+ import { caseSubscriptionOwners, withScopeExpression } from './subscription.js';
38
38
  const CONNECTOR_ACTIVITY_TYPE = 'execute-connector-activity';
39
39
  /**
40
40
  * Every connector element in a plan with the bag that holds its `context`:
@@ -180,7 +180,11 @@ export function savedConnectorContext(owner, bag) {
180
180
  return undefined;
181
181
  if (sdkShaped(bag, context))
182
182
  return undefined;
183
- return { owner, context: structuredClone(context), inputs: inputValues(bag) };
183
+ const inputs = inputValues(bag);
184
+ // A subscription body saved with no match expression compares as compile writes it.
185
+ if (EVENT_SERVICE_TYPES.has(bag.serviceType) && inputs.body !== undefined)
186
+ inputs.body = withScopeExpression(inputs.body, owner);
187
+ return { owner, context: structuredClone(context), inputs };
184
188
  }
185
189
  /** Whether a wire `activityType` is a generic CRUD one (`Generic`, `GenericExpanded`, `GenericTrigger`). */
186
190
  const isGenericKind = (activityType) => activityType.startsWith('Generic');
@@ -15,6 +15,13 @@ export interface PreservedExtractShape {
15
15
  fields?: Record<string, unknown>;
16
16
  /** The row was saved with no `target`. */
17
17
  omit?: ['target'];
18
+ /**
19
+ * The row's saved `target`, when it names neither the row's id nor its
20
+ * variable: a copied task keeps the `target` of the row it was copied from
21
+ * (`target: '=id15'` on the row `{ id: 'id16', var: 'id16' }`). The row's
22
+ * `var` decides what it writes, so the target is the Designer's spelling.
23
+ */
24
+ target?: string;
18
25
  }
19
26
  /** One saved connector element's own rows, as `preserveCaseJson` carries them. */
20
27
  export interface PreservedConnectorRows {
@@ -51,6 +58,20 @@ export declare function caseConnectorRowOwners(plan: Record<string, any>): Array
51
58
  * field. Else `undefined`.
52
59
  */
53
60
  export declare function savedConnectorRows(owner: string, bag: Record<string, any>, elementIds?: readonly string[]): PreservedConnectorRows | undefined;
61
+ /**
62
+ * The own output rows compile built that {@link applyConnectorRows} drops: on an
63
+ * element saved without that row (`Error` only, say), while it calls the same
64
+ * operation, and while {@link outputsBack} writes the saved rows back (the
65
+ * same {@link outputsDiverge} check). Compile numbered them like any other row
66
+ * (`response11`), so until they are dropped they hold an id a saved row may
67
+ * carry. Called before those claims settle, once the element ids are the plan's
68
+ * own; a claim left to settle only moves a row to its saved id, so a counterpart
69
+ * that matches here still matches when the rows go back. Where the two checks
70
+ * could still disagree (a root companion added after this call), this one says
71
+ * the rows diverge, so the id stays held: a dropped row then keeps its id
72
+ * unused, but no two rows hold one.
73
+ */
74
+ export declare function droppedConnectorOutputRows(result: Record<string, any>, entries: readonly PreservedConnectorRows[] | undefined): Array<Record<string, unknown>>;
54
75
  /**
55
76
  * Write each element's saved own rows back over the ones compile built, half
56
77
  * by half, while they still describe the element. Runs after the ids are
@@ -49,15 +49,16 @@
49
49
  *
50
50
  * The author's extracts (`.outputs({ createdById: '=response.CreatedBy.Id' })`)
51
51
  * are compile's to write, but the Designer saves them with a field compile
52
- * does not write (`displayName: 'CreatedBy.Id'`) and without one it does
53
- * (`target`). `extracts` records that difference per extract, keyed by the
52
+ * does not write (`displayName: 'CreatedBy.Id'`), and without one it does
53
+ * (`target`) or with a stale one (`target: '=id15'` on the row `id16`, kept
54
+ * from the task it was copied from). `extracts` records that difference per extract, keyed by the
54
55
  * `source` it reads and the `var` it writes, and compile puts it back on the
55
56
  * row that still reads that source into that variable, while the element calls
56
57
  * the same operation. An extract the author edits (another source or
57
58
  * variable) gets compile's row.
58
59
  */
59
60
  import { comparesContextRow } from './connector-saved-context.js';
60
- import { caseSubscriptionOwners } from './subscription.js';
61
+ import { caseSubscriptionOwners, withScopeExpression } from './subscription.js';
61
62
  const CONNECTOR_ACTIVITY_TYPE = 'execute-connector-activity';
62
63
  /** The context rows that name the operation an element calls. */
63
64
  const OPERATION_ROWS = ['connectorKey', 'objectName', 'method', 'path', 'operation'];
@@ -199,7 +200,7 @@ function savedOutputs(bag, elementIds) {
199
200
  return { rows: structuredClone(rows), ...(bag.outputs === undefined ? { absent: true } : {}) };
200
201
  }
201
202
  /** The saved inputs half, when compile would not write it as it is. */
202
- function savedInputs(bag, activity, elementIds) {
203
+ function savedInputs(bag, activity, elementIds, owner) {
203
204
  if (bag.inputs !== undefined && !Array.isArray(bag.inputs))
204
205
  return undefined;
205
206
  const rows = bag.inputs ?? [];
@@ -212,7 +213,11 @@ function savedInputs(bag, activity, elementIds) {
212
213
  const complete = activity ? ACTIVITY_CONTAINERS.every((name) => names.has(name)) : rows.length === 1;
213
214
  if (bag.inputs !== undefined && complete && rows.every((row) => sdkShapedInput(row, elementIds)))
214
215
  return undefined;
215
- return { rows: structuredClone(rows), ...(bag.inputs === undefined ? { absent: true } : {}) };
216
+ // A subscription body saved with no match expression is carried as compile
217
+ // writes it (`withScopeExpression`): the engine needs the expression.
218
+ const carried = structuredClone(rows).map((row) => (!activity && row.name === 'body' && row.body !== undefined
219
+ ? { ...row, body: withScopeExpression(row.body, owner) } : row));
220
+ return { rows: carried, ...(bag.inputs === undefined ? { absent: true } : {}) };
216
221
  }
217
222
  /**
218
223
  * The saved own rows of a connector element, for each half compile would not
@@ -226,7 +231,7 @@ export function savedConnectorRows(owner, bag, elementIds) {
226
231
  return undefined;
227
232
  const activity = bag.serviceType !== 'Intsvc.EventTrigger' && bag.serviceType !== 'Intsvc.WaitForEvent';
228
233
  const outputs = savedOutputs(bag, elementIds);
229
- const inputs = savedInputs(bag, activity, elementIds);
234
+ const inputs = savedInputs(bag, activity, elementIds, owner);
230
235
  const extracts = savedExtracts(bag);
231
236
  if (!outputs && !inputs && !extracts)
232
237
  return undefined;
@@ -261,9 +266,16 @@ function savedExtracts(bag) {
261
266
  continue;
262
267
  const fields = Object.fromEntries(Object.entries(row).filter(([key]) => !EXTRACT_WRITTEN_FIELDS.has(key)).map(([key, value]) => [key, structuredClone(value)]));
263
268
  const omit = row.target === undefined;
264
- if (!Object.keys(fields).length && !omit)
269
+ // Compile writes `target: "=<id>"`; an own-name extract's id is its variable.
270
+ const target = typeof row.target === 'string' && row.target !== `=${row.id}` && row.target !== `=${row.var}` ? row.target : undefined;
271
+ if (!Object.keys(fields).length && !omit && target === undefined)
265
272
  continue;
266
- out.push({ source: row.source, var: row.var, ...(Object.keys(fields).length ? { fields } : {}), ...(omit ? { omit: ['target'] } : {}) });
273
+ out.push({
274
+ source: row.source, var: row.var,
275
+ ...(Object.keys(fields).length ? { fields } : {}),
276
+ ...(omit ? { omit: ['target'] } : {}),
277
+ ...(target !== undefined ? { target } : {}),
278
+ });
267
279
  }
268
280
  return out.length ? out : undefined;
269
281
  }
@@ -280,6 +292,9 @@ function extractsBack(bag, shapes) {
280
292
  row[key] = structuredClone(value);
281
293
  if (shape.omit?.includes('target'))
282
294
  delete row.target;
295
+ // Only over the target compile writes, so an id compile changed keeps its own.
296
+ else if (shape.target !== undefined && row.target === `=${row.id}`)
297
+ row.target = shape.target;
283
298
  }
284
299
  }
285
300
  /**
@@ -292,14 +307,24 @@ function sameOperation(bag, entry) {
292
307
  return OPERATION_ROWS.every((name) => !comparesContextRow(bag, name) || now[name] === entry.operation[name]);
293
308
  }
294
309
  /**
295
- * The saved outputs over the built ones: the saved own rows in saved order,
296
- * where compile put its first own row, around the rows compile writes for the
297
- * author; a built own row the element was saved without is dropped. Nothing,
298
- * when a saved row's counterpart writes another variable.
310
+ * A saved own row's counterpart among the built own rows: a built row that
311
+ * reads its source, one that also writes its variable when there is one, and
312
+ * of those the one with its id, else the last.
313
+ */
314
+ function counterpartOf(builtOwn, row) {
315
+ const reading = builtOwn.filter((candidate) => candidate.source === row.source);
316
+ const writing = reading.filter((candidate) => row.var !== undefined && candidate.var === row.var);
317
+ const pool = writing.length ? writing : reading;
318
+ return pool.find((candidate) => candidate.id === row.id) ?? pool.at(-1);
319
+ }
320
+ /**
321
+ * Whether the saved outputs no longer describe the built ones: a saved row's
322
+ * counterpart has another id, or writes another variable (and is not the own
323
+ * row the Designer reassigned to a case variable, `reassignedToCaseVariable`).
324
+ * Then {@link outputsBack} writes nothing back and every built row stays, so
325
+ * {@link droppedConnectorOutputRows} frees none of their ids.
299
326
  *
300
- * A saved row's counterpart is a built row that reads its source: one that
301
- * also writes its variable when there is one, and of those the one with its
302
- * id, else the last. An event trigger's `outputs`
327
+ * An event trigger's `outputs`
303
328
  * (`outputs: { responseRow: { source: '=response' } }`) compile writes as
304
329
  * extracts beside the trigger's own rows, with the same source and no id; the
305
330
  * Designer saves the trigger's own row reassigned instead (`{ id:
@@ -308,24 +333,27 @@ function sameOperation(bag, entry) {
308
333
  * counterpart, and having no id it says nothing about renumbering, so the
309
334
  * ids are compared only when the counterpart has one.
310
335
  */
311
- function outputsBack(built, set, caseVariables) {
312
- const builtOwn = built.filter(isOwnOutput);
313
- const counterpartOf = (row) => {
314
- const reading = builtOwn.filter((candidate) => candidate.source === row.source);
315
- const writing = reading.filter((candidate) => row.var !== undefined && candidate.var === row.var);
316
- const pool = writing.length ? writing : reading;
317
- return pool.find((candidate) => candidate.id === row.id) ?? pool.at(-1);
318
- };
319
- for (const row of set.rows) {
320
- const counterpart = counterpartOf(row);
336
+ function outputsDiverge(builtOwn, set, caseVariables) {
337
+ return set.rows.some((row) => {
338
+ const counterpart = counterpartOf(builtOwn, row);
321
339
  if (!counterpart)
322
- continue;
340
+ return false;
323
341
  if (counterpart.id !== undefined && counterpart.id !== row.id)
324
- return undefined;
325
- if (row.var !== undefined && counterpart.var !== row.var && !reassignedToCaseVariable(row, counterpart, caseVariables))
326
- return undefined;
327
- }
328
- const own = set.rows.flatMap((row) => (counterpartOf(row) ? [structuredClone(row)] : []));
342
+ return true;
343
+ return row.var !== undefined && counterpart.var !== row.var && !reassignedToCaseVariable(row, counterpart, caseVariables);
344
+ });
345
+ }
346
+ /**
347
+ * The saved outputs over the built ones: the saved own rows in saved order,
348
+ * where compile put its first own row, around the rows compile writes for the
349
+ * author; a built own row the element was saved without is dropped. Nothing,
350
+ * when the saved rows no longer describe the built ones ({@link outputsDiverge}).
351
+ */
352
+ function outputsBack(built, set, caseVariables) {
353
+ const builtOwn = built.filter(isOwnOutput);
354
+ if (outputsDiverge(builtOwn, set, caseVariables))
355
+ return undefined;
356
+ const own = set.rows.flatMap((row) => (counterpartOf(builtOwn, row) ? [structuredClone(row)] : []));
329
357
  const firstOwn = built.findIndex(isOwnOutput);
330
358
  const others = built.filter((row) => !isOwnOutput(row));
331
359
  const at = firstOwn < 0 ? 0 : firstOwn;
@@ -375,6 +403,38 @@ function inputsBack(built, set) {
375
403
  }
376
404
  return structuredClone(set.rows);
377
405
  }
406
+ /**
407
+ * The own output rows compile built that {@link applyConnectorRows} drops: on an
408
+ * element saved without that row (`Error` only, say), while it calls the same
409
+ * operation, and while {@link outputsBack} writes the saved rows back (the
410
+ * same {@link outputsDiverge} check). Compile numbered them like any other row
411
+ * (`response11`), so until they are dropped they hold an id a saved row may
412
+ * carry. Called before those claims settle, once the element ids are the plan's
413
+ * own; a claim left to settle only moves a row to its saved id, so a counterpart
414
+ * that matches here still matches when the rows go back. Where the two checks
415
+ * could still disagree (a root companion added after this call), this one says
416
+ * the rows diverge, so the id stays held: a dropped row then keeps its id
417
+ * unused, but no two rows hold one.
418
+ */
419
+ export function droppedConnectorOutputRows(result, entries) {
420
+ if (!entries?.length)
421
+ return [];
422
+ const byOwner = new Map(entries.map((entry) => [entry.owner, entry]));
423
+ const caseVariables = caseVariableIds(result);
424
+ const out = [];
425
+ for (const { key, bag } of caseConnectorRowOwners(result)) {
426
+ const entry = byOwner.get(key);
427
+ if (!entry?.outputs || !sameOperation(bag, entry) || !Array.isArray(bag.outputs))
428
+ continue;
429
+ if (outputsDiverge(bag.outputs.filter(isOwnOutput), entry.outputs, caseVariables))
430
+ continue;
431
+ const saved = new Set(entry.outputs.rows.map((row) => row.source));
432
+ for (const row of bag.outputs)
433
+ if (isOwnOutput(row) && !saved.has(row.source))
434
+ out.push(row);
435
+ }
436
+ return out;
437
+ }
378
438
  /**
379
439
  * Write each element's saved own rows back over the ones compile built, half
380
440
  * by half, while they still describe the element. Runs after the ids are
@@ -446,11 +506,12 @@ export function connectorRowErrors(entries) {
446
506
  const { extracts } = entry;
447
507
  if (extracts !== undefined) {
448
508
  const shapeOk = (shape) => isObject(shape) && typeof shape.source === 'string' && /^=(?:response|Error)[.[]/.test(shape.source)
449
- && typeof shape.var === 'string' && Object.keys(shape).every((key) => ['source', 'var', 'fields', 'omit'].includes(key))
509
+ && typeof shape.var === 'string' && Object.keys(shape).every((key) => ['source', 'var', 'fields', 'omit', 'target'].includes(key))
510
+ && (shape.target === undefined || (typeof shape.target === 'string' && shape.target.startsWith('=') && shape.omit === undefined))
450
511
  && (shape.fields === undefined || (isObject(shape.fields) && Object.keys(shape.fields).every((key) => !EXTRACT_WRITTEN_FIELDS.has(key))))
451
512
  && (shape.omit === undefined || (Array.isArray(shape.omit) && shape.omit.length === 1 && shape.omit[0] === 'target'));
452
513
  if (!Array.isArray(extracts) || !extracts.every(shapeOk))
453
- errors.push(`preserved connector rows "${owner}" extracts must each name a source and a var, with only fields compile does not write and omit ["target"]`);
514
+ errors.push(`preserved connector rows "${owner}" extracts must each name a source and a var, with only fields compile does not write, and omit ["target"] or a "=" target`);
454
515
  else if (new Set(extracts.map(extractKey)).size !== extracts.length)
455
516
  errors.push(`preserved connector rows "${owner}" extracts name a source and var twice`);
456
517
  }
@@ -283,6 +283,10 @@ type Preservation = {
283
283
  connectorContexts?: PreservedConnectorContext[];
284
284
  connectorConfigV2?: string[];
285
285
  connectorRows?: PreservedConnectorRows[];
286
+ subscriptionBindings?: Array<{
287
+ owner: string;
288
+ bindings: Array<Record<string, unknown>>;
289
+ }>;
286
290
  subscriptionFilters?: Array<{
287
291
  owner: string;
288
292
  expression?: 'inline';
@@ -2352,6 +2352,17 @@ function ruleInputIdentity(inputs) {
2352
2352
  return {};
2353
2353
  return { inputs: rows.map((row) => ({ name: typeof row?.name === 'string' ? row.name : '', ...(typeof row?.id === 'string' ? { id: row.id } : {}) })) };
2354
2354
  }
2355
+ /**
2356
+ * What a task entry condition was saved with that the builder does not author:
2357
+ * `isInterrupting` (the platform reads it on stage conditions only) and the
2358
+ * absence of a `displayName` (compile derives `"<task> entry"`).
2359
+ */
2360
+ function taskEntryConditionShape(condition) {
2361
+ return {
2362
+ ...(typeof condition.isInterrupting === 'boolean' ? { isInterrupting: condition.isInterrupting } : {}),
2363
+ ...(condition.displayName === undefined ? { noDisplayName: true } : {}),
2364
+ };
2365
+ }
2355
2366
  function slaIdentity(sla) {
2356
2367
  return {
2357
2368
  ...(sla.id ? { id: sla.id } : {}),
@@ -2633,7 +2644,10 @@ function identityPreservation(plan) {
2633
2644
  name: taskSourceName(task),
2634
2645
  ...(task.id ? { id: task.id } : {}),
2635
2646
  ...savedTaskElementId(stage, task),
2636
- entryConditions: (task.entryConditions ?? []).map(conditionIdentity),
2647
+ entryConditions: (task.entryConditions ?? []).map((condition, index, list) => ({
2648
+ ...conditionIdentity(condition, index, list),
2649
+ ...taskEntryConditionShape(condition),
2650
+ })),
2637
2651
  ...emptyLists(task, TASK_EMPTY_LISTS),
2638
2652
  inputs: (task.data?.inputs ?? []).map((row) => ({ name: row.name ?? '', ...(row.id ? { id: row.id } : {}), ...actionInputShape(task, row), ...resourceRowShape(task, row, 'inputs'), ...rowHoldsSavedTaskElementId(stage, task, row) })),
2639
2653
  outputs: (task.data?.outputs ?? []).map((row) => ({
@@ -3055,6 +3069,13 @@ export function collectPreservation(plan) {
3055
3069
  .filter((entry) => entry !== undefined);
3056
3070
  if (connectorRows.length)
3057
3071
  preservation.connectorRows = connectorRows;
3072
+ // A subscription's own non-empty `bindings` (copies of the root Property rows
3073
+ // its filter reads), which compile writes empty (preserve.ts).
3074
+ const subscriptionBindings = caseSubscriptionOwners(plan)
3075
+ .filter(({ bag }) => Array.isArray(bag.bindings) && bag.bindings.length > 0)
3076
+ .map(({ key, bag }) => ({ owner: key, bindings: structuredClone(bag.bindings) }));
3077
+ if (subscriptionBindings.length)
3078
+ preservation.subscriptionBindings = subscriptionBindings;
3058
3079
  const subscriptionFilterEntries = preservedSubscriptionFilters(plan);
3059
3080
  if (subscriptionFilterEntries.length)
3060
3081
  preservation.subscriptionFilters = subscriptionFilterEntries;
@@ -159,6 +159,19 @@ export interface PreservedActionDataFields extends PreservedTaskRef {
159
159
  }
160
160
  interface ConditionIdentity {
161
161
  id?: string;
162
+ /**
163
+ * A task entry condition's saved `isInterrupting`. Studio Web writes it on
164
+ * some task entry conditions; the platform reads it only on a stage's
165
+ * (`cancelStagesAndTasks`), so the builder has no task option for it and it
166
+ * rides in the payload. Ignored on any other condition.
167
+ */
168
+ isInterrupting?: boolean;
169
+ /**
170
+ * The task entry condition was saved with no `displayName`. Compile names
171
+ * every condition (`"<task> entry"`); the name goes again while the source
172
+ * still gives the condition none (the name compile wrote is the derived one).
173
+ */
174
+ noDisplayName?: true;
162
175
  /** The Designer's ids of the canvas edges drawn for the condition. */
163
176
  edgeIds?: string[];
164
177
  /**
@@ -503,6 +516,19 @@ export interface CaseJsonPreservation {
503
516
  * (`case/connector-saved-rows.ts`).
504
517
  */
505
518
  connectorRows?: PreservedConnectorRows[];
519
+ /**
520
+ * A subscription's own `bindings` (a wait-for-connector task or rule, an
521
+ * event trigger), saved non-empty, keyed by owner (`task:<stageId>:<taskId>`).
522
+ * Studio Web copies there the root `Property` binding rows its filter reads
523
+ * (`{ id, resource: 'Property', resourceKey: '<stageId>-<taskId>',
524
+ * propertyAttribute: 'entityScope', ... }`); compile writes `bindings: []`.
525
+ * Compile writes back each saved row whose id the subscription still reads
526
+ * (`=bindings.<id>`), and only where it wrote the list empty.
527
+ */
528
+ subscriptionBindings?: Array<{
529
+ owner: string;
530
+ bindings: Array<Record<string, unknown>>;
531
+ }>;
506
532
  /**
507
533
  * Action tasks' Designer-owned `data` fields: the `context` rows the Designer
508
534
  * saves with a form (its `hitlType`, quick-form schema ids, and a copy of the
@@ -494,6 +494,12 @@ export function caseJsonPreservationErrors(payload) {
494
494
  && (!Array.isArray(payload.connectorConfigV2) || payload.connectorConfigV2.some((key) => typeof key !== 'string' || !key)))
495
495
  errors.push('preserved connectorConfigV2 must be a list of connector element keys (task:<id>, rule:<id> or trigger:<id>)');
496
496
  errors.push(...connectorRowErrors(payload.connectorRows));
497
+ for (const entry of payload.subscriptionBindings ?? []) {
498
+ if (typeof entry?.owner !== 'string' || !/^(trigger|task|rule):/.test(entry.owner))
499
+ errors.push(`preserved subscription bindings owner ${JSON.stringify(entry?.owner)} is not a trigger, task or rule key`);
500
+ else if (!Array.isArray(entry.bindings) || !entry.bindings.every((row) => row !== null && typeof row === 'object' && !Array.isArray(row) && typeof row.id === 'string' && row.id !== ''))
501
+ errors.push(`preserved subscription bindings of "${entry.owner}" must be binding rows with an id`);
502
+ }
497
503
  for (const index of payload.manualTriggerServiceTypeNone ?? [])
498
504
  if (!Number.isInteger(index) || index < 0)
499
505
  errors.push(`manual trigger position "${index}" is not a non-negative integer`);
@@ -17,7 +17,7 @@ import { buildConnectorInputs, nestConnectorBody, transportHttpMethod } from '..
17
17
  import { carriedConnectorFieldsRefusal, withCarriedFields } from '../core/carried-connector-fields.js';
18
18
  import { connectorTaskIdentity, sameConnectorOperation, withCurrentCaches, writeOptionalConfiguration } from './connector-saved-config.js';
19
19
  import { applyConnectorContexts } from './connector-saved-context.js';
20
- import { applyConnectorRows } from './connector-saved-rows.js';
20
+ import { applyConnectorRows, droppedConnectorOutputRows } from './connector-saved-rows.js';
21
21
  import { connectorActivityMetadata, connectorEventFilterTree, connectorEventMetadata } from '../core/connector-v2-metadata.js';
22
22
  import { EQUALS_EXPR_DIALECT } from '../core/connector-checks.js';
23
23
  import { bindingLabelRefusal, connectionStubMessage } from '../core/binding-messages.js';
@@ -555,6 +555,7 @@ export function applyPreservation(result, preservation, options = {}) {
555
555
  applySubscriptionFilters(result, preservation);
556
556
  // After the ids are restored: an unchanged connector element takes its saved own io rows.
557
557
  applyConnectorRows(result, preservation.connectorRows);
558
+ applySubscriptionBindings(result, preservation.subscriptionBindings);
558
559
  // Last, once every row has its saved name and the connector rows are back.
559
560
  restoreOutputInterleaving(result, preservation.identities);
560
561
  Object.assign(result, preservation.topLevel ?? {});
@@ -1282,6 +1283,25 @@ function restoreNoTasks(data, spelling) {
1282
1283
  else
1283
1284
  data.tasks = [];
1284
1285
  }
1286
+ /**
1287
+ * A task entry condition's saved `isInterrupting`, and the absence of a name
1288
+ * it was saved with (`ConditionIdentity`), by position. The name goes only
1289
+ * while it is the one compile derives for an unnamed condition, `"<task>
1290
+ * entry"` (with the suffix a repeat gets): a name the author typed stays.
1291
+ */
1292
+ function restoreTaskEntryShape(task, wanted) {
1293
+ const conditions = Array.isArray(task?.entryConditions) ? task.entryConditions : [];
1294
+ const derived = new RegExp(`^${String(task?.displayName ?? '').replace(/[.*+?^${}()|[\]\\]/g, '\\$&')} entry( \\d+)?$`);
1295
+ (wanted ?? []).forEach((shape, index) => {
1296
+ const condition = conditions[index];
1297
+ if (!condition)
1298
+ return;
1299
+ if (typeof shape.isInterrupting === 'boolean' && condition.isInterrupting === undefined)
1300
+ condition.isInterrupting = shape.isInterrupting;
1301
+ if (shape.noDisplayName === true && typeof condition.displayName === 'string' && derived.test(condition.displayName))
1302
+ delete condition.displayName;
1303
+ });
1304
+ }
1285
1305
  /**
1286
1306
  * Retry the output-id claims that found their carried id held by another row
1287
1307
  * (`claimRowId` returned `false`), until none moves.
@@ -1736,6 +1756,7 @@ function applyPreservedIdentities(result, preservation, warn) {
1736
1756
  savedTaskElementIds.push({ stage, task, elementId: taskIdentity.elementId, rows: elementIdRows });
1737
1757
  restoreEmptyLists(task, taskIdentity.emptyLists, TASK_EMPTY_LISTS);
1738
1758
  takeConditions(task?.entryConditions, taskIdentity.entryConditions);
1759
+ restoreTaskEntryShape(task, taskIdentity.entryConditions);
1739
1760
  // An input row is matched by name when the name is unique on both sides
1740
1761
  // (an input the author removed leaves the rows after it in place), else
1741
1762
  // by position.
@@ -1808,6 +1829,13 @@ function applyPreservedIdentities(result, preservation, warn) {
1808
1829
  }
1809
1830
  const metadata = result.metadata;
1810
1831
  takeConditions(metadata.caseExitRules, identities.caseExitRules);
1832
+ // A built own row the element was saved without is dropped later
1833
+ // (`applyConnectorRows`), so its id is free for a saved row that carries it.
1834
+ // Example: a connector task saved with only its `Error` row compiles with a
1835
+ // `response11` row too; the task saved with `response11` takes it back.
1836
+ for (const row of droppedConnectorOutputRows(result, preservation.connectorRows))
1837
+ if (typeof row.id === 'string')
1838
+ heldOutputIds.delete(row.id);
1811
1839
  settleDeferredClaims(deferredClaims, heldOutputIds, (target, row) => claimRowId(target, row, target.id));
1812
1840
  takeSlas(metadata.slaRules, identities.slaRules);
1813
1841
  restoreEmptyLists(metadata, identities.emptyLists, CASE_EMPTY_LISTS);
@@ -1970,6 +1998,27 @@ function applyPreservedIdentities(result, preservation, warn) {
1970
1998
  for (const { condition, edgeIds } of edgeLinked)
1971
1999
  condition.edgeIds = [...edgeIds];
1972
2000
  }
2001
+ /**
2002
+ * Write each subscription's saved own `bindings` back
2003
+ * ({@link CaseJsonPreservation.subscriptionBindings}), after the ids are
2004
+ * restored, so an owner key names the same element. Only where compile wrote
2005
+ * the list empty, and only the rows the subscription still reads
2006
+ * (`=bindings.<id>` anywhere in it): an edit that drops a filter drops its row.
2007
+ */
2008
+ function applySubscriptionBindings(result, entries) {
2009
+ if (!entries?.length)
2010
+ return;
2011
+ const byOwner = new Map(entries.map((entry) => [entry.owner, entry.bindings]));
2012
+ for (const { key, bag } of caseSubscriptionOwners(result)) {
2013
+ const saved = byOwner.get(key);
2014
+ if (!saved || !Array.isArray(bag.bindings) || bag.bindings.length !== 0)
2015
+ continue;
2016
+ const text = JSON.stringify({ ...bag, bindings: undefined });
2017
+ const read = saved.filter((row) => new RegExp(`bindings\\.${String(row.id).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![\\w$])`).test(text));
2018
+ if (read.length)
2019
+ bag.bindings = read.map((row) => structuredClone(row));
2020
+ }
2021
+ }
1973
2022
  /** Every condition and rule id in a plan: the conditions under `entryConditions`, `exitConditions` and `caseExitRules`, and their rules. */
1974
2023
  function conditionAndRuleIds(plan) {
1975
2024
  const ids = new Set();
@@ -110,6 +110,27 @@ export declare const CASE_FILTER_SPELLING: CaseFilterSpelling;
110
110
  * // { filters: { expression: "=js:(`((Id=='{var_0}'))`)", variables: { var_0: '=js:(vars.request.Id)' } } }
111
111
  */
112
112
  export declare function caseSubscriptionBody(rc: ResolvedConnector, where: Record<string, unknown>, conditions: readonly ReadEventFilter[], elementId: string, spelling?: CaseFilterSpelling): Record<string, unknown> | undefined;
113
+ /**
114
+ * A saved subscription `body` with event parameters in `queryParams` and no
115
+ * `filters`, as compile writes it back: with the match expression those
116
+ * parameters give (`filters: { expression: "(k == 'v') && ..." }`), first, as
117
+ * {@link caseSubscriptionBody} orders it. Any other body comes back as it is.
118
+ *
119
+ * Such a body is what the SDK wrote before it wrote the expression (one Studio
120
+ * Web plan in the brownfield corpus has it too). The engine reads only
121
+ * `filters.expression` to match an event, so decompile reads the body back and
122
+ * compile adds the expression (`checkSubscriptionExpression` in decompile.ts).
123
+ * The carries that keep a saved element while it is unchanged
124
+ * (`connector-saved-context.ts`, `connector-saved-rows.ts`) compare the input
125
+ * values compile writes with the saved ones; they record the saved body this
126
+ * way, so the added expression is not read as an edit that drops the element's
127
+ * saved context and rows.
128
+ *
129
+ * @example
130
+ * // { queryParams: { entityScope: 'tenant' } }
131
+ * // -> { filters: { expression: "(entityScope == 'tenant')" }, queryParams: { entityScope: 'tenant' } }
132
+ */
133
+ export declare function withScopeExpression(body: unknown, owner: string): unknown;
113
134
  /** One subscription in a Case plan: the bag that carries it, keyed by its owner. */
114
135
  export interface CaseSubscriptionOwner {
115
136
  /** `trigger:<node id>`, `task:<stage id>:<task id>` or `rule:<stage id>:<rule id>`. */
@@ -185,6 +185,45 @@ export function caseSubscriptionBody(rc, where, conditions, elementId, spelling
185
185
  body.parameters = parameters;
186
186
  return Object.keys(body).length ? body : undefined;
187
187
  }
188
+ /**
189
+ * A saved subscription `body` with event parameters in `queryParams` and no
190
+ * `filters`, as compile writes it back: with the match expression those
191
+ * parameters give (`filters: { expression: "(k == 'v') && ..." }`), first, as
192
+ * {@link caseSubscriptionBody} orders it. Any other body comes back as it is.
193
+ *
194
+ * Such a body is what the SDK wrote before it wrote the expression (one Studio
195
+ * Web plan in the brownfield corpus has it too). The engine reads only
196
+ * `filters.expression` to match an event, so decompile reads the body back and
197
+ * compile adds the expression (`checkSubscriptionExpression` in decompile.ts).
198
+ * The carries that keep a saved element while it is unchanged
199
+ * (`connector-saved-context.ts`, `connector-saved-rows.ts`) compare the input
200
+ * values compile writes with the saved ones; they record the saved body this
201
+ * way, so the added expression is not read as an edit that drops the element's
202
+ * saved context and rows.
203
+ *
204
+ * @example
205
+ * // { queryParams: { entityScope: 'tenant' } }
206
+ * // -> { filters: { expression: "(entityScope == 'tenant')" }, queryParams: { entityScope: 'tenant' } }
207
+ */
208
+ export function withScopeExpression(body, owner) {
209
+ if (!body || typeof body !== 'object' || Array.isArray(body))
210
+ return body;
211
+ const saved = body;
212
+ const params = saved.queryParams;
213
+ if (saved.filters !== undefined || !params || typeof params !== 'object' || Array.isArray(params))
214
+ return body;
215
+ let expression;
216
+ try {
217
+ expression = eventMatchExpression(eventScopeClauses(params, owner).map((c) => `(${c})`), []);
218
+ }
219
+ catch {
220
+ return body;
221
+ }
222
+ if (expression === '' || literalsOf(params).some((v) => literalProblem(v, false)))
223
+ return body;
224
+ return { filters: { expression }, ...saved };
225
+ }
226
+ const literalsOf = (params) => Object.values(params).map(String);
188
227
  const SUBSCRIPTION_SERVICE_TYPES = new Set(['Intsvc.EventTrigger', 'Intsvc.WaitForEvent']);
189
228
  /**
190
229
  * Every connector event subscription in a plan, keyed by the ids of what owns
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.120.8",
3
+ "version": "6.120.10",
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": "3a3d4e840c450128bb797ce23c1bcbcb2a783704"
127
+ "gitref": "78fafbfe39362afad92df9f92d3dcb418118d84b"
128
128
  }