@uipath/maestro-builder-sdk 6.94.2 → 6.94.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-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 +16 -4
- package/dist/case/preserve.d.ts +12 -1
- package/dist/case/preserve.js +2 -0
- package/dist/case/serialize.js +12 -4
- 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';
|
|
@@ -1470,14 +1471,20 @@ function carriedResource(task, plan) {
|
|
|
1470
1471
|
return ref ? { resource: { kind: String(task.type), ...ref } } : {};
|
|
1471
1472
|
}
|
|
1472
1473
|
/**
|
|
1473
|
-
* The io lists a
|
|
1474
|
-
*
|
|
1474
|
+
* The io lists a task saved empty (`inputs: []`), which compile omits when the
|
|
1475
|
+
* task has no row there; recorded as `emptyIo: ['inputs']`, with the task's
|
|
1476
|
+
* saved `type` as `emptyIoType`. Any task kind: the
|
|
1477
|
+
* Designer saves `inputs: []` on an action form with no field and on a timer
|
|
1478
|
+
* as well as on a resource task.
|
|
1475
1479
|
*/
|
|
1476
1480
|
function emptyIoLists(task) {
|
|
1477
|
-
|
|
1481
|
+
// A connector placeholder compiles to `data: {}` on purpose (#1354), its empty lists included.
|
|
1482
|
+
if (connectorPlaceholderKindOf(task.type, task.data))
|
|
1478
1483
|
return {};
|
|
1479
1484
|
const empty = ['inputs', 'outputs'].filter((side) => Array.isArray(task.data?.[side]) && task.data[side].length === 0);
|
|
1480
|
-
|
|
1485
|
+
// The kind it was saved on: an edit that makes the task another kind (a
|
|
1486
|
+
// connector placeholder, say) gets compile's lists, not this one's.
|
|
1487
|
+
return empty.length ? { emptyIo: [...empty], ...(typeof task.type === 'string' ? { emptyIoType: task.type } : {}) } : {};
|
|
1481
1488
|
}
|
|
1482
1489
|
function ioArg(rows, kind, task, varKeyById) {
|
|
1483
1490
|
const valueField = kind === 'inputs' ? 'value' : 'source';
|
|
@@ -2882,6 +2889,11 @@ export function collectPreservation(plan) {
|
|
|
2882
2889
|
.filter((entry) => entry !== undefined);
|
|
2883
2890
|
if (connectorContexts.length)
|
|
2884
2891
|
preservation.connectorContexts = connectorContexts;
|
|
2892
|
+
const connectorRows = caseConnectorRowOwners(plan)
|
|
2893
|
+
.map(({ key, bag }) => savedConnectorRows(key, bag))
|
|
2894
|
+
.filter((entry) => entry !== undefined);
|
|
2895
|
+
if (connectorRows.length)
|
|
2896
|
+
preservation.connectorRows = connectorRows;
|
|
2885
2897
|
const subscriptionFilterEntries = preservedSubscriptionFilters(plan);
|
|
2886
2898
|
if (subscriptionFilterEntries.length)
|
|
2887
2899
|
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';
|
|
@@ -221,8 +222,10 @@ interface StageIdentity {
|
|
|
221
222
|
/** `var` and `custom: true`: a custom row whose label (`name`) is not the name of the variable it assigns. */
|
|
222
223
|
/** `noAlias: true`: an own-name row saved with no `originalVar` beside a root variable of its id, which compile writes as the alias `originalVar: <id>`. */
|
|
223
224
|
outputs?: PreservedOutputRow[];
|
|
224
|
-
/** The io lists a
|
|
225
|
+
/** The io lists a task saved empty (`inputs: []`), which compile writes only when it has a row there. */
|
|
225
226
|
emptyIo?: Array<'inputs' | 'outputs'>;
|
|
227
|
+
/** The task `type` `emptyIo` was saved on: compile restores the lists only while the task is still that kind. */
|
|
228
|
+
emptyIoType?: string;
|
|
226
229
|
/** `taskFingerprint`, for a task a sibling shares its row names with. */
|
|
227
230
|
fingerprint?: string;
|
|
228
231
|
/** Fields of `TASK_EMPTY_LISTS` the read task spelled `[]`. */
|
|
@@ -429,6 +432,14 @@ export interface CaseJsonPreservation {
|
|
|
429
432
|
* (`case/connector-saved-context.ts`).
|
|
430
433
|
*/
|
|
431
434
|
connectorContexts?: PreservedConnectorContext[];
|
|
435
|
+
/**
|
|
436
|
+
* Each Designer-saved connector element's own io rows (an event trigger, a
|
|
437
|
+
* wait-for-connector task or rule, a connector activity task): its request
|
|
438
|
+
* containers and its `response` / `Error` outputs, verbatim, keyed by owner.
|
|
439
|
+
* Compile writes each half back while it still describes the element
|
|
440
|
+
* (`case/connector-saved-rows.ts`).
|
|
441
|
+
*/
|
|
442
|
+
connectorRows?: PreservedConnectorRows[];
|
|
432
443
|
/**
|
|
433
444
|
* Action tasks' Designer-owned `data` fields: the `context` rows the Designer
|
|
434
445
|
* 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.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';
|
|
@@ -44,7 +45,7 @@ import { taskShapeProblems } from './task-shape.js';
|
|
|
44
45
|
import { SCRIPT_INPUTS, scriptOutputMappings, scriptOutputs, storedScript } from './script.js';
|
|
45
46
|
import { DOCUMENT_EXTRACTION_NAME, DOCUMENT_EXTRACTION_RESOURCE, DOCUMENT_EXTRACTION_SERVICE_TYPE, DOCUMENT_EXTRACTION_VERSION, documentExtractionContext, documentExtractionInputs, documentExtractionOutputMappings, documentExtractionOutputs, documentExtractionRefusal, } from './document-extraction.js';
|
|
46
47
|
import { HTTP_REQUEST_CONNECTION_NAME, HTTP_REQUEST_IMPLICIT_BINDING_ID, HTTP_REQUEST_IMPLICIT_CONNECTION, HTTP_REQUEST_SERVICE_TYPE, httpRequestBody, httpRequestContext, httpRequestInputs, httpRequestOutputMappings, httpRequestOutputs, httpRequestRefusal, writeHttpRequestMetadata, } from './http-request.js';
|
|
47
|
-
import { connectorPlaceholderData, isConnectorPlaceholder } from './connector-placeholder.js';
|
|
48
|
+
import { connectorPlaceholderData, connectorPlaceholderKindOf, isConnectorPlaceholder } from './connector-placeholder.js';
|
|
48
49
|
import { lowerTaskOutputRefs, planTaskOutputs, resolveInPlan, unresolvedTaskOutputRef } from './task-output-ref.js';
|
|
49
50
|
/** The ids a serialize pass hashed from element ids, by the document it returned. */
|
|
50
51
|
const ELEMENT_SEEDED_IDS = new WeakMap();
|
|
@@ -588,6 +589,8 @@ export function applyPreservation(result, preservation, options = {}) {
|
|
|
588
589
|
preservation = followRenames(result, preservation);
|
|
589
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;
|
|
@@ -1692,9 +1695,14 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1692
1695
|
const isAction = task?.type === 'action';
|
|
1693
1696
|
takeOutputRows(task?.data?.outputs ?? [], (taskIdentity.outputs ?? [])
|
|
1694
1697
|
.map((row) => ({ ...row, ...(!isAction && !resourceKept ? { fields: undefined, omit: undefined } : {}) })), isAction);
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
+
// Only on the kind the lists were saved on (`emptyIoType`; a payload from
|
|
1699
|
+
// before it was recorded was written for resource tasks only), and never
|
|
1700
|
+
// on a connector placeholder, whose `data: {}` is its contract (#1354).
|
|
1701
|
+
const sameKind = taskIdentity.emptyIoType === undefined || taskIdentity.emptyIoType === task?.type;
|
|
1702
|
+
if (sameKind && task?.data && !connectorPlaceholderKindOf(task.type, task.data))
|
|
1703
|
+
for (const side of taskIdentity.emptyIo ?? [])
|
|
1704
|
+
if ((side === 'inputs' || side === 'outputs') && task.data[side] === undefined)
|
|
1705
|
+
task.data[side] = [];
|
|
1698
1706
|
}));
|
|
1699
1707
|
}
|
|
1700
1708
|
const metadata = result.metadata;
|
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.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": "aeb5562cbbd086caf34ab585cfa9ac63b9778333"
|
|
115
115
|
}
|