@uipath/maestro-builder-sdk 6.121.1 → 6.122.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.
@@ -0,0 +1,56 @@
1
+ /**
2
+ * core/resource-picker — a connector field that Studio Web's V2 panel fills with a
3
+ * solution-resource picker, as the panel saves it (#849).
4
+ *
5
+ * A picker field (`design.component: "Resources"`, `solutionResourceKind` in the
6
+ * operation's `describe`) holds a resource the solution references. The first kind is
7
+ * a folder-scoped Data Fabric entity, on the connector's `_V3` operations'
8
+ * `folderEntityName`. The panel saves four things for one:
9
+ *
10
+ * - the field and its hidden `<field>_folderKey` companion, as `=bindings.<id>`
11
+ * references to the two bindings below;
12
+ * - two root bindings, `resource="entity"`, keyed by the entity's resource key:
13
+ * `Entity` (`propertyAttribute="name"`, default the name) and `Entity folder`
14
+ * (`folderKey`, default the folder key);
15
+ * - `essentialConfiguration.savedResourceSelections: { <field>: <resource key> }`;
16
+ * - a `bindings` entry in the node's `metadata`, which names the field paths, so
17
+ * `bpmn refresh` writes the entity into `bindings_v2.json` with `Scope: Folder`.
18
+ *
19
+ * Measured with `uip maestro bpmn registry get Intsvc.ActivityExecution --object-name
20
+ * CreateEntityRecord_V3 --input-details … --solution-folder …` (uip 1.207, alpha,
21
+ * 2026-11-13), the design-time client Studio Web runs; the captures are in
22
+ * `tests/fixtures/bpmn/dataservice-folder-v2/`. The panel's `activityIdRef` is a
23
+ * fresh uuid on every save; here it is derived from the element id, so a recompile is
24
+ * byte-identical.
25
+ */
26
+ import { stableId } from './stable-id.js';
27
+ /** The binding `resource` an entity picker writes, lower case as the V2 panel writes it. */
28
+ export const PICKER_ENTITY_RESOURCE = 'entity';
29
+ /** The hidden parameter that carries a picker's folder: `folderEntityName` → `folderEntityName_folderKey`. */
30
+ export function pickerFolderField(field) {
31
+ return `${field}_folderKey`;
32
+ }
33
+ /** `essentialConfiguration.savedResourceSelections`: each picker field's resource key. */
34
+ export function savedResourceSelections(selections) {
35
+ return Object.fromEntries(selections.map((s) => [s.field, s.resourceKey]));
36
+ }
37
+ /** The `metadata.bindings` entries of a node's pickers, one per field. */
38
+ export function pickerMetadataBindings(selections) {
39
+ return selections.map((s) => ({
40
+ resource: PICKER_ENTITY_RESOURCE,
41
+ key: s.resourceKey,
42
+ activityIdRef: stableId(`${s.elementId}:picker:${s.field}`),
43
+ activityDisplayName: 'connector-activity',
44
+ value: {
45
+ name: { defaultValue: s.name, isExpression: false, displayName: 'Entity' },
46
+ folderKey: { defaultValue: s.folderKey, isExpression: false },
47
+ },
48
+ metadata: {
49
+ ActivityName: 'connector-activity',
50
+ BindingsVersion: '2.2',
51
+ NameFieldPath: `${s.bucket}.${s.field}`,
52
+ Scope: 'Folder',
53
+ FolderFieldPath: `${s.bucket}.${pickerFolderField(s.field)}`,
54
+ },
55
+ }));
56
+ }
@@ -3,10 +3,12 @@ import type { EntityFieldSchema } from './entity-schema.js';
3
3
  export declare const ENTITY_KIND = "Entity";
4
4
  /**
5
5
  * A solution resource by kind and name, and — for one in an Orchestrator
6
- * folder — that folder's PATH (`Shared`, `Finance/Prod`), never its key.
6
+ * folder — that folder's PATH (`Shared`, `Finance/Prod`) or, for a source that
7
+ * already holds it, the folder's KEY.
7
8
  *
8
- * `folder` is optional: without it `prepare` searches every folder and records
9
- * the resource when exactly one matches. Writing it pins the answer.
9
+ * Both are optional, and at most one is given: without either `prepare`
10
+ * searches every folder and records the resource when exactly one matches.
11
+ * Writing one pins the answer.
10
12
  */
11
13
  export interface ResourceRef {
12
14
  /** The catalogue kind, e.g. `'Entity'`, `'Asset'`, `'Queue'` (case-insensitive: `asset` is `Asset`). */
@@ -15,6 +17,13 @@ export interface ResourceRef {
15
17
  name: string;
16
18
  /** The Orchestrator folder path the resource lives in, e.g. `'Shared'` or `'Finance/Prod'`. */
17
19
  folder?: string;
20
+ /**
21
+ * The key of the Orchestrator folder the resource lives in (a GUID), for a
22
+ * source that names the folder by key: BPMN's `.dataService({ entity: { name,
23
+ * folderKey } })`. A name is unique within a folder, so the pair names one
24
+ * resource, and `prepare --folder-key` records its key.
25
+ */
26
+ folderKey?: string;
18
27
  }
19
28
  /**
20
29
  * A Data Fabric entity by name and folder path: a {@link ResourceRef} of kind
@@ -118,6 +127,7 @@ export declare function canonicalKind(kind: string): string;
118
127
  * resourceLedgerKey({ kind: 'Entity', name: 'Orders', folder: 'Finance/Prod' }) // '["Entity","Orders","Finance/Prod"]'
119
128
  * resourceLedgerKey({ kind: 'asset', name: 'ApiKey' }) // '["Asset","ApiKey",null]'
120
129
  * resourceLedgerKey({ kind: 'StorageBucket', name: 'Inbox' }) // '["storagebucket","Inbox",null]'
130
+ * resourceLedgerKey({ kind: 'Entity', name: 'Orders', folderKey: 'c4359cde-…' }) // '["Entity","Orders",null,"c4359cde-…"]'
121
131
  */
122
132
  export declare function resourceLedgerKey(ref: ResourceRef): string;
123
133
  /** An {@link EntityRef} as the {@link ResourceRef} it is. */
@@ -44,10 +44,16 @@ export function canonicalKind(kind) {
44
44
  * resourceLedgerKey({ kind: 'Entity', name: 'Orders', folder: 'Finance/Prod' }) // '["Entity","Orders","Finance/Prod"]'
45
45
  * resourceLedgerKey({ kind: 'asset', name: 'ApiKey' }) // '["Asset","ApiKey",null]'
46
46
  * resourceLedgerKey({ kind: 'StorageBucket', name: 'Inbox' }) // '["storagebucket","Inbox",null]'
47
+ * resourceLedgerKey({ kind: 'Entity', name: 'Orders', folderKey: 'c4359cde-…' }) // '["Entity","Orders",null,"c4359cde-…"]'
47
48
  */
48
49
  export function resourceLedgerKey(ref) {
49
50
  const known = KNOWN_KINDS.get(ref.kind.toLowerCase());
50
- return JSON.stringify([known ?? ref.kind.toLowerCase(), ref.name, ref.folder ?? null]);
51
+ const kind = known ?? ref.kind.toLowerCase();
52
+ // A folder named by key keys its own row, a fourth element, so no key a
53
+ // folder-path or folderless reference already recorded changes.
54
+ if (ref.folderKey !== undefined)
55
+ return JSON.stringify([kind, ref.name, null, ref.folderKey]);
56
+ return JSON.stringify([kind, ref.name, ref.folder ?? null]);
51
57
  }
52
58
  /** An {@link EntityRef} as the {@link ResourceRef} it is. */
53
59
  export function entityResource(ref) {
@@ -101,6 +107,7 @@ export function resourcePrepareCommand(ref) {
101
107
  cliSpelling(), 'registry', 'prepare',
102
108
  ...(kind === ENTITY_KIND ? ['--entity', commandArg(ref.name, 'name')] : ['--kind', commandArg(kind, 'kind'), '--name', commandArg(ref.name, 'name')]),
103
109
  ...(ref.folder !== undefined ? ['--folder-path', commandArg(ref.folder, 'folder path')] : []),
110
+ ...(ref.folderKey !== undefined ? ['--folder-key', commandArg(ref.folderKey, 'folder key')] : []),
104
111
  ].join(' ');
105
112
  }
106
113
  /** {@link resourcePrepareCommand} for an entity: `registry prepare --entity <name> [--folder-path <path>]`. */
@@ -166,9 +173,17 @@ export function resourcePlural(kind) {
166
173
  return `${n}es`;
167
174
  return `${n}s`;
168
175
  }
176
+ /** ` in folder "Finance/Prod"`, ` in the folder with key "…"`, or nothing: where a reference says its resource lives. */
177
+ function whereText(ref) {
178
+ if (ref.folder !== undefined)
179
+ return ` in folder ${JSON.stringify(ref.folder)}`;
180
+ if (ref.folderKey !== undefined)
181
+ return ` in the folder with key ${JSON.stringify(ref.folderKey)}`;
182
+ return '';
183
+ }
169
184
  /** `entity "Orders" in folder "Finance/Prod" is not resolved.` — the shared opening of the diagnostic and the compile refusal. */
170
185
  export function resourceUnresolvedMessage(ref) {
171
- return `${resourceNoun(ref.kind)} ${JSON.stringify(ref.name)}${ref.folder !== undefined ? ` in folder ${JSON.stringify(ref.folder)}` : ''} is not resolved.`;
186
+ return `${resourceNoun(ref.kind)} ${JSON.stringify(ref.name)}${whereText(ref)} is not resolved.`;
172
187
  }
173
188
  /**
174
189
  * The recorded row for a reference, for `compile` to write from.
@@ -185,11 +200,11 @@ export function resolveRecordedResource(ref, resolutions, now = Date.now()) {
185
200
  const old = recordedRow(resolutions, ref);
186
201
  const why = old === undefined
187
202
  ? `${resourceUnresolvedMessage(ref)} Compile does not make network calls, so its keys have to be recorded first:`
188
- : `${resourceNoun(ref.kind)} ${JSON.stringify(ref.name)}${ref.folder !== undefined ? ` in folder ${JSON.stringify(ref.folder)}` : ''} was recorded `
203
+ : `${resourceNoun(ref.kind)} ${JSON.stringify(ref.name)}${whereText(ref)} was recorded `
189
204
  + (old.resolvedAt !== undefined ? `at ${old.resolvedAt}, more than 24 hours ago` : 'with no resolvedAt')
190
205
  + ', so its keys may be out of date. Record it again:';
191
206
  throw new CompileRefusal('RESOURCE_UNRESOLVED', `${why}\n ${resourcePrepareCommand(ref)}`
192
- + (ref.folder === undefined && old === undefined
207
+ + (ref.folder === undefined && ref.folderKey === undefined && old === undefined
193
208
  ? `\n No folder given: prepare will search every folder and record the ${resourceNoun(ref.kind)} if exactly one matches; add folder: '<path>' to pin it.`
194
209
  : ''));
195
210
  }
@@ -42,7 +42,7 @@ export declare function cliResourceLedger(argv: readonly string[], fallback: str
42
42
  export declare function readCliResources(argv: readonly string[], fallback: string | undefined): ResourceResolutions | undefined;
43
43
  /**
44
44
  * Record `row` under the reference the author wrote, and — when they gave no
45
- * folder and it resolved into one — under the folder it was found in too, so
45
+ * folder, by path or by key, and it resolved into one — under the folder it was found in too, so
46
46
  * adding `folder:` to the source later needs no second `prepare`. That second
47
47
  * row is marked `aliasOf` the first, and the copy a previous run made for the
48
48
  * same reference is dropped, so a resource that moved folders leaves no row
@@ -119,7 +119,7 @@ export function readCliResources(argv, fallback) {
119
119
  }
120
120
  /**
121
121
  * Record `row` under the reference the author wrote, and — when they gave no
122
- * folder and it resolved into one — under the folder it was found in too, so
122
+ * folder, by path or by key, and it resolved into one — under the folder it was found in too, so
123
123
  * adding `folder:` to the source later needs no second `prepare`. That second
124
124
  * row is marked `aliasOf` the first, and the copy a previous run made for the
125
125
  * same reference is dropped, so a resource that moved folders leaves no row
@@ -135,7 +135,7 @@ export function recordResource(path, ref, row, now = new Date()) {
135
135
  delete resolved.aliasOf;
136
136
  dropAliases(rows, authoredKey);
137
137
  rows[authoredKey] = resolved;
138
- if (ref.folder === undefined && row.folderPath !== null) {
138
+ if (ref.folder === undefined && ref.folderKey === undefined && row.folderPath !== null) {
139
139
  const aliasKey = resourceLedgerKey({ kind: row.kind, name: row.name, folder: row.folderPath });
140
140
  const existing = Object.hasOwn(rows, aliasKey) ? rows[aliasKey] : undefined;
141
141
  if (existing === undefined || existing.aliasOf !== undefined)
@@ -394,7 +394,13 @@ async function findResource(client, request) {
394
394
  const pool = [];
395
395
  const listings = request.listings;
396
396
  const exactName = (c) => c.name === request.name;
397
- const inFolder = (c) => request.folder !== undefined && c.folderPath !== null && folderPathKey(c.folderPath) === folderPathKey(request.folder);
397
+ // The folder the reference pins, by path or by key; `undefined` when it pins none.
398
+ const pinned = request.folder !== undefined
399
+ ? `folder ${JSON.stringify(request.folder)}`
400
+ : request.folderKey !== undefined ? `the folder with key ${JSON.stringify(request.folderKey)}` : undefined;
401
+ const inFolder = (c) => request.folder !== undefined
402
+ ? c.folderPath !== null && folderPathKey(c.folderPath) === folderPathKey(request.folder)
403
+ : request.folderKey !== undefined && c.folderKey !== null && c.folderKey.toLowerCase() === request.folderKey.toLowerCase();
398
404
  const summary = (rows, matching) => rows.length === 0 ? `no ${resourcePlural(kind)}` : `${rows.length} result(s), ${matching} named exactly ${JSON.stringify(request.name)}`;
399
405
  // 1. The catalogue: the tenant's folder-scoped resources, and inside a
400
406
  // solution the solution's own. Remote is read even for `local`, to tell a
@@ -418,7 +424,7 @@ async function findResource(client, request) {
418
424
  "Run prepare from inside the solution, or leave --resource-source out.", "RESOURCE_LISTING_FAILED");
419
425
  }
420
426
  const exact = [...(mode === "local" ? [] : remote), ...local].filter(exactName);
421
- const settled = request.folder !== undefined && exact.filter(inFolder).length === 1;
427
+ const settled = pinned !== undefined && exact.filter(inFolder).length === 1;
422
428
  // 2. For an entity, the tenant-level list: an entity the catalogue cannot
423
429
  // hold. Not needed once the requested folder has its one match, nor for a
424
430
  // solution-only search; a row with no `FolderId` is not known to be
@@ -444,16 +450,16 @@ async function findResource(client, request) {
444
450
  pool.push(...tenantRows);
445
451
  }
446
452
  const all = [...exact, ...tenantExact];
447
- if (request.folder !== undefined) {
453
+ if (pinned !== undefined) {
448
454
  const matches = exact.filter(inFolder);
449
455
  if (matches.length === 1)
450
456
  return resolved(matches[0]);
451
457
  if (matches.length > 1) {
452
- throw new Refusal(`${matches.length} ${resourcePlural(kind)} named ${JSON.stringify(request.name)} are in folder ${JSON.stringify(request.folder)}; refusing to pick one:\n` +
458
+ throw new Refusal(`${matches.length} ${resourcePlural(kind)} named ${JSON.stringify(request.name)} are in ${pinned}; refusing to pick one:\n` +
453
459
  matches.map(candidateLine).join("\n") + `\n${searchedBlock(searched)}`, "RESOURCE_AMBIGUOUS");
454
460
  }
455
461
  if (all.length > 0) {
456
- throw new Refusal(`no ${resourceNoun(kind)} named ${JSON.stringify(request.name)} in folder ${JSON.stringify(request.folder)}. It exists in:\n` +
462
+ throw new Refusal(`no ${resourceNoun(kind)} named ${JSON.stringify(request.name)} in ${pinned}. It exists in:\n` +
457
463
  all.map(candidateLine).join("\n") +
458
464
  `\n${searchedBlock(searched)}\n` +
459
465
  "Change the source to the spelling of the one meant and run its prepare.", "RESOURCE_NOT_IN_FOLDER");
@@ -490,7 +496,7 @@ async function findResource(client, request) {
490
496
  const unique = [...new Map(pool.map((c) => [`${c.name}\u0000${where(c)}`, c])).values()];
491
497
  const near = nearMisses(request.name, unique);
492
498
  throw new Refusal(`no ${resourceNoun(kind)} named ${JSON.stringify(request.name)}` +
493
- (request.folder !== undefined ? ` in folder ${JSON.stringify(request.folder)}` : "") +
499
+ (pinned !== undefined ? ` in ${pinned}` : "") +
494
500
  " (a match is exact, case included).\n" +
495
501
  `${searchedBlock(searched)}\n` +
496
502
  (near.length > 0 ? `Near misses:\n${near.map(candidateLine).join("\n")}\n` : "") +
@@ -522,7 +528,9 @@ export function recordedLines(row, ledger) {
522
528
  */
523
529
  export function recordedRefs(resolutions) {
524
530
  return Object.keys(resolutions).filter((key) => resolutions[key].aliasOf === undefined).map((key) => {
525
- const [kind, name, folder] = JSON.parse(key);
531
+ const [kind, name, folder, folderKey] = JSON.parse(key);
532
+ if (folderKey !== undefined)
533
+ return { kind, name, folderKey };
526
534
  return folder === null ? { kind, name } : { kind, name, folder };
527
535
  });
528
536
  }
@@ -36,6 +36,8 @@ export interface PrepareConnectorOptions {
36
36
  name?: string;
37
37
  /** `--folder-path`: the resource's Orchestrator folder path. */
38
38
  folder?: string;
39
+ /** `--folder-key`: the resource's Orchestrator folder key, for a source that names the folder by key. */
40
+ folderKey?: string;
39
41
  /** `--resource-source`: which listings to consult. Default `auto`. */
40
42
  resourceSource?: ResourceSource;
41
43
  /** `--resources`: the resource ledger. Default `.flow-sdk/resources.json`. */
@@ -22,7 +22,7 @@ import { defaultUipClient } from "./uip/client.js";
22
22
  const DEFAULT_CONNECTOR_IMPORT = PACKAGE_NAME;
23
23
  const USAGE = [
24
24
  "Usage: flow-sdk registry prepare --entity <name> | --kind <kind> --name <name>",
25
- " [--folder-path <path>] [--resource-source auto|local|remote]",
25
+ " [--folder-path <path> | --folder-key <key>] [--resource-source auto|local|remote]",
26
26
  " [--resources <file>] [--refresh-resources]",
27
27
  " flow-sdk registry prepare <connector-key> --action <name> [--entity <name> [--folder-path <path>]]",
28
28
  " [--connection-id <id>]",
@@ -162,6 +162,7 @@ export function parseArgs(argv) {
162
162
  "--kind",
163
163
  "--name",
164
164
  "--folder-path",
165
+ "--folder-key",
165
166
  "--resource-source",
166
167
  "--resources",
167
168
  ]) {
@@ -196,8 +197,14 @@ export function parseArgs(argv) {
196
197
  console.error(`argument ${argv.includes("--kind") ? "--kind" : "--name"}: needs ${argv.includes("--kind") ? "--name" : "--kind"}`);
197
198
  return null;
198
199
  }
199
- if (argv.includes("--folder-path") && !named) {
200
- console.error("argument --folder-path: only with --entity or --kind/--name");
200
+ for (const flag of ["--folder-path", "--folder-key"]) {
201
+ if (argv.includes(flag) && !named) {
202
+ console.error(`argument ${flag}: only with --entity or --kind/--name`);
203
+ return null;
204
+ }
205
+ }
206
+ if (argv.includes("--folder-path") && argv.includes("--folder-key")) {
207
+ console.error("argument --folder-key: not allowed with --folder-path (name the folder one way)");
201
208
  return null;
202
209
  }
203
210
  const resourceSource = value(argv, "--resource-source");
@@ -221,6 +228,7 @@ export function parseArgs(argv) {
221
228
  kind: value(argv, "--kind"),
222
229
  name: value(argv, "--name"),
223
230
  folder: value(argv, "--folder-path"),
231
+ folderKey: value(argv, "--folder-key"),
224
232
  resourceSource: resourceSource,
225
233
  resources: value(argv, "--resources"),
226
234
  refreshResources: argv.includes("--refresh-resources"),
@@ -286,7 +294,9 @@ export async function run(argv) {
286
294
  }
287
295
  /** The one reference `--entity` or `--kind`/`--name` names, or `undefined`. */
288
296
  function requestedRef(options) {
289
- const folder = options.folder !== undefined ? { folder: options.folder } : {};
297
+ const folder = options.folder !== undefined
298
+ ? { folder: options.folder }
299
+ : options.folderKey !== undefined ? { folderKey: options.folderKey } : {};
290
300
  if (options.entity !== undefined)
291
301
  return { kind: ENTITY_KIND, name: options.entity, ...folder };
292
302
  if (options.kind !== undefined && options.name !== undefined)
@@ -379,7 +389,7 @@ export async function prepareResources(options, ports) {
379
389
  }
380
390
  if (refused.length > 0) {
381
391
  throw new Refusal(`${refused.length} of ${refs.length} recorded reference(s) no longer resolve; their rows are removed, so check reports them:\n`
382
- + refused.map(({ ref, error }) => `- ${ref.kind} ${JSON.stringify(ref.name)}${ref.folder !== undefined ? ` in ${JSON.stringify(ref.folder)}` : ""} [${error.code}]: ${error.message}`).join("\n"), "RESOURCE_REFRESH_FAILED");
392
+ + refused.map(({ ref, error }) => `- ${ref.kind} ${JSON.stringify(ref.name)}${ref.folder !== undefined ? ` in ${JSON.stringify(ref.folder)}` : ref.folderKey !== undefined ? ` in folder key ${JSON.stringify(ref.folderKey)}` : ""} [${error.code}]: ${error.message}`).join("\n"), "RESOURCE_REFRESH_FAILED");
383
393
  }
384
394
  return recorded;
385
395
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.121.1",
3
+ "version": "6.122.0",
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",
@@ -87,7 +87,8 @@
87
87
  "flow-script-metadata",
88
88
  "flow-pipeline-strict",
89
89
  "flow-build",
90
- "case-check-baseline"
90
+ "case-check-baseline",
91
+ "prepare-folder-key"
91
92
  ],
92
93
  "files": [
93
94
  "dist",
@@ -125,5 +126,5 @@
125
126
  "@types/node": "^22.7.0",
126
127
  "esbuild": "^0.28.1"
127
128
  },
128
- "gitref": "21e2eeafbe84a29c52703bb50aa5a06a642209cf"
129
+ "gitref": "e76d86fad9a1820eb4e282807215e14b55258dfe"
129
130
  }