@uipath/maestro-builder-sdk 6.120.32 → 6.120.33

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.
package/dist/check.js CHANGED
@@ -19,6 +19,7 @@ import { compareSchemaVersions, schemaVersionRefusal } from './schema-version.js
19
19
  import { planFlowGlobals, planSharedInputs, sharedInputRoots } from './flow-variables.js';
20
20
  import { backedOutputs } from './flow-output-backing.js';
21
21
  import { childStepLists } from './flow-step-tree.js';
22
+ import { unsatisfiableJoins } from './core/exclusive-join.js';
22
23
  import { VARS_READ_RE } from './core/vars-read.js';
23
24
  import { FLOW_METADATA_KEYS, unknownMetadataKeys } from './core/flow-metadata.js';
24
25
  import { endContentKey } from './flow-end-content.js';
@@ -60,8 +61,10 @@ export function checkCompiled(built, opts = {}) {
60
61
  }
61
62
  const serialized = opts.serializer !== false
62
63
  ? serializerRefusals(built, { library: opts.library, bindings: opts.bindings, resources: opts.resources, nodeCatalog: opts.nodeCatalog, ...(opts.solution !== undefined ? { solution: opts.solution } : {}) }, diags)
63
- : { diagnostics: [], flow: undefined };
64
+ : { diagnostics: [], flow: undefined, scopes: [] };
64
65
  diags.push(...serialized.diagnostics);
66
+ if (serialized.flow !== undefined)
67
+ diags.push(...mergeNeverCompletes(serialized.flow, serialized.scopes ?? []));
65
68
  const placed = serialized.flow !== undefined ? placeDiagnostics(diags, serialized.flow) : undefined;
66
69
  const diagnostics = diags.map((d, i) => {
67
70
  const nodeId = d.nodeId ?? (placed?.[i].nodeId || undefined);
@@ -144,6 +147,75 @@ export function scopeToEdit(edited, baseline) {
144
147
  const PRE_EXISTING_LOWERING_NOTE = 'This node is unchanged from the baseline, so this is probably an SDK defect: '
145
148
  + 'the SDK cannot read what the designer wrote. `compile` refuses this node; `merge --baseline-from` keeps it as saved. '
146
149
  + 'Report it: https://github.com/UiPath/builder-sdk/issues';
150
+ /**
151
+ * MERGE_NEVER_COMPLETES, on each graph level the serializer pass emitted
152
+ * (`core/exclusive-join.ts`). Nodes map to steps through the ids that pass
153
+ * gave them (`EmittedScope.stepNodeId`), since a subflow's ids can be prefixed.
154
+ */
155
+ function mergeNeverCompletes(flow, scopes) {
156
+ const out = [];
157
+ const definitions = Array.isArray(flow?.definitions) ? flow.definitions : [];
158
+ for (const scope of scopes) {
159
+ const graph = scope.subflow === undefined ? flow : flow?.subflows?.[scope.subflow];
160
+ if (graph === undefined || graph === null)
161
+ continue;
162
+ const named = new Map();
163
+ const visit = (list) => {
164
+ for (const st of list) {
165
+ if ('name' in st && st.kind !== 'return' && !named.has(st.name))
166
+ named.set(st.name, st);
167
+ for (const child of childStepLists(st))
168
+ visit(child);
169
+ }
170
+ };
171
+ visit(scope.steps);
172
+ const byNode = new Map();
173
+ for (const [name, id] of scope.stepNodeId) {
174
+ const st = named.get(name);
175
+ if (st)
176
+ byNode.set(id, st);
177
+ }
178
+ const splitOf = (n, model) => {
179
+ const kind = byNode.get(n.id)?.kind;
180
+ if (kind === 'branch')
181
+ return 'Decision';
182
+ if (kind === 'switch')
183
+ return 'Switch';
184
+ return model === 'bpmn:ExclusiveGateway' ? 'Decision' : undefined;
185
+ };
186
+ const nameOf = (id, label) => { const st = byNode.get(id); return st && 'name' in st ? st.name : label; };
187
+ for (const j of unsatisfiableJoins({ nodes: graph.nodes, edges: graph.edges, definitions }, splitOf)) {
188
+ const name = nameOf(j.joinId, j.joinLabel);
189
+ const splitName = nameOf(j.splitId, j.splitLabel);
190
+ const ports = j.ports.map((p) => `"${p}"`).join(', ');
191
+ const isParallel = byNode.get(j.joinId)?.kind === 'parallel';
192
+ const method = j.splitKind === 'Switch' ? 'switch' : 'branch';
193
+ const prefix = scope.callers.map((c) => `In subflow "${c}": `).join('');
194
+ // The step the Merge hands on to: where the arms should meet instead.
195
+ const nextId = (graph.edges ?? []).find((e) => e?.sourceNodeId === j.joinId)?.targetNodeId;
196
+ const nextStep = nextId !== undefined ? byNode.get(nextId) : undefined;
197
+ const next = nextStep && 'name' in nextStep ? nextStep.name : undefined;
198
+ out.push({
199
+ level: 'error', code: 'MERGE_NEVER_COMPLETES',
200
+ message: `${prefix}${isParallel ? `.parallel("${name}")'s Merge` : `Merge "${name}"`} can never complete: every path into it `
201
+ + `comes from a different branch of ${j.splitKind} "${splitName}" (ports ${ports}). A Merge is a parallel join that `
202
+ + `waits for ALL its incoming paths, but a ${j.splitKind} takes exactly one branch, so the run stops at "${name}" `
203
+ + `and never reaches an End (\`uip maestro flow validate\` refuses the file for the same reason). `
204
+ + (isParallel
205
+ ? `Add a step after the .${method}("${splitName}") inside the arm, so its paths meet there and the arm hands the `
206
+ + `join one edge; or, if no other arm reaches the join, drop the .parallel and chain the steps.`
207
+ : `Remove the Merge step: the .${method}'s arms meet at ${next !== undefined ? `"${next}"` : 'the next step'} on their `
208
+ + `own, since a step accepts several incoming edges. Use a Merge only to join arms that run at the same time (.parallel).`),
209
+ suggestion: isParallel
210
+ ? `.parallel('${name}', [(a) => a.${method}('${splitName}', …).step('meet', …), …])`
211
+ : `.${method}('${splitName}', …)${next !== undefined ? `.step('${next}', …)` : ''}`,
212
+ step: [...scope.callers, name].join(' › '),
213
+ ...(scope.callers.length === 0 ? { nodeId: j.joinId } : {}),
214
+ });
215
+ }
216
+ }
217
+ return out;
218
+ }
147
219
  /** The error-level diagnostics a custom node's own `diagnostics()` reported (see `serializerRefusals`). */
148
220
  const OWN_NODE_ERRORS = new WeakSet();
149
221
  /**
@@ -163,13 +235,14 @@ const OWN_NODE_ERRORS = new WeakSet();
163
235
  */
164
236
  function serializerRefusals(built, compile, found) {
165
237
  const collected = [];
238
+ const scopes = [];
166
239
  const warned = [];
167
240
  let flow;
168
241
  let stoppedAt;
169
242
  try {
170
243
  // A stale `.layout()` key is the one serializer warning `check` repeats: compile
171
244
  // drops the entry, and the author can only see that here (#1994).
172
- flow = serialize(built, { ...compile, collect: (r) => collected.push(r), warn: (w) => { if (w.code === 'LAYOUT_UNKNOWN_KEY')
245
+ flow = serialize(built, { ...compile, collect: (r) => collected.push(r), scopes: (sc) => scopes.push(sc), warn: (w) => { if (w.code === 'LAYOUT_UNKNOWN_KEY')
173
246
  warned.push(w); } });
174
247
  // Collection stopped: the refusal that stopped it is the last one reported.
175
248
  const stop = collected[collected.length - 1];
@@ -217,7 +290,7 @@ function serializerRefusals(built, compile, found) {
217
290
  seen.add(key);
218
291
  out.push({ level: 'warning', code: w.code, message: w.message });
219
292
  }
220
- return { diagnostics: out, flow, ...(stoppedAt ? { stoppedAt } : {}) };
293
+ return { diagnostics: out, flow, scopes, ...(stoppedAt ? { stoppedAt } : {}) };
221
294
  }
222
295
  /**
223
296
  * `ancestors` is the chain of child flows currently being checked, innermost
@@ -2333,8 +2406,8 @@ const OUTPUT_READ_RULES = {
2333
2406
  * that was not taken, and the run stays Running with no incident. That was
2334
2407
  * measured live on 09-01 (a Merge fed by a Decision's two ports). An older note
2335
2408
  * here said such flows "deploy and run"; they deploy, and they do not finish.
2336
- * This function does NOT refuse that general shape yet — it predates the human
2337
- * task rule below and is tracked as its own SDK issue. It does refuse it when a
2409
+ * MERGE_NEVER_COMPLETES (`mergeNeverCompletes`) judges that shape on the
2410
+ * compiled graph. This function refuses it when a
2338
2411
  * human task's outcome edge is among the arm's alternative edges into the join
2339
2412
  * — a fan-out task at the arm's end, one empty `.stepSwitch` arm beside a body
2340
2413
  * arm, a task on one side of a `.branch` (HITL_FAN_OUT_INTO_JOIN) — and an
@@ -0,0 +1,59 @@
1
+ /**
2
+ * MERGE_NEVER_COMPLETES: a Merge (a `bpmn:ParallelGateway`) waits for a token
3
+ * on every incoming edge, so when every edge into it comes from a different
4
+ * branch of one Decision or Switch, which sends one token, it never completes.
5
+ *
6
+ * d --true--> A --> join
7
+ * d --false-------> join `join` waits for two tokens; `d` sends one.
8
+ *
9
+ * The same walk as `uip maestro flow validate` (maestro-tool
10
+ * `flow-validate-service` `findUnsatisfiableJoin`), so check and validate
11
+ * refuse the same files.
12
+ */
13
+ export interface JoinNode {
14
+ id: string;
15
+ type?: string;
16
+ model?: {
17
+ type?: unknown;
18
+ };
19
+ display?: {
20
+ label?: unknown;
21
+ };
22
+ }
23
+ interface JoinEdge {
24
+ sourceNodeId: string;
25
+ sourcePort?: string;
26
+ targetNodeId: string;
27
+ }
28
+ /** One graph level: the root flow's nodes and edges, or one subflow's, with the file's definitions. */
29
+ export interface JoinGraph {
30
+ nodes?: readonly JoinNode[];
31
+ edges?: readonly JoinEdge[];
32
+ definitions?: ReadonlyArray<{
33
+ nodeType?: string;
34
+ model?: {
35
+ type?: unknown;
36
+ };
37
+ }>;
38
+ }
39
+ /** A Merge that can never complete, and the split whose branches all feed it. */
40
+ export interface UnsatisfiableJoin {
41
+ /** The Merge node's id and label (its id when it has none). */
42
+ joinId: string;
43
+ joinLabel: string;
44
+ /** The Decision or Switch node's id and label. */
45
+ splitId: string;
46
+ splitLabel: string;
47
+ splitKind: 'Decision' | 'Switch';
48
+ /** The split's ports the Merge's incoming paths leave by, sorted. */
49
+ ports: string[];
50
+ }
51
+ /** Whether a node is a Decision or a Switch, and which; `undefined` for any other node. */
52
+ export type SplitOf = (node: JoinNode, modelType: unknown) => 'Decision' | 'Switch' | undefined;
53
+ /**
54
+ * Every Merge of one graph level that can never complete, in node order.
55
+ * `splitOf` names the exclusive splits; by default only a `bpmn:ExclusiveGateway`
56
+ * model type is one (reported as a Decision, as validate words it).
57
+ */
58
+ export declare function unsatisfiableJoins(graph: JoinGraph, splitOf?: SplitOf): UnsatisfiableJoin[];
59
+ export {};
@@ -0,0 +1,78 @@
1
+ /**
2
+ * MERGE_NEVER_COMPLETES: a Merge (a `bpmn:ParallelGateway`) waits for a token
3
+ * on every incoming edge, so when every edge into it comes from a different
4
+ * branch of one Decision or Switch, which sends one token, it never completes.
5
+ *
6
+ * d --true--> A --> join
7
+ * d --false-------> join `join` waits for two tokens; `d` sends one.
8
+ *
9
+ * The same walk as `uip maestro flow validate` (maestro-tool
10
+ * `flow-validate-service` `findUnsatisfiableJoin`), so check and validate
11
+ * refuse the same files.
12
+ */
13
+ /**
14
+ * Every Merge of one graph level that can never complete, in node order.
15
+ * `splitOf` names the exclusive splits; by default only a `bpmn:ExclusiveGateway`
16
+ * model type is one (reported as a Decision, as validate words it).
17
+ */
18
+ export function unsatisfiableJoins(graph, splitOf = (_n, model) => (model === 'bpmn:ExclusiveGateway' ? 'Decision' : undefined)) {
19
+ const nodes = Array.isArray(graph.nodes) ? graph.nodes : [];
20
+ const edges = Array.isArray(graph.edges) ? graph.edges : [];
21
+ const modelByType = new Map();
22
+ for (const def of Array.isArray(graph.definitions) ? graph.definitions : []) {
23
+ if (typeof def?.nodeType === 'string' && typeof def.model?.type === 'string')
24
+ modelByType.set(def.nodeType, def.model.type);
25
+ }
26
+ const modelType = (n) => (typeof n.model?.type === 'string' ? n.model.type : modelByType.get(n.type ?? ''));
27
+ const byId = new Map(nodes.map((n) => [n.id, n]));
28
+ const incoming = new Map();
29
+ for (const e of edges) {
30
+ const list = incoming.get(e.targetNodeId) ?? [];
31
+ list.push(e);
32
+ incoming.set(e.targetNodeId, list);
33
+ }
34
+ const isJoin = (n) => modelType(n) === 'bpmn:ParallelGateway';
35
+ const isSplit = (n) => splitOf(n, modelType(n)) !== undefined;
36
+ /** The split this edge's path leaves, and by which port, when the walk reaches one. */
37
+ const originOf = (edge) => {
38
+ let current = edge;
39
+ const seen = new Set();
40
+ while (current !== undefined && !seen.has(current.sourceNodeId)) {
41
+ const source = byId.get(current.sourceNodeId);
42
+ if (!source)
43
+ return undefined;
44
+ seen.add(source.id);
45
+ if (isSplit(source))
46
+ return { splitId: source.id, port: current.sourcePort };
47
+ const up = incoming.get(source.id) ?? [];
48
+ current = up.length === 1 ? up[0] : undefined;
49
+ }
50
+ return undefined;
51
+ };
52
+ const found = [];
53
+ for (const node of nodes) {
54
+ if (!isJoin(node))
55
+ continue;
56
+ const into = incoming.get(node.id) ?? [];
57
+ if (into.length < 2)
58
+ continue;
59
+ const origins = into.map(originOf);
60
+ if (origins.some((o) => o === undefined))
61
+ continue;
62
+ const resolved = origins;
63
+ if (new Set(resolved.map((o) => o.splitId)).size !== 1)
64
+ continue;
65
+ const ports = [...new Set(resolved.map((o) => String(o.port)))].sort((a, b) => a.localeCompare(b));
66
+ if (ports.length < 2)
67
+ continue;
68
+ const split = byId.get(resolved[0].splitId);
69
+ const label = (n) => (typeof n.display?.label === 'string' ? n.display.label : n.id);
70
+ found.push({
71
+ joinId: node.id, joinLabel: label(node),
72
+ splitId: split.id, splitLabel: label(split),
73
+ splitKind: splitOf(split, modelType(split)) ?? 'Decision',
74
+ ports,
75
+ });
76
+ }
77
+ return found;
78
+ }
@@ -618,6 +618,7 @@ export declare const REFUSALS: {
618
618
  readonly LOOP_PARALLEL_LEGACY: "lint";
619
619
  readonly LOOP_VERSION_UNSUPPORTED: "lowering";
620
620
  readonly MANAGED_HTTP_ABSOLUTE_URL: "lint";
621
+ readonly MERGE_NEVER_COMPLETES: "lint";
621
622
  readonly METHOD_MISSING_PARENTHESES: "lint";
622
623
  readonly MISSING_CONDITION_EXPRESSION: "lint";
623
624
  readonly MISSING_RESOURCE: "lint";
@@ -694,6 +694,7 @@ export const REFUSALS = {
694
694
  LOOP_PARALLEL_LEGACY: 'lint',
695
695
  LOOP_VERSION_UNSUPPORTED: 'lowering',
696
696
  MANAGED_HTTP_ABSOLUTE_URL: 'lint',
697
+ MERGE_NEVER_COMPLETES: 'lint',
697
698
  METHOD_MISSING_PARENTHESES: 'lint',
698
699
  MISSING_CONDITION_EXPRESSION: 'lint',
699
700
  MISSING_RESOURCE: 'lint',
@@ -10,7 +10,7 @@ import { type ResourceResolutions } from './core/resource-resolution.js';
10
10
  import type { SolutionProjects } from './core/solution-projects.js';
11
11
  import type { NodeCatalog } from './core/node-catalog.js';
12
12
  import type { DefinitionReference } from './core/node-classes.js';
13
- import type { BuiltFlow } from './flow-sdk.js';
13
+ import type { BuiltFlow, Step } from './flow-sdk.js';
14
14
  import type { Library } from './library.js';
15
15
  import { type BindingRefusalCode, type BindingsView } from './core/binding-messages.js';
16
16
  import { CONNECTOR_INPUT_MISSING, connectorInputErrors as coreConnectorInputErrors } from './core/connector-inputs.js';
@@ -47,6 +47,16 @@ export interface DraftFinding {
47
47
  /** The sentence the strict compile refuses with. */
48
48
  message: string;
49
49
  }
50
+ /** One emitted graph level (see {@link SerializeOpts.scopes}). */
51
+ export interface EmittedScope {
52
+ /** The body's key in `subflows`; absent for the root. */
53
+ subflow?: string;
54
+ /** The calling steps' names, outermost first. */
55
+ callers: readonly string[];
56
+ steps: readonly Step[];
57
+ /** Step name to the node id compile gave it in this graph level. */
58
+ stepNodeId: ReadonlyMap<string, string>;
59
+ }
50
60
  /** A refusal a collect-mode serialize reported instead of throwing (see {@link SerializeOpts.collect}). */
51
61
  export interface CollectedRefusal {
52
62
  code: string;
@@ -167,6 +177,15 @@ export interface SerializeOpts {
167
177
  * both, each on its own step, where an ordinary compile stops at the first.
168
178
  */
169
179
  collect?: (refusal: CollectedRefusal) => void;
180
+ /**
181
+ * Each graph level the compile emitted, with the node id it gave each step:
182
+ * the root (`subflow` undefined), and every subflow body under its key in
183
+ * `subflows`. `callers` are the calling steps' names, outermost first.
184
+ * A subflow's ids can carry a prefix (`call_cd` for step `cd` of the child
185
+ * `call` runs), so a reader of the compiled graph maps nodes to steps here,
186
+ * not by name.
187
+ */
188
+ scopes?: (scope: EmittedScope) => void;
170
189
  /**
171
190
  * Filled in by `serialize` with the extra files the flow needs beside the
172
191
  * `.flow`, relative to it: one `<source>/agent.json` per inline agent, plus a
package/dist/serialize.js CHANGED
@@ -2036,6 +2036,7 @@ function serializeFlow(built, opts) {
2036
2036
  scope.variableUpdates[startId] = [...(scope.variableUpdates[startId] ?? []), ...renderUpdates(startUpdates, scope.rename)];
2037
2037
  }
2038
2038
  const tails = emit(child.steps, [{ node: startId, port: 'output' }], scope);
2039
+ opts.scopes?.({ subflow: nodeId, callers: [...subflowPath], steps: child.steps, stepNodeId: scope.stepNodeId });
2039
2040
  // Same as the root's implicit End — mapped against the SUBFLOW's own
2040
2041
  // outputs, which is the scope the product validates a subflow body in.
2041
2042
  const capped = tailsToCap(scope, tails);
@@ -3659,6 +3660,7 @@ function serializeFlow(built, opts) {
3659
3660
  }
3660
3661
  }
3661
3662
  }
3663
+ opts.scopes?.({ callers: [], steps: [...built.steps, ...(built.entryPoints ?? []).flatMap((ep) => ep.steps)], stepNodeId: root.stepNodeId });
3662
3664
  // ── Shared root inputs (#924) ────────────────────────────────────────────
3663
3665
  // An input marked `{ shared: '<var>' }` is copied into that variable on its
3664
3666
  // root's TRIGGER node: a `variableUpdates[<triggerId>]` row, the same
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.120.32",
3
+ "version": "6.120.33",
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": "d7c435b08129ee788a1ece08f4ac3dd75e725a9e"
127
+ "gitref": "5da397eb5e83bdd6f38bdbc72b4f63f572170647"
128
128
  }