@uipath/maestro-builder-sdk 6.99.0 → 6.101.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.
package/dist/check-cli.js CHANGED
@@ -21,6 +21,7 @@ import { readCliResources } from './registry/prepare/resources.js';
21
21
  import { resolveFlowFile, loadBuiltFlow } from './load.js';
22
22
  import { check, checkCompiled, scopeToEdit } from './check.js';
23
23
  import { flowCheckOpts } from './cli-library.js';
24
+ import { readNodeCatalog } from './node-catalog-files.js';
24
25
  import { withFetchedDefinitions } from './registry/fetch/with-fetched-definitions.js';
25
26
  import { Bindings } from './bindings.js';
26
27
  import { flagValue, flagValues, runWhenInvokedDirectly } from './cli-run.js';
@@ -54,7 +55,8 @@ function checkOpts(argv, library) {
54
55
  // as still owed — telling the author to re-run a `prepare` they already ran.
55
56
  // The resource ledger `prepare` writes, the default found as bindings.json is.
56
57
  const resources = readCliResources(argv, defaultResourcesFile());
57
- return { ...flowCheckOpts(library, bindings), ...(resources ? { resources } : {}) };
58
+ // The node registry cache a manifest-less `rawNode` resolves from (#1981), read on first use.
59
+ return { ...flowCheckOpts(library, bindings), ...(resources ? { resources } : {}), nodeCatalog: readNodeCatalog() };
58
60
  }
59
61
  export async function run(argv) {
60
62
  const arg = argv.find((a, i) => !a.startsWith('--') && !VALUE_FLAGS.has(argv[i - 1])) ?? argv[0];
package/dist/check.d.ts CHANGED
@@ -9,6 +9,7 @@
9
9
  * lives in the serializer alone.
10
10
  */
11
11
  import type { ResourceResolutions } from './core/resource-resolution.js';
12
+ import type { NodeCatalog } from './core/node-catalog.js';
12
13
  import type { Library } from './core/library.js';
13
14
  import type { BuiltFlow } from './flow-sdk.js';
14
15
  import { type EventCheckOpts } from './core/event-checks.js';
@@ -82,6 +83,12 @@ export interface CheckOpts extends ConnectorCheckOpts, EventCheckOpts {
82
83
  * a library can lower is not judged (check fails open, as its library rules do).
83
84
  */
84
85
  library?: Library;
86
+ /**
87
+ * The node registry cache `compile` serializes with (`SerializeOpts.nodeCatalog`):
88
+ * where a `rawNode` without `manifest` finds its definition. Without one, such
89
+ * a step is `RAW_NODE_MANIFEST_NOT_CACHED`, as `compile` would say.
90
+ */
91
+ nodeCatalog?: NodeCatalog;
85
92
  /** `false` skips the serializer pass, for a caller that compiles the flow itself (`merge`). */
86
93
  serializer?: false;
87
94
  }
package/dist/check.js CHANGED
@@ -11,7 +11,9 @@ import { hasExits } from './core/step-ports.js';
11
11
  import { actionTails, armReachesJoin } from './flow-parallel-hitl.js';
12
12
  import { FLOW_SCHEMA_VERSIONS } from './format-profile.js';
13
13
  import { compareSchemaVersions, schemaVersionRefusal } from './schema-version.js';
14
- import { planSharedInputs, sharedInputRoots } from './flow-variables.js';
14
+ import { planFlowGlobals, planSharedInputs, sharedInputRoots } from './flow-variables.js';
15
+ import { backedOutputs } from './flow-output-backing.js';
16
+ import { childStepLists } from './flow-step-tree.js';
15
17
  import { VARS_READ_RE } from './core/vars-read.js';
16
18
  import { FLOW_METADATA_KEYS, unknownMetadataKeys } from './core/flow-metadata.js';
17
19
  import { endContentKey } from './flow-end-content.js';
@@ -48,7 +50,7 @@ export function checkCompiled(built, opts = {}) {
48
50
  });
49
51
  }
50
52
  const serialized = opts.serializer !== false
51
- ? serializerRefusals(built, { library: opts.library, bindings: opts.bindings, resources: opts.resources }, diags)
53
+ ? serializerRefusals(built, { library: opts.library, bindings: opts.bindings, resources: opts.resources, nodeCatalog: opts.nodeCatalog }, diags)
52
54
  : { diagnostics: [], flow: undefined };
53
55
  diags.push(...serialized.diagnostics);
54
56
  const placed = serialized.flow !== undefined ? placeDiagnostics(diags, serialized.flow) : undefined;
@@ -702,7 +704,7 @@ function checkFlow(built, ancestors, opts = {}) {
702
704
  // to route, and an arm for an exit it does not declare, are the
703
705
  // serializer's STEP_SWITCH_NO_EXITS / STEP_SWITCH_EXIT_UNKNOWN.
704
706
  if (s0.kind === 'stepSwitch') {
705
- const exits = stepExits(s0.spec, s0.options?.version);
707
+ const exits = stepExits(s0.spec, s0.options?.version, opts.nodeCatalog);
706
708
  if (!hasExits(exits)) {
707
709
  for (const c of s0.cases)
708
710
  walk(c.body, inLoop);
@@ -1233,6 +1235,8 @@ function checkFlow(built, ancestors, opts = {}) {
1233
1235
  }
1234
1236
  // The End compile appends when the root path runs out of steps (#941).
1235
1237
  diags.push(...checkFallOffEnd(built));
1238
+ // The End an explicit `.return()` writes (#1966).
1239
+ diags.push(...checkReturnOutputs(built));
1236
1240
  // Check every child flow with the same rules, in its OWN scope — a child's
1237
1241
  // steps never see the parent's variables, so its undeclared references,
1238
1242
  // duplicate step names and type mismatches are its own. Diagnostics come back
@@ -1383,6 +1387,80 @@ function checkFallOffEnd(built) {
1383
1387
  }
1384
1388
  return diags;
1385
1389
  }
1390
+ /**
1391
+ * RETURN_OUTPUT_MISSING: an explicit `.return({ … })` that leaves a declared
1392
+ * output with nothing to map from (#1966).
1393
+ *
1394
+ * A `.return()` End maps each output it names from that value, and every other
1395
+ * output from what set it on the way (`endOutputs` / `fillInSource` in
1396
+ * serialize). An output with a backing Variable (`backedOutputs`: a `default`,
1397
+ * `{ updates }`, a `{ shared }` input, a read in code) maps from that Variable.
1398
+ * One with none is set ONLY by a `.return()` that names it, so this End maps it
1399
+ * to `null`, on every run, whatever the path did before. That is certain, not
1400
+ * "may be unset" as NO_RETURN's flow-sensitive question is, so it is an error.
1401
+ *
1402
+ * ```ts
1403
+ * flow('R').output({ a: types.string, b: types.string })
1404
+ * .step('s', script({ code: 'return 1;' }))
1405
+ * .return({ a: lit('x') }) // b is null here: RETURN_OUTPUT_MISSING
1406
+ * ```
1407
+ *
1408
+ * Every `.return()` in the flow's own tree is judged (`childStepLists`):
1409
+ * `.branch` / `.switch` / `.stepSwitch` arms, loop bodies, `.parallel` arms and
1410
+ * `.stepToList` / `.onError` bodies, and entry-point paths. A subflow child is
1411
+ * checked in its own scope by `checkFlow`'s recursion. Returning `null` on
1412
+ * purpose is still possible, and says so: `.return({ b: lit(null) })`.
1413
+ */
1414
+ function checkReturnOutputs(built) {
1415
+ if (built.outputs.length === 0)
1416
+ return [];
1417
+ // The outputs after the `.output()` + `.var()` merge, which can add a default
1418
+ // (#899). A merge problem is the serializer's refusal, reported on its own.
1419
+ const inputs = [...built.inputs, ...(built.entryPoints ?? []).flatMap((ep) => ep.inputs)];
1420
+ const outputs = planFlowGlobals({ inputs, outputs: built.outputs, vars: built.vars }).outputs;
1421
+ const shared = planSharedInputs({ roots: sharedInputRoots(built), outputs: built.outputs, vars: built.vars });
1422
+ const sharedOutputs = new Set(shared.targets.filter((t) => t.declaredAs === 'output').map((t) => t.name));
1423
+ const backed = backedOutputs(built, outputs, sharedOutputs);
1424
+ const diags = [];
1425
+ const visit = (steps, container) => {
1426
+ let after = container;
1427
+ for (const st of steps) {
1428
+ if (st.kind === 'return') {
1429
+ const missing = outputs.map((o) => o.name).filter((n) => !(n in st.values) && !backed.has(n));
1430
+ if (missing.length)
1431
+ diags.push(returnOutputMissing(st, after, missing));
1432
+ }
1433
+ const name = st.kind !== 'return' && 'name' in st ? st.name : undefined;
1434
+ for (const body of childStepLists(st))
1435
+ visit(body, name ?? after);
1436
+ // A `.stepToList` / `.stepToRef` follows the step it leaves; it is not the
1437
+ // step a later `.return()` follows.
1438
+ if (name !== undefined && st.kind !== 'stepToList' && st.kind !== 'stepToRef')
1439
+ after = name;
1440
+ }
1441
+ };
1442
+ visit(built.steps, undefined);
1443
+ for (const ep of built.entryPoints ?? [])
1444
+ visit(ep.steps, ep.id);
1445
+ return diags;
1446
+ }
1447
+ function returnOutputMissing(st, after, missing) {
1448
+ const one = missing.length === 1;
1449
+ const names = missing.map((n) => `"${n}"`).join(', ');
1450
+ const where = after === undefined ? 'The .return()' : `The .return() after "${after}"`;
1451
+ return {
1452
+ level: 'error',
1453
+ code: 'RETURN_OUTPUT_MISSING',
1454
+ message: `${where} does not set ${one ? 'output' : 'outputs'} ${names}, and nothing else in the flow sets `
1455
+ + `${one ? 'it' : 'them'} (no default, { updates } or shared input), so the run returns null for `
1456
+ + `${one ? 'it' : 'them'} on this path. Name ${one ? 'it' : 'each one'} in the .return({ … }); `
1457
+ + `write ${missing[0]}: lit(null) if null is what this path should return.`,
1458
+ // A named End is a node merge can place a finding on (#1322); an unnamed
1459
+ // one has no id until compile, so it stays `return`, as its expressions do.
1460
+ step: st.options?.name ?? 'return',
1461
+ suggestion: `.return({ ${[...Object.keys(st.values).map((k) => `${k}: …`), ...missing.map((n) => `${n}: …`)].join(', ')} })`,
1462
+ };
1463
+ }
1386
1464
  /**
1387
1465
  * `armTails`, step for step, carrying what each path has surely written. A
1388
1466
  * `.return()` value is NOT a write here: it lives on that `.return()`'s End,
@@ -2548,7 +2626,10 @@ placed, opts) {
2548
2626
  let def;
2549
2627
  try {
2550
2628
  const requestedVersion = step.options?.version;
2551
- def = resolveContributionDefinition(maybeCustom.contribute(requestedVersion !== undefined ? { requestedVersion } : {}).definition, requestedVersion, `step "${step.name}"`);
2629
+ def = resolveContributionDefinition(maybeCustom.contribute({
2630
+ ...(requestedVersion !== undefined ? { requestedVersion } : {}),
2631
+ ...(opts.nodeCatalog !== undefined ? { nodeCatalog: opts.nodeCatalog } : {}),
2632
+ }).definition, requestedVersion, `step "${step.name}"`);
2552
2633
  }
2553
2634
  catch {
2554
2635
  // A contribution compile cannot lower is the serializer's CONTRIBUTION_INVALID.
@@ -0,0 +1,10 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * `flow-sdk capabilities` (#1991): what this installed copy supports, so a
4
+ * caller asks instead of guessing the release from what the package ships.
5
+ *
6
+ * Plain output is the name and version on the first line, then one capability
7
+ * per line, so `flow-sdk capabilities | grep -qx flow-check-baseline` works.
8
+ * With `--json`: `{"ok":true,"name":…,"version":…,"gitref":…,"capabilities":[…]}`.
9
+ */
10
+ export declare function registerCapabilitiesCommand(program: Command): void;
@@ -0,0 +1,24 @@
1
+ import { jsonResultRequested, recordJsonFields } from '../common.js';
2
+ /**
3
+ * `flow-sdk capabilities` (#1991): what this installed copy supports, so a
4
+ * caller asks instead of guessing the release from what the package ships.
5
+ *
6
+ * Plain output is the name and version on the first line, then one capability
7
+ * per line, so `flow-sdk capabilities | grep -qx flow-check-baseline` works.
8
+ * With `--json`: `{"ok":true,"name":…,"version":…,"gitref":…,"capabilities":[…]}`.
9
+ */
10
+ export function registerCapabilitiesCommand(program) {
11
+ program.command('capabilities')
12
+ .description('Print this SDK\'s name, version, gitref and the stable names of the features it supports.')
13
+ .action(async () => {
14
+ const { sdkCapabilities } = await import('../../sdk-capabilities.js');
15
+ const caps = sdkCapabilities();
16
+ if (jsonResultRequested()) {
17
+ recordJsonFields({ ...caps });
18
+ return;
19
+ }
20
+ console.log(`${caps.name} ${caps.version}${caps.gitref === null ? '' : ` (gitref ${caps.gitref})`}`);
21
+ for (const capability of caps.capabilities)
22
+ console.log(capability);
23
+ });
24
+ }
@@ -11,6 +11,8 @@ export declare function invoke(label: string, load: () => Promise<{
11
11
  export declare function refuse(message: string, exitCode?: number): void;
12
12
  /** Record why the verb failed before any tool ran, for the `--json` object. */
13
13
  export declare function recordJsonError(message: string): void;
14
+ /** Add a verb's own fields to the `--json` object. */
15
+ export declare function recordJsonFields(fields: Record<string, unknown>): void;
14
16
  /** Turn `--json` on for this run (the umbrella's `preAction` hook). */
15
17
  export declare function requestJsonResult(): void;
16
18
  export declare function jsonResultRequested(): boolean;
@@ -22,26 +24,24 @@ export declare function jsonResultRequested(): boolean;
22
24
  */
23
25
  export declare function emitJsonResult(): void;
24
26
  export declare function addValue(argv: string[], flag: string, value: unknown): void;
27
+ /** Is emit-only mode on for the PROJECT containing `cwd`? See {@link nearestSetting}. */
28
+ export declare function emitOnlyEnabled(cwd?: string, env?: NodeJS.ProcessEnv): boolean;
25
29
  /**
26
- * Is emit-only mode on for the PROJECT containing `cwd`?
27
- *
28
- * Emit-only is a property of the project, not of the directory you happen to be
29
- * standing in, so this walks up for the nearest `package.json` that actually
30
- * declares `flowSdk.emitOnly` — the way Node tooling resolves project config.
30
+ * Refuse a `flow`, `case` or `bpmn` verb (exit 2) when its project declares
31
+ * `flowSdk.minVersion` and this installed SDK is older (#1991). The project is
32
+ * looked up from the working directory and from each input path
33
+ * ({@link floorAnchors}); a floor any of them finds must be met. Returns whether
34
+ * it refused.
31
35
  *
32
- * Anchoring it to `process.cwd()` alone was #392. Compiling the same project from
33
- * a subdirectory found no `package.json`, silently re-armed the checker, and —
34
- * because check GATES EMISSION — turned a working build into
35
- * `compile: 1 error(s); not emitting.` The same anchoring let `flow check` slip
36
- * past its own emit-only refusal simply by being run one directory down.
37
- *
38
- * Nearest DECLARATION wins, not nearest package.json: a nested `package.json`
39
- * that says nothing about `flowSdk` must not lift an ancestor's emit-only, since
40
- * scaffolders (`uip solution init`) drop exactly such a file into a subdirectory
41
- * of an emit-only project. A nested package that explicitly sets
42
- * `emitOnly: false` still opts out — silence and denial are different answers.
36
+ * The floor lets a project, or a skill that writes its package.json, state the
37
+ * one release it was written for, instead of probing the SDK for each feature.
38
+ * The nearest declaration wins, as for `emitOnly`. A value that is not a release
39
+ * version (`"^6.1"`, `6`) is refused too: a typo must not switch the floor off.
40
+ * A build of a checkout (`0.0.0-local`, `9999.0.0-local`) meets every floor.
41
+ * Registry verbs and `capabilities` are not gated: they are how a caller finds
42
+ * out what it has.
43
43
  */
44
- export declare function emitOnlyEnabled(cwd?: string, env?: NodeJS.ProcessEnv): boolean;
44
+ export declare function refuseBelowMinVersion(label: string, argv?: readonly string[], cwd?: string): Promise<boolean>;
45
45
  export type CheckMode = 'source' | 'compiled';
46
46
  export declare function inferCheckMode(family: 'flow' | 'case' | 'bpmn', input: string, source: boolean, compiled: boolean): CheckMode;
47
47
  /**
@@ -1,7 +1,10 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
- import { dirname, join, resolve } from 'node:path';
2
+ import { basename, dirname, join, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
3
4
  import { Option } from 'commander';
4
5
  export async function invoke(label, load, argv) {
6
+ if (await refuseBelowMinVersion(label, argv))
7
+ return;
5
8
  // In `--json` mode stdout carries exactly one JSON object, printed by
6
9
  // `emitJsonResult` once the verb is done. The tool's own human lines go to
7
10
  // stderr meanwhile, so they are still seen but never mixed into it.
@@ -48,6 +51,10 @@ export function refuse(message, exitCode = 2) {
48
51
  export function recordJsonError(message) {
49
52
  resultSlot().fields.error ??= message.replace(/^error: /, '');
50
53
  }
54
+ /** Add a verb's own fields to the `--json` object. */
55
+ export function recordJsonFields(fields) {
56
+ Object.assign(resultSlot().fields, fields);
57
+ }
51
58
  /** Turn `--json` on for this run (the umbrella's `preAction` hook). */
52
59
  export function requestJsonResult() {
53
60
  resultSlot().json = true;
@@ -80,29 +87,30 @@ export function addValue(argv, flag, value) {
80
87
  argv.push(flag, value);
81
88
  }
82
89
  /**
83
- * `flowSdk.emitOnly` as declared by ONE package.json, or `undefined` when that
84
- * file says nothing about it — absent, unreadable, malformed, or non-boolean.
85
- * "Says nothing" is deliberately distinct from "says false": only the former
86
- * lets the search continue to the parent directory.
90
+ * The value `flowSdk.<key>` has in ONE package.json, or `undefined` when that
91
+ * file says nothing about it — absent, unreadable, malformed, or rejected by
92
+ * `accept`. "Says nothing" is deliberately distinct from "says false": only the
93
+ * former lets the search continue to the parent directory.
87
94
  */
88
- function declaredEmitOnly(packagePath) {
95
+ function declaredSetting(packagePath, key, accept) {
89
96
  if (!existsSync(packagePath))
90
97
  return undefined;
91
98
  try {
92
99
  const pkg = JSON.parse(readFileSync(packagePath, 'utf8'));
93
- const declared = pkg.flowSdk?.emitOnly;
94
- return typeof declared === 'boolean' ? declared : undefined;
100
+ const declared = pkg.flowSdk?.[key];
101
+ return declared === undefined ? undefined : accept(declared);
95
102
  }
96
103
  catch {
97
104
  return undefined;
98
105
  }
99
106
  }
100
107
  /**
101
- * Is emit-only mode on for the PROJECT containing `cwd`?
108
+ * The nearest `flowSdk.<key>` declaration at or above `cwd`, with the
109
+ * package.json that made it; `undefined` when no ancestor declares one.
102
110
  *
103
- * Emit-only is a property of the project, not of the directory you happen to be
104
- * standing in, so this walks up for the nearest `package.json` that actually
105
- * declares `flowSdk.emitOnly` — the way Node tooling resolves project config.
111
+ * A setting under `flowSdk` is a property of the project, not of the directory
112
+ * you happen to be standing in, so this walks up for the nearest `package.json`
113
+ * that actually declares it — the way Node tooling resolves project config.
106
114
  *
107
115
  * Anchoring it to `process.cwd()` alone was #392. Compiling the same project from
108
116
  * a subdirectory found no `package.json`, silently re-armed the checker, and —
@@ -111,23 +119,109 @@ function declaredEmitOnly(packagePath) {
111
119
  * past its own emit-only refusal simply by being run one directory down.
112
120
  *
113
121
  * Nearest DECLARATION wins, not nearest package.json: a nested `package.json`
114
- * that says nothing about `flowSdk` must not lift an ancestor's emit-only, since
122
+ * that says nothing about `flowSdk` must not lift an ancestor's setting, since
115
123
  * scaffolders (`uip solution init`) drop exactly such a file into a subdirectory
116
- * of an emit-only project. A nested package that explicitly sets
117
- * `emitOnly: false` still opts out — silence and denial are different answers.
124
+ * of a project. A nested package that explicitly sets `emitOnly: false` still
125
+ * opts out — silence and denial are different answers.
118
126
  */
127
+ function nearestSetting(cwd, key, accept) {
128
+ for (let dir = resolve(cwd);;) {
129
+ const path = join(dir, 'package.json');
130
+ const value = declaredSetting(path, key, accept);
131
+ if (value !== undefined)
132
+ return { value, path };
133
+ const parent = dirname(dir);
134
+ if (parent === dir)
135
+ return undefined; // filesystem root, nothing declared it
136
+ dir = parent;
137
+ }
138
+ }
139
+ /** Is emit-only mode on for the PROJECT containing `cwd`? See {@link nearestSetting}. */
119
140
  export function emitOnlyEnabled(cwd = process.cwd(), env = process.env) {
120
141
  if (env.FLOW_SDK_EMIT_ONLY === '1')
121
142
  return true;
122
- for (let dir = resolve(cwd);;) {
123
- const declared = declaredEmitOnly(join(dir, 'package.json'));
124
- if (declared !== undefined)
125
- return declared;
143
+ return nearestSetting(cwd, 'emitOnly', (value) => (typeof value === 'boolean' ? value : undefined))?.value ?? false;
144
+ }
145
+ /** The families whose verbs read or write an artifact, and so honor the project floor. */
146
+ const FLOOR_FAMILIES = new Set(['flow', 'case', 'bpmn']);
147
+ /**
148
+ * The directories a verb's floor is looked up from: the working directory, and
149
+ * the directory of each input path, the leading positional arguments before the
150
+ * first option (`[source]`, `[input]`, `[original, edited]`). A verb run from
151
+ * outside its project (`flow check proj/sub/X.flow.ts`) is still in that project.
152
+ */
153
+ function floorAnchors(cwd, argv) {
154
+ const anchors = [resolve(cwd)];
155
+ for (const arg of argv) {
156
+ if (arg.startsWith('-'))
157
+ break;
158
+ const dir = dirname(resolve(cwd, arg));
159
+ if (!anchors.includes(dir))
160
+ anchors.push(dir);
161
+ }
162
+ return anchors;
163
+ }
164
+ /**
165
+ * The npm command that upgrades THIS copy of the SDK. A copy under a project's
166
+ * `node_modules` is used before a global one, so upgrading the global copy would
167
+ * leave the refusal in place; name `--save-dev` and the project then. `@latest`
168
+ * meets any published floor and needs no shell quoting (`>=` is a redirect in
169
+ * `cmd.exe`, quoted or not).
170
+ */
171
+ function upgradeCommand(name, packageRoot) {
172
+ for (let dir = packageRoot;;) {
126
173
  const parent = dirname(dir);
127
174
  if (parent === dir)
128
- return false; // filesystem root, nothing declared it
175
+ break;
176
+ if (basename(dir) === 'node_modules') {
177
+ if (existsSync(join(parent, 'package.json')))
178
+ return `\`npm install --save-dev ${name}@latest\` in ${parent}`;
179
+ break; // <prefix>/lib/node_modules, %APPDATA%\npm\node_modules: the global copy
180
+ }
129
181
  dir = parent;
130
182
  }
183
+ return `\`npm install -g ${name}@latest\``;
184
+ }
185
+ /** This package's root, from `dist/cli/common.js`. */
186
+ const PACKAGE_ROOT = resolve(fileURLToPath(new URL('../../', import.meta.url)));
187
+ /**
188
+ * Refuse a `flow`, `case` or `bpmn` verb (exit 2) when its project declares
189
+ * `flowSdk.minVersion` and this installed SDK is older (#1991). The project is
190
+ * looked up from the working directory and from each input path
191
+ * ({@link floorAnchors}); a floor any of them finds must be met. Returns whether
192
+ * it refused.
193
+ *
194
+ * The floor lets a project, or a skill that writes its package.json, state the
195
+ * one release it was written for, instead of probing the SDK for each feature.
196
+ * The nearest declaration wins, as for `emitOnly`. A value that is not a release
197
+ * version (`"^6.1"`, `6`) is refused too: a typo must not switch the floor off.
198
+ * A build of a checkout (`0.0.0-local`, `9999.0.0-local`) meets every floor.
199
+ * Registry verbs and `capabilities` are not gated: they are how a caller finds
200
+ * out what it has.
201
+ */
202
+ export async function refuseBelowMinVersion(label, argv = [], cwd = process.cwd()) {
203
+ if (!FLOOR_FAMILIES.has(label.split(' ')[0]))
204
+ return false;
205
+ const found = floorAnchors(cwd, argv)
206
+ .map((dir) => nearestSetting(dir, 'minVersion', (value) => value))
207
+ .filter((declared) => declared !== undefined);
208
+ if (found.length === 0)
209
+ return false;
210
+ const { isSdkVersionFloor, sdkCapabilities, sdkVersionSatisfies } = await import('../sdk-capabilities.js');
211
+ const { name, version } = sdkCapabilities();
212
+ for (const declared of found) {
213
+ const floor = declared.value;
214
+ if (typeof floor !== 'string' || !isSdkVersionFloor(floor)) {
215
+ refuse(`flow-sdk ${label}: flowSdk.minVersion in ${declared.path} is ${JSON.stringify(floor)}; write a plain release version, X.Y.Z`);
216
+ return true;
217
+ }
218
+ if (sdkVersionSatisfies(version, floor))
219
+ continue;
220
+ refuse(`flow-sdk ${label}: this project needs ${name} >= ${floor} (flowSdk.minVersion in ${declared.path}); found ${version} at ${PACKAGE_ROOT}. ` +
221
+ `Upgrade that copy: ${upgradeCommand(name, PACKAGE_ROOT)}.`);
222
+ return true;
223
+ }
224
+ return false;
131
225
  }
132
226
  export function inferCheckMode(family, input, source, compiled) {
133
227
  if (source && compiled)
package/dist/cli/index.js CHANGED
@@ -3,6 +3,7 @@ import { readFileSync } from 'node:fs';
3
3
  import { Command, CommanderError } from 'commander';
4
4
  import { emitJsonResult, recordJsonError, requestJsonResult } from './common.js';
5
5
  import { registerBpmnCommands } from './commands/bpmn.js';
6
+ import { registerCapabilitiesCommand } from './commands/capabilities.js';
6
7
  import { registerCaseCommands } from './commands/case.js';
7
8
  import { registerFlowCommands } from './commands/flow.js';
8
9
  import { registerRegistryCommands } from './commands/registry.js';
@@ -16,6 +17,7 @@ registerFlowCommands(program);
16
17
  registerCaseCommands(program);
17
18
  registerBpmnCommands(program);
18
19
  registerRegistryCommands(program);
20
+ registerCapabilitiesCommand(program);
19
21
  // `--json` on every verb (#809): one JSON object on stdout, human lines on
20
22
  // stderr. Added here, once, so a new verb cannot ship without it.
21
23
  const addJson = (command) => {
@@ -42,6 +42,7 @@ import { isWithin, physicalPath } from './path-within.js';
42
42
  import { flowSources, projectMainFlow, resourceSourcesOfOtherFlows } from './project-resource-users.js';
43
43
  import { fnv1aX4Uuid } from './core/stable-id.js';
44
44
  import { cliSpelling } from './core/cli-spelling.js';
45
+ import { readNodeCatalog } from './node-catalog-files.js';
45
46
  /** An agent folder name: a uuid, any case. */
46
47
  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
47
48
  export async function run(argv) {
@@ -151,6 +152,9 @@ export async function run(argv) {
151
152
  rehomed.set(source, { from: source, to, step, owner });
152
153
  return to;
153
154
  };
155
+ // The node registry cache `uip maestro flow registry pull` writes: a `rawNode`
156
+ // without `manifest` resolves its definition there (#1981). Read on first use.
157
+ const nodeCatalog = readNodeCatalog();
154
158
  const warnings = [];
155
159
  let emitted;
156
160
  try {
@@ -158,7 +162,7 @@ export async function run(argv) {
158
162
  // One pass's warnings: a pass that missed a definition runs again.
159
163
  warnings.length = 0;
160
164
  return serializeWithSidecars(built, {
161
- library, bindings, warn: (w) => warnings.push(w), resources, agentSource,
165
+ library, bindings, warn: (w) => warnings.push(w), resources, agentSource, nodeCatalog,
162
166
  carriedDrafts: (d) => warnings.push(draftWarning(d)),
163
167
  });
164
168
  });
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The node catalog: the definitions `uip maestro flow registry pull` caches on
3
+ * this machine, as a port the serializer reads (#1981).
4
+ *
5
+ * A `rawNode` that omits its `manifest` is resolved here by `nodeType` +
6
+ * `version`, the way a `connector()` step resolves from the connector library.
7
+ * The serializer never opens the cache itself: the flow core reaches no
8
+ * `node:` builtin (FB015), so the CLI loads it (`node-catalog-files.ts`) and
9
+ * passes it in as `SerializeOpts.nodeCatalog` / `CheckOpts.nodeCatalog`.
10
+ */
11
+ /** Definitions by `nodeType` + `version`, as `registry get` returns them. */
12
+ export interface NodeCatalog {
13
+ /** The manifest for exactly `nodeType@version`, or `undefined` when the catalog has none. */
14
+ definition(nodeType: string, version: string): unknown;
15
+ /** Every version the catalog holds for `nodeType`; empty when it has none. */
16
+ versions(nodeType: string): readonly string[];
17
+ /** Where the catalog was read from, for messages (`~/.uipath/nodes/index.json`). */
18
+ readonly source?: string;
19
+ }
20
+ /** What a `rawNode` with no `manifest` resolves to: the manifest, or why there is none. */
21
+ export type CatalogLookup = {
22
+ manifest: unknown;
23
+ } | {
24
+ missing: {
25
+ message: string;
26
+ suggestion: string;
27
+ };
28
+ };
29
+ /**
30
+ * Look `nodeType@version` up in `catalog`, wording the miss so the author
31
+ * knows the command that fills the cache (`uip maestro flow registry pull`)
32
+ * and the one that shows what the tenant serves (`registry get`).
33
+ *
34
+ * ```ts
35
+ * catalogDefinition(undefined, 'uipath.exotic.thing', '2.1')
36
+ * // → { missing: { message: 'rawNode("uipath.exotic.thing@2.1") has no manifest, and no node registry cache was loaded …', … } }
37
+ * ```
38
+ */
39
+ export declare function catalogDefinition(catalog: NodeCatalog | undefined, nodeType: string, version: string): CatalogLookup;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The node catalog: the definitions `uip maestro flow registry pull` caches on
3
+ * this machine, as a port the serializer reads (#1981).
4
+ *
5
+ * A `rawNode` that omits its `manifest` is resolved here by `nodeType` +
6
+ * `version`, the way a `connector()` step resolves from the connector library.
7
+ * The serializer never opens the cache itself: the flow core reaches no
8
+ * `node:` builtin (FB015), so the CLI loads it (`node-catalog-files.ts`) and
9
+ * passes it in as `SerializeOpts.nodeCatalog` / `CheckOpts.nodeCatalog`.
10
+ */
11
+ /**
12
+ * Look `nodeType@version` up in `catalog`, wording the miss so the author
13
+ * knows the command that fills the cache (`uip maestro flow registry pull`)
14
+ * and the one that shows what the tenant serves (`registry get`).
15
+ *
16
+ * ```ts
17
+ * catalogDefinition(undefined, 'uipath.exotic.thing', '2.1')
18
+ * // → { missing: { message: 'rawNode("uipath.exotic.thing@2.1") has no manifest, and no node registry cache was loaded …', … } }
19
+ * ```
20
+ */
21
+ export function catalogDefinition(catalog, nodeType, version) {
22
+ const manifest = catalog?.definition(nodeType, version);
23
+ if (manifest !== undefined)
24
+ return { manifest };
25
+ const get = `uip maestro flow registry get ${nodeType}`;
26
+ const suggestion = `Run \`uip maestro flow registry pull\` (add --force to refetch a recent cache) and check `
27
+ + `\`${get}\` serves version ${version}; or pass \`manifest:\` with that command's output.`;
28
+ const head = `rawNode("${nodeType}@${version}") has no manifest`;
29
+ if (catalog === undefined) {
30
+ return {
31
+ missing: {
32
+ message: `${head}, and no node registry cache was loaded to resolve it from. `
33
+ + `Compile and check it with the CLI (\`uip maestro flow compile\`/\`check\`), which reads the cache `
34
+ + `\`uip maestro flow registry pull\` writes, or pass \`manifest:\` explicitly.`,
35
+ suggestion,
36
+ },
37
+ };
38
+ }
39
+ const where = catalog.source ?? 'the node registry cache';
40
+ const held = catalog.versions(nodeType);
41
+ const found = held.length === 0
42
+ ? `${where} has no ${nodeType}`
43
+ : `${where} has ${nodeType} only at ${held.map((v) => `@${v}`).join(', ')}`;
44
+ return { missing: { message: `${head}, and ${found}.`, suggestion } };
45
+ }
@@ -19,6 +19,7 @@
19
19
  *
20
20
  * Parity reference: `docs/FLOW_PARITY.md`.
21
21
  */
22
+ import type { NodeCatalog } from './node-catalog.js';
22
23
  /**
23
24
  * A diagnostic a node contributes during `check` — surfaced alongside the
24
25
  * built-in rules with the same severities.
@@ -76,6 +77,14 @@ export interface ContributionContext {
76
77
  * substituting its own default for an explicit request is forbidden.
77
78
  */
78
79
  requestedVersion?: string;
80
+ /**
81
+ * The node definitions `uip maestro flow registry pull` cached on this
82
+ * machine, when the caller loaded them (`uip maestro flow compile` and
83
+ * `check` do). A contributor that carries no manifest of its own, such as
84
+ * a {@link rawNode} without `manifest`, resolves its definition here by
85
+ * `nodeType` + `version`.
86
+ */
87
+ nodeCatalog?: NodeCatalog;
79
88
  }
80
89
  /**
81
90
  * A resource binding a contribution hoists to the flow's top-level `bindings`
@@ -1,24 +1,3 @@
1
- /**
2
- * Definition-backed node base classes — the public extension surface.
3
- *
4
- * The built-in factories (`http()`, `script()`, `scheduled()`, …) cover the
5
- * node families the SDK ships typed helpers for. Everything else the platform
6
- * can validly express — a less-common OOTB node, a tenant-specific registry
7
- * definition — is authorable by subclassing {@link FlowAction} or
8
- * {@link FlowTrigger} and returning a {@link NodeContribution}: an exact
9
- * definition reference plus the semantic inputs. The shared serializer keeps
10
- * ownership of everything structural (instance ids, `typeVersion`, definition
11
- * deduplication, edges, variables), so an extension cannot bypass the file's
12
- * invariants.
13
- *
14
- * {@link rawNode} is the same contract without the subclass: it carries a
15
- * definition and its manifest verbatim for a node type the SDK has no factory
16
- * for. It is not a raw-JSON escape hatch — the serializer still owns every
17
- * structural field, and the manifest must be an exact copy of one the platform
18
- * serves.
19
- *
20
- * Parity reference: `docs/FLOW_PARITY.md`.
21
- */
22
1
  /**
23
2
  * The abstract root of every definition-backed node the builder can place.
24
3
  *
@@ -18,11 +18,14 @@
18
18
  * `flow-step-exits.ts` reads it. `decompile` reads the same handles off the
19
19
  * file's definition, so what it emits recompiles (#1141).
20
20
  */
21
- import type { DeclaredExit } from './step-ports.js';
21
+ import type { NodeCatalog } from './node-catalog.js';
22
+ import type { DeclaredExit, NoExits } from './step-ports.js';
22
23
  /** The method a raw node answers its exits under. */
23
24
  export declare const RAW_NODE_EXITS: unique symbol;
24
25
  /**
25
26
  * `action`'s exits when it is a raw node whose manifest declares more than one
26
- * forward exit; `undefined` otherwise (then it has nothing to route).
27
+ * forward exit; `undefined` otherwise (then it has nothing to route). A raw node
28
+ * with no manifest reads it from `catalog` (#1981), and answers {@link NoExits}
29
+ * when the catalog has none, so `.stepSwitch` names the command that fills it.
27
30
  */
28
- export declare function rawNodeExits(action: unknown): DeclaredExit[] | undefined;
31
+ export declare function rawNodeExits(action: unknown, catalog?: NodeCatalog): DeclaredExit[] | NoExits | undefined;