@uipath/maestro-builder-sdk 6.96.1 → 6.96.2

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.
@@ -29,6 +29,7 @@
29
29
  * re-attached by `flow-merge`; see `docs/FLOW_PARITY.md`).
30
30
  */
31
31
  import { type FlowGlobalDeclaration } from './flow-variables.js';
32
+ import type { Library } from './core/library.js';
32
33
  /** An expression envelope as written by `migrate.ts` (`{type,expression,fieldType}`). */
33
34
  interface WrappedSource {
34
35
  type: string;
@@ -163,6 +164,18 @@ export interface DecompileOptions {
163
164
  * elsewhere, where the loader's `toString()` has not been measured.
164
165
  */
165
166
  scripts?: 'function' | 'string';
167
+ /**
168
+ * The connector library `compile` will resolve the flow's connector steps
169
+ * against. With it, a connector operation the library has no entry for (a
170
+ * connector or operation newer than the snapshot) is carried from the file:
171
+ * its `definitions[]` entry in `.definitions([...])` and its node's method,
172
+ * endpoint and input slots as the step's `carried` option, so the untouched
173
+ * step compiles back (`core/carried-connector-operation.ts`). Without one,
174
+ * nothing is carried, and compile resolves every step against its own library.
175
+ * The CLI opens the one `compile` opens (`--library`, else
176
+ * `$FLOW_SDK_LIBRARY_JSON`, else the pulled cache).
177
+ */
178
+ library?: Library;
166
179
  }
167
180
  /**
168
181
  * Tracks which identifiers the emitted source uses, per module, so each import
package/dist/decompile.js CHANGED
@@ -89,6 +89,14 @@ let runRawManifests = [];
89
89
  * definition and the node keeps its version even when the author edits it.
90
90
  */
91
91
  let runCarried = new Map();
92
+ /**
93
+ * The connector nodes whose operation the source carries, by `<type>@<version>`:
94
+ * the decompile's library has no entry for the type, and `runCarried` holds the
95
+ * file's definition for the pair. See `core/carried-connector-operation.ts`.
96
+ */
97
+ let runCarriedOperations = new Set();
98
+ /** `DecompileOptions.library` for the current run. */
99
+ let runLibrary;
92
100
  /** The file's top-level `bindings[]` rows, by id, for {@link resolveTemplateBindings}. */
93
101
  let runBindings = new Map();
94
102
  let runStrict = false;
@@ -817,6 +825,7 @@ function liftRegistered(node, impl = registeredImpl(node), graph) {
817
825
  sidecar: (path) => runReadSidecar?.(path),
818
826
  flowId: runFlowId,
819
827
  definitionOf: (n) => runDefs.get(`${n.type}@${n.typeVersion}`) ?? runDefs.get(n.type),
828
+ carriesOperation: () => runCarriedOperations.has(`${node.type}@${version}`),
820
829
  attached: (port, limit = Infinity, accept = () => true) => {
821
830
  const found = [];
822
831
  for (const e of graph?.outEdges(node.id) ?? []) {
@@ -1120,7 +1129,10 @@ function carriedPairs(flow) {
1120
1129
  continue;
1121
1130
  const shipped = shippedVersions(n.type);
1122
1131
  const unresolvable = shipped.length > 0 && !shipped.includes(n.typeVersion);
1123
- if (!unresolvable && !isCanvasDraft(n) && !isDraftDecision(n))
1132
+ const operation = carriesOperation(n);
1133
+ if (operation)
1134
+ runCarriedOperations.add(key);
1135
+ if (!unresolvable && !operation && !isCanvasDraft(n) && !isDraftDecision(n))
1124
1136
  continue;
1125
1137
  const base = `${camel(String(n.type).split('.').pop() ?? 'node')}V${String(n.typeVersion).replace(/[^A-Za-z0-9]+/g, '_')}Definition`;
1126
1138
  let name = base;
@@ -1132,6 +1144,14 @@ function carriedPairs(flow) {
1132
1144
  }
1133
1145
  return out;
1134
1146
  }
1147
+ /**
1148
+ * Whether the source carries node `n` from the file because decompile's library
1149
+ * cannot resolve it: its node type says so (`FlowNodeType.carriesFromFile`).
1150
+ * The caller checks that the file holds its definition.
1151
+ */
1152
+ function carriesOperation(n) {
1153
+ return runLibrary !== undefined && registeredImpl(n)?.carriesFromFile?.(n, runLibrary) === true;
1154
+ }
1135
1155
  /**
1136
1156
  * The input names a definition declares: its `inputDefaults` keys and the
1137
1157
  * top-level `inputs.<name>` its form fields edit. For instance quick-form@1.1
@@ -3052,6 +3072,8 @@ export function decompile(flow, options = {}) {
3052
3072
  if (!runDefs.has(d.nodeType))
3053
3073
  runDefs.set(d.nodeType, d);
3054
3074
  }
3075
+ runLibrary = options.library;
3076
+ runCarriedOperations = new Set();
3055
3077
  runCarried = carriedPairs(flow);
3056
3078
  // Best effort: a malformed `bindings` section (not an array) indexes nothing.
3057
3079
  const rows = flow.bindings;
@@ -312,6 +312,15 @@ export interface FlowDeserializeContext {
312
312
  type: string;
313
313
  typeVersion?: string;
314
314
  }): unknown;
315
+ /**
316
+ * Whether decompile carries this connector node's operation: decompile was
317
+ * given a library with no entry for the node's type, and the file holds the
318
+ * node's definition, which the source carries in `.definitions([...])`. The
319
+ * lift then writes the operation's transport and fields as the step's
320
+ * `carried` option (`core/carried-connector-operation.ts`). `false` for any
321
+ * other node.
322
+ */
323
+ carriesOperation(): boolean;
315
324
  /**
316
325
  * The nodes attached to this one on an artifact handle (`tool`, `context`,
317
326
  * `escalation`, `memory`), in edge order, at most `limit` of them. Their edges
@@ -530,6 +539,16 @@ export interface FlowNodeType<Spec> extends NodeType<Spec, FlowNodeContribution,
530
539
  * file's own `definitions[]` entry for the node, if any. Absent: never a draft.
531
540
  */
532
541
  isDraft?(node: unknown, definition: unknown): boolean;
542
+ /**
543
+ * Whether decompile carries a serialized node of this type from the file
544
+ * because `library` (the one decompile was given) cannot resolve it: decompile
545
+ * then copies the node's definition into `.definitions([...])`, and the lift
546
+ * sees `FlowDeserializeContext.carriesOperation()` as `true`. A connector
547
+ * operation answers `true` for a node type the library does not index whose
548
+ * saved `inputs.detail` describes an operation compile can rebuild
549
+ * (`core/carried-connector-operation.ts`). Absent: never.
550
+ */
551
+ carriesFromFile?(node: unknown, library: NonNullable<SerializeOpts['library']>): boolean;
533
552
  /**
534
553
  * The node-level `model` every node of this type carries, whichever path emits
535
554
  * it — this type's `serialize`, or a `rawNode` of its definition. `'omit'`: none
package/dist/merge-cli.js CHANGED
@@ -317,7 +317,8 @@ export async function run(argv) {
317
317
  }
318
318
  // Decompiled as the stamp records, so the baseline is built from the source the
319
319
  // author started from; without a stamp, with decompile's defaults.
320
- const decompileOpts = stamp ? { scripts: stamp.scripts, strict: stamp.strict } : {};
320
+ // The library decompile carried connector operations against: the one compile opens.
321
+ const decompileOpts = { ...(stamp ? { scripts: stamp.scripts, strict: stamp.strict } : {}), ...(library ? { library } : {}) };
321
322
  let baselineCompile;
322
323
  if (derivedFrom) {
323
324
  try {
@@ -2,6 +2,7 @@ import { type CollectedRefusal, type DraftFinding, type SerializeOpts } from './
2
2
  import { type CheckOpts } from './check.js';
3
3
  import { type PlacedDiagnostic } from './edit-scope.js';
4
4
  import type { BuiltFlow } from './flow-sdk.js';
5
+ import type { Library } from './core/library.js';
5
6
  /**
6
7
  * A compile's flow, the draft refusals it reported instead of throwing, the
7
8
  * lowering refusals collect mode reported on the steps it stood in for (or on
@@ -41,6 +42,14 @@ export interface OriginalDecompileOptions {
41
42
  scripts?: 'function' | 'string';
42
43
  /** As `flow decompile --strict`. */
43
44
  strict?: boolean;
45
+ /**
46
+ * The connector library the source will compile against, as `flow decompile`
47
+ * opens it: an operation it lacks is carried from the file
48
+ * (`core/carried-connector-operation.ts`). Not stamped: `flow decompile` and
49
+ * `flow merge` open the same one (`--library`, else `$FLOW_SDK_LIBRARY_JSON`,
50
+ * else the pulled cache).
51
+ */
52
+ library?: Library;
44
53
  }
45
54
  /**
46
55
  * The baseline of `originalPath`: decompile it (reading agent sidecars beside
@@ -60,7 +60,10 @@ export async function baselineFromOriginal(originalPath, opts = {}, warn, decomp
60
60
  // as written: resolving it through the project's bindings.json would make a
61
61
  // label-to-id edit identical to the baseline and merge would drop it.
62
62
  const asSaved = { ...opts, bindings: new Bindings() };
63
- return withDecompiledOriginal(originalPath, (built, source) => ({ ...compileDraftTolerant(built, asSaved), built, source }), warn, decompileOpts);
63
+ // Decompiled against the library the baseline compiles with, so an operation
64
+ // it lacks is carried, as `flow decompile` carried it.
65
+ const withLibrary = { ...(opts.library ? { library: opts.library } : {}), ...decompileOpts };
66
+ return withDecompiledOriginal(originalPath, (built, source) => ({ ...compileDraftTolerant(built, asSaved), built, source }), warn, withLibrary);
64
67
  }
65
68
  /**
66
69
  * The source `flow decompile` makes of the `.flow` at `path` with `opts`, the SDK
@@ -72,6 +75,7 @@ export function decompileOriginal(path, opts = {}, warn) {
72
75
  bestEffort: opts.strict !== true,
73
76
  scripts: opts.scripts ?? 'function',
74
77
  warn,
78
+ ...(opts.library ? { library: opts.library } : {}),
75
79
  });
76
80
  }
77
81
  /**
@@ -1,5 +1,6 @@
1
1
  import { BindingRefusal, bindingMissingMessage, missingBindingLabels } from '../../../core/binding-messages.js';
2
- import { prepareCommand } from '../../../core/cli-spelling.js';
2
+ import { PULL_COMMAND, prepareCommand } from '../../../core/cli-spelling.js';
3
+ import { carriedConnector, carriedDefinitionMismatch, carriedOperationOf, carriedOperationRefusal, } from '../../../core/carried-connector-operation.js';
3
4
  import { buildConfiguration, readConfigurationIdentity } from '../../../core/connector-configuration.js';
4
5
  import { CONNECTOR_INPUT_MISSING, FLOW_EXPR_DIALECT, buildConnectorInputs, replayInputsOf, transportHttpMethod } from '../../../core/connector-inputs.js';
5
6
  import { ConnectorResolveError } from '../../../core/connector-resolve-error.js';
@@ -63,6 +64,50 @@ function listOutputs(rc, nodeId) {
63
64
  return undefined;
64
65
  return { output: { ...subNodeId(jsonClone(out), nodeId), type: 'array' } };
65
66
  }
67
+ /**
68
+ * The operation a step carries for a node type the library has no entry for,
69
+ * or `undefined` when it carries none: the step's `carried` transport and fields
70
+ * with the definition the flow carries for `<nodeType>@<version>` in
71
+ * `.definitions([...])`. Both halves, or nothing: either alone does not describe
72
+ * an operation, and the step stays CONNECTOR_NOT_IN_LIBRARY.
73
+ */
74
+ function carriedResolution(spec, ctx) {
75
+ const version = spec.version ?? ctx.pinnedVersion;
76
+ if (spec.carried === undefined || version === undefined)
77
+ return undefined;
78
+ const nodeType = `${CONNECTOR_PREFIX}${spec.key}.${spec.action}`;
79
+ const definition = ctx.definition(nodeType, version);
80
+ if (!definition || typeof definition !== 'object')
81
+ return undefined;
82
+ const mismatch = carriedDefinitionMismatch(definition, spec.key, spec.carried, `Connector step "${ctx.step}"`);
83
+ if (mismatch)
84
+ throw new CompileRefusal('CARRIED_DEFINITION_INVALID', mismatch);
85
+ return carriedConnector(nodeType, spec.key, version, definition, spec.carried);
86
+ }
87
+ /**
88
+ * The library's answer for the step's operation: the entry, or what
89
+ * `library.resolve` threw. Only the library call is caught here, so a refusal of
90
+ * the step's carried operation ({@link carriedResolution}), which runs after a
91
+ * CONNECTOR_NOT_IN_LIBRARY answer, reaches the author with its own code.
92
+ */
93
+ function libraryResolution(spec, library) {
94
+ try {
95
+ return { rc: library.resolve(spec.key, spec.action, spec.version, spec.object) };
96
+ }
97
+ catch (error) {
98
+ return { error };
99
+ }
100
+ }
101
+ /**
102
+ * What to do about an input a carried operation does not name: the file
103
+ * describes only the inputs its node sets, so another one needs the operation
104
+ * in the library.
105
+ */
106
+ function carriedInputHint(spec) {
107
+ return ' This operation is not in the connector library: the step compiles from the .flow file\'s own description '
108
+ + '(its `carried` option and carried definition), which names only the inputs the saved node sets. To use another input, '
109
+ + `refresh the library (\`${PULL_COMMAND}\`) or prepare the operation (\`${prepareCommand(spec.key, spec.action)}\`).`;
110
+ }
66
111
  function serializeConnector(spec, ctx) {
67
112
  const step = ctx.step;
68
113
  if (!ctx.library) {
@@ -83,11 +128,29 @@ function serializeConnector(spec, ctx) {
83
128
  // The library's refusals (the operation, its fields) name the connector, not
84
129
  // the step: they say which step as `check` always has.
85
130
  const onStep = (refusal) => new CompileRefusal(refusal.code, `Connector step "${step}": ${refusal.message}`, refusal.suggestion);
131
+ const carriedRefusal = carriedOperationRefusal(spec.carried, `Connector step "${step}"`);
132
+ if (carriedRefusal)
133
+ throw new CompileRefusal('CARRIED_DEFINITION_INVALID', carriedRefusal);
134
+ // The library's entry, else, when the library has no entry for the node type,
135
+ // the operation the step carries from the file (carriedResolution). Only on
136
+ // that refusal: an operation the library knows is the library's, whatever the
137
+ // source carries, so a carried copy cannot relax it. A refusal of the carried
138
+ // operation itself (CARRIED_DEFINITION_INVALID) is thrown as it is.
139
+ const resolved = libraryResolution(spec, ctx.library);
140
+ const fallback = 'error' in resolved && resolved.error instanceof ConnectorResolveError
141
+ && resolved.error.code === 'CONNECTOR_NOT_IN_LIBRARY'
142
+ ? carriedResolution(spec, ctx)
143
+ : undefined;
144
+ const carried = fallback !== undefined;
86
145
  let rc;
87
- try {
88
- rc = ctx.library.resolve(spec.key, spec.action, spec.version, spec.object);
146
+ if ('rc' in resolved) {
147
+ rc = resolved.rc;
89
148
  }
90
- catch (error) {
149
+ else if (fallback !== undefined) {
150
+ rc = fallback;
151
+ }
152
+ else {
153
+ const { error } = resolved;
91
154
  if (error instanceof Error && error.message.startsWith('internal SDK error:'))
92
155
  throw error;
93
156
  // A throw `library.resolve` makes on no purpose is still this step's refusal,
@@ -169,7 +232,12 @@ function serializeConnector(spec, ctx) {
169
232
  });
170
233
  }
171
234
  catch (error) {
172
- throw error instanceof CompileRefusal ? onStep(error) : error;
235
+ if (!(error instanceof CompileRefusal))
236
+ throw error;
237
+ const refusal = carried && error.code === 'CONNECTOR_INPUT'
238
+ ? new CompileRefusal(error.code, error.message + carriedInputHint(spec), error.suggestion)
239
+ : error;
240
+ throw onStep(refusal);
173
241
  }
174
242
  })();
175
243
  const replayInputs = replayInputsOf(connectorInputs);
@@ -279,6 +347,9 @@ function liftConnector(node, ctx) {
279
347
  kind: 'connector', ...split, inputs, connection, folder,
280
348
  object: liftedObject(detail),
281
349
  missing,
350
+ // Only for an operation the decompile's library lacks, beside the
351
+ // definition decompile carries for it: the two together describe it.
352
+ carried: ctx.carriesOperation() ? carriedOperationOf(detail) : undefined,
282
353
  };
283
354
  }
284
355
  /**
@@ -328,6 +399,7 @@ function printConnector(l, ctx) {
328
399
  connection: optional(l.connection),
329
400
  folder: optional(l.folder),
330
401
  object: optional(l.object),
402
+ carried: l.carried === undefined ? undefined : ctx.value(l.carried),
331
403
  };
332
404
  return {
333
405
  factory: 'connector',
@@ -353,6 +425,15 @@ const connector10 = {
353
425
  serialize: (spec, ctx) => serializeConnector(spec, ctx),
354
426
  deserialize: (node, ctx) => liftConnector(node, ctx),
355
427
  isDraft: (node, definition) => isConnectorDraft(node, definition),
428
+ // An operation the decompile's library has no entry for is carried from the
429
+ // file, when its saved detail describes one compile can rebuild.
430
+ carriesFromFile: (node, library) => {
431
+ const n = node;
432
+ if (typeof n.type !== 'string' || splitOperation(n.type) === undefined || library.indexes(n.type))
433
+ return false;
434
+ const detail = n.inputs?.detail;
435
+ return !!detail && typeof detail === 'object' && carriedOperationOf(detail) !== undefined;
436
+ },
356
437
  print: (spec, ctx) => printConnector(spec, ctx),
357
438
  check: (spec, ctx) => ctx.connector(spec),
358
439
  // Every Expr in the inputs, nested ones included, resolves against the flow's names.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.96.1",
3
+ "version": "6.96.2",
4
4
  "description": "Build UiPath Flow, Case, and BPMN artifacts by writing TypeScript.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.uipath.com/maestro",
@@ -113,5 +113,5 @@
113
113
  "@types/node": "^22.7.0",
114
114
  "esbuild": "^0.28.1"
115
115
  },
116
- "gitref": "8e43949aa536978e4bba34b4441dda320958a195"
116
+ "gitref": "2bea7fdf0185f37dfc88632250b4b5233480ecb2"
117
117
  }