@uipath/maestro-builder-sdk 6.86.23 → 6.86.25

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.
@@ -68,18 +68,54 @@ export declare function connectionResources(flow: unknown): BindingsV2Resource[]
68
68
  * "Folder"` and no `SolutionsSupport`.
69
69
  */
70
70
  export declare function entityResources(flow: unknown): BindingsV2Resource[];
71
+ /**
72
+ * The connection and `Entity` rows of the flows a Flow project declares in
73
+ * `bindings_v2.json` — the union over `flows`, in the order given.
74
+ *
75
+ * The sidecar is one file per project, written by whichever compile ran last,
76
+ * so it is derived from the project's flows as they stand on disk — normally
77
+ * just the main one, the flow pack deploys — and not from the compiled flow
78
+ * alone (#1381). Each `.flow` is read the way pack derives a package's rows
79
+ * from it.
80
+ *
81
+ * A connection two flows use is one row, the first flow's (the key is compared
82
+ * case-insensitively, as `uip agent refresh` does). A flow whose rows cannot be
83
+ * derived — the file does not parse, or two of its nodes type one connection
84
+ * differently — is listed in `unreadable` and contributes nothing; the caller
85
+ * must then keep the rows already on disk, since some of them may be its.
86
+ *
87
+ * @param flows - The flows to declare, in a stable order.
88
+ * @returns The rows, and the files whose rows could not be derived.
89
+ */
90
+ export declare function projectBindingRows(flows: ReadonlyArray<{
91
+ file: string;
92
+ flow: unknown;
93
+ }>): {
94
+ connections: BindingsV2Resource[];
95
+ entities: BindingsV2Resource[];
96
+ unreadable: string[];
97
+ };
71
98
  /**
72
99
  * Fold freshly derived connection and entity rows into whatever the project
73
100
  * already has.
74
101
  *
75
- * Connection and `Entity` rows are replaced wholesale — they are re-derived from the flow that
76
- * was just compiled, so the compile is the newer truth. Every other row is
102
+ * Connection and `Entity` rows are replaced wholesale — they are re-derived from
103
+ * the project's flows ({@link projectBindingRows}), so the compile is the newer
104
+ * truth, and a row no declared flow uses is dropped. Every other row is
77
105
  * carried through in its original order, because this module does not derive
78
106
  * those kinds and dropping them would silently delete a `TimeTrigger` (or
79
107
  * anything a future generator adds) that `node configure` or an earlier `pack`
80
108
  * had put there.
109
+ *
110
+ * `keepUnderived` is for a project where some flow's rows could not be derived
111
+ * (`unreadable` above): the existing connection and `Entity` rows that were not
112
+ * re-derived are then kept too, in place, because they may be that flow's. A
113
+ * stale row only declares a connection nothing uses; a lost one leaves a flow's
114
+ * connection undeclared.
81
115
  */
82
- export declare function mergeBindingsV2(existing: unknown, connections: BindingsV2Resource[], entities?: BindingsV2Resource[]): BindingsV2Document;
116
+ export declare function mergeBindingsV2(existing: unknown, connections: BindingsV2Resource[], entities?: BindingsV2Resource[], options?: {
117
+ keepUnderived?: boolean;
118
+ }): BindingsV2Document;
83
119
  /** The files of one inline agent, as `uip agent refresh` reads them. */
84
120
  export interface InlineAgentFiles {
85
121
  /** `<agent>/agent.json`. */
@@ -127,7 +163,7 @@ export declare function mergeInlineAgentResources(existing: BindingsV2Resource[]
127
163
  * declared and a deploy could still fail on it. They are generated by the same
128
164
  * function, so they match exactly, and a row a remaining resource still
129
165
  * declares is kept. Connection rows are not touched here: compile re-derives
130
- * them from the flow ({@link connectionResources}).
166
+ * them from the project's flows ({@link projectBindingRows}).
131
167
  *
132
168
  * @param resources - The project's current rows.
133
169
  * @param agents - Every inline agent's files, as they now stand.
@@ -34,8 +34,10 @@
34
34
  *
35
35
  * Two kinds of row, each copied from the generator that owns it:
36
36
  *
37
- * - `connection` rows for the flow's own connector steps — what pack derives,
38
- * and what #689 is about ({@link connectionResources}).
37
+ * - `connection` rows for the connector steps of the project's main flow —
38
+ * what pack derives, and what #689 is about ({@link connectionResources}).
39
+ * The file is one per project, whichever `.flow` was compiled
40
+ * ({@link projectBindingRows}, #1381).
39
41
  * - `Entity` rows for the flow's folder-scoped Data Fabric steps, which
40
42
  * `uip solution resources refresh` turns into the solution's entity
41
43
  * resource ({@link entityResources}, #1463).
@@ -311,22 +313,79 @@ export function entityResources(flow) {
311
313
  }
312
314
  return resources;
313
315
  }
316
+ /**
317
+ * The connection and `Entity` rows of the flows a Flow project declares in
318
+ * `bindings_v2.json` — the union over `flows`, in the order given.
319
+ *
320
+ * The sidecar is one file per project, written by whichever compile ran last,
321
+ * so it is derived from the project's flows as they stand on disk — normally
322
+ * just the main one, the flow pack deploys — and not from the compiled flow
323
+ * alone (#1381). Each `.flow` is read the way pack derives a package's rows
324
+ * from it.
325
+ *
326
+ * A connection two flows use is one row, the first flow's (the key is compared
327
+ * case-insensitively, as `uip agent refresh` does). A flow whose rows cannot be
328
+ * derived — the file does not parse, or two of its nodes type one connection
329
+ * differently — is listed in `unreadable` and contributes nothing; the caller
330
+ * must then keep the rows already on disk, since some of them may be its.
331
+ *
332
+ * @param flows - The flows to declare, in a stable order.
333
+ * @returns The rows, and the files whose rows could not be derived.
334
+ */
335
+ export function projectBindingRows(flows) {
336
+ const connections = [];
337
+ const entities = [];
338
+ const unreadable = [];
339
+ const seen = new Set();
340
+ for (const { file, flow } of flows) {
341
+ let rows;
342
+ try {
343
+ if (!isRecord(flow))
344
+ throw new Error('not a flow');
345
+ rows = [...connectionResources(flow), ...entityResources(flow)];
346
+ }
347
+ catch {
348
+ unreadable.push(file);
349
+ continue;
350
+ }
351
+ for (const row of rows) {
352
+ const id = mergeIdentity(row);
353
+ if (seen.has(id))
354
+ continue;
355
+ seen.add(id);
356
+ (isConnection(row.resource) ? connections : entities).push(row);
357
+ }
358
+ }
359
+ return { connections, entities, unreadable };
360
+ }
314
361
  /**
315
362
  * Fold freshly derived connection and entity rows into whatever the project
316
363
  * already has.
317
364
  *
318
- * Connection and `Entity` rows are replaced wholesale — they are re-derived from the flow that
319
- * was just compiled, so the compile is the newer truth. Every other row is
365
+ * Connection and `Entity` rows are replaced wholesale — they are re-derived from
366
+ * the project's flows ({@link projectBindingRows}), so the compile is the newer
367
+ * truth, and a row no declared flow uses is dropped. Every other row is
320
368
  * carried through in its original order, because this module does not derive
321
369
  * those kinds and dropping them would silently delete a `TimeTrigger` (or
322
370
  * anything a future generator adds) that `node configure` or an earlier `pack`
323
371
  * had put there.
372
+ *
373
+ * `keepUnderived` is for a project where some flow's rows could not be derived
374
+ * (`unreadable` above): the existing connection and `Entity` rows that were not
375
+ * re-derived are then kept too, in place, because they may be that flow's. A
376
+ * stale row only declares a connection nothing uses; a lost one leaves a flow's
377
+ * connection undeclared.
324
378
  */
325
- export function mergeBindingsV2(existing, connections, entities = []) {
379
+ export function mergeBindingsV2(existing, connections, entities = [], options = {}) {
326
380
  const previous = isRecord(existing) && Array.isArray(existing.resources)
327
381
  ? existing.resources.filter(isRecord)
328
382
  : [];
329
- const preserved = previous.filter((r) => !isConnection(r.resource) && !isEntity(r.resource));
383
+ const derived = new Set([...connections, ...entities].map(mergeIdentity));
384
+ const preserved = previous.filter((r) => {
385
+ if (!isConnection(r.resource) && !isEntity(r.resource))
386
+ return true;
387
+ return options.keepUnderived === true && !derived.has(mergeIdentity(r));
388
+ });
330
389
  const version = (isRecord(existing) && nonEmptyString(existing.version)) || DOCUMENT_VERSION;
331
390
  return { version, resources: [...connections, ...entities, ...preserved] };
332
391
  }
@@ -580,7 +639,7 @@ export function mergeInlineAgentResources(existing, fresh) {
580
639
  * declared and a deploy could still fail on it. They are generated by the same
581
640
  * function, so they match exactly, and a row a remaining resource still
582
641
  * declares is kept. Connection rows are not touched here: compile re-derives
583
- * them from the flow ({@link connectionResources}).
642
+ * them from the project's flows ({@link projectBindingRows}).
584
643
  *
585
644
  * @param resources - The project's current rows.
586
645
  * @param agents - Every inline agent's files, as they now stand.
package/dist/check.js CHANGED
@@ -715,9 +715,9 @@ function checkFlow(built, ancestors, opts = {}) {
715
715
  walk(s.body, true);
716
716
  }
717
717
  else if (s.kind === 'doWhile') {
718
- // Recorded so an error handler on one is REFUSED by name rather than
719
- // silently skipped: `core.logic.dowhile@1.0` declares an error variable
720
- // but no error handle.
718
+ // Recorded as the port source so an `.onError` after it attaches to the
719
+ // container's error port (`core.logic.dowhile@1.0` sets
720
+ // supportsErrorHandling and declares the `error` handle, #1010).
721
721
  prevPortSource = s;
722
722
  addExpr(s.condition.js, s.name);
723
723
  loopNames.set(s.name, LOOP_FIELDS_1_0_0);
@@ -32,13 +32,13 @@ import { compileOwnsResource } from './core/agent-tool-resources.js';
32
32
  import { openCliLibrary } from './cli-library.js';
33
33
  import { Bindings } from './bindings.js';
34
34
  import { flagValue, runWhenInvokedDirectly } from './cli-run.js';
35
- import { connectionResources, entityResources, inlineAgentResources, mergeBindingsV2, refreshInlineAgentRows } from './bindings-v2.js';
35
+ import { connectionResources, inlineAgentResources, mergeBindingsV2, projectBindingRows, refreshInlineAgentRows } from './bindings-v2.js';
36
36
  import { readBindingsV2, readInlineAgentFiles } from './bindings-v2-files.js';
37
37
  import { ensureTypeScriptRuntime } from './node-runtime.js';
38
38
  import { defaultBindingsFile, defaultResourcesFile } from './workdir.js';
39
39
  import { readCliResources } from './registry/prepare/resources.js';
40
40
  import { isWithin, physicalPath } from './path-within.js';
41
- import { flowSources, resourceSourcesOfOtherFlows } from './project-resource-users.js';
41
+ import { flowSources, projectMainFlow, resourceSourcesOfOtherFlows } from './project-resource-users.js';
42
42
  import { fnv1aX4Uuid } from './core/stable-id.js';
43
43
  import { cliSpelling } from './core/cli-spelling.js';
44
44
  /** An agent folder name: a uuid, any case. */
@@ -296,25 +296,71 @@ export async function run(argv) {
296
296
  // with a resource declaration nothing reads would be worse than not writing it.
297
297
  if (existsSync(join(outDir, 'project.uiproj'))) {
298
298
  const sidecarPath = join(outDir, 'bindings_v2.json');
299
- const connections = connectionResources(flowJson);
300
- // The folder-scoped Data Fabric entities, from the two `Entity` bindings each
301
- // step carries — what declares the entity in the solution (#1463).
302
- const entityRows = entityResources(flowJson);
299
+ // A connection two of this flow's nodes type differently is refused here,
300
+ // whichever flow the sidecar declares.
301
+ connectionResources(flowJson);
302
+ // The sidecar is one per PROJECT and declares the flow the project runs:
303
+ // the one `uip` packs, debugs and refreshes resources from
304
+ // (`projectMainFlow`). Any other `.flow` in the project is never deployed,
305
+ // so its connections are not declared, and compiling it leaves the main
306
+ // flow's rows as they are (#1381). Only when the project holds several
307
+ // `.flow` files and none is the main one is every one of them declared:
308
+ // pack would take whichever the file system lists first.
309
+ const self = resolve(out);
310
+ const ownFile = basename(self);
311
+ const main = projectMainFlow(outDir);
312
+ const flowAt = (path) => ({
313
+ file: relative(outDir, path),
314
+ flow: resolve(path) === self ? flowJson : readJsonOrUndefined(path),
315
+ });
316
+ const rowFlows = main.file !== undefined
317
+ ? [flowAt(main.file)]
318
+ : main.ambiguous.length > 0 ? main.ambiguous.map(flowAt) : [{ file: ownFile, flow: flowJson }];
319
+ if (main.file !== undefined && resolve(main.file) !== self) {
320
+ console.log(`compile: ${ownFile} is not this project's main flow (${rowFlows[0].file}, the one pack deploys); `
321
+ + `bindings_v2.json declares ${rowFlows[0].file}'s connections, not ${ownFile}'s`);
322
+ }
323
+ else if (main.ambiguous.length > 1) {
324
+ console.error(`compile: this project holds several .flow files and none is its main one (${rowFlows.map((f) => f.file).join(', ')}); `
325
+ + 'bindings_v2.json declares the connections of all of them. Set "MainFile" in project.uiproj, '
326
+ + 'or keep only the flow you deploy in the project, so pack and refresh read the flow you mean.');
327
+ }
328
+ // Connections, and the folder-scoped Data Fabric entities from the two
329
+ // `Entity` bindings each step carries — what declares the entity in the
330
+ // solution (#1463).
331
+ const { connections, entities: entityRows, unreadable } = projectBindingRows(rowFlows);
332
+ for (const file of unreadable) {
333
+ console.error(`compile: could not read the connections of ${file}; keeping the bindings_v2.json rows this compile does not derive, `
334
+ + 'since some may be its. Fix or recompile that flow to re-derive them.');
335
+ }
303
336
  const existing = readBindingsV2(sidecarPath);
304
337
  // Each inline agent's own rows (process, index, app, … — #962), derived from
305
338
  // the agent directory as it now stands on disk, the way `uip agent refresh
306
339
  // --inline-in-flow` derives them. `uip agent validate --inline-in-flow`
307
340
  // requires every one of them, so leaving them to a refresh the SDK route
308
341
  // never runs made every agent with a deployed-resource tool, a context index
309
- // or an app escalation fail validate with `AgentValidationDrift`.
310
- const agentFiles = agentDirs
342
+ // or an app escalation fail validate with `AgentValidationDrift`. The
343
+ // agents of the flows declared above are re-derived too, since the merge
344
+ // below re-derives every connection row, their agents' included (#1381).
345
+ // This flow's own agents are kept as well: pack ships every agent folder
346
+ // in the project (`processAgents`), not only the main flow's.
347
+ const declaresSelf = rowFlows.some((f) => resolve(outDir, f.file) === self);
348
+ const projectAgentDirs = [...new Set([
349
+ ...rowFlows.flatMap((f) => (resolve(outDir, f.file) === self
350
+ ? agentDirs
351
+ : flowSources(f.flow)
352
+ .map((src) => resolve(outDir, src))
353
+ .filter((dir) => isWithin(outDir, dir) && existsSync(join(dir, 'agent.json'))))),
354
+ ...(declaresSelf ? [] : agentDirs),
355
+ ])];
356
+ const agentFiles = projectAgentDirs
311
357
  .map((dir) => readInlineAgentFiles(dir))
312
358
  .filter((files) => files !== undefined);
313
359
  const agentRows = agentFiles.map((files) => inlineAgentResources(files));
314
360
  // Nothing to declare and nothing already declared — do not create an empty
315
361
  // file for a flow that has no resources at all.
316
362
  if (connections.length > 0 || entityRows.length > 0 || existing !== undefined || agentRows.some((rows) => rows.length > 0)) {
317
- const merged = mergeBindingsV2(existing, connections, entityRows);
363
+ const merged = mergeBindingsV2(existing, connections, entityRows, { keepUnderived: unreadable.length > 0 });
318
364
  merged.resources = refreshInlineAgentRows(merged.resources, agentFiles, removedResources);
319
365
  writeJsonFile(sidecarPath, merged);
320
366
  const derived = new Set([...connections, ...entityRows, ...agentRows.flat()].map((r) => `${r.resource}\u0000${r.key}`));
@@ -26,9 +26,9 @@
26
26
  "handleType": "output",
27
27
  "showButton": true,
28
28
  "constraints": {
29
- "minConnections": 1,
30
- "severity": "warning",
31
- "validationMessage": "Trigger must connect to at least one workflow node (not configuration nodes)"
29
+ "forbiddenTargetCategories": [
30
+ "trigger"
31
+ ]
32
32
  }
33
33
  }
34
34
  ],
@@ -3537,8 +3537,14 @@
3537
3537
  "componentProps": {
3538
3538
  "minCases": 1,
3539
3539
  "maxCases": 10,
3540
- "labelPlaceholder": "e.g., Low",
3541
- "expressionPlaceholder": "e.g., $vars.value <= 30"
3540
+ "expressionPlaceholder": "e.g., $vars.value <= 30",
3541
+ "expressionValidationFields": [
3542
+ {
3543
+ "subPath": "expression",
3544
+ "validationMode": "expression",
3545
+ "expectedType": "boolean"
3546
+ }
3547
+ ]
3542
3548
  }
3543
3549
  },
3544
3550
  {
@@ -3551,6 +3557,9 @@
3551
3557
  ]
3552
3558
  }
3553
3559
  ]
3560
+ },
3561
+ "debug": {
3562
+ "runtime": "clientScript"
3554
3563
  }
3555
3564
  },
3556
3565
  "core.logic.decision@1.0.0": {
@@ -3648,6 +3657,7 @@
3648
3657
  "componentProps": {
3649
3658
  "language": "javascript",
3650
3659
  "returnType": "boolean",
3660
+ "validationMode": "expression",
3651
3661
  "minHeight": 100,
3652
3662
  "placeholder": "e.g., $vars.data.status === \"approved\" && $vars.data.amount > 1000"
3653
3663
  },
@@ -3669,6 +3679,9 @@
3669
3679
  ]
3670
3680
  }
3671
3681
  ]
3682
+ },
3683
+ "debug": {
3684
+ "runtime": "clientScript"
3672
3685
  }
3673
3686
  },
3674
3687
  "core.subflow@1.0.0": {
@@ -3851,7 +3864,7 @@
3851
3864
  }
3852
3865
  ],
3853
3866
  "debug": {
3854
- "runtime": "bpmnEngine"
3867
+ "runtime": "clientScript"
3855
3868
  },
3856
3869
  "model": {
3857
3870
  "type": "bpmn:ScriptTask"
@@ -3882,8 +3895,8 @@
3882
3895
  },
3883
3896
  "error": {
3884
3897
  "type": "object",
3885
- "description": "Error information if the script fails",
3886
- "source": "=result.Error",
3898
+ "description": "Error information if the node fails",
3899
+ "source": "=Error",
3887
3900
  "var": "error",
3888
3901
  "schema": {
3889
3902
  "$schema": "http://json-schema.org/draft-07/schema#",
@@ -3938,6 +3951,7 @@
3938
3951
  "componentProps": {
3939
3952
  "language": "javascript",
3940
3953
  "returnType": "any",
3954
+ "validationMode": "script",
3941
3955
  "minHeight": 200,
3942
3956
  "placeholder": " // Return an object with your result\nreturn {\n message: \"Web request response\",\n data: $vars.httpRequest1.output\n };"
3943
3957
  },
@@ -4031,6 +4045,9 @@
4031
4045
  },
4032
4046
  "parallel": {
4033
4047
  "type": "boolean"
4048
+ },
4049
+ "completionCondition": {
4050
+ "type": "string"
4034
4051
  }
4035
4052
  },
4036
4053
  "required": [
@@ -4039,7 +4056,8 @@
4039
4056
  },
4040
4057
  "inputDefaults": {
4041
4058
  "collection": "",
4042
- "parallel": false
4059
+ "parallel": false,
4060
+ "completionCondition": ""
4043
4061
  },
4044
4062
  "outputDefinition": {
4045
4063
  "currentItem": {
@@ -4139,6 +4157,23 @@
4139
4157
  "type": "switch",
4140
4158
  "label": "Parallel",
4141
4159
  "description": "Execute all iterations at the same time."
4160
+ },
4161
+ {
4162
+ "name": "inputs.completionCondition",
4163
+ "type": "custom",
4164
+ "component": "code-editor",
4165
+ "label": "Break on condition",
4166
+ "description": "Exit the loop early when this condition becomes true after an iteration completes.",
4167
+ "componentProps": {
4168
+ "singleLine": true,
4169
+ "mode": "expression",
4170
+ "toggleable": false,
4171
+ "placeholder": "e.g., $vars.processedCount >= 5",
4172
+ "showVariableButton": true,
4173
+ "alwaysIncludeSelf": true,
4174
+ "returnType": "boolean",
4175
+ "language": "javascript"
4176
+ }
4142
4177
  }
4143
4178
  ]
4144
4179
  }
@@ -4410,7 +4445,7 @@
4410
4445
  "name": "inputs.timerDate",
4411
4446
  "type": "datetime",
4412
4447
  "label": "Value",
4413
- "description": "The date and time when the process should continue",
4448
+ "description": "The date and time when the workflow should continue",
4414
4449
  "rules": [
4415
4450
  {
4416
4451
  "id": "date-format",
@@ -5715,6 +5750,16 @@
5715
5750
  "id": "success",
5716
5751
  "type": "source",
5717
5752
  "handleType": "output"
5753
+ },
5754
+ {
5755
+ "id": "error",
5756
+ "label": "Error",
5757
+ "type": "source",
5758
+ "handleType": "output",
5759
+ "visible": "{inputs.errorHandlingEnabled}",
5760
+ "constraints": {
5761
+ "maxConnections": 1
5762
+ }
5718
5763
  }
5719
5764
  ]
5720
5765
  },
@@ -13955,11 +14000,6 @@
13955
14000
  ],
13956
14001
  "model": {
13957
14002
  "type": "bpmn:EndEvent"
13958
- },
13959
- "runtimeConstraints": {
13960
- "exclude": [
13961
- "api-function"
13962
- ]
13963
14003
  }
13964
14004
  },
13965
14005
  "uipath.human-in-the-loop.quick-form@1.1": {
@@ -15367,12 +15407,7 @@
15367
15407
  }
15368
15408
  }
15369
15409
  },
15370
- "drillable": true,
15371
- "runtimeConstraints": {
15372
- "exclude": [
15373
- "api-function"
15374
- ]
15375
- }
15410
+ "drillable": true
15376
15411
  },
15377
15412
  "core.logic.terminate@1.0": {
15378
15413
  "nodeType": "core.logic.terminate",
@@ -15551,6 +15586,7 @@
15551
15586
  "returnType": "any",
15552
15587
  "validationMode": "script",
15553
15588
  "minHeight": 200,
15589
+ "fillPanel": true,
15554
15590
  "placeholder": " // Return any value\nreturn {\n message: \"Web request response\",\n data: $vars.httpRequest1.output\n};"
15555
15591
  },
15556
15592
  "label": "Code",
@@ -411,9 +411,9 @@ export interface ReturnOptions extends NodeOptions {
411
411
  * Loop-specific options. Every `.loop()` emits the loop's v2.4 definition (the
412
412
  * version the registry serves: inner `start`/`continue`/`break` handles, and a
413
413
  * 1-based `currentIteration` output). The legacy 1.0.0 shape is emitted only for
414
- * an explicit `{ version: '1.0.0' }`. That definition declares `parallel` but no
415
- * `completionCondition`, no `breakEnabled` and no `break` handle, so either of
416
- * those options, or a `b.break()` in the body, fails `check` and compilation
414
+ * an explicit `{ version: '1.0.0' }`. That definition declares `parallel` and
415
+ * `completionCondition`, but no `breakEnabled` and no `break` handle, so
416
+ * `breakEnabled`, or a `b.break()` in the body, fails `check` and compilation
417
417
  * (`LOOP_VERSION_UNSUPPORTED`). `parallel: true` on 1.0.0 compiles, to round-trip
418
418
  * a canvas loop, but `check` warns (`LOOP_PARALLEL_LEGACY`): that version is not
419
419
  * confirmed to run iterations in parallel. `b.continue()` works on both versions.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The `inputs.source` uuids the OTHER `.flow` files in `dir` reference, each
3
- * mapped to the first file that does. `dir` is the namespace sidecar paths are
3
+ * mapped to the first file (by name) that does. `dir` is the namespace sidecar paths are
4
4
  * relative to, so these are the agent resources another flow still uses. The
5
5
  * flow being written (`self`) is left out: what it no longer references is what
6
6
  * pruning is for. Subflow bodies are included; an unreadable file contributes
@@ -15,3 +15,22 @@ export declare function resourceSourcesOfOtherFlows(dir: string, self: string):
15
15
  * two cannot disagree on where a node keeps its source.
16
16
  */
17
17
  export declare function flowSources(flow: unknown): string[];
18
+ /**
19
+ * The `.flow` a Flow project runs, picked the way `uip` picks it for pack,
20
+ * debug, validate and `uip solution resources refresh` (`scanProjectFlowFile`
21
+ * in the CLI's packager-tool-flow `flow-io.ts`): `project.uiproj`'s `MainFile`
22
+ * when it names an existing `.flow` inside the project, else `<Name>.flow`
23
+ * (the name with every character outside `[A-Za-z0-9_-]` made `_`, compared
24
+ * case-insensitively) in the root, `content/` or `flow_files/`, else the
25
+ * first folder of those three that holds a `.flow`, when it holds just one. Only that one file is packed and deployed; any other
26
+ * `.flow` in the project is never run.
27
+ *
28
+ * When that folder holds several and none is the main one, the CLI takes the
29
+ * first in directory order, which is not stable. That case answers
30
+ * `{ file: undefined, ambiguous: [...] }` (absolute paths, sorted) instead of
31
+ * guessing; no `.flow` at all answers `{ file: undefined, ambiguous: [] }`.
32
+ */
33
+ export declare function projectMainFlow(dir: string): {
34
+ file: string | undefined;
35
+ ambiguous: string[];
36
+ };
@@ -3,12 +3,15 @@
3
3
  * use a sidecar directory. Compile's prune and merge's resource removal both
4
4
  * must leave such a directory alone: a decompiled canvas agent keeps its
5
5
  * `source` directory, so two flows in one project can share it (#1151, #1184).
6
+ * Compile's `bindings_v2.json` write reads the same files: the sidecar is one
7
+ * per project, so it declares the project's main flow ({@link projectMainFlow}),
8
+ * whichever `.flow` was compiled (#1381).
6
9
  */
7
- import { readdirSync, readFileSync } from 'node:fs';
8
- import { join, resolve } from 'node:path';
10
+ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
11
+ import { isAbsolute, join, relative, resolve } from 'node:path';
9
12
  /**
10
13
  * The `inputs.source` uuids the OTHER `.flow` files in `dir` reference, each
11
- * mapped to the first file that does. `dir` is the namespace sidecar paths are
14
+ * mapped to the first file (by name) that does. `dir` is the namespace sidecar paths are
12
15
  * relative to, so these are the agent resources another flow still uses. The
13
16
  * flow being written (`self`) is left out: what it no longer references is what
14
17
  * pruning is for. Subflow bodies are included; an unreadable file contributes
@@ -16,26 +19,36 @@ import { join, resolve } from 'node:path';
16
19
  */
17
20
  export function resourceSourcesOfOtherFlows(dir, self) {
18
21
  const users = new Map();
22
+ for (const { file, flow } of otherFlows(dir, self)) {
23
+ for (const src of flowSources(flow))
24
+ if (!users.has(src))
25
+ users.set(src, file);
26
+ }
27
+ return users;
28
+ }
29
+ /**
30
+ * The OTHER `.flow` files in `dir`, sorted by name so every reader sees them in
31
+ * the same order whatever order the file system lists them in. `self` (an
32
+ * absolute path) is left out. A file that cannot be read or parsed is listed
33
+ * with `flow: undefined`, so a caller that must not lose another flow's state
34
+ * can tell "this flow declares nothing" from "this flow could not be read".
35
+ */
36
+ function otherFlows(dir, self) {
19
37
  let entries;
20
38
  try {
21
- entries = readdirSync(dir).filter((f) => f.endsWith('.flow') && resolve(dir, f) !== self);
39
+ entries = readdirSync(dir).filter((f) => f.endsWith('.flow') && resolve(dir, f) !== self).sort();
22
40
  }
23
41
  catch {
24
- return users;
42
+ return [];
25
43
  }
26
- for (const f of entries) {
27
- let flow;
44
+ return entries.map((file) => {
28
45
  try {
29
- flow = JSON.parse(readFileSync(join(dir, f), 'utf8'));
46
+ return { file, flow: JSON.parse(readFileSync(join(dir, file), 'utf8')) };
30
47
  }
31
48
  catch {
32
- continue;
49
+ return { file, flow: undefined };
33
50
  }
34
- for (const src of flowSources(flow))
35
- if (!users.has(src))
36
- users.set(src, f);
37
- }
38
- return users;
51
+ });
39
52
  }
40
53
  /**
41
54
  * Every `inputs.source` string a flow's nodes name — agent folders and agent
@@ -59,3 +72,63 @@ export function flowSources(flow) {
59
72
  walk(flow);
60
73
  return ids;
61
74
  }
75
+ /**
76
+ * The `.flow` a Flow project runs, picked the way `uip` picks it for pack,
77
+ * debug, validate and `uip solution resources refresh` (`scanProjectFlowFile`
78
+ * in the CLI's packager-tool-flow `flow-io.ts`): `project.uiproj`'s `MainFile`
79
+ * when it names an existing `.flow` inside the project, else `<Name>.flow`
80
+ * (the name with every character outside `[A-Za-z0-9_-]` made `_`, compared
81
+ * case-insensitively) in the root, `content/` or `flow_files/`, else the
82
+ * first folder of those three that holds a `.flow`, when it holds just one. Only that one file is packed and deployed; any other
83
+ * `.flow` in the project is never run.
84
+ *
85
+ * When that folder holds several and none is the main one, the CLI takes the
86
+ * first in directory order, which is not stable. That case answers
87
+ * `{ file: undefined, ambiguous: [...] }` (absolute paths, sorted) instead of
88
+ * guessing; no `.flow` at all answers `{ file: undefined, ambiguous: [] }`.
89
+ */
90
+ export function projectMainFlow(dir) {
91
+ let uiproj;
92
+ try {
93
+ uiproj = JSON.parse(readFileSync(join(dir, 'project.uiproj'), 'utf8'));
94
+ }
95
+ catch {
96
+ uiproj = undefined;
97
+ }
98
+ const mainFile = typeof uiproj?.MainFile === 'string' ? uiproj.MainFile : undefined;
99
+ if (mainFile?.endsWith('.flow')) {
100
+ const path = resolve(dir, mainFile);
101
+ const rel = relative(dir, path);
102
+ if (rel !== '' && !/^\.\.(?:[\\/]|$)/.test(rel) && !isAbsolute(rel) && existsSync(path)) {
103
+ return { file: path, ambiguous: [] };
104
+ }
105
+ }
106
+ const preferred = typeof uiproj?.Name === 'string' && uiproj.Name !== ''
107
+ ? `${uiproj.Name.replace(/[^a-zA-Z0-9_-]/g, '_')}.flow`.toLowerCase()
108
+ : undefined;
109
+ const candidates = [];
110
+ let firstFolder;
111
+ for (const sub of ['', 'content', 'flow_files']) {
112
+ const d = join(dir, sub);
113
+ let entries;
114
+ try {
115
+ if (!statSync(d).isDirectory())
116
+ continue;
117
+ entries = readdirSync(d).filter((f) => f.endsWith('.flow')).sort();
118
+ }
119
+ catch {
120
+ continue;
121
+ }
122
+ const named = preferred && entries.find((f) => f.toLowerCase() === preferred);
123
+ if (named)
124
+ return { file: join(d, named), ambiguous: [] };
125
+ if (entries.length > 0)
126
+ firstFolder ??= entries.map((f) => join(d, f));
127
+ candidates.push(...entries.map((f) => join(d, f)));
128
+ }
129
+ // The CLI's fallback is the first `.flow` of the first folder holding one:
130
+ // a fixed answer only when that folder holds exactly one.
131
+ if (firstFolder?.length === 1)
132
+ return { file: firstFolder[0], ambiguous: [] };
133
+ return { file: undefined, ambiguous: candidates };
134
+ }
package/dist/serialize.js CHANGED
@@ -3237,8 +3237,9 @@ function serializeFlow(built, opts) {
3237
3237
  // keeps its `output`/`loopBack` pair, where the bundled lookup alone
3238
3238
  // would have written 2.4's `start`/`continue` onto a 1.0 node (#1311),
3239
3239
  // and an option is written when that definition declares the input
3240
- // (the carried 1.0 declares `completionCondition`; the bundled 1.0.0
3241
- // does not) and refused when it does not.
3240
+ // (the carried 1.0 and the bundled 1.0.0 both declare
3241
+ // `completionCondition`, neither declares `breakEnabled`) and refused
3242
+ // when it does not.
3242
3243
  const loopDef = definitionFor(NODE_TYPE.loop, version);
3243
3244
  const refusal = loopVersionRefusal(step.name, o, usesBreak, loopDef);
3244
3245
  if (refusal)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.86.23",
3
+ "version": "6.86.25",
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": "01b10b60d64048ea4ec6bcb904919687d906fae4"
106
+ "gitref": "c82a85de756369133de0b4d6aff90569d47e5363"
107
107
  }