@uipath/maestro-builder-sdk 6.86.27 → 6.87.0
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/decompile-cli.js +4 -3
- package/dist/bpmn/decompile.js +4 -3
- package/dist/bpmn/merge-cli.js +19 -1
- package/dist/bpmn/merge-placement.d.ts +33 -0
- package/dist/bpmn/merge-placement.js +899 -0
- package/dist/bpmn/merge.d.ts +7 -0
- package/dist/bpmn/merge.js +44 -2
- package/dist/bpmn/serialize.js +2 -1
- package/dist/check.js +24 -54
- package/dist/core/step-ports.d.ts +37 -0
- package/dist/decompile.js +20 -38
- package/dist/flow-node-type.d.ts +30 -1
- package/dist/flow-step-exits.d.ts +10 -1
- package/dist/flow-step-exits.js +18 -6
- package/dist/nodes/hitl/flow/node-type.js +76 -1
- package/package.json +2 -2
package/dist/bpmn/merge.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type BpmnPlacementReport } from './merge-placement.js';
|
|
1
2
|
export interface BpmnMergeOptions {
|
|
2
3
|
/**
|
|
3
4
|
* `compile(decompile(original))` captured BEFORE the author's edits — what a faithful
|
|
@@ -15,5 +16,11 @@ export interface BpmnMergeResult {
|
|
|
15
16
|
authored: string[];
|
|
16
17
|
/** Element ids present in the original but gone from the edited process. */
|
|
17
18
|
removed: string[];
|
|
19
|
+
/**
|
|
20
|
+
* What the merge drew: the edit's new flow nodes and sequence flows get diagram
|
|
21
|
+
* geometry in the original's diagram, and every existing shape keeps its bounds unless
|
|
22
|
+
* a full container had to grow (merge-placement.ts). Empty when the original has no diagram.
|
|
23
|
+
*/
|
|
24
|
+
layout: BpmnPlacementReport;
|
|
18
25
|
}
|
|
19
26
|
export declare function mergeBpmn(originalXml: string, editedXml: string, options?: BpmnMergeOptions): BpmnMergeResult;
|
package/dist/bpmn/merge.js
CHANGED
|
@@ -28,6 +28,9 @@
|
|
|
28
28
|
* children of its sub-process. The document root is merged the same way, so a
|
|
29
29
|
* definition the edit needs (a new `bpmn:error`) lands beside the process.
|
|
30
30
|
*
|
|
31
|
+
* The diagram is the original's. What the edit added is drawn into it, and nothing that
|
|
32
|
+
* was there moves (merge-placement.ts), so a brownfield edit needs no `format`.
|
|
33
|
+
*
|
|
31
34
|
* Without a `baseline` the merge is two-way: take the edited process, re-attach the
|
|
32
35
|
* original diagram by element id. Correct whenever decompile was faithful for every
|
|
33
36
|
* element, and still much better than a bare recompile, which drops layout entirely.
|
|
@@ -65,6 +68,7 @@
|
|
|
65
68
|
* edits that row: the merge changes what the edit changed and nothing else.
|
|
66
69
|
*/
|
|
67
70
|
import { ownEntry } from '../core/own-entry.js';
|
|
71
|
+
import { placeAddedElements } from './merge-placement.js';
|
|
68
72
|
import { findByLocal, parseXmlRanges } from './xml-ranges.js';
|
|
69
73
|
const WIRING = new Set(['incoming', 'outgoing']);
|
|
70
74
|
const isWiring = (range) => WIRING.has(range.local);
|
|
@@ -637,7 +641,45 @@ function twoWay(originalXml, editedXml) {
|
|
|
637
641
|
let merged = originalXml.slice(0, originalProcess.innerStart) + body + originalXml.slice(originalProcess.innerEnd);
|
|
638
642
|
if (removed.length > 0)
|
|
639
643
|
merged = withoutDiagramFor(merged, kept, new Set(removed));
|
|
640
|
-
return {
|
|
644
|
+
return { ...withPlacement(originalXml, withDeclarations(merged, editedXml)), preserved: [], authored, removed };
|
|
645
|
+
}
|
|
646
|
+
/** Each sequence flow's `sourceRef -> targetRef`, by id, anywhere in the document's processes. */
|
|
647
|
+
function flowEnds(xml) {
|
|
648
|
+
const ends = new Map();
|
|
649
|
+
for (const root of parseXmlRanges(xml))
|
|
650
|
+
for (const flow of allByLocal(root.children.filter((c) => c.local === 'process'), 'sequenceFlow'))
|
|
651
|
+
if (flow.id !== undefined)
|
|
652
|
+
ends.set(flow.id, `${flow.attributes.sourceRef ?? ''}->${flow.attributes.targetRef ?? ''}`);
|
|
653
|
+
return ends;
|
|
654
|
+
}
|
|
655
|
+
/** Each element's parent (its process or sub-process), by id, for every element under the document's processes. */
|
|
656
|
+
function scopes(xml) {
|
|
657
|
+
const parents = new Map();
|
|
658
|
+
const visit = (scope) => {
|
|
659
|
+
for (const child of scope.children) {
|
|
660
|
+
if (child.id === undefined)
|
|
661
|
+
continue;
|
|
662
|
+
parents.set(child.id, scope.id ?? '');
|
|
663
|
+
visit(child);
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
for (const root of parseXmlRanges(xml))
|
|
667
|
+
root.children.filter((c) => c.local === 'process').forEach(visit);
|
|
668
|
+
return parents;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Draw what the edit added into the original's diagram (merge-placement.ts): a shape for
|
|
672
|
+
* each new flow node, an edge for each new sequence flow, and a new route for a kept flow
|
|
673
|
+
* whose ends the edit moved.
|
|
674
|
+
*/
|
|
675
|
+
function withPlacement(originalXml, merged) {
|
|
676
|
+
const originalIds = modelIds(originalXml);
|
|
677
|
+
const before = flowEnds(originalXml);
|
|
678
|
+
const rewired = new Set([...flowEnds(merged)].filter(([id, ends]) => before.has(id) && before.get(id) !== ends).map(([id]) => id));
|
|
679
|
+
const scopeBefore = scopes(originalXml);
|
|
680
|
+
const rescoped = new Set([...scopes(merged)].filter(([id, scope]) => scopeBefore.has(id) && scopeBefore.get(id) !== scope).map(([id]) => id));
|
|
681
|
+
const { xml, report } = placeAddedElements(merged, { isAdded: (id) => !originalIds.has(id), rewired, rescoped });
|
|
682
|
+
return { xml, layout: report };
|
|
641
683
|
}
|
|
642
684
|
export function mergeBpmn(originalXml, editedXml, options = {}) {
|
|
643
685
|
processOf(originalXml, 'original');
|
|
@@ -657,5 +699,5 @@ export function mergeBpmn(originalXml, editedXml, options = {}) {
|
|
|
657
699
|
const removed = [...originalIds].filter((id) => !kept.has(id));
|
|
658
700
|
if (removed.length > 0)
|
|
659
701
|
merged = withoutDiagramFor(merged, kept, originalIds);
|
|
660
|
-
return {
|
|
702
|
+
return { ...withPlacement(originalXml, withDeclarations(merged, editedXml)), preserved: ctx.preserved, authored: ctx.authored, removed };
|
|
661
703
|
}
|
package/dist/bpmn/serialize.js
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
*
|
|
12
12
|
* **Semantic-only, no diagram.** BPMN validation is layout-independent, so no
|
|
13
13
|
* `bpmndi:BPMNDiagram` is emitted here; `uip maestro bpmn format` adds geometry
|
|
14
|
-
*
|
|
14
|
+
* to a greenfield file, and a brownfield merge keeps the original's and draws what
|
|
15
|
+
* the edit added (merge-placement.ts).
|
|
15
16
|
*/
|
|
16
17
|
import BpmnModdle from 'bpmn-moddle';
|
|
17
18
|
import { createRequire } from 'node:module';
|
package/dist/check.js
CHANGED
|
@@ -7,7 +7,6 @@ import { checkCookedEscapes, checkFlowExpressions } from './flow-expr-check.js';
|
|
|
7
7
|
import { FLOW_EXPR_DIALECT, checkBindingLabels, checkConnectorLookups as coreCheckConnectorLookups, checkConnectorResources as coreCheckConnectorResources, checkConnectorSchema as coreCheckConnectorSchema, } from './core/connector-checks.js';
|
|
8
8
|
import { nearestName } from './core/edit-distance.js';
|
|
9
9
|
import { escapeRegExp } from './core/escape-regexp.js';
|
|
10
|
-
import { hitlDerivesOutcomeHandles, hitlExitModel, hitlRoutesPerOutcome, outcomeIdOf } from './core/hitl-routing.js';
|
|
11
10
|
import { hasExits } from './core/step-ports.js';
|
|
12
11
|
import { actionTails, armReachesJoin } from './flow-parallel-hitl.js';
|
|
13
12
|
import { FLOW_SCHEMA_VERSIONS } from './format-profile.js';
|
|
@@ -17,7 +16,7 @@ import { VARS_READ_RE } from './core/vars-read.js';
|
|
|
17
16
|
import { FLOW_METADATA_KEYS, unknownMetadataKeys } from './core/flow-metadata.js';
|
|
18
17
|
import { endContentKey } from './flow-end-content.js';
|
|
19
18
|
import { FLOW_NODE_TYPES, FLOW_TRIGGER_TYPES } from './flow-node-registry.js';
|
|
20
|
-
import { stepExits } from './flow-step-exits.js';
|
|
19
|
+
import { stepExits, stepRouting } from './flow-step-exits.js';
|
|
21
20
|
import { stepDeclaredVariables } from './flow-step-variables.js';
|
|
22
21
|
import { plainHttpOnErrorMessage } from './nodes/http/flow/family.js';
|
|
23
22
|
import { resolveVersion, resolveVersionCarried } from './core/nodes/versioned.js';
|
|
@@ -383,10 +382,10 @@ function checkFlow(built, ancestors, opts = {}) {
|
|
|
383
382
|
// the next step with no incoming edge. A `.return()` is an End already, so
|
|
384
383
|
// the outcomes join it. Side exits attach to the task and do not count.
|
|
385
384
|
for (const [i, st] of steps.entries()) {
|
|
386
|
-
if (st.kind !== 'action'
|
|
385
|
+
if (st.kind !== 'action')
|
|
387
386
|
continue;
|
|
388
|
-
const
|
|
389
|
-
if (
|
|
387
|
+
const routing = stepRouting(st.spec, st.options?.version);
|
|
388
|
+
if (routing?.shape !== 'every' || !routing.exits.every((e) => e.endsProcess))
|
|
390
389
|
continue;
|
|
391
390
|
const after = steps.slice(i + 1).find((x) => x.kind !== 'stepToList' && x.kind !== 'stepToRef');
|
|
392
391
|
if (after === undefined || after.kind === 'return')
|
|
@@ -395,7 +394,7 @@ function checkFlow(built, ancestors, opts = {}) {
|
|
|
395
394
|
level: 'error',
|
|
396
395
|
code: 'HITL_UNREACHABLE_AFTER',
|
|
397
396
|
message: `Every outcome of human task "${st.name}" is action: 'End' `
|
|
398
|
-
+ `(${
|
|
397
|
+
+ `(${routing.exits.map((e) => e.value).join(', ')}), so each one ends the run at its own End node, and `
|
|
399
398
|
+ `"${'name' in after ? after.name : after.kind}" after it can never run. Drop action: 'End' from the `
|
|
400
399
|
+ 'outcomes that should continue, or end the path here with .return().',
|
|
401
400
|
step: st.name,
|
|
@@ -458,8 +457,9 @@ function checkFlow(built, ancestors, opts = {}) {
|
|
|
458
457
|
if ((s.kind === 'stepToList' || s.kind === 'stepToRef') && s.port.startsWith('outcome-')) {
|
|
459
458
|
const want = s.port.slice('outcome-'.length);
|
|
460
459
|
const prevSpec = prevAction?.spec;
|
|
461
|
-
|
|
462
|
-
|
|
460
|
+
// Only a type whose exits are outcomes declares how they leave it.
|
|
461
|
+
const routing = prevSpec && 'kind' in prevSpec ? stepRouting(prevSpec, prevAction?.options?.version) : undefined;
|
|
462
|
+
if (!routing) {
|
|
463
463
|
diags.push({
|
|
464
464
|
level: 'error', code: 'HITL_OUTCOME_PORT_MISPLACED', step: prevAction?.name,
|
|
465
465
|
message: `Port "${s.port}" is a human task's per-outcome exit, but the preceding step `
|
|
@@ -467,14 +467,12 @@ function checkFlow(built, ancestors, opts = {}) {
|
|
|
467
467
|
});
|
|
468
468
|
}
|
|
469
469
|
else {
|
|
470
|
-
const model = hitlExitModel(prevSpec.inputs, prevAction?.options?.version);
|
|
471
|
-
const ids = (prevSpec.inputs.outcomes ?? []).map((o, i) => outcomeIdOf(o, i));
|
|
472
470
|
// A task with no per-outcome exits, an id the task does not declare,
|
|
473
471
|
// and a port a task that does not route per outcome already continues
|
|
474
472
|
// on are the serializer's HITL_OUTCOME_PORTS_NONE /
|
|
475
473
|
// HITL_OUTCOME_PORT_UNKNOWN / HITL_OUTCOME_PORTS_OFF (#741). A routed
|
|
476
474
|
// port is recorded for the unrouted-outcome rule.
|
|
477
|
-
if (
|
|
475
|
+
if (routing.shape === 'routed' && routing.exits.some((e) => e.port === s.port) && prevAction) {
|
|
478
476
|
let routed = hitlOutcomeRouted.get(prevAction.name);
|
|
479
477
|
if (!routed)
|
|
480
478
|
hitlOutcomeRouted.set(prevAction.name, routed = new Set());
|
|
@@ -511,38 +509,18 @@ function checkFlow(built, ancestors, opts = {}) {
|
|
|
511
509
|
// `.stepSwitch` routes its exits as ARMS, so the `.stepToList` bookkeeping
|
|
512
510
|
// would report every one of them unrouted. STEP_SWITCH_EXIT_UNROUTED is
|
|
513
511
|
// that step's version of the same question.
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
hitlOutcomeSteps.set(s.name,
|
|
517
|
-
id:
|
|
518
|
-
endsProcess:
|
|
512
|
+
const routing = stepRouting(s.spec, s.options?.version);
|
|
513
|
+
if (s0.kind !== 'stepSwitch' && routing?.shape === 'routed') {
|
|
514
|
+
hitlOutcomeSteps.set(s.name, routing.exits.map((e) => ({
|
|
515
|
+
id: e.port.slice('outcome-'.length),
|
|
516
|
+
endsProcess: e.endsProcess === true,
|
|
519
517
|
})));
|
|
520
518
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
const allEnd = outcomes.length > 0
|
|
527
|
-
&& outcomes.every((o) => typeof o !== 'string' && o?.action === 'End');
|
|
528
|
-
// `.stepSwitch` routes every outcome as an arm, so it never belongs here.
|
|
529
|
-
// Nor does a `legacyCompleted` task: only its primary outcome continues,
|
|
530
|
-
// so no downstream switch can reach the others, and HITL_LEGACY_COMPLETED
|
|
531
|
-
// already says so.
|
|
532
|
-
if (outcomes.length > 1 && !allEnd && s0.kind !== 'stepSwitch'
|
|
533
|
-
&& s.spec.inputs?.legacyCompleted !== true
|
|
534
|
-
&& !hitlRoutesPerOutcome(s.spec.inputs, s.options?.version)) {
|
|
535
|
-
hitlChoiceNoPorts.set(s.name, {
|
|
536
|
-
names: outcomes.map((o) => String((typeof o === 'string' ? o : o?.name) ?? '').trim()),
|
|
537
|
-
ids: outcomes.map((o, i) => outcomeIdOf(o, i)),
|
|
538
|
-
ends: outcomes.filter((o) => typeof o !== 'string' && o?.action === 'End')
|
|
539
|
-
.map((o) => String(o.name ?? '').trim()),
|
|
540
|
-
variant: s.spec.inputs?.variant,
|
|
541
|
-
pinned: s.options?.version,
|
|
542
|
-
portsOff: s.spec.inputs?.outcomePorts === false,
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
}
|
|
519
|
+
// A choice the task's exits leave unsplit waits for the expressions
|
|
520
|
+
// (HITL_OUTCOMES_UNREACHABLE below); `.stepSwitch` routes every outcome
|
|
521
|
+
// as an arm, so it never belongs there.
|
|
522
|
+
if (routing?.unsplit && s0.kind !== 'stepSwitch')
|
|
523
|
+
hitlChoiceNoPorts.set(s.name, routing.unsplit);
|
|
546
524
|
// The process family checks the step itself; the flow-level fire-and-forget
|
|
547
525
|
// read rule below needs to know which steps dispatch without waiting.
|
|
548
526
|
if (s.spec.kind === 'agenticProcess')
|
|
@@ -2207,14 +2185,13 @@ function reportUnreachableHitlOutcomes(choices, exprs, diags) {
|
|
|
2207
2185
|
for (const m of js.matchAll(/\$vars\.([A-Za-z0-9_]+)\s*\[/g))
|
|
2208
2186
|
readsOutcome.add(m[1]);
|
|
2209
2187
|
}
|
|
2210
|
-
for (const [step, { names, ids, ends,
|
|
2188
|
+
for (const [step, { names, ids, ends, canRoute, kept, portsOff }] of choices) {
|
|
2211
2189
|
if (readsOutcome.has(step))
|
|
2212
2190
|
continue;
|
|
2213
|
-
//
|
|
2214
|
-
//
|
|
2215
|
-
//
|
|
2216
|
-
|
|
2217
|
-
// On those two, an `action: 'End'` outcome gets its own End node, so the
|
|
2191
|
+
// A task that draws a handle per outcome can route it — `.stepSwitch`, or
|
|
2192
|
+
// `outcomePorts: true` (a pin keeps its version). An app-backed variant
|
|
2193
|
+
// cannot: the Action read is its only remedy (`canRoute`).
|
|
2194
|
+
// On a task that can, an `action: 'End'` outcome gets its own End node, so the
|
|
2218
2195
|
// graph already tells it apart. Only the outcomes that CONTINUE share a step.
|
|
2219
2196
|
const continuing = canRoute ? names.filter((n) => !ends.includes(n)) : names;
|
|
2220
2197
|
if (continuing.length < 2)
|
|
@@ -2222,13 +2199,6 @@ function reportUnreachableHitlOutcomes(choices, exprs, diags) {
|
|
|
2222
2199
|
const endNote = canRoute && ends.length > 0
|
|
2223
2200
|
? ` (${ends.join(', ')} ${ends.length === 1 ? 'is' : 'are'} action: 'End' and end${ends.length === 1 ? 's' : ''} the run instead)`
|
|
2224
2201
|
: '';
|
|
2225
|
-
const kept = !canRoute
|
|
2226
|
-
? `The "${variant}" variant reads its outcomes from its app and leaves on its single 'completed' exit`
|
|
2227
|
-
: portsOff
|
|
2228
|
-
? `outcomePorts: false continues every outcome to the next step`
|
|
2229
|
-
: variant === 'quick-form'
|
|
2230
|
-
? `A quick-form task continues every outcome to the next step unless it routes them`
|
|
2231
|
-
: `{ version: '${pinned}' } without outcomePorts: true continues every outcome to the next step`;
|
|
2232
2202
|
diags.push({
|
|
2233
2203
|
level: 'warning', code: 'HITL_OUTCOMES_UNREACHABLE', step,
|
|
2234
2204
|
message: `Human task "${step}" declares ${names.length} outcomes (${names.join(', ')}), but nothing `
|
|
@@ -36,6 +36,43 @@ export interface DeclaredExit {
|
|
|
36
36
|
/** The fall-through exit — HTTP's `default`. Last, and optional in an arm list. */
|
|
37
37
|
isDefault?: boolean;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* How a step's author-named exits LEAVE it, for the flow-level routing rules
|
|
41
|
+
* `check` keeps (an outcome no route takes, a step after exits that all end the
|
|
42
|
+
* run, a choice nothing downstream tells apart): a human task's outcomes. A
|
|
43
|
+
* registered type declares it (`FlowNodeType.routing`); a type that has no such
|
|
44
|
+
* exits declares none.
|
|
45
|
+
*/
|
|
46
|
+
export type ExitRouting = {
|
|
47
|
+
/**
|
|
48
|
+
* `single`: one forward exit whatever the outcomes (`exits` is empty);
|
|
49
|
+
* `every`: every exit continues to the next step; `routed`: the first exit
|
|
50
|
+
* continues the main path and the author routes the rest.
|
|
51
|
+
*/
|
|
52
|
+
readonly shape: 'single' | 'every' | 'routed';
|
|
53
|
+
readonly exits: readonly DeclaredExit[];
|
|
54
|
+
/**
|
|
55
|
+
* Set when the step offers a choice of two or more outcomes that its exits
|
|
56
|
+
* do not tell apart, by the author's choice: what HITL_OUTCOMES_UNREACHABLE
|
|
57
|
+
* reports when nothing downstream reads the outcome either.
|
|
58
|
+
*/
|
|
59
|
+
readonly unsplit?: UnsplitChoice;
|
|
60
|
+
};
|
|
61
|
+
/** A choice the exits do not split: the outcomes, and the remedies the step can take. */
|
|
62
|
+
export interface UnsplitChoice {
|
|
63
|
+
/** Every outcome's name, trimmed, in order. */
|
|
64
|
+
readonly names: readonly string[];
|
|
65
|
+
/** Every outcome's id, in order (its port is `outcome-<id>`). */
|
|
66
|
+
readonly ids: readonly string[];
|
|
67
|
+
/** The names of the outcomes that end the run. */
|
|
68
|
+
readonly ends: readonly string[];
|
|
69
|
+
/** Whether the node draws a handle per outcome, so each can get its own route. */
|
|
70
|
+
readonly canRoute: boolean;
|
|
71
|
+
/** Why the outcomes share an exit, as a sentence start ("outcomePorts: false continues every outcome to the next step"). */
|
|
72
|
+
readonly kept: string;
|
|
73
|
+
/** The author turned routing off (`outcomePorts: false`), so dropping that is the remedy. */
|
|
74
|
+
readonly portsOff: boolean;
|
|
75
|
+
}
|
|
39
76
|
/** Why a spec has no routable fan-out, phrased for a diagnostic. */
|
|
40
77
|
export interface NoExits {
|
|
41
78
|
reason: string;
|
package/dist/decompile.js
CHANGED
|
@@ -44,7 +44,6 @@ import { FLOW_TYPE_NAMES, nonFlowTypeReplacement, runtimeEquivalentFlowType } fr
|
|
|
44
44
|
import { outputBackingGlobal, outputBackingName } from './flow-output-backing.js';
|
|
45
45
|
import { mapJsCode } from './core/js-code-spans.js';
|
|
46
46
|
import { VARS_READ_RE } from './core/vars-read.js';
|
|
47
|
-
import { OUTCOME_HANDLE_NODE_TYPES } from './core/hitl-routing.js';
|
|
48
47
|
import { contributionPort, forwardFanOut } from './core/definition-handles.js';
|
|
49
48
|
import { STICKY_NOTE_TYPE } from './core/definitionless-node-types.js';
|
|
50
49
|
import { bindingValueRows, referencedBindingNames } from './core/contribution-bindings.js';
|
|
@@ -310,7 +309,6 @@ function optsArgWith(node, ctx, extra) {
|
|
|
310
309
|
}
|
|
311
310
|
// ─── Node type constants (mirror of serialize.ts NODE_TYPE) ───────────────────
|
|
312
311
|
const T = {
|
|
313
|
-
hitl: 'uipath.human-in-the-loop',
|
|
314
312
|
decision: 'core.logic.decision',
|
|
315
313
|
switch: 'core.logic.switch',
|
|
316
314
|
merge: 'core.logic.merge',
|
|
@@ -643,12 +641,7 @@ class Graph {
|
|
|
643
641
|
*/
|
|
644
642
|
primaryOutcomePort(id) {
|
|
645
643
|
const n = this.byId.get(id);
|
|
646
|
-
|
|
647
|
-
if (!type.startsWith('uipath.human-in-the-loop'))
|
|
648
|
-
return undefined;
|
|
649
|
-
const outcomes = (n?.inputs?.schema?.outcomes ?? []);
|
|
650
|
-
const first = outcomes[0]?.id;
|
|
651
|
-
return typeof first === 'string' && first !== '' ? `outcome-${first}` : undefined;
|
|
644
|
+
return n ? savedExitsOf(n)?.primary : undefined;
|
|
652
645
|
}
|
|
653
646
|
/**
|
|
654
647
|
* A base or quick-form human task whose EVERY outcome is wired, all to ONE
|
|
@@ -664,16 +657,14 @@ class Graph {
|
|
|
664
657
|
*/
|
|
665
658
|
convergedFanOut(id) {
|
|
666
659
|
const n = this.byId.get(id);
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
const ids = outcomeIdsOfNode(n);
|
|
670
|
-
if (ids.length === 0)
|
|
660
|
+
const fanOut = n ? savedExitsOf(n)?.fanOut : undefined;
|
|
661
|
+
if (fanOut === undefined)
|
|
671
662
|
return false;
|
|
672
663
|
const exits = this.outEdges(id).filter((e) => e.sourcePort !== 'error' && !ARTIFACT_PORTS.has(e.sourcePort));
|
|
673
|
-
if (exits.length !==
|
|
664
|
+
if (exits.length !== fanOut.length)
|
|
674
665
|
return false;
|
|
675
666
|
const ports = new Set(exits.map((e) => e.sourcePort));
|
|
676
|
-
if (!
|
|
667
|
+
if (!fanOut.every((p) => ports.has(p)))
|
|
677
668
|
return false;
|
|
678
669
|
return new Set(exits.map((e) => e.targetNodeId)).size === 1;
|
|
679
670
|
}
|
|
@@ -2429,39 +2420,30 @@ function portArmExits(node, ctx) {
|
|
|
2429
2420
|
return undefined;
|
|
2430
2421
|
return declaredExitsOfNode(node);
|
|
2431
2422
|
}
|
|
2432
|
-
/**
|
|
2433
|
-
function
|
|
2434
|
-
|
|
2435
|
-
return node.type === T.hitl && (version === '1.1' || version === '1.2');
|
|
2436
|
-
}
|
|
2437
|
-
/** The outcome ids in a human task's `inputs.schema.outcomes`. */
|
|
2438
|
-
function outcomeIdsOfNode(node) {
|
|
2439
|
-
const outcomes = (node.inputs?.schema?.outcomes ?? []);
|
|
2440
|
-
return outcomes.map((o) => o?.id).filter((id) => typeof id === 'string' && id !== '');
|
|
2423
|
+
/** The exits a saved node of a registered type leaves on, when its type reads them off the node (`savedExits`). */
|
|
2424
|
+
function savedExitsOf(node) {
|
|
2425
|
+
return registeredImpl(node)?.savedExits?.(node);
|
|
2441
2426
|
}
|
|
2442
2427
|
/**
|
|
2443
2428
|
* The exits a node declares, read back off the EMITTED artifact rather than off
|
|
2444
|
-
* an authored spec — `
|
|
2445
|
-
* task
|
|
2446
|
-
* every version), and a registered type's own `exits` over
|
|
2447
|
-
* recovers (an HTTP call's `inputs.branches` plus `default`). The authoring-side
|
|
2429
|
+
* an authored spec — a registered type's `savedExits` (a base or quick-form human
|
|
2430
|
+
* task's `inputs.schema.outcomes`: the product draws one `outcome-<id>` handle per
|
|
2431
|
+
* outcome on both, at every version), and a registered type's own `exits` over
|
|
2432
|
+
* the spec its lift recovers (an HTTP call's `inputs.branches` plus `default`). The authoring-side
|
|
2448
2433
|
* twin is `stepExits` in `flow-step-exits.ts`.
|
|
2449
2434
|
*/
|
|
2450
2435
|
function declaredExitsOfNode(node) {
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
const outcomes = (inputs.schema?.outcomes ?? []);
|
|
2456
|
-
if (outcomes.length === 0)
|
|
2457
|
-
return undefined;
|
|
2458
|
-
return outcomes.map((o) => ({ value: String(o?.name ?? ''), port: `outcome-${o?.id ?? ''}` }));
|
|
2459
|
-
}
|
|
2460
|
-
// A registered type that declares exits answers from its own spec, lifted off
|
|
2461
|
-
// this node; one that declares none is not lifted at all (this runs per edge).
|
|
2436
|
+
// A registered type that reads its exits off the saved node answers from the
|
|
2437
|
+
// node (a human task's `inputs.schema.outcomes`); one that declares exits
|
|
2438
|
+
// answers from its own spec, lifted off this node; one that declares neither
|
|
2439
|
+
// is not lifted at all (this runs per edge).
|
|
2462
2440
|
const impl = registeredImpl(node);
|
|
2463
2441
|
if (!impl)
|
|
2464
2442
|
return rawNodeExits(node);
|
|
2443
|
+
if (impl.savedExits) {
|
|
2444
|
+
const arms = impl.savedExits(node).arms;
|
|
2445
|
+
return arms?.map((a) => ({ value: a.value, port: a.port }));
|
|
2446
|
+
}
|
|
2465
2447
|
if (!impl.exits)
|
|
2466
2448
|
return undefined;
|
|
2467
2449
|
const lifted = liftRegistered(node, impl);
|
package/dist/flow-node-type.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import type { DiagnosticCatalog, NodeFamily, Placement } from './core/nodes/fami
|
|
|
16
16
|
import type { DefinitionReference, NodeContribution } from './core/node-classes.js';
|
|
17
17
|
import type { CheckOpts } from './check.js';
|
|
18
18
|
import type { SerializeOpts } from './serialize.js';
|
|
19
|
-
import type { DeclaredExit, NoExits } from './core/step-ports.js';
|
|
19
|
+
import type { DeclaredExit, ExitRouting, NoExits } from './core/step-ports.js';
|
|
20
20
|
import type { EventEmitEnv } from './core/event-subscription.js';
|
|
21
21
|
/**
|
|
22
22
|
* What a Flow node type's `serialize` returns: the node's type-owned fields.
|
|
@@ -554,6 +554,20 @@ export interface FlowNodeType<Spec> extends NodeType<Spec, FlowNodeContribution,
|
|
|
554
554
|
* one of these (`.onError()` routes it).
|
|
555
555
|
*/
|
|
556
556
|
exits?(spec: Spec, pinnedVersion?: string): DeclaredExit[] | NoExits;
|
|
557
|
+
/**
|
|
558
|
+
* How the step's author-named exits leave it, which `check`'s flow-level
|
|
559
|
+
* routing rules read (§13 of docs/NODE_TYPE_ARCHITECTURE_DESIGN.md keeps those
|
|
560
|
+
* rules in the artifact, on facts from the types): a human task's outcomes.
|
|
561
|
+
* `pinnedVersion` is the author's `{ version }`, as for `exits`. Omitted: the
|
|
562
|
+
* type has no such exits, and an `outcome-<id>` port after it is misplaced.
|
|
563
|
+
*/
|
|
564
|
+
routing?(spec: Spec, pinnedVersion?: string): ExitRouting;
|
|
565
|
+
/**
|
|
566
|
+
* The exits a SAVED node of this type leaves on, read off the node itself
|
|
567
|
+
* rather than a lifted spec, for decompile's graph reading. Omitted: the type's
|
|
568
|
+
* node has no such exits, and a fully wired one forks over its `exits`.
|
|
569
|
+
*/
|
|
570
|
+
savedExits?(node: unknown): FlowSavedExits;
|
|
557
571
|
/**
|
|
558
572
|
* The flow variables a step of this type DECLARES by running: names a later
|
|
559
573
|
* `$vars.<name>` read resolves to that are neither a `.var()` nor a step
|
|
@@ -597,6 +611,21 @@ export interface FlowNodeType<Spec> extends NodeType<Spec, FlowNodeContribution,
|
|
|
597
611
|
version?: string;
|
|
598
612
|
} | undefined;
|
|
599
613
|
}
|
|
614
|
+
/** What decompile's graph reads off a saved node's exits (`FlowNodeType.savedExits`). */
|
|
615
|
+
export interface FlowSavedExits {
|
|
616
|
+
/** The exit the main path continues on; its siblings are side paths. */
|
|
617
|
+
readonly primary?: string;
|
|
618
|
+
/** The exits a fully wired node forks over, as `.stepSwitch` arms: each one's value and port. */
|
|
619
|
+
readonly arms?: ReadonlyArray<{
|
|
620
|
+
readonly value: string;
|
|
621
|
+
readonly port: string;
|
|
622
|
+
}>;
|
|
623
|
+
/**
|
|
624
|
+
* The ports a converged fan-out wires, every one to one target, which reads
|
|
625
|
+
* back as a single `.step()`. Omitted: the node is never one.
|
|
626
|
+
*/
|
|
627
|
+
readonly fanOut?: readonly string[];
|
|
628
|
+
}
|
|
600
629
|
/** A Flow node type with several versions. */
|
|
601
630
|
export type FlowVersionedNodeType<Spec> = VersionedNodeType<Spec, FlowNodeContribution, FlowContexts, FlowNodeType<Spec>>;
|
|
602
631
|
/** A Flow node family. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DeclaredExit, type NoExits } from './core/step-ports.js';
|
|
1
|
+
import { type DeclaredExit, type ExitRouting, type NoExits } from './core/step-ports.js';
|
|
2
2
|
/**
|
|
3
3
|
* The author-declared exits of a step's spec: a registered type's own `exits`,
|
|
4
4
|
* at the version the step resolves to (its pin, else the type's choice; an
|
|
@@ -10,3 +10,12 @@ export declare function stepExits(spec: {
|
|
|
10
10
|
kind?: unknown;
|
|
11
11
|
inputs?: unknown;
|
|
12
12
|
} | undefined, pinnedVersion?: string): DeclaredExit[] | NoExits;
|
|
13
|
+
/**
|
|
14
|
+
* How a step's author-named exits leave it (`FlowNodeType.routing`), at the
|
|
15
|
+
* version the step resolves to, as for `stepExits`: what check's flow-level
|
|
16
|
+
* routing rules read. `undefined` when the step's type declares no such exits.
|
|
17
|
+
*/
|
|
18
|
+
export declare function stepRouting(spec: {
|
|
19
|
+
kind?: unknown;
|
|
20
|
+
inputs?: unknown;
|
|
21
|
+
} | undefined, pinnedVersion?: string): ExitRouting | undefined;
|
package/dist/flow-step-exits.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The exits the author declared on a step — what `.stepSwitch()` routes over and
|
|
3
3
|
* a `.stepToList('<port>')` names — answered by the step's node type when its kind
|
|
4
4
|
* is registered (`FlowNodeType.exits`), else by `core/step-ports.ts` for a kind
|
|
5
|
-
* not yet ported. A module of its own so a test that swaps the registry
|
|
5
|
+
* not yet ported; and how they leave the step (`FlowNodeType.routing`). A module of its own so a test that swaps the registry
|
|
6
6
|
* (`vi.mock('./flow-node-registry.js')`) swaps what this asks too.
|
|
7
7
|
*/
|
|
8
8
|
import { resolveVersion } from './core/nodes/versioned.js';
|
|
@@ -21,15 +21,27 @@ export function stepExits(spec, pinnedVersion) {
|
|
|
21
21
|
const raw = rawNodeExits(spec);
|
|
22
22
|
if (raw !== undefined)
|
|
23
23
|
return raw;
|
|
24
|
+
const impl = resolvedImpl(spec, pinnedVersion, 'exits');
|
|
25
|
+
return impl?.exits?.(spec, pinnedVersion) ?? declaredExits(spec);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* How a step's author-named exits leave it (`FlowNodeType.routing`), at the
|
|
29
|
+
* version the step resolves to, as for `stepExits`: what check's flow-level
|
|
30
|
+
* routing rules read. `undefined` when the step's type declares no such exits.
|
|
31
|
+
*/
|
|
32
|
+
export function stepRouting(spec, pinnedVersion) {
|
|
33
|
+
const impl = resolvedImpl(spec, pinnedVersion, 'routing');
|
|
34
|
+
return impl?.routing?.(spec, pinnedVersion);
|
|
35
|
+
}
|
|
36
|
+
/** The step's registered type at the version it resolves to; an unregistered pin falls back to the type's choice. */
|
|
37
|
+
function resolvedImpl(spec, pinnedVersion, what) {
|
|
24
38
|
const entry = typeof spec?.kind === 'string' ? FLOW_NODE_TYPES.byKind(spec.kind, spec) : undefined;
|
|
25
39
|
if (!entry)
|
|
26
|
-
return
|
|
27
|
-
let impl;
|
|
40
|
+
return undefined;
|
|
28
41
|
try {
|
|
29
|
-
|
|
42
|
+
return resolveVersion(entry.type, spec, pinnedVersion, what);
|
|
30
43
|
}
|
|
31
44
|
catch {
|
|
32
|
-
|
|
45
|
+
return resolveVersion(entry.type, spec, undefined, what);
|
|
33
46
|
}
|
|
34
|
-
return impl.exits?.(spec, pinnedVersion) ?? declaredExits(spec);
|
|
35
47
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import { Expr, toExpr } from '../../../core/expr.js';
|
|
16
16
|
import { formFieldJsonSchema, formFieldRowLoss, formFieldRowLossMessage, formFieldSettingsSource, formFieldSettingsWire, formFieldVariableName, liftFormFieldSettings, sourceFormFieldType, wireFormFieldType, } from '../../../core/form-field-type.js';
|
|
17
17
|
import { isAnswerField } from '../../../core/hitl-answers.js';
|
|
18
|
-
import { OUTCOME_HANDLE_NODE_TYPES, hitlExitModel, outcomeIdOf, outcomeSlug } from '../../../core/hitl-routing.js';
|
|
18
|
+
import { OUTCOME_HANDLE_NODE_TYPES, hitlDerivesOutcomeHandles, hitlExitModel, outcomeIdOf, outcomeSlug } from '../../../core/hitl-routing.js';
|
|
19
19
|
import { jsonClone } from '../../../core/json-clone.js';
|
|
20
20
|
import { nearestName } from '../../../core/edit-distance.js';
|
|
21
21
|
import { schemaId } from '../../../core/stable-id.js';
|
|
@@ -531,6 +531,79 @@ function hitlExits({ inputs }, pinnedVersion) {
|
|
|
531
531
|
...(e.endsProcess ? { endsProcess: true } : {}),
|
|
532
532
|
}));
|
|
533
533
|
}
|
|
534
|
+
/**
|
|
535
|
+
* How the task's outcomes leave it, for check's flow-level routing rules: the
|
|
536
|
+
* same model its tails and exits come from, and the choice it leaves unsplit.
|
|
537
|
+
*/
|
|
538
|
+
function hitlRouting({ inputs }, pinnedVersion) {
|
|
539
|
+
const model = hitlExitModel(inputs, pinnedVersion);
|
|
540
|
+
const exits = model.shape === 'placeholder' ? [] : model.exits.map((e) => ({
|
|
541
|
+
value: e.value,
|
|
542
|
+
port: e.port,
|
|
543
|
+
...(e.endsProcess ? { endsProcess: true } : {}),
|
|
544
|
+
}));
|
|
545
|
+
const shape = model.shape === 'placeholder' ? 'single' : model.shape === 'every-outcome' ? 'every' : 'routed';
|
|
546
|
+
// More than one outcome infers per-outcome routing on the base node, so a
|
|
547
|
+
// choice that reaches here unsplit was chosen — by a variant, a pinned
|
|
548
|
+
// version, or `outcomePorts: false` — and WHICH decides what the remedy can
|
|
549
|
+
// be. A task whose every outcome ends has nothing downstream to tell apart,
|
|
550
|
+
// and a `legacyCompleted` one is HITL_LEGACY_COMPLETED's.
|
|
551
|
+
const outcomes = inputs?.outcomes ?? [];
|
|
552
|
+
const allEnd = outcomes.length > 0 && outcomes.every((o) => typeof o !== 'string' && o?.action === 'End');
|
|
553
|
+
if (outcomes.length <= 1 || allEnd || inputs?.legacyCompleted === true || shape === 'routed')
|
|
554
|
+
return { shape, exits };
|
|
555
|
+
const variant = inputs?.variant;
|
|
556
|
+
const canRoute = hitlDerivesOutcomeHandles(variant);
|
|
557
|
+
const portsOff = inputs?.outcomePorts === false;
|
|
558
|
+
const kept = !canRoute
|
|
559
|
+
? `The "${variant}" variant reads its outcomes from its app and leaves on its single 'completed' exit`
|
|
560
|
+
: portsOff
|
|
561
|
+
? `outcomePorts: false continues every outcome to the next step`
|
|
562
|
+
: variant === 'quick-form'
|
|
563
|
+
? `A quick-form task continues every outcome to the next step unless it routes them`
|
|
564
|
+
: `{ version: '${pinnedVersion}' } without outcomePorts: true continues every outcome to the next step`;
|
|
565
|
+
return {
|
|
566
|
+
shape,
|
|
567
|
+
exits,
|
|
568
|
+
unsplit: {
|
|
569
|
+
names: outcomes.map((o) => String((typeof o === 'string' ? o : o?.name) ?? '').trim()),
|
|
570
|
+
ids: outcomes.map((o, i) => outcomeIdOf(o, i)),
|
|
571
|
+
ends: outcomes.filter((o) => typeof o !== 'string' && o?.action === 'End')
|
|
572
|
+
.map((o) => String(o.name ?? '').trim()),
|
|
573
|
+
canRoute,
|
|
574
|
+
kept,
|
|
575
|
+
portsOff,
|
|
576
|
+
},
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* The exits a saved task leaves on, for decompile's graph: its first outcome is
|
|
581
|
+
* the primary exit on every variant; the base node and quick-form draw a handle
|
|
582
|
+
* per outcome, so a fully wired one forks over them; and those two read back a
|
|
583
|
+
* converged fan-out, except the base node on its 1.1/1.2 definition, where the
|
|
584
|
+
* VERSION selects per-outcome routing (it round-trips as a `.stepSwitch`).
|
|
585
|
+
*/
|
|
586
|
+
function hitlSavedExits(node, typeName) {
|
|
587
|
+
const n = node;
|
|
588
|
+
const outcomes = n.inputs?.schema?.outcomes;
|
|
589
|
+
const list = (Array.isArray(outcomes) ? outcomes : []);
|
|
590
|
+
const first = list[0]?.id;
|
|
591
|
+
const primary = typeof first === 'string' && first !== '' ? `outcome-${first}` : undefined;
|
|
592
|
+
if (!OUTCOME_HANDLE_NODE_TYPES.has(typeName))
|
|
593
|
+
return primary !== undefined ? { primary } : {};
|
|
594
|
+
const arms = list.length > 0
|
|
595
|
+
? list.map((o) => ({ value: String(o?.name ?? ''), port: `outcome-${o?.id ?? ''}` }))
|
|
596
|
+
: undefined;
|
|
597
|
+
const version = String(n.typeVersion ?? '');
|
|
598
|
+
const versionRoutes = typeName === BASE && (version === '1.1' || version === '1.2');
|
|
599
|
+
const ids = outcomeIdsOfNode(n);
|
|
600
|
+
const fanOut = !versionRoutes && ids.length > 0 ? ids.map((i) => `outcome-${i}`) : undefined;
|
|
601
|
+
return {
|
|
602
|
+
...(primary !== undefined ? { primary } : {}),
|
|
603
|
+
...(arms !== undefined ? { arms } : {}),
|
|
604
|
+
...(fanOut !== undefined ? { fanOut } : {}),
|
|
605
|
+
};
|
|
606
|
+
}
|
|
534
607
|
/** The outcome ids in a human task's `inputs.schema.outcomes`. */
|
|
535
608
|
function outcomeIdsOfNode(node) {
|
|
536
609
|
const outcomes = (node.inputs?.schema?.outcomes ?? []);
|
|
@@ -867,6 +940,8 @@ function hitlAt(typeName, version, factory) {
|
|
|
867
940
|
.map((f) => (f?.direction === 'output' ? (f.variable ?? f.id) : undefined))
|
|
868
941
|
.filter((v) => typeof v === 'string' && v !== ''),
|
|
869
942
|
exits: hitlExits,
|
|
943
|
+
routing: hitlRouting,
|
|
944
|
+
savedExits: (node) => hitlSavedExits(node, typeName),
|
|
870
945
|
// The base node and quick-form draw one `outcome-<id>` handle per outcome,
|
|
871
946
|
// whatever the version; their definitions declare only `completed`.
|
|
872
947
|
derivesPort: ({ inputs }, port) => OUTCOME_HANDLE_NODE_TYPES.has(typeName)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.87.0",
|
|
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",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"@types/node": "^22.7.0",
|
|
111
111
|
"esbuild": "^0.28.1"
|
|
112
112
|
},
|
|
113
|
-
"gitref": "
|
|
113
|
+
"gitref": "a1d69f012ec03f34c177c6b1d358b21d5ea2b09c"
|
|
114
114
|
}
|