@uipath/maestro-builder-sdk 6.94.1 → 6.94.3
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-rows.d.ts +42 -0
- package/dist/case/connector-saved-rows.js +318 -0
- package/dist/case/decompile.d.ts +2 -0
- package/dist/case/decompile.js +43 -1
- package/dist/case/preserve.d.ts +28 -0
- package/dist/case/preserve.js +2 -0
- package/dist/case/serialize.d.ts +3 -1
- package/dist/case/serialize.js +107 -3
- package/dist/core/refusals.d.ts +1 -0
- package/dist/core/refusals.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** One half (inputs or outputs) of a saved connector element's own rows. */
|
|
2
|
+
export interface PreservedConnectorRowSet {
|
|
3
|
+
/** The own rows, verbatim, in saved order. */
|
|
4
|
+
rows: Array<Record<string, unknown>>;
|
|
5
|
+
/** The element was saved with no such field at all. */
|
|
6
|
+
absent?: true;
|
|
7
|
+
}
|
|
8
|
+
/** One saved connector element's own rows, as `preserveCaseJson` carries them. */
|
|
9
|
+
export interface PreservedConnectorRows {
|
|
10
|
+
/** `trigger:<node id>`, `task:<task id>` or `rule:<stage id>:<rule id>`. */
|
|
11
|
+
owner: string;
|
|
12
|
+
/** The operation the rows were saved for: each identity context row's value, by name. */
|
|
13
|
+
operation: Record<string, string>;
|
|
14
|
+
inputs?: PreservedConnectorRowSet;
|
|
15
|
+
outputs?: PreservedConnectorRowSet;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Every connector element and the bag that holds its rows: event triggers,
|
|
19
|
+
* wait-for-connector tasks and rules (`caseSubscriptionOwners`), and each
|
|
20
|
+
* `execute-connector-activity` task. A task is keyed by its own id, not its
|
|
21
|
+
* stage's: a task moved to another stage keeps its element ids, and its rows
|
|
22
|
+
* with them.
|
|
23
|
+
*/
|
|
24
|
+
export declare function caseConnectorRowOwners(plan: Record<string, any>): Array<{
|
|
25
|
+
key: string;
|
|
26
|
+
bag: Record<string, any>;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* The saved own rows of a connector element, for each half compile would not
|
|
30
|
+
* write as it is: a row in another shape, a row missing, or no such field.
|
|
31
|
+
* Else `undefined`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function savedConnectorRows(owner: string, bag: Record<string, any>): PreservedConnectorRows | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Write each element's saved own rows back over the ones compile built, half
|
|
36
|
+
* by half, while they still describe the element. Runs after the ids are
|
|
37
|
+
* restored, so an owner key finds its element by the plan's own ids, also
|
|
38
|
+
* after a rename.
|
|
39
|
+
*/
|
|
40
|
+
export declare function applyConnectorRows(result: Record<string, any>, entries: readonly PreservedConnectorRows[] | undefined): void;
|
|
41
|
+
/** Problems with a payload's `connectorRows`, for `caseJsonPreservationErrors`. */
|
|
42
|
+
export declare function connectorRowErrors(entries: unknown): string[];
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Designer-saved connector element's own io rows, 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 or rule, and an `execute-connector-activity` task.
|
|
7
|
+
* Each has rows of its own, which compile rebuilds from the library:
|
|
8
|
+
*
|
|
9
|
+
* - inputs: the request containers (`pathParameters`, `queryParameters`,
|
|
10
|
+
* `body`, a multipart `file` part; an event's `body` subscription), each
|
|
11
|
+
* written `{ name, type, target, body, var: "v<name>", id, elementId }`, with
|
|
12
|
+
* `body: {}` for an unused container (`ioSlot`, `eventInput`);
|
|
13
|
+
* - outputs: `response` (`source: "=response"`) and `Error` (`source:
|
|
14
|
+
* "=Error"`), written with `displayName: "Response"`, a `target: "=<var>"`,
|
|
15
|
+
* and the response schema built from the library's flat output fields
|
|
16
|
+
* (`connectorOutputs`), titles and types only.
|
|
17
|
+
*
|
|
18
|
+
* That is right for a new element. For one Studio Web saved, it rewrote those
|
|
19
|
+
* rows on the first round trip, even with no edit. The Designer saves its own
|
|
20
|
+
* copies: an event `body` row with no `id`, `var` or `elementId`; a container
|
|
21
|
+
* with no `body`, or no row at all for an unused one; an output label the
|
|
22
|
+
* author picked (`"Attachment"`), no `target`, the `_jsonSchema` copy of the
|
|
23
|
+
* body, and the schema as Integration Service described it (field
|
|
24
|
+
* `description`s, an array root); some elements have one output row or none.
|
|
25
|
+
*
|
|
26
|
+
* So decompile records each such element's own rows verbatim, with the
|
|
27
|
+
* operation they were saved for, keyed by owner (`trigger:<node id>`,
|
|
28
|
+
* `task:<task id>` or `rule:<stage id>:<rule id>`). Compile writes each half
|
|
29
|
+
* back while it still describes the element:
|
|
30
|
+
*
|
|
31
|
+
* - outputs, while the element calls the same operation (same `connectorKey`,
|
|
32
|
+
* `objectName`, `method`, `path` and event `operation`) and each saved row's
|
|
33
|
+
* compiled counterpart writes the same variable;
|
|
34
|
+
* - inputs, while it calls the same operation and every input holds the value
|
|
35
|
+
* it was saved with (an input only one side has must be empty).
|
|
36
|
+
*
|
|
37
|
+
* Any other edit gets the rows compile built, as before: another operation
|
|
38
|
+
* has another response, and an edited value must be written.
|
|
39
|
+
*
|
|
40
|
+
* For instance, an Outlook "Email received" trigger saved with `inputs: [{
|
|
41
|
+
* name: "body", type: "json", target: "body", body: { filters: … } }]` (no
|
|
42
|
+
* id) and no `outputs` comes back that way while it watches the same folder.
|
|
43
|
+
* Point it at another folder and compile writes its own `vbody` row.
|
|
44
|
+
*
|
|
45
|
+
* An element whose rows are what compile writes anyway (an SDK-authored
|
|
46
|
+
* plan's) records nothing for that half, so its source carries no copy.
|
|
47
|
+
*/
|
|
48
|
+
import { caseSubscriptionOwners } from './subscription.js';
|
|
49
|
+
const CONNECTOR_ACTIVITY_TYPE = 'execute-connector-activity';
|
|
50
|
+
/** The context rows that name the operation an element calls. */
|
|
51
|
+
const OPERATION_ROWS = ['connectorKey', 'objectName', 'method', 'path', 'operation'];
|
|
52
|
+
const OWN_SOURCES = new Set(['=response', '=Error']);
|
|
53
|
+
/** The input containers compile writes on every connector activity (`ioSlot`). */
|
|
54
|
+
const ACTIVITY_CONTAINERS = ['pathParameters', 'queryParameters', 'body'];
|
|
55
|
+
const isObject = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
56
|
+
/**
|
|
57
|
+
* Every connector element and the bag that holds its rows: event triggers,
|
|
58
|
+
* wait-for-connector tasks and rules (`caseSubscriptionOwners`), and each
|
|
59
|
+
* `execute-connector-activity` task. A task is keyed by its own id, not its
|
|
60
|
+
* stage's: a task moved to another stage keeps its element ids, and its rows
|
|
61
|
+
* with them.
|
|
62
|
+
*/
|
|
63
|
+
export function caseConnectorRowOwners(plan) {
|
|
64
|
+
const out = caseSubscriptionOwners(plan)
|
|
65
|
+
.map(({ key, bag }) => ({ key: key.startsWith('task:') ? `task:${key.split(':').slice(2).join(':')}` : key, bag }));
|
|
66
|
+
for (const node of Array.isArray(plan?.nodes) ? plan.nodes : []) {
|
|
67
|
+
if (!String(node?.type ?? '').endsWith('Stage'))
|
|
68
|
+
continue;
|
|
69
|
+
for (const lane of Array.isArray(node.data?.tasks) ? node.data.tasks : [])
|
|
70
|
+
for (const task of Array.isArray(lane) ? lane : [])
|
|
71
|
+
if (task?.type === CONNECTOR_ACTIVITY_TYPE && isObject(task.data))
|
|
72
|
+
out.push({ key: `task:${task.id}`, bag: task.data });
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
/** Whether `row` is one of the element's own outputs (not an author's extract or assignment). */
|
|
77
|
+
function isOwnOutput(row) {
|
|
78
|
+
return isObject(row) && row.custom !== true && typeof row.source === 'string' && OWN_SOURCES.has(row.source);
|
|
79
|
+
}
|
|
80
|
+
/** Whether `row` is an input row: an object with a name. */
|
|
81
|
+
function isInputRow(row) {
|
|
82
|
+
return isObject(row) && typeof row.name === 'string';
|
|
83
|
+
}
|
|
84
|
+
/** The operation an element calls: its identity context rows' string values. */
|
|
85
|
+
function operationOf(bag) {
|
|
86
|
+
const out = {};
|
|
87
|
+
for (const row of Array.isArray(bag.context) ? bag.context : [])
|
|
88
|
+
if (isObject(row) && OPERATION_ROWS.includes(row.name) && typeof row.value === 'string')
|
|
89
|
+
out[row.name] = row.value;
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
/** `value` with object keys sorted, so key order does not count. */
|
|
93
|
+
function stable(value) {
|
|
94
|
+
if (Array.isArray(value))
|
|
95
|
+
return `[${value.map(stable).join(',')}]`;
|
|
96
|
+
if (isObject(value))
|
|
97
|
+
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stable(value[key])}`).join(',')}}`;
|
|
98
|
+
return JSON.stringify(value) ?? 'undefined';
|
|
99
|
+
}
|
|
100
|
+
/** An input that holds nothing: absent, `""`, `{}` or `[]`. */
|
|
101
|
+
function isEmpty(value) {
|
|
102
|
+
return value === undefined || value === null || value === ''
|
|
103
|
+
|| (Array.isArray(value) && value.length === 0) || (isObject(value) && Object.keys(value).length === 0);
|
|
104
|
+
}
|
|
105
|
+
/** The `Error` row's schema compile writes (serialize.ts `ERROR_OUTPUT_SCHEMA`). */
|
|
106
|
+
const ERROR_SCHEMA = stable({
|
|
107
|
+
type: 'object',
|
|
108
|
+
properties: {
|
|
109
|
+
code: { type: 'string' }, message: { type: 'string' }, detail: { type: 'string' },
|
|
110
|
+
category: { type: 'string' }, status: { type: 'number' }, element: { type: 'string' },
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
const SDK_OUTPUT_FIELDS = new Set(['name', 'displayName', 'type', 'source', 'body', 'var', 'id', 'value', 'target', 'elementId']);
|
|
114
|
+
const SDK_INPUT_FIELDS = new Set(['name', 'type', 'target', 'body', 'value', 'var', 'id', 'elementId']);
|
|
115
|
+
/** The keys `responseJsonSchema` writes on any schema node. */
|
|
116
|
+
const SDK_SCHEMA_FIELDS = new Set(['$schema', 'type', 'properties', 'definitions', 'title', 'items', '$ref']);
|
|
117
|
+
/** Whether every node of `schema` has only keys `responseJsonSchema` writes, under an object root. */
|
|
118
|
+
function sdkSchema(schema) {
|
|
119
|
+
if (!isObject(schema) || schema.type !== 'object')
|
|
120
|
+
return false;
|
|
121
|
+
const node = (value) => {
|
|
122
|
+
if (!isObject(value))
|
|
123
|
+
return false;
|
|
124
|
+
if (!Object.keys(value).every((key) => SDK_SCHEMA_FIELDS.has(key)))
|
|
125
|
+
return false;
|
|
126
|
+
for (const key of ['properties', 'definitions'])
|
|
127
|
+
if (value[key] !== undefined && !(isObject(value[key]) && Object.values(value[key]).every(node)))
|
|
128
|
+
return false;
|
|
129
|
+
return value.items === undefined || node(value.items);
|
|
130
|
+
};
|
|
131
|
+
return node(schema);
|
|
132
|
+
}
|
|
133
|
+
/** Whether compile could have written output `row` as it is (`connectorOutputs`). */
|
|
134
|
+
function sdkShapedOutput(row) {
|
|
135
|
+
if (!Object.keys(row).every((key) => SDK_OUTPUT_FIELDS.has(key)))
|
|
136
|
+
return false;
|
|
137
|
+
const error = row.source === '=Error';
|
|
138
|
+
if (row.name !== (error ? 'Error' : 'response') || row.displayName !== (error ? 'Error' : 'Response') || row.type !== 'jsonSchema')
|
|
139
|
+
return false;
|
|
140
|
+
if (typeof row.var !== 'string' || row.id !== row.var || row.value !== row.var || row.target !== `=${row.var}`)
|
|
141
|
+
return false;
|
|
142
|
+
if (typeof row.elementId !== 'string')
|
|
143
|
+
return false;
|
|
144
|
+
return error ? stable(row.body) === ERROR_SCHEMA : sdkSchema(row.body);
|
|
145
|
+
}
|
|
146
|
+
/** Whether compile could have written input `row` as it is (`ioSlot`, `fileSlot`, `eventInput`). */
|
|
147
|
+
function sdkShapedInput(row) {
|
|
148
|
+
if (!Object.keys(row).every((key) => SDK_INPUT_FIELDS.has(key)))
|
|
149
|
+
return false;
|
|
150
|
+
if (typeof row.var !== 'string' || row.id !== row.var || typeof row.elementId !== 'string')
|
|
151
|
+
return false;
|
|
152
|
+
if (row.type === 'file')
|
|
153
|
+
return row.target === 'file' && row.body === undefined;
|
|
154
|
+
return row.type === 'json' && row.target === row.name && (row.body !== undefined) !== (row.value !== undefined);
|
|
155
|
+
}
|
|
156
|
+
/** The saved outputs half, when compile would not write it as it is. */
|
|
157
|
+
function savedOutputs(bag) {
|
|
158
|
+
if (bag.outputs !== undefined && !Array.isArray(bag.outputs))
|
|
159
|
+
return undefined;
|
|
160
|
+
const rows = (bag.outputs ?? []).filter(isOwnOutput);
|
|
161
|
+
// A source saved twice has no one row to carry; leave the half to compile, as
|
|
162
|
+
// `savedInputs` does for a repeated name (the payload check would refuse it).
|
|
163
|
+
const sources = new Set(rows.map((row) => row.source));
|
|
164
|
+
if (sources.size !== rows.length)
|
|
165
|
+
return undefined;
|
|
166
|
+
const complete = rows.length === 2 && sources.size === 2;
|
|
167
|
+
if (bag.outputs !== undefined && complete && rows.every(sdkShapedOutput))
|
|
168
|
+
return undefined;
|
|
169
|
+
return { rows: structuredClone(rows), ...(bag.outputs === undefined ? { absent: true } : {}) };
|
|
170
|
+
}
|
|
171
|
+
/** The saved inputs half, when compile would not write it as it is. */
|
|
172
|
+
function savedInputs(bag, activity) {
|
|
173
|
+
if (bag.inputs !== undefined && !Array.isArray(bag.inputs))
|
|
174
|
+
return undefined;
|
|
175
|
+
const rows = bag.inputs ?? [];
|
|
176
|
+
// A row decompile does not read as a container is the author's; leave them all to compile.
|
|
177
|
+
if (!rows.every(isInputRow))
|
|
178
|
+
return undefined;
|
|
179
|
+
const names = new Set(rows.map((row) => row.name));
|
|
180
|
+
if (names.size !== rows.length)
|
|
181
|
+
return undefined;
|
|
182
|
+
const complete = activity ? ACTIVITY_CONTAINERS.every((name) => names.has(name)) : rows.length === 1;
|
|
183
|
+
if (bag.inputs !== undefined && complete && rows.every(sdkShapedInput))
|
|
184
|
+
return undefined;
|
|
185
|
+
return { rows: structuredClone(rows), ...(bag.inputs === undefined ? { absent: true } : {}) };
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The saved own rows of a connector element, for each half compile would not
|
|
189
|
+
* write as it is: a row in another shape, a row missing, or no such field.
|
|
190
|
+
* Else `undefined`.
|
|
191
|
+
*/
|
|
192
|
+
export function savedConnectorRows(owner, bag) {
|
|
193
|
+
const operation = operationOf(bag);
|
|
194
|
+
if (operation.connectorKey === undefined)
|
|
195
|
+
return undefined;
|
|
196
|
+
const activity = bag.serviceType !== 'Intsvc.EventTrigger' && bag.serviceType !== 'Intsvc.WaitForEvent';
|
|
197
|
+
const outputs = savedOutputs(bag);
|
|
198
|
+
const inputs = savedInputs(bag, activity);
|
|
199
|
+
if (!outputs && !inputs)
|
|
200
|
+
return undefined;
|
|
201
|
+
return { owner, operation, ...(inputs ? { inputs } : {}), ...(outputs ? { outputs } : {}) };
|
|
202
|
+
}
|
|
203
|
+
/** Whether the element compile built calls the operation the rows were saved for. */
|
|
204
|
+
function sameOperation(bag, entry) {
|
|
205
|
+
const now = operationOf(bag);
|
|
206
|
+
return OPERATION_ROWS.every((name) => now[name] === entry.operation[name]);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The saved outputs over the built ones: the saved own rows in saved order,
|
|
210
|
+
* where compile put its first own row, around the rows compile writes for the
|
|
211
|
+
* author; a built own row the element was saved without is dropped. Nothing,
|
|
212
|
+
* when a saved row's counterpart writes another variable.
|
|
213
|
+
*/
|
|
214
|
+
function outputsBack(built, set) {
|
|
215
|
+
const builtOwn = new Map(built.filter(isOwnOutput).map((row) => [row.source, row]));
|
|
216
|
+
for (const row of set.rows) {
|
|
217
|
+
const counterpart = builtOwn.get(row.source);
|
|
218
|
+
if (counterpart && (counterpart.id !== row.id || (row.var !== undefined && counterpart.var !== row.var)))
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
const own = set.rows.flatMap((row) => {
|
|
222
|
+
const counterpart = builtOwn.get(row.source);
|
|
223
|
+
return counterpart ? [structuredClone(row)] : [];
|
|
224
|
+
});
|
|
225
|
+
const firstOwn = built.findIndex(isOwnOutput);
|
|
226
|
+
const others = built.filter((row) => !isOwnOutput(row));
|
|
227
|
+
const at = firstOwn < 0 ? 0 : firstOwn;
|
|
228
|
+
return [...others.slice(0, at), ...own, ...others.slice(at)];
|
|
229
|
+
}
|
|
230
|
+
/** The value an input row holds: its `body`, else its `value`. */
|
|
231
|
+
function inputValue(row) {
|
|
232
|
+
if (!row)
|
|
233
|
+
return undefined;
|
|
234
|
+
return row.body !== undefined ? row.body : row.value;
|
|
235
|
+
}
|
|
236
|
+
/** The saved inputs, when every input holds the value it was saved with; else nothing. */
|
|
237
|
+
function inputsBack(built, set) {
|
|
238
|
+
if (!built.every(isInputRow))
|
|
239
|
+
return undefined;
|
|
240
|
+
const builtByName = new Map(built.map((row) => [row.name, row]));
|
|
241
|
+
const savedByName = new Map(set.rows.map((row) => [row.name, row]));
|
|
242
|
+
for (const name of new Set([...builtByName.keys(), ...savedByName.keys()])) {
|
|
243
|
+
const [a, b] = [inputValue(builtByName.get(name)), inputValue(savedByName.get(name))];
|
|
244
|
+
if (isEmpty(a) && isEmpty(b))
|
|
245
|
+
continue;
|
|
246
|
+
if (stable(a) !== stable(b))
|
|
247
|
+
return undefined;
|
|
248
|
+
}
|
|
249
|
+
return structuredClone(set.rows);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Write each element's saved own rows back over the ones compile built, half
|
|
253
|
+
* by half, while they still describe the element. Runs after the ids are
|
|
254
|
+
* restored, so an owner key finds its element by the plan's own ids, also
|
|
255
|
+
* after a rename.
|
|
256
|
+
*/
|
|
257
|
+
export function applyConnectorRows(result, entries) {
|
|
258
|
+
if (!entries?.length)
|
|
259
|
+
return;
|
|
260
|
+
const byOwner = new Map(entries.map((entry) => [entry.owner, entry]));
|
|
261
|
+
for (const { key, bag } of caseConnectorRowOwners(result)) {
|
|
262
|
+
const entry = byOwner.get(key);
|
|
263
|
+
if (!entry || !sameOperation(bag, entry))
|
|
264
|
+
continue;
|
|
265
|
+
for (const field of ['inputs', 'outputs']) {
|
|
266
|
+
const set = entry[field];
|
|
267
|
+
if (!set)
|
|
268
|
+
continue;
|
|
269
|
+
const built = Array.isArray(bag[field]) ? bag[field] : [];
|
|
270
|
+
const back = field === 'inputs' ? inputsBack(built, set) : outputsBack(built, set);
|
|
271
|
+
if (!back)
|
|
272
|
+
continue;
|
|
273
|
+
if (set.absent && back.length === 0)
|
|
274
|
+
delete bag[field];
|
|
275
|
+
else
|
|
276
|
+
bag[field] = back;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
/** Problems with a payload's `connectorRows`, for `caseJsonPreservationErrors`. */
|
|
281
|
+
export function connectorRowErrors(entries) {
|
|
282
|
+
if (entries === undefined)
|
|
283
|
+
return [];
|
|
284
|
+
if (!Array.isArray(entries))
|
|
285
|
+
return ['preserved "connectorRows" must be an array'];
|
|
286
|
+
const errors = [];
|
|
287
|
+
for (const entry of entries) {
|
|
288
|
+
const owner = entry?.owner;
|
|
289
|
+
if (typeof owner !== 'string' || !/^(trigger|task|rule):/.test(owner)) {
|
|
290
|
+
errors.push(`preserved connector rows owner ${JSON.stringify(owner)} is not a trigger, task or rule key`);
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
for (const field of Object.keys(entry))
|
|
294
|
+
if (!['owner', 'operation', 'inputs', 'outputs'].includes(field))
|
|
295
|
+
errors.push(`preserved connector rows "${owner}" field "${field}" is not allowed in the preservation channel`);
|
|
296
|
+
const { operation, inputs, outputs } = entry;
|
|
297
|
+
if (!isObject(operation) || typeof operation.connectorKey !== 'string' || !Object.values(operation).every((value) => typeof value === 'string'))
|
|
298
|
+
errors.push(`preserved connector rows "${owner}" operation must map context row names to strings, with a connectorKey`);
|
|
299
|
+
const half = (set, field, row, key) => {
|
|
300
|
+
if (set === undefined)
|
|
301
|
+
return;
|
|
302
|
+
if (!isObject(set) || !Array.isArray(set.rows) || !set.rows.every(row)) {
|
|
303
|
+
errors.push(`preserved connector rows "${owner}" ${field} must hold its own ${field === 'inputs' ? 'named input' : '"=response" / "=Error" output'} rows`);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (new Set(set.rows.map(key)).size !== set.rows.length)
|
|
307
|
+
errors.push(`preserved connector rows "${owner}" ${field} name a row twice`);
|
|
308
|
+
if (set.absent !== undefined && set.absent !== true)
|
|
309
|
+
errors.push(`preserved connector rows "${owner}" ${field} absent must be true`);
|
|
310
|
+
for (const extra of Object.keys(set))
|
|
311
|
+
if (extra !== 'rows' && extra !== 'absent')
|
|
312
|
+
errors.push(`preserved connector rows "${owner}" ${field} field "${extra}" is not allowed in the preservation channel`);
|
|
313
|
+
};
|
|
314
|
+
half(inputs, 'inputs', isInputRow, (row) => row.name);
|
|
315
|
+
half(outputs, 'outputs', isOwnOutput, (row) => row.source);
|
|
316
|
+
}
|
|
317
|
+
return errors;
|
|
318
|
+
}
|
package/dist/case/decompile.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import type { Library } from '../core/library.js';
|
|
7
7
|
import { type ConnectorTaskIdentity } from './connector-saved-config.js';
|
|
8
8
|
import { type PreservedConnectorContext } from './connector-saved-context.js';
|
|
9
|
+
import { type PreservedConnectorRows } from './connector-saved-rows.js';
|
|
9
10
|
import { type PreservedFilterLeafId, type PreservedTriggerDisplayFields } from './preserve.js';
|
|
10
11
|
import { type PreservedResourceWire } from './resource-wire.js';
|
|
11
12
|
interface IoRow {
|
|
@@ -280,6 +281,7 @@ type Preservation = {
|
|
|
280
281
|
metadata: Record<string, unknown>;
|
|
281
282
|
}>;
|
|
282
283
|
connectorContexts?: PreservedConnectorContext[];
|
|
284
|
+
connectorRows?: PreservedConnectorRows[];
|
|
283
285
|
subscriptionFilters?: Array<{
|
|
284
286
|
owner: string;
|
|
285
287
|
expression?: 'inline';
|
package/dist/case/decompile.js
CHANGED
|
@@ -9,6 +9,7 @@ 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
11
|
import { caseConnectorOwners, savedConnectorContext } from './connector-saved-context.js';
|
|
12
|
+
import { caseConnectorRowOwners, savedConnectorRows } from './connector-saved-rows.js';
|
|
12
13
|
import { builtChainSource, chainStatements } from '../core/builder-chain.js';
|
|
13
14
|
import { literalSource } from './literal.js';
|
|
14
15
|
import { ANY_ESCALATION_ID } from './rule-options.js';
|
|
@@ -2237,7 +2238,33 @@ function stageDataPreservation(data, stageName, generation) {
|
|
|
2237
2238
|
return undefined;
|
|
2238
2239
|
return { ...(Object.keys(fields).length ? { fields } : {}), ...(omit.length ? { omit } : {}) };
|
|
2239
2240
|
}
|
|
2240
|
-
|
|
2241
|
+
/**
|
|
2242
|
+
* The ids of SLAs whose displayName another SLA of the plan shares. The source
|
|
2243
|
+
* names an SLA by displayName (`rule('sla-status-change', { sla })`), which
|
|
2244
|
+
* compile resolves to the last SLA declared with it, so a rule on any other
|
|
2245
|
+
* of them keeps its `slaId` in the payload.
|
|
2246
|
+
*/
|
|
2247
|
+
function ambiguousSlaIds(plan) {
|
|
2248
|
+
const slas = [...(plan.metadata?.slaRules ?? []), ...(plan.nodes ?? []).filter(isStage).flatMap((stage) => stage.data?.slaRules ?? [])];
|
|
2249
|
+
const count = new Map();
|
|
2250
|
+
for (const sla of slas)
|
|
2251
|
+
if (sla.displayName)
|
|
2252
|
+
count.set(sla.displayName, (count.get(sla.displayName) ?? 0) + 1);
|
|
2253
|
+
// Each such SLA's id, with the displayName it shares.
|
|
2254
|
+
return new Map(slas.flatMap((sla) => (sla.id && sla.displayName && (count.get(sla.displayName) ?? 0) > 1 ? [[sla.id, sla.displayName]] : [])));
|
|
2255
|
+
}
|
|
2256
|
+
function conditionIdentityOf(condition, ambiguousSlas = new Map(), siblings = [condition]) {
|
|
2257
|
+
// Another condition of the same list with this name: the name alone does not
|
|
2258
|
+
// say which one a pin was saved on.
|
|
2259
|
+
const nameShared = siblings.filter((other) => (other.displayName ?? '') === (condition.displayName ?? '')).length > 1;
|
|
2260
|
+
// A pinned rule is found again, inside its condition, as the n-th
|
|
2261
|
+
// `sla-status-change` rule on an SLA of that name: a rule group added or
|
|
2262
|
+
// removed before it shifts its `[group][rule]` slot, not its order.
|
|
2263
|
+
const flat = (condition.rules ?? []).flat();
|
|
2264
|
+
const ordinal = (rule) => {
|
|
2265
|
+
const name = ambiguousSlas.get(rule.slaId ?? '');
|
|
2266
|
+
return flat.slice(0, flat.indexOf(rule)).filter((other) => other.rule === 'sla-status-change' && ambiguousSlas.get(other.slaId ?? '') === name).length;
|
|
2267
|
+
};
|
|
2241
2268
|
if (condition.edgeIds !== undefined
|
|
2242
2269
|
&& (!Array.isArray(condition.edgeIds) || !condition.edgeIds.every((id) => typeof id === 'string')))
|
|
2243
2270
|
throw new Error(`condition "${condition.displayName ?? condition.id ?? '?'}" has edgeIds that is not a list of edge id strings. The Case Designer writes an array of edge ids; fix or remove the field.`);
|
|
@@ -2248,6 +2275,14 @@ function conditionIdentity(condition) {
|
|
|
2248
2275
|
...(condition.edgeIds !== undefined ? { edgeIds: condition.edgeIds } : {}),
|
|
2249
2276
|
rules: (condition.rules ?? []).map((group) => group.map((rule) => ({
|
|
2250
2277
|
...(rule.id ? { id: rule.id } : {}),
|
|
2278
|
+
// Which of several same-named SLAs the rule watches (see `ambiguousSlaIds`).
|
|
2279
|
+
// The condition's name, as the source spells it, rides with it, and so
|
|
2280
|
+
// does the rule's order among its condition's rules on that SLA name:
|
|
2281
|
+
// conditions pair up by position, and an edit that deletes an earlier
|
|
2282
|
+
// sibling, or adds a rule group, must not move the pin.
|
|
2283
|
+
...(rule.rule === 'sla-status-change' && rule.slaId && ambiguousSlas.has(rule.slaId)
|
|
2284
|
+
? { slaId: rule.slaId, slaCondition: condition.displayName ?? '', ...(nameShared ? { slaConditionShared: true } : {}), ...(ordinal(rule) > 0 ? { slaOrdinal: ordinal(rule) } : {}) }
|
|
2285
|
+
: {}),
|
|
2251
2286
|
// A wait-for-connector rule's rows take their ids from the plan-wide pool,
|
|
2252
2287
|
// so deleting an earlier output would renumber them.
|
|
2253
2288
|
...(rule.uipath?.outputs?.length
|
|
@@ -2425,6 +2460,8 @@ function unaliasedOwnNameRow(row, plan) {
|
|
|
2425
2460
|
return root.some((entry) => entry?.id === row.id) ? { noAlias: true } : {};
|
|
2426
2461
|
}
|
|
2427
2462
|
function identityPreservation(plan) {
|
|
2463
|
+
const ambiguous = ambiguousSlaIds(plan);
|
|
2464
|
+
const conditionIdentity = (condition, _index, list) => conditionIdentityOf(condition, ambiguous, list);
|
|
2428
2465
|
return {
|
|
2429
2466
|
...(plan.id ? { id: plan.id } : {}),
|
|
2430
2467
|
triggers: (plan.nodes ?? []).filter(isTrigger).map((node) => ({ ...(node.id ? { id: node.id } : {}) })),
|
|
@@ -2846,6 +2883,11 @@ export function collectPreservation(plan) {
|
|
|
2846
2883
|
.filter((entry) => entry !== undefined);
|
|
2847
2884
|
if (connectorContexts.length)
|
|
2848
2885
|
preservation.connectorContexts = connectorContexts;
|
|
2886
|
+
const connectorRows = caseConnectorRowOwners(plan)
|
|
2887
|
+
.map(({ key, bag }) => savedConnectorRows(key, bag))
|
|
2888
|
+
.filter((entry) => entry !== undefined);
|
|
2889
|
+
if (connectorRows.length)
|
|
2890
|
+
preservation.connectorRows = connectorRows;
|
|
2849
2891
|
const subscriptionFilterEntries = preservedSubscriptionFilters(plan);
|
|
2850
2892
|
if (subscriptionFilterEntries.length)
|
|
2851
2893
|
preservation.subscriptionFilters = subscriptionFilterEntries;
|
package/dist/case/preserve.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type PreservedConnectorContext } from './connector-saved-context.js';
|
|
2
|
+
import { type PreservedConnectorRows } from './connector-saved-rows.js';
|
|
2
3
|
import type { BuiltCase } from './case-sdk.js';
|
|
3
4
|
import type { ReadEventFilter } from '../core/event-filters.js';
|
|
4
5
|
import { Bindings } from '../core/bindings.js';
|
|
@@ -159,8 +160,27 @@ interface ConditionIdentity {
|
|
|
159
160
|
id?: string;
|
|
160
161
|
/** The Designer's ids of the canvas edges drawn for the condition. */
|
|
161
162
|
edgeIds?: string[];
|
|
163
|
+
/**
|
|
164
|
+
* `slaId`: on a `sla-status-change` rule whose SLA shares its displayName with
|
|
165
|
+
* another SLA, the one the rule watches. The source names the SLA by
|
|
166
|
+
* displayName only, and compile resolves that to the last declaration.
|
|
167
|
+
* `slaCondition` is the displayName of the condition that held the rule, as
|
|
168
|
+
* the source spells it (`slaConditionShared` when another condition of the
|
|
169
|
+
* list has that name too), and `slaOrdinal` (absent for 0) the rule's place
|
|
170
|
+
* among that condition's `sla-status-change` rules on an SLA of the same
|
|
171
|
+
* name. Compile gives the pin to the one condition of the list with that
|
|
172
|
+
* name, when the name is unique on both sides; else to the condition at the
|
|
173
|
+
* same position, when no other pin owns that slot by name and either the
|
|
174
|
+
* saved name was unique (the condition was renamed) or the list kept its
|
|
175
|
+
* length. Each condition takes at most one pin per rule, and a pin with no
|
|
176
|
+
* owner is dropped with a `SLA_PIN_DROPPED` warning.
|
|
177
|
+
*/
|
|
162
178
|
rules?: Array<Array<{
|
|
163
179
|
id?: string;
|
|
180
|
+
slaId?: string;
|
|
181
|
+
slaCondition?: string;
|
|
182
|
+
slaConditionShared?: boolean;
|
|
183
|
+
slaOrdinal?: number;
|
|
164
184
|
outputs?: Array<{
|
|
165
185
|
name: string;
|
|
166
186
|
id?: string;
|
|
@@ -410,6 +430,14 @@ export interface CaseJsonPreservation {
|
|
|
410
430
|
* (`case/connector-saved-context.ts`).
|
|
411
431
|
*/
|
|
412
432
|
connectorContexts?: PreservedConnectorContext[];
|
|
433
|
+
/**
|
|
434
|
+
* Each Designer-saved connector element's own io rows (an event trigger, a
|
|
435
|
+
* wait-for-connector task or rule, a connector activity task): its request
|
|
436
|
+
* containers and its `response` / `Error` outputs, verbatim, keyed by owner.
|
|
437
|
+
* Compile writes each half back while it still describes the element
|
|
438
|
+
* (`case/connector-saved-rows.ts`).
|
|
439
|
+
*/
|
|
440
|
+
connectorRows?: PreservedConnectorRows[];
|
|
413
441
|
/**
|
|
414
442
|
* Action tasks' Designer-owned `data` fields: the `context` rows the Designer
|
|
415
443
|
* saves with a form (its `hitlType`, quick-form schema ids, and a copy of the
|
package/dist/case/preserve.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { connectorContextErrors } from './connector-saved-context.js';
|
|
2
|
+
import { connectorRowErrors } from './connector-saved-rows.js';
|
|
2
3
|
import { stableId } from '../core/stable-id.js';
|
|
3
4
|
import { Bindings } from '../core/bindings.js';
|
|
4
5
|
import { bindingIdCandidates, offlineBindingLabel } from './ids.js';
|
|
@@ -467,6 +468,7 @@ export function caseJsonPreservationErrors(payload) {
|
|
|
467
468
|
errors.push(`preserved http-request metadata of task "${entry?.task}" must be an object`);
|
|
468
469
|
}
|
|
469
470
|
errors.push(...connectorContextErrors(payload.connectorContexts));
|
|
471
|
+
errors.push(...connectorRowErrors(payload.connectorRows));
|
|
470
472
|
for (const index of payload.manualTriggerServiceTypeNone ?? [])
|
|
471
473
|
if (!Number.isInteger(index) || index < 0)
|
|
472
474
|
errors.push(`manual trigger position "${index}" is not a non-negative integer`);
|
package/dist/case/serialize.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export interface CaseSerializeOpts {
|
|
|
62
62
|
}
|
|
63
63
|
/** A warning `serialize` reports through {@link CaseSerializeOpts.warn}. */
|
|
64
64
|
export interface CaseSerializeWarning {
|
|
65
|
-
code: 'CONNECTION_STUB';
|
|
65
|
+
code: 'CONNECTION_STUB' | 'SLA_PIN_DROPPED';
|
|
66
66
|
message: string;
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
@@ -90,6 +90,8 @@ export interface ApplyPreservationOptions {
|
|
|
90
90
|
* of the merge is that the original wins on exactly those.
|
|
91
91
|
*/
|
|
92
92
|
overwrite?: boolean;
|
|
93
|
+
/** The serializer's warning sink: a preserved fact the edit left no place for (`SLA_PIN_DROPPED`). */
|
|
94
|
+
warn?: (warning: CaseSerializeWarning) => void;
|
|
93
95
|
}
|
|
94
96
|
/**
|
|
95
97
|
* Stamp a preservation payload onto a caseplan-shaped document. Exported for
|
package/dist/case/serialize.js
CHANGED
|
@@ -17,6 +17,7 @@ import { buildConnectorInputs, nestConnectorBody, transportHttpMethod } from '..
|
|
|
17
17
|
import { carriedConnectorFieldsRefusal, withCarriedFields } from '../core/carried-connector-fields.js';
|
|
18
18
|
import { connectorTaskIdentity, sameConnectorOperation, withCurrentCaches, writeOptionalConfiguration } from './connector-saved-config.js';
|
|
19
19
|
import { applyConnectorContexts } from './connector-saved-context.js';
|
|
20
|
+
import { applyConnectorRows } from './connector-saved-rows.js';
|
|
20
21
|
import { connectorActivityMetadata, connectorEventFilterTree, connectorEventMetadata } from '../core/connector-v2-metadata.js';
|
|
21
22
|
import { EQUALS_EXPR_DIALECT } from '../core/connector-checks.js';
|
|
22
23
|
import { bindingLabelRefusal, connectionStubMessage } from '../core/binding-messages.js';
|
|
@@ -428,7 +429,7 @@ function serializeCase(built, opts) {
|
|
|
428
429
|
};
|
|
429
430
|
ELEMENT_SEEDED_IDS.set(result, resolver.elementSeededIds);
|
|
430
431
|
WRITTEN_SUBSCRIPTIONS.set(result, resolver.subscriptions);
|
|
431
|
-
const plan = stampConnectorConfigVersion(applyAuthorLayout(applyPreservation(result, caseJsonPreservation(built)), built.layout));
|
|
432
|
+
const plan = stampConnectorConfigVersion(applyAuthorLayout(applyPreservation(result, caseJsonPreservation(built), opts.warn ? { warn: opts.warn } : {}), built.layout));
|
|
432
433
|
// Last, over the finished document: V32 requires case-unique condition names,
|
|
433
434
|
// and an author (or a decompiled pre-V32 plan) can repeat one. Rename the
|
|
434
435
|
// repeats the way the platform's V31/V32.0.1 migrations would, so the file is
|
|
@@ -586,8 +587,10 @@ export function applyPreservation(result, preservation, options = {}) {
|
|
|
586
587
|
if (errors.length)
|
|
587
588
|
throw new CompileRefusal('PRESERVATION_COLLISION', `invalid Case JSON preservation payload: ${errors.join('; ')}`);
|
|
588
589
|
preservation = followRenames(result, preservation);
|
|
589
|
-
applyPreservedIdentities(result, preservation);
|
|
590
|
+
applyPreservedIdentities(result, preservation, options.warn);
|
|
590
591
|
applySubscriptionFilters(result, preservation);
|
|
592
|
+
// After the ids are restored: an unchanged connector element takes its saved own io rows.
|
|
593
|
+
applyConnectorRows(result, preservation.connectorRows);
|
|
591
594
|
Object.assign(result, preservation.topLevel ?? {});
|
|
592
595
|
Object.assign(result.metadata, preservation.metadata ?? {});
|
|
593
596
|
const metadata = result.metadata;
|
|
@@ -1308,7 +1311,7 @@ function restoreNoTasks(data, spelling) {
|
|
|
1308
1311
|
else
|
|
1309
1312
|
data.tasks = [];
|
|
1310
1313
|
}
|
|
1311
|
-
function applyPreservedIdentities(result, preservation) {
|
|
1314
|
+
function applyPreservedIdentities(result, preservation, warn) {
|
|
1312
1315
|
const identities = preservation.identities;
|
|
1313
1316
|
if (!identities)
|
|
1314
1317
|
return;
|
|
@@ -1550,6 +1553,7 @@ function applyPreservedIdentities(result, preservation) {
|
|
|
1550
1553
|
});
|
|
1551
1554
|
};
|
|
1552
1555
|
const takeConditions = (current, wanted) => {
|
|
1556
|
+
const pins = [];
|
|
1553
1557
|
(wanted ?? []).forEach((condition, index) => {
|
|
1554
1558
|
const target = current?.[index];
|
|
1555
1559
|
take(target, condition.id);
|
|
@@ -1558,11 +1562,41 @@ function applyPreservedIdentities(result, preservation) {
|
|
|
1558
1562
|
(condition.rules ?? []).forEach((group, groupIndex) => group.forEach((rule, ruleIndex) => {
|
|
1559
1563
|
const ruleTarget = target?.rules?.[groupIndex]?.[ruleIndex];
|
|
1560
1564
|
take(ruleTarget, rule.id);
|
|
1565
|
+
if (typeof rule.slaId === 'string')
|
|
1566
|
+
pins.push({ index, rule });
|
|
1561
1567
|
if (rule.outputs)
|
|
1562
1568
|
takeOutputRows(ruleTarget?.[bagField]?.outputs ?? [], rule.outputs);
|
|
1563
1569
|
}));
|
|
1564
1570
|
});
|
|
1571
|
+
// Each pin goes to the condition it was saved on. Ids pair up by position,
|
|
1572
|
+
// and an edit that deletes an earlier sibling shifts the next condition into
|
|
1573
|
+
// its slot, so a pin is found by the condition's name when that name is one
|
|
1574
|
+
// condition's on both sides. Else, by position: only when no other pin owns
|
|
1575
|
+
// that slot by name, and the saved name was unique (the condition was
|
|
1576
|
+
// renamed) or the list kept its length (nothing shifted). A pin with no
|
|
1577
|
+
// owner is dropped, and so is a second pin for the same rule, which
|
|
1578
|
+
// `restoreRuleSlas` decides once it has found the rule (it warns).
|
|
1579
|
+
const list = current ?? [];
|
|
1580
|
+
const nameOf = (condition) => condition?.displayName ?? '';
|
|
1581
|
+
const byName = (pin) => {
|
|
1582
|
+
const name = pin.rule.slaCondition;
|
|
1583
|
+
if (typeof name !== 'string' || pin.rule.slaConditionShared === true)
|
|
1584
|
+
return undefined;
|
|
1585
|
+
const named = list.filter((candidate) => nameOf(candidate) === name);
|
|
1586
|
+
return named.length === 1 ? named[0] : undefined;
|
|
1587
|
+
};
|
|
1588
|
+
const ownedByName = new Set(pins.map(byName).filter(Boolean));
|
|
1589
|
+
for (const pin of pins) {
|
|
1590
|
+
const atSlot = list[pin.index];
|
|
1591
|
+
const owner = byName(pin)
|
|
1592
|
+
?? (atSlot && !ownedByName.has(atSlot) && (pin.rule.slaConditionShared !== true || list.length === (wanted ?? []).length) ? atSlot : undefined);
|
|
1593
|
+
const ordinal = typeof pin.rule.slaOrdinal === 'number' ? pin.rule.slaOrdinal : 0;
|
|
1594
|
+
wantedRuleSlas.push({ condition: owner, ordinal, slaId: pin.rule.slaId, conditionName: pin.rule.slaCondition ?? nameOf(atSlot) });
|
|
1595
|
+
}
|
|
1565
1596
|
};
|
|
1597
|
+
// `sla-status-change` rules whose payload names which of several same-named
|
|
1598
|
+
// SLAs they watch, settled by `restoreRuleSlas` once SLA ids are final.
|
|
1599
|
+
const wantedRuleSlas = [];
|
|
1566
1600
|
// Preserved SLA and escalation ids, restored by `restoreSlaIds` once every
|
|
1567
1601
|
// other id is in place.
|
|
1568
1602
|
const wantedSlaIds = new Map();
|
|
@@ -1677,6 +1711,7 @@ function applyPreservedIdentities(result, preservation) {
|
|
|
1677
1711
|
takeSlas(metadata.slaRules, identities.slaRules);
|
|
1678
1712
|
restoreEmptyLists(metadata, identities.emptyLists, CASE_EMPTY_LISTS);
|
|
1679
1713
|
restoreSlaIds();
|
|
1714
|
+
restoreRuleSlas(result, stages, wantedRuleSlas, (id) => replacements.get(id) ?? id, warn);
|
|
1680
1715
|
const variables = result.variables;
|
|
1681
1716
|
if (carriedCompanions.size) {
|
|
1682
1717
|
const inputOutputs = (variables.inputOutputs ??= []);
|
|
@@ -2638,6 +2673,75 @@ function refreshedActionContext(context, data, saved, formKindChanged) {
|
|
|
2638
2673
|
}
|
|
2639
2674
|
return out;
|
|
2640
2675
|
}
|
|
2676
|
+
/**
|
|
2677
|
+
* Point each `sla-status-change` rule the payload pinned back at the SLA it
|
|
2678
|
+
* watched. The source names an SLA by displayName, which compile resolves to
|
|
2679
|
+
* the last SLA declared with it; a rule on another SLA of that name gets its
|
|
2680
|
+
* own `slaId` back, and an at-risk rule the same-named escalation of that SLA.
|
|
2681
|
+
* The rule is the `ordinal`-th `sla-status-change` rule of its condition on an
|
|
2682
|
+
* SLA of the pinned SLA's name, so a rule group added before it does not hide
|
|
2683
|
+
* it. A pin the edit left no place for (no condition, no such rule, the SLA
|
|
2684
|
+
* renamed or removed, no same-named escalation) keeps compile's answer, with a
|
|
2685
|
+
* `SLA_PIN_DROPPED` warning that names the condition and both SLA ids.
|
|
2686
|
+
*/
|
|
2687
|
+
function restoreRuleSlas(result, stages, wanted,
|
|
2688
|
+
// The final id of an id this pass generated: the rule still holds the
|
|
2689
|
+
// generated SLA and escalation ids until the reference rewrite runs.
|
|
2690
|
+
final, warn) {
|
|
2691
|
+
if (!wanted.length)
|
|
2692
|
+
return;
|
|
2693
|
+
const slas = [...(result.metadata?.slaRules ?? []), ...stages.flatMap((stage) => stage.data?.slaRules ?? [])];
|
|
2694
|
+
const byId = new Map(slas.filter((sla) => typeof sla?.id === 'string').map((sla) => [sla.id, sla]));
|
|
2695
|
+
// Each rule takes at most one pin. The rule is found by its condition, the
|
|
2696
|
+
// pinned SLA's name and its place among that condition's rules on the name,
|
|
2697
|
+
// so two pins in one condition on SLAs of different names (each the first on
|
|
2698
|
+
// its own name) are two rules, not one.
|
|
2699
|
+
const claimed = new Set();
|
|
2700
|
+
for (const { condition, ordinal, slaId, conditionName } of wanted) {
|
|
2701
|
+
const pinned = byId.get(slaId);
|
|
2702
|
+
const name = pinned?.displayName;
|
|
2703
|
+
const lastNamed = name ? [...slas].reverse().find((sla) => sla?.displayName === name) : undefined;
|
|
2704
|
+
const drop = (why) => warn?.({
|
|
2705
|
+
code: 'SLA_PIN_DROPPED',
|
|
2706
|
+
message: `Condition "${conditionName}": its sla-status-change rule watched SLA ${slaId}${name ? ` ("${name}")` : ''}, but ${why}. `
|
|
2707
|
+
+ (lastNamed?.id ? `The rule now watches ${lastNamed.id}, the last SLA of that name. ` : '')
|
|
2708
|
+
+ 'Several SLAs share that name and the source names an SLA by displayName only; give each SLA its own displayName to pick one.',
|
|
2709
|
+
});
|
|
2710
|
+
if (!pinned || !name) {
|
|
2711
|
+
drop('that SLA is no longer in the plan');
|
|
2712
|
+
continue;
|
|
2713
|
+
}
|
|
2714
|
+
if (!condition) {
|
|
2715
|
+
drop('the edit left no condition that is clearly the one it was saved on');
|
|
2716
|
+
continue;
|
|
2717
|
+
}
|
|
2718
|
+
const onName = (condition.rules ?? []).flat()
|
|
2719
|
+
.filter((rule) => rule?.rule === 'sla-status-change' && typeof rule.slaId === 'string' && byId.get(final(rule.slaId))?.displayName === name);
|
|
2720
|
+
const rule = onName[ordinal];
|
|
2721
|
+
if (!rule) {
|
|
2722
|
+
drop('the condition no longer has that rule');
|
|
2723
|
+
continue;
|
|
2724
|
+
}
|
|
2725
|
+
if (claimed.has(rule)) {
|
|
2726
|
+
drop('another pin already claims that rule');
|
|
2727
|
+
continue;
|
|
2728
|
+
}
|
|
2729
|
+
claimed.add(rule);
|
|
2730
|
+
if (final(rule.slaId) === slaId)
|
|
2731
|
+
continue;
|
|
2732
|
+
if (rule.escalationId !== undefined && rule.escalationId !== ANY_ESCALATION_ID) {
|
|
2733
|
+
const current = byId.get(final(rule.slaId));
|
|
2734
|
+
const escalationName = (current?.escalationRule ?? []).find((entry) => entry?.id === final(String(rule.escalationId)))?.displayName;
|
|
2735
|
+
const escalation = escalationName === undefined ? undefined : (pinned.escalationRule ?? []).find((entry) => entry?.displayName === escalationName);
|
|
2736
|
+
if (!escalation?.id) {
|
|
2737
|
+
drop('that SLA has no escalation of the name the rule waits for');
|
|
2738
|
+
continue;
|
|
2739
|
+
}
|
|
2740
|
+
rule.escalationId = escalation.id;
|
|
2741
|
+
}
|
|
2742
|
+
rule.slaId = slaId;
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2641
2745
|
/**
|
|
2642
2746
|
* Put back the own-name shape of `restored` rows whose variable the source plan
|
|
2643
2747
|
* had no root entry for: no `originalVar`, and no root companion, as the
|
package/dist/core/refusals.d.ts
CHANGED
|
@@ -700,6 +700,7 @@ export declare const REFUSALS: {
|
|
|
700
700
|
readonly SLA_COUNT_RANGE: "lint";
|
|
701
701
|
readonly SLA_NONPOSITIVE: "lint";
|
|
702
702
|
readonly SLA_NO_ESCALATIONS: "lint";
|
|
703
|
+
readonly SLA_PIN_DROPPED: "lint";
|
|
703
704
|
readonly STAGE_NO_COMPLETION: "lint";
|
|
704
705
|
readonly STEP_ID_COLLISION: "lowering";
|
|
705
706
|
readonly STEP_NOT_ACTION: "lowering";
|
package/dist/core/refusals.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.94.
|
|
3
|
+
"version": "6.94.3",
|
|
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": "30a156946c9d4247a85f4a7b3442d4167e031843"
|
|
115
115
|
}
|