@uipath/maestro-builder-sdk 6.86.13 → 6.86.15

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.
@@ -3,7 +3,7 @@
3
3
  * decompile-cli — caseplan.json → <Name>.case.ts
4
4
  *
5
5
  * Usage:
6
- * node --experimental-strip-types decompile-cli.js <caseplan.json> [-o Name.case.ts] [--import <specifier>] [--library <dir>] [--best-effort] [--no-pipeline]
6
+ * node --experimental-strip-types decompile-cli.js <caseplan.json> [-o Name.case.ts] [--import <specifier>] [--library <dir>] [--connectors-local <dir>] [--best-effort] [--no-pipeline]
7
7
  *
8
8
  * The reverse of compile-cli: reads a V20-V32 caseplan and emits builder source whose
9
9
  * default export re-serializes to the same caseplan (structurally). `--import`
@@ -14,14 +14,21 @@
14
14
  * mirroring how the Flow arm's decompile-cli overrides it. By default the
15
15
  * command also emits a `<Name>.pipeline.mjs` helper that recompiles edits
16
16
  * through the public Case CLI. Pass `--no-pipeline` to skip it.
17
+ *
18
+ * The library is opened as `case compile` and `case check` open it
19
+ * (`openCliLibrary`): `--library`, and the `connectors-local` overlay `registry
20
+ * prepare` writes (`--connectors-local`, else `.flow-sdk/connectors-local`). A
21
+ * plan whose connector is one only a tenant has (a Data Service entity, a custom
22
+ * connector) is decompiled after `registry prepare` has described it, as it is
23
+ * compiled.
17
24
  */
18
25
  import { reportResult } from '../cli-result.js';
19
- import { mkdirSync, existsSync, readFileSync, writeFileSync } from 'node:fs';
26
+ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
27
+ import { openCliLibrary } from '../core/cli-library.js';
20
28
  import { resolveLibraryDir } from '../core/library-cache.js';
21
29
  import { basename, join, resolve } from 'node:path';
22
- import { defaultSourceOut, workDirBeside, writeSource } from '../workdir.js';
30
+ import { defaultOverlayDir, defaultSourceOut, workDirBeside, writeSource } from '../workdir.js';
23
31
  import { flagValue, runWhenInvokedDirectly } from '../cli-run.js';
24
- import { Library } from '../core/library.js';
25
32
  import { decompileWithDiagnostics } from './decompile.js';
26
33
  import { CASE_IMPORT } from '../package-name.js';
27
34
  import { commentText } from '../core/comment-text.js';
@@ -44,10 +51,10 @@ function baseName(plan) {
44
51
  */
45
52
  export function run(argv) {
46
53
  if (argv.length === 0 || argv[0] === '-h' || argv[0] === '--help') {
47
- console.error('usage: decompile <caseplan.json> [-o Name.case.ts] [--import <specifier>] [--library <dir>] [--best-effort] [--no-pipeline]');
54
+ console.error('usage: decompile <caseplan.json> [-o Name.case.ts] [--import <specifier>] [--library <dir>] [--connectors-local <dir>] [--best-effort] [--no-pipeline]');
48
55
  return 2;
49
56
  }
50
- const flags = new Set(['-o', '--import', '--library']);
57
+ const flags = new Set(['-o', '--import', '--library', '--connectors-local']);
51
58
  const pos = argv.find((a, i) => !flags.has(a) && !flags.has(argv[i - 1]) && !a.startsWith('-'));
52
59
  if (!pos) {
53
60
  console.error('decompile: missing <caseplan.json>');
@@ -55,7 +62,9 @@ export function run(argv) {
55
62
  }
56
63
  const plan = JSON.parse(readFileSync(pos, 'utf8'));
57
64
  const libraryDir = resolveLibraryDir(flagValue(argv, '--library'));
58
- const library = libraryDir && existsSync(`${libraryDir}/index.json`) ? new Library(libraryDir) : undefined;
65
+ // The overlay the library opened, flag or auto-detected, so the helper reads it from any directory.
66
+ const overlayDir = flagValue(argv, '--connectors-local') ?? defaultOverlayDir();
67
+ const library = openCliLibrary(argv);
59
68
  const importSpecifier = flagValue(argv, '--import') ?? CASE_IMPORT;
60
69
  const bestEffort = argv.includes('--best-effort');
61
70
  const result = decompileWithDiagnostics(plan, {
@@ -75,7 +84,7 @@ export function run(argv) {
75
84
  const workDir = workDirBeside(out);
76
85
  mkdirSync(workDir, { recursive: true });
77
86
  const pipelinePath = join(workDir, basename(out).replace(/\.case\.ts$|\.ts$/, '') + '.pipeline.mjs');
78
- writeFileSync(pipelinePath, pipelineScript(resolve(pos), resolve(out), resolve(pipelinePath), importSpecifier, bestEffort, libraryDir ? resolve(libraryDir) : undefined));
87
+ writeFileSync(pipelinePath, pipelineScript(resolve(pos), resolve(out), resolve(pipelinePath), importSpecifier, bestEffort, libraryDir ? resolve(libraryDir) : undefined, overlayDir ? resolve(overlayDir) : undefined));
79
88
  console.log(`decompile: wrote ${basename(pipelinePath)}`);
80
89
  reportResult({ pipeline: resolve(pipelinePath) });
81
90
  }
@@ -87,7 +96,7 @@ export function run(argv) {
87
96
  * feeding the original caseplan back as the binding registry; this preserves
88
97
  * the resource keys that the typed source deliberately names symbolically.
89
98
  */
90
- function pipelineScript(originalPath, tsPath, pipelinePath, importSpecifier, bestEffort, libraryDir) {
99
+ function pipelineScript(originalPath, tsPath, pipelinePath, importSpecifier, bestEffort, libraryDir, overlayDir) {
91
100
  const base = pipelinePath.replace(/\.pipeline\.mjs$/, '');
92
101
  return `#!/usr/bin/env node
93
102
  // Generated by case decompile — edit ${commentText(basename(tsPath))}, then run this file.
@@ -98,9 +107,10 @@ const TS = ${JSON.stringify(tsPath)};
98
107
  const OUTPUT = ${JSON.stringify(base + '.caseplan.json')};
99
108
  const IMPORT = ${JSON.stringify(importSpecifier)};
100
109
  const LIBRARY = ${JSON.stringify(libraryDir)};
110
+ const OVERLAY = ${JSON.stringify(overlayDir)};
101
111
  const BEST_EFFORT = ${JSON.stringify(bestEffort)};
102
112
 
103
- const withLibrary = (args) => LIBRARY ? [...args, '--library', LIBRARY] : args;
113
+ const withLibrary = (args) => [...args, ...(LIBRARY ? ['--library', LIBRARY] : []), ...(OVERLAY ? ['--connectors-local', OVERLAY] : [])];
104
114
 
105
115
  if (!existsSync(TS)) {
106
116
  const decompileArgs = [ORIGINAL, '-o', TS, '--import', IMPORT, '--no-pipeline'];
@@ -22,6 +22,16 @@ export declare function liftResourceName(value: unknown, rows: BindingRows): unk
22
22
  * `solution_folder.<name>` key; the builder spells that folder
23
23
  * `solution_folder` (resource-identity.ts).
24
24
  * - A row with a `default` names that folder.
25
+ * - A row whose `default` is itself a `=bindings.<id>` reference (Studio Web
26
+ * chains the task's folderPath row to a second folderPath row) names what
27
+ * that row names, read by these same rules:
28
+ *
29
+ * { id: 'f2', resourceKey: '=bindings.f1.Billing', default: '=bindings.f1' }
30
+ * { id: 'f1', resourceKey: 'Billing' } -> no folder ('')
31
+ *
32
+ * The reference is never the folder itself: written into the source as
33
+ * `folder: '=bindings.f1'`, compile reads it as a bindings.json label, which
34
+ * the project has none of.
25
35
  * - A row with no `default` (V27 Studio Web) writes its folder only in its key,
26
36
  * `<folder>.<name>`: a key equal to the name has no folder. Any other key
27
37
  * names no folder this can read, and the lift fails.
@@ -29,8 +39,9 @@ export declare function liftResourceName(value: unknown, rows: BindingRows): unk
29
39
  * @param value - The task's `data.folderPath`.
30
40
  * @param name - The literal the task's `data.name` lifted to.
31
41
  * @param rows - The plan's root binding rows.
42
+ * @param seen - The rows already read along a chain (a cycle fails the lift).
32
43
  */
33
- export declare function liftResourceFolder(value: unknown, name: unknown, rows: BindingRows): unknown;
44
+ export declare function liftResourceFolder(value: unknown, name: unknown, rows: BindingRows, seen?: ReadonlySet<string>): unknown;
34
45
  /**
35
46
  * The root rows a task's saved `data.name` / `data.folderPath` read, with any
36
47
  * row they chain to (a folderPath row whose `default` or `resourceKey` is
@@ -51,6 +51,16 @@ export function liftResourceName(value, rows) {
51
51
  * `solution_folder.<name>` key; the builder spells that folder
52
52
  * `solution_folder` (resource-identity.ts).
53
53
  * - A row with a `default` names that folder.
54
+ * - A row whose `default` is itself a `=bindings.<id>` reference (Studio Web
55
+ * chains the task's folderPath row to a second folderPath row) names what
56
+ * that row names, read by these same rules:
57
+ *
58
+ * { id: 'f2', resourceKey: '=bindings.f1.Billing', default: '=bindings.f1' }
59
+ * { id: 'f1', resourceKey: 'Billing' } -> no folder ('')
60
+ *
61
+ * The reference is never the folder itself: written into the source as
62
+ * `folder: '=bindings.f1'`, compile reads it as a bindings.json label, which
63
+ * the project has none of.
54
64
  * - A row with no `default` (V27 Studio Web) writes its folder only in its key,
55
65
  * `<folder>.<name>`: a key equal to the name has no folder. Any other key
56
66
  * names no folder this can read, and the lift fails.
@@ -58,17 +68,22 @@ export function liftResourceName(value, rows) {
58
68
  * @param value - The task's `data.folderPath`.
59
69
  * @param name - The literal the task's `data.name` lifted to.
60
70
  * @param rows - The plan's root binding rows.
71
+ * @param seen - The rows already read along a chain (a cycle fails the lift).
61
72
  */
62
- export function liftResourceFolder(value, name, rows) {
73
+ export function liftResourceFolder(value, name, rows, seen = new Set()) {
63
74
  const id = bindingRefId(value);
64
75
  if (id === undefined)
65
76
  return value;
66
- const row = rows.get(id);
77
+ const row = seen.has(id) ? undefined : rows.get(id);
67
78
  const key = row?.resourceKey;
68
79
  if (typeof key === 'string' && isInSolutionKey(key))
69
80
  return SOLUTION_FOLDER;
70
- if (typeof row?.default === 'string')
71
- return row.default;
81
+ if (typeof row?.default === 'string') {
82
+ if (bindingRefId(row.default) === undefined)
83
+ return row.default;
84
+ const next = liftResourceFolder(row.default, name, rows, new Set([...seen, id]));
85
+ return isLiftFailure(next) ? { field: 'folderPath', value: value, id, row } : next;
86
+ }
72
87
  if (row && typeof key === 'string' && typeof name === 'string' && name) {
73
88
  if (key === name)
74
89
  return '';
@@ -1088,7 +1088,17 @@ export function followRenames(result, preservation) {
1088
1088
  const unpairedCompiled = unmatchedCompiled.filter((stage) => !paired.has(stage));
1089
1089
  if (unpairedWanted.length === unpairedCompiled.length)
1090
1090
  unpairedWanted.forEach((stage, index) => stageLabels.set(stage.label, labelOf(unpairedCompiled[index])));
1091
- const rowNames = (inputs, outputs) => JSON.stringify([inputs, outputs].map((rows) => (Array.isArray(rows) ? rows : []).map((row) => String(row?.name ?? ''))));
1091
+ // A custom (`{ assign }`) output row reads as the name of the variable it
1092
+ // assigns. Compile names the row by the variable's id and the payload
1093
+ // restores the label later; the names come from the payload's variable
1094
+ // identities.
1095
+ const variableNames = new Map();
1096
+ for (const lane of Object.values(preservation.identities?.variables ?? {}))
1097
+ for (const row of lane ?? [])
1098
+ if (typeof row?.id === 'string' && !variableNames.has(row.id))
1099
+ variableNames.set(row.id, row.name);
1100
+ const rowName = (row) => row?.custom === true && typeof row.var === 'string' ? variableNames.get(row.var) ?? row.var : String(row?.name ?? '');
1101
+ const rowNames = (inputs, outputs) => JSON.stringify([inputs, outputs].map((rows) => (Array.isArray(rows) ? rows : []).map(rowName)));
1092
1102
  const nameOf = (task) => String(task.displayName ?? '');
1093
1103
  const stageSides = wanted.map((stage) => {
1094
1104
  const target = compiled.find((candidate) => labelOf(candidate) === (stageLabels.get(stage.label) ?? stage.label));
@@ -57,6 +57,8 @@ export function registerCaseCommands(program) {
57
57
  .option('-o, --output <file>', 'output .case.ts path')
58
58
  .option('--import <specifier>', 'SDK import specifier in generated source')
59
59
  .option('--library <dir>', 'connector library directory')
60
+ // Decompile reads the overlay `registry prepare` writes, as compile and check do.
61
+ .option('--connectors-local <dir>', 'connection-resolved connector overlay')
60
62
  .option('--best-effort', 'emit a marked repair scaffold for unsupported constructs')
61
63
  .option('--no-pipeline', 'do not emit a brownfield pipeline helper')
62
64
  .action(async (input, options) => {
@@ -64,6 +66,7 @@ export function registerCaseCommands(program) {
64
66
  addValue(argv, '-o', options.output);
65
67
  addValue(argv, '--import', options.import);
66
68
  addValue(argv, '--library', options.library);
69
+ addValue(argv, '--connectors-local', options.connectorsLocal);
67
70
  if (options.bestEffort === true)
68
71
  argv.push('--best-effort');
69
72
  if (options.pipeline === false)
@@ -330,6 +330,12 @@ export declare class Library {
330
330
  * Reverse a resolved connector activity back to the symbolic authoring key.
331
331
  * Case decompile uses the same library that compile will use, so it never has
332
332
  * to guess an action name from a display label.
333
+ *
334
+ * The wire's `method` is the TRANSPORT verb compile writes
335
+ * (`transportHttpMethod`): a curated Retrieve the library records as
336
+ * `GETBYID` goes on the wire as `GET`. So an entry matches on its transport
337
+ * verb too, after an exact match: Outlook `download-email-attachment`
338
+ * (`GETBYID /DownloadAttachment`) is saved as `GET /DownloadAttachment`.
333
339
  */
334
340
  identifyAction(wire: {
335
341
  connectorKey: string;
@@ -15,6 +15,7 @@ import { loadByoaLedger, loadInvariantCollections, loadLookupResolutions } from
15
15
  import { ownEntry } from './own-entry.js';
16
16
  import { ConnectorResolveError } from './connector-resolve-error.js';
17
17
  import { CompileRefusal } from './compile-refusal.js';
18
+ import { transportHttpMethod } from './connector-inputs.js';
18
19
  export { ConnectorResolveError } from './connector-resolve-error.js';
19
20
  export class Library {
20
21
  layers = [];
@@ -265,30 +266,43 @@ export class Library {
265
266
  * Reverse a resolved connector activity back to the symbolic authoring key.
266
267
  * Case decompile uses the same library that compile will use, so it never has
267
268
  * to guess an action name from a display label.
269
+ *
270
+ * The wire's `method` is the TRANSPORT verb compile writes
271
+ * (`transportHttpMethod`): a curated Retrieve the library records as
272
+ * `GETBYID` goes on the wire as `GET`. So an entry matches on its transport
273
+ * verb too, after an exact match: Outlook `download-email-attachment`
274
+ * (`GETBYID /DownloadAttachment`) is saved as `GET /DownloadAttachment`.
268
275
  */
269
276
  identifyAction(wire) {
270
277
  const prefix = `uipath.connector.${wire.connectorKey}.`;
271
- for (const layer of this.layers) {
272
- for (const indexed of layer.entries) {
273
- if (indexed.connectorKey !== wire.connectorKey || !String(indexed.nodeType ?? '').startsWith(prefix))
274
- continue;
275
- if (wire.version && indexed.version !== wire.version)
276
- continue;
277
- const entry = readJson(this.read, libraryPath(layer.dir, indexed.path));
278
- const operation = entry.operation ?? {};
279
- if (wire.httpMethod && String(operation.httpMethod ?? '').toUpperCase() !== wire.httpMethod.toUpperCase())
280
- continue;
281
- if (wire.endpoint && operation.path !== wire.endpoint)
282
- continue;
283
- if (wire.objectName && operation.objectName !== wire.objectName)
284
- continue;
285
- const siblings = layer.entries.filter((candidate) => candidate.nodeType === indexed.nodeType);
286
- return {
287
- key: wire.connectorKey,
288
- action: String(indexed.nodeType).slice(prefix.length),
289
- version: String(indexed.version),
290
- ...(siblings.length > 1 && operation.objectName ? { object: String(operation.objectName) } : {}),
291
- };
278
+ const verb = (method, transport) => {
279
+ const upper = String(method ?? '').toUpperCase();
280
+ return transport ? transportHttpMethod(upper) : upper;
281
+ };
282
+ // Exact verbs first, so an entry the wire names exactly wins over a transport twin.
283
+ for (const transport of [false, true]) {
284
+ for (const layer of this.layers) {
285
+ for (const indexed of layer.entries) {
286
+ if (indexed.connectorKey !== wire.connectorKey || !String(indexed.nodeType ?? '').startsWith(prefix))
287
+ continue;
288
+ if (wire.version && indexed.version !== wire.version)
289
+ continue;
290
+ const entry = readJson(this.read, libraryPath(layer.dir, indexed.path));
291
+ const operation = entry.operation ?? {};
292
+ if (wire.httpMethod && verb(operation.httpMethod, transport) !== verb(wire.httpMethod, transport))
293
+ continue;
294
+ if (wire.endpoint && operation.path !== wire.endpoint)
295
+ continue;
296
+ if (wire.objectName && operation.objectName !== wire.objectName)
297
+ continue;
298
+ const siblings = layer.entries.filter((candidate) => candidate.nodeType === indexed.nodeType);
299
+ return {
300
+ key: wire.connectorKey,
301
+ action: String(indexed.nodeType).slice(prefix.length),
302
+ version: String(indexed.version),
303
+ ...(siblings.length > 1 && operation.objectName ? { object: String(operation.objectName) } : {}),
304
+ };
305
+ }
292
306
  }
293
307
  }
294
308
  throw new CompileRefusal('CONNECTOR_NOT_IN_LIBRARY', `connector activity not found in library: ${wire.connectorKey} ${wire.httpMethod ?? '?'} ${wire.endpoint ?? '?'}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.86.13",
3
+ "version": "6.86.15",
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",
@@ -103,5 +103,5 @@
103
103
  "@types/node": "^22.7.0",
104
104
  "esbuild": "^0.28.1"
105
105
  },
106
- "gitref": "a9f27ba26a5984b9391ae2025df3e6c4b5a93c3c"
106
+ "gitref": "1ea0d5d6d20c0aebdd6817378709f6b05d65432a"
107
107
  }