@uipath/maestro-builder-sdk 6.85.3 → 6.85.5

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.
@@ -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. `connector` belongs here: it serializes to
57
- * a `bpmn:sendTask`, which is an activity like any other, and catching a
58
- * connector's failure is the commonest error-handling shape there is.
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 = new Set(['task', 'scriptTask', 'subProcess', 'connector', 'typed', 'connectorEvent', 'externalTask']);
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 — silently, with no diagnostic anywhere else.
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
- for (const v of allVars) {
828
- if (typeof v.elementId === 'string' && !ids.has(v.elementId))
829
- diags.push({
830
- level: 'error',
831
- code: 'SCOPED_VAR_UNKNOWN_ELEMENT',
832
- message: `Variable "${v.id}" is scoped to element "${v.elementId}", which does not exist.`,
833
- where: v.id,
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 scope — one with no event definition and no
1043
- // trigger, the "start this manually" event. The platform counts them per process and
1044
- // per sub-process (`validateSingleBlankStartEvent`) and errors on a second; a
1045
- // `sequence` scope refuses one at build, but an explicit-mode scope did not, so the
1046
- // shape reached `validate`.
1047
- const blankStarts = nodes.filter((n) => n.kind === 'startEvent' && n.event === undefined && n.trigger === undefined);
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({ level: 'error', code: 'BAD_DEFAULT', message: `Gateway "${n.id}" default "${n.default}" is not one of its outgoing flows.`, where: n.id });
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 on ANY node — a task with one conditional
1165
- // outgoing flow trips it too, not just a gateway — minus parallel and event-based
1166
- // gateways, and minus the exclusive/inclusive gateways the superfluous rule above
1167
- // already owns (one in, one out), so the two rules do not both fire on one element.
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
- if (!ownedBySuperfluous && only.condition !== undefined && only.id !== defaultFlowId)
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 && !ACTIVITY_KINDS.has(target.kind))
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.
@@ -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
- /** Render `{ a: 1, b: 2 }` from the entries that are present; `''` when none are. */
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.filter(([, v]) => v !== undefined).map(([k, v]) => `${key(k)}: ${v}`);
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.filter(([, v]) => v !== undefined).map(([k, v]) => `${key(k)}: ${v}`);
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
- inputs = safeJson(inputRows[0].body);
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 !== '' && optsText !== '{}' ? [optsText] : []), ...(body ? [body] : [])];
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 !== '' && joinOpt !== '{}' ? joinOpt : undefined],
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): Record<string, unknown>;
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
- requireBindingPair(site, sub, eventTarget(sub));
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
@@ -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) || seen.has(ref.root))
297
+ if (scope.roots.has(ref.root))
296
298
  continue;
297
- seen.add(ref.root);
298
- const near = nearMiss(ref.root, scope.roots);
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}.${ref.root}\`, but no ${noun} named "${ref.root}" is declared.`,
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
+ }
@@ -1985,6 +1985,21 @@
1985
1985
  "type": "jsonSchema",
1986
1986
  "elementId": "{nodeId}",
1987
1987
  "custom": true
1988
+ },
1989
+ {
1990
+ "condition": "hasEdgeFromHandle('error')",
1991
+ "id": "{nodeId}.error",
1992
+ "name": "error",
1993
+ "type": "jsonSchema",
1994
+ "elementId": "{nodeId}",
1995
+ "custom": true
1996
+ },
1997
+ {
1998
+ "condition": "!hasEdgeFromHandle('error')",
1999
+ "id": "{nodeId}.boundaryError",
2000
+ "name": "Error",
2001
+ "type": "jsonSchema",
2002
+ "elementId": "_Implicit_SubprocessBoundaryError_{nodeId}"
1988
2003
  }
1989
2004
  ],
1990
2005
  "nodes": [
@@ -2017,14 +2032,14 @@
2017
2032
  {
2018
2033
  "name": "output",
2019
2034
  "type": "jsonSchema",
2020
- "source": "=$vars.response",
2035
+ "source": "=vars.response",
2021
2036
  "var": "{nodeId}.output",
2022
2037
  "custom": true
2023
2038
  },
2024
2039
  {
2025
- "name": "error",
2040
+ "name": "Error",
2026
2041
  "type": "jsonSchema",
2027
- "source": "=$vars.error",
2042
+ "source": "=vars.error",
2028
2043
  "var": "{nodeId}.error",
2029
2044
  "custom": true
2030
2045
  }
@@ -2114,33 +2129,6 @@
2114
2129
  }
2115
2130
  }
2116
2131
  },
2117
- {
2118
- "id": "_Implicit_Gateway_{nodeId}",
2119
- "type": "bpmn:ExclusiveGateway",
2120
- "parentId": "{nodeId}",
2121
- "position": {
2122
- "x": 0,
2123
- "y": 0
2124
- },
2125
- "condition": "node.data.inputs.branches.length > 0",
2126
- "data": {
2127
- "label": "Response Branch",
2128
- "defaultFlowId": "_Implicit_Edge__Implicit_Gateway_{nodeId}__Implicit_EndEvent_Default_{nodeId}"
2129
- }
2130
- },
2131
- {
2132
- "forEach": "node.data.inputs.branches",
2133
- "id": "_Implicit_EndEvent_{branchName}_{nodeId}",
2134
- "type": "bpmn:EndEvent",
2135
- "parentId": "{nodeId}",
2136
- "position": {
2137
- "x": 0,
2138
- "y": 0
2139
- },
2140
- "data": {
2141
- "label": "{branch.name}"
2142
- }
2143
- },
2144
2132
  {
2145
2133
  "id": "_Implicit_EndEvent_Default_{nodeId}",
2146
2134
  "type": "bpmn:EndEvent",
@@ -2163,19 +2151,7 @@
2163
2151
  "y": 0
2164
2152
  },
2165
2153
  "data": {
2166
- "label": "Failure",
2167
- "model": {
2168
- "serviceType": "BPMN.Variables",
2169
- "outputs": [
2170
- {
2171
- "name": "error",
2172
- "type": "boolean",
2173
- "source": "=true",
2174
- "var": "error",
2175
- "internal": true
2176
- }
2177
- ]
2178
- }
2154
+ "label": "Failure"
2179
2155
  }
2180
2156
  },
2181
2157
  {
@@ -2189,11 +2165,21 @@
2189
2165
  },
2190
2166
  "data": {
2191
2167
  "label": "Error",
2192
- "cancelActivity": false,
2193
2168
  "attachedToId": "_Implicit_HttpTask_{nodeId}",
2194
2169
  "eventDefinition": {
2195
2170
  "type": "bpmn:ErrorEventDefinition",
2196
2171
  "id": "_Implicit_BoundaryError_{nodeId}_Error"
2172
+ },
2173
+ "model": {
2174
+ "outputs": [
2175
+ {
2176
+ "name": "Error",
2177
+ "type": "jsonSchema",
2178
+ "source": "=Error",
2179
+ "var": "error",
2180
+ "internal": true
2181
+ }
2182
+ ]
2197
2183
  }
2198
2184
  }
2199
2185
  }
@@ -2207,43 +2193,12 @@
2207
2193
  "data": {}
2208
2194
  },
2209
2195
  {
2210
- "condition": "node.data.inputs.branches.length === 0",
2211
2196
  "id": "_Implicit_Edge__Implicit_HttpTask_{nodeId}__Implicit_EndEvent_Default_{nodeId}",
2212
2197
  "source": "_Implicit_HttpTask_{nodeId}",
2213
2198
  "target": "_Implicit_EndEvent_Default_{nodeId}",
2214
2199
  "type": "bpmn:SequenceFlow",
2215
2200
  "data": {}
2216
2201
  },
2217
- {
2218
- "condition": "node.data.inputs.branches.length > 0",
2219
- "id": "_Implicit_Edge__Implicit_HttpTask_{nodeId}__Implicit_Gateway_{nodeId}",
2220
- "source": "_Implicit_HttpTask_{nodeId}",
2221
- "target": "_Implicit_Gateway_{nodeId}",
2222
- "type": "bpmn:SequenceFlow",
2223
- "data": {}
2224
- },
2225
- {
2226
- "forEach": "node.data.inputs.branches",
2227
- "condition": "node.data.inputs.branches.length > 0",
2228
- "id": "_Implicit_Edge__Implicit_Gateway_{nodeId}__Implicit_EndEvent_{branchName}_{nodeId}",
2229
- "source": "_Implicit_Gateway_{nodeId}",
2230
- "target": "_Implicit_EndEvent_{branchName}_{nodeId}",
2231
- "type": "bpmn:SequenceFlow",
2232
- "data": {
2233
- "conditionExpression": "{branch.conditionExpression}",
2234
- "label": "{branch.name}"
2235
- }
2236
- },
2237
- {
2238
- "condition": "node.data.inputs.branches.length > 0",
2239
- "id": "_Implicit_Edge__Implicit_Gateway_{nodeId}__Implicit_EndEvent_Default_{nodeId}",
2240
- "source": "_Implicit_Gateway_{nodeId}",
2241
- "target": "_Implicit_EndEvent_Default_{nodeId}",
2242
- "type": "bpmn:SequenceFlow",
2243
- "data": {
2244
- "label": "Default"
2245
- }
2246
- },
2247
2202
  {
2248
2203
  "condition": "hasEdgeFromHandle('error')",
2249
2204
  "id": "_Implicit_Edge__Implicit_BoundaryError_{nodeId}__Implicit_EndEvent_Failure_{nodeId}",
@@ -2254,6 +2209,34 @@
2254
2209
  }
2255
2210
  ]
2256
2211
  },
2212
+ {
2213
+ "condition": "!hasEdgeFromHandle('error')",
2214
+ "id": "_Implicit_SubprocessBoundaryError_{nodeId}",
2215
+ "type": "bpmn:BoundaryEvent",
2216
+ "parentId": null,
2217
+ "position": {
2218
+ "x": 0,
2219
+ "y": 0
2220
+ },
2221
+ "data": {
2222
+ "label": "",
2223
+ "attachedToId": "{nodeId}",
2224
+ "eventDefinition": {
2225
+ "type": "bpmn:ErrorEventDefinition",
2226
+ "id": "_Implicit_SubprocessBoundaryError_{nodeId}_Error"
2227
+ },
2228
+ "model": {
2229
+ "outputs": [
2230
+ {
2231
+ "name": "Error",
2232
+ "type": "jsonSchema",
2233
+ "source": "=Error",
2234
+ "var": "{nodeId}.boundaryError"
2235
+ }
2236
+ ]
2237
+ }
2238
+ }
2239
+ },
2257
2240
  {
2258
2241
  "id": "_Implicit_PostSubprocessGateway_{nodeId}",
2259
2242
  "type": "bpmn:ExclusiveGateway",
@@ -2306,7 +2289,7 @@
2306
2289
  "source": "_Implicit_PostSubprocessGateway_{nodeId}",
2307
2290
  "type": "bpmn:SequenceFlow",
2308
2291
  "data": {
2309
- "conditionExpression": "=js:$vars.{nodeId}.error || $vars.{nodeId}.output?.statusCode >= 400",
2292
+ "conditionExpression": "=js:vars.{nodeId}.error != null || (vars.{nodeId}.output != null && vars.{nodeId}.output.statusCode >= 400)",
2310
2293
  "label": "Error"
2311
2294
  }
2312
2295
  },
@@ -2508,7 +2491,7 @@
2508
2491
  "value": "manual"
2509
2492
  },
2510
2493
  {
2511
- "label": "API Definition",
2494
+ "label": "API definition",
2512
2495
  "value": "apiDefinition"
2513
2496
  }
2514
2497
  ]
@@ -2517,12 +2500,26 @@
2517
2500
  "name": "inputs.swaggerDefinition",
2518
2501
  "type": "custom",
2519
2502
  "component": "http-swagger-section",
2520
- "label": ""
2503
+ "label": "",
2504
+ "rules": [
2505
+ {
2506
+ "id": "show-swagger",
2507
+ "conditions": [
2508
+ {
2509
+ "when": "inputs.mode",
2510
+ "is": "apiDefinition"
2511
+ }
2512
+ ],
2513
+ "effects": {
2514
+ "visible": true
2515
+ }
2516
+ }
2517
+ ]
2521
2518
  },
2522
2519
  {
2523
2520
  "name": "inputs.method",
2524
2521
  "type": "select",
2525
- "label": "HTTP Method",
2522
+ "label": "HTTP method",
2526
2523
  "options": [
2527
2524
  {
2528
2525
  "label": "GET",
@@ -2550,7 +2547,14 @@
2550
2547
  "name": "inputs.url",
2551
2548
  "type": "custom",
2552
2549
  "component": "http-url-field",
2553
- "label": "URL"
2550
+ "label": "URL",
2551
+ "componentProps": {
2552
+ "expressionValidationFields": [
2553
+ {
2554
+ "expectedType": "string"
2555
+ }
2556
+ ]
2557
+ }
2554
2558
  }
2555
2559
  ]
2556
2560
  },
@@ -2564,11 +2568,10 @@
2564
2568
  "name": "inputs.headers",
2565
2569
  "type": "custom",
2566
2570
  "component": "key-value-editor",
2567
- "label": "HTTP Headers",
2571
+ "label": "HTTP headers",
2568
2572
  "componentProps": {
2569
- "keyLabel": "Header Name",
2570
- "valueLabel": "Header Value",
2571
- "keyDefault": "Content-Type",
2573
+ "keyLabel": "Header name",
2574
+ "valueLabel": "Header value",
2572
2575
  "keyOptions": [
2573
2576
  "Accept",
2574
2577
  "Accept-Encoding",
@@ -2596,7 +2599,7 @@
2596
2599
  },
2597
2600
  {
2598
2601
  "id": "parameters",
2599
- "title": "Query Parameters",
2602
+ "title": "Query parameters",
2600
2603
  "collapsible": true,
2601
2604
  "defaultExpanded": false,
2602
2605
  "fields": [
@@ -2604,10 +2607,10 @@
2604
2607
  "name": "inputs.queryParams",
2605
2608
  "type": "custom",
2606
2609
  "component": "key-value-editor",
2607
- "label": "Query Parameters",
2610
+ "label": "Query parameters",
2608
2611
  "componentProps": {
2609
- "keyLabel": "Parameter Name",
2610
- "valueLabel": "Parameter Value"
2612
+ "keyLabel": "Parameter name",
2613
+ "valueLabel": "Parameter value"
2611
2614
  }
2612
2615
  }
2613
2616
  ]
@@ -2621,7 +2624,7 @@
2621
2624
  {
2622
2625
  "name": "inputs.contentType",
2623
2626
  "type": "select",
2624
- "label": "Content Type",
2627
+ "label": "Content type",
2625
2628
  "options": [
2626
2629
  {
2627
2630
  "label": "application/json",
@@ -2647,7 +2650,9 @@
2647
2650
  "component": "code-editor",
2648
2651
  "label": "Body",
2649
2652
  "componentProps": {
2650
- "language": "json",
2653
+ "language": "javascript",
2654
+ "mode": "expression",
2655
+ "expectedType": "any",
2651
2656
  "minHeight": 150,
2652
2657
  "placeholder": "{\n \"key\": \"value\"\n}"
2653
2658
  }
@@ -2664,8 +2669,17 @@
2664
2669
  "name": "inputs.branches",
2665
2670
  "type": "custom",
2666
2671
  "component": "http-branch-editor",
2667
- "label": "Response Branches",
2668
- "description": "Define conditional branches based on response status or properties"
2672
+ "label": "Response branches",
2673
+ "description": "Define conditional branches based on response status or properties",
2674
+ "componentProps": {
2675
+ "expressionValidationFields": [
2676
+ {
2677
+ "subPath": "conditionExpression",
2678
+ "validationMode": "expression",
2679
+ "expectedType": "boolean"
2680
+ }
2681
+ ]
2682
+ }
2669
2683
  }
2670
2684
  ]
2671
2685
  },
@@ -2684,7 +2698,7 @@
2684
2698
  {
2685
2699
  "name": "inputs.retryCount",
2686
2700
  "type": "number",
2687
- "label": "Retry Count",
2701
+ "label": "Retry count",
2688
2702
  "description": "Number of times to retry on failure"
2689
2703
  }
2690
2704
  ]
@@ -2695,7 +2709,7 @@
2695
2709
  "core.action.http.v2@2.3": {
2696
2710
  "nodeType": "core.action.http.v2",
2697
2711
  "version": "2.3",
2698
- "category": "data-operations",
2712
+ "category": "connector",
2699
2713
  "description": "HTTP request with managed authentication",
2700
2714
  "tags": [
2701
2715
  "connector",
@@ -3255,6 +3269,20 @@
3255
3269
  "form": {
3256
3270
  "id": "http-v2-properties",
3257
3271
  "title": "HTTP Request",
3272
+ "metadata": {
3273
+ "propertyPanel": {
3274
+ "tabs": [
3275
+ {
3276
+ "id": "branching",
3277
+ "title": "Branching"
3278
+ }
3279
+ ],
3280
+ "sectionTabs": {
3281
+ "branches": "branching",
3282
+ "advanced": "advanced"
3283
+ }
3284
+ }
3285
+ },
3258
3286
  "sections": [
3259
3287
  {
3260
3288
  "id": "http-config",
@@ -4406,7 +4434,7 @@
4406
4434
  "core.action.queue.create@1.2": {
4407
4435
  "nodeType": "core.action.queue.create",
4408
4436
  "version": "1.2",
4409
- "category": "data-operations",
4437
+ "category": "queue-tools",
4410
4438
  "description": "Add an item to an Orchestrator queue",
4411
4439
  "tags": [
4412
4440
  "queue",
@@ -4438,6 +4466,16 @@
4438
4466
  "id": "success",
4439
4467
  "type": "source",
4440
4468
  "handleType": "output"
4469
+ },
4470
+ {
4471
+ "id": "error",
4472
+ "label": "Error",
4473
+ "type": "source",
4474
+ "handleType": "output",
4475
+ "visible": "{inputs.errorHandlingEnabled}",
4476
+ "constraints": {
4477
+ "maxConnections": 1
4478
+ }
4441
4479
  }
4442
4480
  ]
4443
4481
  }
@@ -4571,6 +4609,13 @@
4571
4609
  "form": {
4572
4610
  "id": "create-queue-item-properties",
4573
4611
  "title": "Create queue item",
4612
+ "metadata": {
4613
+ "propertyPanel": {
4614
+ "sectionTabs": {
4615
+ "advanced": "advanced"
4616
+ }
4617
+ }
4618
+ },
4574
4619
  "sections": [
4575
4620
  {
4576
4621
  "id": "queue-selection",
@@ -4675,7 +4720,7 @@
4675
4720
  "core.action.queue.create-and-wait@1.2": {
4676
4721
  "nodeType": "core.action.queue.create-and-wait",
4677
4722
  "version": "1.2",
4678
- "category": "data-operations",
4723
+ "category": "queue-tools",
4679
4724
  "description": "Add a queue item and wait for it to complete",
4680
4725
  "tags": [
4681
4726
  "queue",
@@ -4708,6 +4753,16 @@
4708
4753
  "id": "success",
4709
4754
  "type": "source",
4710
4755
  "handleType": "output"
4756
+ },
4757
+ {
4758
+ "id": "error",
4759
+ "label": "Error",
4760
+ "type": "source",
4761
+ "handleType": "output",
4762
+ "visible": "{inputs.errorHandlingEnabled}",
4763
+ "constraints": {
4764
+ "maxConnections": 1
4765
+ }
4711
4766
  }
4712
4767
  ]
4713
4768
  }
@@ -4841,6 +4896,13 @@
4841
4896
  "form": {
4842
4897
  "id": "create-and-wait-queue-item-properties",
4843
4898
  "title": "Create and wait for queue item",
4899
+ "metadata": {
4900
+ "propertyPanel": {
4901
+ "sectionTabs": {
4902
+ "advanced": "advanced"
4903
+ }
4904
+ }
4905
+ },
4844
4906
  "sections": [
4845
4907
  {
4846
4908
  "id": "queue-selection",
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
- if (typeof model.bindings.resourceKey === 'string' && model.bindings.resourceKey)
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: { source: 'snapshot', nodeType: def.nodeType, version: def.version, manifest: def },
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, and compile and check refuse it (BINDING_MISSING) `
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 computed expression' },
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 value that is no `$vars.` path is the serializer's HITL_FIELD_VALUE_NOT_REF
257
- // (a constant) or HITL_FIELD_VALUE_NOT_PATH (an expression).
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`: the platform resolves it as a path against the
289
- * workflow's variables (`vars.<flowInput>`, `vars.<node>.output.<field>`), so the
290
- * `$vars.` prefix our expressions carry is dropped. A computed expression cannot
291
- * be a path — `refuseUnwritable` refuses one (HITL_FIELD_VALUE_NOT_PATH) before we get here.
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, a computed field binding that
315
- * resolves to nothing), and `compile` refused all of them before #1497.
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
- if (value.literal || !/^\$vars\.[A-Za-z0-9_]+(\.[A-Za-z0-9_]+)*$/.test(value.js.trim())) {
451
- throw new CompileRefusal('HITL_FIELD_VALUE_NOT_PATH', `Human task "${step}" fills the form field "${id}" from the expression `
452
- + `"${value.literal ? String(value.value) : value.js.trim().slice(0, 60)}". A field binding is `
453
- + `a variable PATH, so a computed expression resolves to nothing on the deployed form. `
454
- + `Compute it in a script step first and point the field at that step's output.`, `value: out('<scriptStep>')`);
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
- emittedDefs.set(`${type}@${def.version}`, def);
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",
3
+ "version": "6.85.5",
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": "78e095c8f23759ce52656ba998e071c274a11c03"
106
+ "gitref": "a60a4c0ce7835f89af7abf7fdd2e6c05c0925789"
107
107
  }