@uipath/maestro-builder-sdk 6.111.0 → 6.113.0

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.
@@ -2,9 +2,11 @@
2
2
  * node-placement — where compile puts a node it has no position for, and where
3
3
  * merge moves one the edit added.
4
4
  *
5
- * Compile gives every node a placeholder from its emission index,
6
- * `x = 256 + 288 × index, y = 144` (`+160` inside a container). Merge replaces
7
- * that placeholder on each node the edit added:
5
+ * In a flow or subflow whose `.layout()` names nodes (every decompiled source
6
+ * with positions), compile gives each node it leaves out a placeholder from its
7
+ * emission index, `x = 256 + 288 × index, y = 144` (`+160` inside a container).
8
+ * A scope with no `.layout()` node entries is laid out whole instead
9
+ * (`auto-layout.ts`). Merge replaces the placeholder on each node the edit added:
8
10
  *
9
11
  * - right of its rightmost positioned predecessor in the same container, past
10
12
  * its width, on that predecessor's row; when the node leads into another
@@ -90,6 +92,38 @@ export function isPlaceholderPosition(p) {
90
92
  const k = (p.x - PLACEHOLDER.x0) / PLACEHOLDER.dx;
91
93
  return Number.isInteger(k) && k >= 0 && (p.y === PLACEHOLDER.y0 || p.y === PLACEHOLDER.y0 + PLACEHOLDER.nestedDy);
92
94
  }
95
+ /**
96
+ * The `ui` key compile writes on a node whose position it chose itself: every node of a
97
+ * flow or subflow it laid out (no `.layout()` node entries, `auto-layout.ts`). Its value
98
+ * is the position compile chose, so the mark holds only while the node is still there:
99
+ * Studio Web keeps unknown `ui` keys on save (flow-schema `extractLayout` persists "the
100
+ * full ui object (including unknown keys like zoom)"), and a drag changes `position` but
101
+ * not this key. Merge places an added node whose mark holds, and decompile writes no
102
+ * `.layout()` entry for it. The `.flow` schema's node `ui` takes extra keys
103
+ * (flow-schema `workflow-file`, `$catchall`).
104
+ *
105
+ * Example: `flow compile` of a source with no `.layout()` writes
106
+ * `{ position: { x: 448, y: 144 }, size: …, collapsed: false, placeholder: { x: 448, y: 144 } }`.
107
+ * Drag the node to (448, 304) in the designer and the mark no longer holds.
108
+ */
109
+ export const PLACEHOLDER_FLAG = 'placeholder';
110
+ /** `ui` with {@link PLACEHOLDER_FLAG} set to its current position. */
111
+ export function markCompilePlaced(ui) {
112
+ return ui.position ? { ...ui, [PLACEHOLDER_FLAG]: { x: ui.position.x, y: ui.position.y } } : ui;
113
+ }
114
+ /** Whether a node's `ui` (layout entry over `node.ui`) still sits where compile put it. */
115
+ export function isMarkedPlaceholder(ui) {
116
+ if (!ui || typeof ui !== 'object')
117
+ return false;
118
+ const { position, [PLACEHOLDER_FLAG]: mark } = ui;
119
+ const at = mark;
120
+ return !!position && !!at && typeof at === 'object' && at.x === position.x && at.y === position.y;
121
+ }
122
+ /** Remove {@link PLACEHOLDER_FLAG} from a node's `ui`, or a `layout.nodes` entry, in place. */
123
+ export function stripPlaceholderFlag(ui) {
124
+ if (ui && typeof ui === 'object')
125
+ delete ui[PLACEHOLDER_FLAG];
126
+ }
93
127
  const overlaps = (a, b) => !(a.x + a.width + PADDING <= b.x || b.x + b.width + PADDING <= a.x
94
128
  || a.y + a.height + PADDING <= b.y || b.y + b.height + PADDING <= a.y);
95
129
  /** Whether two boxes share a row: their vertical extents meet, padding included. */
@@ -199,7 +233,8 @@ function sceneOf(nodes, edges, layoutNodes, isAdded) {
199
233
  notesOf: new Map(),
200
234
  };
201
235
  for (const n of nodes) {
202
- if (isAdded(n.id) && n.type !== STICKY_NOTE_TYPE && isPlaceholderPosition(uiOf(s, n)?.position))
236
+ const ui = uiOf(s, n);
237
+ if (isAdded(n.id) && n.type !== STICKY_NOTE_TYPE && (isMarkedPlaceholder(ui) || isPlaceholderPosition(ui?.position)))
203
238
  s.pending.add(n.id);
204
239
  }
205
240
  // A pending node no edge path links to a positioned one in its container
@@ -0,0 +1,24 @@
1
+ /** One path the cleanup removed or left, with why. */
2
+ export interface PipelineArtifact {
3
+ /** Absolute path. */
4
+ path: string;
5
+ /** What it was (removed), or why it stayed (kept). */
6
+ reason: string;
7
+ }
8
+ /**
9
+ * Remove the earlier loop's compiled artifacts for the flow `name` from
10
+ * `workDir`. Does nothing unless `workDir` is the SDK's work directory
11
+ * (`.flow-sdk`). Never throws: what it cannot read or remove is `kept`.
12
+ *
13
+ * @example
14
+ * // .flow-sdk/ holds Order.flow.ts, Order.merged.flow and Order.baseline/Order.flow
15
+ * clearPipelineArtifacts('.flow-sdk', 'Order')
16
+ * // → removed: [.flow-sdk/Order.merged.flow, .flow-sdk/Order.baseline], kept: []
17
+ */
18
+ export declare function clearPipelineArtifacts(workDir: string, name: string, options?: {
19
+ keep?: readonly string[];
20
+ original?: unknown;
21
+ }): {
22
+ removed: PipelineArtifact[];
23
+ kept: PipelineArtifact[];
24
+ };
@@ -0,0 +1,228 @@
1
+ /**
2
+ * pipeline-artifacts — the compiled leftovers of an earlier brownfield loop for
3
+ * one flow, which a fresh `flow decompile` of that flow clears (#1995).
4
+ *
5
+ * Every brownfield loop the SDK has generated or documented compiles `.flow`
6
+ * files into the work directory (`.flow-sdk/`, workdir.ts) beside the source:
7
+ *
8
+ * .flow-sdk/Order.baseline/Order.flow the pipeline's baseline compile
9
+ * .flow-sdk/Order.edited/Order.flow the pipeline's edited compile
10
+ * .flow-sdk/Order.merged.flow the pipeline's merge candidate
11
+ * .flow-sdk/<uuid>/agent.json an inline agent merge wrote beside it
12
+ * .flow-sdk/Order.baseline.flow the same, as a pipeline before #1207 named them
13
+ * .flow-sdk/baseline/Order.flow the by-hand loop the guides taught
14
+ *
15
+ * Inside a Flow project each of those `.flow` files is one more deliverable to
16
+ * product validation, which reads every `.flow` below the project, hidden
17
+ * folders included. A new decompile writes a new source, so a baseline compiled
18
+ * from the old one is stale anyway: the next loop must compile its own. So
19
+ * decompile removes them, instead of every guide carrying a `find … -exec rm`.
20
+ *
21
+ * Only what is provably this flow's is removed, and only inside the work
22
+ * directory:
23
+ *
24
+ * - a FILE by its exact name (`<Name>.merged.flow`, ...), never a link;
25
+ * - a DIRECTORY by its exact name, and only when it holds nothing but
26
+ * `<Name>.flow` and agent folders (`<uuid>/`), as a compile writes it; one
27
+ * holding anything else is kept and reported;
28
+ * - an agent folder at the top of the work directory only when a removed
29
+ * `.flow` names it as an agent `source` and no `.flow` that stays does.
30
+ *
31
+ * Never removed: a `<Name>.merged.flow` that differs from the flow being
32
+ * decompiled (`options.original`), which may hold the only copy of an edit not yet
33
+ * applied; the file the decompile read, or a folder holding it
34
+ * (`options.keep`): `flow decompile .flow-sdk/Order.merged.flow` looks at the
35
+ * candidate, it does not start a new loop over it.
36
+ *
37
+ * Library module (FB010): it returns what it did, and the CLI prints it.
38
+ */
39
+ import { lstatSync, readdirSync, readFileSync, realpathSync, rmSync } from 'node:fs';
40
+ import { basename, join, resolve } from 'node:path';
41
+ import { isWithin, physicalPath } from './path-within.js';
42
+ import { flowSources } from './project-resource-users.js';
43
+ import { WORK_DIR } from './workdir.js';
44
+ /** An agent folder name: a uuid, any case. */
45
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
46
+ /** The files a loop wrote for `name`, each with what it was. */
47
+ function candidateFiles(name) {
48
+ return [
49
+ [`${name}.merged.flow`, 'an earlier merge candidate'],
50
+ [`${name}.baseline.flow`, 'an earlier baseline compile'],
51
+ [`${name}.edited.flow`, 'an earlier edited compile'],
52
+ ];
53
+ }
54
+ /** The directories a loop compiled `name` into, each with what it was. */
55
+ function candidateDirs(name) {
56
+ return [
57
+ [`${name}.baseline`, 'an earlier baseline compile'],
58
+ [`${name}.edited`, 'an earlier edited compile'],
59
+ ['baseline', 'an earlier baseline compile'],
60
+ ['edited', 'an earlier edited compile'],
61
+ ];
62
+ }
63
+ /**
64
+ * Remove the earlier loop's compiled artifacts for the flow `name` from
65
+ * `workDir`. Does nothing unless `workDir` is the SDK's work directory
66
+ * (`.flow-sdk`). Never throws: what it cannot read or remove is `kept`.
67
+ *
68
+ * @example
69
+ * // .flow-sdk/ holds Order.flow.ts, Order.merged.flow and Order.baseline/Order.flow
70
+ * clearPipelineArtifacts('.flow-sdk', 'Order')
71
+ * // → removed: [.flow-sdk/Order.merged.flow, .flow-sdk/Order.baseline], kept: []
72
+ */
73
+ export function clearPipelineArtifacts(workDir, name, options = {}) {
74
+ const removed = [];
75
+ const kept = [];
76
+ if (basename(workDir) !== WORK_DIR || name === '' || name !== basename(name))
77
+ return { removed, kept };
78
+ let root;
79
+ let entries;
80
+ try {
81
+ root = realpathSync.native(workDir);
82
+ entries = readdirSync(workDir, { withFileTypes: true });
83
+ }
84
+ catch {
85
+ return { removed, kept };
86
+ }
87
+ const byName = new Map(entries.map((e) => [e.name, e]));
88
+ /** Remove `path` (a plain file or folder in the work directory), recording the outcome. */
89
+ // Where each kept path lands on disk, so a candidate that IS one, or holds one,
90
+ // is never removed whatever spelling or link reached it.
91
+ const keep = (options.keep ?? []).map((p) => physicalPath(resolve(p))).filter((p) => p !== undefined);
92
+ const remove = (path, reason) => {
93
+ const at = physicalPath(path);
94
+ if (at === undefined || at === root || !isWithin(root, at)) {
95
+ kept.push({ path, reason: `not inside ${workDir}` });
96
+ return false;
97
+ }
98
+ if (keep.some((k) => isWithin(at, k))) {
99
+ kept.push({ path, reason: 'it is, or holds, the file this decompile read' });
100
+ return false;
101
+ }
102
+ try {
103
+ rmSync(path, { recursive: true, force: true });
104
+ }
105
+ catch (error) {
106
+ kept.push({ path, reason: `could not remove it (${error instanceof Error ? error.message : String(error)})` });
107
+ return false;
108
+ }
109
+ removed.push({ path, reason });
110
+ return true;
111
+ };
112
+ // Agent folders a removed top-level `.flow` names; removed below once nothing that stays names them.
113
+ const named = new Set();
114
+ for (const [file, reason] of candidateFiles(name)) {
115
+ const entry = byName.get(file);
116
+ if (!entry?.isFile())
117
+ continue; // absent, a folder, or a link: not ours
118
+ const path = join(workDir, file);
119
+ const json = readJson(path);
120
+ // A merge candidate that differs from the original being decompiled holds an
121
+ // edit nobody has applied yet: decompile has just overwritten the source, so it
122
+ // may be the last copy of that edit. Kept until it matches (it was copied over).
123
+ if (file === `${name}.merged.flow` && !(json !== undefined && sameDocument(json, options.original))) {
124
+ kept.push({ path, reason: `it differs from the flow this decompile read, so it may be an unapplied merge candidate: copy it over the original or delete it yourself` });
125
+ continue;
126
+ }
127
+ const sources = flowSources(json);
128
+ if (remove(path, reason))
129
+ for (const s of sources)
130
+ if (UUID.test(s))
131
+ named.add(s);
132
+ }
133
+ for (const [dir, reason] of candidateDirs(name)) {
134
+ const entry = byName.get(dir);
135
+ if (!entry?.isDirectory())
136
+ continue;
137
+ const path = join(workDir, dir);
138
+ const stray = strayEntry(path, name);
139
+ if (stray !== undefined) {
140
+ kept.push({ path, reason: stray });
141
+ continue;
142
+ }
143
+ remove(path, reason);
144
+ }
145
+ if (named.size > 0) {
146
+ // A `.flow` that stays (another flow's candidate) may share the folder.
147
+ const stillNamed = new Set();
148
+ for (const e of readdirSafe(workDir)) {
149
+ if (e.isFile() && e.name.endsWith('.flow'))
150
+ for (const s of flowSources(readJson(join(workDir, e.name))))
151
+ stillNamed.add(s.toLowerCase());
152
+ }
153
+ for (const source of [...named].sort()) {
154
+ const entry = byName.get(source);
155
+ if (!entry?.isDirectory())
156
+ continue;
157
+ const path = join(workDir, source);
158
+ if (stillNamed.has(source.toLowerCase())) {
159
+ kept.push({ path, reason: 'another .flow in the work directory still names it' });
160
+ continue;
161
+ }
162
+ if (!isPlainFile(join(path, 'agent.json'))) {
163
+ kept.push({ path, reason: 'it holds no agent.json, so it is not an agent folder merge wrote' });
164
+ continue;
165
+ }
166
+ remove(path, 'the agent folder an earlier merge candidate named');
167
+ }
168
+ }
169
+ return { removed, kept };
170
+ }
171
+ /**
172
+ * Why the folder at `dir` is not a compile of `name`, or `undefined` when it
173
+ * is: it holds `<name>.flow` and otherwise only agent folders.
174
+ */
175
+ function strayEntry(dir, name) {
176
+ let entries;
177
+ try {
178
+ entries = readdirSync(dir, { withFileTypes: true });
179
+ }
180
+ catch (error) {
181
+ return `could not read it (${error instanceof Error ? error.message : String(error)})`;
182
+ }
183
+ const flow = `${name}.flow`;
184
+ if (!entries.some((e) => e.isFile() && e.name === flow))
185
+ return `it holds no ${flow}, so it is not this flow's compile`;
186
+ const other = entries.find((e) => !(e.isFile() && e.name === flow) && !(e.isDirectory() && UUID.test(e.name)));
187
+ return other === undefined ? undefined : `it holds ${other.name}, which a compile of ${name} does not write`;
188
+ }
189
+ function readdirSafe(dir) {
190
+ try {
191
+ return readdirSync(dir, { withFileTypes: true });
192
+ }
193
+ catch {
194
+ return [];
195
+ }
196
+ }
197
+ /** `path` is a file itself, not a link to one. */
198
+ function isPlainFile(path) {
199
+ try {
200
+ return lstatSync(path).isFile();
201
+ }
202
+ catch {
203
+ return false;
204
+ }
205
+ }
206
+ /** `a` and `b` are the same JSON document, whatever the order of each object's keys. */
207
+ function sameDocument(a, b) {
208
+ if (a === b)
209
+ return true;
210
+ if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null)
211
+ return false;
212
+ if (Array.isArray(a) !== Array.isArray(b))
213
+ return false;
214
+ if (Array.isArray(a))
215
+ return a.length === b.length && a.every((x, i) => sameDocument(x, b[i]));
216
+ const ka = Object.keys(a);
217
+ const kb = Object.keys(b);
218
+ return ka.length === kb.length && ka.every((k) => Object.prototype.hasOwnProperty.call(b, k)
219
+ && sameDocument(a[k], b[k]));
220
+ }
221
+ function readJson(path) {
222
+ try {
223
+ return JSON.parse(readFileSync(path, 'utf8'));
224
+ }
225
+ catch {
226
+ return undefined;
227
+ }
228
+ }
@@ -24,6 +24,31 @@ export declare function otherProjectFlows(file: string): {
24
24
  project: string | undefined;
25
25
  others: string[];
26
26
  };
27
+ /**
28
+ * Every `.flow` file below `root` (absolute paths), read breadth-first within
29
+ * {@link MAX_DEPTH} levels and {@link MAX_DIRS} folders, links not followed,
30
+ * `node_modules/` skipped. The one walk of a project's `.flow` files.
31
+ *
32
+ * - `readers: true` reads what a project's readers read (see the module
33
+ * comment): dot-folders and nested projects are skipped.
34
+ * - `readers: false` reads everything a `$ref` could come from: dot-folders and
35
+ * nested projects included (`.git/` still skipped). Merge uses it to prove no
36
+ * `.flow` reads a part file before deleting it.
37
+ *
38
+ * `complete` is `false` when the walk stopped at a bound, could not read a
39
+ * folder, or (`readers: false`) met a link to a folder or a `.flow`, which it
40
+ * does not follow: a caller that must prove an absence fails closed on it.
41
+ *
42
+ * @example
43
+ * projectFlowFiles('/s/Order', { readers: true })
44
+ * // { files: ['/s/Order/Order.flow', '/s/Order/backup/Order.flow'], complete: true }
45
+ */
46
+ export declare function projectFlowFiles(root: string, options: {
47
+ readers: boolean;
48
+ }): {
49
+ files: string[];
50
+ complete: boolean;
51
+ };
27
52
  /**
28
53
  * The `SECOND_FLOW_IN_PROJECT` warning for writing `file`, or `undefined` when
29
54
  * its project holds no other `.flow` a reader sees, or `file` itself sits where
@@ -35,7 +35,7 @@
35
35
  *
36
36
  * Library module (FB010): it returns the files, and the CLIs print the warning.
37
37
  */
38
- import { existsSync, readdirSync } from 'node:fs';
38
+ import { existsSync, readdirSync, statSync } from 'node:fs';
39
39
  import { dirname, join, relative, resolve } from 'node:path';
40
40
  /** How many folder levels below the project the scan reads. */
41
41
  export const MAX_DEPTH = 8;
@@ -76,10 +76,36 @@ export function otherProjectFlows(file) {
76
76
  if (project === undefined)
77
77
  return { project, others: [] };
78
78
  const self = resolve(file);
79
- const others = [];
80
- const queue = [{ dir: project, depth: 0 }];
79
+ const { files } = projectFlowFiles(project, { readers: true });
80
+ return { project, others: files.filter((f) => f !== self).map((f) => relative(project, f)).sort() };
81
+ }
82
+ /**
83
+ * Every `.flow` file below `root` (absolute paths), read breadth-first within
84
+ * {@link MAX_DEPTH} levels and {@link MAX_DIRS} folders, links not followed,
85
+ * `node_modules/` skipped. The one walk of a project's `.flow` files.
86
+ *
87
+ * - `readers: true` reads what a project's readers read (see the module
88
+ * comment): dot-folders and nested projects are skipped.
89
+ * - `readers: false` reads everything a `$ref` could come from: dot-folders and
90
+ * nested projects included (`.git/` still skipped). Merge uses it to prove no
91
+ * `.flow` reads a part file before deleting it.
92
+ *
93
+ * `complete` is `false` when the walk stopped at a bound, could not read a
94
+ * folder, or (`readers: false`) met a link to a folder or a `.flow`, which it
95
+ * does not follow: a caller that must prove an absence fails closed on it.
96
+ *
97
+ * @example
98
+ * projectFlowFiles('/s/Order', { readers: true })
99
+ * // { files: ['/s/Order/Order.flow', '/s/Order/backup/Order.flow'], complete: true }
100
+ */
101
+ export function projectFlowFiles(root, options) {
102
+ const files = [];
103
+ let complete = true;
104
+ const queue = [{ dir: root, depth: 0 }];
81
105
  let read = 0;
82
- while (queue.length > 0 && read < MAX_DIRS) {
106
+ while (queue.length > 0) {
107
+ if (read >= MAX_DIRS)
108
+ return { files, complete: false };
83
109
  const { dir, depth } = queue.shift();
84
110
  read++;
85
111
  let entries;
@@ -87,20 +113,42 @@ export function otherProjectFlows(file) {
87
113
  entries = readdirSync(dir, { withFileTypes: true });
88
114
  }
89
115
  catch {
116
+ complete = false;
90
117
  continue;
91
118
  }
92
119
  for (const e of entries) {
93
120
  const path = join(dir, e.name);
121
+ if (e.isSymbolicLink()) {
122
+ // Not followed. A link to a folder or a `.flow` hides what it leads to, so
123
+ // a walk that must see every `.flow` is incomplete (a dangling `.flow` link too).
124
+ if (!options.readers && (e.name.endsWith('.flow') || linksToFolder(path)))
125
+ complete = false;
126
+ continue;
127
+ }
94
128
  if (e.isFile() && e.name.endsWith('.flow')) {
95
- if (path !== self)
96
- others.push(relative(project, path));
129
+ files.push(path);
97
130
  }
98
- else if (e.isDirectory() && !e.name.startsWith('.') && !SKIPPED.has(e.name) && depth < MAX_DEPTH && !existsSync(join(path, 'project.uiproj'))) {
131
+ else if (e.isDirectory() && !SKIPPED.has(e.name) && e.name !== '.git') {
132
+ if (options.readers && (e.name.startsWith('.') || existsSync(join(path, 'project.uiproj'))))
133
+ continue;
134
+ if (depth >= MAX_DEPTH) {
135
+ complete = false;
136
+ continue;
137
+ }
99
138
  queue.push({ dir: path, depth: depth + 1 });
100
139
  }
101
140
  }
102
141
  }
103
- return { project, others: others.sort() };
142
+ return { files, complete };
143
+ }
144
+ /** `path` (a link) leads to a folder. */
145
+ function linksToFolder(path) {
146
+ try {
147
+ return statSync(path).isDirectory();
148
+ }
149
+ catch {
150
+ return false;
151
+ }
104
152
  }
105
153
  /** A project-relative path inside a folder the scan does not read (a dot-folder, `node_modules/`). */
106
154
  function unread(rel) {
package/dist/serialize.js CHANGED
@@ -33,6 +33,7 @@ import { BindingRefusal, bindingLabelRefusal, bindingPairRefusal, connectionStub
33
33
  import { OUTCOME_HANDLE_NODE_TYPES, assertHitlExitInvariant, hitlExitViolation } from './core/hitl-routing.js';
34
34
  import { STICKY_NOTE_TYPE, STICKY_NOTE_TYPE_VERSION } from './core/definitionless-node-types.js';
35
35
  import { placeholderPosition } from './node-placement.js';
36
+ import { applyCompiledGeometry } from './auto-layout.js';
36
37
  import { hasExits } from './core/step-ports.js';
37
38
  import { stopsAtEnd } from './flow-step-tree.js';
38
39
  import { assertNodeEnvelope } from './core/node-envelope.js';
@@ -332,7 +333,7 @@ function emitStickyNotes(built, scope, claimNoteId) {
332
333
  * as the persisted `layout.edges` section. Unknown keys are compile errors —
333
334
  * a silently dropped layout entry would read as "the designer moved my node".
334
335
  */
335
- function applyAuthorLayout(layout, scope, where) {
336
+ function applyAuthorLayout(layout, scope, where, author) {
336
337
  if (!layout)
337
338
  return undefined;
338
339
  const resolveId = (key) => {
@@ -348,8 +349,11 @@ function applyAuthorLayout(layout, scope, where) {
348
349
  const node = scope.nodes.find((n) => n.id === resolveId(key));
349
350
  node.ui = node.ui ?? {};
350
351
  node.ui.position = { x: nl.position.x, y: nl.position.y };
351
- if (nl.size !== undefined)
352
+ author.placed.add(node.id);
353
+ if (nl.size !== undefined) {
352
354
  node.ui.size = { width: nl.size.width, height: nl.size.height };
355
+ author.sized.add(node.id);
356
+ }
353
357
  if (nl.collapsed !== undefined)
354
358
  node.ui.collapsed = nl.collapsed;
355
359
  }
@@ -1788,6 +1792,8 @@ function serializeFlow(built, opts) {
1788
1792
  emittedDefs.set(key, shared ?? def);
1789
1793
  }
1790
1794
  let col = 0;
1795
+ /** The nodes `.layout()` placed or sized; `applyCompiledGeometry` places and sizes the rest. */
1796
+ const authorGeometry = { placed: new Set(), sized: new Set() };
1791
1797
  /**
1792
1798
  * Create a node from a definition (core def by type, or a supplied connector
1793
1799
  * v1def). `requestedVersion` is the author's exact `{ version }` node option
@@ -2011,7 +2017,7 @@ function serializeFlow(built, opts) {
2011
2017
  assertHitlExitInvariant(scope.nodes, scope.edges, legacyCompletedNodes);
2012
2018
  typeAgentInputSchemas(scope, globals);
2013
2019
  emitStickyNotes(child, scope, claimNoteId);
2014
- const layoutEdges = applyAuthorLayout(child.layout, scope, `subflow "${nodeId}"`);
2020
+ const layoutEdges = applyAuthorLayout(child.layout, scope, `subflow "${nodeId}"`, authorGeometry);
2015
2021
  assertNodeEnvelope(scope.nodes, `subflow "${nodeId}"`);
2016
2022
  return {
2017
2023
  nodes: scope.nodes,
@@ -3661,7 +3667,7 @@ function serializeFlow(built, opts) {
3661
3667
  assertHitlExitInvariant(root.nodes, root.edges, legacyCompletedNodes);
3662
3668
  typeAgentInputSchemas(root, globals);
3663
3669
  emitStickyNotes(built, root, claimNoteId);
3664
- const rootLayoutEdges = applyAuthorLayout(built.layout, root, `flow "${built.id}"`);
3670
+ const rootLayoutEdges = applyAuthorLayout(built.layout, root, `flow "${built.id}"`, authorGeometry);
3665
3671
  assertNodeEnvelope(root.nodes, `flow "${built.id}"`);
3666
3672
  // The FILE-FORMAT version this document declares: the author's
3667
3673
  // `.schemaVersion()` when they set one, else the profile's write floor. It is
@@ -3691,6 +3697,10 @@ function serializeFlow(built, opts) {
3691
3697
  // Passing the target is what lets a version-conditional step exist at all —
3692
3698
  // see migrate.ts's VERSION_CONDITIONAL ladder.
3693
3699
  migrateToSchemaVersion(flow, schemaVersion);
3700
+ // Sizes from each node's canvas shape, and `uip maestro flow format`'s layout for a
3701
+ // flow or subflow with no `.layout()` node entries (#1992). After migration, so the
3702
+ // layout reads the file `format` would read.
3703
+ applyCompiledGeometry(flow, authorGeometry);
3694
3704
  // Emitted-document invariants over connections, checked on the FINISHED file
3695
3705
  // so every family and every emission order is covered by one rule, not by
3696
3706
  // each call site remembering it (flow-builder-sdk#865/#866).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.111.0",
3
+ "version": "6.113.0",
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",
@@ -117,11 +117,12 @@
117
117
  "acorn": "^8.17.0",
118
118
  "bpmn-moddle": "^9.0.4",
119
119
  "commander": "^14.0.0",
120
+ "elkjs": "0.11.1",
120
121
  "typescript": "^5.9.3"
121
122
  },
122
123
  "devDependencies": {
123
124
  "@types/node": "^22.7.0",
124
125
  "esbuild": "^0.28.1"
125
126
  },
126
- "gitref": "b15c2763847c5eddc42573477d28692f00a28844"
127
+ "gitref": "846b52878024374f366bd0ffc6a472b5678140fe"
127
128
  }