@uipath/maestro-builder-sdk 6.86.19 → 6.86.20

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
@@ -42,6 +42,7 @@ interface Rule {
42
42
  selectedStageId?: string;
43
43
  selectedStageIds?: string[];
44
44
  selectedTasksIds?: string[];
45
+ selectedTriggerIds?: unknown;
45
46
  conditionExpression?: string;
46
47
  uipath?: SubscriptionBag;
47
48
  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 !== '{}')
@@ -2793,14 +2820,11 @@ export function decompileWithDiagnostics(plan, options = {}) {
2793
2820
  const refs = buildRefs(plan, options.library, options.bestEffort ? diagnostics : undefined);
2794
2821
  const selectNextStage = selectNextStageByExit(plan, refs);
2795
2822
  const metadata = plan.metadata ?? {};
2796
- const triggers = (plan.nodes ?? []).filter(isTrigger);
2797
- const triggerNameById = new Map();
2823
+ const consts = triggerConsts(plan);
2824
+ const triggers = consts.map(({ trigger }) => trigger);
2798
2825
  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)};`);
2826
+ consts.forEach(({ trigger, name }, index) => {
2827
+ out.line(0, `const ${name} = ${triggerSource(trigger, index, plan, refs)};`);
2804
2828
  });
2805
2829
  if (triggers.length)
2806
2830
  out.line(0, '');
@@ -2841,8 +2865,9 @@ export function decompileWithDiagnostics(plan, options = {}) {
2841
2865
  throw new Error('allowAdhocOptionalStageTasks must be boolean.');
2842
2866
  chain.line(depth, metadata.allowAdhocOptionalStageTasks ? '.allowAdhocTasks()' : '.allowAdhocTasks(false)');
2843
2867
  }
2844
- emitVariables(chain, depth, plan, triggerNameById, triggers.map(isTimerTrigger));
2845
- triggers.forEach((_trigger, index) => chain.line(depth, `.trigger(trigger${index + 1})`));
2868
+ emitVariables(chain, depth, plan, refs.triggerVarById, triggers.map(isTimerTrigger));
2869
+ for (const { name } of consts)
2870
+ chain.line(depth, `.trigger(${name})`);
2846
2871
  (metadata.slaRules ?? []).forEach((sla, index) => chain.line(depth, `.sla(${slaSource(sla, index)})`));
2847
2872
  for (const event of metadata.businessEvents ?? [])
2848
2873
  chain.line(depth, businessEventSource(event));
@@ -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
  });
@@ -1613,7 +1615,7 @@ function applyPreservedIdentities(result, preservation) {
1613
1615
  // then renamed to its designer id, and the exit points at nothing. Silently:
1614
1616
  // `case check` says OK and `uip maestro case validate` reports nothing about it.
1615
1617
  const referenceFields = new Set([
1616
- 'elementId', 'exitToStageId', 'selectedStageId', 'selectedStageIds', 'selectedTasksIds',
1618
+ 'elementId', 'exitToStageId', 'selectedStageId', 'selectedStageIds', 'selectedTasksIds', 'selectedTriggerIds',
1617
1619
  'slaId', 'escalationId', 'originalVar', 'var', 'source', 'target',
1618
1620
  ]);
1619
1621
  const preservedOutputSources = [];
@@ -3426,6 +3428,15 @@ function emitRule(r, seed, ownerId, ids, resolver, site) {
3426
3428
  return tid;
3427
3429
  });
3428
3430
  }
3431
+ if (r.rule === 'case-entered' && r.triggers !== undefined) {
3432
+ // Absent means any trigger; a list narrows the rule to those triggers.
3433
+ out.selectedTriggerIds = r.triggers.map((t, i) => {
3434
+ const id = resolver.triggerIdByRef.get(t);
3435
+ if (!id)
3436
+ 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(...).`);
3437
+ return id;
3438
+ });
3439
+ }
3429
3440
  if (r.rule === 'wait-for-connector') {
3430
3441
  // A rule always carries the subscription under `uipath` (placeholder-safe).
3431
3442
  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.20",
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": "e802da118b3c4f36c932a0e15950c80cf88b7c14"
107
107
  }