@uipath/maestro-builder-sdk 6.93.2 → 6.93.4
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.d.ts +34 -0
- package/dist/case/connector-saved-context.js +281 -0
- package/dist/case/decompile.d.ts +6 -0
- package/dist/case/decompile.js +68 -1
- package/dist/case/preserve.d.ts +38 -1
- package/dist/case/preserve.js +32 -2
- package/dist/case/serialize.js +36 -3
- package/package.json +2 -2
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** One saved connector element context, as `preserveCaseJson` carries it. */
|
|
2
|
+
export interface PreservedConnectorContext {
|
|
3
|
+
/** `trigger:<node id>`, `task:<stage id>:<task id>` or `rule:<stage id>:<rule id>`. */
|
|
4
|
+
owner: string;
|
|
5
|
+
/** The element's `context` list, verbatim. */
|
|
6
|
+
context: Array<Record<string, unknown>>;
|
|
7
|
+
/** Each input row's saved value (`body`, else `value`), by row name. */
|
|
8
|
+
inputs: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Every connector element in a plan with the bag that holds its `context`:
|
|
12
|
+
* the event subscriptions (`caseSubscriptionOwners`), and each
|
|
13
|
+
* `execute-connector-activity` task, keyed `task:<stage id>:<task id>` as a
|
|
14
|
+
* wait-for-connector task is.
|
|
15
|
+
*/
|
|
16
|
+
export declare function caseConnectorOwners(plan: Record<string, any>): Array<{
|
|
17
|
+
key: string;
|
|
18
|
+
bag: Record<string, any>;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* The saved context of a connector element, when it has a `metadata` row with
|
|
22
|
+
* an object body (the Designer's state) that compile could not have written
|
|
23
|
+
* ({@link sdkShaped}); else `undefined`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function savedConnectorContext(owner: string, bag: Record<string, any>): PreservedConnectorContext | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Write each saved connector context back onto the element compile built for
|
|
28
|
+
* the same owner, while that element is unchanged ({@link unchanged}). Runs
|
|
29
|
+
* after the ids are restored, so an owner key finds its element by the plan's
|
|
30
|
+
* own ids, also after a rename.
|
|
31
|
+
*/
|
|
32
|
+
export declare function applyConnectorContexts(result: Record<string, any>, entries: readonly PreservedConnectorContext[] | undefined): void;
|
|
33
|
+
/** Problems with a payload's `connectorContexts`, for `caseJsonPreservationErrors`. */
|
|
34
|
+
export declare function connectorContextErrors(entries: unknown): string[];
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Designer-saved connector element's `context`, kept through a decompile ->
|
|
3
|
+
* compile round trip while the element is unchanged.
|
|
4
|
+
*
|
|
5
|
+
* Four elements call Integration Service: an event trigger, a
|
|
6
|
+
* wait-for-connector task, a wait-for-connector rule, and an
|
|
7
|
+
* `execute-connector-activity` task. Each carries a `context` list: the
|
|
8
|
+
* connector rows (`connectorKey`, `connection`, `objectName`, `method`,
|
|
9
|
+
* `path`, ...) and a `metadata` row whose body is the Designer's state for
|
|
10
|
+
* that element (`activityPropertyConfiguration`, `activityMetadata`,
|
|
11
|
+
* `inputMetadata`, `telemetryData`, and, on an event, the `bindings` that name
|
|
12
|
+
* its trigger parameters and the `filterExpression` it shows).
|
|
13
|
+
*
|
|
14
|
+
* Compile rebuilds that `metadata` body from the library
|
|
15
|
+
* (`core/connector-v2-metadata.ts`): the functional half only, with no
|
|
16
|
+
* Designer cosmetics, no saved `connectorVersion`, and no event `bindings` or
|
|
17
|
+
* `filterExpression`. That is right for a new element. For one Studio Web
|
|
18
|
+
* saved, it rewrote the whole body on the first round trip, even with no edit:
|
|
19
|
+
* no Designer-saved connector trigger, wait or activity in the brownfield
|
|
20
|
+
* corpus came back as it was saved.
|
|
21
|
+
*
|
|
22
|
+
* So decompile records each connector element's saved `context` verbatim,
|
|
23
|
+
* with the input values it was saved against, keyed by owner
|
|
24
|
+
* (`caseConnectorOwners`). Compile writes the saved `context` back only while
|
|
25
|
+
* the element is unchanged: every connector row both sides carry holds the
|
|
26
|
+
* same value (the same connector, operation, connection and folder), and every
|
|
27
|
+
* input row holds the same value. Any edit to those, or a deleted element,
|
|
28
|
+
* gets the `context` compile built, as before. The `metadata` body describes
|
|
29
|
+
* input values (an event's filter, its trigger parameter `bindings`, the
|
|
30
|
+
* Designer's display caches), so a value edit must not keep it.
|
|
31
|
+
*
|
|
32
|
+
* For instance, an Outlook "Email Received" trigger saved with
|
|
33
|
+
* `filterExpression: "(parentFolderId == 'AAMk...')"` and a `bindings` entry
|
|
34
|
+
* for `parentFolderId` keeps both while the source still filters on that
|
|
35
|
+
* folder. Point it at another folder and compile writes its own body.
|
|
36
|
+
*/
|
|
37
|
+
import { caseSubscriptionOwners } from './subscription.js';
|
|
38
|
+
const CONNECTOR_ACTIVITY_TYPE = 'execute-connector-activity';
|
|
39
|
+
/**
|
|
40
|
+
* Every connector element in a plan with the bag that holds its `context`:
|
|
41
|
+
* the event subscriptions (`caseSubscriptionOwners`), and each
|
|
42
|
+
* `execute-connector-activity` task, keyed `task:<stage id>:<task id>` as a
|
|
43
|
+
* wait-for-connector task is.
|
|
44
|
+
*/
|
|
45
|
+
export function caseConnectorOwners(plan) {
|
|
46
|
+
const out = caseSubscriptionOwners(plan);
|
|
47
|
+
for (const node of Array.isArray(plan?.nodes) ? plan.nodes : []) {
|
|
48
|
+
if (!String(node?.type ?? '').endsWith('Stage'))
|
|
49
|
+
continue;
|
|
50
|
+
for (const lane of Array.isArray(node.data?.tasks) ? node.data.tasks : [])
|
|
51
|
+
for (const task of Array.isArray(lane) ? lane : [])
|
|
52
|
+
if (task?.type === CONNECTOR_ACTIVITY_TYPE && task.data && typeof task.data === 'object')
|
|
53
|
+
out.push({ key: `task:${node.id}:${task.id}`, bag: task.data });
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
const isObject = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
58
|
+
/** The value an input row holds: its `body`, else its `value`. */
|
|
59
|
+
function inputValue(row) {
|
|
60
|
+
return row.body !== undefined ? row.body : row.value;
|
|
61
|
+
}
|
|
62
|
+
/** Each input row's value, by name. */
|
|
63
|
+
function inputValues(bag) {
|
|
64
|
+
const out = {};
|
|
65
|
+
for (const row of Array.isArray(bag.inputs) ? bag.inputs : [])
|
|
66
|
+
if (isObject(row) && typeof row.name === 'string')
|
|
67
|
+
out[row.name] = inputValue(row);
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
/** `value` with object keys sorted, so key order does not count. */
|
|
71
|
+
function stable(value) {
|
|
72
|
+
if (Array.isArray(value))
|
|
73
|
+
return `[${value.map(stable).join(',')}]`;
|
|
74
|
+
if (isObject(value))
|
|
75
|
+
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stable(value[key])}`).join(',')}}`;
|
|
76
|
+
return JSON.stringify(value) ?? 'undefined';
|
|
77
|
+
}
|
|
78
|
+
/** An input that holds nothing: absent, `""`, `{}` or `[]`. */
|
|
79
|
+
function isEmptyInput(value) {
|
|
80
|
+
return value === undefined || value === null || value === ''
|
|
81
|
+
|| (Array.isArray(value) && value.length === 0) || (isObject(value) && Object.keys(value).length === 0);
|
|
82
|
+
}
|
|
83
|
+
const EVENT_SERVICE_TYPES = new Set(['Intsvc.EventTrigger', 'Intsvc.WaitForEvent']);
|
|
84
|
+
const JSON_STRING = '=jsonString:';
|
|
85
|
+
/** The context row a flagged-V2 plan's connector elements carry (`stampConnectorConfigVersion`). */
|
|
86
|
+
const V2_CONFIG_ROW = 'activityConfigurationVersion';
|
|
87
|
+
/**
|
|
88
|
+
* The fields `core/connector-v2-metadata.ts` writes in a `metadata` body, per
|
|
89
|
+
* element kind: `connectorActivityMetadata` for a connector activity,
|
|
90
|
+
* `connectorEventMetadata` for an event. Compile writes no other.
|
|
91
|
+
*/
|
|
92
|
+
const SDK_METADATA_FIELDS = {
|
|
93
|
+
activity: {
|
|
94
|
+
body: new Set(['activityPropertyConfiguration', 'activityMetadata', 'inputMetadata', 'telemetryData']),
|
|
95
|
+
apc: new Set(['multipartParameters', 'configuration', 'uiPathActivityTypeId', 'errorState', 'executionType', 'eventType', 'eventMode']),
|
|
96
|
+
},
|
|
97
|
+
event: {
|
|
98
|
+
body: new Set(['activityPropertyConfiguration', 'activityMetadata', 'telemetryData']),
|
|
99
|
+
apc: new Set(['objectName', 'eventType', 'eventMode', 'configuration', 'uiPathActivityTypeId', 'errorState', 'filterExpression']),
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
const SDK_ACTIVITY_FIELDS = new Set(['displayName', 'description', 'category', 'configuration', 'uiPathActivityTypeId', 'isEnabled']);
|
|
103
|
+
const SDK_TELEMETRY_FIELDS = new Set(['connectorKey', 'connectorName', 'objectName', 'objectDisplayName']);
|
|
104
|
+
const SDK_ROW_FIELDS = new Set(['name', 'type', 'value', 'body']);
|
|
105
|
+
const within = (value, fields) => isObject(value) && Object.keys(value).every((key) => fields.has(key));
|
|
106
|
+
/**
|
|
107
|
+
* Whether compile could have written this context: every row and every
|
|
108
|
+
* `metadata` field is one the SDK's builders write, and the configuration has
|
|
109
|
+
* no Designer half (`optionalConfiguration`) and no saved `connectorVersion`.
|
|
110
|
+
* A context the SDK wrote is left to compile, which rebuilds it from the
|
|
111
|
+
* library, so an SDK-authored plan's source carries no copy of it. Anything
|
|
112
|
+
* else (Studio Web's `activityMetadata.activity.svgIconUrl`, an event's
|
|
113
|
+
* `bindings`, `telemetryData.primaryKeyName`, a `metadata` row with no
|
|
114
|
+
* `type`) is a field compile never writes, so only the saved copy can keep it.
|
|
115
|
+
*/
|
|
116
|
+
function sdkShaped(bag, context) {
|
|
117
|
+
if (!context.every((row) => within(row, SDK_ROW_FIELDS)))
|
|
118
|
+
return false;
|
|
119
|
+
const row = context.find((candidate) => candidate.name === 'metadata');
|
|
120
|
+
if (row.type !== 'json')
|
|
121
|
+
return false;
|
|
122
|
+
const body = row.body;
|
|
123
|
+
const fields = EVENT_SERVICE_TYPES.has(bag.serviceType) ? SDK_METADATA_FIELDS.event : SDK_METADATA_FIELDS.activity;
|
|
124
|
+
if (!within(body, fields.body) || !within(body.activityPropertyConfiguration, fields.apc))
|
|
125
|
+
return false;
|
|
126
|
+
if (!within(body.activityMetadata, new Set(['activity'])) || !within(body.activityMetadata.activity, SDK_ACTIVITY_FIELDS))
|
|
127
|
+
return false;
|
|
128
|
+
if (!within(body.telemetryData, SDK_TELEMETRY_FIELDS))
|
|
129
|
+
return false;
|
|
130
|
+
const encoded = body.activityPropertyConfiguration.configuration;
|
|
131
|
+
if (typeof encoded !== 'string' || !encoded.startsWith(JSON_STRING))
|
|
132
|
+
return false;
|
|
133
|
+
try {
|
|
134
|
+
const configuration = JSON.parse(encoded.slice(JSON_STRING.length));
|
|
135
|
+
return within(configuration, new Set(['essentialConfiguration']))
|
|
136
|
+
&& (configuration.essentialConfiguration?.connectorVersion ?? null) === null;
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The saved context of a connector element, when it has a `metadata` row with
|
|
144
|
+
* an object body (the Designer's state) that compile could not have written
|
|
145
|
+
* ({@link sdkShaped}); else `undefined`.
|
|
146
|
+
*/
|
|
147
|
+
export function savedConnectorContext(owner, bag) {
|
|
148
|
+
const context = bag?.context;
|
|
149
|
+
if (!Array.isArray(context) || !context.every(isObject))
|
|
150
|
+
return undefined;
|
|
151
|
+
if (!context.some((row) => row.name === 'metadata' && isObject(row.body)))
|
|
152
|
+
return undefined;
|
|
153
|
+
if (sdkShaped(bag, context))
|
|
154
|
+
return undefined;
|
|
155
|
+
return { owner, context: structuredClone(context), inputs: inputValues(bag) };
|
|
156
|
+
}
|
|
157
|
+
/** Whether a wire `activityType` is a generic CRUD one (`Generic`, `GenericExpanded`, `GenericTrigger`). */
|
|
158
|
+
const isGenericKind = (activityType) => activityType.startsWith('Generic');
|
|
159
|
+
/**
|
|
160
|
+
* Which action a context was built for: the `uiPathActivityTypeId` its
|
|
161
|
+
* `metadata` row names (in `activityPropertyConfiguration`, else in
|
|
162
|
+
* `activityMetadata.activity`) and the essential configuration's
|
|
163
|
+
* `instanceParameters.activityType` (`Curated` or `Generic`). A curated
|
|
164
|
+
* activity and its generic twin share `method`, `path` and `objectName`
|
|
165
|
+
* (Outlook `send-email` and `insert-record-deprecated-`), so only these tell
|
|
166
|
+
* them apart. Either is `undefined` when the context does not say.
|
|
167
|
+
*/
|
|
168
|
+
function actionIdentity(context) {
|
|
169
|
+
const raw = context.find((row) => row.name === 'metadata')?.body;
|
|
170
|
+
if (!isObject(raw))
|
|
171
|
+
return {};
|
|
172
|
+
const body = raw;
|
|
173
|
+
const id = body.activityPropertyConfiguration?.uiPathActivityTypeId ?? body.activityMetadata?.activity?.uiPathActivityTypeId;
|
|
174
|
+
let activityType;
|
|
175
|
+
const encoded = body.activityPropertyConfiguration?.configuration;
|
|
176
|
+
if (typeof encoded === 'string' && encoded.startsWith(JSON_STRING)) {
|
|
177
|
+
try {
|
|
178
|
+
activityType = JSON.parse(encoded.slice(JSON_STRING.length))?.essentialConfiguration?.instanceParameters?.activityType;
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
activityType = undefined;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
typeId: typeof id === 'string' && id ? id : undefined,
|
|
186
|
+
activityType: typeof activityType === 'string' && activityType ? activityType : undefined,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Whether the element compile built is the one the context was saved for:
|
|
191
|
+
*
|
|
192
|
+
* - every non-`metadata` row either side names holds the same value, a row on
|
|
193
|
+
* one side only reading as no value. So adding or removing a `folderKey`
|
|
194
|
+
* row (an edit that adds or drops `folder:`) gets compile's context, while
|
|
195
|
+
* a Designer row compile never writes and that holds no value (a bare
|
|
196
|
+
* `method`) still compares equal. `connectorKey` must be on both sides;
|
|
197
|
+
* - the action is the same: the activity type id agrees, and the wire
|
|
198
|
+
* activity type is curated on both sides or generic on both, wherever both
|
|
199
|
+
* sides carry them ({@link actionIdentity}), so switching to an action's
|
|
200
|
+
* curated or generic twin gets compile's context;
|
|
201
|
+
* - every input holds the same value (an input only one side has must be
|
|
202
|
+
* empty, as compile writes `body: {}` for an unused container).
|
|
203
|
+
*/
|
|
204
|
+
function unchanged(bag, entry, v2) {
|
|
205
|
+
const built = Array.isArray(bag.context) ? bag.context.filter(isObject) : [];
|
|
206
|
+
const builtRows = new Map(built.map((row) => [row.name, row]));
|
|
207
|
+
const saved = new Map(entry.context.map((row) => [row.name, row]));
|
|
208
|
+
if (!builtRows.has('connectorKey') || !saved.has('connectorKey'))
|
|
209
|
+
return false;
|
|
210
|
+
for (const name of new Set([...builtRows.keys(), ...saved.keys()])) {
|
|
211
|
+
if (name === 'metadata')
|
|
212
|
+
continue;
|
|
213
|
+
// On a flagged-V2 plan `activityConfigurationVersion: v2` is compile's
|
|
214
|
+
// repair: it is written on connection-bound contexts, on a trigger or task
|
|
215
|
+
// after this pass (`stampConnectorConfigVersion` in serialize.ts), which
|
|
216
|
+
// keeps a row the context already has. A side that lacks it says nothing
|
|
217
|
+
// about the action, so it counts only when both sides carry it.
|
|
218
|
+
if (name === V2_CONFIG_ROW && v2 && !(builtRows.has(name) && saved.has(name)))
|
|
219
|
+
continue;
|
|
220
|
+
if (stable(builtRows.get(name)?.value) !== stable(saved.get(name)?.value))
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
const [now, then] = [actionIdentity(built), actionIdentity(entry.context)];
|
|
224
|
+
if (now.typeId && then.typeId && now.typeId !== then.typeId)
|
|
225
|
+
return false;
|
|
226
|
+
// Only the curated / generic split names a twin: an event's saved kind
|
|
227
|
+
// varies with no change of action (a trigger saved as `CuratedWaitFor` that
|
|
228
|
+
// compile writes as `CuratedTrigger`, the same activity type id).
|
|
229
|
+
if (now.activityType && then.activityType && isGenericKind(now.activityType) !== isGenericKind(then.activityType))
|
|
230
|
+
return false;
|
|
231
|
+
const values = inputValues(bag);
|
|
232
|
+
for (const name of new Set([...Object.keys(values), ...Object.keys(entry.inputs)])) {
|
|
233
|
+
const [a, b] = [values[name], entry.inputs[name]];
|
|
234
|
+
if (isEmptyInput(a) && isEmptyInput(b))
|
|
235
|
+
continue;
|
|
236
|
+
if (stable(a) !== stable(b))
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Write each saved connector context back onto the element compile built for
|
|
243
|
+
* the same owner, while that element is unchanged ({@link unchanged}). Runs
|
|
244
|
+
* after the ids are restored, so an owner key finds its element by the plan's
|
|
245
|
+
* own ids, also after a rename.
|
|
246
|
+
*/
|
|
247
|
+
export function applyConnectorContexts(result, entries) {
|
|
248
|
+
if (!entries?.length)
|
|
249
|
+
return;
|
|
250
|
+
const byOwner = new Map(entries.map((entry) => [entry.owner, entry]));
|
|
251
|
+
const v2 = result.metadata?.intsvcActivityConfig === 'v2';
|
|
252
|
+
for (const { key, bag } of caseConnectorOwners(result)) {
|
|
253
|
+
const entry = byOwner.get(key);
|
|
254
|
+
if (entry && unchanged(bag, entry, v2))
|
|
255
|
+
bag.context = structuredClone(entry.context);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/** Problems with a payload's `connectorContexts`, for `caseJsonPreservationErrors`. */
|
|
259
|
+
export function connectorContextErrors(entries) {
|
|
260
|
+
if (entries === undefined)
|
|
261
|
+
return [];
|
|
262
|
+
if (!Array.isArray(entries))
|
|
263
|
+
return ['preserved "connectorContexts" must be an array'];
|
|
264
|
+
const errors = [];
|
|
265
|
+
for (const entry of entries) {
|
|
266
|
+
const owner = entry?.owner;
|
|
267
|
+
if (typeof owner !== 'string' || !/^(trigger|task|rule):/.test(owner)) {
|
|
268
|
+
errors.push(`preserved connector context owner ${JSON.stringify(owner)} is not a trigger, task or rule key`);
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
for (const field of Object.keys(entry))
|
|
272
|
+
if (!['owner', 'context', 'inputs'].includes(field))
|
|
273
|
+
errors.push(`preserved connector context "${owner}" field "${field}" is not allowed in the preservation channel`);
|
|
274
|
+
const { context, inputs } = entry;
|
|
275
|
+
if (!Array.isArray(context) || !context.every(isObject) || !context.some((row) => row.name === 'metadata' && isObject(row.body)))
|
|
276
|
+
errors.push(`preserved connector context "${owner}" must be a list of context rows with a metadata row`);
|
|
277
|
+
if (!isObject(inputs))
|
|
278
|
+
errors.push(`preserved connector context "${owner}" inputs must be an object`);
|
|
279
|
+
}
|
|
280
|
+
return errors;
|
|
281
|
+
}
|
package/dist/case/decompile.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { Library } from '../core/library.js';
|
|
7
7
|
import { type ConnectorTaskIdentity } from './connector-saved-config.js';
|
|
8
|
+
import { type PreservedConnectorContext } from './connector-saved-context.js';
|
|
8
9
|
import { type PreservedFilterLeafId, type PreservedTriggerDisplayFields } from './preserve.js';
|
|
9
10
|
import { type PreservedResourceWire } from './resource-wire.js';
|
|
10
11
|
interface IoRow {
|
|
@@ -248,6 +249,10 @@ type Preservation = {
|
|
|
248
249
|
omitLayout?: boolean;
|
|
249
250
|
variableLanes?: Array<'inputs' | 'outputs' | 'inputOutputs'>;
|
|
250
251
|
omitInputDefaults?: string[];
|
|
252
|
+
unbridgedInArgs?: Array<{
|
|
253
|
+
name: string;
|
|
254
|
+
trigger: string;
|
|
255
|
+
}>;
|
|
251
256
|
omitMetadata?: Array<'caseAppEnabled' | 'caseIdentifierType' | 'publishVersion'>;
|
|
252
257
|
publishVersion?: number;
|
|
253
258
|
nodeFields?: Record<string, Record<string, unknown>>;
|
|
@@ -274,6 +279,7 @@ type Preservation = {
|
|
|
274
279
|
task: string;
|
|
275
280
|
metadata: Record<string, unknown>;
|
|
276
281
|
}>;
|
|
282
|
+
connectorContexts?: PreservedConnectorContext[];
|
|
277
283
|
subscriptionFilters?: Array<{
|
|
278
284
|
owner: string;
|
|
279
285
|
expression?: 'inline';
|
package/dist/case/decompile.js
CHANGED
|
@@ -8,6 +8,7 @@ import { isOlderDocumentExtractionData } from './document-extraction-saved.js';
|
|
|
8
8
|
import { isScriptOwnOutput, liftScript } from './decompile-script.js';
|
|
9
9
|
import { isHttpRequestOwnOutput, liftHttpRequest } from './decompile-http-request.js';
|
|
10
10
|
import { savedHttpRequestMetadata } from './http-request.js';
|
|
11
|
+
import { caseConnectorOwners, savedConnectorContext } from './connector-saved-context.js';
|
|
11
12
|
import { builtChainSource, chainStatements } from '../core/builder-chain.js';
|
|
12
13
|
import { literalSource } from './literal.js';
|
|
13
14
|
import { ANY_ESCALATION_ID } from './rule-options.js';
|
|
@@ -17,7 +18,7 @@ import { preserveSchemaVersion } from '../schema-version.js';
|
|
|
17
18
|
import { ownEntry } from '../core/own-entry.js';
|
|
18
19
|
import { EVENT_FILTER_OPERATORS, eventFilterExpressionOf, eventFilterFromTreeLeaf, eventFilterProblem, EXPRESSION_FILTER_OPERATORS, filterExprFromLeaf } from '../core/event-filters.js';
|
|
19
20
|
import { CASE_FILTER_SPELLING, caseSubscriptionBody, caseSubscriptionOwners } from './subscription.js';
|
|
20
|
-
import { CASE_NODE_CANVAS_FIELDS, CASE_NODE_LAYOUT_FIELDS, isTypedInputField, isUnrestorableSlotId, PRESERVED_STAGE_DATA_KEYS, PRESERVED_TRIGGER_DATA_KEYS, RESOURCE_INPUT_WRITTEN, RESOURCE_OUTPUT_WRITTEN, CASE_EMPTY_LISTS, STAGE_EMPTY_LISTS, TASK_EMPTY_LISTS, taskFingerprint, PRESERVED_ACTION_DATA_KEYS, TYPED_TRIGGER_DISPLAY_KEYS, } from './preserve.js';
|
|
21
|
+
import { CASE_NODE_CANVAS_FIELDS, CASE_NODE_LAYOUT_FIELDS, isTypedInputField, isUnrestorableSlotId, planElementIds, PRESERVED_STAGE_DATA_KEYS, PRESERVED_TRIGGER_DATA_KEYS, RESOURCE_INPUT_WRITTEN, RESOURCE_OUTPUT_WRITTEN, CASE_EMPTY_LISTS, STAGE_EMPTY_LISTS, TASK_EMPTY_LISTS, taskFingerprint, PRESERVED_ACTION_DATA_KEYS, TYPED_TRIGGER_DISPLAY_KEYS, } from './preserve.js';
|
|
21
22
|
import { stableId } from '../core/stable-id.js';
|
|
22
23
|
import { ACTION_CONTEXT_COPIES, ACTION_PASSTHROUGH_SETTINGS } from './action-settings.js';
|
|
23
24
|
import { resourceIdentity, SOLUTION_FOLDER } from './resource-identity.js';
|
|
@@ -1748,6 +1749,28 @@ function variableDescription(entry) {
|
|
|
1748
1749
|
throw new Error(`variable "${entry.name}" has a non-string "description", which is not authorable.`);
|
|
1749
1750
|
return description;
|
|
1750
1751
|
}
|
|
1752
|
+
/**
|
|
1753
|
+
* The `elementId` compile writes on each root `inputOutputs` row, by name: an
|
|
1754
|
+
* In-arg's companion takes the trigger the In-arg is bound to, every other row
|
|
1755
|
+
* `root`. An In-arg whose saved trigger is not a trigger node of the plan is
|
|
1756
|
+
* left out: compile binds it to the primary trigger, which this does not track.
|
|
1757
|
+
*/
|
|
1758
|
+
function companionElementIds(plan) {
|
|
1759
|
+
const triggers = new Set((plan.nodes ?? []).filter(isTrigger).map((node) => node.id));
|
|
1760
|
+
const out = new Map();
|
|
1761
|
+
for (const row of plan.variables?.inputOutputs ?? [])
|
|
1762
|
+
if (row?.name)
|
|
1763
|
+
out.set(row.name, 'root');
|
|
1764
|
+
for (const input of plan.variables?.inputs ?? []) {
|
|
1765
|
+
if (!input?.name)
|
|
1766
|
+
continue;
|
|
1767
|
+
if (typeof input.elementId === 'string' && triggers.has(input.elementId))
|
|
1768
|
+
out.set(input.name, input.elementId);
|
|
1769
|
+
else
|
|
1770
|
+
out.delete(input.name);
|
|
1771
|
+
}
|
|
1772
|
+
return out;
|
|
1773
|
+
}
|
|
1751
1774
|
/**
|
|
1752
1775
|
* The root `inputOutputs` rows decompile turns into a `.var()`: not an In- or
|
|
1753
1776
|
* Out-arg's companion, nor a custom row a task output writes. These are the
|
|
@@ -1866,6 +1889,23 @@ function inArgsInBridgeOrder(plan) {
|
|
|
1866
1889
|
}
|
|
1867
1890
|
return inputs;
|
|
1868
1891
|
}
|
|
1892
|
+
/**
|
|
1893
|
+
* In-args bound to a trigger of the plan that no row of that trigger reads
|
|
1894
|
+
* (`{ source: "=vars.<slot>" }`, in `data.inputs.outputs` or a V30 trigger's
|
|
1895
|
+
* stray `data.uipath.outputs`), each with that trigger's id. Compile writes
|
|
1896
|
+
* that bridge row for every In-arg.
|
|
1897
|
+
*/
|
|
1898
|
+
function unbridgedInArgs(plan) {
|
|
1899
|
+
const triggers = new Map((plan.nodes ?? []).filter(isTrigger).map((node) => [node.id, node]));
|
|
1900
|
+
return (plan.variables?.inputs ?? []).flatMap((input) => {
|
|
1901
|
+
const node = typeof input.elementId === 'string' ? triggers.get(input.elementId) : undefined;
|
|
1902
|
+
if (!node || typeof node.id !== 'string' || typeof input.id !== 'string' || !input.name)
|
|
1903
|
+
return [];
|
|
1904
|
+
const stray = node.type === 'uipath.case.trigger' ? (node.data?.uipath?.outputs ?? []) : [];
|
|
1905
|
+
const rows = [...(triggerData(node).bag?.outputs ?? []), ...stray];
|
|
1906
|
+
return rows.some((row) => row?.source === `=vars.${input.id}`) ? [] : [{ name: input.name, trigger: node.id }];
|
|
1907
|
+
});
|
|
1908
|
+
}
|
|
1869
1909
|
function emitVariables(out, depth, plan, triggerNameById, triggerIsTimer) {
|
|
1870
1910
|
const variables = plan.variables ?? {};
|
|
1871
1911
|
const produced = producedVariableNames(plan);
|
|
@@ -2774,6 +2814,11 @@ export function collectPreservation(plan) {
|
|
|
2774
2814
|
preservation.connectorConfigurations = connectorConfigurations;
|
|
2775
2815
|
if (httpRequestMetadata.length)
|
|
2776
2816
|
preservation.httpRequestMetadata = httpRequestMetadata;
|
|
2817
|
+
const connectorContexts = caseConnectorOwners(plan)
|
|
2818
|
+
.map(({ key, bag }) => savedConnectorContext(key, bag))
|
|
2819
|
+
.filter((entry) => entry !== undefined);
|
|
2820
|
+
if (connectorContexts.length)
|
|
2821
|
+
preservation.connectorContexts = connectorContexts;
|
|
2777
2822
|
const subscriptionFilterEntries = preservedSubscriptionFilters(plan);
|
|
2778
2823
|
if (subscriptionFilterEntries.length)
|
|
2779
2824
|
preservation.subscriptionFilters = subscriptionFilterEntries;
|
|
@@ -2825,6 +2870,8 @@ export function collectPreservation(plan) {
|
|
|
2825
2870
|
const legacyVariableDefaults = {};
|
|
2826
2871
|
const variableOrder = {};
|
|
2827
2872
|
const declaredInOut = declaredInOutNames(plan);
|
|
2873
|
+
const writtenElementId = companionElementIds(plan);
|
|
2874
|
+
let elementIds;
|
|
2828
2875
|
for (const lane of ['inputs', 'outputs', 'inputOutputs']) {
|
|
2829
2876
|
const rows = plan.variables?.[lane] ?? [];
|
|
2830
2877
|
if (rows.length)
|
|
@@ -2847,6 +2894,23 @@ export function collectPreservation(plan) {
|
|
|
2847
2894
|
const formalOutput = (plan.variables?.outputs ?? []).find((candidate) => candidate.name === row.name);
|
|
2848
2895
|
if (lane === 'inputOutputs' && formalOutput && row.default !== undefined && formalOutput.default !== row.default)
|
|
2849
2896
|
fields.default = row.default;
|
|
2897
|
+
// The element a root row belongs to. Compile writes the In-arg's trigger on
|
|
2898
|
+
// its companion and `root` on every other row; Studio Web can save another
|
|
2899
|
+
// (a `.var()` row it keeps under `trigger_1` after the In-arg that put it
|
|
2900
|
+
// there went). The converter copies it into the BPMN variables, so it is
|
|
2901
|
+
// carried with the value compile writes, and applied only while compile
|
|
2902
|
+
// still writes that value.
|
|
2903
|
+
if (lane === 'inputOutputs' && typeof row.elementId === 'string') {
|
|
2904
|
+
const written = writtenElementId.get(row.name);
|
|
2905
|
+
if (written !== undefined && written !== row.elementId)
|
|
2906
|
+
Object.assign(fields, {
|
|
2907
|
+
elementId: row.elementId,
|
|
2908
|
+
...(written === 'root' ? {} : { writtenElementId: written }),
|
|
2909
|
+
// One that named no element when saved stays as saved; compile cannot
|
|
2910
|
+
// tell an element an edit deleted from one that was never there.
|
|
2911
|
+
...(row.elementId === 'root' || (elementIds ??= planElementIds(plan)).has(row.elementId) ? {} : { elementIdUnresolved: true }),
|
|
2912
|
+
});
|
|
2913
|
+
}
|
|
2850
2914
|
if (lane === 'outputs' && row.var !== undefined)
|
|
2851
2915
|
fields.var = row.var;
|
|
2852
2916
|
// `body` is typed only on a structured (`jsonSchema`) variable. On any
|
|
@@ -2879,6 +2943,9 @@ export function collectPreservation(plan) {
|
|
|
2879
2943
|
.map((row) => row.name);
|
|
2880
2944
|
if (omitInputDefaults.length)
|
|
2881
2945
|
preservation.omitInputDefaults = omitInputDefaults;
|
|
2946
|
+
const unbridged = unbridgedInArgs(plan);
|
|
2947
|
+
if (unbridged.length)
|
|
2948
|
+
preservation.unbridgedInArgs = unbridged;
|
|
2882
2949
|
if (Object.keys(variableFields).length)
|
|
2883
2950
|
preservation.variableFields = variableFields;
|
|
2884
2951
|
if (Object.keys(legacyVariableDefaults).length)
|
package/dist/case/preserve.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PreservedConnectorContext } from './connector-saved-context.js';
|
|
1
2
|
import type { BuiltCase } from './case-sdk.js';
|
|
2
3
|
import type { ReadEventFilter } from '../core/event-filters.js';
|
|
3
4
|
import { Bindings } from '../core/bindings.js';
|
|
@@ -5,6 +6,14 @@ import type { BindingsView } from '../core/binding-messages.js';
|
|
|
5
6
|
import { type PreservedResourceWire } from './resource-wire.js';
|
|
6
7
|
import { type PreservedDocumentExtractionData } from './document-extraction-saved.js';
|
|
7
8
|
export type PreservedVariableLane = 'inputs' | 'outputs' | 'inputOutputs';
|
|
9
|
+
/**
|
|
10
|
+
* The ids a variable row's `elementId` can name in `plan`: every node (stages,
|
|
11
|
+
* triggers), and every task, by its own id and by the `<stageId>-<taskId>`
|
|
12
|
+
* form Studio Web writes on task io rows.
|
|
13
|
+
*/
|
|
14
|
+
export declare function planElementIds(plan: {
|
|
15
|
+
nodes?: unknown;
|
|
16
|
+
}): Set<string>;
|
|
8
17
|
/**
|
|
9
18
|
* A preserved `inputs[]` / `outputs[]` slot id copied verbatim from its name is
|
|
10
19
|
* the STRICT_FORMAL_ARG_ID defect, not an identity to keep; the minted id stands.
|
|
@@ -301,6 +310,18 @@ export interface CaseJsonPreservation {
|
|
|
301
310
|
* platform's V23 -> V24 migration does when it makes the same change.
|
|
302
311
|
*/
|
|
303
312
|
legacyTriggerIds?: string[];
|
|
313
|
+
/**
|
|
314
|
+
* In-args whose trigger has no bridge row reading them (no `{ source:
|
|
315
|
+
* "=vars.<slot>" }` in its `outputs`). Compile writes that row for every
|
|
316
|
+
* In-arg; a Studio Web plan can lack it, and then the companion is never set
|
|
317
|
+
* when the case starts. Compile leaves the row out again for each In-arg
|
|
318
|
+
* only while it is still bound to the trigger that lacked the row: an edit
|
|
319
|
+
* that binds it to another trigger gets that trigger's bridge.
|
|
320
|
+
*/
|
|
321
|
+
unbridgedInArgs?: Array<{
|
|
322
|
+
name: string;
|
|
323
|
+
trigger: string;
|
|
324
|
+
}>;
|
|
304
325
|
/**
|
|
305
326
|
* Opaque V30 layout side-car. Decompile folds a node's inline
|
|
306
327
|
* {@link CASE_NODE_LAYOUT_FIELDS} into it, the platform's disk form.
|
|
@@ -344,7 +365,16 @@ export interface CaseJsonPreservation {
|
|
|
344
365
|
* being silently rewritten.
|
|
345
366
|
*/
|
|
346
367
|
publishVersion?: number;
|
|
347
|
-
/**
|
|
368
|
+
/**
|
|
369
|
+
* Designer-internal variable fields keyed by lane and variable name. On an
|
|
370
|
+
* `inputOutputs` row, `elementId` is the element Studio Web saved the row
|
|
371
|
+
* under when compile writes another (`writtenElementId`, absent for `root`);
|
|
372
|
+
* compile puts it back only while it still writes that value, so a source
|
|
373
|
+
* edit that moves the row (a `.var()` made an In-arg) keeps compile's. It is
|
|
374
|
+
* also put back only while it is `root` or names an element of the plan
|
|
375
|
+
* (`planElementIds`), unless it named none when saved
|
|
376
|
+
* (`elementIdUnresolved`): an edit that deletes that element gets `root`.
|
|
377
|
+
*/
|
|
348
378
|
variableFields?: Partial<Record<PreservedVariableLane, Record<string, Record<string, unknown>>>>;
|
|
349
379
|
/**
|
|
350
380
|
* Legacy non-string defaults retained by decompile/recompile. Each value must
|
|
@@ -363,6 +393,13 @@ export interface CaseJsonPreservation {
|
|
|
363
393
|
* another connector version is written back instead of downgraded.
|
|
364
394
|
*/
|
|
365
395
|
httpRequestMetadata?: PreservedHttpRequestMetadata[];
|
|
396
|
+
/**
|
|
397
|
+
* Each Designer-saved connector element's `context` (an event trigger, a
|
|
398
|
+
* wait-for-connector task or rule, a connector activity task), verbatim,
|
|
399
|
+
* keyed by owner. Compile writes it back while the element is unchanged
|
|
400
|
+
* (`case/connector-saved-context.ts`).
|
|
401
|
+
*/
|
|
402
|
+
connectorContexts?: PreservedConnectorContext[];
|
|
366
403
|
/**
|
|
367
404
|
* Action tasks' Designer-owned `data` fields: the `context` rows the Designer
|
|
368
405
|
* saves with a form (its `hitlType`, quick-form schema ids, and a copy of the
|
package/dist/case/preserve.js
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
1
|
+
import { connectorContextErrors } from './connector-saved-context.js';
|
|
1
2
|
import { stableId } from '../core/stable-id.js';
|
|
2
3
|
import { Bindings } from '../core/bindings.js';
|
|
3
4
|
import { bindingIdCandidates, offlineBindingLabel } from './ids.js';
|
|
4
5
|
import { resourceBindingSeed, resourceWireError } from './resource-wire.js';
|
|
5
6
|
import { preservedDocumentExtractionDataError } from './document-extraction-saved.js';
|
|
7
|
+
/**
|
|
8
|
+
* The ids a variable row's `elementId` can name in `plan`: every node (stages,
|
|
9
|
+
* triggers), and every task, by its own id and by the `<stageId>-<taskId>`
|
|
10
|
+
* form Studio Web writes on task io rows.
|
|
11
|
+
*/
|
|
12
|
+
export function planElementIds(plan) {
|
|
13
|
+
const ids = new Set();
|
|
14
|
+
for (const node of (Array.isArray(plan.nodes) ? plan.nodes : [])) {
|
|
15
|
+
if (typeof node?.id !== 'string')
|
|
16
|
+
continue;
|
|
17
|
+
ids.add(node.id);
|
|
18
|
+
for (const task of (node.data?.tasks ?? []).flat())
|
|
19
|
+
if (typeof task?.id === 'string')
|
|
20
|
+
ids.add(task.id).add(`${node.id}-${task.id}`);
|
|
21
|
+
}
|
|
22
|
+
return ids;
|
|
23
|
+
}
|
|
6
24
|
/**
|
|
7
25
|
* A preserved `inputs[]` / `outputs[]` slot id copied verbatim from its name is
|
|
8
26
|
* the STRICT_FORMAL_ARG_ID defect, not an identity to keep; the minted id stands.
|
|
@@ -279,6 +297,13 @@ export function caseJsonPreservationErrors(payload) {
|
|
|
279
297
|
continue;
|
|
280
298
|
}
|
|
281
299
|
// A carried `body` names the non-structured type it was saved for.
|
|
300
|
+
for (const [name, fields] of Object.entries(rows ?? {}))
|
|
301
|
+
for (const field of ['elementId', 'writtenElementId'])
|
|
302
|
+
if (fields[field] !== undefined && (typeof fields[field] !== 'string' || fields[field] === ''))
|
|
303
|
+
errors.push(`variable "${name}" carried ${field} must be a non-empty string`);
|
|
304
|
+
for (const [name, fields] of Object.entries(rows ?? {}))
|
|
305
|
+
if (fields.elementIdUnresolved !== undefined && fields.elementIdUnresolved !== true)
|
|
306
|
+
errors.push(`variable "${name}" carried elementIdUnresolved must be true when present`);
|
|
282
307
|
for (const [name, fields] of Object.entries(rows ?? {}))
|
|
283
308
|
if (fields.body !== undefined && (typeof fields.bodyType !== 'string' || fields.bodyType === 'jsonSchema'))
|
|
284
309
|
errors.push(`variable "${name}" carried body needs the non-jsonSchema type it was saved for (bodyType)`);
|
|
@@ -287,12 +312,12 @@ export function caseJsonPreservationErrors(payload) {
|
|
|
287
312
|
if (lane === 'inputOutputs' && field === 'value')
|
|
288
313
|
errors.push(`variable "${name}" field "value" on inputOutputs is behavior (a process mapping's var) and cannot be preserved`);
|
|
289
314
|
else if (!PRESERVED_VARIABLE_KEYS.has(field)
|
|
290
|
-
&& !(lane === 'inputOutputs' && (field === 'default' || field === 'custom'))
|
|
315
|
+
&& !(lane === 'inputOutputs' && (field === 'default' || field === 'custom' || field === 'elementId' || field === 'writtenElementId' || field === 'elementIdUnresolved'))
|
|
291
316
|
&& !(lane === 'outputs' && field === 'var')
|
|
292
317
|
&& field !== 'body' && field !== 'bodyType')
|
|
293
318
|
errors.push(`variable "${name}" field "${field}" is not an allowed preserved designer field`);
|
|
294
319
|
else if (VARIABLE_KEYS.has(field)
|
|
295
|
-
&& !(lane === 'inputOutputs' && field === 'default')
|
|
320
|
+
&& !(lane === 'inputOutputs' && (field === 'default' || field === 'elementId'))
|
|
296
321
|
&& !(lane === 'outputs' && field === 'var')
|
|
297
322
|
&& field !== 'body')
|
|
298
323
|
errors.push(`variable "${name}" field "${field}" is owned by the typed Case serializer`);
|
|
@@ -313,6 +338,10 @@ export function caseJsonPreservationErrors(payload) {
|
|
|
313
338
|
errors.push(`legacy variable default "${name}" must be a JSON-encodable non-string value`);
|
|
314
339
|
}
|
|
315
340
|
}
|
|
341
|
+
if (payload.unbridgedInArgs !== undefined
|
|
342
|
+
&& (!Array.isArray(payload.unbridgedInArgs) || !payload.unbridgedInArgs.every((entry) => entry !== null && typeof entry === 'object'
|
|
343
|
+
&& typeof entry.name === 'string' && entry.name !== '' && typeof entry.trigger === 'string' && entry.trigger !== '')))
|
|
344
|
+
errors.push('preserved "unbridgedInArgs" must be an array of { name, trigger } with non-empty strings');
|
|
316
345
|
if (payload.legacyTriggerIds !== undefined
|
|
317
346
|
&& (!Array.isArray(payload.legacyTriggerIds) || !payload.legacyTriggerIds.every((id) => typeof id === 'string')))
|
|
318
347
|
errors.push('preserved "legacyTriggerIds" must be an array of trigger id strings');
|
|
@@ -433,6 +462,7 @@ export function caseJsonPreservationErrors(payload) {
|
|
|
433
462
|
if (!entry?.metadata || typeof entry.metadata !== 'object' || Array.isArray(entry.metadata))
|
|
434
463
|
errors.push(`preserved http-request metadata of task "${entry?.task}" must be an object`);
|
|
435
464
|
}
|
|
465
|
+
errors.push(...connectorContextErrors(payload.connectorContexts));
|
|
436
466
|
for (const index of payload.manualTriggerServiceTypeNone ?? [])
|
|
437
467
|
if (!Number.isInteger(index) || index < 0)
|
|
438
468
|
errors.push(`manual trigger position "${index}" is not a non-negative integer`);
|
package/dist/case/serialize.js
CHANGED
|
@@ -9,13 +9,14 @@
|
|
|
9
9
|
* name) are resolved here to the generated ids.
|
|
10
10
|
*/
|
|
11
11
|
import { IdGen, offlineBindingSeed } from './ids.js';
|
|
12
|
-
import { CASE_EMPTY_LISTS, isUnrestorableSlotId, METADATA_ABSENT_READING, STAGE_EMPTY_LISTS, TASK_EMPTY_LISTS, taskFingerprint } from './preserve.js';
|
|
12
|
+
import { CASE_EMPTY_LISTS, isUnrestorableSlotId, METADATA_ABSENT_READING, planElementIds, STAGE_EMPTY_LISTS, TASK_EMPTY_LISTS, taskFingerprint } from './preserve.js';
|
|
13
13
|
import { v31TaskSets } from './task-sets.js';
|
|
14
14
|
import { camelizeName, defaultActionOutputVar } from './action-output-var.js';
|
|
15
15
|
import { ACTION_CONTEXT_COPIES, ACTION_FORM_KIND_CONTEXT, ACTION_PASSTHROUGH_SETTINGS } from './action-settings.js';
|
|
16
16
|
import { buildConnectorInputs, nestConnectorBody, transportHttpMethod } from '../core/connector-inputs.js';
|
|
17
17
|
import { carriedConnectorFieldsRefusal, withCarriedFields } from '../core/carried-connector-fields.js';
|
|
18
18
|
import { connectorTaskIdentity, sameConnectorOperation, withCurrentCaches, writeOptionalConfiguration } from './connector-saved-config.js';
|
|
19
|
+
import { applyConnectorContexts } from './connector-saved-context.js';
|
|
19
20
|
import { connectorActivityMetadata, connectorEventFilterTree, connectorEventMetadata } from '../core/connector-v2-metadata.js';
|
|
20
21
|
import { EQUALS_EXPR_DIALECT } from '../core/connector-checks.js';
|
|
21
22
|
import { bindingLabelRefusal, connectionStubMessage } from '../core/binding-messages.js';
|
|
@@ -623,6 +624,7 @@ export function applyPreservation(result, preservation, options = {}) {
|
|
|
623
624
|
const named = new Set(order ?? []);
|
|
624
625
|
variables[lane] = [...ordered, ...rows.filter((row) => !named.has(String(row.name ?? '')))];
|
|
625
626
|
}
|
|
627
|
+
let elementIds;
|
|
626
628
|
for (const [lane, byName] of Object.entries(preservation.variableFields ?? {})) {
|
|
627
629
|
const rows = variables[lane] ?? [];
|
|
628
630
|
for (const [name, fields] of Object.entries(byName ?? {})) {
|
|
@@ -631,16 +633,27 @@ export function applyPreservation(result, preservation, options = {}) {
|
|
|
631
633
|
continue;
|
|
632
634
|
// `custom` alone has nothing to mark when no row is written: an older SDK's
|
|
633
635
|
// companion for a variable an output writes, which this one migrates away.
|
|
634
|
-
|
|
636
|
+
// A carried `elementId` likewise has no row to re-point.
|
|
637
|
+
if (!row && Object.keys(fields).every((field) => field === 'custom' || (lane === 'inputOutputs' && (field === 'elementId' || field === 'writtenElementId' || field === 'elementIdUnresolved'))))
|
|
635
638
|
continue;
|
|
636
639
|
if (!row)
|
|
637
640
|
throw new CompileRefusal('PRESERVATION_TARGET_MISSING', `preserved variable "${name}" was not regenerated in variables.${lane}.`);
|
|
638
641
|
for (const [field, value] of Object.entries(fields)) {
|
|
639
642
|
// `bodyType` is the type a carried `body` was saved for, not a field.
|
|
640
|
-
if (field === 'bodyType')
|
|
643
|
+
if (field === 'bodyType' || field === 'writtenElementId' || field === 'elementIdUnresolved')
|
|
641
644
|
continue;
|
|
642
645
|
if (row[field] === value)
|
|
643
646
|
continue;
|
|
647
|
+
// A saved `elementId` replaces the one compile writes only while compile
|
|
648
|
+
// writes the value it wrote at decompile; an edit that moved the row wins.
|
|
649
|
+
// It must also still name an element of the plan (or have named none when
|
|
650
|
+
// saved): an edit that deleted the trigger it names gets compile's `root`.
|
|
651
|
+
if (lane === 'inputOutputs' && field === 'elementId') {
|
|
652
|
+
const stillThere = value === 'root' || fields.elementIdUnresolved === true || (elementIds ??= planElementIds(result)).has(String(value));
|
|
653
|
+
if (stillThere && row.elementId === (fields.writtenElementId ?? 'root'))
|
|
654
|
+
row.elementId = value;
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
644
657
|
// A carried `body` describes the type it was saved with. A variable the
|
|
645
658
|
// edit gave another type (a `string`, or a `jsonSchema` with the schema
|
|
646
659
|
// the author typed) does not get it.
|
|
@@ -675,6 +688,23 @@ export function applyPreservation(result, preservation, options = {}) {
|
|
|
675
688
|
row.default = value;
|
|
676
689
|
}
|
|
677
690
|
}
|
|
691
|
+
// An In-arg its trigger had no bridge row for: drop the row compile wrote,
|
|
692
|
+
// and the `outputs` list when that row was its only entry. Only while the
|
|
693
|
+
// In-arg is still bound to that trigger: one an edit rebinds keeps its bridge.
|
|
694
|
+
for (const { name, trigger } of preservation.unbridgedInArgs ?? []) {
|
|
695
|
+
const input = (variables.inputs ?? []).find((candidate) => candidate.name === name);
|
|
696
|
+
if (!input || typeof input.id !== 'string' || input.elementId !== trigger)
|
|
697
|
+
continue;
|
|
698
|
+
const node = result.nodes.find((candidate) => candidate.id === input.elementId);
|
|
699
|
+
const bag = node?.data?.[CASE_FORMAT_PROFILE.triggerBagField];
|
|
700
|
+
if (!Array.isArray(bag?.outputs))
|
|
701
|
+
continue;
|
|
702
|
+
bag.outputs = bag.outputs.filter((row) => row?.source !== `=vars.${input.id}`);
|
|
703
|
+
if (!bag.outputs.length)
|
|
704
|
+
delete bag.outputs;
|
|
705
|
+
if (!Object.keys(bag).length)
|
|
706
|
+
delete node.data[CASE_FORMAT_PROFILE.triggerBagField];
|
|
707
|
+
}
|
|
678
708
|
for (const name of preservation.omitInputDefaults ?? []) {
|
|
679
709
|
const row = (variables.inputs ?? []).find((candidate) => candidate.name === name);
|
|
680
710
|
if (row?.default === '')
|
|
@@ -742,6 +772,9 @@ export function applyPreservation(result, preservation, options = {}) {
|
|
|
742
772
|
continue;
|
|
743
773
|
writeHttpRequestMetadata(task.data, entry.metadata);
|
|
744
774
|
}
|
|
775
|
+
// After the subscription filters and the optional halves: an unchanged
|
|
776
|
+
// connector element takes its saved context whole.
|
|
777
|
+
applyConnectorContexts(result, preservation.connectorContexts);
|
|
745
778
|
for (const entry of preservation.actionDataFields ?? []) {
|
|
746
779
|
const stage = stageNodes.find((candidate) => candidate.data?.label === entry.stage);
|
|
747
780
|
const task = stageTask(stage, entry.task);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.93.
|
|
3
|
+
"version": "6.93.4",
|
|
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",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"@types/node": "^22.7.0",
|
|
112
112
|
"esbuild": "^0.28.1"
|
|
113
113
|
},
|
|
114
|
-
"gitref": "
|
|
114
|
+
"gitref": "eaccb8095e2b8920cc42d99737e369fd6ab30f8d"
|
|
115
115
|
}
|