@uipath/maestro-builder-sdk 6.105.1 → 6.107.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.
@@ -157,6 +157,7 @@ export function planSharedInputs(decl) {
157
157
  target = {
158
158
  name,
159
159
  type: declared ? String(declared.type) : String(inp.type),
160
+ ...(!declared && inp.format !== undefined ? { format: inp.format } : {}),
160
161
  declaredAs: od ? 'output' : vd ? 'var' : 'auto',
161
162
  hasDefault: (od?.default ?? vd?.default) !== undefined,
162
163
  feeds: [],
@@ -216,7 +217,10 @@ export function planSharedInputs(decl) {
216
217
  const targets = [...byName.values()];
217
218
  // A target that names an input is already refused above; leaving it out here
218
219
  // keeps the global plan from reporting the same name a second time.
219
- const autoVars = targets.filter((t) => t.declaredAs === 'auto' && !inputNames.has(t.name)).map((t) => ({ name: t.name, type: t.type }));
220
+ // An auto variable keeps the first feeding input's number width, so its global has the input's type.
221
+ const autoVars = targets.filter((t) => t.declaredAs === 'auto' && !inputNames.has(t.name)).map((t) => ({
222
+ name: t.name, type: t.type, ...(t.format !== undefined ? { format: t.format } : {}),
223
+ }));
220
224
  return { targets, autoVars, problems };
221
225
  }
222
226
  /**
package/dist/merge-cli.js CHANGED
@@ -63,6 +63,10 @@
63
63
  * the sidecars in memory; what merge cannot carry is warned, and refused under
64
64
  * `--strict`. See merge-sidecars.ts.
65
65
  *
66
+ * Writing into a Flow project that already holds another `.flow` outside its
67
+ * dot-folders (a candidate beside the original, a backup) warns
68
+ * `SECOND_FLOW_IN_PROJECT` (project-flows.ts).
69
+ *
66
70
  * Agent resources (#1221): a context or tool the edit adds or changes is written
67
71
  * beside the merged output too. One the edit REMOVES is listed, one
68
72
  * `flow-merge: remove <dir>` line each (and `removed` in `--json`), because
@@ -72,7 +76,7 @@
72
76
  * merged flow and its agents, as compile does, and written beside the merged
73
77
  * output when it changes.
74
78
  */
75
- import { reportCompileRefusal, reportDiagnostics, reportResult } from './cli-result.js';
79
+ import { diagnosticLine, reportCompileRefusal, reportDiagnostics, reportResult } from './cli-result.js';
76
80
  import { writeJsonFile } from './core/json-file.js';
77
81
  import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
78
82
  import { inlineAgentResources, mergeBindingsV2, projectBindingRows, refreshInlineAgentRows } from './bindings-v2.js';
@@ -82,6 +86,7 @@ import { MergeRefusedError, mergeFlowWithSidecars } from './merge.js';
82
86
  import { sidecarSetFromList } from './merge-sidecars.js';
83
87
  import { isWithin } from './path-within.js';
84
88
  import { flowSources, projectMainFlow, resourceSourcesOfOtherFlows } from './project-resource-users.js';
89
+ import { secondFlowWarning } from './project-flows.js';
85
90
  import { flagValue, flagValues, runWhenInvokedDirectly } from './cli-run.js';
86
91
  import { readFlowFile } from './decompile-file.js';
87
92
  import { readFlowStamp, restampFlowSource, sourceDigest, STAMP_MARKER } from './decompile-stamp.js';
@@ -508,6 +513,14 @@ export async function run(argv) {
508
513
  mkdirSync(outDir, { recursive: true });
509
514
  writeJsonFile(out, flow);
510
515
  console.log(`flow-merge: wrote ${basename(out)} (${(flow.nodes ?? []).length} nodes, ${(flow.edges ?? []).length} edges)`);
516
+ // A candidate written into the original's Flow project outside a dot-folder, or an
517
+ // in-place merge into a project that holds a backup, leaves a second `.flow` where
518
+ // `uip` or a globbing reader can take it for the project's (#1996). Never fatal.
519
+ const second = secondFlowWarning(out);
520
+ if (second !== undefined) {
521
+ console.error(` ${diagnosticLine(second)}`);
522
+ reportDiagnostics([second]);
523
+ }
511
524
  for (const { sidecar, target } of targets) {
512
525
  mkdirSync(dirname(target), { recursive: true });
513
526
  writeJsonFile(target, sidecar.json);
@@ -0,0 +1,40 @@
1
+ /** How many folder levels below the project the scan reads. */
2
+ export declare const MAX_DEPTH = 8;
3
+ /** How many folders the scan reads before it stops. */
4
+ export declare const MAX_DIRS = 2000;
5
+ /**
6
+ * The Flow project folder that holds `file`, or `undefined` when no
7
+ * `project.uiproj` sits at or above its folder.
8
+ *
9
+ * @example
10
+ * // Solution/Order/project.uiproj exists
11
+ * flowProjectOf('Solution/Order/backup/Order.flow') // '<abs>/Solution/Order'
12
+ * flowProjectOf('scratch/Order.flow') // undefined
13
+ */
14
+ export declare function flowProjectOf(file: string): string | undefined;
15
+ /**
16
+ * Every `.flow` file in the Flow project that holds `file`, other than `file`
17
+ * itself: paths relative to the project folder, sorted. Empty outside a project.
18
+ *
19
+ * @example
20
+ * otherProjectFlows('Solution/Order/Order.flow')
21
+ * // { project: '<abs>/Solution/Order', others: ['backup/Order.flow'] }
22
+ */
23
+ export declare function otherProjectFlows(file: string): {
24
+ project: string | undefined;
25
+ others: string[];
26
+ };
27
+ /**
28
+ * The `SECOND_FLOW_IN_PROJECT` warning for writing `file`, or `undefined` when
29
+ * its project holds no other `.flow` a reader sees, or `file` itself sits where
30
+ * none looks (a dot-folder).
31
+ *
32
+ * @example
33
+ * secondFlowWarning('Solution/Order/Order.flow')?.message
34
+ * // 'the Flow project Order/ holds another .flow besides Order.flow: backup/Order.flow. …'
35
+ */
36
+ export declare function secondFlowWarning(file: string): {
37
+ level: 'warning';
38
+ code: 'SECOND_FLOW_IN_PROJECT';
39
+ message: string;
40
+ } | undefined;
@@ -0,0 +1,136 @@
1
+ /**
2
+ * project-flows — the other `.flow` files in the Flow project a write lands in,
3
+ * for compile's and merge's `SECOND_FLOW_IN_PROJECT` warning (#1996).
4
+ *
5
+ * Two readers take a project's `.flow` from its folder, not from a name:
6
+ *
7
+ * - `uip` (pack, debug, validate, `solution resources refresh`) picks one from
8
+ * the project root, `content/` or `flow_files/` (`scanProjectFlowFile` in the
9
+ * CLI's packager-tool-flow `flow-io.ts`). With several there and no
10
+ * `MainFile`, it takes whichever the file system lists first.
11
+ * - A reader that globs the project, as the eval graders do
12
+ * (`glob('**' + '/*.flow', recursive=True)`), reads every `.flow` below it
13
+ * outside dot-folders: Python's glob skips those.
14
+ *
15
+ * Neither reads a dot-folder, so `.flow-sdk/`, where the generated pipeline
16
+ * compiles its baseline, edited and merged candidates, is not scanned. A backup
17
+ * or a `baseline/` compile anywhere else in the project is. Compile and merge are
18
+ * the only writers of a `.flow`, so they say so:
19
+ *
20
+ * Solution/Order/project.uiproj
21
+ * Solution/Order/Order.flow <- the deliverable
22
+ * Solution/Order/backup/Order.flow <- warned: a second .flow
23
+ * Solution/Order/.flow-sdk/Order.merged.flow (not warned: no reader sees it)
24
+ *
25
+ * The project is found as `uip` finds it (`findFlowProjectRoot` in the CLI's
26
+ * packager-tool-flow `flow-project-root.ts`): the nearest folder at or above the
27
+ * written file that holds `project.uiproj`. Like `uip`, the climb tests only for
28
+ * that file, one `exists` per level: it never lists an ancestor, which for a
29
+ * write under a crowded `/tmp` would read every entry there. Outside a project
30
+ * nothing is a deliverable, and nothing is warned.
31
+ *
32
+ * The scan is bounded: it does not follow links, skips dot-folders,
33
+ * `node_modules/` and any nested folder that is a project of its own, and stops after
34
+ * {@link MAX_DEPTH} levels or {@link MAX_DIRS} folders.
35
+ *
36
+ * Library module (FB010): it returns the files, and the CLIs print the warning.
37
+ */
38
+ import { existsSync, readdirSync } from 'node:fs';
39
+ import { dirname, join, relative, resolve } from 'node:path';
40
+ /** How many folder levels below the project the scan reads. */
41
+ export const MAX_DEPTH = 8;
42
+ /** How many folders the scan reads before it stops. */
43
+ export const MAX_DIRS = 2000;
44
+ /** Folders the scan never enters besides dot-folders. */
45
+ const SKIPPED = new Set(['node_modules']);
46
+ /**
47
+ * The Flow project folder that holds `file`, or `undefined` when no
48
+ * `project.uiproj` sits at or above its folder.
49
+ *
50
+ * @example
51
+ * // Solution/Order/project.uiproj exists
52
+ * flowProjectOf('Solution/Order/backup/Order.flow') // '<abs>/Solution/Order'
53
+ * flowProjectOf('scratch/Order.flow') // undefined
54
+ */
55
+ export function flowProjectOf(file) {
56
+ let dir = dirname(resolve(file));
57
+ for (;;) {
58
+ if (existsSync(join(dir, 'project.uiproj')))
59
+ return dir;
60
+ const parent = dirname(dir);
61
+ if (parent === dir)
62
+ return undefined;
63
+ dir = parent;
64
+ }
65
+ }
66
+ /**
67
+ * Every `.flow` file in the Flow project that holds `file`, other than `file`
68
+ * itself: paths relative to the project folder, sorted. Empty outside a project.
69
+ *
70
+ * @example
71
+ * otherProjectFlows('Solution/Order/Order.flow')
72
+ * // { project: '<abs>/Solution/Order', others: ['backup/Order.flow'] }
73
+ */
74
+ export function otherProjectFlows(file) {
75
+ const project = flowProjectOf(file);
76
+ if (project === undefined)
77
+ return { project, others: [] };
78
+ const self = resolve(file);
79
+ const others = [];
80
+ const queue = [{ dir: project, depth: 0 }];
81
+ let read = 0;
82
+ while (queue.length > 0 && read < MAX_DIRS) {
83
+ const { dir, depth } = queue.shift();
84
+ read++;
85
+ let entries;
86
+ try {
87
+ entries = readdirSync(dir, { withFileTypes: true });
88
+ }
89
+ catch {
90
+ continue;
91
+ }
92
+ for (const e of entries) {
93
+ const path = join(dir, e.name);
94
+ if (e.isFile() && e.name.endsWith('.flow')) {
95
+ if (path !== self)
96
+ others.push(relative(project, path));
97
+ }
98
+ else if (e.isDirectory() && !e.name.startsWith('.') && !SKIPPED.has(e.name) && depth < MAX_DEPTH && !existsSync(join(path, 'project.uiproj'))) {
99
+ queue.push({ dir: path, depth: depth + 1 });
100
+ }
101
+ }
102
+ }
103
+ return { project, others: others.sort() };
104
+ }
105
+ /** A project-relative path inside a folder the scan does not read (a dot-folder, `node_modules/`). */
106
+ function unread(rel) {
107
+ return rel.split(/[\\/]/).slice(0, -1).some((seg) => seg.startsWith('.') || SKIPPED.has(seg));
108
+ }
109
+ /**
110
+ * The `SECOND_FLOW_IN_PROJECT` warning for writing `file`, or `undefined` when
111
+ * its project holds no other `.flow` a reader sees, or `file` itself sits where
112
+ * none looks (a dot-folder).
113
+ *
114
+ * @example
115
+ * secondFlowWarning('Solution/Order/Order.flow')?.message
116
+ * // 'the Flow project Order/ holds another .flow besides Order.flow: backup/Order.flow. …'
117
+ */
118
+ export function secondFlowWarning(file) {
119
+ const { project, others } = otherProjectFlows(file);
120
+ if (project === undefined || others.length === 0)
121
+ return undefined;
122
+ // Written into a dot-folder (the pipeline's `.flow-sdk/Order.baseline/Order.flow`):
123
+ // no reader sees this file, so it competes with nothing.
124
+ if (unread(relative(project, resolve(file))))
125
+ return undefined;
126
+ const shown = others.length > 5 ? `${others.slice(0, 5).join(', ')}, and ${others.length - 5} more` : others.join(', ');
127
+ const name = relative(dirname(project), project) || project;
128
+ return {
129
+ level: 'warning',
130
+ code: 'SECOND_FLOW_IN_PROJECT',
131
+ message: `the Flow project ${name}/ holds another .flow besides ${relative(project, resolve(file))}: ${shown}. `
132
+ + '`uip` packs and validates one .flow per project, taken from its root, content/ or flow_files/ (the first listed when there are several and no MainFile), '
133
+ + 'and a reader that globs the project (**/*.flow) reads every .flow outside dot-folders. '
134
+ + 'Keep one .flow in the project: delete the others, or move them out of it or into .flow-sdk/.',
135
+ };
136
+ }
package/dist/serialize.js CHANGED
@@ -385,6 +385,14 @@ function renderUpdates(updates, rename) {
385
385
  return { variableId: rename.updates?.get(name) ?? name, expression };
386
386
  });
387
387
  }
388
+ /**
389
+ * The `type` a declared variable's global carries: its `types.*` name, or for
390
+ * a `{ type: types.number, format }` the width (`"double"`), the type the
391
+ * `.flow` it was decompiled from had (`VarSpec.format`).
392
+ */
393
+ function globalType(decl) {
394
+ return decl.format ?? decl.type;
395
+ }
388
396
  /**
389
397
  * The optional metadata a declared variable persists on its global — appended
390
398
  * AFTER the fixed fields so a flow that declares none is byte-identical to
@@ -1989,16 +1997,16 @@ function serializeFlow(built, opts) {
1989
1997
  emitEnd(scope, uid(scope, 'end'), capped);
1990
1998
  const globals = [];
1991
1999
  for (const inp of child.inputs)
1992
- globals.push({ id: inp.name, name: inp.name, direction: 'in', type: inp.type, triggerNodeId: startId, ...varMeta(inp) });
2000
+ globals.push({ id: inp.name, name: inp.name, direction: 'in', type: globalType(inp), triggerNodeId: startId, ...varMeta(inp) });
1993
2001
  for (const o of childGlobals.outputs)
1994
- globals.push({ id: o.name, name: o.name, direction: 'out', type: o.type, ...varMeta(o) });
2002
+ globals.push({ id: o.name, name: o.name, direction: 'out', type: globalType(o), ...varMeta(o) });
1995
2003
  for (const o of childGlobals.outputs) {
1996
2004
  const b = childGlobals.backing.get(o.name);
1997
2005
  if (b && !childGlobals.backingAdopted.has(o.name))
1998
2006
  globals.push(outputBackingGlobal(o, b));
1999
2007
  }
2000
2008
  for (const vd of childGlobals.vars)
2001
- globals.push({ id: vd.name, name: vd.name, direction: 'inout', type: vd.type, ...varMeta(vd) });
2009
+ globals.push({ id: vd.name, name: vd.name, direction: 'inout', type: globalType(vd), ...varMeta(vd) });
2002
2010
  resolveRejoins(scope, addEdge, (from, refusal) => refuseOn(scope, stepOfNode(scope, from.node), refusal));
2003
2011
  assertHitlExitInvariant(scope.nodes, scope.edges, legacyCompletedNodes);
2004
2012
  typeAgentInputSchemas(scope, globals);
@@ -3632,19 +3640,19 @@ function serializeFlow(built, opts) {
3632
3640
  const globals = [];
3633
3641
  const triggerNodeId = built.triggerId ?? 'start';
3634
3642
  for (const inp of built.inputs)
3635
- globals.push({ id: inp.name, name: inp.name, direction: 'in', type: inp.type, triggerNodeId, ...varMeta(inp) });
3643
+ globals.push({ id: inp.name, name: inp.name, direction: 'in', type: globalType(inp), triggerNodeId, ...varMeta(inp) });
3636
3644
  for (const o of rootGlobals.outputs)
3637
- globals.push({ id: o.name, name: o.name, direction: 'out', type: o.type, ...varMeta(o) });
3645
+ globals.push({ id: o.name, name: o.name, direction: 'out', type: globalType(o), ...varMeta(o) });
3638
3646
  for (const o of rootGlobals.outputs) {
3639
3647
  const b = rootGlobals.backing.get(o.name);
3640
3648
  if (b && !rootGlobals.backingAdopted.has(o.name))
3641
3649
  globals.push(outputBackingGlobal(o, b));
3642
3650
  }
3643
3651
  for (const vd of rootGlobals.vars)
3644
- globals.push({ id: vd.name, name: vd.name, direction: 'inout', type: vd.type, ...varMeta(vd) });
3652
+ globals.push({ id: vd.name, name: vd.name, direction: 'inout', type: globalType(vd), ...varMeta(vd) });
3645
3653
  for (const ep of entryPoints) {
3646
3654
  for (const inp of ep.inputs) {
3647
- globals.push({ id: inp.name, name: inp.name, direction: 'in', type: inp.type, triggerNodeId: ep.id, ...varMeta(inp) });
3655
+ globals.push({ id: inp.name, name: inp.name, direction: 'in', type: globalType(inp), triggerNodeId: ep.id, ...varMeta(inp) });
3648
3656
  }
3649
3657
  }
3650
3658
  resolveRejoins(root, addEdge, (from, refusal) => refuseOn(root, stepOfNode(root, from.node), refusal));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.105.1",
3
+ "version": "6.107.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",
@@ -60,6 +60,7 @@
60
60
  "flow-decompile": "./dist/decompile-cli.js",
61
61
  "flow-merge": "./dist/merge-cli.js",
62
62
  "flow-check": "./dist/check-cli.js",
63
+ "flow-build": "./dist/build-cli.js",
63
64
  "case-compile": "./dist/case/compile-cli.js",
64
65
  "case-check": "./dist/case/check-cli.js",
65
66
  "case-decompile": "./dist/case/decompile-cli.js",
@@ -84,7 +85,8 @@
84
85
  "flow-check-baseline",
85
86
  "flow-decompile-scripts",
86
87
  "flow-script-metadata",
87
- "flow-pipeline-strict"
88
+ "flow-pipeline-strict",
89
+ "flow-build"
88
90
  ],
89
91
  "files": [
90
92
  "dist",
@@ -121,5 +123,5 @@
121
123
  "@types/node": "^22.7.0",
122
124
  "esbuild": "^0.28.1"
123
125
  },
124
- "gitref": "187db960348287f6543d4824b9c5d9f865f86c7a"
126
+ "gitref": "4295f20ce709d1016209913e4bfc43b93ee986ef"
125
127
  }