@uipath/maestro-builder-sdk 6.86.19 → 6.86.21

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.
@@ -49,6 +49,19 @@ export interface RuleOpts {
49
49
  * "Reject") must be qualified at the source, e.g. `'Withdraw Request (Counsel)'`.
50
50
  */
51
51
  tasks?: string[];
52
+ /**
53
+ * For a `case-entered` rule: the triggers whose start of the case fires it,
54
+ * as the trigger objects passed to {@link CaseBuilder.trigger}. Omit it and
55
+ * the rule fires whichever trigger starts the case. Emitted as the rule's
56
+ * `selectedTriggerIds`; the platform lowers each listed trigger to its own
57
+ * `CaseEntered` condition naming that trigger.
58
+ *
59
+ * @example
60
+ * const web = manualTrigger({ name: 'Web form' });
61
+ * casePlan('intake').trigger(web)
62
+ * .stage('Triage', (s) => s.entryWhen(rule('case-entered', { triggers: [web] })))
63
+ */
64
+ triggers?: BuiltTrigger[];
52
65
  /**
53
66
  * For a `wait-for-connector` rule — the connector event to suspend on. Omit for
54
67
  * a placeholder (both fields default to `"placeholder"`). Emits the rule's
@@ -16,6 +16,8 @@ interface IoRow {
16
16
  _jsonSchema?: unknown;
17
17
  /** A third copy of an action form output's `body` the Designer can save. */
18
18
  jsonSchema?: unknown;
19
+ /** The readable alias `@uipath/case-schema`'s id migration stamps on a row. */
20
+ canonicalId?: string;
19
21
  custom?: boolean;
20
22
  elementId?: string;
21
23
  var?: string;
@@ -42,6 +44,7 @@ interface Rule {
42
44
  selectedStageId?: string;
43
45
  selectedStageIds?: string[];
44
46
  selectedTasksIds?: string[];
47
+ selectedTriggerIds?: unknown;
45
48
  conditionExpression?: string;
46
49
  uipath?: SubscriptionBag;
47
50
  slaId?: string;
@@ -118,6 +118,7 @@ function buildRefs(plan, library, diagnostics) {
118
118
  const refs = {
119
119
  stageLabelById: new Map(),
120
120
  taskNameById: new Map(),
121
+ triggerVarById: new Map(),
121
122
  slaNameById: new Map(),
122
123
  escalationNameById: new Map(),
123
124
  bindingById: new Map(),
@@ -143,6 +144,9 @@ function buildRefs(plan, library, diagnostics) {
143
144
  }
144
145
  }
145
146
  addSlaRefs(plan.metadata?.slaRules, refs, seenSlaIds);
147
+ for (const { trigger, name } of triggerConsts(plan))
148
+ if (trigger.id)
149
+ refs.triggerVarById.set(trigger.id, name);
146
150
  return refs;
147
151
  }
148
152
  /**
@@ -183,6 +187,14 @@ function variableKeys(plan) {
183
187
  }
184
188
  return keys;
185
189
  }
190
+ /**
191
+ * Each trigger node with the name of the const its decompile declares. The one
192
+ * place that names them: the declarations, `.trigger(...)` and a `case-entered`
193
+ * rule's `triggers` all read it, so they cannot drift apart.
194
+ */
195
+ function triggerConsts(plan) {
196
+ return (plan.nodes ?? []).filter(isTrigger).map((trigger, index) => ({ trigger, name: `trigger${index + 1}` }));
197
+ }
186
198
  function diagnose(refs, diagnostic) {
187
199
  if (!refs.diagnostics)
188
200
  throw new Error(diagnostic.message);
@@ -568,6 +580,21 @@ function emitRule(rule, refs) {
568
580
  });
569
581
  entries.push(['tasks', `[${names.join(', ')}]`]);
570
582
  }
583
+ if (rule.selectedTriggerIds !== undefined) {
584
+ // Only `case-entered` reads it: on any other rule it has no authored spelling.
585
+ if (rule.rule !== 'case-entered')
586
+ throw new Error(`rule "${rule.rule}" has selectedTriggerIds, which only a case-entered rule takes; remove the field.`);
587
+ const ids = rule.selectedTriggerIds;
588
+ if (!Array.isArray(ids) || !ids.every((id) => typeof id === 'string'))
589
+ throw new Error(`rule "${rule.rule}" has selectedTriggerIds that is not a list of trigger id strings.`);
590
+ const names = ids.map((id) => {
591
+ const name = refs.triggerVarById.get(id);
592
+ if (name === undefined)
593
+ throw new Error(`rule "${rule.rule}" selects unknown trigger id "${id}"; the case has no trigger with that id.`);
594
+ return name;
595
+ });
596
+ entries.push(['triggers', `[${names.join(', ')}]`]);
597
+ }
571
598
  if (rule.rule === 'wait-for-connector') {
572
599
  const connector = waitConnectorSpec(rule.uipath, `rule "${rule.rule}"`, refs);
573
600
  if (connector && connector !== '{}')
@@ -704,8 +731,10 @@ const ACTION_DATA_KEYS = new Set([
704
731
  */
705
732
  const ACTION_INPUT_ROW_KEYS = new Set([
706
733
  'name', 'type', 'subType', 'displayName', 'value', 'required', 'options', 'body', 'source', 'id', 'var', 'elementId',
734
+ 'canonicalId',
707
735
  ]);
708
- const ACTION_OUTPUT_ROW_KEYS = new Set([...ACTION_INPUT_ROW_KEYS, 'target', 'originalVar', '_jsonSchema', 'jsonSchema']);
736
+ const ACTION_OUTPUT_ROW_KEYS = new Set([...ACTION_INPUT_ROW_KEYS, 'target', 'originalVar', '_jsonSchema', 'jsonSchema']
737
+ .filter((key) => key !== 'canonicalId'));
709
738
  function actionFields(rows, side, owner) {
710
739
  if (!rows?.length)
711
740
  return undefined;
@@ -716,6 +745,12 @@ function actionFields(rows, side, owner) {
716
745
  throw new Error(`${owner} form ${side} "${row.name ?? '?'}" has unsupported field "${unknown}".`);
717
746
  // The key names alone are not enough: compile rewrites these from the
718
747
  // row's id and value, so a row whose values differ would change silently.
748
+ // `canonicalId` is the readable alias `@uipath/case-schema`'s id migration
749
+ // stamps on a row (and then skips it on); it is carried only as a copy of
750
+ // the id (`actionInputShape`), since any other value renames how the
751
+ // Designer spells references to the row.
752
+ if (side === 'input' && row.canonicalId !== undefined && (row.id === undefined || row.canonicalId !== row.id))
753
+ throw new Error(`${owner} form input "${row.name ?? '?'}" has canonicalId "${String(row.canonicalId)}", which is not its id.`);
719
754
  if (row.var !== undefined && side === 'input' && row.var !== row.id)
720
755
  throw new Error(`${owner} form input "${row.name ?? '?'}" has var "${String(row.var)}", which is not its id; compile writes var as the id.`);
721
756
  if (side === 'output' && row.var !== undefined && row.var !== row.value)
@@ -2179,9 +2214,13 @@ function prunePreservation(preservation, plan) {
2179
2214
  * `elementId` that is not the task's is carried.
2180
2215
  */
2181
2216
  function actionInputShape(task, row) {
2182
- if (task.type !== 'action' || !row.id || row.elementId === undefined || row.elementId === task.elementId)
2217
+ if (task.type !== 'action' || !row.id)
2183
2218
  return {};
2184
- return { elementId: row.elementId };
2219
+ return {
2220
+ ...(row.elementId !== undefined && row.elementId !== task.elementId ? { elementId: row.elementId } : {}),
2221
+ // `actionFields` has checked it is a copy of the id.
2222
+ ...(row.canonicalId !== undefined ? { canonicalId: true } : {}),
2223
+ };
2185
2224
  }
2186
2225
  /**
2187
2226
  * What an action form output row has that compile would not write the same
@@ -2793,14 +2832,11 @@ export function decompileWithDiagnostics(plan, options = {}) {
2793
2832
  const refs = buildRefs(plan, options.library, options.bestEffort ? diagnostics : undefined);
2794
2833
  const selectNextStage = selectNextStageByExit(plan, refs);
2795
2834
  const metadata = plan.metadata ?? {};
2796
- const triggers = (plan.nodes ?? []).filter(isTrigger);
2797
- const triggerNameById = new Map();
2835
+ const consts = triggerConsts(plan);
2836
+ const triggers = consts.map(({ trigger }) => trigger);
2798
2837
  const out = new Emit();
2799
- triggers.forEach((trigger, index) => {
2800
- const variableName = `trigger${index + 1}`;
2801
- if (trigger.id)
2802
- triggerNameById.set(trigger.id, variableName);
2803
- out.line(0, `const ${variableName} = ${triggerSource(trigger, index, plan, refs)};`);
2838
+ consts.forEach(({ trigger, name }, index) => {
2839
+ out.line(0, `const ${name} = ${triggerSource(trigger, index, plan, refs)};`);
2804
2840
  });
2805
2841
  if (triggers.length)
2806
2842
  out.line(0, '');
@@ -2841,8 +2877,9 @@ export function decompileWithDiagnostics(plan, options = {}) {
2841
2877
  throw new Error('allowAdhocOptionalStageTasks must be boolean.');
2842
2878
  chain.line(depth, metadata.allowAdhocOptionalStageTasks ? '.allowAdhocTasks()' : '.allowAdhocTasks(false)');
2843
2879
  }
2844
- emitVariables(chain, depth, plan, triggerNameById, triggers.map(isTimerTrigger));
2845
- triggers.forEach((_trigger, index) => chain.line(depth, `.trigger(trigger${index + 1})`));
2880
+ emitVariables(chain, depth, plan, refs.triggerVarById, triggers.map(isTimerTrigger));
2881
+ for (const { name } of consts)
2882
+ chain.line(depth, `.trigger(${name})`);
2846
2883
  (metadata.slaRules ?? []).forEach((sla, index) => chain.line(depth, `.sla(${slaSource(sla, index)})`));
2847
2884
  for (const event of metadata.businessEvents ?? [])
2848
2885
  chain.line(depth, businessEventSource(event));
@@ -181,11 +181,12 @@ interface StageIdentity {
181
181
  entryConditions?: ConditionIdentity[];
182
182
  /** The resource the rows' `fields` / `omit` describe; they are applied only while the task still names it. */
183
183
  resource?: ResourceTaskIdentity;
184
- /** `elementId` only for an action form input whose row names another element than its task. `fields`: a resource task row's Designer fields compile does not write (`displayName`, `title`, `body`, ...). */
184
+ /** `elementId` only for an action form input whose row names another element than its task. `canonicalId: true`: an action form input saved with the schema migration's `canonicalId`, a copy of its id. `fields`: a resource task row's Designer fields compile does not write (`displayName`, `title`, `body`, ...). */
185
185
  inputs?: Array<{
186
186
  name: string;
187
187
  id?: string;
188
188
  elementId?: string;
189
+ canonicalId?: true;
189
190
  fields?: Record<string, unknown>;
190
191
  }>;
191
192
  /** `originalVar` only when it is not the row's `id` (the serializer's own spelling). `elementId` when an action form output names another element than its task. `fields` as on an input. `omit`: the fields an action form output (`target`, `_jsonSchema`, `elementId`) or a resource extract (`target`) was saved without that compile writes. `target`: which of the row's variables its saved `target` names when that is not its id (`=<var>` or `=<originalVar>`; compile writes `=<id>`). `bodyCopies`: the extra copies of its `body` an action form output was saved with (`jsonSchema`), which compile writes back from the body. */
@@ -9,7 +9,7 @@ export const ANY_ESCALATION_ID = 'any';
9
9
  /** `expression` is a gate any rule can carry. */
10
10
  const COMMON = ['expression'];
11
11
  const RULE_OPTIONS = {
12
- 'case-entered': [],
12
+ 'case-entered': ['triggers'],
13
13
  'required-tasks-completed': [],
14
14
  'required-stages-completed': [],
15
15
  'selected-stage-completed': ['stage', 'stages'],
@@ -228,6 +228,7 @@ function serializeCase(built, opts) {
228
228
  escalationId: new Map(),
229
229
  escalationIdByName: new Map(),
230
230
  businessEvents: new Set((built.businessEvents ?? []).map((event) => event.name)),
231
+ triggerIdByRef: new Map(),
231
232
  conditionName: conditionNamer(built),
232
233
  elementSeededIds: [],
233
234
  subscriptions: [],
@@ -293,6 +294,7 @@ function serializeCase(built, opts) {
293
294
  // trigger-bound In-arg can resolve `{ from }` to the node it wires onto.
294
295
  const triggerNodeByRef = new Map();
295
296
  built.triggers.forEach((t, i) => triggerNodeByRef.set(t, triggerNodes[i]));
297
+ built.triggers.forEach((t, i) => resolver.triggerIdByRef.set(t, triggerNodes[i].id));
296
298
  built.stages.forEach((stage, si) => {
297
299
  nodes.push(emitStage(stage, stageLanes[si], si, stageIds[si], taskIds[si], ids, resolver));
298
300
  });
@@ -1536,6 +1538,10 @@ function applyPreservedIdentities(result, preservation) {
1536
1538
  Object.assign(input, { id: row.id, var: row.id, elementId: row.elementId ?? task.elementId });
1537
1539
  if (input.elementId === undefined)
1538
1540
  delete input.elementId;
1541
+ // The schema migration's readable alias of the id, which it stamps
1542
+ // once and then skips the row on: the same id again.
1543
+ if (row.canonicalId === true)
1544
+ input.canonicalId = row.id;
1539
1545
  return;
1540
1546
  }
1541
1547
  takeRow(input, row.id, false);
@@ -1613,7 +1619,7 @@ function applyPreservedIdentities(result, preservation) {
1613
1619
  // then renamed to its designer id, and the exit points at nothing. Silently:
1614
1620
  // `case check` says OK and `uip maestro case validate` reports nothing about it.
1615
1621
  const referenceFields = new Set([
1616
- 'elementId', 'exitToStageId', 'selectedStageId', 'selectedStageIds', 'selectedTasksIds',
1622
+ 'elementId', 'exitToStageId', 'selectedStageId', 'selectedStageIds', 'selectedTasksIds', 'selectedTriggerIds',
1617
1623
  'slaId', 'escalationId', 'originalVar', 'var', 'source', 'target',
1618
1624
  ]);
1619
1625
  const preservedOutputSources = [];
@@ -3426,6 +3432,15 @@ function emitRule(r, seed, ownerId, ids, resolver, site) {
3426
3432
  return tid;
3427
3433
  });
3428
3434
  }
3435
+ if (r.rule === 'case-entered' && r.triggers !== undefined) {
3436
+ // Absent means any trigger; a list narrows the rule to those triggers.
3437
+ out.selectedTriggerIds = r.triggers.map((t, i) => {
3438
+ const id = resolver.triggerIdByRef.get(t);
3439
+ if (!id)
3440
+ throw new CompileRefusal('UNKNOWN_TRIGGER_REF', `rule "case-entered" in ${site} lists trigger #${i + 1}${t && typeof t === 'object' && t.name ? ` ("${t.name}")` : ''}, which the case does not declare — pass the object you gave .trigger(...).`);
3441
+ return id;
3442
+ });
3443
+ }
3429
3444
  if (r.rule === 'wait-for-connector') {
3430
3445
  // A rule always carries the subscription under `uipath` (placeholder-safe).
3431
3446
  out[CASE_FORMAT_PROFILE.waitConnectorRuleBagField] = waitConnectorBag(r.connector, { alwaysContext: true }, resolver, `${ownerId}-${ruleId}`, `wait-for-connector rule in ${site}`);
@@ -757,6 +757,7 @@ export declare const REFUSALS: {
757
757
  readonly UNKNOWN_SLA_REF: "lowering";
758
758
  readonly UNKNOWN_STAGE_REF: "lowering";
759
759
  readonly UNKNOWN_TASK_REF: "lowering";
760
+ readonly UNKNOWN_TRIGGER_REF: "lowering";
760
761
  readonly UPDATES_NOT_SUPPORTED: "lowering";
761
762
  readonly UPDATE_INPUT_READONLY: "lint";
762
763
  readonly UPDATE_UNKNOWN_VAR: "lint";
@@ -830,6 +830,7 @@ export const REFUSALS = {
830
830
  UNKNOWN_SLA_REF: 'lowering',
831
831
  UNKNOWN_STAGE_REF: 'lowering',
832
832
  UNKNOWN_TASK_REF: 'lowering',
833
+ UNKNOWN_TRIGGER_REF: 'lowering',
833
834
  UPDATES_NOT_SUPPORTED: 'lowering',
834
835
  UPDATE_INPUT_READONLY: 'lint',
835
836
  UPDATE_UNKNOWN_VAR: 'lint',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.86.19",
3
+ "version": "6.86.21",
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",
@@ -103,5 +103,5 @@
103
103
  "@types/node": "^22.7.0",
104
104
  "esbuild": "^0.28.1"
105
105
  },
106
- "gitref": "b5c4c83fdc2104407f0c15ecdfb279a0a567b063"
106
+ "gitref": "e0ee81ffb8c846fe651e90f1d0e2d879ccde3306"
107
107
  }