@uipath/maestro-builder-sdk 6.85.3 → 6.85.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bpmn/check.js +121 -27
- package/dist/bpmn/decompile.js +62 -8
- package/dist/core/carried-definitions.d.ts +2 -0
- package/dist/core/carried-definitions.js +1 -1
- package/dist/core/event-subscription.d.ts +3 -1
- package/dist/core/event-subscription.js +4 -2
- package/dist/core/expr-check.d.ts +2 -1
- package/dist/core/expr-check.js +51 -5
- package/dist/core/shared-definition.d.ts +11 -0
- package/dist/core/shared-definition.js +85 -0
- package/dist/decompile.js +11 -2
- package/dist/nodes/connector/flow/event-wait.js +39 -8
- package/dist/nodes/hitl/flow/check.js +3 -3
- package/dist/nodes/hitl/flow/node-type.js +26 -11
- package/dist/serialize.js +20 -1
- package/package.json +2 -2
package/dist/bpmn/check.js
CHANGED
|
@@ -53,11 +53,27 @@ const MIN_TASK_TIMER_MINUTES = 15;
|
|
|
53
53
|
const MAX_TASK_TIMER_MINUTES = 90 * 24 * 60;
|
|
54
54
|
const GATEWAY_KINDS = new Set(['exclusiveGateway', 'parallelGateway', 'inclusiveGateway', 'eventBasedGateway']);
|
|
55
55
|
/**
|
|
56
|
-
* What a boundary event may attach to.
|
|
57
|
-
*
|
|
58
|
-
*
|
|
56
|
+
* What a boundary event may attach to: every activity kind. Tied to the node union
|
|
57
|
+
* rather than kept by hand. The `satisfies` clause fails the build when an activity
|
|
58
|
+
* arm is added to `BpmnNode` without an entry here, and when an entry names a kind
|
|
59
|
+
* that is not an activity. The hand-kept set this replaced missed `plainTask`, so
|
|
60
|
+
* check refused a timer on a plain `bpmn:task` / `bpmn:userTask` that validate
|
|
61
|
+
* accepts (#1678). `connector` is here because it serializes to a `bpmn:sendTask`,
|
|
62
|
+
* and catching a connector's failure is the commonest error-handling shape there is.
|
|
59
63
|
*/
|
|
60
|
-
const ACTIVITY_KINDS =
|
|
64
|
+
const ACTIVITY_KINDS = {
|
|
65
|
+
scriptTask: true,
|
|
66
|
+
task: true,
|
|
67
|
+
connector: true,
|
|
68
|
+
typed: true,
|
|
69
|
+
connectorEvent: true,
|
|
70
|
+
externalTask: true,
|
|
71
|
+
plainTask: true,
|
|
72
|
+
subProcess: true,
|
|
73
|
+
};
|
|
74
|
+
function isActivityNode(n) {
|
|
75
|
+
return Object.hasOwn(ACTIVITY_KINDS, n.kind);
|
|
76
|
+
}
|
|
61
77
|
/**
|
|
62
78
|
* Validate a built process.
|
|
63
79
|
*
|
|
@@ -797,7 +813,14 @@ function checkVariableOrder(built, diags) {
|
|
|
797
813
|
* A variable scoped with `elementId` must name an element that exists.
|
|
798
814
|
*
|
|
799
815
|
* The runtime resolves the scope by id and has nothing to fall back on, so a typo
|
|
800
|
-
* makes the variable unreachable
|
|
816
|
+
* makes the variable unreachable. Unreachable matters only if something READS it,
|
|
817
|
+
* and the level follows that, as the platform's own rule does
|
|
818
|
+
* (`unresolvableDeclaration` in `uip maestro bpmn validate`, VARIABLE_ELEMENT_ID_NOT_FOUND):
|
|
819
|
+
* an ERROR when some expression reads `vars.<id>` (that read fails at run time with
|
|
820
|
+
* "Variable 'vars.<id>' does not exist"), a WARNING when nothing does. The second
|
|
821
|
+
* shape is common in real exports — the canvas keeps a deleted node's output
|
|
822
|
+
* variables — and an error there refused processes the platform accepts and runs
|
|
823
|
+
* (#1679: 17 of the brownfield fuzzer's stage-A seeds).
|
|
801
824
|
*/
|
|
802
825
|
function checkScopedVars(built, diags) {
|
|
803
826
|
const ids = new Set();
|
|
@@ -824,16 +847,58 @@ function checkScopedVars(built, diags) {
|
|
|
824
847
|
}
|
|
825
848
|
};
|
|
826
849
|
collect(built.nodes);
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
850
|
+
const dangling = allVars.filter((v) => typeof v.elementId === 'string' && !ids.has(v.elementId));
|
|
851
|
+
if (!dangling.length)
|
|
852
|
+
return;
|
|
853
|
+
const reads = variableReads(built);
|
|
854
|
+
for (const v of dangling) {
|
|
855
|
+
const read = reads.has(v.id);
|
|
856
|
+
diags.push({
|
|
857
|
+
level: read ? 'error' : 'warning',
|
|
858
|
+
code: 'SCOPED_VAR_UNKNOWN_ELEMENT',
|
|
859
|
+
message: read
|
|
860
|
+
? `Variable "${v.id}" is scoped to element "${v.elementId}", which does not exist, so every \`vars.${v.id}\` read fails at run time.`
|
|
861
|
+
: `Variable "${v.id}" is scoped to element "${v.elementId}", which does not exist. Nothing reads it, so it is unreachable but harmless; scope it to the process or remove it.`,
|
|
862
|
+
where: v.id,
|
|
863
|
+
});
|
|
835
864
|
}
|
|
836
865
|
}
|
|
866
|
+
/** `vars.<id>` and `vars["<id>"]`, the platform's own pattern for a variable read. */
|
|
867
|
+
const VARIABLE_READ = /vars(?:\.([A-Za-z_$][\w$]*)|\[\s*["']([^"']+)["']\s*\])/g;
|
|
868
|
+
/** Fields that name or label something rather than hold an expression or a body. */
|
|
869
|
+
const NOT_EXPRESSION_KEYS = new Set(['id', 'name', 'elementId', 'documentation']);
|
|
870
|
+
/**
|
|
871
|
+
* Every variable id some string in the process reads — conditions, scripts, input and
|
|
872
|
+
* output mappings, bodies, at any depth. The platform scans every `=` attribute and
|
|
873
|
+
* every text body of the process for the same pattern; the built model holds those
|
|
874
|
+
* strings in node fields, so this walks them all rather than one field per node kind.
|
|
875
|
+
*/
|
|
876
|
+
function variableReads(built) {
|
|
877
|
+
const reads = new Set();
|
|
878
|
+
const seen = new Set();
|
|
879
|
+
const visit = (val) => {
|
|
880
|
+
if (typeof val === 'string') {
|
|
881
|
+
for (const m of val.matchAll(VARIABLE_READ))
|
|
882
|
+
reads.add(m[1] ?? m[2]);
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
if (!val || typeof val !== 'object' || seen.has(val))
|
|
886
|
+
return;
|
|
887
|
+
seen.add(val);
|
|
888
|
+
if (Array.isArray(val)) {
|
|
889
|
+
for (const v of val)
|
|
890
|
+
visit(v);
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
for (const [k, v] of Object.entries(val))
|
|
894
|
+
if (!NOT_EXPRESSION_KEYS.has(k))
|
|
895
|
+
visit(v);
|
|
896
|
+
};
|
|
897
|
+
visit(built.nodes);
|
|
898
|
+
visit(built.flows);
|
|
899
|
+
visit(built.variables);
|
|
900
|
+
return reads;
|
|
901
|
+
}
|
|
837
902
|
/**
|
|
838
903
|
* A duration the RUNTIME can parse — days/hours/minutes/seconds only.
|
|
839
904
|
*
|
|
@@ -1039,12 +1104,19 @@ inEventSubProcess = false) {
|
|
|
1039
1104
|
// NO_START on a process that has one, refusing an artifact the platform accepts.
|
|
1040
1105
|
if (nodes.length && !nodes.some(isStartElement))
|
|
1041
1106
|
diags.push({ level: isTop ? 'error' : 'warning', code: 'NO_START', message: `${where} has no start event.`, where });
|
|
1042
|
-
// At most one BLANK start event per
|
|
1043
|
-
// trigger, the "start this manually" event. The platform
|
|
1044
|
-
//
|
|
1045
|
-
//
|
|
1046
|
-
//
|
|
1047
|
-
|
|
1107
|
+
// At most one BLANK start event per SUB-PROCESS — one with no event definition and no
|
|
1108
|
+
// trigger, the "start this manually" event. The platform's rule
|
|
1109
|
+
// (`validateSingleBlankStartEvent`) errors on a second one inside a `bpmn:subProcess`,
|
|
1110
|
+
// which is entered by its one incoming flow and so has one way to begin.
|
|
1111
|
+
//
|
|
1112
|
+
// It does NOT fire at the process root, and that is not an oversight to copy around:
|
|
1113
|
+
// a process with several blank starts, each carrying its own `uipath:entryPointId`, is
|
|
1114
|
+
// how Studio Web writes a process with several entry points ("start", "restart after
|
|
1115
|
+
// approval", "mark complete"). The rule walks the canvas's container nodes, and the
|
|
1116
|
+
// process itself is not one, so `uip maestro bpmn validate` accepts the shape — and
|
|
1117
|
+
// production processes ship it. Checking the root here refused those processes on a
|
|
1118
|
+
// no-edit round trip (#1679).
|
|
1119
|
+
const blankStarts = isTop ? [] : nodes.filter((n) => n.kind === 'startEvent' && n.event === undefined && n.trigger === undefined);
|
|
1048
1120
|
if (blankStarts.length > 1)
|
|
1049
1121
|
diags.push({
|
|
1050
1122
|
level: 'error',
|
|
@@ -1121,9 +1193,23 @@ inEventSubProcess = false) {
|
|
|
1121
1193
|
// A default naming no element or flow in this scope at all is the
|
|
1122
1194
|
// serializer's BPMN_GATEWAY_DEFAULT_UNKNOWN (compile refuses it); this is
|
|
1123
1195
|
// the other case, a flow or element that is not one of the gateway's own.
|
|
1196
|
+
//
|
|
1197
|
+
// A WARNING, not an error. The platform has no rule for it: the canvas marks a
|
|
1198
|
+
// flow as the default only when its OWN source names it (`source.default.id ===
|
|
1199
|
+
// flow.id`), and the local engine looks the default up among the gateway's
|
|
1200
|
+
// outgoing flows, so a foreign default is ignored and the gateway behaves as if it
|
|
1201
|
+
// had none. `uip maestro bpmn validate` calls such a process Valid, and Studio Web
|
|
1202
|
+
// writes one when a gateway is copied with its `default` (#1679). Refusing it
|
|
1203
|
+
// stopped a no-edit round trip of a process the platform deploys.
|
|
1124
1204
|
if (n.default !== undefined && !outs.some((o) => o.id === n.default)
|
|
1125
1205
|
&& (nodeIds.has(n.default) || flows.some((f) => f.id === n.default)))
|
|
1126
|
-
diags.push({
|
|
1206
|
+
diags.push({
|
|
1207
|
+
level: 'warning',
|
|
1208
|
+
code: 'BAD_DEFAULT',
|
|
1209
|
+
message: `Gateway "${n.id}" default "${n.default}" is not one of its outgoing flows, so it is ignored and the gateway ` +
|
|
1210
|
+
`has no default flow. Point it at one of the gateway's own outgoing flows, or remove it.`,
|
|
1211
|
+
where: n.id,
|
|
1212
|
+
});
|
|
1127
1213
|
if (outs.length > 1) {
|
|
1128
1214
|
const level = n.kind === 'exclusiveGateway' ? 'error' : 'warning';
|
|
1129
1215
|
for (const o of outs)
|
|
@@ -1161,17 +1247,25 @@ inEventSubProcess = false) {
|
|
|
1161
1247
|
});
|
|
1162
1248
|
}
|
|
1163
1249
|
// The only outgoing flow carries a condition, so a false condition strands the token
|
|
1164
|
-
// with nowhere to go. The platform's rule is
|
|
1165
|
-
//
|
|
1166
|
-
//
|
|
1167
|
-
//
|
|
1250
|
+
// with nowhere to go. The platform's rule (`validateSingleConditionalOutgoingFlow`) is
|
|
1251
|
+
// on ANY node, minus parallel and event-based gateways, and minus the
|
|
1252
|
+
// exclusive/inclusive gateways the superfluous rule above already owns (one in, one
|
|
1253
|
+
// out), so the two rules do not both fire on one element.
|
|
1254
|
+
//
|
|
1255
|
+
// Its SEVERITY depends on the node. On an exclusive or inclusive gateway it is an
|
|
1256
|
+
// ERROR: the engine fails a gateway with no branch to take. On anything else — a
|
|
1257
|
+
// task, an event — it is a WARNING and `uip maestro bpmn validate` says Valid. This
|
|
1258
|
+
// rule used to error on every node, so check refused production exports that
|
|
1259
|
+
// validate accepts, with a task whose one outgoing flow is conditional (#1679).
|
|
1260
|
+
// An empty condition counts as none, as the platform's `!conditionExpression` does.
|
|
1168
1261
|
if (n.kind !== 'parallelGateway' && n.kind !== 'eventBasedGateway' && outs.length === 1) {
|
|
1169
1262
|
const ownedBySuperfluous = (n.kind === 'exclusiveGateway' || n.kind === 'inclusiveGateway') && ins === 1;
|
|
1170
1263
|
const only = outs[0];
|
|
1171
1264
|
const defaultFlowId = 'default' in n ? n.default : undefined;
|
|
1172
|
-
|
|
1265
|
+
const gateway = n.kind === 'exclusiveGateway' || n.kind === 'inclusiveGateway';
|
|
1266
|
+
if (!ownedBySuperfluous && only.condition && only.id !== defaultFlowId)
|
|
1173
1267
|
diags.push({
|
|
1174
|
-
level: 'error',
|
|
1268
|
+
level: gateway ? 'error' : 'warning',
|
|
1175
1269
|
code: 'SINGLE_CONDITIONAL_OUTGOING_FLOW',
|
|
1176
1270
|
message: `The only outgoing flow of "${n.id}" ("${only.id}") carries a condition, so the instance strands there ` +
|
|
1177
1271
|
`whenever it is false. Drop the condition, mark the flow as the default, or add the other branch.`,
|
|
@@ -1230,7 +1324,7 @@ inEventSubProcess = false) {
|
|
|
1230
1324
|
if (n.kind === 'boundaryEvent') {
|
|
1231
1325
|
const target = nodes.find((x) => x.id === n.attachedTo);
|
|
1232
1326
|
// An unknown target is the serializer's BOUNDARY_UNATTACHED.
|
|
1233
|
-
if (target && !
|
|
1327
|
+
if (target && !isActivityNode(target))
|
|
1234
1328
|
diags.push({ level: 'error', code: 'BOUNDARY_NOT_ACTIVITY', message: `Boundary event "${n.id}" must attach to an activity, not "${target.kind}".`, where: n.id });
|
|
1235
1329
|
}
|
|
1236
1330
|
// A timer event definition needs one of duration/date/cycle.
|
package/dist/bpmn/decompile.js
CHANGED
|
@@ -193,17 +193,42 @@ function jsonValue(body) {
|
|
|
193
193
|
function key(k) {
|
|
194
194
|
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(k) ? k : tsText(k);
|
|
195
195
|
}
|
|
196
|
-
/**
|
|
196
|
+
/**
|
|
197
|
+
* `key: value` for each entry that is present.
|
|
198
|
+
*
|
|
199
|
+
* A present value must be a TypeScript expression, so `''` is refused here rather
|
|
200
|
+
* than written: `timer: ` is a syntax error, and the generated module would fail to
|
|
201
|
+
* load with no hint of which element caused it. Leave a field out with `undefined`.
|
|
202
|
+
*/
|
|
203
|
+
function pairs(entries) {
|
|
204
|
+
return entries
|
|
205
|
+
.filter(([, v]) => v !== undefined)
|
|
206
|
+
.map(([k, v]) => {
|
|
207
|
+
if (v.trim() === '')
|
|
208
|
+
throw new Error(`decompile: internal: option "${k}" rendered to no expression`);
|
|
209
|
+
return `${key(k)}: ${v}`;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Render `{ a: 1, b: 2 }` from the entries that are present, and `{}` when none are.
|
|
214
|
+
*
|
|
215
|
+
* Always an expression, so it is safe anywhere a value goes — an empty
|
|
216
|
+
* `<bpmn:timerEventDefinition />` is `timer: {}`. It used to return `''` for "no
|
|
217
|
+
* fields", which a caller nesting it as a value wrote out as `timer: }`. Where the
|
|
218
|
+
* whole argument is optional, wrap it in {@link optionalArg}, which drops the `{}`.
|
|
219
|
+
*/
|
|
197
220
|
function opts(entries) {
|
|
198
|
-
const parts = entries
|
|
199
|
-
return parts.length ? `{ ${parts.join(', ')} }` :
|
|
221
|
+
const parts = pairs(entries);
|
|
222
|
+
return parts.length ? `{ ${parts.join(', ')} }` : EMPTY_OPTS;
|
|
200
223
|
}
|
|
224
|
+
/** What {@link opts} renders when no entry is present. */
|
|
225
|
+
const EMPTY_OPTS = '{}';
|
|
201
226
|
/**
|
|
202
227
|
* The same option pairs as {@link opts}, but as the TAIL of a literal that already has
|
|
203
228
|
* a field — `{ id: 'x'` + `, name: 'y', … }` — for the array forms.
|
|
204
229
|
*/
|
|
205
230
|
function inner(entries) {
|
|
206
|
-
const parts = entries
|
|
231
|
+
const parts = pairs(entries);
|
|
207
232
|
return parts.length ? `, ${parts.join(', ')}` : '';
|
|
208
233
|
}
|
|
209
234
|
/** A record literal, or `undefined` when the record is empty. */
|
|
@@ -908,7 +933,18 @@ function emitTypedNode(chain, el, payload, type) {
|
|
|
908
933
|
}
|
|
909
934
|
}
|
|
910
935
|
else if (inputRows.length) {
|
|
911
|
-
|
|
936
|
+
if (bodyRowReproducible(inputRows, spec))
|
|
937
|
+
inputs = safeJson(inputRows[0].body);
|
|
938
|
+
// Rows the type's one payload row cannot reproduce go back verbatim. Reading
|
|
939
|
+
// the first row's body into `inputs` kept its content and threw away the rest:
|
|
940
|
+
// its name and target, any second row, and the fact that it was there at all
|
|
941
|
+
// for a type the registry says takes none. A deployed
|
|
942
|
+
// `Maestro.RetrieveCaseState` sends `<uipath:input name="body" target="body">`
|
|
943
|
+
// `{"variableNames":[…]}` while the registry declares `inputPattern: none`, so
|
|
944
|
+
// the `inputs` form came back as a refusal (BPMN_TYPE_NO_INPUTS), and a
|
|
945
|
+
// `mergedBody` row under another name would have been renamed silently.
|
|
946
|
+
else
|
|
947
|
+
verbatimInputs = emitInputRows(inputRows);
|
|
912
948
|
}
|
|
913
949
|
const verbatimContext = contextRowsNeedSpellingOut(payload, type) ? emitContextRows(payload) : undefined;
|
|
914
950
|
const { outputVar, extras } = outputsOf(payload, id, type);
|
|
@@ -957,6 +993,24 @@ function inputRowsNeedSpellingOut(rows, spec) {
|
|
|
957
993
|
return (r.type ?? 'string') !== derivedType;
|
|
958
994
|
});
|
|
959
995
|
}
|
|
996
|
+
/**
|
|
997
|
+
* Whether `inputs` — one object — would reproduce these rows for a type with a
|
|
998
|
+
* single payload row (`mergedBody`, `splitInputsItemData`): exactly one `json` row,
|
|
999
|
+
* under the name and target the registry gives it, whose body is a JSON object.
|
|
1000
|
+
* That is the only row `inputRows` in typed-node.ts writes for such a type, and a
|
|
1001
|
+
* `none` type writes no row at all, so for it any row needs spelling out.
|
|
1002
|
+
*/
|
|
1003
|
+
function bodyRowReproducible(rows, spec) {
|
|
1004
|
+
if (spec.inputPattern === 'none' || !spec.inputName || rows.length !== 1)
|
|
1005
|
+
return false;
|
|
1006
|
+
const [r] = rows;
|
|
1007
|
+
if (r.name !== spec.inputName || r.target !== (spec.inputTarget ?? 'body'))
|
|
1008
|
+
return false;
|
|
1009
|
+
if (r.type !== 'json' || r.value !== undefined || typeof r.body !== 'string')
|
|
1010
|
+
return false;
|
|
1011
|
+
const parsed = safeJson(r.body);
|
|
1012
|
+
return parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed);
|
|
1013
|
+
}
|
|
960
1014
|
/** The payload rows as `TypedInputRow` option source, in document order. */
|
|
961
1015
|
function emitInputRows(rows) {
|
|
962
1016
|
if (!rows.length)
|
|
@@ -1009,7 +1063,7 @@ function identifierize(name) {
|
|
|
1009
1063
|
}
|
|
1010
1064
|
/** `, { … }` when there are options, `''` when there are none. */
|
|
1011
1065
|
function optionalArg(rendered) {
|
|
1012
|
-
return rendered ? `, ${rendered}` : '';
|
|
1066
|
+
return rendered && rendered !== EMPTY_OPTS ? `, ${rendered}` : '';
|
|
1013
1067
|
}
|
|
1014
1068
|
/** Parse a CDATA body as JSON, falling back to the raw string. */
|
|
1015
1069
|
function safeJson(body) {
|
|
@@ -1524,7 +1578,7 @@ function renderHandler(plan, h, depth, indent) {
|
|
|
1524
1578
|
['payload', payload && type ? opts([['type', tsText(type)], ['outputRows', emitOutputRows(payload) ?? '[]']]) : undefined],
|
|
1525
1579
|
]);
|
|
1526
1580
|
const body = renderArmBody(plan, h.arm, depth, indent);
|
|
1527
|
-
const args = [defExpr, ...(optsText !==
|
|
1581
|
+
const args = [defExpr, ...(optsText !== EMPTY_OPTS ? [optsText] : []), ...(body ? [body] : [])];
|
|
1528
1582
|
return `t.${method}(${args.join(', ')});`;
|
|
1529
1583
|
}
|
|
1530
1584
|
function renderBranch(plan, lift, depth, indent) {
|
|
@@ -1542,7 +1596,7 @@ function renderBranch(plan, lift, depth, indent) {
|
|
|
1542
1596
|
const optsText = opts([
|
|
1543
1597
|
['name', gw.name !== undefined ? tsText(gw.name) : undefined],
|
|
1544
1598
|
['inclusive', lift.inclusive ? 'true' : undefined],
|
|
1545
|
-
['join', joinOpt !== undefined && joinOpt !==
|
|
1599
|
+
['join', joinOpt !== undefined && joinOpt !== EMPTY_OPTS ? joinOpt : undefined],
|
|
1546
1600
|
]);
|
|
1547
1601
|
const armTexts = lift.arms.map(({ flow, arm, otherwise }) => {
|
|
1548
1602
|
const body = renderArmBody(plan, arm, depth + 2, indent);
|
|
@@ -13,3 +13,5 @@ export declare function carriedDefinitionRefusal(manifest: unknown, where: strin
|
|
|
13
13
|
* guess).
|
|
14
14
|
*/
|
|
15
15
|
export declare function indexCarriedDefinitions(manifests: readonly unknown[], where: string, into?: Map<string, Record<string, unknown>>): Map<string, Record<string, unknown>>;
|
|
16
|
+
/** `JSON.stringify` with object keys sorted, so two copies of one manifest compare equal whatever their key order. */
|
|
17
|
+
export declare function stableJson(value: unknown): string;
|
|
@@ -57,7 +57,7 @@ export function indexCarriedDefinitions(manifests, where, into = new Map()) {
|
|
|
57
57
|
return into;
|
|
58
58
|
}
|
|
59
59
|
/** `JSON.stringify` with object keys sorted, so two copies of one manifest compare equal whatever their key order. */
|
|
60
|
-
function stableJson(value) {
|
|
60
|
+
export function stableJson(value) {
|
|
61
61
|
return JSON.stringify(value, (_key, v) => (v && typeof v === 'object' && !Array.isArray(v)
|
|
62
62
|
? Object.fromEntries(Object.keys(v).sort().map((k) => [k, v[k]]))
|
|
63
63
|
: v));
|
|
@@ -166,4 +166,6 @@ export declare function splitEventParameters(rc: ResolvedConnector, where: Recor
|
|
|
166
166
|
* // "(parentFolderId == 'inbox') && ((contains(subject,'Invoice')))"
|
|
167
167
|
*/
|
|
168
168
|
export declare function eventMatchExpression(scopeClauses: readonly string[], conditions: readonly ReadEventFilter[]): string;
|
|
169
|
-
export declare function eventDetail(rc: ResolvedConnector, sub: EventSubscription, nodeId: string, env: EventEmitEnv, site: string
|
|
169
|
+
export declare function eventDetail(rc: ResolvedConnector, sub: EventSubscription, nodeId: string, env: EventEmitEnv, site: string, opts?: {
|
|
170
|
+
unbound?: boolean;
|
|
171
|
+
}): Record<string, unknown>;
|
|
@@ -267,8 +267,10 @@ export function eventMatchExpression(scopeClauses, conditions) {
|
|
|
267
267
|
const group = conditions.map((c) => `(${eventFilterJmes(c)})`).join('&&');
|
|
268
268
|
return [...scopeClauses, ...(group !== '' ? [`(${group})`] : [])].join(' && ');
|
|
269
269
|
}
|
|
270
|
-
export function eventDetail(rc, sub, nodeId, env, site) {
|
|
271
|
-
|
|
270
|
+
export function eventDetail(rc, sub, nodeId, env, site, opts = {}) {
|
|
271
|
+
// An unbound draft the canvas saved (`opts.unbound`, a draft compile) is written with no connection, as the file has it.
|
|
272
|
+
if (!opts.unbound)
|
|
273
|
+
requireBindingPair(site, sub, eventTarget(sub));
|
|
272
274
|
const conn = env.resolveBinding(sub.connection, 'connection', `event node "${nodeId}"`, eventTarget(sub));
|
|
273
275
|
const folder = env.resolveBinding(sub.folder, 'folder', `event node "${nodeId}"`, eventTarget(sub));
|
|
274
276
|
const op = (rc.entry?.operation ?? {});
|
|
@@ -115,7 +115,8 @@ export interface ExprScope {
|
|
|
115
115
|
*/
|
|
116
116
|
export declare function extractRefs(expr: string, namespace?: string): ExprRef[];
|
|
117
117
|
/**
|
|
118
|
-
* First-level check of ONE expression: every reference's root must resolve
|
|
118
|
+
* First-level check of ONE expression: every reference's root must resolve (or, for a
|
|
119
|
+
* root declared with a dot in its name, its leading segments; see `unresolvedDottedName`).
|
|
119
120
|
*
|
|
120
121
|
* Returns a diagnostic per unresolved root (deduped, so `$vars.x + $vars.x` is one
|
|
121
122
|
* message). An empty result means "nothing this check is sure is wrong" — never
|
package/dist/core/expr-check.js
CHANGED
|
@@ -259,7 +259,8 @@ function nearMiss(name, roots) {
|
|
|
259
259
|
return oneEdit;
|
|
260
260
|
}
|
|
261
261
|
/**
|
|
262
|
-
* First-level check of ONE expression: every reference's root must resolve
|
|
262
|
+
* First-level check of ONE expression: every reference's root must resolve (or, for a
|
|
263
|
+
* root declared with a dot in its name, its leading segments; see `unresolvedDottedName`).
|
|
263
264
|
*
|
|
264
265
|
* Returns a diagnostic per unresolved root (deduped, so `$vars.x + $vars.x` is one
|
|
265
266
|
* message). An empty result means "nothing this check is sure is wrong" — never
|
|
@@ -291,17 +292,62 @@ export function checkExpression(expr, scope, escapes = []) {
|
|
|
291
292
|
: {}),
|
|
292
293
|
}];
|
|
293
294
|
}
|
|
295
|
+
const dotted = dottedRoots(scope.roots);
|
|
294
296
|
for (const ref of extractRefs(expr, namespace)) {
|
|
295
|
-
if (scope.roots.has(ref.root)
|
|
297
|
+
if (scope.roots.has(ref.root))
|
|
296
298
|
continue;
|
|
297
|
-
|
|
298
|
-
|
|
299
|
+
const name = dotted.length ? unresolvedDottedName(ref, dotted) : ref.root;
|
|
300
|
+
if (name === undefined || seen.has(name))
|
|
301
|
+
continue;
|
|
302
|
+
seen.add(name);
|
|
303
|
+
const near = nearMiss(name, scope.roots);
|
|
299
304
|
diags.push({
|
|
300
305
|
level: 'error',
|
|
301
306
|
code: 'EXPR_UNDECLARED_REF',
|
|
302
|
-
message: `Expression references \`${namespace}.${
|
|
307
|
+
message: `Expression references \`${namespace}.${name}\`, but no ${noun} named "${name}" is declared.`,
|
|
303
308
|
...(near ? { suggestion: near } : {}),
|
|
304
309
|
});
|
|
305
310
|
}
|
|
306
311
|
return diags;
|
|
307
312
|
}
|
|
313
|
+
/** The roots whose name contains a dot, split into segments (`step1.output` → `['step1', 'output']`). */
|
|
314
|
+
function dottedRoots(roots) {
|
|
315
|
+
const out = [];
|
|
316
|
+
for (const r of roots)
|
|
317
|
+
if (r.includes('.'))
|
|
318
|
+
out.push(r.split('.'));
|
|
319
|
+
return out;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Resolve a reference against the roots whose NAME contains a dot, the way the engine does.
|
|
323
|
+
*
|
|
324
|
+
* A variable may be declared with a dot in its id: a Flow-converted BPMN declares every
|
|
325
|
+
* node output as `<nodeId>.output` (`<uipath:inputOutput id="step1.output" …/>`) and
|
|
326
|
+
* reads it as `vars.step1.output.ok`. The engine stores such a variable twice, under the
|
|
327
|
+
* flat key and as a nested path (`local-engine/src/core/data-manager.ts`,
|
|
328
|
+
* `setNestedProperty`: `vars["step1.output"]` and `vars.step1.output` both work), so a
|
|
329
|
+
* reference resolves when its segments run along a declared id — either past its end
|
|
330
|
+
* (`vars.step1.output.ok` reads INTO the value) or stopping short of it (`vars.step1`
|
|
331
|
+
* reads the intermediate object the engine builds). Matching the first segment alone, as
|
|
332
|
+
* the plain-root test does, refused every read of a dotted id.
|
|
333
|
+
*
|
|
334
|
+
* @returns undefined when the reference resolves; otherwise the dotted name to report —
|
|
335
|
+
* the reference up to its first segment no declared id continues with
|
|
336
|
+
* (`vars.step1.outptu` → `step1.outptu`), or the bare root when no dotted id starts
|
|
337
|
+
* with it.
|
|
338
|
+
*/
|
|
339
|
+
function unresolvedDottedName(ref, dotted) {
|
|
340
|
+
const segs = [ref.root, ...ref.path];
|
|
341
|
+
let deepest = 0; // how many leading segments some declared id shares with the reference
|
|
342
|
+
for (const d of dotted) {
|
|
343
|
+
let k = 0;
|
|
344
|
+
while (k < d.length && k < segs.length && d[k] === segs[k])
|
|
345
|
+
k++;
|
|
346
|
+
// Every segment of the shorter one matched: the reference reads along this id.
|
|
347
|
+
if (k === d.length || k === segs.length)
|
|
348
|
+
return undefined;
|
|
349
|
+
if (k > deepest)
|
|
350
|
+
deepest = k;
|
|
351
|
+
}
|
|
352
|
+
return deepest === 0 ? ref.root : segs.slice(0, deepest + 1).join('.');
|
|
353
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The entry `definitions[]` holds for two definitions of one `<type>@<version>`:
|
|
3
|
+
* `prior` (the entry so far) and `next` (the next node's). Equal ones are the
|
|
4
|
+
* entry as they are. Ones that differ only in their resource binding share the
|
|
5
|
+
* unbound one. Anything else is `undefined`: the difference is not a binding,
|
|
6
|
+
* and the caller keeps its own rule for it.
|
|
7
|
+
*
|
|
8
|
+
* `template` is the bundled or carried definition at the same `<type>@<version>`,
|
|
9
|
+
* whose `model.context` the entry takes when the instances' rows differ.
|
|
10
|
+
*/
|
|
11
|
+
export declare function sharedDefinition(prior: unknown, next: unknown, template: unknown): unknown;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one `definitions[]` entry that several nodes of one `<type>@<version>`
|
|
3
|
+
* share, when each was compiled against its own copy of the definition (#1672).
|
|
4
|
+
*
|
|
5
|
+
* A `.flow` file holds ONE definition per `<type>@<version>`, while each node
|
|
6
|
+
* carries its own `model` (its resource binding) and `outputs`. Compile builds
|
|
7
|
+
* a node from a definition and copies the definition's `model` onto the node,
|
|
8
|
+
* so a node bound to a resource is compiled against a definition that carries
|
|
9
|
+
* that binding: a `rawNode` manifest decompile resolved with the node's own
|
|
10
|
+
* queue (#1512), or a typed queue step's definition with its queue key.
|
|
11
|
+
*
|
|
12
|
+
* Two such nodes on two queues hand compile two definitions that differ only
|
|
13
|
+
* in which queue they name. The entry used to be whichever came last, so it
|
|
14
|
+
* named the last node's queue, and the next decompile read that queue back for
|
|
15
|
+
* every node of the type: the first node came back bound to the second's queue.
|
|
16
|
+
*
|
|
17
|
+
* The shared entry is the definition with the binding taken OUT: an empty
|
|
18
|
+
* `resourceKey` and no `default`s — the template Studio Web stores, and the
|
|
19
|
+
* shape decompile resolves per node (#1513). For instance, two
|
|
20
|
+
* `core.action.queue.get-items@1.0` nodes on `queue-key-001` and
|
|
21
|
+
* `queue-key-002` share
|
|
22
|
+
*
|
|
23
|
+
* { model: { bindings: { resource: 'queue', resourceKey: '', values: [{ name: 'name', … }] }, … } }
|
|
24
|
+
*
|
|
25
|
+
* and each node keeps its own key and defaults on its own `model.bindings`.
|
|
26
|
+
*
|
|
27
|
+
* `model.context` is the node's binding references. When the instances agree
|
|
28
|
+
* on it (a decompiled `rawNode` keeps the `<bindings.NAME>` placeholders) it
|
|
29
|
+
* stays; when they do not (a typed queue step writes `=bindings.<id>` rows and
|
|
30
|
+
* its step label), the entry takes the template's rows: the definition the SDK
|
|
31
|
+
* bundles or the flow carries for that `<type>@<version>`.
|
|
32
|
+
*/
|
|
33
|
+
import { jsonClone } from './json-clone.js';
|
|
34
|
+
import { stableJson } from './carried-definitions.js';
|
|
35
|
+
/** True for a definition whose `model.bindings` names a resource other than a connection. */
|
|
36
|
+
function bindsResource(def) {
|
|
37
|
+
const b = def?.model?.bindings;
|
|
38
|
+
return b !== null && typeof b === 'object' && typeof b.resource === 'string' && b.resource !== '' && b.resource !== 'connection';
|
|
39
|
+
}
|
|
40
|
+
/** `def` with its resource binding emptied: `resourceKey: ''`, no `default` on any value. */
|
|
41
|
+
function unbound(def) {
|
|
42
|
+
const out = jsonClone(def);
|
|
43
|
+
const b = out.model.bindings;
|
|
44
|
+
b.resourceKey = '';
|
|
45
|
+
if (Array.isArray(b.values)) {
|
|
46
|
+
b.values = b.values.map((v) => {
|
|
47
|
+
if (v === null || typeof v !== 'object')
|
|
48
|
+
return v;
|
|
49
|
+
const { default: _default, ...rest } = v;
|
|
50
|
+
return rest;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
/** `def` without `model.context`, for comparing what the instances share apart from it. */
|
|
56
|
+
function withoutContext(def) {
|
|
57
|
+
const { context: _context, ...model } = def.model;
|
|
58
|
+
return { ...def, model };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The entry `definitions[]` holds for two definitions of one `<type>@<version>`:
|
|
62
|
+
* `prior` (the entry so far) and `next` (the next node's). Equal ones are the
|
|
63
|
+
* entry as they are. Ones that differ only in their resource binding share the
|
|
64
|
+
* unbound one. Anything else is `undefined`: the difference is not a binding,
|
|
65
|
+
* and the caller keeps its own rule for it.
|
|
66
|
+
*
|
|
67
|
+
* `template` is the bundled or carried definition at the same `<type>@<version>`,
|
|
68
|
+
* whose `model.context` the entry takes when the instances' rows differ.
|
|
69
|
+
*/
|
|
70
|
+
export function sharedDefinition(prior, next, template) {
|
|
71
|
+
if (stableJson(prior) === stableJson(next))
|
|
72
|
+
return prior;
|
|
73
|
+
if (!bindsResource(prior) || !bindsResource(next))
|
|
74
|
+
return undefined;
|
|
75
|
+
const a = unbound(prior);
|
|
76
|
+
const b = unbound(next);
|
|
77
|
+
if (stableJson(withoutContext(a)) !== stableJson(withoutContext(b)))
|
|
78
|
+
return undefined;
|
|
79
|
+
if (stableJson(a.model.context) === stableJson(b.model.context))
|
|
80
|
+
return a;
|
|
81
|
+
const rows = template?.model?.context;
|
|
82
|
+
if (rows === undefined)
|
|
83
|
+
return undefined;
|
|
84
|
+
return { ...a, model: { ...a.model, context: jsonClone(rows) } };
|
|
85
|
+
}
|
package/dist/decompile.js
CHANGED
|
@@ -1045,6 +1045,14 @@ function emitEventSubscription(node, imp, inputNames) {
|
|
|
1045
1045
|
* resolved with the node's own key and defaults (#1512); any other `def` comes
|
|
1046
1046
|
* back unchanged.
|
|
1047
1047
|
*
|
|
1048
|
+
* A definition that is already BOUND gets the same treatment when the node is
|
|
1049
|
+
* fully bound elsewhere: `definitions[]` holds one entry per `<type>@<version>`,
|
|
1050
|
+
* so a bound entry names at most one of the nodes that share it, and the node's
|
|
1051
|
+
* own binding is the one it runs with. SDK compiles before #1672 wrote the last
|
|
1052
|
+
* node's queue into that shared entry; reading it for every node rebound the
|
|
1053
|
+
* others. A bound entry that the node does not fully override stays as it is,
|
|
1054
|
+
* with no warning: it is a binding, just not a different one.
|
|
1055
|
+
*
|
|
1048
1056
|
* For instance, a template context row `queueName: "<bindings.name>"`, on a node
|
|
1049
1057
|
* whose `queueName` row is `=bindings.bQueueName`, takes `bQueueName`'s
|
|
1050
1058
|
* `resourceKey` and `default`. The placeholders stay, for compile to close.
|
|
@@ -1058,8 +1066,7 @@ function resolveTemplateBindings(def, node) {
|
|
|
1058
1066
|
const resource = model?.bindings?.resource;
|
|
1059
1067
|
if (names.length === 0 || typeof resource !== 'string' || !resource || resource === 'connection')
|
|
1060
1068
|
return { def };
|
|
1061
|
-
|
|
1062
|
-
return { def };
|
|
1069
|
+
const bound = typeof model.bindings.resourceKey === 'string' && model.bindings.resourceKey !== '';
|
|
1063
1070
|
const nodeModel = node.model;
|
|
1064
1071
|
const nodeContext = Array.isArray(nodeModel?.context) ? nodeModel.context : [];
|
|
1065
1072
|
const nodeValues = Array.isArray(nodeModel?.bindings?.values) ? nodeModel.bindings.values : [];
|
|
@@ -1091,6 +1098,8 @@ function resolveTemplateBindings(def, node) {
|
|
|
1091
1098
|
// Nothing bound at all: compile's own refusal already says what to do.
|
|
1092
1099
|
if (keys.size === 0 && defaults.size === 0)
|
|
1093
1100
|
return { def };
|
|
1101
|
+
if (bound && (missing.length > 0 || new Set(keys.values()).size !== 1))
|
|
1102
|
+
return { def };
|
|
1094
1103
|
if (missing.length > 0) {
|
|
1095
1104
|
return { def, reason: `${label} is bound to a ${resource}, but its binding has ${missing.join(', ')}, so its definition stays the template.` };
|
|
1096
1105
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { missingBindingLabels } from '../../../core/binding-messages.js';
|
|
1
|
+
import { bindingMissingMessage, missingBindingLabels } from '../../../core/binding-messages.js';
|
|
2
2
|
import { prepareCommand } from '../../../core/cli-spelling.js';
|
|
3
3
|
import { commentText } from '../../../core/comment-text.js';
|
|
4
4
|
import { eventFilterFromTreeLeaf } from '../../../core/event-filters.js';
|
|
@@ -16,6 +16,26 @@ export function splitEvent(typeName) {
|
|
|
16
16
|
return undefined;
|
|
17
17
|
return { connector: rest.slice(0, dot), event: rest.slice(dot + 1) };
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* The definition a wait is written with. The node is the event the author named
|
|
21
|
+
* (`rc.nodeType`); a definition naming another is written under that name, so the
|
|
22
|
+
* node and its definitions[] entry agree.
|
|
23
|
+
*/
|
|
24
|
+
function eventDefinition(rc) {
|
|
25
|
+
const v1def = rc.v1def;
|
|
26
|
+
const def = v1def.nodeType === rc.nodeType ? v1def : { ...v1def, nodeType: rc.nodeType };
|
|
27
|
+
return { source: 'snapshot', nodeType: def.nodeType, version: def.version, manifest: def };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Whether a saved wait is a draft: the canvas saved it before a connection was
|
|
31
|
+
* picked (`detail.connectionId: null`), so it has no connection or folder.
|
|
32
|
+
* Decompile then marks its step `{ draft: true }` and carries its definition.
|
|
33
|
+
*/
|
|
34
|
+
function isEventWaitDraft(node) {
|
|
35
|
+
const detail = (node.inputs?.detail ?? {});
|
|
36
|
+
const label = (v) => (typeof v === 'string' ? v : undefined);
|
|
37
|
+
return missingBindingLabels({ connection: label(detail.connectionId), folder: label(detail.connectionFolderKey) }).length > 0;
|
|
38
|
+
}
|
|
19
39
|
function serializeEventWait(spec, ctx) {
|
|
20
40
|
const sub = spec.subscription;
|
|
21
41
|
const site = `waitForEvent "${ctx.step}"`;
|
|
@@ -23,11 +43,25 @@ function serializeEventWait(spec, ctx) {
|
|
|
23
43
|
throw libraryRequiredForEvent(ctx.events, sub, ctx.nodeId, site, site);
|
|
24
44
|
const rc = resolveEvent(ctx.library, 'event', sub, site);
|
|
25
45
|
refuseUnverifiedByoa(ctx.events, site, sub);
|
|
46
|
+
const target = eventTarget(sub);
|
|
47
|
+
// A wait with no connection or folder is refused (BINDING_MISSING), unless it
|
|
48
|
+
// is a draft the canvas saved (a draft compile, `{ draft: true }`): it is
|
|
49
|
+
// written unbound, as the file has it, with a draft finding (#1674).
|
|
50
|
+
const missing = missingBindingLabels(sub);
|
|
51
|
+
if (missing.length > 0 && ctx.drafting) {
|
|
52
|
+
ctx.draft('BINDING_MISSING', bindingMissingMessage(site, missing, target));
|
|
53
|
+
// A draft is written with the definition the source carries (the canvas file's), at the step's version.
|
|
54
|
+
const detail = eventDetail(rc, sub, ctx.nodeId, ctx.events, site, { unbound: true });
|
|
55
|
+
const carried = ctx.definition(rc.nodeType, ctx.version);
|
|
56
|
+
const definition = carried !== undefined
|
|
57
|
+
? { source: 'snapshot', nodeType: rc.nodeType, version: ctx.version, manifest: carried }
|
|
58
|
+
: eventDefinition(rc);
|
|
59
|
+
return { definition, inputs: { detail }, port: 'output' };
|
|
60
|
+
}
|
|
26
61
|
const detail = eventDetail(rc, sub, ctx.nodeId, ctx.events, site);
|
|
27
62
|
// The platform reaches the connection through the flow's `bindings[]`, as for
|
|
28
63
|
// a connector operation (board G-19). `eventDetail` refused a node without
|
|
29
64
|
// both labels, so both resolve here.
|
|
30
|
-
const target = eventTarget(sub);
|
|
31
65
|
const connectionId = ctx.resolveBinding(sub.connection, 'connection', site, target);
|
|
32
66
|
const folderKey = ctx.resolveBinding(sub.folder, 'folder', site, target);
|
|
33
67
|
ctx.bindConnection({
|
|
@@ -35,12 +69,8 @@ function serializeEventWait(spec, ctx) {
|
|
|
35
69
|
connectorKey: rc.connectorKey, connectionId: connectionId,
|
|
36
70
|
...(folderKey !== undefined ? { folderKey } : {}),
|
|
37
71
|
});
|
|
38
|
-
// The node is the event the author named (`rc.nodeType`); a definition naming
|
|
39
|
-
// another is written under that name, so the node and its definitions[] entry agree.
|
|
40
|
-
const v1def = rc.v1def;
|
|
41
|
-
const def = v1def.nodeType === rc.nodeType ? v1def : { ...v1def, nodeType: rc.nodeType };
|
|
42
72
|
return {
|
|
43
|
-
definition:
|
|
73
|
+
definition: eventDefinition(rc),
|
|
44
74
|
inputs: { detail },
|
|
45
75
|
// A wait continues on `output`, as every connector node does.
|
|
46
76
|
port: 'output',
|
|
@@ -103,7 +133,7 @@ function liftEventWait(node, ctx) {
|
|
|
103
133
|
const missing = missingBindingLabels({ connection, folder });
|
|
104
134
|
if (missing.length > 0) {
|
|
105
135
|
ctx.warn(`node ${tsLiteral(n.id)} (${n.type}) has no ${missing.join(' or ')} in the .flow (an unbound draft). `
|
|
106
|
-
+ `The source leaves ${missing.length > 1 ? 'them' : 'it'} out
|
|
136
|
+
+ `The source leaves ${missing.length > 1 ? 'them' : 'it'} out. With the file's definition the step is marked \`{ draft: true }\` and compile writes it as a draft; check refuses it (BINDING_MISSING) `
|
|
107
137
|
+ `until it names both labels: run \`${prepareCommand(split.connector, split.event)}\`, then pass `
|
|
108
138
|
+ `\`connection\` and \`folder\`.`);
|
|
109
139
|
}
|
|
@@ -141,6 +171,7 @@ const eventWait10 = {
|
|
|
141
171
|
errorPort: false,
|
|
142
172
|
serialize: (spec, ctx) => serializeEventWait(spec, ctx),
|
|
143
173
|
deserialize: (node, ctx) => liftEventWait(node, ctx),
|
|
174
|
+
isDraft: (node) => isEventWaitDraft(node),
|
|
144
175
|
print: (spec, ctx) => printEventWait(spec, ctx),
|
|
145
176
|
check: (spec, ctx) => ctx.eventSubscription(spec.subscription, `waitForEvent "${ctx.step}"`),
|
|
146
177
|
namedNode: (spec) => {
|
|
@@ -35,7 +35,7 @@ export const HITL_DIAGNOSTICS = {
|
|
|
35
35
|
HITL_FIELD_SETTING_INVALID: { severity: 'error', summary: 'a form field setting (controlType, colSpan, …) the platform refuses' },
|
|
36
36
|
HITL_FIELD_NO_VALUE: { severity: 'error', summary: 'a shown field with no value' },
|
|
37
37
|
HITL_FIELD_VALUE_NOT_REF: { severity: 'error', summary: 'a shown field filled from a literal' },
|
|
38
|
-
HITL_FIELD_VALUE_NOT_PATH: { severity: 'error', summary: 'a shown field filled from a
|
|
38
|
+
HITL_FIELD_VALUE_NOT_PATH: { severity: 'error', summary: 'a shown field filled from a lit(...) literal' },
|
|
39
39
|
HITL_FIELD_DIRECTION: { severity: 'error', summary: 'a field direction that is not input, output or inOut' },
|
|
40
40
|
HITL_FIELD_VARIABLE: { severity: 'error', summary: "an asked field's variable that is not one identifier, or sits on a shown field" },
|
|
41
41
|
HITL_NO_OUTCOMES: { severity: 'error', summary: 'no outcomes, so the task never completes' },
|
|
@@ -253,8 +253,8 @@ export function checkHitl(inputs, ctx) {
|
|
|
253
253
|
at('HITL_FIELD_NO_VALUE', `Human task "${step}" shows the form field "${id}" to the reviewer but gives it no value, `
|
|
254
254
|
+ `so the field renders empty — the flow says "show them this" and shows them nothing.`, `value: input('<flowInput>') // or out('<step>', '<field>')`);
|
|
255
255
|
}
|
|
256
|
-
// A
|
|
257
|
-
//
|
|
256
|
+
// A raw constant is the serializer's HITL_FIELD_VALUE_NOT_REF and a `lit(...)` its
|
|
257
|
+
// HITL_FIELD_VALUE_NOT_PATH; any other expression is written as `=js:<expression>`.
|
|
258
258
|
}
|
|
259
259
|
else if (f?.direction !== 'output') {
|
|
260
260
|
at('HITL_FIELD_DIRECTION', `Human task "${step}" gives the form field "${id}" the direction `
|
|
@@ -285,15 +285,28 @@ function appBindingExpr(value, ctx) {
|
|
|
285
285
|
return path.startsWith('=') ? path : `=${path.startsWith('vars.') ? path : `vars.${path}`}`;
|
|
286
286
|
}
|
|
287
287
|
/**
|
|
288
|
-
* A shown field's `binding
|
|
289
|
-
* workflow's variables (`vars.<flowInput>`,
|
|
290
|
-
* `$vars.` prefix our expressions carry is
|
|
291
|
-
*
|
|
288
|
+
* A shown field's `binding`. A reference is written as the path the platform
|
|
289
|
+
* resolves against the workflow's variables (`vars.<flowInput>`,
|
|
290
|
+
* `vars.<node>.output.<field>`), so the `$vars.` prefix our expressions carry is
|
|
291
|
+
* dropped. Any other expression is written as `=js:<expression>`, the spelling
|
|
292
|
+
* Studio Web saves for a field in expression mode: flow-v1 reads that binding
|
|
293
|
+
* as an expression (`parseFlowBinding` in `@uipath/hitl-schema-types`) and
|
|
294
|
+
* evaluates it into the task's `HitlTaskArguments` (UiPath/flow-v1#4182). For
|
|
295
|
+
* instance js`'NWF-' + $vars.ticket.output.id` is written as
|
|
296
|
+
* `=js:'NWF-' + $vars.ticket.output.id`, and decompile reads it back as the same
|
|
297
|
+
* expression (#1674). A `lit(...)` is refused before we get here
|
|
298
|
+
* (`refuseUnwritable`, HITL_FIELD_VALUE_NOT_PATH).
|
|
292
299
|
*/
|
|
300
|
+
/** Whether `js` is a bare variable reference (`$vars.a.b`), the one binding written as a path. */
|
|
301
|
+
function isVarsPath(js) {
|
|
302
|
+
return /^\$vars\.[A-Za-z0-9_]+(\.[A-Za-z0-9_]+)*$/.test(js);
|
|
303
|
+
}
|
|
293
304
|
function bindingPath(value, ctx) {
|
|
294
305
|
if (!(value instanceof Expr))
|
|
295
306
|
return String(value ?? '');
|
|
296
307
|
const js = ctx.renameRefs(value.js).trim();
|
|
308
|
+
if (!isVarsPath(js))
|
|
309
|
+
return `=js:${js}`;
|
|
297
310
|
const path = js.startsWith('$vars.') ? js.slice('$vars.'.length) : js;
|
|
298
311
|
// `vars.`-prefixed, which is what 526 of 528 bound fields in deployed v1 flows
|
|
299
312
|
// carry. flow-v1's serializer does prefix a bare identifier itself
|
|
@@ -311,8 +324,8 @@ function bindingPath(value, ctx) {
|
|
|
311
324
|
* `check` reports the same refusals, on the step, from this one place (collect
|
|
312
325
|
* mode). Every condition each code names is refused, the lossy shape and the
|
|
313
326
|
* rest alike: the rest are tasks the platform cannot run as written (a blank
|
|
314
|
-
* extraction result, an app it cannot find,
|
|
315
|
-
*
|
|
327
|
+
* extraction result, an app it cannot find), and `compile` refused all of them
|
|
328
|
+
* before #1497.
|
|
316
329
|
* The checks run in `checkHitl`'s order, so the first refusal is the one
|
|
317
330
|
* `check` used to report first.
|
|
318
331
|
*/
|
|
@@ -447,11 +460,13 @@ function refuseUnwritable(inputs, typeName, step) {
|
|
|
447
460
|
+ `\`out(...)\` reference, two copies of the SDK are loaded: an expression built by the other `
|
|
448
461
|
+ `copy is not recognised as one — import every helper from one SDK install.`, `value: input('<flowInput>')`);
|
|
449
462
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
+ `
|
|
463
|
+
// A computed expression is written as `=js:<expression>` (`bindingPath`). A `lit(...)` has
|
|
464
|
+
// no written form here: the binding would read back as an expression, not as the literal.
|
|
465
|
+
if (value.literal) {
|
|
466
|
+
throw new CompileRefusal('HITL_FIELD_VALUE_NOT_PATH', `Human task "${step}" fills the form field "${id}" from the literal `
|
|
467
|
+
+ `"${String(value.value).slice(0, 60)}". A field binding is a variable path or an expression, `
|
|
468
|
+
+ `so a \`lit(...)\` has no form there. Write the value as an expression (js\`'text'\`), `
|
|
469
|
+
+ `or point the field at a variable that holds it.`, "value: js`'<text>'`");
|
|
455
470
|
}
|
|
456
471
|
}
|
|
457
472
|
});
|
package/dist/serialize.js
CHANGED
|
@@ -22,6 +22,7 @@ import { stepExits } from './flow-step-exits.js';
|
|
|
22
22
|
import { endOutcomeRefusal, fanInRefusal, hitlEndHazards, hitlFanInto } from './flow-parallel-hitl.js';
|
|
23
23
|
import { resolveVersionCarried } from './core/nodes/versioned.js';
|
|
24
24
|
import { indexCarriedDefinitions } from './core/carried-definitions.js';
|
|
25
|
+
import { sharedDefinition } from './core/shared-definition.js';
|
|
25
26
|
import { connectionConnectors } from './bindings-v2.js';
|
|
26
27
|
import { BindingRefusal, bindingLabelRefusal, connectionStubMessage } from './core/binding-messages.js';
|
|
27
28
|
import { OUTCOME_HANDLE_NODE_TYPES, assertHitlExitInvariant, hitlExitViolation } from './core/hitl-routing.js';
|
|
@@ -1739,6 +1740,24 @@ function serializeFlow(built, opts) {
|
|
|
1739
1740
|
function pushEdge(scope, from, toNode, toPort = 'input') {
|
|
1740
1741
|
scope.edges.push({ id: `edge_${edgeSeq++}`, sourceNodeId: from.node, sourcePort: from.port, targetNodeId: toNode, targetPort: toPort });
|
|
1741
1742
|
}
|
|
1743
|
+
/**
|
|
1744
|
+
* Record `def` as the `definitions[]` entry for `type@version`. The file holds
|
|
1745
|
+
* one per pair, and each node copies its own `model` from the definition it
|
|
1746
|
+
* was built from, so two nodes bound to two resources bring two definitions.
|
|
1747
|
+
* Those share the unbound one (`sharedDefinition`, #1672): the entry used to
|
|
1748
|
+
* be the last node's, and the next decompile read its binding back for every
|
|
1749
|
+
* node of the type. Any other difference keeps the last one, as before; a
|
|
1750
|
+
* family that needs a union (an inline agent's memory handle) builds it
|
|
1751
|
+
* through `ctx.emitted`.
|
|
1752
|
+
*/
|
|
1753
|
+
function recordDefinition(type, def) {
|
|
1754
|
+
const key = `${type}@${def.version}`;
|
|
1755
|
+
const prior = emittedDefs.get(key);
|
|
1756
|
+
const shared = prior === undefined || prior === def
|
|
1757
|
+
? undefined
|
|
1758
|
+
: sharedDefinition(prior, def, definitionFor(type, String(def.version)));
|
|
1759
|
+
emittedDefs.set(key, shared ?? def);
|
|
1760
|
+
}
|
|
1742
1761
|
let col = 0;
|
|
1743
1762
|
/**
|
|
1744
1763
|
* Create a node from a definition (core def by type, or a supplied connector
|
|
@@ -1772,7 +1791,7 @@ function serializeFlow(built, opts) {
|
|
|
1772
1791
|
def = exact;
|
|
1773
1792
|
}
|
|
1774
1793
|
if (def)
|
|
1775
|
-
|
|
1794
|
+
recordDefinition(type, def);
|
|
1776
1795
|
if (def && !o.def)
|
|
1777
1796
|
bundledNodeDefs.set(id, def);
|
|
1778
1797
|
const node = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.85.
|
|
3
|
+
"version": "6.85.4",
|
|
4
4
|
"description": "Build UiPath Flow, Case, and BPMN artifacts by writing TypeScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://docs.uipath.com/maestro",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"@types/node": "^22.7.0",
|
|
104
104
|
"esbuild": "^0.28.1"
|
|
105
105
|
},
|
|
106
|
-
"gitref": "
|
|
106
|
+
"gitref": "04a7cb4ba4ed4854adb6e4838d4548e5851b2cc1"
|
|
107
107
|
}
|