@uipath/maestro-builder-sdk 6.106.0 → 6.108.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
@@ -15,6 +15,7 @@
15
15
  * `flow merge` and `flow decompile` take it.
16
16
  */
17
17
  import { existsSync, readFileSync } from 'node:fs';
18
+ import { dirname, resolve } from 'node:path';
18
19
  import { diagnosticLine, reportDiagnostics, reportResult } from './cli-result.js';
19
20
  import { defaultBindingsFile, defaultResourcesFile } from './workdir.js';
20
21
  import { readCliResources } from './registry/prepare/resources.js';
@@ -29,6 +30,7 @@ import { ensureTypeScriptRuntime } from './node-runtime.js';
29
30
  import { withDecompiledOriginal } from './merge-compile.js';
30
31
  import { baselineSummary } from './core/baseline-scope.js';
31
32
  import { loadNodePackages } from './node-packages.js';
33
+ import { readSolutionProjects } from './solution-projects-files.js';
32
34
  /** Flags that take a value, so the value is never read as the source argument. */
33
35
  const VALUE_FLAGS = new Set(['--library', '--bindings', '--connectors-local', '--resources', '--baseline', '--package']);
34
36
  /**
@@ -44,7 +46,7 @@ const VALUE_FLAGS = new Set(['--library', '--bindings', '--connectors-local', '-
44
46
  * compile-cli's flags and defaults: the library is the one
45
47
  * `withFetchedDefinitions` opens for compile.
46
48
  */
47
- function checkOpts(argv, library) {
49
+ function checkOpts(argv, library, solution) {
48
50
  // The default bindings.json (workdir.ts), exactly as compile-cli finds it — so the
49
51
  // own-name refusal compile would raise is reported here first.
50
52
  const bindFlag = argv.indexOf('--bindings');
@@ -56,7 +58,7 @@ function checkOpts(argv, library) {
56
58
  // The resource ledger `prepare` writes, the default found as bindings.json is.
57
59
  const resources = readCliResources(argv, defaultResourcesFile());
58
60
  // The node registry cache a manifest-less `rawNode` resolves from (#1981), read on first use.
59
- return { ...flowCheckOpts(library, bindings), ...(resources ? { resources } : {}), nodeCatalog: readNodeCatalog() };
61
+ return { ...flowCheckOpts(library, bindings), ...(resources ? { resources } : {}), nodeCatalog: readNodeCatalog(), ...(solution ? { solution } : {}) };
60
62
  }
61
63
  export async function run(argv) {
62
64
  const arg = argv.find((a, i) => !a.startsWith('--') && !VALUE_FLAGS.has(argv[i - 1])) ?? argv[0];
@@ -74,10 +76,13 @@ export async function run(argv) {
74
76
  const file = resolveFlowFile(arg);
75
77
  ensureTypeScriptRuntime();
76
78
  const built = await loadBuiltFlow(file);
79
+ // The solution the flow sits in, read as compile reads it, so an in-solution
80
+ // step named by `project` is judged against the same sibling (#1978).
81
+ const solution = readSolutionProjects(dirname(resolve(file)));
77
82
  // A connector operation no layer carries is fetched through `uip` and the
78
83
  // check runs again, as `compile` does (docs/CONNECTOR_LIBRARY_OPTIONAL_DESIGN.md).
79
84
  const diags = await withFetchedDefinitions(argv, (library) => {
80
- const opts = checkOpts(argv, library);
85
+ const opts = checkOpts(argv, library, solution);
81
86
  return baselinePath !== undefined ? checkAgainstBaseline(built, baselinePath, original, opts, flagValues(argv, '--package')) : check(built, opts);
82
87
  }, { who: 'check' });
83
88
  reportDiagnostics(diags);
package/dist/check.d.ts CHANGED
@@ -8,6 +8,7 @@
8
8
  * serializer in collect mode (`serializerRefusals`), so each of those rules
9
9
  * lives in the serializer alone.
10
10
  */
11
+ import type { SolutionProjects } from './core/solution-projects.js';
11
12
  import type { ResourceResolutions } from './core/resource-resolution.js';
12
13
  import type { NodeCatalog } from './core/node-catalog.js';
13
14
  import type { Library } from './core/library.js';
@@ -68,6 +69,13 @@ export interface CheckOpts extends ConnectorCheckOpts, EventCheckOpts {
68
69
  * `entity()`, with no row here is `RESOURCE_UNRESOLVED`.
69
70
  */
70
71
  resources?: ResourceResolutions;
72
+ /**
73
+ * The solution the flow is authored in and its sibling projects, read by the
74
+ * CLI (`readSolutionProjects`, #1978). `check` gives it to the serializer
75
+ * pass and to each step's `withSolution`, as `compile` does, so an in-solution
76
+ * step named by `project` is judged as it compiles.
77
+ */
78
+ solution?: SolutionProjects;
71
79
  /** Resolve the measured collection envelope for one connector operation. */
72
80
  listEnvelope?: (connector: string, operation: string, version?: string, object?: string) => ListEnvelopeFields | undefined;
73
81
  /**
package/dist/check.js CHANGED
@@ -54,7 +54,7 @@ export function checkCompiled(built, opts = {}) {
54
54
  });
55
55
  }
56
56
  const serialized = opts.serializer !== false
57
- ? serializerRefusals(built, { library: opts.library, bindings: opts.bindings, resources: opts.resources, nodeCatalog: opts.nodeCatalog }, diags)
57
+ ? serializerRefusals(built, { library: opts.library, bindings: opts.bindings, resources: opts.resources, nodeCatalog: opts.nodeCatalog, ...(opts.solution !== undefined ? { solution: opts.solution } : {}) }, diags)
58
58
  : { diagnostics: [], flow: undefined };
59
59
  diags.push(...serialized.diagnostics);
60
60
  const placed = serialized.flow !== undefined ? placeDiagnostics(diags, serialized.flow) : undefined;
@@ -2404,9 +2404,11 @@ function registeredKind(spec) {
2404
2404
  * cause the gap, so there is no author diagnostic to report.
2405
2405
  */
2406
2406
  function checkRegisteredStep(entry, s, exprs, errorSource, opts, diags, typeOf, triggerId, carried) {
2407
- const spec = s.spec;
2407
+ /** The spec `impl` judges: what the solution says about a sibling it names filled in (#1978), as serialize fills it. */
2408
+ const specFor = (impl) => (impl.withSolution ? impl.withSolution(s.spec, opts.solution) : s.spec);
2408
2409
  /** The step's node-local rules and expressions, as `impl` defines them. */
2409
2410
  const runRules = (impl, version = impl.version, carriedDef) => {
2411
+ const spec = specFor(impl);
2410
2412
  const ctx = {
2411
2413
  step: s.name,
2412
2414
  // At a carried version, the version and definition serialize emits.
@@ -2458,7 +2460,7 @@ function checkRegisteredStep(entry, s, exprs, errorSource, opts, diags, typeOf,
2458
2460
  let carriedDef;
2459
2461
  try {
2460
2462
  // A pin the registry lacks but the flow carries resolves (#1128), as in serialize.
2461
- const resolved = resolveVersionCarried(entry.type, spec, s.options?.version, `step "${s.name}"`, carried);
2463
+ const resolved = resolveVersionCarried(entry.type, s.spec, s.options?.version, `step "${s.name}"`, carried);
2462
2464
  impl = resolved.impl;
2463
2465
  version = resolved.version;
2464
2466
  carriedDef = resolved.carried;
@@ -2472,14 +2474,16 @@ function checkRegisteredStep(entry, s, exprs, errorSource, opts, diags, typeOf,
2472
2474
  // would get unpinned (select(), else the default) — as decompile lifts an
2473
2475
  // unregistered version — so fixing the pin is not followed by a second round.
2474
2476
  // It stays unplaced: the pin is wrong, so no family rule may rely on it.
2475
- const fallback = resolveVersion(entry.type, spec, undefined, `step "${s.name}"`);
2477
+ const fallback = resolveVersion(entry.type, s.spec, undefined, `step "${s.name}"`);
2476
2478
  const fallbackCtx = runRules(fallback);
2479
+ const spec = specFor(fallback);
2477
2480
  return {
2478
2481
  placed: false,
2479
2482
  checked: { entry, impl: fallback, spec, placement: { step: s.name, kind: fallback.kind, spec, version: fallback.version }, ctx: fallbackCtx },
2480
2483
  };
2481
2484
  }
2482
2485
  const ctx = runRules(impl, version, carriedDef);
2486
+ const spec = specFor(impl);
2483
2487
  return {
2484
2488
  placed: true,
2485
2489
  checked: {
@@ -20,6 +20,11 @@
20
20
  * other draft, such as one an agent just wrote (even of an operation the canvas
21
21
  * has a draft of), is refused.
22
22
  *
23
+ * Writing into a Flow project (`project.uiproj` at or above the output) that
24
+ * already holds another `.flow` below it, outside dot-folders, warns
25
+ * `SECOND_FLOW_IN_PROJECT` (project-flows.ts): `uip` or a reader that globs the
26
+ * project can take it for the project's flow.
27
+ *
23
28
  * `--no-check` is a deprecated no-op: it is accepted for one minor version, with
24
29
  * a warning, and then removed.
25
30
  */
@@ -35,6 +40,7 @@ import { Bindings } from './bindings.js';
35
40
  import { flagValue, runWhenInvokedDirectly } from './cli-run.js';
36
41
  import { connectionResources, inlineAgentResources, mergeBindingsV2, projectBindingRows, refreshInlineAgentRows } from './bindings-v2.js';
37
42
  import { readBindingsV2, readInlineAgentFiles } from './bindings-v2-files.js';
43
+ import { readSolutionProjects } from './solution-projects-files.js';
38
44
  import { ensureTypeScriptRuntime } from './node-runtime.js';
39
45
  import { defaultBindingsFile, defaultResourcesFile } from './workdir.js';
40
46
  import { readCliResources } from './registry/prepare/resources.js';
@@ -43,6 +49,7 @@ import { flowSources, projectMainFlow, resourceSourcesOfOtherFlows } from './pro
43
49
  import { fnv1aX4Uuid } from './core/stable-id.js';
44
50
  import { cliSpelling } from './core/cli-spelling.js';
45
51
  import { readNodeCatalog } from './node-catalog-files.js';
52
+ import { secondFlowWarning } from './project-flows.js';
46
53
  /** An agent folder name: a uuid, any case. */
47
54
  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
48
55
  export async function run(argv) {
@@ -81,6 +88,9 @@ export async function run(argv) {
81
88
  // The resource ledger `registry prepare` writes (docs/ENTITY_RESOLUTION_DESIGN.md);
82
89
  // a Data Fabric step naming `{ name, folder }` compiles from its row.
83
90
  const resources = readCliResources(argv, defaultResourcesFile());
91
+ // The solution the flow sits in: an in-solution step named by `project` compiles
92
+ // from its sibling's resource file and entry points (#1978).
93
+ const solution = readSolutionProjects(dirname(resolve(file)));
84
94
  // One list per run; every exit path reports it (reportResult overwrites keys).
85
95
  const diagnostics = [];
86
96
  // The serializer's own observations — a connection or folder value that can
@@ -163,6 +173,7 @@ export async function run(argv) {
163
173
  warnings.length = 0;
164
174
  return serializeWithSidecars(built, {
165
175
  library, bindings, warn: (w) => warnings.push(w), resources, agentSource, nodeCatalog,
176
+ ...(solution !== undefined ? { solution } : {}),
166
177
  carriedDrafts: (d) => warnings.push(draftWarning(d)),
167
178
  });
168
179
  });
@@ -201,6 +212,14 @@ export async function run(argv) {
201
212
  reportDiagnostics(diagnostics);
202
213
  return 1;
203
214
  }
215
+ // A second `.flow` in the Flow project, outside dot-folders (a backup, a
216
+ // baseline/ compile), is one `uip` or a globbing reader can take for the
217
+ // project's (#1996). Said here, where the `.flow` is written; never fatal.
218
+ const second = secondFlowWarning(out);
219
+ if (second !== undefined) {
220
+ console.error(` ${diagnosticLine(second)}`);
221
+ diagnostics.push(second);
222
+ }
204
223
  // Reported before the first write, so a write that throws still carries it.
205
224
  reportDiagnostics(diagnostics);
206
225
  writeJsonFile(out, flowJson);
@@ -281,6 +281,7 @@ export declare const REFUSALS: {
281
281
  readonly DATAFABRIC_UNKNOWN_FIELD: "lint";
282
282
  readonly DEAD_END: "lint";
283
283
  readonly DECLARATION_SHAPE: "lowering";
284
+ readonly DECLARATION_FORMAT_INVALID: "lowering";
284
285
  readonly DECLARATION_TYPE_NOT_FLOW: "lowering";
285
286
  readonly DECLARATION_TYPE_UNKNOWN: "lowering";
286
287
  readonly DECOMPILE_NOT_A_NUMBER: "lowering";
@@ -528,6 +529,11 @@ export declare const REFUSALS: {
528
529
  readonly FLOW_AGENT_TOOL_UNKNOWN_KIND: "lowering";
529
530
  readonly INLINE_AGENT_UNDECLARED_PLACEHOLDER: "lint";
530
531
  readonly INLINE_AGENT_UNREFERENCED_INPUT: "lint";
532
+ readonly IN_SOLUTION_KEY_MISMATCH: "lowering";
533
+ readonly IN_SOLUTION_NO_SOLUTION: "lowering";
534
+ readonly IN_SOLUTION_PROJECT_NOT_FOUND: "lowering";
535
+ readonly IN_SOLUTION_PROJECT_PUBLISHED: "lowering";
536
+ readonly IN_SOLUTION_WRONG_BUILDER: "lowering";
531
537
  readonly INPUT_READ_WITHOUT_TRIGGER: "lint";
532
538
  readonly INTSVC_BINDING_MISMATCH: "lint";
533
539
  readonly INTSVC_BINDING_UNDECLARED: "lint";
@@ -355,6 +355,7 @@ export const REFUSALS = {
355
355
  DATAFABRIC_UNKNOWN_FIELD: 'lint',
356
356
  DEAD_END: 'lint',
357
357
  DECLARATION_SHAPE: 'lowering',
358
+ DECLARATION_FORMAT_INVALID: 'lowering',
358
359
  DECLARATION_TYPE_NOT_FLOW: 'lowering',
359
360
  DECLARATION_TYPE_UNKNOWN: 'lowering',
360
361
  DECOMPILE_NOT_A_NUMBER: 'lowering',
@@ -604,6 +605,11 @@ export const REFUSALS = {
604
605
  FLOW_AGENT_TOOL_UNKNOWN_KIND: 'lowering',
605
606
  INLINE_AGENT_UNDECLARED_PLACEHOLDER: 'lint',
606
607
  INLINE_AGENT_UNREFERENCED_INPUT: 'lint',
608
+ IN_SOLUTION_KEY_MISMATCH: 'lowering',
609
+ IN_SOLUTION_NO_SOLUTION: 'lowering',
610
+ IN_SOLUTION_PROJECT_NOT_FOUND: 'lowering',
611
+ IN_SOLUTION_PROJECT_PUBLISHED: 'lowering',
612
+ IN_SOLUTION_WRONG_BUILDER: 'lowering',
607
613
  INPUT_READ_WITHOUT_TRIGGER: 'lint',
608
614
  INTSVC_BINDING_MISMATCH: 'lint',
609
615
  INTSVC_BINDING_UNDECLARED: 'lint',
@@ -0,0 +1,63 @@
1
+ /**
2
+ * core/solution-projects — the sibling projects of the solution a flow is
3
+ * authored in, as `compile` and `check` read them off disk (#1978).
4
+ *
5
+ * A step that calls a sibling (`rpaWorkflow({ location: 'in-solution', project:
6
+ * 'CalculatePay' })`) needs that sibling's resource key, its project id and its
7
+ * argument contract. All three are files of the solution:
8
+ *
9
+ * - `resources/solution_folder/process/<type>/<Project>.json` holds the
10
+ * resource: `resource.key` (the node type's suffix), `resource.projectKey`
11
+ * (the step's `projectId`) and `resource.type`, the folder it sits in;
12
+ * - the project's `entry-points.json` holds the contract: the first entry
13
+ * point's `type`, and its `input` / `output` schemas.
14
+ *
15
+ * This module is the portable half: the shape the CLI hands in. Reading the
16
+ * files is `solution-projects-files.ts`, next to the CLIs that call it, so the
17
+ * flow core reaches no `node:` builtin (FB015).
18
+ */
19
+ /** One sibling project, as its resource file and entry points describe it. */
20
+ export interface SolutionProject {
21
+ /** The resource's name (`resource.name`), which is the project's name. */
22
+ readonly name: string;
23
+ /**
24
+ * The resource's type (`resource.type`), which is also the folder under
25
+ * `resources/solution_folder/process/` it sits in: `process`, `api`,
26
+ * `function`, `agent`, `flow`, `processOrchestration`, `caseManagement`, …
27
+ */
28
+ readonly resourceType: string;
29
+ /** The resource key (`resource.key`): the suffix of the node type. */
30
+ readonly key: string;
31
+ /** The project id (`resource.projectKey`): the step's `projectId`. */
32
+ readonly projectId: string;
33
+ /** The resource file, relative to the solution folder, for messages. */
34
+ readonly file: string;
35
+ /**
36
+ * The first entry point's `type` in the project's `entry-points.json`, as
37
+ * written (`agent`, `function`, `Api`, `Process`); undefined when the
38
+ * project has no readable entry points.
39
+ */
40
+ readonly entryPointType?: string;
41
+ /**
42
+ * The output fields the first entry point declares, each with its JSON
43
+ * schema `type`; undefined when no contract is on disk (an RPA project
44
+ * that was never built has none, #1042).
45
+ */
46
+ readonly outputs?: Readonly<Record<string, string>>;
47
+ }
48
+ /** The solution a flow is authored in, and its sibling projects. */
49
+ export interface SolutionProjects {
50
+ /** The folder holding the solution's `.uipx`, for messages. */
51
+ readonly dir: string;
52
+ /** Every project with a resource file under `resources/solution_folder/process/`. */
53
+ readonly projects: readonly SolutionProject[];
54
+ }
55
+ /** GUIDs compare case-insensitively: a `.uipx` id and a `projectKey` can differ in case. */
56
+ export declare function sameGuid(a: string, b: string): boolean;
57
+ /**
58
+ * The project named `name`: the exact name, else the only one that matches
59
+ * ignoring case. Undefined when none does, or when several do.
60
+ */
61
+ export declare function solutionProjectByName(solution: SolutionProjects, name: string): SolutionProject | undefined;
62
+ /** The project whose resource key is `key`, if any. */
63
+ export declare function solutionProjectByKey(solution: SolutionProjects, key: string): SolutionProject | undefined;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * core/solution-projects — the sibling projects of the solution a flow is
3
+ * authored in, as `compile` and `check` read them off disk (#1978).
4
+ *
5
+ * A step that calls a sibling (`rpaWorkflow({ location: 'in-solution', project:
6
+ * 'CalculatePay' })`) needs that sibling's resource key, its project id and its
7
+ * argument contract. All three are files of the solution:
8
+ *
9
+ * - `resources/solution_folder/process/<type>/<Project>.json` holds the
10
+ * resource: `resource.key` (the node type's suffix), `resource.projectKey`
11
+ * (the step's `projectId`) and `resource.type`, the folder it sits in;
12
+ * - the project's `entry-points.json` holds the contract: the first entry
13
+ * point's `type`, and its `input` / `output` schemas.
14
+ *
15
+ * This module is the portable half: the shape the CLI hands in. Reading the
16
+ * files is `solution-projects-files.ts`, next to the CLIs that call it, so the
17
+ * flow core reaches no `node:` builtin (FB015).
18
+ */
19
+ /** GUIDs compare case-insensitively: a `.uipx` id and a `projectKey` can differ in case. */
20
+ export function sameGuid(a, b) {
21
+ return a.trim().toLowerCase() === b.trim().toLowerCase();
22
+ }
23
+ /**
24
+ * The project named `name`: the exact name, else the only one that matches
25
+ * ignoring case. Undefined when none does, or when several do.
26
+ */
27
+ export function solutionProjectByName(solution, name) {
28
+ const exact = solution.projects.find((p) => p.name === name);
29
+ if (exact !== undefined)
30
+ return exact;
31
+ const folded = solution.projects.filter((p) => p.name.toLowerCase() === name.toLowerCase());
32
+ return folded.length === 1 ? folded[0] : undefined;
33
+ }
34
+ /** The project whose resource key is `key`, if any. */
35
+ export function solutionProjectByKey(solution, key) {
36
+ return solution.projects.find((p) => sameGuid(p.key, key));
37
+ }
package/dist/decompile.js CHANGED
@@ -40,7 +40,7 @@ import { tsKey as key, tsLiteral, tsNumber, tsObject as objLit, tsOptions as opt
40
40
  import { wireExprBody } from './core/wire-expr.js';
41
41
  import { hasExits } from './core/step-ports.js';
42
42
  import { readFlowGlobals } from './flow-variables.js';
43
- import { FLOW_TYPE_NAMES, nonFlowTypeReplacement, runtimeEquivalentFlowType } from './flow-types.js';
43
+ import { FLOW_TYPE_NAMES, runtimeEquivalentFlowType } from './flow-types.js';
44
44
  import { outputBackingGlobal, outputBackingName } from './flow-output-backing.js';
45
45
  import { mapJsCode } from './core/js-code-spans.js';
46
46
  import { VARS_READ_RE } from './core/vars-read.js';
@@ -1222,61 +1222,106 @@ function camel(id) {
1222
1222
  // ─── Variables ────────────────────────────────────────────────────────────────
1223
1223
  const TYPE_NAMES = new Set(FLOW_TYPE_NAMES);
1224
1224
  /**
1225
- * `types.<name>` for a global's type (#861).
1225
+ * `types.<name>` for a global's type (#861, #1997).
1226
1226
  *
1227
- * A Flow type prints as itself. Every other type warns once per variable (an
1228
- * error when `bestEffort` is false), and then:
1227
+ * A Flow type prints as itself. The Case-only types print as the Flow type
1228
+ * the run already sees, so an untouched global never blocks a brownfield
1229
+ * edit:
1230
+ * - `float` / `double` print as `{ type: types.number, format: 'double' }`
1231
+ * (`VarSpec.format`), which recompiles to the file's own `"type":"double"`.
1232
+ * Nothing changes, so nothing warns. The width matters: `flow pack` writes
1233
+ * it into the entry point's schema as `"format":"double"`.
1229
1234
  * - `date` / `datetime` print as `types.string`, the type Flow packaging
1230
- * already gives them, so an untouched global never blocks a brownfield
1231
- * edit. The recompiled `.flow` says `"type":"string"`; the warning says so.
1232
- * - `float`, `double` and `jsonSchema` print as written (`types.float`),
1233
- * because a recompile would lose a format or a schema kind: the declaration
1234
- * is a TypeScript error and `DECLARATION_TYPE_NOT_FLOW` at build until the
1235
- * author picks the type the warning names.
1236
- * - any other string prints as a string literal: `DECLARATION_TYPE_UNKNOWN`.
1237
- */
1238
- function typeExpr(g, imp) {
1235
+ * already gives them. The recompiled `.flow` says `"type":"string"`.
1236
+ * - `jsonSchema` prints as `types.object` (`types.array` when its schema is
1237
+ * an array's) with the file's schema (its `body`, else `schema`, as `flow pack` reads them) in
1238
+ * `{ schema }`. The recompiled `.flow` says `"type":"object"`.
1239
+ * A type that changes warns once per variable (an error when `bestEffort` is
1240
+ * false), naming what the recompile writes. Any other string prints as a
1241
+ * string literal: `DECLARATION_TYPE_UNKNOWN`.
1242
+ */
1243
+ function printedType(g) {
1239
1244
  if (TYPE_NAMES.has(g.type))
1240
- return `${imp.use('types')}.${g.type}`;
1241
- const replacement = nonFlowTypeReplacement(g.type);
1242
- const equivalent = runtimeEquivalentFlowType(g.type);
1245
+ return { type: g.type };
1246
+ if (g.type === 'float' || g.type === 'double')
1247
+ return { type: 'number', format: g.type };
1243
1248
  const head = `variable ${tsLiteral(g.id)} has type ${tsLiteral(g.type)}`;
1244
- const message = equivalent !== undefined
1245
- ? `${head}, a Case type Flow does not model. The source declares it types.${equivalent}, so a recompile `
1249
+ const equivalent = runtimeEquivalentFlowType(g.type);
1250
+ let printed;
1251
+ let message;
1252
+ if (equivalent !== undefined) {
1253
+ printed = { type: equivalent };
1254
+ message = `${head}, a Case type Flow does not model. The source declares it types.${equivalent}, so a recompile `
1246
1255
  + `writes "type":"${equivalent}" in its place; nothing changes at run time, because flow pack already `
1247
- + `writes a ${g.type} as a plain string.`
1248
- : replacement !== undefined
1249
- ? `${head}, a Case type Flow does not model (packaging and the Workbench do not know it). The source `
1250
- + `keeps types.${g.type}, which the builder refuses (DECLARATION_TYPE_NOT_FLOW): declare it as ${replacement}.`
1251
- : `${head}, which is not a Flow type. The source keeps it as a string, which the builder refuses `
1252
- + `(DECLARATION_TYPE_UNKNOWN): declare one of ${FLOW_TYPE_NAMES.map((t) => `types.${t}`).join(', ')}.`;
1256
+ + `writes a ${g.type} as a plain string.`;
1257
+ }
1258
+ else if (g.type === 'jsonSchema') {
1259
+ const schema = jsonSchemaBody(g);
1260
+ const kind = schema?.type === 'array' ? 'array' : 'object';
1261
+ printed = { type: kind, ...(schema !== undefined ? { schema } : {}) };
1262
+ message = `${head}, a Case type Flow does not model. The source declares it types.${kind}`
1263
+ + `${schema !== undefined ? ' with its schema in { schema }' : ''}, so a recompile writes "type":"${kind}" in its `
1264
+ + `place; nothing changes at run time, because the engine reads both as JSON.`;
1265
+ }
1266
+ else {
1267
+ printed = { type: g.type };
1268
+ message = `${head}, which is not a Flow type. The source keeps it as a string, which the builder refuses `
1269
+ + `(DECLARATION_TYPE_UNKNOWN): declare one of ${FLOW_TYPE_NAMES.map((t) => `types.${t}`).join(', ')}.`;
1270
+ }
1253
1271
  if (runStrict)
1254
1272
  throw new Error(`decompile: ${message}`);
1255
1273
  warnOnce(message);
1256
- if (equivalent !== undefined)
1257
- return `${imp.use('types')}.${equivalent}`;
1258
- return replacement !== undefined ? `${imp.use('types')}.${g.type}` : tsLiteral(g.type);
1274
+ return printed;
1275
+ }
1276
+ /**
1277
+ * A `jsonSchema` global's shape: the `body` Case writes it in (an object, or
1278
+ * that object as JSON text), else its `schema`. `undefined` when it has
1279
+ * neither. `body` first, because `flow pack` packs `body ?? schema`
1280
+ * (flow-workbench `variableToJsonSchema`), so the recompiled entry point packs
1281
+ * the shape the original did.
1282
+ */
1283
+ function jsonSchemaBody(g) {
1284
+ const isObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
1285
+ const fromBody = (body) => {
1286
+ if (isObject(body))
1287
+ return body;
1288
+ if (typeof body !== 'string')
1289
+ return undefined;
1290
+ try {
1291
+ const parsed = JSON.parse(body);
1292
+ return isObject(parsed) ? parsed : undefined;
1293
+ }
1294
+ catch {
1295
+ return undefined;
1296
+ }
1297
+ };
1298
+ return fromBody(g.body) ?? (isObject(g.schema) ? g.schema : undefined);
1259
1299
  }
1260
1300
  /**
1261
1301
  * A global carrying metadata decompiles to the rich VarSpec spelling
1262
- * (`{ type: types.x, description, subType, schema }`); a bare one keeps the
1263
- * compact `name: types.x` form.
1302
+ * (`{ type: types.x, format, description, subType, schema }`); a bare one
1303
+ * keeps the compact `name: types.x` form.
1264
1304
  */
1265
1305
  function declExpr(g, withDefault, imp, shared) {
1306
+ const printed = printedType(g);
1307
+ const type = TYPE_NAMES.has(printed.type) ? `${imp.use('types')}.${printed.type}` : tsLiteral(printed.type);
1308
+ const schema = printed.schema ?? g.schema;
1266
1309
  const meta = [];
1310
+ if (printed.format !== undefined)
1311
+ meta.push(`format: ${tsLiteral(printed.format)}`);
1267
1312
  if (withDefault && g.defaultValue !== undefined)
1268
1313
  meta.push(`default: ${tsLiteral(g.defaultValue)}`);
1269
1314
  if (g.description !== undefined)
1270
1315
  meta.push(`description: ${tsLiteral(g.description)}`);
1271
1316
  if (g.subType !== undefined)
1272
1317
  meta.push(`subType: ${tsLiteral(g.subType)}`);
1273
- if (g.schema !== undefined)
1274
- meta.push(`schema: ${tsLiteral(g.schema)}`);
1318
+ if (schema !== undefined)
1319
+ meta.push(`schema: ${tsLiteral(schema)}`);
1275
1320
  if (shared !== undefined)
1276
1321
  meta.push(`shared: ${tsLiteral(shared)}`);
1277
1322
  if (meta.length === 0)
1278
- return typeExpr(g, imp);
1279
- return `{ type: ${typeExpr(g, imp)}, ${meta.join(', ')} }`;
1323
+ return type;
1324
+ return `{ type: ${type}, ${meta.join(', ')} }`;
1280
1325
  }
1281
1326
  function sharedCopies(flow, triggers) {
1282
1327
  const globals = readFlowGlobals(flow.variables, runStrict);
@@ -9,6 +9,7 @@
9
9
  * owns the node's id, label, `typeVersion`, layout, edges and definition dedupe;
10
10
  * each context below is the whole of what a node type can see.
11
11
  */
12
+ import type { SolutionProjects } from './core/solution-projects.js';
12
13
  import type { ResourceResolutions } from './core/resource-resolution.js';
13
14
  import type { ArtifactContexts, FactoryCall, NodeType, OptionKeyLists } from './core/nodes/node-type.js';
14
15
  import type { VersionedNodeType } from './core/nodes/versioned.js';
@@ -159,6 +160,12 @@ export interface FlowSerializeContext {
159
160
  * (docs/ENTITY_RESOLUTION_DESIGN.md); undefined when the compile was given no ledger.
160
161
  */
161
162
  readonly resources: ResourceResolutions | undefined;
163
+ /**
164
+ * The solution the flow is compiled in, and its sibling projects, as the CLI
165
+ * read them (`SerializeOpts.solution`, #1978); undefined when the compile was
166
+ * given none.
167
+ */
168
+ readonly solution?: SolutionProjects;
162
169
  /**
163
170
  * The bundled definition `<typeName>@<version>`, else one the flow carries;
164
171
  * undefined when neither exists. When the node is emitted at a carried
@@ -673,6 +680,16 @@ export interface FlowNodeType<Spec> extends NodeType<Spec, FlowNodeContribution,
673
680
  typeName: string;
674
681
  version?: string;
675
682
  } | undefined;
683
+ /**
684
+ * The spec with what the solution on disk says filled in, for a type whose
685
+ * step can name a sibling project instead of copying its identifiers (an
686
+ * in-solution process step's `project`, #1978). `check` and `serialize` both
687
+ * call it before anything else reads the spec — the type's `check`,
688
+ * `serialize` and `output` see its result — so the two rungs judge the same
689
+ * spec. `solution` is undefined when the caller gave none. Omitted: the spec
690
+ * is used as authored.
691
+ */
692
+ withSolution?(spec: Spec, solution: SolutionProjects | undefined): Spec;
676
693
  }
677
694
  /** What decompile's graph reads off a saved node's exits (`FlowNodeType.savedExits`). */
678
695
  export interface FlowSavedExits {
@@ -67,6 +67,7 @@ export declare function planOutputBacking(built: Pick<BuiltFlow, 'inputs' | 'ste
67
67
  export declare function outputBackingGlobal(o: {
68
68
  name: string;
69
69
  type: string;
70
+ format?: string;
70
71
  default?: unknown;
71
72
  subType?: string;
72
73
  schema?: Record<string, unknown>;
@@ -221,7 +221,7 @@ export function planOutputBacking(built, outputs, vars, sharedOutputs = new Set(
221
221
  /** The `inout` global that backs output `o`: its type and value metadata, no description. */
222
222
  export function outputBackingGlobal(o, id) {
223
223
  return {
224
- id, name: id, direction: 'inout', type: o.type,
224
+ id, name: id, direction: 'inout', type: o.format ?? o.type,
225
225
  ...(o.default !== undefined ? { defaultValue: o.default } : {}),
226
226
  ...(o.subType !== undefined ? { subType: o.subType } : {}),
227
227
  ...(o.schema !== undefined ? { schema: o.schema } : {}),
@@ -74,9 +74,13 @@ export interface VarDecl {
74
74
  subType?: string;
75
75
  /** JSON schema for complex type validation (object/array shapes). */
76
76
  schema?: Record<string, unknown>;
77
+ /** A `number`'s width, written as the global's `type`. See {@link VarSpec.format}. */
78
+ format?: NumberFormat;
77
79
  /** Inputs only: the flow variable this root's input is copied into when the root fires. See {@link VarSpec.shared}. */
78
80
  shared?: string;
79
81
  }
82
+ /** The widths a `types.number` variable may keep: {@link VarSpec.format}. */
83
+ export type NumberFormat = 'float' | 'double';
80
84
  /**
81
85
  * The rich spelling of a variable declaration: pass it instead of a bare
82
86
  * `types.*` descriptor wherever `.input()` / `.output()` / `.var()` take one,
@@ -93,6 +97,17 @@ export interface VarSpec {
93
97
  subType?: string;
94
98
  /** JSON schema for complex type validation (object/array shapes). */
95
99
  schema?: Record<string, unknown>;
100
+ /**
101
+ * `types.number` only: keep a `float` or `double` width the `.flow` already
102
+ * carries. The global is written `"type":"double"` instead of `"number"`, and
103
+ * `flow pack` puts `{ "type": "number", "format": "double" }` in the entry
104
+ * point's schema. The run is the same either way: the engine reads every
105
+ * number as a double. Decompile prints it for a global a Case-era or Studio
106
+ * Web file typed `float` / `double`, so a recompile writes the file's own type
107
+ * back, e.g. `.input({ rate: { type: types.number, format: 'double' } })`.
108
+ * Any other type, or another value, is `DECLARATION_FORMAT_INVALID`.
109
+ */
110
+ format?: NumberFormat;
96
111
  /**
97
112
  * Default value — the variable's value before anything assigns it. On an
98
113
  * output it is the starting value a `{ updates }` accumulator reads, e.g.
package/dist/flow-sdk.js CHANGED
@@ -91,6 +91,10 @@ function varDeclOf(method, name, value) {
91
91
  if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
92
92
  const spec = value;
93
93
  assertType(method, name, spec.type);
94
+ if (spec.format !== undefined && (spec.type !== 'number' || !NUMBER_FORMATS.includes(spec.format))) {
95
+ throw new CompileRefusal('DECLARATION_FORMAT_INVALID', `.${method}() declared ${JSON.stringify(name)} with format ${JSON.stringify(spec.format)} on types.${String(spec.type)}. `
96
+ + `A format keeps a number's width: use { type: types.number, format: 'float' } or 'double', or drop it.`);
97
+ }
94
98
  if (spec.shared !== undefined) {
95
99
  if (method !== 'input') {
96
100
  throw new CompileRefusal('SHARED_INPUT_NOT_INPUT', `.${method}() declared ${JSON.stringify(name)} with { shared }, which only an input takes: it names `
@@ -108,6 +112,7 @@ function varDeclOf(method, name, value) {
108
112
  ...(spec.description !== undefined ? { description: spec.description } : {}),
109
113
  ...(spec.subType !== undefined ? { subType: spec.subType } : {}),
110
114
  ...(spec.schema !== undefined ? { schema: spec.schema } : {}),
115
+ ...(spec.format !== undefined ? { format: spec.format } : {}),
111
116
  ...(spec.shared !== undefined ? { shared: spec.shared } : {}),
112
117
  };
113
118
  }
@@ -135,6 +140,7 @@ function assertType(method, name, type) {
135
140
  throw new CompileRefusal('DECLARATION_TYPE_UNKNOWN', `.${method}() declared ${JSON.stringify(name)} with type ${JSON.stringify(type)}, which is not `
136
141
  + `a type. Use one of ${flowTypes}.`);
137
142
  }
143
+ const NUMBER_FORMATS = ['float', 'double'];
138
144
  export function onEvent(a, opts) {
139
145
  return builtinTriggerSpec({ kind: 'event', subscription: subscriptionFrom(a, opts) });
140
146
  }
@@ -22,7 +22,10 @@ import type { TypeDesc } from './core/expr.js';
22
22
  *
23
23
  * The others are Case-only. Packaging turns `date` / `datetime` into a plain
24
24
  * `string` with no format, the expression model types `float` / `double` /
25
- * `jsonSchema` as `any`, and no Flow editor offers any of them.
25
+ * `jsonSchema` as `any`, and no Flow editor offers any of them. One thing is
26
+ * kept: packaging writes a `float` / `double` global as `"type":"number"` with
27
+ * `"format":"float"` / `"double"` in the entry point's schema, so a Flow
28
+ * number may carry that width as `{ type: types.number, format }`.
26
29
  *
27
30
  * `satisfies Record<TypeDesc, …>` makes this exhaustive: adding a type to
28
31
  * `types` without deciding whether Flow takes it is a compile error here.
@@ -36,8 +39,8 @@ declare const flowTypeSupport: {
36
39
  readonly file: true;
37
40
  readonly any: true;
38
41
  readonly integer: true;
39
- readonly float: "types.number";
40
- readonly double: "types.number";
42
+ readonly float: "{ type: types.number, format: 'float' }";
43
+ readonly double: "{ type: types.number, format: 'double' }";
41
44
  readonly date: "types.string";
42
45
  readonly datetime: "types.string";
43
46
  readonly jsonSchema: "types.object or types.array, with its shape in { schema }";
@@ -65,8 +68,10 @@ export declare function nonFlowTypeReplacement(type: string): string | undefined
65
68
  * older SDK or Studio Web wrote still round-trips; the recompile writes
66
69
  * `"type":"string"`, which the decompile warning announces.
67
70
  *
68
- * `undefined` for every other type: `float` / `double` lose a format and
69
- * `jsonSchema` a schema kind, so those keep the builder's hard stop.
71
+ * `undefined` for every other type. Decompile prints `float` / `double` as
72
+ * `{ type: types.number, format }` (`VarSpec.format`), which writes the same
73
+ * type back, and `jsonSchema` as `types.object` / `types.array` with the
74
+ * shape in `{ schema }`.
70
75
  */
71
76
  export declare function runtimeEquivalentFlowType(type: string): FlowTypeDesc | undefined;
72
77
  export {};