@uipath/maestro-builder-sdk 6.121.1 → 6.122.1

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.
@@ -1,5 +1,6 @@
1
1
  import { CompileRefusal } from '../core/compile-refusal.js';
2
- import { entityPrepareCommand, isEntityRef, resolveEntityRef } from '../core/resource-resolution.js';
2
+ import { ENTITY_KIND, entityPrepareCommand, isEntityRef, resolveRecordedResource, } from '../core/resource-resolution.js';
3
+ import { PICKER_ENTITY_RESOURCE } from '../core/resource-picker.js';
3
4
  import { ownEntry } from '../core/own-entry.js';
4
5
  import { connectorActivityMetadata } from '../core/connector-v2-metadata.js';
5
6
  import { ACTIVITY_CONFIGURATION_V2 } from './connector.js';
@@ -21,6 +22,8 @@ export function isFolderEntity(entity) {
21
22
  * @param entity - The Data Service entity: a name, e.g. `'ContractRegistry'`, or a
22
23
  * folder-scoped `{ name, folderKey }`.
23
24
  * @param operation - Which operation, and its parameters.
25
+ * @param picker - For a folder-scoped entity, its recorded resource key and binding
26
+ * ids: a record operation other than delete is then the V2 `_V3` wire.
24
27
  * @returns The wire shape, without the connection/folder wiring the builder adds.
25
28
  * @throws CompileRefusal for a folder-scoped entity on a file operation (`BPMN_DATA_SERVICE_FOLDER_FILE_OP`), or one with no name
26
29
  * (`BPMN_DATA_SERVICE_ENTITY_NO_NAME`), no folder key (`BPMN_DATA_SERVICE_FOLDER_KEY_MISSING`) or a folder key that is not a
@@ -28,9 +31,9 @@ export function isFolderEntity(entity) {
28
31
  * (`BPMN_DATA_SERVICE_QUERY_START_INVALID`) or whose literal `limit` is not one from 1 to 1000
29
32
  * (`BPMN_DATA_SERVICE_QUERY_LIMIT_INVALID`).
30
33
  */
31
- export function dataServiceWire(entity, operation) {
34
+ export function dataServiceWire(entity, operation, picker) {
32
35
  if (typeof entity !== 'string')
33
- return folderEntityWire(entity, operation);
36
+ return folderEntityWire(entity, operation, picker);
34
37
  const attachment = '/Attachment/{entityName}/{recordId}/{fieldName}';
35
38
  switch (operation.op) {
36
39
  case 'create':
@@ -88,47 +91,92 @@ export function isPendingEntity(entity) {
88
91
  return isEntityRef(entity) && !isFolderEntity(entity);
89
92
  }
90
93
  /**
91
- * The wire for a `{ name, folder }` entity from the row `registry prepare --entity`
92
- * recorded: the V1 `_V3` folder form and the two `Entity` binding rows for a folder-scoped
93
- * entity, exactly as `{ name, folderKey }` writes the task; the tenant form and no
94
- * bindings for a tenant-level one. `check` calls this too, so the two cannot disagree.
94
+ * True when a `{ name, folderKey }` entity's wire waits for the recorded row too: a
95
+ * record operation that has a V2 `_V3` form ({@link FOLDER_RECORD_OPERATIONS}), on a
96
+ * folder KEY rather than an `=`-expression. The V2 wire saves the entity's resource
97
+ * key, which the folder key alone does not give, so `prepare --entity <name>
98
+ * --folder-key <key>` records it. Delete, the file operations and an expression
99
+ * folder stay the V1 form, which needs no row.
100
+ */
101
+ export function pendsOnFolderKeyRow(entity, operation) {
102
+ return isFolderEntity(entity)
103
+ && typeof entity.folderKey === 'string'
104
+ && GUID.test(entity.folderKey)
105
+ && typeof entity.name === 'string'
106
+ && entity.name.trim() !== ''
107
+ && ownEntry(FOLDER_RECORD_OPERATIONS, operation.op) !== undefined;
108
+ }
109
+ /**
110
+ * The wire for a pending entity from the row `registry prepare --entity` recorded.
111
+ *
112
+ * A folder-scoped row gives the entity's binding pair, and a wire that takes the pair's
113
+ * final ids: the serializer settles them first (two entities cannot share one). A record
114
+ * operation other than delete is then the V2 `_V3` form, which references the pair as
115
+ * Studio Web's picker does; delete and the file operations are the V1 form, beside which
116
+ * the pair is unreferenced and carries the resource key `bpmn refresh` declares the
117
+ * entity from. A tenant row gives the tenant form and no bindings. `check` runs the
118
+ * serializer, so the two cannot disagree.
95
119
  *
96
120
  * @throws CompileRefusal `RESOURCE_UNRESOLVED` or `RESOURCE_ROW_INCOMPLETE` from
97
- * `resolveEntityRef`, prefixed with the node; `BPMN_DATA_SERVICE_FOLDER_FILE_OP` for a
98
- * file operation on an entity that resolved to a folder.
121
+ * `resolveRecordedResource`, prefixed with the node; `BPMN_DATA_SERVICE_FOLDER_FILE_OP`
122
+ * (from the wire) for a file operation on an entity that resolved to a folder.
99
123
  */
100
124
  export function lowerDataServiceEntity(id, pending, resources) {
101
- let resolved;
125
+ const { name, folder, folderKey } = pending.ref;
126
+ const ref = {
127
+ kind: ENTITY_KIND, name, ...(folder !== undefined ? { folder } : {}), ...(folderKey !== undefined ? { folderKey } : {}),
128
+ };
129
+ let row;
102
130
  try {
103
- resolved = resolveEntityRef(pending.ref, resources);
131
+ row = resolveRecordedResource(ref, resources);
104
132
  }
105
133
  catch (error) {
106
134
  if (error instanceof CompileRefusal)
107
135
  throw new CompileRefusal(error.code, `dataService "${id}": ${error.message}`, error.suggestion);
108
136
  throw error;
109
137
  }
110
- if (resolved.folderKey === undefined || resolved.resourceKey === undefined) {
111
- return { wire: dataServiceWire(resolved.name, pending.operation), bindings: [] };
112
- }
138
+ if (row.scope === 'tenant')
139
+ return { bindings: [], wire: () => dataServiceWire(row.name, pending.operation) };
140
+ const entity = { name: row.name, folderKey: row.folderKey };
141
+ const bindings = entityBindings(row.name, row.folderKey, row.key, pending.operation.op === 'delete' ? EntityBindingForm.V1 : EntityBindingForm.Picker);
113
142
  return {
114
- wire: dataServiceWire({ name: resolved.name, folderKey: resolved.folderKey }, pending.operation),
115
- bindings: entityBindings(resolved.name, resolved.folderKey, resolved.resourceKey),
143
+ bindings,
144
+ wire: (ids = { name: bindings[0].id, folder: bindings[1].id }) => dataServiceWire(entity, pending.operation, { resourceKey: row.key, nameBinding: ids.name, folderBinding: ids.folder }),
116
145
  };
117
146
  }
118
147
  /**
119
- * The two `Entity` binding rows of a folder-scoped entity, as Flow writes them
120
- * (`entityBindings` in `nodes/data-fabric/flow/shared.ts`, which explains each attribute):
121
- * the capital `E`, `name` / `folderKey` attributes, one resource key, and the
122
- * `b<Entity>EntityName` / `b<Entity>EntityFolder` ids, so two tasks on one entity share
123
- * one pair.
148
+ * The binding pair of a folder-scoped entity, `name` / `folderKey` attributes and one
149
+ * resource key, in one of two forms:
150
+ *
151
+ * - for a V2 task, as Studio Web's picker writes it: `resource="entity"`, names
152
+ * `Entity` and `Entity folder`;
153
+ * - for a V1 task (delete), as Flow writes it (`entityBindings` in
154
+ * `nodes/data-fabric/flow/shared.ts`): `resource="Entity"`, names `<name>` and
155
+ * `<name>Folder`. A V1 task has no picker metadata, so `bpmn refresh` declares its
156
+ * entity from this capital-`E` pair alone.
157
+ *
158
+ * The ids are `b<Entity>EntityName` / `b<Entity>EntityFolder` either way, so two tasks
159
+ * on one entity share one pair, and the serializer keeps the picker form when any of
160
+ * them is V2, whose metadata then declares the entity.
124
161
  */
125
- function entityBindings(name, folderKey, resourceKey) {
162
+ function entityBindings(name, folderKey, resourceKey, form) {
126
163
  const base = `b${name.replace(/[^A-Za-z0-9]/g, '')}Entity`;
127
- return [
128
- { id: `${base}Name`, name, type: 'string', resource: 'Entity', resourceKey, default: name, propertyAttribute: 'name' },
129
- { id: `${base}Folder`, name: `${name}Folder`, type: 'string', resource: 'Entity', resourceKey, default: folderKey, propertyAttribute: 'folderKey' },
130
- ];
164
+ const resource = form === EntityBindingForm.Picker ? PICKER_ENTITY_RESOURCE : V1_ENTITY_RESOURCE;
165
+ const row = (suffix, label, value, propertyAttribute) => ({ id: `${base}${suffix}`, name: label, type: 'string', resource, resourceKey, default: value, propertyAttribute });
166
+ return form === EntityBindingForm.Picker
167
+ ? [row('Name', 'Entity', name, 'name'), row('Folder', 'Entity folder', folderKey, 'folderKey')]
168
+ : [row('Name', name, name, 'name'), row('Folder', `${name}Folder`, folderKey, 'folderKey')];
131
169
  }
170
+ /** Which wire contract a folder entity's binding pair follows; see {@link entityBindings}. */
171
+ var EntityBindingForm;
172
+ (function (EntityBindingForm) {
173
+ /** Studio Web's picker pair, for a V2 task. */
174
+ EntityBindingForm[EntityBindingForm["Picker"] = 0] = "Picker";
175
+ /** Flow's pair, for a V1 task. */
176
+ EntityBindingForm[EntityBindingForm["V1"] = 1] = "V1";
177
+ })(EntityBindingForm || (EntityBindingForm = {}));
178
+ /** The binding `resource` of a V1 task's entity pair, capital `E` as Flow writes it. */
179
+ const V1_ENTITY_RESOURCE = 'Entity';
132
180
  /**
133
181
  * The `uipath:context` values of a `.dataService()` task, in the order the canvas writes
134
182
  * them: the connection wiring, the operation's identity, and for a V2 operation the
@@ -150,13 +198,14 @@ export function dataServiceContext(wire, wiring) {
150
198
  metadata: {},
151
199
  };
152
200
  }
201
+ const pickers = wire.picker !== undefined ? [{ ...wire.picker, elementId: wiring.elementId ?? '' }] : [];
153
202
  return {
154
203
  connectorKey: DATA_SERVICE_CONNECTOR_KEY,
155
204
  connection,
156
205
  resourceKey,
157
206
  ...(folderKey !== undefined ? { folderKey } : {}),
158
207
  ...wire.context,
159
- metadata: dataServiceMetadata(wire.catalog, wire.slots),
208
+ metadata: dataServiceMetadata(wire.catalog, wire.slots, pickers),
160
209
  activityConfigurationVersion: ACTIVITY_CONFIGURATION_V2,
161
210
  };
162
211
  }
@@ -166,8 +215,15 @@ const DATA_SERVICE_CONNECTOR_NAME = 'UiPath Data Fabric';
166
215
  * The design-time `metadata` of a V2 record operation, from the shared builder: the
167
216
  * operation is described here rather than resolved from the library, which ships
168
217
  * only `query-entity-records`.
218
+ *
219
+ * A folder-scoped entity's picker adds what the panel saves for one: the schema
220
+ * replay of the folder entity (`FetchObjectMetadataFolder` on the picker field, the
221
+ * `_V3` operations' `design.actions`), the saved selection, and the `bindings` entry.
169
222
  */
170
- function dataServiceMetadata(catalog, slots) {
223
+ function dataServiceMetadata(catalog, slots, pickers) {
224
+ const replay = pickers.length > 0
225
+ ? { customFieldsRequestDetails: { objectActionName: 'FetchObjectMetadataFolder', parameterValues: pickers.map((p) => [p.field, p.name]) } }
226
+ : {};
171
227
  const operation = {
172
228
  name: catalog.verb,
173
229
  objectName: catalog.objectName,
@@ -177,6 +233,7 @@ function dataServiceMetadata(catalog, slots) {
177
233
  activityType: 'Curated',
178
234
  supportsStreaming: false,
179
235
  subType: 'standard',
236
+ ...replay,
180
237
  };
181
238
  const metadata = connectorActivityMetadata({
182
239
  entry: { connector: { key: DATA_SERVICE_CONNECTOR_KEY }, operation, display: { label: catalog.displayName, description: catalog.description } },
@@ -185,7 +242,7 @@ function dataServiceMetadata(catalog, slots) {
185
242
  nodeType: `uipath.connector.${DATA_SERVICE_CONNECTOR_KEY}.${catalog.objectName}`,
186
243
  connectorKey: DATA_SERVICE_CONNECTOR_KEY,
187
244
  connectorName: DATA_SERVICE_CONNECTOR_NAME,
188
- }, operation, slots, catalog.objectName);
245
+ }, operation, slots, catalog.objectName, undefined, undefined, pickers);
189
246
  // A list operation's paging, as Studio Web saves the query (`maxPageSize` is the connector's).
190
247
  return catalog.verb === 'list' ? { ...metadata, inputMetadata: { operation: 'list', pagination: { maxPageSize: QUERY_PAGE_CAP } } } : metadata;
191
248
  }
@@ -222,6 +279,37 @@ const RECORD_OPERATIONS = {
222
279
  description: 'Deletes an existing record for the selected entity from Data Fabric', label: (e) => `Delete ${e} record`,
223
280
  },
224
281
  };
282
+ /**
283
+ * The four `_V3` record operations Studio Web's V2 panel saves for a folder-scoped
284
+ * entity, from `uip maestro bpmn registry get Intsvc.ActivityExecution --object-name
285
+ * <Op>_V3 --input-details … --solution-folder …` (uip 1.207, alpha, 2026-11-13;
286
+ * `tests/fixtures/bpmn/dataservice-folder-v2/`). Delete has no entry: the design-time
287
+ * client fails to build `DeleteEntityRecord_V3` with a picker ("Cannot convert undefined
288
+ * or null to object"), so there is no V2 save to match, and it stays the V1 form.
289
+ */
290
+ const FOLDER_RECORD_OPERATIONS = {
291
+ create: {
292
+ objectName: 'CreateEntityRecord_V3', verb: 'create', method: 'POST', path: '/v3/CreateEntityRecord/insert',
293
+ activityTypeId: '11a59287-5a7a-3a74-b000-91d2c2b6428d', displayName: 'Create Entity Record (Preview)',
294
+ description: 'Creates a new record for the selected entity in Data Fabric.', label: (e) => `Create ${e}`,
295
+ },
296
+ update: {
297
+ objectName: 'UpdateEntityRecord_V3', verb: 'replace', method: 'PUT', path: '/v3/UpdateEntityRecord/update',
298
+ activityTypeId: 'fa2a1fb6-c297-3e7b-8ced-99521f9d60d8', displayName: 'Update Entity Record (Preview)',
299
+ description: 'Updates an existing record for the selected entity in Data Fabric.', label: (e) => `Update ${e}`,
300
+ },
301
+ get: {
302
+ objectName: 'GetEntityRecord_V3', verb: 'retrieve', method: 'GET', path: '/v3/GetEntityRecord/read',
303
+ activityTypeId: 'd94d7374-fcc3-3212-83f6-1dac43c4e109', displayName: 'Get Entity Record by ID (Preview)',
304
+ description: 'Reads an existing record for the selected entity from Data Fabric.', label: (e) => `Get ${e} record`,
305
+ },
306
+ query: {
307
+ objectName: 'QueryEntityRecords_V3', verb: 'list', method: 'POST', path: '/v3/QueryEntityRecords/query',
308
+ activityTypeId: 'deababb7-2da5-3651-a5ca-2e6bb4bbd957', displayName: 'Query Entity Records (Preview)',
309
+ description: 'Retrieves a list of records for the selected entity from Data Fabric, according to specified filters.',
310
+ label: (e) => `Query ${e}`,
311
+ },
312
+ };
225
313
  /** The `_V3` scope rows' wire names, as `describe` declares them and the canvas writes them. */
226
314
  const FOLDER_SCOPE = {
227
315
  scopeParameter: 'entityScope',
@@ -278,17 +366,21 @@ function validateFolderEntity(entity) {
278
366
  }
279
367
  }
280
368
  /**
281
- * The V1 `_V3` form for a folder-scoped entity. The three scope rows come first, then
282
- * the operation's own parameters, which `_V3` takes as query rows where the tenant forms
283
- * use the path (`recordId`, never `id`).
369
+ * The `_V3` form for a folder-scoped entity: V2 ({@link folderEntityV2Wire}) for a record
370
+ * operation that has one when the entity's keys are recorded (`picker`), V1 otherwise.
371
+ * In the V1 form the three scope rows come first, then the operation's own parameters,
372
+ * which `_V3` takes as query rows where the tenant forms use the path (`recordId`, never
373
+ * `id`).
284
374
  */
285
- function folderEntityWire(entity, operation) {
375
+ function folderEntityWire(entity, operation, picker) {
286
376
  validateFolderEntity(entity);
287
377
  if (operation.op === 'downloadFile' || operation.op === 'uploadFile' || operation.op === 'deleteFile') {
288
378
  throw new CompileRefusal('BPMN_DATA_SERVICE_FOLDER_FILE_OP', `dataService: ${operation.op} does not support a folder-scoped entity yet. Its _V3 operation declares no field-name parameter, ` +
289
379
  `so where it takes "${operation.field}" is unknown here, and there is no SDK form for it. Tell the user; a plain entity name would address a tenant-level entity instead, ` +
290
380
  'and a hand-filled .activity() would have to guess the same parameter.');
291
381
  }
382
+ if (picker !== undefined && operation.op !== 'delete')
383
+ return folderEntityV2Wire(entity, operation, picker);
292
384
  const scope = [
293
385
  scalarRow(FOLDER_SCOPE.scopeParameter, 'query', FOLDER_SCOPE.scopeValue),
294
386
  scalarRow(FOLDER_SCOPE.nameParameter, 'query', entity.name),
@@ -323,6 +415,68 @@ function folderEntityWire(entity, operation) {
323
415
  return wire([scalarRow('recordId', 'query', operation.recordId)]);
324
416
  }
325
417
  }
418
+ /**
419
+ * The V2 `_V3` wire for a folder-scoped entity, as Studio Web's V2 panel saves it: an
420
+ * empty `pathParameters` row; the `queryParameters` row with the scope, the picker and
421
+ * its folder as `=bindings.<id>` references to the entity's pair, the operation's own
422
+ * parameters between them; and the `body` row, which a query always has (`{}`, or the
423
+ * sort field). The picker rides on the wire for the metadata to save.
424
+ */
425
+ function folderEntityV2Wire(entity, operation, picker) {
426
+ const catalog = ownEntry(FOLDER_RECORD_OPERATIONS, operation.op);
427
+ const defined = (params) => Object.fromEntries(Object.entries(params).filter(([, v]) => v !== undefined));
428
+ let params;
429
+ let body;
430
+ switch (operation.op) {
431
+ case 'create':
432
+ params = {};
433
+ body = operation.record;
434
+ break;
435
+ case 'update':
436
+ params = { recordId: operation.id };
437
+ body = operation.record;
438
+ break;
439
+ case 'get':
440
+ params = defined({ recordId: operation.recordId, expansionLevel: operation.expansionLevel });
441
+ break;
442
+ case 'query':
443
+ params = defined({
444
+ queryExpression: operation.where,
445
+ start: operation.start ?? 0,
446
+ limit: operation.limit ?? 100,
447
+ isAscending: operation.ascending,
448
+ expansionLevel: operation.expansionLevel,
449
+ });
450
+ // The sort field is a body field, as in the tenant form (`recordWire`).
451
+ body = operation.sortBy !== undefined ? { _sortFieldName: operation.sortBy } : {};
452
+ break;
453
+ }
454
+ const query = {
455
+ [FOLDER_SCOPE.scopeParameter]: FOLDER_SCOPE.scopeValue,
456
+ [FOLDER_SCOPE.nameParameter]: `=bindings.${picker.nameBinding}`,
457
+ ...params,
458
+ [FOLDER_SCOPE.folderKeyParameter]: `=bindings.${picker.folderBinding}`,
459
+ };
460
+ const pathParameters = {};
461
+ return {
462
+ label: catalog.label(entity.name),
463
+ context: { objectName: catalog.objectName, method: catalog.method, path: catalog.path },
464
+ inputRows: [
465
+ { name: 'pathParameters', type: 'json', target: 'pathParameters', body: pathParameters },
466
+ { name: 'queryParameters', type: 'json', target: 'queryParameters', body: query },
467
+ ...(body !== undefined ? [bodyRow(body)] : []),
468
+ ],
469
+ catalog,
470
+ slots: { pathParameters, queryParameters: query, bodyParameters: body ?? {} },
471
+ picker: {
472
+ field: FOLDER_SCOPE.nameParameter,
473
+ bucket: 'queryParameters',
474
+ name: entity.name,
475
+ folderKey: entity.folderKey,
476
+ resourceKey: picker.resourceKey,
477
+ },
478
+ };
479
+ }
326
480
  /**
327
481
  * The V2 curated wire for a tenant-level entity's record operation: the entity as the
328
482
  * `entityName` path parameter, the record id (`recordId`, never `id`) and the query's
@@ -2498,7 +2498,14 @@ function bindingIsReferenced(xml, id) {
2498
2498
  return new RegExp(String.raw `bindings\.${id.replace(/[.*+?^${}()|[\]\\]/g, String.raw `\$&`)}\b`).test(xml);
2499
2499
  }
2500
2500
  /**
2501
- * The resource keys of the `Entity` binding pairs a Data Service task uses.
2501
+ * An entity binding row: `resource="entity"` as Studio Web's V2 picker and the SDK
2502
+ * write it, or `Entity` as the Flow→BPMN converter and earlier SDK builds write it.
2503
+ */
2504
+ function isEntityBinding(b) {
2505
+ return typeof b.resource === 'string' && b.resource.toLowerCase() === 'entity';
2506
+ }
2507
+ /**
2508
+ * The resource keys of the entity binding pairs a Data Service task uses.
2502
2509
  *
2503
2510
  * A folder-scoped `.dataService()` writes its entity's `name` / `folderKey` pair beside
2504
2511
  * the task rather than referencing it (`bpmn/data-service.ts`): the pair is how
@@ -2526,7 +2533,7 @@ function usedEntityKeys(bindings, container) {
2526
2533
  const folderKey = row('folderEntityName_folderKey');
2527
2534
  if (typeof name !== 'string' || typeof folderKey !== 'string')
2528
2535
  continue;
2529
- const has = (attr, value, key) => bindings.some((b) => b.resource === 'Entity' && b.propertyAttribute === attr && b.default === value && b.resourceKey === key);
2536
+ const has = (attr, value, key) => bindings.some((b) => isEntityBinding(b) && b.propertyAttribute === attr && b.default === value && b.resourceKey === key);
2530
2537
  for (const b of bindings) {
2531
2538
  const key = b.resourceKey;
2532
2539
  if (key !== undefined && has('name', name, key) && has('folderKey', folderKey, key))
@@ -2700,7 +2707,7 @@ export async function decompile(xml, options = {}) {
2700
2707
  const bindingEntries = [];
2701
2708
  const entityKeys = usedEntityKeys(bindings?.binding ?? [], process);
2702
2709
  for (const b of bindings?.binding ?? []) {
2703
- if (!options.keepUnusedBindings && !bindingIsReferenced(xml, b.id) && !(b.resource === 'Entity' && entityKeys.has(b.resourceKey))) {
2710
+ if (!options.keepUnusedBindings && !bindingIsReferenced(xml, b.id) && !(isEntityBinding(b) && entityKeys.has(b.resourceKey))) {
2704
2711
  droppedBindings.push(b.id);
2705
2712
  continue;
2706
2713
  }
@@ -16,6 +16,7 @@
16
16
  */
17
17
  import BpmnModdle from 'bpmn-moddle';
18
18
  import { createRequire } from 'node:module';
19
+ import { PICKER_ENTITY_RESOURCE } from '../core/resource-picker.js';
19
20
  import { createConnectorTask } from './connector.js';
20
21
  import { createConnectorEvent, createExternalTask } from './intsvc.js';
21
22
  import { connectorEventErrorVar, intsvcOutputVar } from './intsvc-vars.js';
@@ -806,8 +807,9 @@ function createNode(ctx, n) {
806
807
  }
807
808
  }
808
809
  /**
809
- * A `.dataService()` on `{ name, folder }` as it compiles: the wire from the recorded
810
- * row, and the entity's two `Entity` bindings into the sink (`lowerDataServiceEntity`).
810
+ * A pending `.dataService()` (`{ name, folder }`, or `{ name, folderKey }` on a record
811
+ * operation with a V2 form) as it compiles: the entity's binding pair into the sink, and
812
+ * the wire from the recorded row, built on the pair's settled ids (`lowerDataServiceEntity`).
811
813
  *
812
814
  * A pair's id is taken only when nothing else holds it, or what holds it is the same
813
815
  * entity (the same resource key): another task's pair, or the pair a decompiled
@@ -822,7 +824,7 @@ function createNode(ctx, n) {
822
824
  * id is a label only; a tool that keys on it must not assume it is stable.
823
825
  */
824
826
  function lowerPendingDataService(ctx, n) {
825
- const { wire, bindings } = lowerDataServiceEntity(n.id, n.dataServiceEntity, ctx.resources);
827
+ const { bindings, wire: wireFor } = lowerDataServiceEntity(n.id, n.dataServiceEntity, ctx.resources);
826
828
  const free = (suffix) => bindings.every((b) => {
827
829
  const id = withSuffix(b.id, suffix);
828
830
  const held = ctx.bindingSink.get(id);
@@ -839,14 +841,22 @@ function lowerPendingDataService(ctx, n) {
839
841
  for (const b of bindings) {
840
842
  const id = withSuffix(b.id, suffix);
841
843
  // A declared pair for this entity is written from the declaration (it wins on
842
- // an id); only a pair nothing declares goes into the sink.
843
- if (!ctx.declaredBindings?.has(id))
844
+ // an id); only a pair nothing declares goes into the sink. Tasks on one entity
845
+ // share the pair: the picker form, once any of them is V2, whatever their order.
846
+ if (ctx.declaredBindings?.has(id))
847
+ continue;
848
+ const held = ctx.bindingSink.get(id);
849
+ if (held === undefined || b.resource === PICKER_ENTITY_RESOURCE)
844
850
  ctx.bindingSink.set(id, { ...b, id });
845
851
  }
852
+ const wire = bindings.length === 2
853
+ ? wireFor({ name: withSuffix(bindings[0].id, suffix), folder: withSuffix(bindings[1].id, suffix) })
854
+ : wireFor();
846
855
  const context = n.context;
847
- // A record operation's tenant wire, which the builder wrote, is V2 and carries the
848
- // connection's key; a file operation's is V1 and needs none.
849
- const wiring = { connection: context.connection, resourceKey: context.resourceKey ?? '', folderKey: context.folderKey };
856
+ // The connection's key, which a V2 wire carries as `resourceKey`: the builder recorded it
857
+ // with the pending entity, since the wire it wrote first may be V1.
858
+ const resourceKey = n.dataServiceEntity.connectionKey ?? context.resourceKey ?? '';
859
+ const wiring = { connection: context.connection, resourceKey, folderKey: context.folderKey, elementId: n.id };
850
860
  return { ...n, context: dataServiceContext(wire, wiring), inputRows: wire.inputRows };
851
861
  }
852
862
  /** `bOrdersEntityName` with suffix `2` → `bOrdersEntity2Name`: the pair keeps its shared stem. */
package/dist/bpmn-api.md CHANGED
@@ -906,8 +906,9 @@ One `uipath:context` input row, spelled out.
906
906
 
907
907
  A `.dataService()` whose entity is `{ name, folder }`: which wire it gets, the `_V3` folder form or the tenant form, is…
908
908
 
909
- - `PendingDataServiceEntity.ref: EntityRef` — The entity as authored: its name, and the folder path it lives in.
909
+ - `PendingDataServiceEntity.ref: EntityRef & { folderKey?: string }` — The entity as authored: its name, and the folder path or folder key it lives in.
910
910
  - `PendingDataServiceEntity.operation: DataServiceOperation` — The operation and its parameters, for the wire the recorded row selects.
911
+ - `PendingDataServiceEntity.connectionKey?: string` — The connection's key, which a V2 wire carries as `resourceKey`.
911
912
 
912
913
  ### `RegistryTypeSpec`
913
914
 
@@ -593,12 +593,13 @@ export interface CaseHttpRequestSpec {
593
593
  */
594
594
  query?: Record<string, string>;
595
595
  /**
596
- * The request body, for POST, PUT or PATCH: an object, JSON text, or an `=`
597
- * expression (`=js:vars.payload`). In an object, a value `=js:<expression>`
598
- * or `=<reference>` (`=vars.id`) is sent as the value it reads.
596
+ * The request body, for POST, PUT or PATCH: an object, JSON text, a
597
+ * `taskOutput()` (read at run time), or an `=` expression (`=js:vars.payload`).
598
+ * In an object, a value `=js:<expression>`, `=<reference>` (`=vars.id`) or
599
+ * `taskOutput()` is sent as the value it reads.
599
600
  *
600
601
  * @enforcedBy HTTP_REQUEST_BODY_METHOD `check` reports a body on another method.
601
- * @enforcedBy HTTP_REQUEST_BODY_FORM compile refuses text that is neither JSON nor an expression.
602
+ * @enforcedBy HTTP_REQUEST_BODY_FORM compile refuses text that is neither JSON, a `taskOutput()`, nor an expression.
602
603
  * @enforcedBy HTTP_REQUEST_BODY_EXPRESSION compile refuses an object value that is another kind of `=` expression.
603
604
  */
604
605
  body?: string | Record<string, unknown> | unknown[];
@@ -1743,9 +1744,10 @@ declare class TaskBuilder {
1743
1744
  * Designer's suffixed key: `Result2: '=Result'` is its own bare output. This
1744
1745
  * is the output an SDD lists with no `->` arrow. Read it elsewhere with
1745
1746
  * {@link taskOutput | taskOutput('<stage>', '<task>', '<output>')} (or the
1746
- * SDD's `$xref` marker copied as written), which compiles to `vars.<id>`
1747
- * of that output, so a plan built from an SDD needs no case variable the SDD
1748
- * does not declare.
1747
+ * SDD's `$xref` marker copied as written), which compiles to `=vars.<id>`
1748
+ * of that output as a whole value (`=js:vars.<id>?.field` with property
1749
+ * reads; `vars.<id>` inside an expression), so a plan built from an SDD needs
1750
+ * no case variable the SDD does not declare.
1749
1751
  *
1750
1752
  * Pass `{ assign, type }` for a **custom** output: the SDD's `x = expr` row.
1751
1753
  * When the task completes, the case variable is set to `assign` — a literal,
@@ -786,9 +786,10 @@ class TaskBuilder {
786
786
  * Designer's suffixed key: `Result2: '=Result'` is its own bare output. This
787
787
  * is the output an SDD lists with no `->` arrow. Read it elsewhere with
788
788
  * {@link taskOutput | taskOutput('<stage>', '<task>', '<output>')} (or the
789
- * SDD's `$xref` marker copied as written), which compiles to `vars.<id>`
790
- * of that output, so a plan built from an SDD needs no case variable the SDD
791
- * does not declare.
789
+ * SDD's `$xref` marker copied as written), which compiles to `=vars.<id>`
790
+ * of that output as a whole value (`=js:vars.<id>?.field` with property
791
+ * reads; `vars.<id>` inside an expression), so a plan built from an SDD needs
792
+ * no case variable the SDD does not declare.
792
793
  *
793
794
  * Pass `{ assign, type }` for a **custom** output: the SDD's `x = expr` row.
794
795
  * When the task completes, the case variable is set to `assign` — a literal,
@@ -713,17 +713,18 @@ function checkStage(stage, diags, refStage, refPlacement) {
713
713
  if (o.custom)
714
714
  continue; // an assigned value, not a result field
715
715
  // `=response.X` and `=response[...]`. `check` does not see the
716
- // artifact's argument list, so an artifact whose own output argument is
717
- // named `response` is flagged too (the trade-off BUSINESS_RULE_OUTPUT_SOURCE
718
- // makes for `=result.`). A bare `=response` is left alone: it names
716
+ // artifact's argument list, and an output argument named `response`
717
+ // (an object) is read `=response.<field>`, the source the SDD and
718
+ // `validate --strict --sdd` expect. So this is a warning that names
719
+ // that case, not an error. A bare `=response` is left alone: it names
719
720
  // such an argument whole, and has no field to suggest.
720
721
  if (!/^=\s*response\s*[.[]/.test(o.source))
721
722
  continue;
722
723
  const fix = /^=\s*response\s*\.\s*(.+)$/.exec(o.source)?.[1];
723
724
  diags.push({
724
- level: 'error',
725
+ level: 'warning',
725
726
  code: 'REFERENCE_OUTPUT_SOURCE',
726
- message: `Task "${t.name}" (${t.kind}) output "${o.var}" reads "${o.source}". This ${t.kind} task's result fields are read directly; \`=response.<field>\` is the connector form and reads nothing here. Write ${fix !== undefined ? `"=${fix}"` : 'the field without the `response` prefix'} (the source the Designer and \`uip maestro case sdd convert\` write).`,
727
+ message: `Task "${t.name}" (${t.kind}) output "${o.var}" reads "${o.source}", the connector form. Keep it only if the ${t.kind}'s own output argument is an object named \`response\` (the SDD lists \`response.<field>\`; \`uip maestro case tasks describe --type ${t.kind} --id <entityKey>\` lists the outputs). Otherwise write ${fix !== undefined ? `"=${fix}"` : 'the field without the `response` prefix'}, the source the Designer writes.`,
727
728
  where: t.name,
728
729
  });
729
730
  }
@@ -26,7 +26,7 @@
26
26
  */
27
27
  import { parse } from 'acorn';
28
28
  import { MANAGED_HTTP_CONNECTOR_KEY, MANAGED_HTTP_ENDPOINT, MANAGED_HTTP_ENDPOINT_METHOD, MANAGED_HTTP_OBJECT_NAME, } from '../core/managed-http.js';
29
- import { taskOutputRefs } from './task-output-ref.js';
29
+ import { isWholeTaskOutputMarker } from './task-output-ref.js';
30
30
  import metadata from './http-request-metadata.json' with { type: 'json' };
31
31
  /**
32
32
  * The Designer's `metadata` context entry body, copied byte for byte from
@@ -123,11 +123,11 @@ export function httpRequestRefusal(owner, spec) {
123
123
  return { code: 'HTTP_REQUEST_FIELD', message: `${owner} ${field} must be an object of text values.` };
124
124
  // Text that is neither JSON nor an expression would be wrapped as `=js:( … )`,
125
125
  // which the activity evaluates: compile would turn the author's text into code.
126
- if (typeof spec.body === 'string' && !spec.body.startsWith('=') && !parsesAsJson(spec.body))
126
+ if (typeof spec.body === 'string' && !spec.body.startsWith('=') && !isWholeTaskOutputMarker(spec.body) && !parsesAsJson(spec.body))
127
127
  return {
128
128
  code: 'HTTP_REQUEST_BODY_FORM',
129
129
  message: `${owner} body is neither JSON nor an \`=\` expression. The activity evaluates its body as JavaScript, so the text would be written as code.`,
130
- suggestion: 'Pass the body as an object, JSON text, or an expression such as `=js:vars.payload`.',
130
+ suggestion: 'Pass the body as an object, JSON text, a `taskOutput()`, or an expression such as `=js:vars.payload`.',
131
131
  };
132
132
  if (spec.body !== undefined && typeof spec.body !== 'string') {
133
133
  const leaf = unlowerableLeaf(spec.body);
@@ -154,19 +154,6 @@ const parsesAsJson = (text) => {
154
154
  };
155
155
  /** A dotted reference such as `vars.customer.id`: JavaScript as written. */
156
156
  const REFERENCE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/;
157
- /** Property reads after a reference: `.field.sub`. */
158
- const DOTTED_TAIL = /^(?:\.[A-Za-z_$][\w$]*)*$/;
159
- /**
160
- * Whether `text` is exactly one `taskOutput()` marker (`vars.$xref('S','T','body')`),
161
- * optionally followed by property reads. It is a reference once lowered: the
162
- * whole plan's markers are lowered to `vars.<output id>` after the body is
163
- * written (`lowerPlanTaskOutputRefs` in `serialize.ts`), so the activity never
164
- * sees `$xref`.
165
- */
166
- function isTaskOutputReference(text) {
167
- const refs = taskOutputRefs(text);
168
- return refs.length === 1 && refs[0].index === 0 && DOTTED_TAIL.test(text.slice(refs[0].whole.length));
169
- }
170
157
  /**
171
158
  * `code` parenthesized as one JavaScript expression, `(<code>\n)`, or
172
159
  * `undefined` when it is not exactly one. The parentheses close on a new line,
@@ -215,14 +202,17 @@ function oneExpression(code) {
215
202
  * (`HTTP_REQUEST_BODY_EXPRESSION`).
216
203
  */
217
204
  function leafCode(value) {
205
+ // A bare marker is lowered to `vars.<id>` over the finished plan (`lowerPlanTaskOutputRefs`).
206
+ if (isWholeTaskOutputMarker(value))
207
+ return value;
218
208
  if (value.startsWith('=js:')) {
219
209
  const code = value.slice('=js:'.length).trim();
220
210
  return code === '' ? undefined : oneExpression(code);
221
211
  }
222
212
  const reference = value.slice(1).trim();
223
- return REFERENCE.test(reference) || isTaskOutputReference(reference) ? reference : undefined;
213
+ return REFERENCE.test(reference) || isWholeTaskOutputMarker(reference) ? reference : undefined;
224
214
  }
225
- const isExpressionLeaf = (value) => typeof value === 'string' && value.startsWith('=');
215
+ const isExpressionLeaf = (value) => typeof value === 'string' && (value.startsWith('=') || isWholeTaskOutputMarker(value));
226
216
  const childrenOf = (value) => Array.isArray(value) ? value : typeof value === 'object' && value !== null ? Object.values(value) : [];
227
217
  function hasExpressionLeaf(value) {
228
218
  return isExpressionLeaf(value) || childrenOf(value).some(hasExpressionLeaf);
@@ -276,8 +266,8 @@ export function httpRequestLint(owner, spec) {
276
266
  message: `${owner} names no connector, so it calls url directly, and has none.`,
277
267
  suggestion: "Pass url (for example url: 'https://api.example.com/items'), or connector: { key, connection, folder } with a path.",
278
268
  });
279
- // A literal value is the secret itself, written into the plan; an `=` value is read at run time.
280
- const literalCredential = (fields, names) => Object.entries(isObjectOfText(fields) ? fields : {}).find(([k, v]) => names.has(k.toLowerCase()) && !v.startsWith('='))?.[0];
269
+ // A literal value is the secret itself, written into the plan; an `=` value or a `taskOutput()` is read at run time.
270
+ const literalCredential = (fields, names) => Object.entries(isObjectOfText(fields) ? fields : {}).find(([k, v]) => names.has(k.toLowerCase()) && !v.startsWith('=') && !isWholeTaskOutputMarker(v))?.[0];
281
271
  const credentials = [
282
272
  ['header', literalCredential(spec.headers, CREDENTIAL_HEADERS)],
283
273
  ['query parameter', literalCredential(spec.query, CREDENTIAL_QUERY_KEYS)],
@@ -2,8 +2,9 @@
2
2
  * Reference-mode task kinds: a task that runs a separately published artifact
3
3
  * (a process, agent, RPA or API workflow, ...) and binds its arguments with
4
4
  * `.inputs()` / `.outputs()`. The artifact's result fields are at the top of
5
- * its result, so an extract reads `=<Field>`, not the connector form
6
- * `=response.<field>` (builder-sdk#1565). Shared by the builder (which kinds
5
+ * its result, so an extract reads `=<Field>` (`=<Argument>.<field>` for an
6
+ * object argument), not the connector form `=response.<field>` unless the
7
+ * argument itself is named `response` (builder-sdk#1565). Shared by the builder (which kinds
7
8
  * take `.inputs()`) and `check` (REFERENCE_OUTPUT_SOURCE).
8
9
  */
9
10
  import type { TaskKind } from './case-sdk.js';
@@ -47,7 +47,7 @@ import { SCRIPT_INPUTS, scriptOutputMappings, scriptOutputs, storedScript } from
47
47
  import { DOCUMENT_EXTRACTION_NAME, DOCUMENT_EXTRACTION_RESOURCE, DOCUMENT_EXTRACTION_SERVICE_TYPE, DOCUMENT_EXTRACTION_VERSION, documentExtractionContext, documentExtractionInputs, documentExtractionOutputMappings, documentExtractionOutputs, documentExtractionRefusal, } from './document-extraction.js';
48
48
  import { HTTP_REQUEST_CONNECTION_NAME, HTTP_REQUEST_IMPLICIT_BINDING_ID, HTTP_REQUEST_IMPLICIT_CONNECTION, HTTP_REQUEST_SERVICE_TYPE, httpRequestBody, httpRequestContext, httpRequestInputs, httpRequestOutputMappings, httpRequestOutputs, httpRequestRefusal, writeHttpRequestMetadata, } from './http-request.js';
49
49
  import { connectorPlaceholderData, connectorPlaceholderKindOf, isConnectorPlaceholder } from './connector-placeholder.js';
50
- import { lowerTaskOutputRefs, planTaskOutputs, resolveInPlan, unresolvedTaskOutputRef } from './task-output-ref.js';
50
+ import { isWholeTaskOutputMarker, lowerTaskOutputRefs, taskOutputRefs, planTaskOutputs, resolveInPlan, unresolvedTaskOutputRef } from './task-output-ref.js';
51
51
  import { applyCustomRowShape } from './custom-output-shape.js';
52
52
  /** The ids a serialize pass hashed from element ids, by the document it returned. */
53
53
  const ELEMENT_SEEDED_IDS = new WeakMap();
@@ -456,7 +456,7 @@ function serializeCase(built, opts) {
456
456
  */
457
457
  function lowerPlanTaskOutputRefs(plan) {
458
458
  let tasks;
459
- const lower = (text) => lowerTaskOutputRefs(text, (ref) => {
459
+ const lowerText = (text) => lowerTaskOutputRefs(text, (ref) => {
460
460
  tasks ??= planTaskOutputs(plan);
461
461
  const resolved = resolveInPlan(tasks, ref);
462
462
  if ('why' in resolved)
@@ -465,6 +465,17 @@ function lowerPlanTaskOutputRefs(plan) {
465
465
  // left, and the stood-in task's own refusal is what `check` reports.
466
466
  return 'standIn' in resolved ? undefined : resolved.variable;
467
467
  });
468
+ // A bare marker as a whole value (`<- "S"."T".out`) is a reference, so it gets
469
+ // the `=` a literal `vars.<id>` would lack, as `sdd convert` writes it:
470
+ // `=vars.<id>`, or with property reads `=js:vars.<id>?.field` (strict validate
471
+ // accepts no other bare `=` form, and `?.` reads empty while the producer has
472
+ // not run). An author's own `=` value is left as written.
473
+ const lower = (text) => {
474
+ const lowered = lowerText(text);
475
+ if (lowered === text || !isWholeTaskOutputMarker(text))
476
+ return lowered;
477
+ return taskOutputRefs(text)[0].whole.length === text.length ? `=${lowered}` : lowerText(`=js:${text}`);
478
+ };
468
479
  const walk = (value) => {
469
480
  if (typeof value === 'string')
470
481
  return value.includes('$xref') ? lower(value) : value;