@uipath/maestro-builder-sdk 6.120.7 → 6.120.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/case/connector-saved-context.js +6 -2
- package/dist/case/connector-saved-rows.d.ts +7 -0
- package/dist/case/connector-saved-rows.js +26 -10
- package/dist/case/decompile.d.ts +4 -0
- package/dist/case/decompile.js +35 -3
- package/dist/case/preserve.d.ts +28 -1
- package/dist/case/preserve.js +11 -0
- package/dist/case/serialize.js +46 -1
- package/dist/case/subscription.d.ts +21 -0
- package/dist/case/subscription.js +39 -0
- package/package.json +2 -2
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* for `parentFolderId` keeps both while the source still filters on that
|
|
35
35
|
* folder. Point it at another folder and compile writes its own body.
|
|
36
36
|
*/
|
|
37
|
-
import { caseSubscriptionOwners } from './subscription.js';
|
|
37
|
+
import { caseSubscriptionOwners, withScopeExpression } from './subscription.js';
|
|
38
38
|
const CONNECTOR_ACTIVITY_TYPE = 'execute-connector-activity';
|
|
39
39
|
/**
|
|
40
40
|
* Every connector element in a plan with the bag that holds its `context`:
|
|
@@ -180,7 +180,11 @@ export function savedConnectorContext(owner, bag) {
|
|
|
180
180
|
return undefined;
|
|
181
181
|
if (sdkShaped(bag, context))
|
|
182
182
|
return undefined;
|
|
183
|
-
|
|
183
|
+
const inputs = inputValues(bag);
|
|
184
|
+
// A subscription body saved with no match expression compares as compile writes it.
|
|
185
|
+
if (EVENT_SERVICE_TYPES.has(bag.serviceType) && inputs.body !== undefined)
|
|
186
|
+
inputs.body = withScopeExpression(inputs.body, owner);
|
|
187
|
+
return { owner, context: structuredClone(context), inputs };
|
|
184
188
|
}
|
|
185
189
|
/** Whether a wire `activityType` is a generic CRUD one (`Generic`, `GenericExpanded`, `GenericTrigger`). */
|
|
186
190
|
const isGenericKind = (activityType) => activityType.startsWith('Generic');
|
|
@@ -15,6 +15,13 @@ export interface PreservedExtractShape {
|
|
|
15
15
|
fields?: Record<string, unknown>;
|
|
16
16
|
/** The row was saved with no `target`. */
|
|
17
17
|
omit?: ['target'];
|
|
18
|
+
/**
|
|
19
|
+
* The row's saved `target`, when it names neither the row's id nor its
|
|
20
|
+
* variable: a copied task keeps the `target` of the row it was copied from
|
|
21
|
+
* (`target: '=id15'` on the row `{ id: 'id16', var: 'id16' }`). The row's
|
|
22
|
+
* `var` decides what it writes, so the target is the Designer's spelling.
|
|
23
|
+
*/
|
|
24
|
+
target?: string;
|
|
18
25
|
}
|
|
19
26
|
/** One saved connector element's own rows, as `preserveCaseJson` carries them. */
|
|
20
27
|
export interface PreservedConnectorRows {
|
|
@@ -49,15 +49,16 @@
|
|
|
49
49
|
*
|
|
50
50
|
* The author's extracts (`.outputs({ createdById: '=response.CreatedBy.Id' })`)
|
|
51
51
|
* are compile's to write, but the Designer saves them with a field compile
|
|
52
|
-
* does not write (`displayName: 'CreatedBy.Id'`) and without one it does
|
|
53
|
-
* (`target`)
|
|
52
|
+
* does not write (`displayName: 'CreatedBy.Id'`), and without one it does
|
|
53
|
+
* (`target`) or with a stale one (`target: '=id15'` on the row `id16`, kept
|
|
54
|
+
* from the task it was copied from). `extracts` records that difference per extract, keyed by the
|
|
54
55
|
* `source` it reads and the `var` it writes, and compile puts it back on the
|
|
55
56
|
* row that still reads that source into that variable, while the element calls
|
|
56
57
|
* the same operation. An extract the author edits (another source or
|
|
57
58
|
* variable) gets compile's row.
|
|
58
59
|
*/
|
|
59
60
|
import { comparesContextRow } from './connector-saved-context.js';
|
|
60
|
-
import { caseSubscriptionOwners } from './subscription.js';
|
|
61
|
+
import { caseSubscriptionOwners, withScopeExpression } from './subscription.js';
|
|
61
62
|
const CONNECTOR_ACTIVITY_TYPE = 'execute-connector-activity';
|
|
62
63
|
/** The context rows that name the operation an element calls. */
|
|
63
64
|
const OPERATION_ROWS = ['connectorKey', 'objectName', 'method', 'path', 'operation'];
|
|
@@ -199,7 +200,7 @@ function savedOutputs(bag, elementIds) {
|
|
|
199
200
|
return { rows: structuredClone(rows), ...(bag.outputs === undefined ? { absent: true } : {}) };
|
|
200
201
|
}
|
|
201
202
|
/** The saved inputs half, when compile would not write it as it is. */
|
|
202
|
-
function savedInputs(bag, activity, elementIds) {
|
|
203
|
+
function savedInputs(bag, activity, elementIds, owner) {
|
|
203
204
|
if (bag.inputs !== undefined && !Array.isArray(bag.inputs))
|
|
204
205
|
return undefined;
|
|
205
206
|
const rows = bag.inputs ?? [];
|
|
@@ -212,7 +213,11 @@ function savedInputs(bag, activity, elementIds) {
|
|
|
212
213
|
const complete = activity ? ACTIVITY_CONTAINERS.every((name) => names.has(name)) : rows.length === 1;
|
|
213
214
|
if (bag.inputs !== undefined && complete && rows.every((row) => sdkShapedInput(row, elementIds)))
|
|
214
215
|
return undefined;
|
|
215
|
-
|
|
216
|
+
// A subscription body saved with no match expression is carried as compile
|
|
217
|
+
// writes it (`withScopeExpression`): the engine needs the expression.
|
|
218
|
+
const carried = structuredClone(rows).map((row) => (!activity && row.name === 'body' && row.body !== undefined
|
|
219
|
+
? { ...row, body: withScopeExpression(row.body, owner) } : row));
|
|
220
|
+
return { rows: carried, ...(bag.inputs === undefined ? { absent: true } : {}) };
|
|
216
221
|
}
|
|
217
222
|
/**
|
|
218
223
|
* The saved own rows of a connector element, for each half compile would not
|
|
@@ -226,7 +231,7 @@ export function savedConnectorRows(owner, bag, elementIds) {
|
|
|
226
231
|
return undefined;
|
|
227
232
|
const activity = bag.serviceType !== 'Intsvc.EventTrigger' && bag.serviceType !== 'Intsvc.WaitForEvent';
|
|
228
233
|
const outputs = savedOutputs(bag, elementIds);
|
|
229
|
-
const inputs = savedInputs(bag, activity, elementIds);
|
|
234
|
+
const inputs = savedInputs(bag, activity, elementIds, owner);
|
|
230
235
|
const extracts = savedExtracts(bag);
|
|
231
236
|
if (!outputs && !inputs && !extracts)
|
|
232
237
|
return undefined;
|
|
@@ -261,9 +266,16 @@ function savedExtracts(bag) {
|
|
|
261
266
|
continue;
|
|
262
267
|
const fields = Object.fromEntries(Object.entries(row).filter(([key]) => !EXTRACT_WRITTEN_FIELDS.has(key)).map(([key, value]) => [key, structuredClone(value)]));
|
|
263
268
|
const omit = row.target === undefined;
|
|
264
|
-
|
|
269
|
+
// Compile writes `target: "=<id>"`; an own-name extract's id is its variable.
|
|
270
|
+
const target = typeof row.target === 'string' && row.target !== `=${row.id}` && row.target !== `=${row.var}` ? row.target : undefined;
|
|
271
|
+
if (!Object.keys(fields).length && !omit && target === undefined)
|
|
265
272
|
continue;
|
|
266
|
-
out.push({
|
|
273
|
+
out.push({
|
|
274
|
+
source: row.source, var: row.var,
|
|
275
|
+
...(Object.keys(fields).length ? { fields } : {}),
|
|
276
|
+
...(omit ? { omit: ['target'] } : {}),
|
|
277
|
+
...(target !== undefined ? { target } : {}),
|
|
278
|
+
});
|
|
267
279
|
}
|
|
268
280
|
return out.length ? out : undefined;
|
|
269
281
|
}
|
|
@@ -280,6 +292,9 @@ function extractsBack(bag, shapes) {
|
|
|
280
292
|
row[key] = structuredClone(value);
|
|
281
293
|
if (shape.omit?.includes('target'))
|
|
282
294
|
delete row.target;
|
|
295
|
+
// Only over the target compile writes, so an id compile changed keeps its own.
|
|
296
|
+
else if (shape.target !== undefined && row.target === `=${row.id}`)
|
|
297
|
+
row.target = shape.target;
|
|
283
298
|
}
|
|
284
299
|
}
|
|
285
300
|
/**
|
|
@@ -446,11 +461,12 @@ export function connectorRowErrors(entries) {
|
|
|
446
461
|
const { extracts } = entry;
|
|
447
462
|
if (extracts !== undefined) {
|
|
448
463
|
const shapeOk = (shape) => isObject(shape) && typeof shape.source === 'string' && /^=(?:response|Error)[.[]/.test(shape.source)
|
|
449
|
-
&& typeof shape.var === 'string' && Object.keys(shape).every((key) => ['source', 'var', 'fields', 'omit'].includes(key))
|
|
464
|
+
&& typeof shape.var === 'string' && Object.keys(shape).every((key) => ['source', 'var', 'fields', 'omit', 'target'].includes(key))
|
|
465
|
+
&& (shape.target === undefined || (typeof shape.target === 'string' && shape.target.startsWith('=') && shape.omit === undefined))
|
|
450
466
|
&& (shape.fields === undefined || (isObject(shape.fields) && Object.keys(shape.fields).every((key) => !EXTRACT_WRITTEN_FIELDS.has(key))))
|
|
451
467
|
&& (shape.omit === undefined || (Array.isArray(shape.omit) && shape.omit.length === 1 && shape.omit[0] === 'target'));
|
|
452
468
|
if (!Array.isArray(extracts) || !extracts.every(shapeOk))
|
|
453
|
-
errors.push(`preserved connector rows "${owner}" extracts must each name a source and a var, with only fields compile does not write and omit ["target"]`);
|
|
469
|
+
errors.push(`preserved connector rows "${owner}" extracts must each name a source and a var, with only fields compile does not write, and omit ["target"] or a "=" target`);
|
|
454
470
|
else if (new Set(extracts.map(extractKey)).size !== extracts.length)
|
|
455
471
|
errors.push(`preserved connector rows "${owner}" extracts name a source and var twice`);
|
|
456
472
|
}
|
package/dist/case/decompile.d.ts
CHANGED
|
@@ -283,6 +283,10 @@ type Preservation = {
|
|
|
283
283
|
connectorContexts?: PreservedConnectorContext[];
|
|
284
284
|
connectorConfigV2?: string[];
|
|
285
285
|
connectorRows?: PreservedConnectorRows[];
|
|
286
|
+
subscriptionBindings?: Array<{
|
|
287
|
+
owner: string;
|
|
288
|
+
bindings: Array<Record<string, unknown>>;
|
|
289
|
+
}>;
|
|
286
290
|
subscriptionFilters?: Array<{
|
|
287
291
|
owner: string;
|
|
288
292
|
expression?: 'inline';
|
package/dist/case/decompile.js
CHANGED
|
@@ -743,9 +743,9 @@ const ACTION_DATA_KEYS = new Set([
|
|
|
743
743
|
*/
|
|
744
744
|
const ACTION_INPUT_ROW_KEYS = new Set([
|
|
745
745
|
'name', 'type', 'subType', 'displayName', 'value', 'required', 'options', 'body', 'source', 'id', 'var', 'elementId',
|
|
746
|
-
'canonicalId',
|
|
746
|
+
'canonicalId', 'target',
|
|
747
747
|
]);
|
|
748
|
-
const ACTION_OUTPUT_ROW_KEYS = new Set([...ACTION_INPUT_ROW_KEYS, '
|
|
748
|
+
const ACTION_OUTPUT_ROW_KEYS = new Set([...ACTION_INPUT_ROW_KEYS, 'originalVar', '_jsonSchema', 'jsonSchema']
|
|
749
749
|
.filter((key) => key !== 'canonicalId'));
|
|
750
750
|
function actionFields(rows, side, owner) {
|
|
751
751
|
if (!rows?.length)
|
|
@@ -761,6 +761,11 @@ function actionFields(rows, side, owner) {
|
|
|
761
761
|
// stamps on a row (and then skips it on); it is carried only as a copy of
|
|
762
762
|
// the id (`actionInputShape`), since any other value renames how the
|
|
763
763
|
// Designer spells references to the row.
|
|
764
|
+
// An input's `target` is the slot Studio Web says it fills (`"bodyField"`, the
|
|
765
|
+
// HITL task arguments); nothing reads it to run the case, so it is carried
|
|
766
|
+
// verbatim (`actionInputShape`), as long as it is a string.
|
|
767
|
+
if (side === 'input' && row.target !== undefined && typeof row.target !== 'string')
|
|
768
|
+
throw new Error(`${owner} form input "${row.name ?? '?'}" has a non-string target ${JSON.stringify(row.target)}.`);
|
|
764
769
|
if (side === 'input' && row.canonicalId !== undefined && (row.id === undefined || row.canonicalId !== row.id))
|
|
765
770
|
throw new Error(`${owner} form input "${row.name ?? '?'}" has canonicalId "${String(row.canonicalId)}", which is not its id.`);
|
|
766
771
|
if (row.var !== undefined && side === 'input' && row.var !== row.id)
|
|
@@ -2347,6 +2352,17 @@ function ruleInputIdentity(inputs) {
|
|
|
2347
2352
|
return {};
|
|
2348
2353
|
return { inputs: rows.map((row) => ({ name: typeof row?.name === 'string' ? row.name : '', ...(typeof row?.id === 'string' ? { id: row.id } : {}) })) };
|
|
2349
2354
|
}
|
|
2355
|
+
/**
|
|
2356
|
+
* What a task entry condition was saved with that the builder does not author:
|
|
2357
|
+
* `isInterrupting` (the platform reads it on stage conditions only) and the
|
|
2358
|
+
* absence of a `displayName` (compile derives `"<task> entry"`).
|
|
2359
|
+
*/
|
|
2360
|
+
function taskEntryConditionShape(condition) {
|
|
2361
|
+
return {
|
|
2362
|
+
...(typeof condition.isInterrupting === 'boolean' ? { isInterrupting: condition.isInterrupting } : {}),
|
|
2363
|
+
...(condition.displayName === undefined ? { noDisplayName: true } : {}),
|
|
2364
|
+
};
|
|
2365
|
+
}
|
|
2350
2366
|
function slaIdentity(sla) {
|
|
2351
2367
|
return {
|
|
2352
2368
|
...(sla.id ? { id: sla.id } : {}),
|
|
@@ -2430,10 +2446,14 @@ function prunePreservation(preservation, plan) {
|
|
|
2430
2446
|
* writes such a row with no `elementId`, so it is recorded even when the
|
|
2431
2447
|
* task's `elementId` is the `<stageId>-<taskId>` compile writes. Any other
|
|
2432
2448
|
* `elementId` is carried as the value itself.
|
|
2449
|
+
* - A `target` (`"bodyField"`) is carried on any row, e.g. the Designer's
|
|
2450
|
+
* { name: 'note', type: 'string', target: 'bodyField', value: '=vars.note' }
|
|
2451
|
+
* records `{ name: 'note', target: 'bodyField' }`.
|
|
2433
2452
|
*/
|
|
2434
2453
|
function actionInputShape(task, row) {
|
|
2435
2454
|
if (task.type !== 'action')
|
|
2436
2455
|
return {};
|
|
2456
|
+
const target = typeof row.target === 'string' ? { target: row.target } : {};
|
|
2437
2457
|
const omit = [];
|
|
2438
2458
|
if (row.type === undefined)
|
|
2439
2459
|
omit.push('type');
|
|
@@ -2442,6 +2462,7 @@ function actionInputShape(task, row) {
|
|
|
2442
2462
|
return {
|
|
2443
2463
|
...(own ? { taskElementId: true } : row.elementId !== undefined ? { elementId: row.elementId } : {}),
|
|
2444
2464
|
...(omit.length ? { omit } : {}),
|
|
2465
|
+
...target,
|
|
2445
2466
|
};
|
|
2446
2467
|
}
|
|
2447
2468
|
if (row.var === undefined)
|
|
@@ -2453,6 +2474,7 @@ function actionInputShape(task, row) {
|
|
|
2453
2474
|
// `actionFields` has checked it is a copy of the id.
|
|
2454
2475
|
...(row.canonicalId !== undefined ? { canonicalId: true } : {}),
|
|
2455
2476
|
...(omit.length ? { omit } : {}),
|
|
2477
|
+
...target,
|
|
2456
2478
|
};
|
|
2457
2479
|
}
|
|
2458
2480
|
/**
|
|
@@ -2622,7 +2644,10 @@ function identityPreservation(plan) {
|
|
|
2622
2644
|
name: taskSourceName(task),
|
|
2623
2645
|
...(task.id ? { id: task.id } : {}),
|
|
2624
2646
|
...savedTaskElementId(stage, task),
|
|
2625
|
-
entryConditions: (task.entryConditions ?? []).map(
|
|
2647
|
+
entryConditions: (task.entryConditions ?? []).map((condition, index, list) => ({
|
|
2648
|
+
...conditionIdentity(condition, index, list),
|
|
2649
|
+
...taskEntryConditionShape(condition),
|
|
2650
|
+
})),
|
|
2626
2651
|
...emptyLists(task, TASK_EMPTY_LISTS),
|
|
2627
2652
|
inputs: (task.data?.inputs ?? []).map((row) => ({ name: row.name ?? '', ...(row.id ? { id: row.id } : {}), ...actionInputShape(task, row), ...resourceRowShape(task, row, 'inputs'), ...rowHoldsSavedTaskElementId(stage, task, row) })),
|
|
2628
2653
|
outputs: (task.data?.outputs ?? []).map((row) => ({
|
|
@@ -3044,6 +3069,13 @@ export function collectPreservation(plan) {
|
|
|
3044
3069
|
.filter((entry) => entry !== undefined);
|
|
3045
3070
|
if (connectorRows.length)
|
|
3046
3071
|
preservation.connectorRows = connectorRows;
|
|
3072
|
+
// A subscription's own non-empty `bindings` (copies of the root Property rows
|
|
3073
|
+
// its filter reads), which compile writes empty (preserve.ts).
|
|
3074
|
+
const subscriptionBindings = caseSubscriptionOwners(plan)
|
|
3075
|
+
.filter(({ bag }) => Array.isArray(bag.bindings) && bag.bindings.length > 0)
|
|
3076
|
+
.map(({ key, bag }) => ({ owner: key, bindings: structuredClone(bag.bindings) }));
|
|
3077
|
+
if (subscriptionBindings.length)
|
|
3078
|
+
preservation.subscriptionBindings = subscriptionBindings;
|
|
3047
3079
|
const subscriptionFilterEntries = preservedSubscriptionFilters(plan);
|
|
3048
3080
|
if (subscriptionFilterEntries.length)
|
|
3049
3081
|
preservation.subscriptionFilters = subscriptionFilterEntries;
|
package/dist/case/preserve.d.ts
CHANGED
|
@@ -159,6 +159,19 @@ export interface PreservedActionDataFields extends PreservedTaskRef {
|
|
|
159
159
|
}
|
|
160
160
|
interface ConditionIdentity {
|
|
161
161
|
id?: string;
|
|
162
|
+
/**
|
|
163
|
+
* A task entry condition's saved `isInterrupting`. Studio Web writes it on
|
|
164
|
+
* some task entry conditions; the platform reads it only on a stage's
|
|
165
|
+
* (`cancelStagesAndTasks`), so the builder has no task option for it and it
|
|
166
|
+
* rides in the payload. Ignored on any other condition.
|
|
167
|
+
*/
|
|
168
|
+
isInterrupting?: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* The task entry condition was saved with no `displayName`. Compile names
|
|
171
|
+
* every condition (`"<task> entry"`); the name goes again while the source
|
|
172
|
+
* still gives the condition none (the name compile wrote is the derived one).
|
|
173
|
+
*/
|
|
174
|
+
noDisplayName?: true;
|
|
162
175
|
/** The Designer's ids of the canvas edges drawn for the condition. */
|
|
163
176
|
edgeIds?: string[];
|
|
164
177
|
/**
|
|
@@ -235,13 +248,14 @@ interface StageIdentity {
|
|
|
235
248
|
entryConditions?: ConditionIdentity[];
|
|
236
249
|
/** The resource the rows' `fields` / `omit` describe; they are applied only while the task still names it. */
|
|
237
250
|
resource?: ResourceTaskIdentity;
|
|
238
|
-
/** `elementId` only for an action form input whose row names another element than its task. `canonicalId: true`: an action form input saved with the schema migration's `canonicalId`, a copy of its id. `fields`: a resource task row's Designer fields compile does not write (`displayName`, `title`, `body`, ...). */
|
|
251
|
+
/** `elementId` only for an action form input whose row names another element than its task. `canonicalId: true`: an action form input saved with the schema migration's `canonicalId`, a copy of its id. `target`: the slot an action form input was saved with (`"bodyField"`), which compile does not write. `fields`: a resource task row's Designer fields compile does not write (`displayName`, `title`, `body`, ...). */
|
|
239
252
|
/** `omit` on an action form input: the fields compile writes that it was saved without (`type`; `var`, `elementId` on a row with an id). `taskElementId: true`: the row was saved with its task's `elementId`; compile writes back the task's final `elementId` (see `elementId` above). An action form input with no id, which compile writes with no `elementId`, carries it whenever its `elementId` is the task's. */
|
|
240
253
|
inputs?: Array<{
|
|
241
254
|
name: string;
|
|
242
255
|
id?: string;
|
|
243
256
|
elementId?: string;
|
|
244
257
|
canonicalId?: true;
|
|
258
|
+
target?: string;
|
|
245
259
|
fields?: Record<string, unknown>;
|
|
246
260
|
omit?: string[];
|
|
247
261
|
taskElementId?: true;
|
|
@@ -502,6 +516,19 @@ export interface CaseJsonPreservation {
|
|
|
502
516
|
* (`case/connector-saved-rows.ts`).
|
|
503
517
|
*/
|
|
504
518
|
connectorRows?: PreservedConnectorRows[];
|
|
519
|
+
/**
|
|
520
|
+
* A subscription's own `bindings` (a wait-for-connector task or rule, an
|
|
521
|
+
* event trigger), saved non-empty, keyed by owner (`task:<stageId>:<taskId>`).
|
|
522
|
+
* Studio Web copies there the root `Property` binding rows its filter reads
|
|
523
|
+
* (`{ id, resource: 'Property', resourceKey: '<stageId>-<taskId>',
|
|
524
|
+
* propertyAttribute: 'entityScope', ... }`); compile writes `bindings: []`.
|
|
525
|
+
* Compile writes back each saved row whose id the subscription still reads
|
|
526
|
+
* (`=bindings.<id>`), and only where it wrote the list empty.
|
|
527
|
+
*/
|
|
528
|
+
subscriptionBindings?: Array<{
|
|
529
|
+
owner: string;
|
|
530
|
+
bindings: Array<Record<string, unknown>>;
|
|
531
|
+
}>;
|
|
505
532
|
/**
|
|
506
533
|
* Action tasks' Designer-owned `data` fields: the `context` rows the Designer
|
|
507
534
|
* saves with a form (its `hitlType`, quick-form schema ids, and a copy of the
|
package/dist/case/preserve.js
CHANGED
|
@@ -385,6 +385,11 @@ export function caseJsonPreservationErrors(payload) {
|
|
|
385
385
|
errors.push(`task "${task.name}" ${side} "${row.name}" omits "${String(field)}", which is not an omittable field`);
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
+
for (const stage of payload.identities?.stages ?? [])
|
|
389
|
+
for (const task of (stage.tasks ?? []).flat())
|
|
390
|
+
for (const row of task.inputs ?? [])
|
|
391
|
+
if (row.target !== undefined && typeof row.target !== 'string')
|
|
392
|
+
errors.push(`task "${task.name}" input "${row.name}" target must be a string`);
|
|
388
393
|
for (const stage of payload.identities?.stages ?? [])
|
|
389
394
|
for (const task of (stage.tasks ?? []).flat())
|
|
390
395
|
for (const row of task.outputs ?? []) {
|
|
@@ -489,6 +494,12 @@ export function caseJsonPreservationErrors(payload) {
|
|
|
489
494
|
&& (!Array.isArray(payload.connectorConfigV2) || payload.connectorConfigV2.some((key) => typeof key !== 'string' || !key)))
|
|
490
495
|
errors.push('preserved connectorConfigV2 must be a list of connector element keys (task:<id>, rule:<id> or trigger:<id>)');
|
|
491
496
|
errors.push(...connectorRowErrors(payload.connectorRows));
|
|
497
|
+
for (const entry of payload.subscriptionBindings ?? []) {
|
|
498
|
+
if (typeof entry?.owner !== 'string' || !/^(trigger|task|rule):/.test(entry.owner))
|
|
499
|
+
errors.push(`preserved subscription bindings owner ${JSON.stringify(entry?.owner)} is not a trigger, task or rule key`);
|
|
500
|
+
else if (!Array.isArray(entry.bindings) || !entry.bindings.every((row) => row !== null && typeof row === 'object' && !Array.isArray(row) && typeof row.id === 'string' && row.id !== ''))
|
|
501
|
+
errors.push(`preserved subscription bindings of "${entry.owner}" must be binding rows with an id`);
|
|
502
|
+
}
|
|
492
503
|
for (const index of payload.manualTriggerServiceTypeNone ?? [])
|
|
493
504
|
if (!Number.isInteger(index) || index < 0)
|
|
494
505
|
errors.push(`manual trigger position "${index}" is not a non-negative integer`);
|
package/dist/case/serialize.js
CHANGED
|
@@ -555,6 +555,7 @@ export function applyPreservation(result, preservation, options = {}) {
|
|
|
555
555
|
applySubscriptionFilters(result, preservation);
|
|
556
556
|
// After the ids are restored: an unchanged connector element takes its saved own io rows.
|
|
557
557
|
applyConnectorRows(result, preservation.connectorRows);
|
|
558
|
+
applySubscriptionBindings(result, preservation.subscriptionBindings);
|
|
558
559
|
// Last, once every row has its saved name and the connector rows are back.
|
|
559
560
|
restoreOutputInterleaving(result, preservation.identities);
|
|
560
561
|
Object.assign(result, preservation.topLevel ?? {});
|
|
@@ -1282,6 +1283,25 @@ function restoreNoTasks(data, spelling) {
|
|
|
1282
1283
|
else
|
|
1283
1284
|
data.tasks = [];
|
|
1284
1285
|
}
|
|
1286
|
+
/**
|
|
1287
|
+
* A task entry condition's saved `isInterrupting`, and the absence of a name
|
|
1288
|
+
* it was saved with (`ConditionIdentity`), by position. The name goes only
|
|
1289
|
+
* while it is the one compile derives for an unnamed condition, `"<task>
|
|
1290
|
+
* entry"` (with the suffix a repeat gets): a name the author typed stays.
|
|
1291
|
+
*/
|
|
1292
|
+
function restoreTaskEntryShape(task, wanted) {
|
|
1293
|
+
const conditions = Array.isArray(task?.entryConditions) ? task.entryConditions : [];
|
|
1294
|
+
const derived = new RegExp(`^${String(task?.displayName ?? '').replace(/[.*+?^${}()|[\]\\]/g, '\\$&')} entry( \\d+)?$`);
|
|
1295
|
+
(wanted ?? []).forEach((shape, index) => {
|
|
1296
|
+
const condition = conditions[index];
|
|
1297
|
+
if (!condition)
|
|
1298
|
+
return;
|
|
1299
|
+
if (typeof shape.isInterrupting === 'boolean' && condition.isInterrupting === undefined)
|
|
1300
|
+
condition.isInterrupting = shape.isInterrupting;
|
|
1301
|
+
if (shape.noDisplayName === true && typeof condition.displayName === 'string' && derived.test(condition.displayName))
|
|
1302
|
+
delete condition.displayName;
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1285
1305
|
/**
|
|
1286
1306
|
* Retry the output-id claims that found their carried id held by another row
|
|
1287
1307
|
* (`claimRowId` returned `false`), until none moves.
|
|
@@ -1736,6 +1756,7 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1736
1756
|
savedTaskElementIds.push({ stage, task, elementId: taskIdentity.elementId, rows: elementIdRows });
|
|
1737
1757
|
restoreEmptyLists(task, taskIdentity.emptyLists, TASK_EMPTY_LISTS);
|
|
1738
1758
|
takeConditions(task?.entryConditions, taskIdentity.entryConditions);
|
|
1759
|
+
restoreTaskEntryShape(task, taskIdentity.entryConditions);
|
|
1739
1760
|
// An input row is matched by name when the name is unique on both sides
|
|
1740
1761
|
// (an input the author removed leaves the rows after it in place), else
|
|
1741
1762
|
// by position.
|
|
@@ -1750,8 +1771,11 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1750
1771
|
if (input && row.taskElementId === true)
|
|
1751
1772
|
elementIdRows.saved.add(input);
|
|
1752
1773
|
// An action form input is written `{ name, type, value }`; the Designer's
|
|
1753
|
-
// row also has its id, `var` (the id) and `elementId`, which come back
|
|
1774
|
+
// row also has its id, `var` (the id) and `elementId`, which come back,
|
|
1775
|
+
// and the `target` it was saved with (`"bodyField"`), on any row.
|
|
1754
1776
|
if (task?.type === 'action' && input && input.id === undefined && input.name === row.name) {
|
|
1777
|
+
if (typeof row.target === 'string' && input.target === undefined)
|
|
1778
|
+
input.target = row.target;
|
|
1755
1779
|
// The fields the row was saved without: a `type` compile defaulted
|
|
1756
1780
|
// to `string` (a type the source spells stays, `string` included),
|
|
1757
1781
|
// and the `var` / `elementId` of a row with an id.
|
|
@@ -1967,6 +1991,27 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1967
1991
|
for (const { condition, edgeIds } of edgeLinked)
|
|
1968
1992
|
condition.edgeIds = [...edgeIds];
|
|
1969
1993
|
}
|
|
1994
|
+
/**
|
|
1995
|
+
* Write each subscription's saved own `bindings` back
|
|
1996
|
+
* ({@link CaseJsonPreservation.subscriptionBindings}), after the ids are
|
|
1997
|
+
* restored, so an owner key names the same element. Only where compile wrote
|
|
1998
|
+
* the list empty, and only the rows the subscription still reads
|
|
1999
|
+
* (`=bindings.<id>` anywhere in it): an edit that drops a filter drops its row.
|
|
2000
|
+
*/
|
|
2001
|
+
function applySubscriptionBindings(result, entries) {
|
|
2002
|
+
if (!entries?.length)
|
|
2003
|
+
return;
|
|
2004
|
+
const byOwner = new Map(entries.map((entry) => [entry.owner, entry.bindings]));
|
|
2005
|
+
for (const { key, bag } of caseSubscriptionOwners(result)) {
|
|
2006
|
+
const saved = byOwner.get(key);
|
|
2007
|
+
if (!saved || !Array.isArray(bag.bindings) || bag.bindings.length !== 0)
|
|
2008
|
+
continue;
|
|
2009
|
+
const text = JSON.stringify({ ...bag, bindings: undefined });
|
|
2010
|
+
const read = saved.filter((row) => new RegExp(`bindings\\.${String(row.id).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![\\w$])`).test(text));
|
|
2011
|
+
if (read.length)
|
|
2012
|
+
bag.bindings = read.map((row) => structuredClone(row));
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
1970
2015
|
/** Every condition and rule id in a plan: the conditions under `entryConditions`, `exitConditions` and `caseExitRules`, and their rules. */
|
|
1971
2016
|
function conditionAndRuleIds(plan) {
|
|
1972
2017
|
const ids = new Set();
|
|
@@ -110,6 +110,27 @@ export declare const CASE_FILTER_SPELLING: CaseFilterSpelling;
|
|
|
110
110
|
* // { filters: { expression: "=js:(`((Id=='{var_0}'))`)", variables: { var_0: '=js:(vars.request.Id)' } } }
|
|
111
111
|
*/
|
|
112
112
|
export declare function caseSubscriptionBody(rc: ResolvedConnector, where: Record<string, unknown>, conditions: readonly ReadEventFilter[], elementId: string, spelling?: CaseFilterSpelling): Record<string, unknown> | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* A saved subscription `body` with event parameters in `queryParams` and no
|
|
115
|
+
* `filters`, as compile writes it back: with the match expression those
|
|
116
|
+
* parameters give (`filters: { expression: "(k == 'v') && ..." }`), first, as
|
|
117
|
+
* {@link caseSubscriptionBody} orders it. Any other body comes back as it is.
|
|
118
|
+
*
|
|
119
|
+
* Such a body is what the SDK wrote before it wrote the expression (one Studio
|
|
120
|
+
* Web plan in the brownfield corpus has it too). The engine reads only
|
|
121
|
+
* `filters.expression` to match an event, so decompile reads the body back and
|
|
122
|
+
* compile adds the expression (`checkSubscriptionExpression` in decompile.ts).
|
|
123
|
+
* The carries that keep a saved element while it is unchanged
|
|
124
|
+
* (`connector-saved-context.ts`, `connector-saved-rows.ts`) compare the input
|
|
125
|
+
* values compile writes with the saved ones; they record the saved body this
|
|
126
|
+
* way, so the added expression is not read as an edit that drops the element's
|
|
127
|
+
* saved context and rows.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* // { queryParams: { entityScope: 'tenant' } }
|
|
131
|
+
* // -> { filters: { expression: "(entityScope == 'tenant')" }, queryParams: { entityScope: 'tenant' } }
|
|
132
|
+
*/
|
|
133
|
+
export declare function withScopeExpression(body: unknown, owner: string): unknown;
|
|
113
134
|
/** One subscription in a Case plan: the bag that carries it, keyed by its owner. */
|
|
114
135
|
export interface CaseSubscriptionOwner {
|
|
115
136
|
/** `trigger:<node id>`, `task:<stage id>:<task id>` or `rule:<stage id>:<rule id>`. */
|
|
@@ -185,6 +185,45 @@ export function caseSubscriptionBody(rc, where, conditions, elementId, spelling
|
|
|
185
185
|
body.parameters = parameters;
|
|
186
186
|
return Object.keys(body).length ? body : undefined;
|
|
187
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* A saved subscription `body` with event parameters in `queryParams` and no
|
|
190
|
+
* `filters`, as compile writes it back: with the match expression those
|
|
191
|
+
* parameters give (`filters: { expression: "(k == 'v') && ..." }`), first, as
|
|
192
|
+
* {@link caseSubscriptionBody} orders it. Any other body comes back as it is.
|
|
193
|
+
*
|
|
194
|
+
* Such a body is what the SDK wrote before it wrote the expression (one Studio
|
|
195
|
+
* Web plan in the brownfield corpus has it too). The engine reads only
|
|
196
|
+
* `filters.expression` to match an event, so decompile reads the body back and
|
|
197
|
+
* compile adds the expression (`checkSubscriptionExpression` in decompile.ts).
|
|
198
|
+
* The carries that keep a saved element while it is unchanged
|
|
199
|
+
* (`connector-saved-context.ts`, `connector-saved-rows.ts`) compare the input
|
|
200
|
+
* values compile writes with the saved ones; they record the saved body this
|
|
201
|
+
* way, so the added expression is not read as an edit that drops the element's
|
|
202
|
+
* saved context and rows.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* // { queryParams: { entityScope: 'tenant' } }
|
|
206
|
+
* // -> { filters: { expression: "(entityScope == 'tenant')" }, queryParams: { entityScope: 'tenant' } }
|
|
207
|
+
*/
|
|
208
|
+
export function withScopeExpression(body, owner) {
|
|
209
|
+
if (!body || typeof body !== 'object' || Array.isArray(body))
|
|
210
|
+
return body;
|
|
211
|
+
const saved = body;
|
|
212
|
+
const params = saved.queryParams;
|
|
213
|
+
if (saved.filters !== undefined || !params || typeof params !== 'object' || Array.isArray(params))
|
|
214
|
+
return body;
|
|
215
|
+
let expression;
|
|
216
|
+
try {
|
|
217
|
+
expression = eventMatchExpression(eventScopeClauses(params, owner).map((c) => `(${c})`), []);
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
return body;
|
|
221
|
+
}
|
|
222
|
+
if (expression === '' || literalsOf(params).some((v) => literalProblem(v, false)))
|
|
223
|
+
return body;
|
|
224
|
+
return { filters: { expression }, ...saved };
|
|
225
|
+
}
|
|
226
|
+
const literalsOf = (params) => Object.values(params).map(String);
|
|
188
227
|
const SUBSCRIPTION_SERVICE_TYPES = new Set(['Intsvc.EventTrigger', 'Intsvc.WaitForEvent']);
|
|
189
228
|
/**
|
|
190
229
|
* Every connector event subscription in a plan, keyed by the ids of what owns
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.120.
|
|
3
|
+
"version": "6.120.9",
|
|
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",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"@types/node": "^22.7.0",
|
|
125
125
|
"esbuild": "^0.28.1"
|
|
126
126
|
},
|
|
127
|
-
"gitref": "
|
|
127
|
+
"gitref": "47f18663967be1967931c35b6637a3c334bd427f"
|
|
128
128
|
}
|