@uipath/maestro-builder-sdk 6.98.0 → 6.100.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);
@@ -971,6 +973,23 @@ function checkFlow(built, ancestors, opts = {}) {
971
973
  });
972
974
  continue;
973
975
  }
976
+ // `$vars.start.output.<x>` inside a subflow, for an `x` the subflow does
977
+ // not declare as an input (#1969). A subflow body is its own scope: its
978
+ // `start` is the child's OWN Start node (serialize renames it to
979
+ // `<caller>Start`), and that node publishes exactly the child's declared
980
+ // inputs. So the read names nothing at run time, typically a parent input
981
+ // the author expected to be visible: `input('n')` or `$vars.start.output.n`
982
+ // written in the child as if it were the caller. A step of the caller is
983
+ // UNKNOWN_REF above; this is the one parent-scope read that `start` being
984
+ // declared in every scope let through.
985
+ if (ancestors.length > 0 && (name === 'start' || name === built.triggerId) && field === 'output'
986
+ && code.startsWith('$vars', m.index ?? 0)) {
987
+ const key = rest.split('.')[1];
988
+ if (key !== undefined && key !== '' && !inputNames.has(key)) {
989
+ diags.push(subflowParentScopeRead(built, ancestors, name, key, step));
990
+ continue;
991
+ }
992
+ }
974
993
  // `$vars.<input>` — a flow INPUT read by its bare name.
975
994
  //
976
995
  // Inputs, outputs and vars share one namespace in `variables.globals[]`,
@@ -1216,6 +1235,8 @@ function checkFlow(built, ancestors, opts = {}) {
1216
1235
  }
1217
1236
  // The End compile appends when the root path runs out of steps (#941).
1218
1237
  diags.push(...checkFallOffEnd(built));
1238
+ // The End an explicit `.return()` writes (#1966).
1239
+ diags.push(...checkReturnOutputs(built));
1219
1240
  // Check every child flow with the same rules, in its OWN scope — a child's
1220
1241
  // steps never see the parent's variables, so its undeclared references,
1221
1242
  // duplicate step names and type mismatches are its own. Diagnostics come back
@@ -1366,6 +1387,80 @@ function checkFallOffEnd(built) {
1366
1387
  }
1367
1388
  return diags;
1368
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
+ }
1369
1464
  /**
1370
1465
  * `armTails`, step for step, carrying what each path has surely written. A
1371
1466
  * `.return()` value is NOT a write here: it lives on that `.return()`'s End,
@@ -1546,6 +1641,40 @@ function checkSubflow(step, child, inputs, parent, ancestors, diags) {
1546
1641
  }
1547
1642
  }
1548
1643
  }
1644
+ /**
1645
+ * SUBFLOW_PARENT_SCOPE_READ: a subflow body reads `$vars.<start>.output.<key>`
1646
+ * for a `key` that is not one of its own inputs (#1969). The child's Start
1647
+ * publishes only the child's inputs, so the read is empty on every run. When
1648
+ * `key` is an input of a calling flow, the message says so; the fix is the
1649
+ * same either way: declare it on the child and pass it in.
1650
+ *
1651
+ * ```ts
1652
+ * const child = flow('C').output({ r: types.number })
1653
+ * .step('s', script({ code: 'return $vars.start.output.n + 1;' })) // n is the PARENT's input
1654
+ * .return({ r: out('s') });
1655
+ * // fix: flow('C').input({ n: types.number })… and subflow(child, { n: input('n') })
1656
+ * ```
1657
+ */
1658
+ function subflowParentScopeRead(child, ancestors, root, key, step) {
1659
+ // The nearest calling flow that declares `key`, on its trigger or an entry point.
1660
+ const owner = [...ancestors].reverse().map((f) => ({
1661
+ f, input: [...f.inputs, ...(f.entryPoints ?? []).flatMap((ep) => ep.inputs)].find((i) => i.name === key),
1662
+ })).find((x) => x.input !== undefined);
1663
+ const type = owner?.input ? String(owner.input.type) : undefined;
1664
+ const whose = owner
1665
+ ? `"${key}" is an input of the calling flow "${owner.f.id}", not of this subflow`
1666
+ : `the subflow "${child.id}" declares no input "${key}"`;
1667
+ return {
1668
+ level: 'error',
1669
+ code: 'SUBFLOW_PARENT_SCOPE_READ',
1670
+ message: `"$vars.${root}.output.${key}" in "${step}" reads the subflow's own start, and ${whose}. A subflow `
1671
+ + `sees only the inputs it declares, so this read is empty at run time. Declare `
1672
+ + `.input({ ${key}: types.${type ?? '…'} }) on "${child.id}" and pass it from the subflow step: `
1673
+ + `subflow(…, { ${key}: input('${key}') }).`,
1674
+ step,
1675
+ suggestion: `{ ${key}: input('${key}') }`,
1676
+ };
1677
+ }
1549
1678
  /**
1550
1679
  * Diagnose a read of a subflow's output: `$vars.<step>.output.<childOutput>`.
1551
1680
  *
@@ -2497,7 +2626,10 @@ placed, opts) {
2497
2626
  let def;
2498
2627
  try {
2499
2628
  const requestedVersion = step.options?.version;
2500
- 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}"`);
2501
2633
  }
2502
2634
  catch {
2503
2635
  // A contribution compile cannot lower is the serializer's CONTRIBUTION_INVALID.
@@ -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;
@@ -2,9 +2,11 @@
2
2
  export const RAW_NODE_EXITS = Symbol('rawNodeExits');
3
3
  /**
4
4
  * `action`'s exits when it is a raw node whose manifest declares more than one
5
- * forward exit; `undefined` otherwise (then it has nothing to route).
5
+ * forward exit; `undefined` otherwise (then it has nothing to route). A raw node
6
+ * with no manifest reads it from `catalog` (#1981), and answers {@link NoExits}
7
+ * when the catalog has none, so `.stepSwitch` names the command that fills it.
6
8
  */
7
- export function rawNodeExits(action) {
9
+ export function rawNodeExits(action, catalog) {
8
10
  const own = action?.[RAW_NODE_EXITS];
9
- return typeof own === 'function' ? own.call(action) : undefined;
11
+ return typeof own === 'function' ? own.call(action, catalog) : undefined;
10
12
  }
@@ -626,6 +626,7 @@ export declare const REFUSALS: {
626
626
  readonly QUEUE_READ_WITHOUT_RETURNS: "lint";
627
627
  readonly QUEUE_RETURNS_WITHOUT_WAIT: "lowering";
628
628
  readonly RAW_NODE_CONNECTOR: "lowering";
629
+ readonly RAW_NODE_MANIFEST_NOT_CACHED: "lowering";
629
630
  readonly RAW_NODE_TYPED_FAMILY: "lint";
630
631
  readonly RAW_NODE_UNKNOWN_INPUT: "lowering";
631
632
  readonly RAW_NODE_VERSION_MISMATCH: "lowering";
@@ -650,6 +651,7 @@ export declare const REFUSALS: {
650
651
  readonly RETRY_BASE_WITHOUT_EXPONENTIAL: "lint";
651
652
  readonly RETRY_INVALID_COUNT: "lint";
652
653
  readonly RETRY_INVALID_DURATION: "lint";
654
+ readonly RETURN_OUTPUT_MISSING: "lint";
653
655
  readonly RETURN_UPDATES_SAME_VAR: "lowering";
654
656
  readonly RPA_KEY_NOT_KEY: "lint";
655
657
  readonly RPA_LOCAL_HAS_FOLDER: "lowering";
@@ -728,6 +730,7 @@ export declare const REFUSALS: {
728
730
  readonly SUBFLOW_NO_CHILD: "lint";
729
731
  readonly SUBFLOW_OUTPUT_NEVER_RETURNED: "lint";
730
732
  readonly SUBFLOW_OUTPUT_NO_FIELD: "lint";
733
+ readonly SUBFLOW_PARENT_SCOPE_READ: "lint";
731
734
  readonly SUBFLOW_UNKNOWN_INPUT: "lint";
732
735
  readonly SUBFLOW_UNKNOWN_OUTPUT: "lint";
733
736
  readonly SUPERFLUOUS_GATEWAY: "lint";
@@ -700,6 +700,7 @@ export const REFUSALS = {
700
700
  QUEUE_READ_WITHOUT_RETURNS: 'lint',
701
701
  QUEUE_RETURNS_WITHOUT_WAIT: 'lowering',
702
702
  RAW_NODE_CONNECTOR: 'lowering',
703
+ RAW_NODE_MANIFEST_NOT_CACHED: 'lowering',
703
704
  RAW_NODE_TYPED_FAMILY: 'lint',
704
705
  RAW_NODE_UNKNOWN_INPUT: 'lowering',
705
706
  RAW_NODE_VERSION_MISMATCH: 'lowering',
@@ -724,6 +725,7 @@ export const REFUSALS = {
724
725
  RETRY_BASE_WITHOUT_EXPONENTIAL: 'lint',
725
726
  RETRY_INVALID_COUNT: 'lint',
726
727
  RETRY_INVALID_DURATION: 'lint',
728
+ RETURN_OUTPUT_MISSING: 'lint',
727
729
  RETURN_UPDATES_SAME_VAR: 'lowering',
728
730
  RPA_KEY_NOT_KEY: 'lint',
729
731
  RPA_LOCAL_HAS_FOLDER: 'lowering',
@@ -802,6 +804,7 @@ export const REFUSALS = {
802
804
  SUBFLOW_NO_CHILD: 'lint',
803
805
  SUBFLOW_OUTPUT_NEVER_RETURNED: 'lint',
804
806
  SUBFLOW_OUTPUT_NO_FIELD: 'lint',
807
+ SUBFLOW_PARENT_SCOPE_READ: 'lint',
805
808
  SUBFLOW_UNKNOWN_INPUT: 'lint',
806
809
  SUBFLOW_UNKNOWN_OUTPUT: 'lint',
807
810
  SUPERFLUOUS_GATEWAY: 'lint',
package/dist/decompile.js CHANGED
@@ -1985,7 +1985,6 @@ function armCb(param, segs) {
1985
1985
  */
1986
1986
  function returnSeg(node, ctx) {
1987
1987
  const updates = ctx.flow.variables?.variableUpdates?.[node.id] ?? [];
1988
- const outputIds = new Set(readFlowGlobals(ctx.flow.variables).filter((g) => g.direction === 'out').map((g) => g.id));
1989
1988
  const opts = returnOptsArg(node, ctx.refTargets?.has(node.id) ?? false);
1990
1989
  const entries = updates.map((u) => `${key(u.variableId)}: ${emitVal(u.expression, ctx.imp, ctx.inputNames)}`);
1991
1990
  const written = new Set(updates.map((u) => u.variableId));
@@ -1994,7 +1993,7 @@ function returnSeg(node, ctx) {
1994
1993
  continue;
1995
1994
  const source = out?.source;
1996
1995
  const raw = unwrapSource(source);
1997
- if (raw === undefined || isIdentityEndSource(raw, name, outputIds.has(name)))
1996
+ if (raw === undefined || isIdentityEndSource(raw, name))
1998
1997
  continue;
1999
1998
  entries.push(`${key(name)}: ${emitVal(source, ctx.imp, ctx.inputNames)}`);
2000
1999
  }
@@ -2005,12 +2004,19 @@ function returnSeg(node, ctx) {
2005
2004
  /**
2006
2005
  * The fill-in mapping `endOutputs` writes for a variable no `.return` named:
2007
2006
  * `=js:$vars.<name>`, read through the backing Variable `foldOutputBacking`
2008
- * has already folded back. An output with no backing Variable fills in as
2009
- * `null` (#1092), since nothing but `.return()` sets it.
2010
- */
2011
- function isIdentityEndSource(raw, name, isOutput = false) {
2007
+ * has already folded back.
2008
+ *
2009
+ * An output mapped to `null` is NOT folded, though compile writes that for an
2010
+ * unbacked output a `.return()` leaves out (#1092). A designer End that says
2011
+ * `report_location <- null` returns null on purpose, and source that drops it
2012
+ * reads as a `.return()` that forgot the output, which `check` refuses
2013
+ * (RETURN_OUTPUT_MISSING, #1966). So decompile spells it: ``report_location:
2014
+ * js`null` ``. That compiles to the same `=js:null` mapping, so the round trip is
2015
+ * unchanged.
2016
+ */
2017
+ function isIdentityEndSource(raw, name) {
2012
2018
  const body = (raw.startsWith('=js:') ? raw.slice(4) : raw).trim();
2013
- return body === `$vars.${name}` || (isOutput && body === 'null');
2019
+ return body === `$vars.${name}`;
2014
2020
  }
2015
2021
  /**
2016
2022
  * The options argument for a `.return(...)` — `version`, plus the End's `name`
package/dist/emit.js CHANGED
@@ -33,6 +33,7 @@ import { openCliLibrary } from './core/cli-library.js';
33
33
  import { defaultBindingsFile, defaultResourcesFile } from './workdir.js';
34
34
  import { readCliResources } from './registry/prepare/resources.js';
35
35
  import { writeJsonFile } from './core/json-file.js';
36
+ import { readNodeCatalog } from './node-catalog-files.js';
36
37
  /**
37
38
  * Resolve the connector library the way `compile-cli` does (`openCliLibrary`),
38
39
  * with the `connectors-local` overlay `registry prepare` writes: only load it
@@ -54,6 +55,8 @@ export function emitFlow(built, path, opts = {}) {
54
55
  library: opts.library ?? defaultLibrary(opts.libraryDir),
55
56
  bindings: opts.bindings ?? new Bindings(bindFile),
56
57
  resources: opts.resources ?? defaultResources(),
58
+ // Where a `rawNode` without `manifest` finds its definition, as in `compile`.
59
+ nodeCatalog: opts.nodeCatalog ?? readNodeCatalog(),
57
60
  // Same channel `compile` uses; a host that wants them elsewhere passes `warn`.
58
61
  warn: opts.warn ?? ((w) => process.stderr.write(` ⚠ [${w.code}] ${w.message}\n`)),
59
62
  });
@@ -40,6 +40,17 @@ export declare function scopeVariableUse(steps: readonly Step[]): {
40
40
  read: Set<string>;
41
41
  stepNames: Set<string>;
42
42
  };
43
+ /**
44
+ * The outputs of one scope that get a backing Variable, without the collision
45
+ * plan: the names `planOutputBacking` backs whenever it has no problem to
46
+ * report. An output NOT in this set is set only by a `.return()` that names
47
+ * it, and every other End maps it to `null` (`check`'s RETURN_OUTPUT_MISSING).
48
+ *
49
+ * @param built - The scope's flow.
50
+ * @param outputs - Its outputs after the `.output()` + `.var()` merge (`planFlowGlobals`).
51
+ * @param sharedOutputs - The outputs a `{ shared }` input feeds.
52
+ */
53
+ export declare function backedOutputs(built: Pick<BuiltFlow, 'steps' | 'entryPoints'>, outputs: readonly Pick<VarDecl, 'name' | 'default'>[], sharedOutputs?: ReadonlySet<string>): Set<string>;
43
54
  /**
44
55
  * Plan the backing Variables for one scope (the flow, or one subflow body).
45
56
  *
@@ -136,6 +136,28 @@ export function scopeVariableUse(steps) {
136
136
  visit(s);
137
137
  return { written, read, stepNames };
138
138
  }
139
+ /**
140
+ * Whether output `o` gets a backing Variable: the scope sets or reads it
141
+ * outside a `.return()` value (the list in this file's header).
142
+ */
143
+ function needsBacking(o, use, sharedOutputs) {
144
+ const readsIt = use.read.has(o.name) && !use.stepNames.has(o.name);
145
+ return use.written.has(o.name) || readsIt || sharedOutputs.has(o.name) || o.default !== undefined;
146
+ }
147
+ /**
148
+ * The outputs of one scope that get a backing Variable, without the collision
149
+ * plan: the names `planOutputBacking` backs whenever it has no problem to
150
+ * report. An output NOT in this set is set only by a `.return()` that names
151
+ * it, and every other End maps it to `null` (`check`'s RETURN_OUTPUT_MISSING).
152
+ *
153
+ * @param built - The scope's flow.
154
+ * @param outputs - Its outputs after the `.output()` + `.var()` merge (`planFlowGlobals`).
155
+ * @param sharedOutputs - The outputs a `{ shared }` input feeds.
156
+ */
157
+ export function backedOutputs(built, outputs, sharedOutputs = new Set()) {
158
+ const use = scopeVariableUse([...built.steps, ...(built.entryPoints ?? []).flatMap((ep) => ep.steps)]);
159
+ return new Set(outputs.filter((o) => needsBacking(o, use, sharedOutputs)).map((o) => o.name));
160
+ }
139
161
  /**
140
162
  * Plan the backing Variables for one scope (the flow, or one subflow body).
141
163
  *
@@ -169,8 +191,7 @@ export function planOutputBacking(built, outputs, vars, sharedOutputs = new Set(
169
191
  const problems = [];
170
192
  for (const o of outputs) {
171
193
  const readsIt = use.read.has(o.name) && !use.stepNames.has(o.name);
172
- const needs = use.written.has(o.name) || readsIt || sharedOutputs.has(o.name) || o.default !== undefined;
173
- if (!needs)
194
+ if (!needsBacking(o, use, sharedOutputs))
174
195
  continue;
175
196
  const id = outputBackingName(o.name);
176
197
  const holder = taken.get(id);
@@ -38,6 +38,7 @@ export * from './core/connectors.js';
38
38
  export * from './core/lookups.js';
39
39
  export { resource, entity, type ResourceToken, type ResourceRef } from './core/resource-resolution.js';
40
40
  export * from './core/node-classes.js';
41
+ export type { NodeCatalog } from './core/node-catalog.js';
41
42
  export * from './raw-node.js';
42
43
  import { Expr } from './core/expr.js';
43
44
  import type { ErrorEnvelopeField } from './core/expr.js';
@@ -1,4 +1,5 @@
1
1
  import { type DeclaredExit, type ExitRouting, type NoExits } from './core/step-ports.js';
2
+ import type { NodeCatalog } from './core/node-catalog.js';
2
3
  /**
3
4
  * The author-declared exits of a step's spec: a registered type's own `exits`,
4
5
  * at the version the step resolves to (its pin, else the type's choice; an
@@ -9,7 +10,9 @@ import { type DeclaredExit, type ExitRouting, type NoExits } from './core/step-p
9
10
  export declare function stepExits(spec: {
10
11
  kind?: unknown;
11
12
  inputs?: unknown;
12
- } | undefined, pinnedVersion?: string): DeclaredExit[] | NoExits;
13
+ } | undefined, pinnedVersion?: string,
14
+ /** The node registry cache a manifest-less `rawNode` reads its exits from (#1981). */
15
+ nodeCatalog?: NodeCatalog): DeclaredExit[] | NoExits;
13
16
  /**
14
17
  * How a step's author-named exits leave it (`FlowNodeType.routing`), at the
15
18
  * version the step resolves to, as for `stepExits`: what check's flow-level
@@ -16,9 +16,12 @@ import { rawNodeExits } from './core/raw-node-exits.js';
16
16
  * `declaredExits` for a kind not yet registered. `serialize` and `check` ask
17
17
  * here, so they agree on what a port means.
18
18
  */
19
- export function stepExits(spec, pinnedVersion) {
20
- // A `rawNode` declares its exits through the manifest it carries (#1141).
21
- const raw = rawNodeExits(spec);
19
+ export function stepExits(spec, pinnedVersion,
20
+ /** The node registry cache a manifest-less `rawNode` reads its exits from (#1981). */
21
+ nodeCatalog) {
22
+ // A `rawNode` declares its exits through the manifest it carries (#1141), or
23
+ // the one the node registry cache holds for it.
24
+ const raw = rawNodeExits(spec, nodeCatalog);
22
25
  if (raw !== undefined)
23
26
  return raw;
24
27
  const impl = resolvedImpl(spec, pinnedVersion, 'exits');