@uipath/maestro-builder-sdk 6.93.1 → 6.93.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-context.d.ts +34 -0
- package/dist/case/connector-saved-context.js +281 -0
- package/dist/case/decompile.d.ts +2 -0
- package/dist/case/decompile.js +30 -0
- package/dist/case/preserve.d.ts +8 -0
- package/dist/case/preserve.js +2 -0
- package/dist/case/serialize.js +4 -0
- package/dist/core/connector-configuration.d.ts +16 -0
- package/dist/core/connector-configuration.js +23 -3
- package/dist/core/library.d.ts +11 -0
- package/dist/core/library.js +43 -24
- 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 {
|
|
@@ -274,6 +275,7 @@ type Preservation = {
|
|
|
274
275
|
task: string;
|
|
275
276
|
metadata: Record<string, unknown>;
|
|
276
277
|
}>;
|
|
278
|
+
connectorContexts?: PreservedConnectorContext[];
|
|
277
279
|
subscriptionFilters?: Array<{
|
|
278
280
|
owner: string;
|
|
279
281
|
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';
|
|
@@ -917,6 +918,28 @@ function savedConfiguration(context) {
|
|
|
917
918
|
return undefined;
|
|
918
919
|
}
|
|
919
920
|
}
|
|
921
|
+
/**
|
|
922
|
+
* The activity type the task was saved against (`Curated`, ...): the saved
|
|
923
|
+
* configuration's `instanceParameters.activityType`, else the activity
|
|
924
|
+
* metadata's. It picks between a curated activity and the generic one on the
|
|
925
|
+
* same object and path (`Library.identifyAction`).
|
|
926
|
+
*/
|
|
927
|
+
function connectorActivityType(context) {
|
|
928
|
+
const fromConfig = savedConfiguration(context)?.essentialConfiguration?.instanceParameters?.activityType;
|
|
929
|
+
if (typeof fromConfig === 'string' && fromConfig)
|
|
930
|
+
return fromConfig;
|
|
931
|
+
let activity = context.get('metadata')?.body?.activityMetadata?.activity?.configuration;
|
|
932
|
+
if (typeof activity === 'string') {
|
|
933
|
+
try {
|
|
934
|
+
activity = JSON.parse(activity);
|
|
935
|
+
}
|
|
936
|
+
catch {
|
|
937
|
+
return undefined;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
const fromActivity = activity?.activityType;
|
|
941
|
+
return typeof fromActivity === 'string' && fromActivity ? fromActivity : undefined;
|
|
942
|
+
}
|
|
920
943
|
function connectorVersion(context) {
|
|
921
944
|
const metadata = context.get('metadata')?.body;
|
|
922
945
|
const encoded = metadata?.activityPropertyConfiguration?.configuration;
|
|
@@ -1057,6 +1080,7 @@ function connectorCall(task, refs, library) {
|
|
|
1057
1080
|
endpoint: String(endpoint),
|
|
1058
1081
|
objectName: String(objectName),
|
|
1059
1082
|
version: connectorVersion(context),
|
|
1083
|
+
activityType: connectorActivityType(context),
|
|
1060
1084
|
});
|
|
1061
1085
|
const fromLibrary = library.resolve(identity.key, identity.action, identity.version, identity.object);
|
|
1062
1086
|
// The fields the plan's saved field list declares and the library lacks: a
|
|
@@ -1155,6 +1179,7 @@ function externalCall(task, refs, library) {
|
|
|
1155
1179
|
endpoint: stringValue('path'),
|
|
1156
1180
|
objectName: stringValue('objectName'),
|
|
1157
1181
|
version: connectorVersion(context),
|
|
1182
|
+
activityType: connectorActivityType(context),
|
|
1158
1183
|
});
|
|
1159
1184
|
const resolved = library.resolve(identity.key, identity.action, identity.version, identity.object);
|
|
1160
1185
|
const refused = externalDescriptorRefusal(kind, resolved);
|
|
@@ -2750,6 +2775,11 @@ export function collectPreservation(plan) {
|
|
|
2750
2775
|
preservation.connectorConfigurations = connectorConfigurations;
|
|
2751
2776
|
if (httpRequestMetadata.length)
|
|
2752
2777
|
preservation.httpRequestMetadata = httpRequestMetadata;
|
|
2778
|
+
const connectorContexts = caseConnectorOwners(plan)
|
|
2779
|
+
.map(({ key, bag }) => savedConnectorContext(key, bag))
|
|
2780
|
+
.filter((entry) => entry !== undefined);
|
|
2781
|
+
if (connectorContexts.length)
|
|
2782
|
+
preservation.connectorContexts = connectorContexts;
|
|
2753
2783
|
const subscriptionFilterEntries = preservedSubscriptionFilters(plan);
|
|
2754
2784
|
if (subscriptionFilterEntries.length)
|
|
2755
2785
|
preservation.subscriptionFilters = subscriptionFilterEntries;
|
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';
|
|
@@ -363,6 +364,13 @@ export interface CaseJsonPreservation {
|
|
|
363
364
|
* another connector version is written back instead of downgraded.
|
|
364
365
|
*/
|
|
365
366
|
httpRequestMetadata?: PreservedHttpRequestMetadata[];
|
|
367
|
+
/**
|
|
368
|
+
* Each Designer-saved connector element's `context` (an event trigger, a
|
|
369
|
+
* wait-for-connector task or rule, a connector activity task), verbatim,
|
|
370
|
+
* keyed by owner. Compile writes it back while the element is unchanged
|
|
371
|
+
* (`case/connector-saved-context.ts`).
|
|
372
|
+
*/
|
|
373
|
+
connectorContexts?: PreservedConnectorContext[];
|
|
366
374
|
/**
|
|
367
375
|
* Action tasks' Designer-owned `data` fields: the `context` rows the Designer
|
|
368
376
|
* saves with a form (its `hitlType`, quick-form schema ids, and a copy of the
|
package/dist/case/preserve.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
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';
|
|
@@ -433,6 +434,7 @@ export function caseJsonPreservationErrors(payload) {
|
|
|
433
434
|
if (!entry?.metadata || typeof entry.metadata !== 'object' || Array.isArray(entry.metadata))
|
|
434
435
|
errors.push(`preserved http-request metadata of task "${entry?.task}" must be an object`);
|
|
435
436
|
}
|
|
437
|
+
errors.push(...connectorContextErrors(payload.connectorContexts));
|
|
436
438
|
for (const index of payload.manualTriggerServiceTypeNone ?? [])
|
|
437
439
|
if (!Number.isInteger(index) || index < 0)
|
|
438
440
|
errors.push(`manual trigger position "${index}" is not a non-negative integer`);
|
package/dist/case/serialize.js
CHANGED
|
@@ -16,6 +16,7 @@ import { ACTION_CONTEXT_COPIES, ACTION_FORM_KIND_CONTEXT, ACTION_PASSTHROUGH_SET
|
|
|
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';
|
|
@@ -742,6 +743,9 @@ export function applyPreservation(result, preservation, options = {}) {
|
|
|
742
743
|
continue;
|
|
743
744
|
writeHttpRequestMetadata(task.data, entry.metadata);
|
|
744
745
|
}
|
|
746
|
+
// After the subscription filters and the optional halves: an unchanged
|
|
747
|
+
// connector element takes its saved context whole.
|
|
748
|
+
applyConnectorContexts(result, preservation.connectorContexts);
|
|
745
749
|
for (const entry of preservation.actionDataFields ?? []) {
|
|
746
750
|
const stage = stageNodes.find((candidate) => candidate.data?.label === entry.stage);
|
|
747
751
|
const task = stageTask(stage, entry.task);
|
|
@@ -79,6 +79,22 @@
|
|
|
79
79
|
* records the body parameter.
|
|
80
80
|
*/
|
|
81
81
|
export declare function buildConfiguration(entry: any, version: string, inputValues?: Record<string, unknown>, seed?: string, executionType?: string | null): string;
|
|
82
|
+
/**
|
|
83
|
+
* The `instanceParameters.activityType` compile writes for a library entry's
|
|
84
|
+
* `operation.activityType`: `Generic` for a generic CRUD entry (`Generic`,
|
|
85
|
+
* `GenericExpanded`), else `Curated`. Studio Web saves the same two values.
|
|
86
|
+
* `wireActivityTypeMatches` is its inverse; keep the two together.
|
|
87
|
+
*/
|
|
88
|
+
export declare function wireActivityType(libraryActivityType: unknown): 'Generic' | 'Curated';
|
|
89
|
+
/**
|
|
90
|
+
* Whether a library entry with `operation.activityType` `libraryActivityType`
|
|
91
|
+
* is one compile would save with the wire `activityType` `wire`: the inverse
|
|
92
|
+
* of `wireActivityType`. For instance a `GenericExpanded` entry matches a
|
|
93
|
+
* saved `"Generic"`, and a `Curated` one a saved `"Curated"`. A wire value
|
|
94
|
+
* that is neither (`GenericExpanded` read off an older plan reads as
|
|
95
|
+
* `Generic`) names no entry kind.
|
|
96
|
+
*/
|
|
97
|
+
export declare function wireActivityTypeMatches(libraryActivityType: unknown, wire: string): boolean;
|
|
82
98
|
/**
|
|
83
99
|
* The `essentialConfiguration` object that {@link buildConfiguration} wraps in
|
|
84
100
|
* its `=jsonString:` envelope. For a caller that also needs a field of it (Case
|
|
@@ -190,6 +190,27 @@ export function buildConfiguration(entry, version, inputValues, seed = 'node', e
|
|
|
190
190
|
essentialConfiguration: buildEssentialConfiguration(entry, version, inputValues, seed, executionType),
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* The `instanceParameters.activityType` compile writes for a library entry's
|
|
195
|
+
* `operation.activityType`: `Generic` for a generic CRUD entry (`Generic`,
|
|
196
|
+
* `GenericExpanded`), else `Curated`. Studio Web saves the same two values.
|
|
197
|
+
* `wireActivityTypeMatches` is its inverse; keep the two together.
|
|
198
|
+
*/
|
|
199
|
+
export function wireActivityType(libraryActivityType) {
|
|
200
|
+
return libraryActivityType === 'Generic' || libraryActivityType === 'GenericExpanded' ? 'Generic' : 'Curated';
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Whether a library entry with `operation.activityType` `libraryActivityType`
|
|
204
|
+
* is one compile would save with the wire `activityType` `wire`: the inverse
|
|
205
|
+
* of `wireActivityType`. For instance a `GenericExpanded` entry matches a
|
|
206
|
+
* saved `"Generic"`, and a `Curated` one a saved `"Curated"`. A wire value
|
|
207
|
+
* that is neither (`GenericExpanded` read off an older plan reads as
|
|
208
|
+
* `Generic`) names no entry kind.
|
|
209
|
+
*/
|
|
210
|
+
export function wireActivityTypeMatches(libraryActivityType, wire) {
|
|
211
|
+
const kind = wire === 'GenericExpanded' ? 'Generic' : wire;
|
|
212
|
+
return (kind === 'Generic' || kind === 'Curated') && wireActivityType(libraryActivityType) === kind;
|
|
213
|
+
}
|
|
193
214
|
/**
|
|
194
215
|
* The `essentialConfiguration` object that {@link buildConfiguration} wraps in
|
|
195
216
|
* its `=jsonString:` envelope. For a caller that also needs a field of it (Case
|
|
@@ -206,9 +227,8 @@ export function buildConfiguration(entry, version, inputValues, seed = 'node', e
|
|
|
206
227
|
export function buildEssentialConfiguration(entry, version, inputValues, seed = 'node', executionType = null) {
|
|
207
228
|
const op = entry.operation ?? {};
|
|
208
229
|
const conn = entry.connector ?? {};
|
|
209
|
-
const
|
|
210
|
-
const isGeneric =
|
|
211
|
-
const v1ActivityType = isGeneric ? 'Generic' : 'Curated';
|
|
230
|
+
const v1ActivityType = wireActivityType(op.activityType);
|
|
231
|
+
const isGeneric = v1ActivityType === 'Generic';
|
|
212
232
|
// `operation.name` is the verb (`List`, `Create`, …); the platform stores it
|
|
213
233
|
// lower-cased. Falls back to the default `create` for an entry that declares no
|
|
214
234
|
// name, which keeps such an entry's emission exactly as it was.
|
package/dist/core/library.d.ts
CHANGED
|
@@ -336,6 +336,16 @@ export declare class Library {
|
|
|
336
336
|
* `GETBYID` goes on the wire as `GET`. So an entry matches on its transport
|
|
337
337
|
* verb too, after an exact match: Outlook `download-email-attachment`
|
|
338
338
|
* (`GETBYID /DownloadAttachment`) is saved as `GET /DownloadAttachment`.
|
|
339
|
+
*
|
|
340
|
+
* One object often has two entries with the same verb and path: the curated
|
|
341
|
+
* activity and the generic CRUD one (Outlook `send-email`, `Curated`, and
|
|
342
|
+
* `insert-record-deprecated-`, `GenericExpanded`, both `POST
|
|
343
|
+
* /hubs/productivity/send-mail-v2`). The wire's `activityType` (the saved
|
|
344
|
+
* `instanceParameters.activityType`) says which one the plan was saved
|
|
345
|
+
* against: `Curated` or `Generic`, as compile writes it from the entry's
|
|
346
|
+
* `operation.activityType` (`wireActivityType`; a `GenericExpanded` entry is
|
|
347
|
+
* saved as `Generic`). An entry of that kind wins; without one, the first
|
|
348
|
+
* match in library order does.
|
|
339
349
|
*/
|
|
340
350
|
identifyAction(wire: {
|
|
341
351
|
connectorKey: string;
|
|
@@ -343,6 +353,7 @@ export declare class Library {
|
|
|
343
353
|
endpoint?: string;
|
|
344
354
|
objectName?: string;
|
|
345
355
|
version?: string;
|
|
356
|
+
activityType?: string;
|
|
346
357
|
}): ConnectorActionIdentity;
|
|
347
358
|
/**
|
|
348
359
|
* Resolve a connector EVENT: the START trigger
|
package/dist/core/library.js
CHANGED
|
@@ -16,6 +16,7 @@ import { ownEntry } from './own-entry.js';
|
|
|
16
16
|
import { ConnectorResolveError } from './connector-resolve-error.js';
|
|
17
17
|
import { CompileRefusal } from './compile-refusal.js';
|
|
18
18
|
import { transportHttpMethod } from './connector-inputs.js';
|
|
19
|
+
import { wireActivityTypeMatches } from './connector-configuration.js';
|
|
19
20
|
export { ConnectorResolveError } from './connector-resolve-error.js';
|
|
20
21
|
export class Library {
|
|
21
22
|
layers = [];
|
|
@@ -272,6 +273,16 @@ export class Library {
|
|
|
272
273
|
* `GETBYID` goes on the wire as `GET`. So an entry matches on its transport
|
|
273
274
|
* verb too, after an exact match: Outlook `download-email-attachment`
|
|
274
275
|
* (`GETBYID /DownloadAttachment`) is saved as `GET /DownloadAttachment`.
|
|
276
|
+
*
|
|
277
|
+
* One object often has two entries with the same verb and path: the curated
|
|
278
|
+
* activity and the generic CRUD one (Outlook `send-email`, `Curated`, and
|
|
279
|
+
* `insert-record-deprecated-`, `GenericExpanded`, both `POST
|
|
280
|
+
* /hubs/productivity/send-mail-v2`). The wire's `activityType` (the saved
|
|
281
|
+
* `instanceParameters.activityType`) says which one the plan was saved
|
|
282
|
+
* against: `Curated` or `Generic`, as compile writes it from the entry's
|
|
283
|
+
* `operation.activityType` (`wireActivityType`; a `GenericExpanded` entry is
|
|
284
|
+
* saved as `Generic`). An entry of that kind wins; without one, the first
|
|
285
|
+
* match in library order does.
|
|
275
286
|
*/
|
|
276
287
|
identifyAction(wire) {
|
|
277
288
|
const prefix = `uipath.connector.${wire.connectorKey}.`;
|
|
@@ -279,32 +290,40 @@ export class Library {
|
|
|
279
290
|
const upper = String(method ?? '').toUpperCase();
|
|
280
291
|
return transport ? transportHttpMethod(upper) : upper;
|
|
281
292
|
};
|
|
282
|
-
//
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
293
|
+
// The wire's activityType first, then any; exact verbs first within each,
|
|
294
|
+
// so an entry the wire names exactly wins over a transport twin.
|
|
295
|
+
const kinds = wire.activityType ? [wire.activityType, undefined] : [undefined];
|
|
296
|
+
for (const kind of kinds)
|
|
297
|
+
for (const transport of [false, true]) {
|
|
298
|
+
for (const layer of this.layers) {
|
|
299
|
+
for (const indexed of layer.entries) {
|
|
300
|
+
if (indexed.connectorKey !== wire.connectorKey || !String(indexed.nodeType ?? '').startsWith(prefix))
|
|
301
|
+
continue;
|
|
302
|
+
if (wire.version && indexed.version !== wire.version)
|
|
303
|
+
continue;
|
|
304
|
+
// The index row carries the entry's activityType: filter on it before parsing the entry.
|
|
305
|
+
if (kind !== undefined && indexed.activityType !== undefined && !wireActivityTypeMatches(indexed.activityType, kind))
|
|
306
|
+
continue;
|
|
307
|
+
const entry = readJson(this.read, libraryPath(layer.dir, indexed.path));
|
|
308
|
+
const operation = entry.operation ?? {};
|
|
309
|
+
if (kind !== undefined && indexed.activityType === undefined && !wireActivityTypeMatches(operation.activityType, kind))
|
|
310
|
+
continue;
|
|
311
|
+
if (wire.httpMethod && verb(operation.httpMethod, transport) !== verb(wire.httpMethod, transport))
|
|
312
|
+
continue;
|
|
313
|
+
if (wire.endpoint && operation.path !== wire.endpoint)
|
|
314
|
+
continue;
|
|
315
|
+
if (wire.objectName && operation.objectName !== wire.objectName)
|
|
316
|
+
continue;
|
|
317
|
+
const siblings = layer.entries.filter((candidate) => candidate.nodeType === indexed.nodeType);
|
|
318
|
+
return {
|
|
319
|
+
key: wire.connectorKey,
|
|
320
|
+
action: String(indexed.nodeType).slice(prefix.length),
|
|
321
|
+
version: String(indexed.version),
|
|
322
|
+
...(siblings.length > 1 && operation.objectName ? { object: String(operation.objectName) } : {}),
|
|
323
|
+
};
|
|
324
|
+
}
|
|
305
325
|
}
|
|
306
326
|
}
|
|
307
|
-
}
|
|
308
327
|
throw new CompileRefusal('CONNECTOR_NOT_IN_LIBRARY', `connector activity not found in library: ${wire.connectorKey} ${wire.httpMethod ?? '?'} ${wire.endpoint ?? '?'}`);
|
|
309
328
|
}
|
|
310
329
|
/**
|
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.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": "b79fb2c5ae6006191f9e66aa74fdf305741d6fa4"
|
|
115
115
|
}
|