@uipath/maestro-builder-sdk 6.120.5 → 6.120.7
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.
|
@@ -33,17 +33,24 @@ export interface PreservedConnectorRows {
|
|
|
33
33
|
* `execute-connector-activity` task. A task is keyed by its own id, not its
|
|
34
34
|
* stage's: a task moved to another stage keeps its element ids, and its rows
|
|
35
35
|
* with them.
|
|
36
|
+
*
|
|
37
|
+
* `elementIds` are the spellings of the element's own id a row may carry:
|
|
38
|
+
* the one compile writes (the trigger's node id, else `<stage id>-<task or
|
|
39
|
+
* rule id>`), and an older SDK's bare task or rule id, which compile repairs
|
|
40
|
+
* (#1426).
|
|
36
41
|
*/
|
|
37
42
|
export declare function caseConnectorRowOwners(plan: Record<string, any>): Array<{
|
|
38
43
|
key: string;
|
|
39
44
|
bag: Record<string, any>;
|
|
45
|
+
elementIds: string[];
|
|
40
46
|
}>;
|
|
41
47
|
/**
|
|
42
48
|
* The saved own rows of a connector element, for each half compile would not
|
|
43
|
-
* write as it is: a row in another shape, a row missing,
|
|
44
|
-
*
|
|
49
|
+
* write as it is: a row in another shape, a row missing, a row that names
|
|
50
|
+
* another element (not one of `elementIds`, its own id's spellings), or no such
|
|
51
|
+
* field. Else `undefined`.
|
|
45
52
|
*/
|
|
46
|
-
export declare function savedConnectorRows(owner: string, bag: Record<string, any
|
|
53
|
+
export declare function savedConnectorRows(owner: string, bag: Record<string, any>, elementIds?: readonly string[]): PreservedConnectorRows | undefined;
|
|
47
54
|
/**
|
|
48
55
|
* Write each element's saved own rows back over the ones compile built, half
|
|
49
56
|
* by half, while they still describe the element. Runs after the ids are
|
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
*
|
|
31
31
|
* - outputs, while the element calls the same operation (same `connectorKey`,
|
|
32
32
|
* `objectName`, `method`, `path` and event `operation`) and each saved row's
|
|
33
|
-
* compiled counterpart writes the same variable
|
|
33
|
+
* compiled counterpart writes the same variable, or the saved row is the
|
|
34
|
+
* Designer's reassignment of the output to a case variable the plan still
|
|
35
|
+
* declares (`reassignedToCaseVariable`);
|
|
34
36
|
* - inputs, while it calls the same operation and every input holds the value
|
|
35
37
|
* it was saved with (an input only one side has must be empty).
|
|
36
38
|
*
|
|
@@ -69,17 +71,28 @@ const isObject = (value) => !!value && typeof value === 'object' && !Array.isArr
|
|
|
69
71
|
* `execute-connector-activity` task. A task is keyed by its own id, not its
|
|
70
72
|
* stage's: a task moved to another stage keeps its element ids, and its rows
|
|
71
73
|
* with them.
|
|
74
|
+
*
|
|
75
|
+
* `elementIds` are the spellings of the element's own id a row may carry:
|
|
76
|
+
* the one compile writes (the trigger's node id, else `<stage id>-<task or
|
|
77
|
+
* rule id>`), and an older SDK's bare task or rule id, which compile repairs
|
|
78
|
+
* (#1426).
|
|
72
79
|
*/
|
|
73
80
|
export function caseConnectorRowOwners(plan) {
|
|
74
|
-
const out = caseSubscriptionOwners(plan)
|
|
75
|
-
|
|
81
|
+
const out = caseSubscriptionOwners(plan).map(({ key, bag }) => {
|
|
82
|
+
const [kind, ...rest] = key.split(':');
|
|
83
|
+
if (kind === 'trigger')
|
|
84
|
+
return { key, bag, elementIds: [rest.join(':')] };
|
|
85
|
+
const [stageId, ...own] = rest;
|
|
86
|
+
const ownId = own.join(':');
|
|
87
|
+
return { key: kind === 'task' ? `task:${ownId}` : key, bag, elementIds: [`${stageId}-${ownId}`, ownId] };
|
|
88
|
+
});
|
|
76
89
|
for (const node of Array.isArray(plan?.nodes) ? plan.nodes : []) {
|
|
77
90
|
if (!String(node?.type ?? '').endsWith('Stage'))
|
|
78
91
|
continue;
|
|
79
92
|
for (const lane of Array.isArray(node.data?.tasks) ? node.data.tasks : [])
|
|
80
93
|
for (const task of Array.isArray(lane) ? lane : [])
|
|
81
94
|
if (task?.type === CONNECTOR_ACTIVITY_TYPE && isObject(task.data))
|
|
82
|
-
out.push({ key: `task:${task.id}`, bag: task.data });
|
|
95
|
+
out.push({ key: `task:${task.id}`, bag: task.data, elementIds: [`${node.id}-${task.id}`, String(task.id)] });
|
|
83
96
|
}
|
|
84
97
|
return out;
|
|
85
98
|
}
|
|
@@ -140,8 +153,10 @@ function sdkSchema(schema) {
|
|
|
140
153
|
};
|
|
141
154
|
return node(schema);
|
|
142
155
|
}
|
|
143
|
-
/** Whether
|
|
144
|
-
|
|
156
|
+
/** Whether a row's `elementId` names its own element (`elementIds`), when those are known. */
|
|
157
|
+
const ownElement = (row, elementIds) => typeof row.elementId === 'string' && (elementIds === undefined || elementIds.includes(row.elementId));
|
|
158
|
+
/** Whether compile could have written output `row` as it is (`connectorOutputs`) on its element (`elementIds`). */
|
|
159
|
+
function sdkShapedOutput(row, elementIds) {
|
|
145
160
|
if (!Object.keys(row).every((key) => SDK_OUTPUT_FIELDS.has(key)))
|
|
146
161
|
return false;
|
|
147
162
|
const error = row.source === '=Error';
|
|
@@ -149,22 +164,27 @@ function sdkShapedOutput(row) {
|
|
|
149
164
|
return false;
|
|
150
165
|
if (typeof row.var !== 'string' || row.id !== row.var || row.value !== row.var || row.target !== `=${row.var}`)
|
|
151
166
|
return false;
|
|
152
|
-
if (
|
|
167
|
+
if (!ownElement(row, elementIds))
|
|
153
168
|
return false;
|
|
154
169
|
return error ? stable(row.body) === ERROR_SCHEMA : sdkSchema(row.body);
|
|
155
170
|
}
|
|
156
|
-
/**
|
|
157
|
-
|
|
171
|
+
/**
|
|
172
|
+
* Whether compile could have written input `row` as it is (`ioSlot`, `fileSlot`,
|
|
173
|
+
* `eventInput`) on its element (`elementIds`). A row whose `elementId` names another
|
|
174
|
+
* element is the Designer's: a copied rule keeps the rows of the rule it was
|
|
175
|
+
* copied from, `elementId` and all, and compile would point them at the copy.
|
|
176
|
+
*/
|
|
177
|
+
function sdkShapedInput(row, elementIds) {
|
|
158
178
|
if (!Object.keys(row).every((key) => SDK_INPUT_FIELDS.has(key)))
|
|
159
179
|
return false;
|
|
160
|
-
if (typeof row.var !== 'string' || row.id !== row.var ||
|
|
180
|
+
if (typeof row.var !== 'string' || row.id !== row.var || !ownElement(row, elementIds))
|
|
161
181
|
return false;
|
|
162
182
|
if (row.type === 'file')
|
|
163
183
|
return row.target === 'file' && row.body === undefined;
|
|
164
184
|
return row.type === 'json' && row.target === row.name && (row.body !== undefined) !== (row.value !== undefined);
|
|
165
185
|
}
|
|
166
186
|
/** The saved outputs half, when compile would not write it as it is. */
|
|
167
|
-
function savedOutputs(bag) {
|
|
187
|
+
function savedOutputs(bag, elementIds) {
|
|
168
188
|
if (bag.outputs !== undefined && !Array.isArray(bag.outputs))
|
|
169
189
|
return undefined;
|
|
170
190
|
const rows = (bag.outputs ?? []).filter(isOwnOutput);
|
|
@@ -174,12 +194,12 @@ function savedOutputs(bag) {
|
|
|
174
194
|
if (sources.size !== rows.length)
|
|
175
195
|
return undefined;
|
|
176
196
|
const complete = rows.length === 2 && sources.size === 2;
|
|
177
|
-
if (bag.outputs !== undefined && complete && rows.every(sdkShapedOutput))
|
|
197
|
+
if (bag.outputs !== undefined && complete && rows.every((row) => sdkShapedOutput(row, elementIds)))
|
|
178
198
|
return undefined;
|
|
179
199
|
return { rows: structuredClone(rows), ...(bag.outputs === undefined ? { absent: true } : {}) };
|
|
180
200
|
}
|
|
181
201
|
/** The saved inputs half, when compile would not write it as it is. */
|
|
182
|
-
function savedInputs(bag, activity) {
|
|
202
|
+
function savedInputs(bag, activity, elementIds) {
|
|
183
203
|
if (bag.inputs !== undefined && !Array.isArray(bag.inputs))
|
|
184
204
|
return undefined;
|
|
185
205
|
const rows = bag.inputs ?? [];
|
|
@@ -190,22 +210,23 @@ function savedInputs(bag, activity) {
|
|
|
190
210
|
if (names.size !== rows.length)
|
|
191
211
|
return undefined;
|
|
192
212
|
const complete = activity ? ACTIVITY_CONTAINERS.every((name) => names.has(name)) : rows.length === 1;
|
|
193
|
-
if (bag.inputs !== undefined && complete && rows.every(sdkShapedInput))
|
|
213
|
+
if (bag.inputs !== undefined && complete && rows.every((row) => sdkShapedInput(row, elementIds)))
|
|
194
214
|
return undefined;
|
|
195
215
|
return { rows: structuredClone(rows), ...(bag.inputs === undefined ? { absent: true } : {}) };
|
|
196
216
|
}
|
|
197
217
|
/**
|
|
198
218
|
* The saved own rows of a connector element, for each half compile would not
|
|
199
|
-
* write as it is: a row in another shape, a row missing,
|
|
200
|
-
*
|
|
219
|
+
* write as it is: a row in another shape, a row missing, a row that names
|
|
220
|
+
* another element (not one of `elementIds`, its own id's spellings), or no such
|
|
221
|
+
* field. Else `undefined`.
|
|
201
222
|
*/
|
|
202
|
-
export function savedConnectorRows(owner, bag) {
|
|
223
|
+
export function savedConnectorRows(owner, bag, elementIds) {
|
|
203
224
|
const operation = operationOf(bag);
|
|
204
225
|
if (operation.connectorKey === undefined)
|
|
205
226
|
return undefined;
|
|
206
227
|
const activity = bag.serviceType !== 'Intsvc.EventTrigger' && bag.serviceType !== 'Intsvc.WaitForEvent';
|
|
207
|
-
const outputs = savedOutputs(bag);
|
|
208
|
-
const inputs = savedInputs(bag, activity);
|
|
228
|
+
const outputs = savedOutputs(bag, elementIds);
|
|
229
|
+
const inputs = savedInputs(bag, activity, elementIds);
|
|
209
230
|
const extracts = savedExtracts(bag);
|
|
210
231
|
if (!outputs && !inputs && !extracts)
|
|
211
232
|
return undefined;
|
|
@@ -275,23 +296,64 @@ function sameOperation(bag, entry) {
|
|
|
275
296
|
* where compile put its first own row, around the rows compile writes for the
|
|
276
297
|
* author; a built own row the element was saved without is dropped. Nothing,
|
|
277
298
|
* when a saved row's counterpart writes another variable.
|
|
299
|
+
*
|
|
300
|
+
* A saved row's counterpart is a built row that reads its source: one that
|
|
301
|
+
* also writes its variable when there is one, and of those the one with its
|
|
302
|
+
* id, else the last. An event trigger's `outputs`
|
|
303
|
+
* (`outputs: { responseRow: { source: '=response' } }`) compile writes as
|
|
304
|
+
* extracts beside the trigger's own rows, with the same source and no id; the
|
|
305
|
+
* Designer saves the trigger's own row reassigned instead (`{ id:
|
|
306
|
+
* 'responseRow', var: 'responseRow', originalVar: 'response', source:
|
|
307
|
+
* '=response' }`). The extract that writes the saved row's variable is its
|
|
308
|
+
* counterpart, and having no id it says nothing about renumbering, so the
|
|
309
|
+
* ids are compared only when the counterpart has one.
|
|
278
310
|
*/
|
|
279
|
-
function outputsBack(built, set) {
|
|
280
|
-
const builtOwn =
|
|
311
|
+
function outputsBack(built, set, caseVariables) {
|
|
312
|
+
const builtOwn = built.filter(isOwnOutput);
|
|
313
|
+
const counterpartOf = (row) => {
|
|
314
|
+
const reading = builtOwn.filter((candidate) => candidate.source === row.source);
|
|
315
|
+
const writing = reading.filter((candidate) => row.var !== undefined && candidate.var === row.var);
|
|
316
|
+
const pool = writing.length ? writing : reading;
|
|
317
|
+
return pool.find((candidate) => candidate.id === row.id) ?? pool.at(-1);
|
|
318
|
+
};
|
|
281
319
|
for (const row of set.rows) {
|
|
282
|
-
const counterpart =
|
|
283
|
-
if (counterpart
|
|
320
|
+
const counterpart = counterpartOf(row);
|
|
321
|
+
if (!counterpart)
|
|
322
|
+
continue;
|
|
323
|
+
if (counterpart.id !== undefined && counterpart.id !== row.id)
|
|
324
|
+
return undefined;
|
|
325
|
+
if (row.var !== undefined && counterpart.var !== row.var && !reassignedToCaseVariable(row, counterpart, caseVariables))
|
|
284
326
|
return undefined;
|
|
285
327
|
}
|
|
286
|
-
const own = set.rows.flatMap((row) =>
|
|
287
|
-
const counterpart = builtOwn.get(row.source);
|
|
288
|
-
return counterpart ? [structuredClone(row)] : [];
|
|
289
|
-
});
|
|
328
|
+
const own = set.rows.flatMap((row) => (counterpartOf(row) ? [structuredClone(row)] : []));
|
|
290
329
|
const firstOwn = built.findIndex(isOwnOutput);
|
|
291
330
|
const others = built.filter((row) => !isOwnOutput(row));
|
|
292
331
|
const at = firstOwn < 0 ? 0 : firstOwn;
|
|
293
332
|
return [...others.slice(0, at), ...own, ...others.slice(at)];
|
|
294
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Whether saved own row `row` is the Designer's reassignment of the output to
|
|
336
|
+
* a case variable the compiled plan still declares, where compile wrote the
|
|
337
|
+
* output to its own variable. The Designer saves such a row as `{ id:
|
|
338
|
+
* 'response2', var: 'inquiry', originalVar: 'response2', value: 'inquiry' }`
|
|
339
|
+
* with `inquiry` a root variable. No builder call writes an element's own row
|
|
340
|
+
* into another variable, so compile's counterpart writes `var: 'response2'`
|
|
341
|
+
* on every round trip, and refusing the saved row on that difference dropped
|
|
342
|
+
* the reassignment: the output stopped writing `inquiry`, and a later task
|
|
343
|
+
* reading `vars.inquiry` read nothing.
|
|
344
|
+
*/
|
|
345
|
+
function reassignedToCaseVariable(row, counterpart, caseVariables) {
|
|
346
|
+
return typeof row.var === 'string' && row.var !== row.id && counterpart.var === counterpart.id && caseVariables.has(row.var);
|
|
347
|
+
}
|
|
348
|
+
/** The ids of the case's root variables (`variables.inputs`, `outputs`, `inputOutputs`). */
|
|
349
|
+
function caseVariableIds(result) {
|
|
350
|
+
const ids = new Set();
|
|
351
|
+
for (const lane of ['inputs', 'outputs', 'inputOutputs'])
|
|
352
|
+
for (const variable of Array.isArray(result?.variables?.[lane]) ? result.variables[lane] : [])
|
|
353
|
+
if (typeof variable?.id === 'string')
|
|
354
|
+
ids.add(variable.id);
|
|
355
|
+
return ids;
|
|
356
|
+
}
|
|
295
357
|
/** The value an input row holds: its `body`, else its `value`. */
|
|
296
358
|
function inputValue(row) {
|
|
297
359
|
if (!row)
|
|
@@ -323,6 +385,7 @@ export function applyConnectorRows(result, entries) {
|
|
|
323
385
|
if (!entries?.length)
|
|
324
386
|
return;
|
|
325
387
|
const byOwner = new Map(entries.map((entry) => [entry.owner, entry]));
|
|
388
|
+
const caseVariables = caseVariableIds(result);
|
|
326
389
|
for (const { key, bag } of caseConnectorRowOwners(result)) {
|
|
327
390
|
const entry = byOwner.get(key);
|
|
328
391
|
if (!entry || !sameOperation(bag, entry))
|
|
@@ -334,7 +397,7 @@ export function applyConnectorRows(result, entries) {
|
|
|
334
397
|
if (!set)
|
|
335
398
|
continue;
|
|
336
399
|
const built = Array.isArray(bag[field]) ? bag[field] : [];
|
|
337
|
-
const back = field === 'inputs' ? inputsBack(built, set) : outputsBack(built, set);
|
|
400
|
+
const back = field === 'inputs' ? inputsBack(built, set) : outputsBack(built, set, caseVariables);
|
|
338
401
|
if (!back)
|
|
339
402
|
continue;
|
|
340
403
|
if (set.absent && back.length === 0)
|
package/dist/case/decompile.js
CHANGED
|
@@ -1057,6 +1057,14 @@ function connectorInputs(slots, resolved, owner, task) {
|
|
|
1057
1057
|
if (!body || typeof body !== 'object' || Array.isArray(body)) {
|
|
1058
1058
|
if (owner)
|
|
1059
1059
|
throw new Error(`${owner} input container "${name}" must carry an object body.`);
|
|
1060
|
+
// A container saved as one value, not fields: a whole-body expression,
|
|
1061
|
+
// `{ name: 'body', body: '=js:({ "id": vars.x })' }`. The SDK names a
|
|
1062
|
+
// connector's inputs field by field, so it has nowhere to put it, and
|
|
1063
|
+
// compile would write the container empty: refuse, never drop.
|
|
1064
|
+
if (hasAuthoredValue(body))
|
|
1065
|
+
throw new Error(`${who} input container "${name}" is saved as one ${typeof body === 'string' ? 'expression' : 'value'}, ` +
|
|
1066
|
+
`not as fields; the SDK sets a connector's inputs field by field, so decompile cannot lift it and the value would be lost. ` +
|
|
1067
|
+
'In Studio Web, set the fields one by one instead of the whole container, then decompile the saved plan.');
|
|
1060
1068
|
continue;
|
|
1061
1069
|
}
|
|
1062
1070
|
for (const [wireName, value] of Object.entries(body)) {
|
|
@@ -3032,7 +3040,7 @@ export function collectPreservation(plan) {
|
|
|
3032
3040
|
if (connectorConfigV2.length)
|
|
3033
3041
|
preservation.connectorConfigV2 = connectorConfigV2;
|
|
3034
3042
|
const connectorRows = caseConnectorRowOwners(plan)
|
|
3035
|
-
.map(({ key, bag }) => savedConnectorRows(key, bag))
|
|
3043
|
+
.map(({ key, bag, elementIds }) => savedConnectorRows(key, bag, elementIds))
|
|
3036
3044
|
.filter((entry) => entry !== undefined);
|
|
3037
3045
|
if (connectorRows.length)
|
|
3038
3046
|
preservation.connectorRows = connectorRows;
|
package/dist/case/serialize.js
CHANGED
|
@@ -186,8 +186,7 @@ function collected(resolver, where, nodeId, emit, standIn) {
|
|
|
186
186
|
/** The root companions a stand-in's authored outputs need, the way an emitted node registers them. */
|
|
187
187
|
function standInCompanions(resolver, outputs) {
|
|
188
188
|
for (const o of outputs ?? [])
|
|
189
|
-
|
|
190
|
-
resolver.varCompanions.set(o.var, { id: o.var, name: o.var, type: o.type, elementId: 'root', custom: true });
|
|
189
|
+
addVarCompanion(resolver, o.var, { id: o.var, name: o.var, type: o.type, elementId: 'root', custom: true });
|
|
191
190
|
}
|
|
192
191
|
/**
|
|
193
192
|
* The value an author wrote, as plain JSON, for a stand-in. Deterministic, so
|
|
@@ -222,6 +221,7 @@ function serializeCase(built, opts) {
|
|
|
222
221
|
offlineBindingIds: new Map(),
|
|
223
222
|
varCompanions: new Map(),
|
|
224
223
|
ownNameRows: new Map(),
|
|
224
|
+
firstWriters: new Map(),
|
|
225
225
|
// A carried task's saved output rows keep their ids: no other row takes one.
|
|
226
226
|
outputIds: new Set(savedOutputIds(caseJsonPreservation(built)?.documentExtractionData)),
|
|
227
227
|
savedDocumentExtractions: pairSavedDocumentExtractions(carriedDocumentExtractionTasks(built), caseJsonPreservation(built)?.documentExtractionData),
|
|
@@ -392,8 +392,8 @@ function serializeCase(built, opts) {
|
|
|
392
392
|
const variables = emitVariables(built.vars, ids, triggerNodeByRef, triggerNodes, built.triggers, resolver.collect);
|
|
393
393
|
const inputOutputs = variables.inputOutputs;
|
|
394
394
|
const declared = new Set(inputOutputs.map((e) => e.id));
|
|
395
|
-
for (const
|
|
396
|
-
if (!declared.has(
|
|
395
|
+
for (const companion of orderedCompanions(resolver))
|
|
396
|
+
if (!declared.has(companion.id))
|
|
397
397
|
inputOutputs.push(companion);
|
|
398
398
|
// An own-name row that writes a variable which DOES have a root entry (a
|
|
399
399
|
// declared `.var()`, or a companion another, reassigned, writer needed) is the
|
|
@@ -1952,6 +1952,7 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1952
1952
|
held.add(row.id);
|
|
1953
1953
|
}
|
|
1954
1954
|
}
|
|
1955
|
+
dropOwnVariableCompanions(result, stages, nodes, identities);
|
|
1955
1956
|
}
|
|
1956
1957
|
// An id hashed from a generated element id is re-minted from the preserved one,
|
|
1957
1958
|
// wherever it is spelled, including inside a `=jsonString:` configuration.
|
|
@@ -2316,8 +2317,7 @@ function emitTrigger(t, i, triggerId, resolver) {
|
|
|
2316
2317
|
if (t.eventOutputs?.length) {
|
|
2317
2318
|
const outputs = t.eventOutputs.map((o) => {
|
|
2318
2319
|
const field = o.source.replace(/^=/, '').split('.').pop() || o.source;
|
|
2319
|
-
|
|
2320
|
-
resolver.varCompanions.set(o.var, { id: o.var, name: o.var, type: o.type, elementId: 'root', custom: true });
|
|
2320
|
+
addVarCompanion(resolver, o.var, { id: o.var, name: o.var, type: o.type, elementId: 'root', custom: true });
|
|
2321
2321
|
return { name: field, var: o.var, source: o.source, type: o.type, value: o.var };
|
|
2322
2322
|
});
|
|
2323
2323
|
bag.outputs = [...(bag.outputs ?? []), ...outputs];
|
|
@@ -2835,15 +2835,8 @@ function emitActionField(f, outputElementId, resolver) {
|
|
|
2835
2835
|
// for it). Only a suffixed, reassigned row needs the readable companion.
|
|
2836
2836
|
if (resolver && id === variable)
|
|
2837
2837
|
addOwnNameRow(resolver, variable, row);
|
|
2838
|
-
else if (resolver
|
|
2839
|
-
resolver
|
|
2840
|
-
id: variable,
|
|
2841
|
-
name: variable,
|
|
2842
|
-
type: f.type ?? 'string',
|
|
2843
|
-
elementId: 'root',
|
|
2844
|
-
custom: true,
|
|
2845
|
-
});
|
|
2846
|
-
}
|
|
2838
|
+
else if (resolver)
|
|
2839
|
+
addVarCompanion(resolver, variable, { id: variable, name: variable, type: f.type ?? 'string', elementId: 'root', custom: true });
|
|
2847
2840
|
}
|
|
2848
2841
|
if (f.required !== undefined)
|
|
2849
2842
|
row.required = f.required;
|
|
@@ -2999,6 +2992,41 @@ function settleOwnNameRows(result, stages, restored, identities) {
|
|
|
2999
2992
|
if (variables.inputOutputs)
|
|
3000
2993
|
variables.inputOutputs = variables.inputOutputs.filter((entry) => !(names.has(entry?.id) && entry.custom === true && entry.elementId === 'root'));
|
|
3001
2994
|
}
|
|
2995
|
+
/**
|
|
2996
|
+
* A custom (`{ assign }`) row Studio Web saved as its task's own output, with
|
|
2997
|
+
* an id that is its variable and the task's `elementId` (`{ custom: true, id:
|
|
2998
|
+
* 'region', var: 'region', elementId: '<stageId>-<taskId>' }`), declares that
|
|
2999
|
+
* variable itself: the platform reads every row on the task's `elementId` that
|
|
3000
|
+
* has an id as a task output variable. Compile writes a root companion for
|
|
3001
|
+
* every `{ assign }` row (`emitCustomOutput`), so such a row would come back
|
|
3002
|
+
* with a second, root declaration the plan never had. Once the saved shapes are
|
|
3003
|
+
* back, a companion is dropped when its variable has no root row in the source
|
|
3004
|
+
* (`identities.variables`) and every row that writes it is such an own row; a
|
|
3005
|
+
* row that writes it any other way (an edit can add one) keeps it.
|
|
3006
|
+
*/
|
|
3007
|
+
function dropOwnVariableCompanions(result, stages, nodes, identities) {
|
|
3008
|
+
const variables = result.variables;
|
|
3009
|
+
if (!variables?.inputOutputs?.length)
|
|
3010
|
+
return;
|
|
3011
|
+
const declared = new Set(Object.values(identities.variables ?? {}).flatMap((rows) => (rows ?? []).map((row) => row.name)));
|
|
3012
|
+
const own = new Set();
|
|
3013
|
+
for (const stage of stages)
|
|
3014
|
+
for (const task of (stage.data?.tasks ?? []).flat())
|
|
3015
|
+
for (const row of task?.data?.outputs ?? [])
|
|
3016
|
+
if (row?.custom === true && typeof row.var === 'string' && row.id === row.var
|
|
3017
|
+
&& typeof task.elementId === 'string' && row.elementId === task.elementId && row.elementId !== 'root')
|
|
3018
|
+
own.add(row.var);
|
|
3019
|
+
if (!own.size)
|
|
3020
|
+
return;
|
|
3021
|
+
const ownRow = (row) => row?.custom === true && row.id === row.var && row.elementId !== 'root';
|
|
3022
|
+
for (const row of [...planOutputRows(result, stages), ...triggerOutputRows(nodes)])
|
|
3023
|
+
if (own.has(row?.var) && !ownRow(row))
|
|
3024
|
+
own.delete(row.var);
|
|
3025
|
+
const gone = new Set([...own].filter((name) => !declared.has(name)));
|
|
3026
|
+
if (!gone.size)
|
|
3027
|
+
return;
|
|
3028
|
+
variables.inputOutputs = variables.inputOutputs.filter((entry) => !(gone.has(entry?.id) && entry.custom === true && entry.elementId === 'root'));
|
|
3029
|
+
}
|
|
3002
3030
|
/** Every `outputs[]` row the plan's trigger nodes carry. */
|
|
3003
3031
|
function triggerOutputRows(nodes) {
|
|
3004
3032
|
return nodes.flatMap((node) => node.type === 'uipath.case.trigger' ? (node.data?.inputs?.outputs ?? [])
|
|
@@ -3102,8 +3130,7 @@ function emitTaskOutput(o, elementId, ids, seed, resolver) {
|
|
|
3102
3130
|
// A reassigned row registers the readable companion once (declared vars take
|
|
3103
3131
|
// precedence in the merge); an own-name row is the variable and registers none.
|
|
3104
3132
|
const companion = () => {
|
|
3105
|
-
|
|
3106
|
-
resolver.varCompanions.set(o.var, { id: o.var, name: o.var, type: o.type, elementId: 'root', custom: true });
|
|
3133
|
+
addVarCompanion(resolver, o.var, { id: o.var, name: o.var, type: o.type, elementId: 'root', custom: true });
|
|
3107
3134
|
};
|
|
3108
3135
|
if (isOwnNameOutput(o)) {
|
|
3109
3136
|
const id = claimOutputId(resolver, o.var);
|
|
@@ -3140,8 +3167,7 @@ function emitTaskOutput(o, elementId, ids, seed, resolver) {
|
|
|
3140
3167
|
* Like an extract, it registers the root companion so `=vars.<var>` resolves.
|
|
3141
3168
|
*/
|
|
3142
3169
|
function emitCustomOutput(o, resolver) {
|
|
3143
|
-
|
|
3144
|
-
resolver.varCompanions.set(o.var, { id: o.var, name: o.var, type: o.type, elementId: 'root', custom: true });
|
|
3170
|
+
addVarCompanion(resolver, o.var, { id: o.var, name: o.var, type: o.type, elementId: 'root', custom: true });
|
|
3145
3171
|
return { name: o.var, type: o.type, custom: true, var: o.var, value: o.source, source: o.source, target: '', body: '', elementId: 'root' };
|
|
3146
3172
|
}
|
|
3147
3173
|
// ─── Business-rule task ───────────────────────────────────────────────────────
|
|
@@ -3432,8 +3458,7 @@ function scriptTaskData(task, resolver, elementId) {
|
|
|
3432
3458
|
*/
|
|
3433
3459
|
function registerMappedCompanions(resolver, mappings) {
|
|
3434
3460
|
for (const variable of mappings.values())
|
|
3435
|
-
|
|
3436
|
-
resolver.varCompanions.set(variable, { id: variable, name: variable, type: 'object', elementId: 'root', custom: true });
|
|
3461
|
+
addVarCompanion(resolver, variable, { id: variable, name: variable, type: 'object', elementId: 'root', custom: true });
|
|
3437
3462
|
}
|
|
3438
3463
|
/**
|
|
3439
3464
|
* An HTTP request task (`case/http-request.ts`): the generic HTTP connector's
|
|
@@ -3728,12 +3753,51 @@ function connectorOutputVar(resolver, base) {
|
|
|
3728
3753
|
}
|
|
3729
3754
|
/** Record an own-name row (`id == var`), the variable itself; see the variables merge in `serialize`. */
|
|
3730
3755
|
function addOwnNameRow(resolver, name, row) {
|
|
3756
|
+
if (!resolver.firstWriters.has(name))
|
|
3757
|
+
resolver.firstWriters.set(name, { own: row });
|
|
3731
3758
|
const rows = resolver.ownNameRows.get(name);
|
|
3732
3759
|
if (rows)
|
|
3733
3760
|
rows.push(row);
|
|
3734
3761
|
else
|
|
3735
3762
|
resolver.ownNameRows.set(name, [row]);
|
|
3736
3763
|
}
|
|
3764
|
+
/**
|
|
3765
|
+
* Register the root companion a reassigned or custom row needs to write
|
|
3766
|
+
* `name` (`=vars.<name>` reads it), once per variable. See `orderedCompanions`
|
|
3767
|
+
* for where and with which type it is written.
|
|
3768
|
+
*/
|
|
3769
|
+
function addVarCompanion(resolver, name, companion) {
|
|
3770
|
+
if (!resolver.firstWriters.has(name))
|
|
3771
|
+
resolver.firstWriters.set(name, {});
|
|
3772
|
+
if (!resolver.varCompanions.has(name))
|
|
3773
|
+
resolver.varCompanions.set(name, companion);
|
|
3774
|
+
}
|
|
3775
|
+
/**
|
|
3776
|
+
* The root companions, in the order their variables were first written, each
|
|
3777
|
+
* with its first writer's type when that writer is an own-name row.
|
|
3778
|
+
*
|
|
3779
|
+
* A companion belongs to the variable, and the variable is its first writer.
|
|
3780
|
+
* When an own-name row comes first (`{ id: 'status', var: 'status' }`) and a
|
|
3781
|
+
* later task writes the same variable, only the later row is reassigned and
|
|
3782
|
+
* registers the companion, but the companion still stands where `status` was
|
|
3783
|
+
* first written, typed as that row is. Example: task A saves
|
|
3784
|
+
* `{ id: 'status', var: 'status', type: 'string' }`, then task B's
|
|
3785
|
+
* `.outputs({ status: { source: '=Result', type: 'jsonSchema' } })` writes it
|
|
3786
|
+
* too: the root gets `{ id: 'status', type: 'string', ... }`, ahead of the
|
|
3787
|
+
* companion of any variable first written after task A. This is also how
|
|
3788
|
+
* compile repairs two tasks saved with one output id (validate's
|
|
3789
|
+
* CASE_MGMT_OUTPUT_ID_DUPLICATE): the first keeps the id and is the variable.
|
|
3790
|
+
*/
|
|
3791
|
+
function orderedCompanions(resolver) {
|
|
3792
|
+
const order = [...resolver.firstWriters.keys()];
|
|
3793
|
+
const at = new Map(order.map((name, index) => [name, index]));
|
|
3794
|
+
return [...resolver.varCompanions]
|
|
3795
|
+
.sort(([a], [b]) => (at.get(a) ?? order.length) - (at.get(b) ?? order.length))
|
|
3796
|
+
.map(([name, companion]) => {
|
|
3797
|
+
const own = resolver.firstWriters.get(name)?.own;
|
|
3798
|
+
return own && typeof own.type === 'string' && own.type !== companion.type ? { ...companion, type: own.type } : companion;
|
|
3799
|
+
});
|
|
3800
|
+
}
|
|
3737
3801
|
/**
|
|
3738
3802
|
* Claim a task-output row id from the document-wide pool, the Designer's
|
|
3739
3803
|
* uniqueness rule: the first claimant of `base` gets `base`, later ones get
|
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.7",
|
|
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": "f927fee124eec291c9647253cc5bdb152b0b7213"
|
|
128
128
|
}
|