@uipath/maestro-builder-sdk 6.86.3 → 6.86.5

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.
@@ -122,7 +122,12 @@ export type BpmnNode = {
122
122
  name?: string;
123
123
  attachedTo: string;
124
124
  cancelActivity: boolean;
125
- event: EventDef;
125
+ /**
126
+ * Absent for a boundary with no event definition: a deployed process can carry
127
+ * one, and the builder keeps it as written. The platform never fires it, so
128
+ * `check` warns (BPMN_BOUNDARY_NO_EVENT).
129
+ */
130
+ event?: EventDef;
126
131
  /** A `uipath:activity` payload on the boundary — see {@link ExtensionPayload}. */
127
132
  payload?: ExtensionPayload;
128
133
  } | {
@@ -774,8 +779,13 @@ export interface ThrowOpts {
774
779
  /**
775
780
  * Options for `.boundaryEvent()`: the activity it attaches to, whether it
776
781
  * interrupts that activity, and the event definition — exactly one of
777
- * `message` / `timer` / `error` (checked in the order error, timer, message;
778
- * none at all is refused).
782
+ * `message` / `timer` / `error` (checked in the order error, timer, message).
783
+ *
784
+ * None at all writes a `bpmn:boundaryEvent` with no event definition. The platform
785
+ * never triggers such a boundary (the local engine treats it as a catch-all error
786
+ * boundary, which production does not), so `check` warns (BPMN_BOUNDARY_NO_EVENT); the builder
787
+ * still writes it, because deployed processes carry the shape and
788
+ * `uip maestro bpmn validate` accepts it, so a decompiled one has to compile back.
779
789
  */
780
790
  export interface BoundaryOpts {
781
791
  /** Display name the designer shows on the event. */
@@ -796,8 +796,6 @@ class ScopeBuilder {
796
796
  event = { type: 'timer', timer: normTimer(opts.timer) };
797
797
  else if (opts.message !== undefined)
798
798
  event = { type: 'message', messageRef: this._defs.messageRef(opts.message) };
799
- else
800
- throw new CompileRefusal('BPMN_BOUNDARY_NO_EVENT', `boundaryEvent "${id}" needs one of { message, timer, error }.`);
801
799
  return this.push({
802
800
  kind: 'boundaryEvent',
803
801
  id,
@@ -1360,6 +1360,22 @@ inEventSubProcess = false) {
1360
1360
  // An unknown target is the serializer's BOUNDARY_UNATTACHED.
1361
1361
  if (target && !isActivityNode(target))
1362
1362
  diags.push({ level: 'error', code: 'BOUNDARY_NOT_ACTIVITY', message: `Boundary event "${n.id}" must attach to an activity, not "${target.kind}".`, where: n.id });
1363
+ // No definition means the platform never triggers it: PO.BpmnEngine arms it as a
1364
+ // timer with no props, and its error routing only considers error boundaries. So
1365
+ // its path is dead in production. (The local engine still runs it as a catch-all
1366
+ // error boundary, a legacy V1-port behaviour — #1826.) A warning,
1367
+ // not an error: deployed processes carry the shape and `uip maestro bpmn
1368
+ // validate` accepts it, so refusing it would stop a brownfield process from
1369
+ // compiling back over an element the edit did not touch.
1370
+ if (n.event === undefined)
1371
+ diags.push({
1372
+ level: 'warning',
1373
+ code: 'BPMN_BOUNDARY_NO_EVENT',
1374
+ message: `Boundary event "${n.id}" has no event definition, so the platform never fires it and the path after it ` +
1375
+ 'never runs (the local engine runs it as a catch-all error boundary, so a local run can pass where ' +
1376
+ 'production does not). Give it one of `message`, `timer` or `error`, or remove it.',
1377
+ where: n.id,
1378
+ });
1363
1379
  }
1364
1380
  // A timer event definition needs one of duration/date/cycle.
1365
1381
  // An error START event only means something inside an event sub-process: that is
@@ -1338,6 +1338,20 @@ function labelKeptFlows(lift, into = new Set()) {
1338
1338
  function isEventSubProcess(el) {
1339
1339
  return el.$type === 'bpmn:SubProcess' && el.triggeredByEvent === true;
1340
1340
  }
1341
+ /**
1342
+ * Whether the builder, in a `sequence` scope, implies an edge OUT of this element to
1343
+ * the statement written after it — the mirror of `opensPath` in bpmn-sdk.ts. An end
1344
+ * event, a gateway, a boundary event and an event sub-process never do, so a flow
1345
+ * out of one of them must be written explicitly. A boundary the lift leaves flat (one
1346
+ * with no event definition, say) was implied anyway, and the recompile refused the
1347
+ * element after it with BPMN_SEQUENCE_NO_INCOMING.
1348
+ */
1349
+ function opensPathInSequence(el) {
1350
+ const kind = localName(el.$type);
1351
+ if (kind === 'endEvent' || kind === 'boundaryEvent' || kind.endsWith('Gateway'))
1352
+ return false;
1353
+ return !isEventSubProcess(el);
1354
+ }
1341
1355
  /** An element an arm may contain: something with one way in and one way out, or an end. */
1342
1356
  function isArmNode(el) {
1343
1357
  const kind = localName(el.$type);
@@ -1872,7 +1886,7 @@ function emitScopeNested(chain, container, depth, indent, summary, relabel, sequ
1872
1886
  // statement IS the successor, the edge may be relabelled (or already carries the
1873
1887
  // derived id), and it carries no label. Otherwise it is written here, before the
1874
1888
  // next statement, so the builder does not imply a second one beside it.
1875
- if (sequence && fresh && (relabel || derivableFlow(f)) && !labelledImpliedFlow([f], false))
1889
+ if (sequence && fresh && opensPathInSequence(el) && (relabel || derivableFlow(f)) && !labelledImpliedFlow([f], false))
1876
1890
  implyFlow(plan, f);
1877
1891
  else if (sequence)
1878
1892
  writeNow([f]);
package/dist/check.js CHANGED
@@ -568,13 +568,15 @@ function checkFlow(built, ancestors, opts = {}) {
568
568
  walk(s.body, inLoop, s.port === 'error' ? prevAction?.name ?? errorSource : errorSource);
569
569
  }
570
570
  else if (s.kind === 'branch') {
571
- addExpr(s.cond.js, s.name);
571
+ // No condition (a canvas draft) is the serializer's DECISION_NO_CONDITION.
572
+ if (s.cond !== undefined)
573
+ addExpr(s.cond.js, s.name);
572
574
  // A constant condition always takes the SAME arm — the `.branch` twin of
573
575
  // SWITCH_CONST_ON, and what `.branch('big', 'amount', …)` (a field name
574
576
  // where an expression belongs) degrades into once types are stripped.
575
577
  // Testing a value is legal and uses JS truthiness, so the constant does
576
578
  // not fail anywhere downstream: it quietly picks one arm forever.
577
- if (s.cond.literal)
579
+ if (s.cond?.literal)
578
580
  diags.push({
579
581
  level: 'error',
580
582
  code: 'BRANCH_CONST_COND',
@@ -67,7 +67,7 @@ export declare const REFUSALS: {
67
67
  readonly BOUNDARY_UNATTACHED: "lowering";
68
68
  readonly BPMN_BINDING_READ_BEFORE_DECLARED: "lowering";
69
69
  readonly BPMN_BINDING_RESOURCE_KEY_CONFLICT: "lowering";
70
- readonly BPMN_BOUNDARY_NO_EVENT: "lowering";
70
+ readonly BPMN_BOUNDARY_NO_EVENT: "lint";
71
71
  readonly BPMN_BRANCH_EMPTY_ARMS: "lowering";
72
72
  readonly BPMN_BRANCH_NOWHERE_TO_GO: "lowering";
73
73
  readonly BPMN_BRANCH_NO_ARMS: "lowering";
@@ -268,6 +268,7 @@ export declare const REFUSALS: {
268
268
  readonly DECLARATION_TYPE_UNKNOWN: "lowering";
269
269
  readonly DECOMPILE_NOT_A_NUMBER: "lowering";
270
270
  readonly DECOMPILE_VARIABLES_SHAPE: "lowering";
271
+ readonly DECISION_NO_CONDITION: "draft";
271
272
  readonly DELAY_CALENDAR: "lint";
272
273
  readonly DELAY_DURATION_XOR_UNTIL: "lowering";
273
274
  readonly DELAY_HAS_NO_OUTPUT: "lint";
@@ -116,7 +116,7 @@ export const REFUSALS = {
116
116
  BOUNDARY_UNATTACHED: 'lowering',
117
117
  BPMN_BINDING_READ_BEFORE_DECLARED: 'lowering',
118
118
  BPMN_BINDING_RESOURCE_KEY_CONFLICT: 'lowering',
119
- BPMN_BOUNDARY_NO_EVENT: 'lowering',
119
+ BPMN_BOUNDARY_NO_EVENT: 'lint',
120
120
  BPMN_BRANCH_EMPTY_ARMS: 'lowering',
121
121
  BPMN_BRANCH_NOWHERE_TO_GO: 'lowering',
122
122
  BPMN_BRANCH_NO_ARMS: 'lowering',
@@ -341,6 +341,7 @@ export const REFUSALS = {
341
341
  DECLARATION_TYPE_UNKNOWN: 'lowering',
342
342
  DECOMPILE_NOT_A_NUMBER: 'lowering',
343
343
  DECOMPILE_VARIABLES_SHAPE: 'lowering',
344
+ DECISION_NO_CONDITION: 'draft',
344
345
  DELAY_CALENDAR: 'lint',
345
346
  DELAY_DURATION_XOR_UNTIL: 'lowering',
346
347
  DELAY_HAS_NO_OUTPUT: 'lint',
package/dist/decompile.js CHANGED
@@ -235,7 +235,7 @@ function shippedVersions(type) {
235
235
  * `{ fork }` (#1310). A `.parallel` whose arms rejoin on a plain step has no
236
236
  * join node, so `node` may be absent; the fork then supplies the version.
237
237
  */
238
- function forkOptsArg(node, fork) {
238
+ function forkOptsArg(node, fork, extra = []) {
239
239
  const parts = [];
240
240
  const ver = node ? verClause(node) : fork ? verClause(fork) : '';
241
241
  if (ver)
@@ -253,6 +253,7 @@ function forkOptsArg(node, fork) {
253
253
  ];
254
254
  parts.push(forkParts.length === 1 ? `fork: ${tsLiteral(fork.id)}` : `fork: { ${forkParts.join(', ')} }`);
255
255
  }
256
+ parts.push(...extra);
256
257
  return parts.length ? `, { ${parts.join(', ')} }` : '';
257
258
  }
258
259
  /**
@@ -1168,6 +1169,17 @@ function unsupportedSpec(node, imp, o) {
1168
1169
  // is a safe structural stand-in, and the marker records what it replaced.
1169
1170
  return `${imp.use('mock')}() /* TODO: unsupported node type ${commentText(node.type)} */`;
1170
1171
  }
1172
+ /**
1173
+ * Whether `node` is a decision the canvas saved before its condition was set
1174
+ * (no `expression`, or a blank one) and whose definition the file holds.
1175
+ * Decompile prints its `.branch()` with no condition and `{ draft: true }`, and
1176
+ * carries the definition, so compile writes it back (DECISION_NO_CONDITION).
1177
+ */
1178
+ function isDraftDecision(node) {
1179
+ if (node.type !== T.decision || !node.typeVersion || !runDefs.has(`${node.type}@${node.typeVersion}`))
1180
+ return false;
1181
+ return conditionText((node.inputs ?? {}).expression) === '';
1182
+ }
1171
1183
  /**
1172
1184
  * Whether `node` is a draft the canvas saved whose definition the file holds
1173
1185
  * (its node type's `isDraft`). Decompile carries that definition and marks the
@@ -1201,7 +1213,7 @@ function carriedPairs(flow) {
1201
1213
  continue;
1202
1214
  const shipped = shippedVersions(n.type);
1203
1215
  const unresolvable = shipped.length > 0 && !shipped.includes(n.typeVersion);
1204
- if (!unresolvable && !isCanvasDraft(n))
1216
+ if (!unresolvable && !isCanvasDraft(n) && !isDraftDecision(n))
1205
1217
  continue;
1206
1218
  const base = `${camel(String(n.type).split('.').pop() ?? 'node')}V${String(n.typeVersion).replace(/[^A-Za-z0-9]+/g, '_')}Definition`;
1207
1219
  let name = base;
@@ -2232,7 +2244,9 @@ function region(cursor, stop, scope, ipdom, ctx, refInto) {
2232
2244
  }
2233
2245
  if (node.type === T.decision) {
2234
2246
  const r = ipdom.get(node.id) ?? stop;
2235
- const cond = emitBareExpr(conditionText((node.inputs ?? {}).expression), ctx.imp, ctx.inputNames);
2247
+ // A decision the canvas saved with no condition prints as `undefined`, marked `{ draft: true }` (#1674).
2248
+ const draftDecision = isDraftDecision(node);
2249
+ const cond = draftDecision ? 'undefined' : emitBareExpr(conditionText((node.inputs ?? {}).expression), ctx.imp, ctx.inputNames);
2236
2250
  const thenSegs = forkRegion(portEdges(ctx.graph, node.id, 'true'), r, scope, ipdom, ctx, refInto);
2237
2251
  const elseSegs = forkRegion(portEdges(ctx.graph, node.id, 'false'), r, scope, ipdom, ctx, refInto);
2238
2252
  const labels = armLabels(node);
@@ -2240,7 +2254,7 @@ function region(cursor, stop, scope, ipdom, ctx, refInto) {
2240
2254
  thenSegs.unshift(`.label(${tsLiteral(labels.trueLabel)})`);
2241
2255
  if (labels.falseLabel)
2242
2256
  elseSegs.unshift(`.label(${tsLiteral(labels.falseLabel)})`);
2243
- segs.push(`.branch(${tsLiteral(node.id)}, ${cond},\n${reindent(armCb('t', thenSegs), ' ')},\n${reindent(armCb('e', elseSegs), ' ')}${forkOptsArg(node)})`);
2257
+ segs.push(`.branch(${tsLiteral(node.id)}, ${cond},\n${reindent(armCb('t', thenSegs), ' ')},\n${reindent(armCb('e', elseSegs), ' ')}${forkOptsArg(node, undefined, draftDecision ? ['draft: true'] : [])})`);
2244
2258
  flagDropped(node, ctx, segs);
2245
2259
  cursor = r === EXIT ? undefined : r;
2246
2260
  continue;
@@ -158,7 +158,8 @@ function walk(steps, roots, out) {
158
158
  walk(s.body, roots, out);
159
159
  break;
160
160
  case 'branch':
161
- pushExpr(s.cond, s.name, roots, out);
161
+ if (s.cond !== undefined)
162
+ pushExpr(s.cond, s.name, roots, out);
162
163
  walk(s.then, roots, out);
163
164
  walk(s.otherwise, roots, out);
164
165
  break;
@@ -315,6 +315,23 @@ export interface StepOptions extends NodeOptions {
315
315
  */
316
316
  draft?: boolean;
317
317
  }
318
+ /**
319
+ * The options of `.branch()`: the {@link NodeOptions}, plus `draft` for a
320
+ * decision the canvas saved before its condition was set.
321
+ */
322
+ export interface BranchOptions extends NodeOptions {
323
+ /**
324
+ * This decision is a DRAFT the canvas saved with no condition. Decompile
325
+ * prints it as `.branch('check', undefined, …, { draft: true })` and carries
326
+ * the decision's definition in `.definitions([...])`; `compile` then writes the
327
+ * node with no `expression` and prints a warning (`DECISION_NO_CONDITION`)
328
+ * instead of refusing. Without the flag, or without a carried definition,
329
+ * the branch is refused. `check` reports it either way.
330
+ *
331
+ * Do not set it on a branch you write: give it a condition instead.
332
+ */
333
+ draft?: boolean;
334
+ }
318
335
  /**
319
336
  * The options of `.parallel()`: the join's {@link NodeOptions}, plus the fork
320
337
  * node when the flow has one.
@@ -436,10 +453,10 @@ export type Step = {
436
453
  label?: string;
437
454
  trueLabel?: string;
438
455
  falseLabel?: string;
439
- cond: Expr;
456
+ cond?: Expr;
440
457
  then: Step[];
441
458
  otherwise: Step[];
442
- options?: NodeOptions;
459
+ options?: BranchOptions;
443
460
  } | {
444
461
  kind: 'switch';
445
462
  name: string;
@@ -960,14 +977,17 @@ declare class StepList {
960
977
  *
961
978
  * @param name - The decision node's id.
962
979
  * @param cond - The condition, as an expression — typically `js\`…\``.
980
+ * `undefined` only for a decision the canvas saved before its condition was
981
+ * set: decompile prints it so, with `{ draft: true }` (see {@link BranchOptions.draft}).
982
+ * Compile refuses any other branch with no condition (DECISION_NO_CONDITION).
963
983
  * @param thenFn - Receives a sub-builder for the TRUE arm.
964
984
  * @param elseFn - Receives a sub-builder for the FALSE arm. Omit it for a
965
985
  * decision whose false path simply continues.
966
986
  * @param options - Node options; `version` selects the exact definition
967
- * version (see {@link NodeOptions}).
987
+ * version (see {@link BranchOptions}).
968
988
  * @returns This builder, after both arms have rejoined.
969
989
  */
970
- branch(name: string, cond: Expr, thenFn: (b: ArmBuilder) => void, elseFn?: (b: ArmBuilder) => void, options?: NodeOptions): this;
990
+ branch(name: string, cond: Expr | undefined, thenFn: (b: ArmBuilder) => void, elseFn?: (b: ArmBuilder) => void, options?: BranchOptions): this;
971
991
  /**
972
992
  * N-way branch on the value of `on` — one arm per case, plus an optional
973
993
  * default arm. Each arm gets its own sub-builder, exactly like `.branch`.
package/dist/flow-sdk.js CHANGED
@@ -502,11 +502,14 @@ class StepList {
502
502
  *
503
503
  * @param name - The decision node's id.
504
504
  * @param cond - The condition, as an expression — typically `js\`…\``.
505
+ * `undefined` only for a decision the canvas saved before its condition was
506
+ * set: decompile prints it so, with `{ draft: true }` (see {@link BranchOptions.draft}).
507
+ * Compile refuses any other branch with no condition (DECISION_NO_CONDITION).
505
508
  * @param thenFn - Receives a sub-builder for the TRUE arm.
506
509
  * @param elseFn - Receives a sub-builder for the FALSE arm. Omit it for a
507
510
  * decision whose false path simply continues.
508
511
  * @param options - Node options; `version` selects the exact definition
509
- * version (see {@link NodeOptions}).
512
+ * version (see {@link BranchOptions}).
510
513
  * @returns This builder, after both arms have rejoined.
511
514
  */
512
515
  branch(name, cond, thenFn, elseFn, options) {
@@ -530,7 +533,8 @@ class StepList {
530
533
  name,
531
534
  ...(t.armLabel !== undefined ? { trueLabel: t.armLabel } : {}),
532
535
  ...(e.armLabel !== undefined ? { falseLabel: e.armLabel } : {}),
533
- cond: toExpr(cond),
536
+ // No condition at all is kept as none: a canvas draft (BranchOptions.draft), refused otherwise.
537
+ ...(cond !== undefined ? { cond: toExpr(cond) } : {}),
534
538
  then: t.steps,
535
539
  otherwise: e.steps,
536
540
  ...(options ? { options } : {}),
@@ -33,7 +33,7 @@ export interface SerializeWarning {
33
33
  }
34
34
  export { CONNECTOR_INPUT_MISSING } from './core/connector-inputs.js';
35
35
  /** The refusals a draft-tolerant compile reports instead of throwing. */
36
- export type DraftCode = BindingRefusalCode | typeof CONNECTOR_INPUT_MISSING | 'CONNECTOR_OBJECT_REQUIRED' | 'TRANSFORM_NO_COLLECTION';
36
+ export type DraftCode = BindingRefusalCode | typeof CONNECTOR_INPUT_MISSING | 'CONNECTOR_OBJECT_REQUIRED' | 'TRANSFORM_NO_COLLECTION' | 'DECISION_NO_CONDITION';
37
37
  /** A refusal a draft-tolerant compile reported instead of throwing (see {@link SerializeOpts.draft}). */
38
38
  export interface DraftFinding {
39
39
  /** The emitted node's id. */
package/dist/serialize.js CHANGED
@@ -2536,6 +2536,26 @@ function serializeFlow(built, opts) {
2536
2536
  * still judged; any other compile throws it. With no owning step it throws in
2537
2537
  * collect mode too: then it is scope-level.
2538
2538
  */
2539
+ /**
2540
+ * A `.branch()` with no condition (DECISION_NO_CONDITION, class `draft`). Merge's
2541
+ * draft-tolerant compile (`opts.draft`) takes it as a draft; `compile`
2542
+ * (`opts.carriedDrafts`) does only for a step marked `{ draft: true }` whose
2543
+ * flow carries the decision's definition at its version (decompile's copy of a
2544
+ * canvas decision saved with no condition); anything else is refused.
2545
+ */
2546
+ function refuseOrDraftDecision(scope, step, id, version) {
2547
+ const refusal = new CompileRefusal('DECISION_NO_CONDITION', `Branch "${step.name}" has no condition, so the decision cannot choose an arm. Pass the condition as an expression.`, 'js`<condition>`');
2548
+ const finding = { nodeId: id, step: step.name, code: 'DECISION_NO_CONDITION', message: refusal.message };
2549
+ if (opts.draft) {
2550
+ opts.draft(finding);
2551
+ return;
2552
+ }
2553
+ if (!opts.collect && opts.carriedDrafts && step.options?.draft === true && carriedFor(NODE_TYPE.decision, version) !== undefined) {
2554
+ opts.carriedDrafts(finding);
2555
+ return;
2556
+ }
2557
+ refuseOn(scope, step.name, refusal);
2558
+ }
2539
2559
  function refuseOn(scope, stepName, refusal) {
2540
2560
  if (!opts.collect || stepName === undefined)
2541
2561
  throw refusal;
@@ -3050,7 +3070,14 @@ function serializeFlow(built, opts) {
3050
3070
  else if (step.kind === 'branch') {
3051
3071
  const id = stepUid(scope, step.name);
3052
3072
  const node = makeNode(NODE_TYPE.decision, id, step.options?.label ?? step.label ?? step.name, { parentId, requestedVersion: step.options?.version });
3053
- node.inputs = { trueLabel: step.trueLabel ?? 'True', falseLabel: step.falseLabel ?? 'False', expression: renameRefs(step.cond.js, scope.rename) };
3073
+ // A branch with no condition is a decision the canvas saved unfinished (#1674):
3074
+ // written with no `expression` in a draft compile, else refused.
3075
+ if (step.cond === undefined)
3076
+ refuseOrDraftDecision(scope, step, id, node.typeVersion);
3077
+ node.inputs = {
3078
+ trueLabel: step.trueLabel ?? 'True', falseLabel: step.falseLabel ?? 'False',
3079
+ ...(step.cond !== undefined ? { expression: renameRefs(step.cond.js, scope.rename) } : {}),
3080
+ };
3054
3081
  scope.nodes.push(node);
3055
3082
  for (const t of tails)
3056
3083
  addEdge(scope, t, id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.86.3",
3
+ "version": "6.86.5",
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": "10ab9a305a9e66a2bd0b4ca2c5d477d90b8376f6"
106
+ "gitref": "ab528288226a2e7a52d8d6901afc14dc14d24f0d"
107
107
  }