@uipath/maestro-builder-sdk 6.124.0 → 6.124.2
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/bpmn/uipath-moddle.v1.json +62 -0
- package/dist/case/connector-saved-context.d.ts +12 -0
- package/dist/case/connector-saved-context.js +31 -2
- package/dist/case/connector-saved-rows.js +11 -6
- package/dist/case/decompile.js +8 -0
- package/dist/case/subscription.d.ts +6 -1
- package/dist/case/subscription.js +13 -3
- package/dist/merge-variables.js +174 -8
- package/package.json +2 -2
|
@@ -843,6 +843,68 @@
|
|
|
843
843
|
"superClass": ["Element"],
|
|
844
844
|
"properties": []
|
|
845
845
|
},
|
|
846
|
+
{
|
|
847
|
+
"name": "ExecutionHooks",
|
|
848
|
+
"superClass": ["Element"],
|
|
849
|
+
"properties": [
|
|
850
|
+
{
|
|
851
|
+
"name": "version",
|
|
852
|
+
"isAttr": true,
|
|
853
|
+
"type": "String"
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
"name": "executionHook",
|
|
857
|
+
"type": "ExecutionHook",
|
|
858
|
+
"isMany": true
|
|
859
|
+
}
|
|
860
|
+
]
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
"name": "ExecutionHook",
|
|
864
|
+
"superClass": ["Element"],
|
|
865
|
+
"properties": [
|
|
866
|
+
{
|
|
867
|
+
"name": "type",
|
|
868
|
+
"isAttr": true,
|
|
869
|
+
"type": "String"
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
"name": "phase",
|
|
873
|
+
"isAttr": true,
|
|
874
|
+
"type": "String"
|
|
875
|
+
},
|
|
876
|
+
{
|
|
877
|
+
"name": "retries",
|
|
878
|
+
"isAttr": true,
|
|
879
|
+
"type": "Integer"
|
|
880
|
+
},
|
|
881
|
+
{
|
|
882
|
+
"name": "input",
|
|
883
|
+
"type": "Input",
|
|
884
|
+
"isMany": true
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
"name": "inputOverlay",
|
|
888
|
+
"type": "InputOverlay"
|
|
889
|
+
}
|
|
890
|
+
]
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
"name": "InputOverlay",
|
|
894
|
+
"superClass": ["Element"],
|
|
895
|
+
"properties": [
|
|
896
|
+
{
|
|
897
|
+
"name": "value",
|
|
898
|
+
"isAttr": true,
|
|
899
|
+
"type": "String"
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
"name": "body",
|
|
903
|
+
"type": "String",
|
|
904
|
+
"isBody": true
|
|
905
|
+
}
|
|
906
|
+
]
|
|
907
|
+
},
|
|
846
908
|
{
|
|
847
909
|
"name": "SkipObservability",
|
|
848
910
|
"superClass": ["Element"],
|
|
@@ -28,7 +28,19 @@ export interface RebuiltConnectorElement {
|
|
|
28
28
|
metadata?: Record<string, unknown>;
|
|
29
29
|
containers?: Record<string, unknown>;
|
|
30
30
|
responseSchema?: unknown;
|
|
31
|
+
/** An event's parameter names the library puts in the event bucket (the rest are query or path). */
|
|
32
|
+
eventParameters?: ReadonlySet<string>;
|
|
31
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* An event subscription's input values with its `where` read as the source
|
|
36
|
+
* holds it: `body.queryParams` and `body.parameters` merged into one `where`.
|
|
37
|
+
* Which slot a parameter sits in is the connector's bucket split, which the
|
|
38
|
+
* source cannot write: a Data Fabric trigger Studio Web saved with
|
|
39
|
+
* `queryParams: { entityScope, tenantEntityName }` holds the same values as
|
|
40
|
+
* the `parameters: { entityScope, tenantEntityName }` compile writes (#1645).
|
|
41
|
+
* A body that names one parameter in both slots is left as it is.
|
|
42
|
+
*/
|
|
43
|
+
export declare function subscriptionValues(values: Record<string, unknown>): Record<string, unknown>;
|
|
32
44
|
/**
|
|
33
45
|
* Which kind of connector element a bag belongs to, which decides how its
|
|
34
46
|
* inputs compare: an activity's field by field across its containers
|
|
@@ -81,6 +81,34 @@ function isEmptyInput(value) {
|
|
|
81
81
|
|| (Array.isArray(value) && value.length === 0) || (isObject(value) && Object.keys(value).length === 0);
|
|
82
82
|
}
|
|
83
83
|
const EVENT_SERVICE_TYPES = new Set(['Intsvc.EventTrigger', 'Intsvc.WaitForEvent']);
|
|
84
|
+
/**
|
|
85
|
+
* An event subscription's input values with its `where` read as the source
|
|
86
|
+
* holds it: `body.queryParams` and `body.parameters` merged into one `where`.
|
|
87
|
+
* Which slot a parameter sits in is the connector's bucket split, which the
|
|
88
|
+
* source cannot write: a Data Fabric trigger Studio Web saved with
|
|
89
|
+
* `queryParams: { entityScope, tenantEntityName }` holds the same values as
|
|
90
|
+
* the `parameters: { entityScope, tenantEntityName }` compile writes (#1645).
|
|
91
|
+
* A body that names one parameter in both slots is left as it is.
|
|
92
|
+
*/
|
|
93
|
+
export function subscriptionValues(values) {
|
|
94
|
+
const body = values.body;
|
|
95
|
+
if (!isObject(body) || (body.queryParams === undefined && body.parameters === undefined))
|
|
96
|
+
return values;
|
|
97
|
+
const slots = [body.queryParams, body.parameters].filter((slot) => slot !== undefined);
|
|
98
|
+
if (!slots.every(isObject))
|
|
99
|
+
return values;
|
|
100
|
+
const where = {};
|
|
101
|
+
for (const slot of slots)
|
|
102
|
+
for (const [name, value] of Object.entries(slot)) {
|
|
103
|
+
if (name in where)
|
|
104
|
+
return values;
|
|
105
|
+
where[name] = value;
|
|
106
|
+
}
|
|
107
|
+
const rest = { ...body };
|
|
108
|
+
delete rest.queryParams;
|
|
109
|
+
delete rest.parameters;
|
|
110
|
+
return { ...values, body: { ...rest, where } };
|
|
111
|
+
}
|
|
84
112
|
/**
|
|
85
113
|
* Which kind of connector element a bag belongs to, which decides how its
|
|
86
114
|
* inputs compare: an activity's field by field across its containers
|
|
@@ -171,9 +199,10 @@ export function onlyLibraryValuesDiffer(built, saved, opaque = NO_DATA) {
|
|
|
171
199
|
/** Whether two input value maps hold the same values, an input on one side only reading as empty. */
|
|
172
200
|
function sameInputs(a, b, kind) {
|
|
173
201
|
const [now, then] = kind === ConnectorKind.Activity ? [activityFieldValues(a), activityFieldValues(b)] : [undefined, undefined];
|
|
202
|
+
const [x, y] = kind === ConnectorKind.Event ? [subscriptionValues(a), subscriptionValues(b)] : [a, b];
|
|
174
203
|
const pairs = now && then
|
|
175
204
|
? [...new Set([...now.keys(), ...then.keys()])].map((key) => [now.get(key), then.get(key)])
|
|
176
|
-
: [...new Set([...Object.keys(
|
|
205
|
+
: [...new Set([...Object.keys(x), ...Object.keys(y)])].map((key) => [x[key], y[key]]);
|
|
177
206
|
return pairs.every(([x, y]) => (isEmptyInput(x) && isEmptyInput(y)) || stable(x) === stable(y));
|
|
178
207
|
}
|
|
179
208
|
/**
|
|
@@ -308,7 +337,7 @@ export function savedConnectorContext(owner, bag, rebuild) {
|
|
|
308
337
|
const inputs = inputValues(bag);
|
|
309
338
|
// A subscription body saved with no match expression compares as compile writes it.
|
|
310
339
|
if (EVENT_SERVICE_TYPES.has(bag.serviceType) && inputs.body !== undefined)
|
|
311
|
-
inputs.body = withScopeExpression(inputs.body, owner);
|
|
340
|
+
inputs.body = withScopeExpression(inputs.body, owner, rebuilt?.eventParameters);
|
|
312
341
|
else if (rebuilt?.containers)
|
|
313
342
|
Object.assign(inputs, structuredClone(rebuilt.containers));
|
|
314
343
|
return { owner, context: structuredClone(context), inputs };
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
* the same operation. An extract the author edits (another source or
|
|
61
61
|
* variable) gets compile's row.
|
|
62
62
|
*/
|
|
63
|
-
import { activityFieldValues, comparesContextRow, ConnectorKind, connectorKind, onlyLibraryValuesDiffer } from './connector-saved-context.js';
|
|
63
|
+
import { activityFieldValues, comparesContextRow, ConnectorKind, connectorKind, onlyLibraryValuesDiffer, subscriptionValues } from './connector-saved-context.js';
|
|
64
64
|
import { caseSubscriptionOwners, withScopeExpression } from './subscription.js';
|
|
65
65
|
/** Two input values that hold the same thing: both empty, or equal with key order not counting. */
|
|
66
66
|
function sameInput(a, b) {
|
|
@@ -252,7 +252,7 @@ function savedInputs(bag, activity, elementIds, owner, rebuilt) {
|
|
|
252
252
|
// A subscription body saved with no match expression is carried as compile
|
|
253
253
|
// writes it (`withScopeExpression`): the engine needs the expression.
|
|
254
254
|
const carried = structuredClone(rows).map((row) => (!activity && row.name === 'body' && row.body !== undefined
|
|
255
|
-
? { ...row, body: withScopeExpression(row.body, owner) } : row));
|
|
255
|
+
? { ...row, body: withScopeExpression(row.body, owner, rebuilt?.eventParameters) } : row));
|
|
256
256
|
return { rows: carried, ...(bag.inputs === undefined ? { absent: true } : {}) };
|
|
257
257
|
}
|
|
258
258
|
/**
|
|
@@ -468,10 +468,15 @@ function inputsBack(built, set, kind) {
|
|
|
468
468
|
return structuredClone(set.rows);
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
const
|
|
471
|
+
// An event's `where` is compared as the source holds it, whatever slot
|
|
472
|
+
// (`queryParams`, `parameters`) each parameter was saved in (`subscriptionValues`).
|
|
473
|
+
const values = (rows) => {
|
|
474
|
+
const named = Object.fromEntries(rows.map((row) => [String(row.name), inputValue(row)]));
|
|
475
|
+
return kind === ConnectorKind.Event ? subscriptionValues(named) : named;
|
|
476
|
+
};
|
|
477
|
+
const [builtValues, savedValues] = [values(built), values(set.rows)];
|
|
478
|
+
for (const name of new Set([...Object.keys(builtValues), ...Object.keys(savedValues)])) {
|
|
479
|
+
const [a, b] = [builtValues[name], savedValues[name]];
|
|
475
480
|
if (isEmpty(a) && isEmpty(b))
|
|
476
481
|
continue;
|
|
477
482
|
if (stable(a) !== stable(b))
|
package/dist/case/decompile.js
CHANGED
|
@@ -12,6 +12,7 @@ import { caseConnectorOwners, savedConnectorContext } from './connector-saved-co
|
|
|
12
12
|
import { connectorActivityMetadata, connectorEventMetadata } from '../core/connector-v2-metadata.js';
|
|
13
13
|
import { buildConnectorInputs, nestConnectorBody } from '../core/connector-inputs.js';
|
|
14
14
|
import { responseJsonSchema } from '../core/connector-response-schema.js';
|
|
15
|
+
import { splitEventParameters } from '../core/event-subscription.js';
|
|
15
16
|
import { EQUALS_EXPR_DIALECT } from '../core/connector-checks.js';
|
|
16
17
|
import { elementConfigV2Owners } from './intsvc-activity-config.js';
|
|
17
18
|
import { caseConnectorRowOwners, savedConnectorRows } from './connector-saved-rows.js';
|
|
@@ -325,6 +326,9 @@ function subscriptionBody(bag, owner) {
|
|
|
325
326
|
* A plan with no `parameters` reads back: it is what the SDK wrote before it
|
|
326
327
|
* split the `where` (all of it in `queryParams`), and recompiling moves a
|
|
327
328
|
* query- or path-bucket parameter to `parameters`, where the engine reads it.
|
|
329
|
+
* A Studio Web save in that shape keeps its split while the element is
|
|
330
|
+
* unedited: its rows and context come back as saved (`subscriptionValues` in
|
|
331
|
+
* connector-saved-context.ts reads the two slots as one `where`).
|
|
328
332
|
*/
|
|
329
333
|
function checkSubscriptionSlots(body, rc, owner) {
|
|
330
334
|
if (body.slots?.parameters === undefined)
|
|
@@ -3030,9 +3034,13 @@ function rebuiltConnectorElement(library, owner, bag, seed) {
|
|
|
3030
3034
|
version: configuration?.essentialConfiguration?.packageVersion,
|
|
3031
3035
|
});
|
|
3032
3036
|
const rc = library.resolveEvent(kind, identity.key, identity.event, identity.version, identity.object);
|
|
3037
|
+
// The saved `where`, whatever slot each parameter sits in, split by the library's buckets.
|
|
3038
|
+
const body = (Array.isArray(bag.inputs) ? bag.inputs : []).find((row) => row?.name === 'body')?.body;
|
|
3039
|
+
const where = { ...(body?.queryParams ?? {}), ...(body?.parameters ?? {}) };
|
|
3033
3040
|
return {
|
|
3034
3041
|
metadata: connectorEventMetadata(rc, rc.entry.operation ?? {}, configuration?.essentialConfiguration?.filter ?? null),
|
|
3035
3042
|
responseSchema: responseSchema(rc),
|
|
3043
|
+
eventParameters: new Set(Object.keys(splitEventParameters(rc, where).eventParameters)),
|
|
3036
3044
|
};
|
|
3037
3045
|
}
|
|
3038
3046
|
const identity = library.identifyAction({
|
|
@@ -126,11 +126,16 @@ export declare function caseSubscriptionBody(rc: ResolvedConnector, where: Recor
|
|
|
126
126
|
* way, so the added expression is not read as an edit that drops the element's
|
|
127
127
|
* saved context and rows.
|
|
128
128
|
*
|
|
129
|
+
* `eventParameters`, when decompile knows them from the library, are the
|
|
130
|
+
* names the connector puts in the event bucket; only those give a clause. A
|
|
131
|
+
* Data Fabric trigger saved with its query-bucket `entityScope` in
|
|
132
|
+
* `queryParams` gets no expression, as compile writes none for it.
|
|
133
|
+
*
|
|
129
134
|
* @example
|
|
130
135
|
* // { queryParams: { entityScope: 'tenant' } }
|
|
131
136
|
* // -> { filters: { expression: "(entityScope == 'tenant')" }, queryParams: { entityScope: 'tenant' } }
|
|
132
137
|
*/
|
|
133
|
-
export declare function withScopeExpression(body: unknown, owner: string): unknown;
|
|
138
|
+
export declare function withScopeExpression(body: unknown, owner: string, eventParameters?: ReadonlySet<string>): unknown;
|
|
134
139
|
/** One subscription in a Case plan: the bag that carries it, keyed by its owner. */
|
|
135
140
|
export interface CaseSubscriptionOwner {
|
|
136
141
|
/** `trigger:<node id>`, `task:<stage id>:<task id>` or `rule:<stage id>:<rule id>`. */
|
|
@@ -203,17 +203,27 @@ export function caseSubscriptionBody(rc, where, conditions, elementId, spelling
|
|
|
203
203
|
* way, so the added expression is not read as an edit that drops the element's
|
|
204
204
|
* saved context and rows.
|
|
205
205
|
*
|
|
206
|
+
* `eventParameters`, when decompile knows them from the library, are the
|
|
207
|
+
* names the connector puts in the event bucket; only those give a clause. A
|
|
208
|
+
* Data Fabric trigger saved with its query-bucket `entityScope` in
|
|
209
|
+
* `queryParams` gets no expression, as compile writes none for it.
|
|
210
|
+
*
|
|
206
211
|
* @example
|
|
207
212
|
* // { queryParams: { entityScope: 'tenant' } }
|
|
208
213
|
* // -> { filters: { expression: "(entityScope == 'tenant')" }, queryParams: { entityScope: 'tenant' } }
|
|
209
214
|
*/
|
|
210
|
-
export function withScopeExpression(body, owner) {
|
|
215
|
+
export function withScopeExpression(body, owner, eventParameters) {
|
|
211
216
|
if (!body || typeof body !== 'object' || Array.isArray(body))
|
|
212
217
|
return body;
|
|
213
218
|
const saved = body;
|
|
214
|
-
const
|
|
215
|
-
if (saved.filters !== undefined || !
|
|
219
|
+
const savedParams = saved.queryParams;
|
|
220
|
+
if (saved.filters !== undefined || !savedParams || typeof savedParams !== 'object' || Array.isArray(savedParams))
|
|
216
221
|
return body;
|
|
222
|
+
// Only the event-bucket parameters fold into the expression: a query- or
|
|
223
|
+
// path-bucket one is no scope clause compile writes (`caseSubscriptionBody`).
|
|
224
|
+
const params = eventParameters
|
|
225
|
+
? Object.fromEntries(Object.entries(savedParams).filter(([name]) => eventParameters.has(name)))
|
|
226
|
+
: savedParams;
|
|
217
227
|
let expression;
|
|
218
228
|
try {
|
|
219
229
|
expression = eventMatchExpression(eventScopeClauses(params, owner).map((c) => `(${c})`), []);
|
package/dist/merge-variables.js
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
* - the whole section: edited equals baseline → the original's, verbatim;
|
|
10
10
|
* - a top-level key (`globals`, `nodes`, `variableUpdates`): edited equals
|
|
11
11
|
* baseline → the original's (absent stays absent);
|
|
12
|
-
* - an entry of an id-keyed list (`globals`, `nodes`)
|
|
13
|
-
* (`variableUpdates`)
|
|
14
|
-
*
|
|
12
|
+
* - an entry of an id-keyed list (`globals`, `nodes`), a key of a map
|
|
13
|
+
* (`variableUpdates`) and a row under that key (by `variableId`): the
|
|
14
|
+
* same, and inside an entry each field the same, so an edited global's new
|
|
15
|
+
* `type` lands without the `name` compile adds.
|
|
15
16
|
*
|
|
16
17
|
* Presence follows the same logic. An entry the edited file lacks was removed
|
|
17
18
|
* by the author when the baseline has it, and lost by the round trip when it
|
|
@@ -79,7 +80,7 @@ export function mergeVariables(original, edited, baseline, goneNodeIds) {
|
|
|
79
80
|
for (const key of keysInOrder(orig, edited)) {
|
|
80
81
|
const updates = key === 'variableUpdates';
|
|
81
82
|
const inner = updates
|
|
82
|
-
? (o, b, e) => (isObj(o) && isObj(e) ?
|
|
83
|
+
? (o, b, e) => (isObj(o) && isObj(e) ? mergeUpdates(o, isObj(b) ? b : {}, e) : copy(e))
|
|
83
84
|
: (o, b, e) => mergeList(o, b, e, goneNodeIds);
|
|
84
85
|
// A section the original lacks but the round trip writes is merged as an
|
|
85
86
|
// empty one, so its minted entries stay out and only the author's land.
|
|
@@ -92,7 +93,53 @@ export function mergeVariables(original, edited, baseline, goneNodeIds) {
|
|
|
92
93
|
}
|
|
93
94
|
if (original === undefined && entries.length === 0)
|
|
94
95
|
return undefined;
|
|
95
|
-
return withoutGoneUpdates(Object.fromEntries(entries), goneNodeIds);
|
|
96
|
+
return withoutGoneUpdates(withoutRowsForGoneGlobals(Object.fromEntries(entries), orig, edited), goneNodeIds);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* `variables` without an update row kept from the original for a global the
|
|
100
|
+
* merged file no longer has. `mergeRows` keeps a row compile never writes (the
|
|
101
|
+
* edited file lacks it, and so does the baseline), so when the author renamed or
|
|
102
|
+
* deleted the global that row writes, it would outlive the variable.
|
|
103
|
+
*
|
|
104
|
+
* Example, the author renames global `x` to `y` on an End whose `x` row compile
|
|
105
|
+
* does not write:
|
|
106
|
+
*
|
|
107
|
+
* original end: [x = 1] merged globals [y] edited end: [y = 2]
|
|
108
|
+
* merged end: [y = 2] (not [x = 1, y = 2])
|
|
109
|
+
*
|
|
110
|
+
* Only a row the edited file lacks, for an id that was a global in the original
|
|
111
|
+
* and is not one now: any other row is left to the delta rule.
|
|
112
|
+
*/
|
|
113
|
+
function withoutRowsForGoneGlobals(merged, orig, edited) {
|
|
114
|
+
const ids = (v) => new Set(Array.isArray(v) ? v.filter((g) => isObj(g) && typeof g.id === 'string').map((g) => g.id) : []);
|
|
115
|
+
const before = ids(orig.globals);
|
|
116
|
+
const now = ids(merged.globals);
|
|
117
|
+
const gone = [...before].filter((id) => !now.has(id));
|
|
118
|
+
if (gone.length === 0 || !isObj(merged.variableUpdates))
|
|
119
|
+
return merged;
|
|
120
|
+
const editedUpdates = isObj(edited.variableUpdates) ? edited.variableUpdates : {};
|
|
121
|
+
// Built from entries, not by assignment, so a node id `__proto__` stays a key.
|
|
122
|
+
const entries = [];
|
|
123
|
+
let changed = false;
|
|
124
|
+
for (const [nodeId, rows] of Object.entries(merged.variableUpdates)) {
|
|
125
|
+
if (!Array.isArray(rows)) {
|
|
126
|
+
entries.push([nodeId, rows]);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const editedOwn = own(editedUpdates, nodeId);
|
|
130
|
+
const editedRows = Array.isArray(editedOwn) ? editedOwn : [];
|
|
131
|
+
const inEdited = (vid) => editedRows.some((r) => isObj(r) && r.variableId === vid);
|
|
132
|
+
const kept = rows.filter((r) => !(isObj(r) && typeof r.variableId === 'string' && gone.includes(r.variableId) && !inEdited(r.variableId)));
|
|
133
|
+
if (kept.length === rows.length) {
|
|
134
|
+
entries.push([nodeId, rows]);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
changed = true;
|
|
138
|
+
// A node left with no rows keeps no key, as the merge writes for a node the author emptied.
|
|
139
|
+
if (kept.length)
|
|
140
|
+
entries.push([nodeId, kept]);
|
|
141
|
+
}
|
|
142
|
+
return changed ? { ...merged, variableUpdates: Object.fromEntries(entries) } : merged;
|
|
96
143
|
}
|
|
97
144
|
/** `undefined` for an empty list or map, so an absent section stays absent. */
|
|
98
145
|
function nonEmpty(v) {
|
|
@@ -188,9 +235,128 @@ function insertAt(out, edited, i) {
|
|
|
188
235
|
return 0;
|
|
189
236
|
}
|
|
190
237
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
238
|
+
* The `variableUpdates` map (node id -> rows) the author changed: each node's
|
|
239
|
+
* rows under the delta rule, one row at a time ({@link mergeRows}), node ids in
|
|
240
|
+
* the original's order.
|
|
241
|
+
*
|
|
242
|
+
* Taking a changed node's rows whole lost what the original wrote and kept what
|
|
243
|
+
* only compile writes. An End the original wrote with ten rows that compile
|
|
244
|
+
* does not write came back with just the one row the author added; an End the
|
|
245
|
+
* original wrote with none came back with the row compile mints for it too.
|
|
246
|
+
*/
|
|
247
|
+
function mergeUpdates(o, b, e) {
|
|
248
|
+
const entries = [];
|
|
249
|
+
for (const key of keysInOrder(o, e)) {
|
|
250
|
+
const [inO, inB, inE] = [has(o, key), has(b, key), has(e, key)];
|
|
251
|
+
let v;
|
|
252
|
+
if (!inE)
|
|
253
|
+
v = inB || !inO ? undefined : copy(o[key]); // removed by the author / lost by the round trip
|
|
254
|
+
else if (inB && same(e[key], b[key]))
|
|
255
|
+
v = inO ? copy(o[key]) : undefined; // untouched
|
|
256
|
+
else {
|
|
257
|
+
const rows = mergeRows(inO ? o[key] : [], inB ? b[key] : [], e[key]);
|
|
258
|
+
// Every row compile minted, and none the author wrote: absent stays absent.
|
|
259
|
+
v = !inO && Array.isArray(rows) && rows.length === 0 ? undefined : rows;
|
|
260
|
+
}
|
|
261
|
+
if (v !== undefined)
|
|
262
|
+
entries.push([key, v]);
|
|
263
|
+
}
|
|
264
|
+
return Object.fromEntries(entries);
|
|
265
|
+
}
|
|
266
|
+
/** Rows (`{ variableId, expression }`), each variable at most once. */
|
|
267
|
+
function rowList(v) {
|
|
268
|
+
if (!Array.isArray(v) || !v.every((x) => isObj(x) && typeof x.variableId === 'string'))
|
|
269
|
+
return false;
|
|
270
|
+
return new Set(v.map((x) => x.variableId)).size === v.length;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* One node's update rows, keyed by `variableId`, under the delta rule: a row
|
|
274
|
+
* the author did not change is the original's; one the edited file lacks was
|
|
275
|
+
* removed (the baseline has it) or lost by the round trip (kept); one the
|
|
276
|
+
* original lacks is the author's, unless the baseline has it unchanged (minted
|
|
277
|
+
* by the round trip, dropped).
|
|
278
|
+
*
|
|
279
|
+
* Order: rows are ordered BPMN output mappings, and the runtime writes each one
|
|
280
|
+
* before it evaluates the next, so order can change a value. When the author
|
|
281
|
+
* did not reorder (the rows edited and baseline share are in the same order in
|
|
282
|
+
* both), rows keep the original's order and an added row goes after the edited
|
|
283
|
+
* row before it, else before the edited row after it, else last. When the
|
|
284
|
+
* author did reorder, rows follow the edited order, and a row only the original
|
|
285
|
+
* has (one compile never writes) goes after the original row before it, else
|
|
286
|
+
* before the original row after it, else last.
|
|
287
|
+
*
|
|
288
|
+
* Example, the author adds `extra` to an End compile writes no rows for:
|
|
289
|
+
*
|
|
290
|
+
* original [a, b] baseline [] edited [extra]
|
|
291
|
+
* merged [a, b, extra]
|
|
292
|
+
*
|
|
293
|
+
* Example, the author swaps `a` and `b` on an End that also has `k`, a row
|
|
294
|
+
* compile never writes:
|
|
295
|
+
*
|
|
296
|
+
* original [a, k, b] baseline [a, b] edited [b, a]
|
|
297
|
+
* merged [b, a, k]
|
|
298
|
+
*/
|
|
299
|
+
function mergeRows(o, b, e) {
|
|
300
|
+
if (!rowList(o) || !rowList(b) || !rowList(e))
|
|
301
|
+
return copy(e);
|
|
302
|
+
const id = (x) => x.variableId;
|
|
303
|
+
const base = new Map(b.map((x) => [id(x), x]));
|
|
304
|
+
const edits = new Map(e.map((x) => [id(x), x]));
|
|
305
|
+
/** The merged row for an edited one; `undefined` = minted by the round trip. */
|
|
306
|
+
const originals = new Map(o.map((x) => [id(x), x]));
|
|
307
|
+
const mergedRow = (ed) => {
|
|
308
|
+
const [row, bRow] = [originals.get(id(ed)), base.get(id(ed))];
|
|
309
|
+
const untouched = bRow !== undefined && same(ed, bRow);
|
|
310
|
+
if (!row)
|
|
311
|
+
return untouched ? undefined : copy(ed);
|
|
312
|
+
return untouched ? copy(row) : mergeFields(row, bRow, ed);
|
|
313
|
+
};
|
|
314
|
+
/** A row only the original has: compile never writes it, so it is kept. */
|
|
315
|
+
const originalOnly = (row) => !edits.has(id(row)) && !base.has(id(row));
|
|
316
|
+
const shared = (rows, other) => rows.map(id).filter((v) => other.has(v));
|
|
317
|
+
const reordered = shared(e, base).join('\0') !== shared(b, edits).join('\0');
|
|
318
|
+
const out = [];
|
|
319
|
+
if (reordered) {
|
|
320
|
+
for (const ed of e) {
|
|
321
|
+
const row = mergedRow(ed);
|
|
322
|
+
if (row)
|
|
323
|
+
out.push(row);
|
|
324
|
+
}
|
|
325
|
+
for (const [i, row] of o.entries())
|
|
326
|
+
if (originalOnly(row))
|
|
327
|
+
out.splice(rowInsertAt(out, o, i), 0, copy(row));
|
|
328
|
+
return out;
|
|
329
|
+
}
|
|
330
|
+
for (const row of o) {
|
|
331
|
+
const ed = edits.get(id(row));
|
|
332
|
+
if (ed)
|
|
333
|
+
out.push(mergedRow(ed));
|
|
334
|
+
else if (originalOnly(row))
|
|
335
|
+
out.push(copy(row));
|
|
336
|
+
}
|
|
337
|
+
for (const [i, ed] of e.entries()) {
|
|
338
|
+
if (originals.has(id(ed)))
|
|
339
|
+
continue; // placed above
|
|
340
|
+
const row = mergedRow(ed);
|
|
341
|
+
if (row)
|
|
342
|
+
out.splice(rowInsertAt(out, e, i), 0, row);
|
|
343
|
+
}
|
|
344
|
+
return out;
|
|
345
|
+
}
|
|
346
|
+
/** After the nearest earlier row of `rows` already in `out`, else before the nearest later one, else last. */
|
|
347
|
+
function rowInsertAt(out, rows, i) {
|
|
348
|
+
const at = (j) => out.findIndex((x) => x.variableId === rows[j].variableId);
|
|
349
|
+
for (let j = i - 1; j >= 0; j--)
|
|
350
|
+
if (at(j) >= 0)
|
|
351
|
+
return at(j) + 1;
|
|
352
|
+
for (let j = i + 1; j < rows.length; j++)
|
|
353
|
+
if (at(j) >= 0)
|
|
354
|
+
return at(j);
|
|
355
|
+
return out.length;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* An object the author changed, a list entry or an update row: each key under
|
|
359
|
+
* the delta rule, each value taken whole, keys in the original's order.
|
|
194
360
|
*/
|
|
195
361
|
function mergeFields(o, b, e) {
|
|
196
362
|
return mergeObject(o, b ?? {}, e, (_o, _b, ev) => copy(ev));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.124.
|
|
3
|
+
"version": "6.124.2",
|
|
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",
|
|
@@ -127,5 +127,5 @@
|
|
|
127
127
|
"@types/node": "^22.7.0",
|
|
128
128
|
"esbuild": "^0.28.1"
|
|
129
129
|
},
|
|
130
|
-
"gitref": "
|
|
130
|
+
"gitref": "56204a12ddb7029c659153d9c82aeb1933879346"
|
|
131
131
|
}
|