@uipath/maestro-builder-sdk 6.94.1 → 6.94.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/case/decompile.js +37 -1
- package/dist/case/preserve.d.ts +19 -0
- package/dist/case/serialize.d.ts +3 -1
- package/dist/case/serialize.js +104 -3
- package/dist/core/refusals.d.ts +1 -0
- package/dist/core/refusals.js +1 -0
- package/package.json +2 -2
package/dist/case/decompile.js
CHANGED
|
@@ -2237,7 +2237,33 @@ function stageDataPreservation(data, stageName, generation) {
|
|
|
2237
2237
|
return undefined;
|
|
2238
2238
|
return { ...(Object.keys(fields).length ? { fields } : {}), ...(omit.length ? { omit } : {}) };
|
|
2239
2239
|
}
|
|
2240
|
-
|
|
2240
|
+
/**
|
|
2241
|
+
* The ids of SLAs whose displayName another SLA of the plan shares. The source
|
|
2242
|
+
* names an SLA by displayName (`rule('sla-status-change', { sla })`), which
|
|
2243
|
+
* compile resolves to the last SLA declared with it, so a rule on any other
|
|
2244
|
+
* of them keeps its `slaId` in the payload.
|
|
2245
|
+
*/
|
|
2246
|
+
function ambiguousSlaIds(plan) {
|
|
2247
|
+
const slas = [...(plan.metadata?.slaRules ?? []), ...(plan.nodes ?? []).filter(isStage).flatMap((stage) => stage.data?.slaRules ?? [])];
|
|
2248
|
+
const count = new Map();
|
|
2249
|
+
for (const sla of slas)
|
|
2250
|
+
if (sla.displayName)
|
|
2251
|
+
count.set(sla.displayName, (count.get(sla.displayName) ?? 0) + 1);
|
|
2252
|
+
// Each such SLA's id, with the displayName it shares.
|
|
2253
|
+
return new Map(slas.flatMap((sla) => (sla.id && sla.displayName && (count.get(sla.displayName) ?? 0) > 1 ? [[sla.id, sla.displayName]] : [])));
|
|
2254
|
+
}
|
|
2255
|
+
function conditionIdentityOf(condition, ambiguousSlas = new Map(), siblings = [condition]) {
|
|
2256
|
+
// Another condition of the same list with this name: the name alone does not
|
|
2257
|
+
// say which one a pin was saved on.
|
|
2258
|
+
const nameShared = siblings.filter((other) => (other.displayName ?? '') === (condition.displayName ?? '')).length > 1;
|
|
2259
|
+
// A pinned rule is found again, inside its condition, as the n-th
|
|
2260
|
+
// `sla-status-change` rule on an SLA of that name: a rule group added or
|
|
2261
|
+
// removed before it shifts its `[group][rule]` slot, not its order.
|
|
2262
|
+
const flat = (condition.rules ?? []).flat();
|
|
2263
|
+
const ordinal = (rule) => {
|
|
2264
|
+
const name = ambiguousSlas.get(rule.slaId ?? '');
|
|
2265
|
+
return flat.slice(0, flat.indexOf(rule)).filter((other) => other.rule === 'sla-status-change' && ambiguousSlas.get(other.slaId ?? '') === name).length;
|
|
2266
|
+
};
|
|
2241
2267
|
if (condition.edgeIds !== undefined
|
|
2242
2268
|
&& (!Array.isArray(condition.edgeIds) || !condition.edgeIds.every((id) => typeof id === 'string')))
|
|
2243
2269
|
throw new Error(`condition "${condition.displayName ?? condition.id ?? '?'}" has edgeIds that is not a list of edge id strings. The Case Designer writes an array of edge ids; fix or remove the field.`);
|
|
@@ -2248,6 +2274,14 @@ function conditionIdentity(condition) {
|
|
|
2248
2274
|
...(condition.edgeIds !== undefined ? { edgeIds: condition.edgeIds } : {}),
|
|
2249
2275
|
rules: (condition.rules ?? []).map((group) => group.map((rule) => ({
|
|
2250
2276
|
...(rule.id ? { id: rule.id } : {}),
|
|
2277
|
+
// Which of several same-named SLAs the rule watches (see `ambiguousSlaIds`).
|
|
2278
|
+
// The condition's name, as the source spells it, rides with it, and so
|
|
2279
|
+
// does the rule's order among its condition's rules on that SLA name:
|
|
2280
|
+
// conditions pair up by position, and an edit that deletes an earlier
|
|
2281
|
+
// sibling, or adds a rule group, must not move the pin.
|
|
2282
|
+
...(rule.rule === 'sla-status-change' && rule.slaId && ambiguousSlas.has(rule.slaId)
|
|
2283
|
+
? { slaId: rule.slaId, slaCondition: condition.displayName ?? '', ...(nameShared ? { slaConditionShared: true } : {}), ...(ordinal(rule) > 0 ? { slaOrdinal: ordinal(rule) } : {}) }
|
|
2284
|
+
: {}),
|
|
2251
2285
|
// A wait-for-connector rule's rows take their ids from the plan-wide pool,
|
|
2252
2286
|
// so deleting an earlier output would renumber them.
|
|
2253
2287
|
...(rule.uipath?.outputs?.length
|
|
@@ -2425,6 +2459,8 @@ function unaliasedOwnNameRow(row, plan) {
|
|
|
2425
2459
|
return root.some((entry) => entry?.id === row.id) ? { noAlias: true } : {};
|
|
2426
2460
|
}
|
|
2427
2461
|
function identityPreservation(plan) {
|
|
2462
|
+
const ambiguous = ambiguousSlaIds(plan);
|
|
2463
|
+
const conditionIdentity = (condition, _index, list) => conditionIdentityOf(condition, ambiguous, list);
|
|
2428
2464
|
return {
|
|
2429
2465
|
...(plan.id ? { id: plan.id } : {}),
|
|
2430
2466
|
triggers: (plan.nodes ?? []).filter(isTrigger).map((node) => ({ ...(node.id ? { id: node.id } : {}) })),
|
package/dist/case/preserve.d.ts
CHANGED
|
@@ -159,8 +159,27 @@ interface ConditionIdentity {
|
|
|
159
159
|
id?: string;
|
|
160
160
|
/** The Designer's ids of the canvas edges drawn for the condition. */
|
|
161
161
|
edgeIds?: string[];
|
|
162
|
+
/**
|
|
163
|
+
* `slaId`: on a `sla-status-change` rule whose SLA shares its displayName with
|
|
164
|
+
* another SLA, the one the rule watches. The source names the SLA by
|
|
165
|
+
* displayName only, and compile resolves that to the last declaration.
|
|
166
|
+
* `slaCondition` is the displayName of the condition that held the rule, as
|
|
167
|
+
* the source spells it (`slaConditionShared` when another condition of the
|
|
168
|
+
* list has that name too), and `slaOrdinal` (absent for 0) the rule's place
|
|
169
|
+
* among that condition's `sla-status-change` rules on an SLA of the same
|
|
170
|
+
* name. Compile gives the pin to the one condition of the list with that
|
|
171
|
+
* name, when the name is unique on both sides; else to the condition at the
|
|
172
|
+
* same position, when no other pin owns that slot by name and either the
|
|
173
|
+
* saved name was unique (the condition was renamed) or the list kept its
|
|
174
|
+
* length. Each condition takes at most one pin per rule, and a pin with no
|
|
175
|
+
* owner is dropped with a `SLA_PIN_DROPPED` warning.
|
|
176
|
+
*/
|
|
162
177
|
rules?: Array<Array<{
|
|
163
178
|
id?: string;
|
|
179
|
+
slaId?: string;
|
|
180
|
+
slaCondition?: string;
|
|
181
|
+
slaConditionShared?: boolean;
|
|
182
|
+
slaOrdinal?: number;
|
|
164
183
|
outputs?: Array<{
|
|
165
184
|
name: string;
|
|
166
185
|
id?: string;
|
package/dist/case/serialize.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export interface CaseSerializeOpts {
|
|
|
62
62
|
}
|
|
63
63
|
/** A warning `serialize` reports through {@link CaseSerializeOpts.warn}. */
|
|
64
64
|
export interface CaseSerializeWarning {
|
|
65
|
-
code: 'CONNECTION_STUB';
|
|
65
|
+
code: 'CONNECTION_STUB' | 'SLA_PIN_DROPPED';
|
|
66
66
|
message: string;
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
@@ -90,6 +90,8 @@ export interface ApplyPreservationOptions {
|
|
|
90
90
|
* of the merge is that the original wins on exactly those.
|
|
91
91
|
*/
|
|
92
92
|
overwrite?: boolean;
|
|
93
|
+
/** The serializer's warning sink: a preserved fact the edit left no place for (`SLA_PIN_DROPPED`). */
|
|
94
|
+
warn?: (warning: CaseSerializeWarning) => void;
|
|
93
95
|
}
|
|
94
96
|
/**
|
|
95
97
|
* Stamp a preservation payload onto a caseplan-shaped document. Exported for
|
package/dist/case/serialize.js
CHANGED
|
@@ -428,7 +428,7 @@ function serializeCase(built, opts) {
|
|
|
428
428
|
};
|
|
429
429
|
ELEMENT_SEEDED_IDS.set(result, resolver.elementSeededIds);
|
|
430
430
|
WRITTEN_SUBSCRIPTIONS.set(result, resolver.subscriptions);
|
|
431
|
-
const plan = stampConnectorConfigVersion(applyAuthorLayout(applyPreservation(result, caseJsonPreservation(built)), built.layout));
|
|
431
|
+
const plan = stampConnectorConfigVersion(applyAuthorLayout(applyPreservation(result, caseJsonPreservation(built), opts.warn ? { warn: opts.warn } : {}), built.layout));
|
|
432
432
|
// Last, over the finished document: V32 requires case-unique condition names,
|
|
433
433
|
// and an author (or a decompiled pre-V32 plan) can repeat one. Rename the
|
|
434
434
|
// repeats the way the platform's V31/V32.0.1 migrations would, so the file is
|
|
@@ -586,7 +586,7 @@ export function applyPreservation(result, preservation, options = {}) {
|
|
|
586
586
|
if (errors.length)
|
|
587
587
|
throw new CompileRefusal('PRESERVATION_COLLISION', `invalid Case JSON preservation payload: ${errors.join('; ')}`);
|
|
588
588
|
preservation = followRenames(result, preservation);
|
|
589
|
-
applyPreservedIdentities(result, preservation);
|
|
589
|
+
applyPreservedIdentities(result, preservation, options.warn);
|
|
590
590
|
applySubscriptionFilters(result, preservation);
|
|
591
591
|
Object.assign(result, preservation.topLevel ?? {});
|
|
592
592
|
Object.assign(result.metadata, preservation.metadata ?? {});
|
|
@@ -1308,7 +1308,7 @@ function restoreNoTasks(data, spelling) {
|
|
|
1308
1308
|
else
|
|
1309
1309
|
data.tasks = [];
|
|
1310
1310
|
}
|
|
1311
|
-
function applyPreservedIdentities(result, preservation) {
|
|
1311
|
+
function applyPreservedIdentities(result, preservation, warn) {
|
|
1312
1312
|
const identities = preservation.identities;
|
|
1313
1313
|
if (!identities)
|
|
1314
1314
|
return;
|
|
@@ -1550,6 +1550,7 @@ function applyPreservedIdentities(result, preservation) {
|
|
|
1550
1550
|
});
|
|
1551
1551
|
};
|
|
1552
1552
|
const takeConditions = (current, wanted) => {
|
|
1553
|
+
const pins = [];
|
|
1553
1554
|
(wanted ?? []).forEach((condition, index) => {
|
|
1554
1555
|
const target = current?.[index];
|
|
1555
1556
|
take(target, condition.id);
|
|
@@ -1558,11 +1559,41 @@ function applyPreservedIdentities(result, preservation) {
|
|
|
1558
1559
|
(condition.rules ?? []).forEach((group, groupIndex) => group.forEach((rule, ruleIndex) => {
|
|
1559
1560
|
const ruleTarget = target?.rules?.[groupIndex]?.[ruleIndex];
|
|
1560
1561
|
take(ruleTarget, rule.id);
|
|
1562
|
+
if (typeof rule.slaId === 'string')
|
|
1563
|
+
pins.push({ index, rule });
|
|
1561
1564
|
if (rule.outputs)
|
|
1562
1565
|
takeOutputRows(ruleTarget?.[bagField]?.outputs ?? [], rule.outputs);
|
|
1563
1566
|
}));
|
|
1564
1567
|
});
|
|
1568
|
+
// Each pin goes to the condition it was saved on. Ids pair up by position,
|
|
1569
|
+
// and an edit that deletes an earlier sibling shifts the next condition into
|
|
1570
|
+
// its slot, so a pin is found by the condition's name when that name is one
|
|
1571
|
+
// condition's on both sides. Else, by position: only when no other pin owns
|
|
1572
|
+
// that slot by name, and the saved name was unique (the condition was
|
|
1573
|
+
// renamed) or the list kept its length (nothing shifted). A pin with no
|
|
1574
|
+
// owner is dropped, and so is a second pin for the same rule, which
|
|
1575
|
+
// `restoreRuleSlas` decides once it has found the rule (it warns).
|
|
1576
|
+
const list = current ?? [];
|
|
1577
|
+
const nameOf = (condition) => condition?.displayName ?? '';
|
|
1578
|
+
const byName = (pin) => {
|
|
1579
|
+
const name = pin.rule.slaCondition;
|
|
1580
|
+
if (typeof name !== 'string' || pin.rule.slaConditionShared === true)
|
|
1581
|
+
return undefined;
|
|
1582
|
+
const named = list.filter((candidate) => nameOf(candidate) === name);
|
|
1583
|
+
return named.length === 1 ? named[0] : undefined;
|
|
1584
|
+
};
|
|
1585
|
+
const ownedByName = new Set(pins.map(byName).filter(Boolean));
|
|
1586
|
+
for (const pin of pins) {
|
|
1587
|
+
const atSlot = list[pin.index];
|
|
1588
|
+
const owner = byName(pin)
|
|
1589
|
+
?? (atSlot && !ownedByName.has(atSlot) && (pin.rule.slaConditionShared !== true || list.length === (wanted ?? []).length) ? atSlot : undefined);
|
|
1590
|
+
const ordinal = typeof pin.rule.slaOrdinal === 'number' ? pin.rule.slaOrdinal : 0;
|
|
1591
|
+
wantedRuleSlas.push({ condition: owner, ordinal, slaId: pin.rule.slaId, conditionName: pin.rule.slaCondition ?? nameOf(atSlot) });
|
|
1592
|
+
}
|
|
1565
1593
|
};
|
|
1594
|
+
// `sla-status-change` rules whose payload names which of several same-named
|
|
1595
|
+
// SLAs they watch, settled by `restoreRuleSlas` once SLA ids are final.
|
|
1596
|
+
const wantedRuleSlas = [];
|
|
1566
1597
|
// Preserved SLA and escalation ids, restored by `restoreSlaIds` once every
|
|
1567
1598
|
// other id is in place.
|
|
1568
1599
|
const wantedSlaIds = new Map();
|
|
@@ -1677,6 +1708,7 @@ function applyPreservedIdentities(result, preservation) {
|
|
|
1677
1708
|
takeSlas(metadata.slaRules, identities.slaRules);
|
|
1678
1709
|
restoreEmptyLists(metadata, identities.emptyLists, CASE_EMPTY_LISTS);
|
|
1679
1710
|
restoreSlaIds();
|
|
1711
|
+
restoreRuleSlas(result, stages, wantedRuleSlas, (id) => replacements.get(id) ?? id, warn);
|
|
1680
1712
|
const variables = result.variables;
|
|
1681
1713
|
if (carriedCompanions.size) {
|
|
1682
1714
|
const inputOutputs = (variables.inputOutputs ??= []);
|
|
@@ -2638,6 +2670,75 @@ function refreshedActionContext(context, data, saved, formKindChanged) {
|
|
|
2638
2670
|
}
|
|
2639
2671
|
return out;
|
|
2640
2672
|
}
|
|
2673
|
+
/**
|
|
2674
|
+
* Point each `sla-status-change` rule the payload pinned back at the SLA it
|
|
2675
|
+
* watched. The source names an SLA by displayName, which compile resolves to
|
|
2676
|
+
* the last SLA declared with it; a rule on another SLA of that name gets its
|
|
2677
|
+
* own `slaId` back, and an at-risk rule the same-named escalation of that SLA.
|
|
2678
|
+
* The rule is the `ordinal`-th `sla-status-change` rule of its condition on an
|
|
2679
|
+
* SLA of the pinned SLA's name, so a rule group added before it does not hide
|
|
2680
|
+
* it. A pin the edit left no place for (no condition, no such rule, the SLA
|
|
2681
|
+
* renamed or removed, no same-named escalation) keeps compile's answer, with a
|
|
2682
|
+
* `SLA_PIN_DROPPED` warning that names the condition and both SLA ids.
|
|
2683
|
+
*/
|
|
2684
|
+
function restoreRuleSlas(result, stages, wanted,
|
|
2685
|
+
// The final id of an id this pass generated: the rule still holds the
|
|
2686
|
+
// generated SLA and escalation ids until the reference rewrite runs.
|
|
2687
|
+
final, warn) {
|
|
2688
|
+
if (!wanted.length)
|
|
2689
|
+
return;
|
|
2690
|
+
const slas = [...(result.metadata?.slaRules ?? []), ...stages.flatMap((stage) => stage.data?.slaRules ?? [])];
|
|
2691
|
+
const byId = new Map(slas.filter((sla) => typeof sla?.id === 'string').map((sla) => [sla.id, sla]));
|
|
2692
|
+
// Each rule takes at most one pin. The rule is found by its condition, the
|
|
2693
|
+
// pinned SLA's name and its place among that condition's rules on the name,
|
|
2694
|
+
// so two pins in one condition on SLAs of different names (each the first on
|
|
2695
|
+
// its own name) are two rules, not one.
|
|
2696
|
+
const claimed = new Set();
|
|
2697
|
+
for (const { condition, ordinal, slaId, conditionName } of wanted) {
|
|
2698
|
+
const pinned = byId.get(slaId);
|
|
2699
|
+
const name = pinned?.displayName;
|
|
2700
|
+
const lastNamed = name ? [...slas].reverse().find((sla) => sla?.displayName === name) : undefined;
|
|
2701
|
+
const drop = (why) => warn?.({
|
|
2702
|
+
code: 'SLA_PIN_DROPPED',
|
|
2703
|
+
message: `Condition "${conditionName}": its sla-status-change rule watched SLA ${slaId}${name ? ` ("${name}")` : ''}, but ${why}. `
|
|
2704
|
+
+ (lastNamed?.id ? `The rule now watches ${lastNamed.id}, the last SLA of that name. ` : '')
|
|
2705
|
+
+ 'Several SLAs share that name and the source names an SLA by displayName only; give each SLA its own displayName to pick one.',
|
|
2706
|
+
});
|
|
2707
|
+
if (!pinned || !name) {
|
|
2708
|
+
drop('that SLA is no longer in the plan');
|
|
2709
|
+
continue;
|
|
2710
|
+
}
|
|
2711
|
+
if (!condition) {
|
|
2712
|
+
drop('the edit left no condition that is clearly the one it was saved on');
|
|
2713
|
+
continue;
|
|
2714
|
+
}
|
|
2715
|
+
const onName = (condition.rules ?? []).flat()
|
|
2716
|
+
.filter((rule) => rule?.rule === 'sla-status-change' && typeof rule.slaId === 'string' && byId.get(final(rule.slaId))?.displayName === name);
|
|
2717
|
+
const rule = onName[ordinal];
|
|
2718
|
+
if (!rule) {
|
|
2719
|
+
drop('the condition no longer has that rule');
|
|
2720
|
+
continue;
|
|
2721
|
+
}
|
|
2722
|
+
if (claimed.has(rule)) {
|
|
2723
|
+
drop('another pin already claims that rule');
|
|
2724
|
+
continue;
|
|
2725
|
+
}
|
|
2726
|
+
claimed.add(rule);
|
|
2727
|
+
if (final(rule.slaId) === slaId)
|
|
2728
|
+
continue;
|
|
2729
|
+
if (rule.escalationId !== undefined && rule.escalationId !== ANY_ESCALATION_ID) {
|
|
2730
|
+
const current = byId.get(final(rule.slaId));
|
|
2731
|
+
const escalationName = (current?.escalationRule ?? []).find((entry) => entry?.id === final(String(rule.escalationId)))?.displayName;
|
|
2732
|
+
const escalation = escalationName === undefined ? undefined : (pinned.escalationRule ?? []).find((entry) => entry?.displayName === escalationName);
|
|
2733
|
+
if (!escalation?.id) {
|
|
2734
|
+
drop('that SLA has no escalation of the name the rule waits for');
|
|
2735
|
+
continue;
|
|
2736
|
+
}
|
|
2737
|
+
rule.escalationId = escalation.id;
|
|
2738
|
+
}
|
|
2739
|
+
rule.slaId = slaId;
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2641
2742
|
/**
|
|
2642
2743
|
* Put back the own-name shape of `restored` rows whose variable the source plan
|
|
2643
2744
|
* had no root entry for: no `originalVar`, and no root companion, as the
|
package/dist/core/refusals.d.ts
CHANGED
|
@@ -700,6 +700,7 @@ export declare const REFUSALS: {
|
|
|
700
700
|
readonly SLA_COUNT_RANGE: "lint";
|
|
701
701
|
readonly SLA_NONPOSITIVE: "lint";
|
|
702
702
|
readonly SLA_NO_ESCALATIONS: "lint";
|
|
703
|
+
readonly SLA_PIN_DROPPED: "lint";
|
|
703
704
|
readonly STAGE_NO_COMPLETION: "lint";
|
|
704
705
|
readonly STEP_ID_COLLISION: "lowering";
|
|
705
706
|
readonly STEP_NOT_ACTION: "lowering";
|
package/dist/core/refusals.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.94.
|
|
3
|
+
"version": "6.94.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",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"@types/node": "^22.7.0",
|
|
112
112
|
"esbuild": "^0.28.1"
|
|
113
113
|
},
|
|
114
|
-
"gitref": "
|
|
114
|
+
"gitref": "32128da37ad09d34ff04fae56bd1c0d50d30bab5"
|
|
115
115
|
}
|