@uipath/maestro-builder-sdk 6.86.9 → 6.86.11

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.
@@ -98,6 +98,20 @@ function addSlaRefs(slas, refs, seen) {
98
98
  claim(escalation.id, escalation.displayName, refs.escalationNameById);
99
99
  }
100
100
  }
101
+ /**
102
+ * The name a task goes by in the source: its `displayName`, or, for a task
103
+ * saved with no `displayName`, its id. The builder keys a task by name (rule
104
+ * `tasks` references, the case-wide uniqueness check, every preserved row that
105
+ * locates a task), so an unnamed task needs one that is stable and unique: two
106
+ * unnamed tasks would both be `""`, and a `selected-tasks-completed` rule could
107
+ * not name either. Compile writes no `displayName` back while the task still
108
+ * goes by its id (`omitTaskDisplayNames` in preserve.ts).
109
+ */
110
+ function taskSourceName(task) {
111
+ if (task.displayName !== undefined)
112
+ return task.displayName;
113
+ return typeof task.id === 'string' ? task.id : '';
114
+ }
101
115
  function buildRefs(plan, library, diagnostics) {
102
116
  const refs = {
103
117
  stageLabelById: new Map(),
@@ -119,9 +133,11 @@ function buildRefs(plan, library, diagnostics) {
119
133
  refs.stageLabelById.set(node.id, node.data.label);
120
134
  addSlaRefs(node.data?.slaRules, refs, seenSlaIds);
121
135
  for (const lane of node.data?.tasks ?? [])
122
- for (const task of lane)
123
- if (task.id && task.displayName)
124
- refs.taskNameById.set(task.id, task.displayName);
136
+ for (const task of lane) {
137
+ const name = taskSourceName(task);
138
+ if (task.id && name)
139
+ refs.taskNameById.set(task.id, name);
140
+ }
125
141
  }
126
142
  addSlaRefs(plan.metadata?.slaRules, refs, seenSlaIds);
127
143
  return refs;
@@ -1333,7 +1349,7 @@ function ioArg(rows, kind, task) {
1333
1349
  return `{ ${entries.join(', ')} }`;
1334
1350
  }
1335
1351
  function emitTask(out, depth, task, lane, refs, library) {
1336
- out.line(depth, `.task(${tsLiteral(task.displayName ?? '')}, t => t`);
1352
+ out.line(depth, `.task(${tsLiteral(taskSourceName(task))}, t => t`);
1337
1353
  const inner = depth + 1;
1338
1354
  out.line(inner, emitTaskKind(task, refs, library));
1339
1355
  if (ownEntry(TASK_KIND_METHOD, task.type) || isAuthorableBusinessRule(task)) {
@@ -2098,6 +2114,16 @@ function emptyLists(owner, fields) {
2098
2114
  });
2099
2115
  return empty.length ? { emptyLists: empty } : {};
2100
2116
  }
2117
+ /**
2118
+ * `{ noTasks }` when a stage with no task spells it as no `tasks` field
2119
+ * (`'absent'`) or as `tasks: []` (`'empty'`), not as the one empty task set
2120
+ * the serializer writes (`[[]]`); see `noTasks` in preserve.ts.
2121
+ */
2122
+ function noTasksSpelling(data) {
2123
+ if (data.tasks === undefined)
2124
+ return { noTasks: 'absent' };
2125
+ return Array.isArray(data.tasks) && data.tasks.length === 0 ? { noTasks: 'empty' } : {};
2126
+ }
2101
2127
  /**
2102
2128
  * A structured root variable the Designer saved with its schema in `body`
2103
2129
  * only. Compile writes a structured variable's schema twice, `body` and the
@@ -2132,7 +2158,7 @@ function identityPreservation(plan) {
2132
2158
  label: stage.data?.label ?? '',
2133
2159
  ...(stage.id ? { id: stage.id } : {}),
2134
2160
  tasks: (stage.data?.tasks ?? []).map((lane) => lane.map((task) => ({
2135
- name: task.displayName ?? '',
2161
+ name: taskSourceName(task),
2136
2162
  ...(task.id ? { id: task.id } : {}),
2137
2163
  entryConditions: (task.entryConditions ?? []).map(conditionIdentity),
2138
2164
  ...emptyLists(task, TASK_EMPTY_LISTS),
@@ -2155,6 +2181,7 @@ function identityPreservation(plan) {
2155
2181
  exitConditions: (stage.data?.exitConditions ?? []).map(conditionIdentity),
2156
2182
  slaRules: (stage.data?.slaRules ?? []).map(slaIdentity),
2157
2183
  ...emptyLists(stage.data ?? {}, STAGE_EMPTY_LISTS),
2184
+ ...noTasksSpelling(stage.data ?? {}),
2158
2185
  };
2159
2186
  }),
2160
2187
  caseExitRules: (plan.metadata?.caseExitRules ?? []).map(conditionIdentity),
@@ -2238,7 +2265,7 @@ function savedResourceWires(plan) {
2238
2265
  continue;
2239
2266
  }
2240
2267
  wires.push({
2241
- stage: stage.data?.label ?? '', task: task.displayName ?? '', ...(task.id ? { taskId: task.id } : {}),
2268
+ stage: stage.data?.label ?? '', task: taskSourceName(task), ...(task.id ? { taskId: task.id } : {}),
2242
2269
  kind, ref, data: saved, rows: wireRows(saved, planRows),
2243
2270
  });
2244
2271
  }
@@ -2464,7 +2491,7 @@ export function collectPreservation(plan) {
2464
2491
  // A source document that carries no `elementId` must not gain one: see
2465
2492
  // `omitTaskElementIds` in preserve.ts.
2466
2493
  if (!Object.prototype.hasOwnProperty.call(task, 'elementId'))
2467
- omitTaskElementIds.push({ stage: label, lane: laneIndex, task: task.displayName ?? '' });
2494
+ omitTaskElementIds.push({ stage: label, lane: laneIndex, task: taskSourceName(task) });
2468
2495
  // A task saved with no name must not gain `displayName: ""`: see
2469
2496
  // `omitTaskDisplayNames` in preserve.ts.
2470
2497
  if (task.displayName === undefined && typeof task.id === 'string' && task.id !== '')
@@ -2473,7 +2500,7 @@ export function collectPreservation(plan) {
2473
2500
  for (const field of Object.keys(fields))
2474
2501
  throw new Error(`task "${task.displayName ?? task.id ?? '?'}" has unsupported field "${field}", which is not allowed in the collision-refusing preservation channel.`);
2475
2502
  if (Object.keys(fields).length)
2476
- taskFields.push({ stage: label, lane: laneIndex, task: task.displayName ?? '', fields });
2503
+ taskFields.push({ stage: label, lane: laneIndex, task: taskSourceName(task), fields });
2477
2504
  // The Designer's half of a connector task's configuration, which compile
2478
2505
  // does not rebuild: its saved field list is what the next decompile
2479
2506
  // carries `carriedFields` from (#1362).
@@ -2494,7 +2521,7 @@ export function collectPreservation(plan) {
2494
2521
  saved[row.name] = data[field];
2495
2522
  }
2496
2523
  actionDataFields.push({
2497
- stage: label, lane: laneIndex, task: task.displayName ?? '', fields: carried,
2524
+ stage: label, lane: laneIndex, task: taskSourceName(task), fields: carried,
2498
2525
  app: data.name !== undefined, ...(Object.keys(saved).length ? { saved } : {}),
2499
2526
  });
2500
2527
  }
@@ -2503,14 +2530,14 @@ export function collectPreservation(plan) {
2503
2530
  const optionalConfiguration = connector && savedOptionalConfiguration(task);
2504
2531
  if (connector && optionalConfiguration)
2505
2532
  connectorConfigurations.push({
2506
- stage: label, lane: laneIndex, task: task.displayName ?? '', connector, optionalConfiguration,
2533
+ stage: label, lane: laneIndex, task: taskSourceName(task), connector, optionalConfiguration,
2507
2534
  cachedFieldValues: cachedFieldValues(task, optionalConfiguration),
2508
2535
  });
2509
2536
  // An http-request task's metadata from another connector version than the
2510
2537
  // vendored copy compile writes: carried, so the round trip keeps it.
2511
2538
  const metadata = task.type === 'http-request' ? savedHttpRequestMetadata(task.data) : undefined;
2512
2539
  if (metadata)
2513
- httpRequestMetadata.push({ stage: label, lane: laneIndex, task: task.displayName ?? '', metadata });
2540
+ httpRequestMetadata.push({ stage: label, lane: laneIndex, task: taskSourceName(task), metadata });
2514
2541
  }));
2515
2542
  }
2516
2543
  if (taskFields.length)
@@ -212,6 +212,15 @@ interface StageIdentity {
212
212
  slaRules?: SlaIdentity[];
213
213
  /** Fields of `STAGE_EMPTY_LISTS` the read stage's `data` spelled `[]`. */
214
214
  emptyLists?: string[];
215
+ /**
216
+ * How the read stage spelled "no tasks", when not as one empty task set:
217
+ * `'absent'` (no `tasks` field) or `'empty'` (`tasks: []`). The builder holds
218
+ * a stage with no task as one empty set and the serializer writes
219
+ * `tasks: [[]]`; the Designer writes all three. The platform reads them
220
+ * alike (`tasks ?? []`, flattened), so this is the Designer's spelling only.
221
+ * Compile writes it back while every task set of the stage is still empty.
222
+ */
223
+ noTasks?: 'absent' | 'empty';
215
224
  }
216
225
  /**
217
226
  * The lists the serializer omits when empty, which the Designer writes both as
@@ -415,13 +424,16 @@ export interface CaseJsonPreservation {
415
424
  omitTaskElementIds?: PreservedTaskRef[];
416
425
  /**
417
426
  * Ids of the tasks the source saved with no `displayName`. The builder names
418
- * every task (`.task("", ...)` for such a task), and the serializer writes
419
- * `displayName: ""`. The two are not the same to the platform: the converter
420
- * embeds each task's JSON verbatim in the BPMN it writes
421
- * (`serializeTaskForCaseManagement` in `@uipath/case-schema`), and its
422
- * validation names a task `displayName ?? data.name ?? id`, so `""` would
423
- * replace the fallback. Compile removes the field from a listed task while
424
- * its name is still `""`; a task the author named keeps its name.
427
+ * every task, so decompile names such a task by its id
428
+ * (`.task("tWait1", ...)`): unique, so two unnamed tasks do not collide, and
429
+ * a `selected-tasks-completed` rule can name it (`tasks: ["tWait1"]`). The
430
+ * serializer writes the name as `displayName`, which is not the same as no
431
+ * field to the platform: the converter embeds each task's JSON verbatim in
432
+ * the BPMN it writes (`serializeTaskForCaseManagement` in
433
+ * `@uipath/case-schema`), and its validation names a task
434
+ * `displayName ?? data.name ?? id`. Compile removes the field from a listed
435
+ * task while its name is still its id (or `""`, the name an older decompile
436
+ * gave it); a task the author renamed keeps its name.
425
437
  */
426
438
  omitTaskDisplayNames?: string[];
427
439
  /** Opaque wire identities aligned to typed constructs by name and position. */
@@ -856,13 +856,14 @@ export function applyPreservation(result, preservation, options = {}) {
856
856
  delete result.layout;
857
857
  applyResourceWires(result, preservation.resourceWires);
858
858
  // Last, after every lookup of a task by its name: a task the source saved
859
- // with no name gets none back while it is still unnamed (preserve.ts).
859
+ // with no name gets none back while it still goes by its id, the name
860
+ // decompile gave it (preserve.ts).
860
861
  if (preservation.omitTaskDisplayNames?.length) {
861
862
  const unnamed = new Set(preservation.omitTaskDisplayNames);
862
863
  for (const stage of stageNodes)
863
864
  for (const lane of stage.data?.tasks ?? [])
864
865
  for (const task of lane)
865
- if (unnamed.has(task?.id) && task.displayName === '')
866
+ if (unnamed.has(task?.id) && (task.displayName === task.id || task.displayName === ''))
866
867
  delete task.displayName;
867
868
  }
868
869
  // Root rows of the original that compile does not write itself
@@ -1202,6 +1203,21 @@ function restoreEmptyLists(owner, wanted, fields) {
1202
1203
  if (typeof field === 'string' && fields.includes(field) && owner[field] === undefined)
1203
1204
  owner[field] = [];
1204
1205
  }
1206
+ /**
1207
+ * Write a stage's read "no tasks" spelling back (`noTasks` in preserve.ts):
1208
+ * no `tasks` field, or `tasks: []`, in place of the serializer's `[[]]`. A
1209
+ * stage an edit gave a task is left alone.
1210
+ */
1211
+ function restoreNoTasks(data, spelling) {
1212
+ if (!data || (spelling !== 'absent' && spelling !== 'empty'))
1213
+ return;
1214
+ if (!Array.isArray(data.tasks) || !data.tasks.every((set) => Array.isArray(set) && set.length === 0))
1215
+ return;
1216
+ if (spelling === 'absent')
1217
+ delete data.tasks;
1218
+ else
1219
+ data.tasks = [];
1220
+ }
1205
1221
  function applyPreservedIdentities(result, preservation) {
1206
1222
  const identities = preservation.identities;
1207
1223
  if (!identities)
@@ -1440,6 +1456,7 @@ function applyPreservedIdentities(result, preservation) {
1440
1456
  takeConditions(stage?.data?.exitConditions, stageIdentity.exitConditions);
1441
1457
  takeSlas(stage?.data?.slaRules, stageIdentity.slaRules);
1442
1458
  restoreEmptyLists(stage?.data, stageIdentity.emptyLists, STAGE_EMPTY_LISTS);
1459
+ restoreNoTasks(stage?.data, stageIdentity.noTasks);
1443
1460
  (stageIdentity.tasks ?? []).forEach((lane) => lane.forEach((taskIdentity) => {
1444
1461
  const task = stageTask(stage, taskIdentity.name);
1445
1462
  // Rows' carried fields describe the resource the task named when it was
package/dist/check.js CHANGED
@@ -1778,12 +1778,11 @@ function checkNodeUpdates(built, diags) {
1778
1778
  visit(built.steps);
1779
1779
  }
1780
1780
  /**
1781
- * Diagnose a root's trigger: a registered trigger through its own rules
1782
- * (FLOW_TRIGGER_TYPES), and the connector event here.
1781
+ * Diagnose a root's trigger through its own rules (FLOW_TRIGGER_TYPES).
1783
1782
  *
1784
1783
  * A connector event's subscription is checked identically for `onEvent()` (the
1785
1784
  * start trigger) and `waitForEvent()` (the mid-flow wait), because they subscribe
1786
- * the same way.
1785
+ * the same way: both types run the shared rules through `eventSubscription`.
1787
1786
  *
1788
1787
  * ## `where` is the connector's event parameters — and NOT every operation has any
1789
1788
  *
@@ -1827,15 +1826,8 @@ function checkTrigger(spec, at, diags, opts = {}) {
1827
1826
  diags.push({ level, code, message, step, ...(suggestion ? { suggestion } : {}) });
1828
1827
  };
1829
1828
  // Types are stripped at run time, so `.trigger({ every: 'R/PT1H' })` (the spec
1830
- // object without its factory) or a typo'd kind reaches here intact.
1831
- if (spec?.kind === 'event') {
1832
- const sub = spec.subscription;
1833
- // As for waitForEvent: what compile refuses is the serializer's.
1834
- checkEventSubscription(sub, 'trigger', push('error'), push('warning'), eventParamsFor(sub, opts), false);
1835
- checkEventResolution(sub, 'trigger', 'trigger', opts, push('error'), push('warning'), eventParamsFor(sub, opts), false);
1836
- return;
1837
- }
1838
- // Anything not registered here is not a trigger: the serializer's TRIGGER_UNKNOWN_KIND.
1829
+ // object without its factory) or a typo'd kind reaches here intact. Anything
1830
+ // not registered is not a trigger: the serializer's TRIGGER_UNKNOWN_KIND.
1839
1831
  const kind = spec?.kind;
1840
1832
  const registered = typeof kind === 'string' ? FLOW_TRIGGER_TYPES.byKind(kind) : undefined;
1841
1833
  if (!registered)
@@ -1851,6 +1843,13 @@ function checkTrigger(spec, at, diags, opts = {}) {
1851
1843
  // Key order as every family's diagnostics give it (`catalogued`) — `check --json` prints it.
1852
1844
  diags.push({ level: known.severity, code, step, message, ...(suggestion !== undefined ? { suggestion } : {}) });
1853
1845
  },
1846
+ // The subscription rules a wait runs, in the order their diagnostics have
1847
+ // always had; what compile refuses (the event, its filters, its labels) is the serializer's.
1848
+ eventSubscription: (subscription, where) => {
1849
+ const params = eventParamsFor(subscription, opts);
1850
+ checkEventSubscription(subscription, where, push('error'), push('warning'), params, false);
1851
+ checkEventResolution(subscription, where, 'trigger', opts, push('error'), push('warning'), params, false);
1852
+ },
1854
1853
  });
1855
1854
  }
1856
1855
  /** A release key is a GUID — the shape 45/45 deployed rpa node types carry. */
package/dist/decompile.js CHANGED
@@ -44,12 +44,9 @@ import { FLOW_TYPE_NAMES, nonFlowTypeReplacement, runtimeEquivalentFlowType } fr
44
44
  import { outputBackingGlobal, outputBackingName } from './flow-output-backing.js';
45
45
  import { mapJsCode } from './core/js-code-spans.js';
46
46
  import { VARS_READ_RE } from './core/vars-read.js';
47
- import { missingBindingLabels } from './core/binding-messages.js';
48
- import { placeholder, prepareCommand } from './core/cli-spelling.js';
49
47
  import { OUTCOME_HANDLE_NODE_TYPES } from './core/hitl-routing.js';
50
48
  import { contributionPort, forwardFanOut } from './core/definition-handles.js';
51
49
  import { STICKY_NOTE_TYPE } from './core/definitionless-node-types.js';
52
- import { eventFilterFromTreeLeaf } from './core/event-filters.js';
53
50
  import { bindingValueRows, referencedBindingNames } from './core/contribution-bindings.js';
54
51
  import { builtChainSource, chainStatements } from './core/builder-chain.js';
55
52
  /**
@@ -323,9 +320,12 @@ const T = {
323
320
  terminate: 'core.logic.terminate',
324
321
  end: 'core.control.end',
325
322
  };
326
- /** A trigger node's type (its id is always `start`). */
323
+ /**
324
+ * A trigger node's type: a registered trigger's, or any `core.trigger.*`, which
325
+ * stays a root with an unsupported-trigger marker when no type reads it.
326
+ */
327
327
  function isTrigger(type) {
328
- return type.startsWith('core.trigger.') || type.startsWith('uipath.connector.event.') || type.startsWith('uipath.connector.trigger.');
328
+ return type.startsWith('core.trigger.') || FLOW_TRIGGER_TYPES.byTypeName(type) !== undefined;
329
329
  }
330
330
  // ─── Injection-safe source emitters (ported verbatim from case/decompile.ts) ──
331
331
  /** A boolean literal, coerced so an untrusted non-boolean can never reach source verbatim. */
@@ -947,98 +947,6 @@ function emitStepSpec(node, imp, inputNames, o, graph) {
947
947
  * Returns `undefined` when the node is not one of them, so the caller can fall
948
948
  * through to the next arm.
949
949
  */
950
- /**
951
- * A connector EVENT subscription, shared by the trigger (`onEvent`) and the
952
- * mid-flow wait (`waitForEvent`) — the same node body in both places, so the
953
- * same inversion serves both.
954
- *
955
- * The `where` scope comes back from `detail.eventParameters`, which carries it
956
- * verbatim; the `contains` filters from the filter tree inside
957
- * `detail.configuration`. Both are also encoded into the generated
958
- * `filterExpression` string, but reading the structured copies avoids parsing a
959
- * string this file generated.
960
- */
961
- /**
962
- * A connector-bound node the file carries UNBOUND: Studio Web saves a draft whose
963
- * connection was never picked as `connectionId: null`. The source cannot invent
964
- * labels for it, and `check` refuses a node without both (BINDING_MISSING, the
965
- * rule `flow validate` applies too: flow-builder-sdk#890), and so does `compile`
966
- * unless it is a carried canvas draft (`{ draft: true }`). So the source says so
967
- * at the node and the run warns once, instead of handing back a file whose first
968
- * compile fails with no context. Returns the inline marker, or '' when bound.
969
- */
970
- function unboundMarker(node, labels, key, action) {
971
- const missing = missingBindingLabels(labels);
972
- if (missing.length === 0)
973
- return '';
974
- const names = missing.join(' and ');
975
- warnOnce(`node ${tsLiteral(node.id)} (${node.type}) has no ${missing.join(' or ')} in the .flow (an unbound draft). `
976
- + `The source leaves ${missing.length > 1 ? 'them' : 'it'} out${isCanvasDraft(node)
977
- ? ' and marks the step `{ draft: true }`: compile writes it as a draft, and check refuses it'
978
- : ', and compile and check refuse it'} (BINDING_MISSING) until it names both labels: `
979
- + `run \`${prepareCommand(key, action ?? placeholder('<action>'))}\`, then pass `
980
- + `\`connection\` and \`folder\`.`);
981
- return ` /* TODO: bind ${commentText(names)}; check refuses this node until it has both labels (BINDING_MISSING) */`;
982
- }
983
- function emitEventSubscription(node, imp, inputNames) {
984
- const prefix = node.type.startsWith('uipath.connector.event.') ? 'uipath.connector.event.'
985
- : node.type.startsWith('uipath.connector.trigger.') ? 'uipath.connector.trigger.'
986
- : undefined;
987
- if (prefix === undefined)
988
- return undefined;
989
- const rest = node.type.slice(prefix.length);
990
- const dot = rest.lastIndexOf('.');
991
- if (dot <= 0)
992
- return undefined;
993
- const connector = rest.slice(0, dot);
994
- const event = rest.slice(dot + 1);
995
- const detail = (node.inputs ?? {}).detail;
996
- const where = (detail?.eventParameters ?? {});
997
- const whereRows = Object.entries(where)
998
- .filter(([, v]) => v !== undefined && v !== null && String(v) !== '')
999
- .map(([k, v]) => [k, emitVal(v, imp, inputNames)]);
1000
- // The filter tree lives inside the `=jsonString:` configuration blob, and so
1001
- // does the one fact that says whether `detail.objectName` was the AUTHOR's
1002
- // choice: a GENERIC event (`activityType: GenericTrigger`) carries the object
1003
- // the author named, a curated one carries its built-in object.
1004
- let filterRows = [];
1005
- let generic = false;
1006
- const config = detail?.configuration;
1007
- if (typeof config === 'string' && config.startsWith('=jsonString:')) {
1008
- try {
1009
- const parsed = JSON.parse(config.slice('=jsonString:'.length));
1010
- generic = parsed?.essentialConfiguration?.instanceParameters?.activityType === 'GenericTrigger';
1011
- const tree = parsed?.essentialConfiguration?.filter;
1012
- const rows = (tree?.filters ?? []);
1013
- filterRows = rows
1014
- .map((f) => eventFilterFromTreeLeaf(f))
1015
- .filter((f) => f !== undefined)
1016
- .map((f) => opts([
1017
- ['field', tsLiteral(f.field)],
1018
- [f.operator, typeof f.value === 'string' ? tsLiteral(f.value) : JSON.stringify(f.value)],
1019
- ]));
1020
- }
1021
- catch {
1022
- // A hand-edited blob is not ours to guess at — the scope and identity
1023
- // still recover, and the filters simply do not come back.
1024
- filterRows = [];
1025
- }
1026
- }
1027
- const object = generic && typeof detail?.objectName === 'string' && detail.objectName !== ''
1028
- ? detail.objectName
1029
- : undefined;
1030
- const conn = typeof detail?.connectionId === 'string' ? detail.connectionId : undefined;
1031
- const folder = typeof detail?.connectionFolderKey === 'string' ? detail.connectionFolderKey : undefined;
1032
- return opts([
1033
- ['connector', tsLiteral(connector)],
1034
- ['event', tsLiteral(event)],
1035
- ['where', whereRows.length ? objLit(whereRows) : undefined],
1036
- ['object', object !== undefined ? tsLiteral(object) : undefined],
1037
- ['filters', filterRows.length ? `[${filterRows.join(', ')}]` : undefined],
1038
- ['connection', conn !== undefined ? tsLiteral(conn) : undefined],
1039
- ['folder', folder !== undefined ? tsLiteral(folder) : undefined],
1040
- ]) + unboundMarker(node, { connection: conn, folder }, connector, event);
1041
- }
1042
950
  /**
1043
951
  * The definition a `rawNode` carries for `node`. A per-tenant template
1044
952
  * (`<bindings.NAME>` placeholders, empty `resourceKey`) comes back as a copy
@@ -1423,16 +1331,7 @@ function emitVariables(e, depth, flow, imp, epTriggers = new Set(), shared) {
1423
1331
  function triggerFactory(t, imp, inputNames) {
1424
1332
  // A registered trigger (FLOW_TRIGGER_TYPES) lifts and prints itself.
1425
1333
  const registered = FLOW_TRIGGER_TYPES.byTypeName(t.type);
1426
- if (registered) {
1427
- const call = emitRegisteredSpec(t, imp, inputNames, undefined, registered.type);
1428
- if (call !== undefined)
1429
- return call;
1430
- }
1431
- // A connector EVENT trigger — the same subscription body as a mid-flow wait.
1432
- const sub = emitEventSubscription(t, imp, inputNames);
1433
- if (sub !== undefined)
1434
- return `${imp.use('onEvent')}(${sub})`;
1435
- return undefined;
1334
+ return registered ? emitRegisteredSpec(t, imp, inputNames, undefined, registered.type) : undefined;
1436
1335
  }
1437
1336
  function emitTrigger(e, depth, trigger, imp, o, inputNames = new Set(), extra = []) {
1438
1337
  // The trigger's id is addressable — a flow's inputs are published as its
@@ -28,8 +28,8 @@ export interface RegisteredTrigger {
28
28
  * root, and its type name may name a step too (the connector event does).
29
29
  * Built from an explicit list and refused with every problem at once, as the
30
30
  * node-type registry is: family ids, kinds and type names are unique, each
31
- * type's definition is bundled, and no code is claimed by two families, the
32
- * step families included.
31
+ * type's definition is bundled unless it is a prefix type (per-tenant), and no
32
+ * code is claimed by two families, the step families included.
33
33
  */
34
34
  export declare class FlowTriggerRegistry {
35
35
  #private;
@@ -11,7 +11,7 @@ import { adoptContributedFamilies } from './core/nodes/extensions.js';
11
11
  import { bundledVersions, hasBundledDefinition } from './flow-definitions.js';
12
12
  import { agentFlowFamily } from './nodes/agent/flow/family.js';
13
13
  import { aiPatternsFlowFamily } from './nodes/ai-patterns/flow/family.js';
14
- import { connectorFlowFamily } from './nodes/connector/flow/family.js';
14
+ import { connectorFlowFamily, connectorTriggerFamily } from './nodes/connector/flow/family.js';
15
15
  import { conversationFlowFamily } from './nodes/conversation/flow/family.js';
16
16
  import { dataFabricFlowFamily } from './nodes/data-fabric/flow/family.js';
17
17
  import { delayFlowFamily } from './nodes/delay/flow/family.js';
@@ -45,12 +45,13 @@ export function registerFlowNodeFamily(family) {
45
45
  * root, and its type name may name a step too (the connector event does).
46
46
  * Built from an explicit list and refused with every problem at once, as the
47
47
  * node-type registry is: family ids, kinds and type names are unique, each
48
- * type's definition is bundled, and no code is claimed by two families, the
49
- * step families included.
48
+ * type's definition is bundled unless it is a prefix type (per-tenant), and no
49
+ * code is claimed by two families, the step families included.
50
50
  */
51
51
  export class FlowTriggerRegistry {
52
52
  #byKind = new Map();
53
53
  #byTypeName = new Map();
54
+ #byPrefix = [];
54
55
  constructor(families, steps) {
55
56
  const problems = [];
56
57
  const familyIds = new Set();
@@ -77,10 +78,19 @@ export class FlowTriggerRegistry {
77
78
  const byName = this.#byTypeName.get(type.typeName);
78
79
  if (byName)
79
80
  problems.push(`trigger type name "${type.typeName}" is registered twice (${byName.family.id}/${byName.type.kind} and ${where})`);
80
- if (bundledVersions(type.typeName).length === 0)
81
- problems.push(`${where}: ${type.typeName} is not a bundled definition`);
82
81
  this.#byKind.set(type.kind, entry);
83
82
  this.#byTypeName.set(type.typeName, entry);
83
+ if (type.typeNamePrefix !== undefined) {
84
+ if (type.typeName !== `${type.typeNamePrefix}*`)
85
+ problems.push(`${where}: typeName must be typeNamePrefix plus "*"`);
86
+ this.#byPrefix.push({ prefix: type.typeNamePrefix, matches: type.typeNameMatches?.bind(type), entry });
87
+ }
88
+ else if (type.typeNameMatches !== undefined) {
89
+ problems.push(`${where}: typeNameMatches narrows a typeNamePrefix, and the type declares none`);
90
+ }
91
+ else if (bundledVersions(type.typeName).length === 0) {
92
+ problems.push(`${where}: ${type.typeName} is not a bundled definition`);
93
+ }
84
94
  }
85
95
  }
86
96
  if (problems.length > 0) {
@@ -93,7 +103,8 @@ export class FlowTriggerRegistry {
93
103
  }
94
104
  /** The trigger for a root node's type name, or undefined when no registered trigger owns it. */
95
105
  byTypeName(typeName) {
96
- return this.#byTypeName.get(typeName);
106
+ return this.#byTypeName.get(typeName)
107
+ ?? this.#byPrefix.find((p) => typeName.startsWith(p.prefix) && (p.matches?.(typeName) ?? true))?.entry;
97
108
  }
98
109
  /** Every registered trigger kind, sorted. */
99
110
  kinds() {
@@ -101,5 +112,5 @@ export class FlowTriggerRegistry {
101
112
  }
102
113
  }
103
114
  /** The families with start triggers. Adding one is the whole of registering its triggers. */
104
- export const FLOW_TRIGGER_FAMILIES = [triggerFlowFamily];
115
+ export const FLOW_TRIGGER_FAMILIES = [connectorTriggerFamily, triggerFlowFamily];
105
116
  export const FLOW_TRIGGER_TYPES = new FlowTriggerRegistry(FLOW_TRIGGER_FAMILIES, FLOW_NODE_FAMILIES);
@@ -620,15 +620,40 @@ export interface FlowTriggerSerializeContext {
620
620
  readonly version: string | undefined;
621
621
  /**
622
622
  * The stable identity the platform keys a root by: a GUID minted from the
623
- * flow's id and the root's id. Once a flow has more than one root the
624
- * pipeline gives the default root one too, when its type wrote none.
623
+ * flow's id and `seed`, the root's id unless one is given. Once a flow has more
624
+ * than one root the pipeline gives the default root one too, when its type
625
+ * wrote none.
625
626
  */
626
- entryPointId(): string;
627
+ entryPointId(seed?: string): string;
628
+ /** The connector library serialize was given, for a trigger that resolves a connector event. */
629
+ readonly library: SerializeOpts['library'];
630
+ /** What an event subscription's shared emission needs, as `FlowSerializeContext.events`. */
631
+ readonly events: EventEmitEnv;
632
+ /** A symbolic `connection` or `folder` label resolved through bindings.json, as `FlowSerializeContext.resolveBinding`. */
633
+ resolveBinding(name: string | undefined, attribute: 'connection' | 'folder', where: string, target?: {
634
+ key: string;
635
+ action?: string;
636
+ }): string | undefined;
637
+ /** Hoist the connection pair a definition's `model` references, as `FlowSerializeContext.bindConnection`. */
638
+ bindConnection(o: {
639
+ model: unknown;
640
+ connectorKey: string;
641
+ connectionId: string | undefined;
642
+ folderKey?: string;
643
+ }): void;
627
644
  }
628
645
  /** What a trigger's serialize returns; the pipeline places the node from it. */
629
646
  export interface FlowTriggerContribution {
630
647
  /** The version to place, when the spec selects one (a cron schedule needs 1.2); otherwise the author's pin or the definition's default. */
631
648
  readonly version?: string;
649
+ /** The node's type, for a type whose name is a prefix (`typeNamePrefix`); otherwise the type's `typeName`. */
650
+ readonly typeName?: string;
651
+ /**
652
+ * The definition to place the node under, for a per-tenant type (a connector
653
+ * event's library entry); a bundled type's is resolved by type name. Its version
654
+ * is the node's, and a `{ version }` pin it does not have is refused.
655
+ */
656
+ readonly definition?: unknown;
632
657
  /** The node's `inputs`, in the order the file writes them. */
633
658
  readonly inputs: Record<string, unknown>;
634
659
  }
@@ -636,13 +661,32 @@ export interface FlowTriggerCheckContext {
636
661
  readonly root: FlowTriggerRoot;
637
662
  /** Report one of the family's codes (its catalog names the severity) on the root. */
638
663
  report(code: string, message: string, suggestion?: string): void;
664
+ /**
665
+ * Run the rules every event subscription shares, as `FlowCheckContext.eventSubscription`
666
+ * does for a wait, resolving the event as a start trigger; reported on the root
667
+ * under the pipeline's codes.
668
+ */
669
+ eventSubscription(subscription: unknown, where: string): void;
639
670
  }
640
- /** One start trigger's node type. Each is bundled: the pipeline resolves its definition by `typeName`. */
671
+ /**
672
+ * One start trigger's node type. A bundled one's definition is resolved by
673
+ * `typeName`; a per-tenant one (`typeNamePrefix`) supplies its definition from
674
+ * its serialize.
675
+ */
641
676
  export interface FlowTriggerType<Spec> {
642
677
  /** The spec discriminator, e.g. `'scheduled'`. Unique among the triggers. */
643
678
  readonly kind: string;
644
- /** The type name in the file, e.g. `'core.trigger.scheduled'`. Unique among the triggers. */
679
+ /** The type name in the file, e.g. `'core.trigger.scheduled'`, or `typeNamePrefix` plus `*`. Unique among the triggers. */
645
680
  readonly typeName: string;
681
+ /**
682
+ * For a type that is a node type per tenant resource, as a step's
683
+ * `typeNamePrefix` is: the type owns every name under it that
684
+ * `typeNameMatches` accepts, and its serialize names the node's type and
685
+ * supplies its definition.
686
+ */
687
+ readonly typeNamePrefix?: string;
688
+ /** Narrows `typeNamePrefix`, as a step's does. */
689
+ typeNameMatches?(typeName: string): boolean;
646
690
  /** The public factory that produces this spec, e.g. `'scheduled'`. */
647
691
  readonly factory: string;
648
692
  /** What a subflow's own trigger of this type would drop, as SUBFLOW_CHILD_TRIGGER names it; `'trigger'` when unset. */
@@ -0,0 +1,6 @@
1
+ import type { FlowTriggerType } from '../../../flow-node-type.js';
2
+ import type { TriggerSpec } from '../../trigger/flow/index.js';
3
+ export type EventTriggerSpec = Extract<TriggerSpec, {
4
+ kind: 'event';
5
+ }>;
6
+ export declare const eventTriggerType: FlowTriggerType<EventTriggerSpec>;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * A flow started by an Integration Service event — `onEvent(subscription)`, the
3
+ * connector family's start trigger: a node type per event, named
4
+ * `uipath.connector.trigger.<connectorKey>.<event>` or, for an event the library
5
+ * serves under its wait's name, `uipath.connector.event.<connectorKey>.<event>`.
6
+ * The library's resolution of the event names which, so the type owns both
7
+ * prefixes (`typeNameMatches`), and it is per-tenant: its serialize supplies the
8
+ * library's definition, and that names the version.
9
+ *
10
+ * The node's body is the wait's (`event-wait.ts`): `eventDetail` writes
11
+ * `inputs.detail`, and the lift and printer are shared. What differs is the
12
+ * root around it: the platform's entry-point identity, and the sites the
13
+ * refusals name, which keep the wording they had in serialize.ts.
14
+ *
15
+ * Moved from serialize.ts / check.ts / decompile.ts in Phase 4 of
16
+ * docs/NODE_TYPE_ARCHITECTURE_DESIGN.md.
17
+ */
18
+ import { eventDetail, eventTarget, libraryRequiredForEvent, refuseUnverifiedByoa, resolveEvent } from '../../../core/event-subscription.js';
19
+ import { liftSubscription, printSubscription, splitEvent } from './event-wait.js';
20
+ const CONNECTOR_PREFIX = 'uipath.connector.';
21
+ const PREFIXES = [`${CONNECTOR_PREFIX}trigger.`, `${CONNECTOR_PREFIX}event.`];
22
+ function serializeEventTrigger(spec, ctx) {
23
+ const sub = spec.subscription;
24
+ const { root } = ctx;
25
+ const site = root.isDefault ? 'event trigger' : `onEvent() entry point "${root.id}"`;
26
+ if (!ctx.library)
27
+ throw libraryRequiredForEvent(ctx.events, sub, root.id, site, 'onEvent()');
28
+ const rc = resolveEvent(ctx.library, 'trigger', sub, 'trigger');
29
+ refuseUnverifiedByoa(ctx.events, 'trigger', sub);
30
+ const detail = eventDetail(rc, sub, root.id, ctx.events, site);
31
+ // An event trigger's definition declares the same connection binding names a
32
+ // mid-flow connector's does, so the pair goes into the flow's `bindings[]` (G-19).
33
+ const target = eventTarget(sub);
34
+ const bindingSite = root.isDefault ? 'event trigger' : 'onEvent() entry point';
35
+ const connectionId = ctx.resolveBinding(sub.connection, 'connection', bindingSite, target);
36
+ const folderKey = ctx.resolveBinding(sub.folder, 'folder', bindingSite, target);
37
+ ctx.bindConnection({
38
+ model: rc.v1def?.model,
39
+ connectorKey: rc.connectorKey, connectionId,
40
+ ...(folderKey !== undefined ? { folderKey } : {}),
41
+ });
42
+ return {
43
+ typeName: rc.nodeType,
44
+ definition: rc.v1def,
45
+ // The deployed shape: 38 of 39 archived instances carry `entryPointId`, 28
46
+ // carry `isDefaultEntryPoint: true`, and the subscription lives in `detail`.
47
+ // The default root's identity is minted from `start` whatever the root's id,
48
+ // as it was before the port.
49
+ inputs: root.isDefault
50
+ ? { entryPointId: ctx.entryPointId('start'), isDefaultEntryPoint: true, detail }
51
+ : { entryPointId: ctx.entryPointId(), detail },
52
+ };
53
+ }
54
+ export const eventTriggerType = {
55
+ kind: 'event',
56
+ typeName: `${CONNECTOR_PREFIX}*`,
57
+ typeNamePrefix: CONNECTOR_PREFIX,
58
+ // Any name under the two prefixes, an eventless one included: a root of that
59
+ // type is still a trigger, which the lift declines (an unsupported-trigger marker).
60
+ typeNameMatches: (typeName) => PREFIXES.some((p) => typeName.startsWith(p)),
61
+ factory: 'onEvent',
62
+ noun: 'event subscription',
63
+ serialize: serializeEventTrigger,
64
+ deserialize: (node, ctx) => {
65
+ const type = node.type;
66
+ const prefix = PREFIXES.find((p) => type.startsWith(p));
67
+ const split = prefix === undefined ? undefined : splitEvent(type, prefix);
68
+ return split ? liftSubscription(node, split, ctx, false) : undefined;
69
+ },
70
+ print: (spec, ctx) => printSubscription(spec, 'onEvent', ctx),
71
+ // What compile refuses (the event itself, its filters, its binding labels) is the serializer's.
72
+ check: (spec, ctx) => ctx.eventSubscription(spec.subscription, 'trigger'),
73
+ };
@@ -6,10 +6,9 @@
6
6
  * narrowing leaves it alone. Per-tenant: the definition is the library's event
7
7
  * entry, and so is its version (`versionedByDefinition`).
8
8
  *
9
- * The same node type opens a flow as its start trigger (`onEvent`). That place
10
- * stays the pipeline's until the triggers port: serialize places the trigger, and
11
- * decompile reads a root `uipath.connector.event.*` node as one. This type is the
12
- * node as a step, with an incoming edge.
9
+ * The same node type opens a flow as its start trigger (`onEvent`, in
10
+ * `event-trigger.ts`), registered apart from the steps; this type is the node as
11
+ * a step, with an incoming edge. The two share the lift and the printer below.
13
12
  *
14
13
  * The subscription's emission — `inputs.detail`, the library's resolution, the
15
14
  * refusals compile makes with and without a library — is shared with the trigger,
@@ -21,13 +20,49 @@
21
20
  * docs/NODE_TYPE_ARCHITECTURE_DESIGN.md.
22
21
  */
23
22
  import type { ActionSpec } from '../../../core/actions.js';
24
- import type { FlowVersionedNodeType } from '../../../flow-node-type.js';
23
+ import type { FactoryCall } from '../../../core/nodes/node-type.js';
24
+ import type { FlowDeserializeContext, FlowPrintContext, FlowVersionedNodeType } from '../../../flow-node-type.js';
25
25
  export type EventWaitSpec = Extract<ActionSpec, {
26
26
  kind: 'waitEvent';
27
27
  }>;
28
- /** `<connector>.<event>` after the prefix, split on the last dot; undefined for a name with no event. */
29
- export declare function splitEvent(typeName: string): {
28
+ /** `<connector>.<event>` after `prefix`, split on the last dot; undefined for a name with no event. */
29
+ export declare function splitEvent(typeName: string, prefix?: string): {
30
30
  connector: string;
31
31
  event: string;
32
32
  } | undefined;
33
+ /** What the lift recovers; the printer only formats it. */
34
+ export interface LiftedSubscription {
35
+ connector: string;
36
+ event: string;
37
+ where: Array<[string, unknown]>;
38
+ object: string | undefined;
39
+ filters: Array<{
40
+ field: string;
41
+ operator: string;
42
+ value: unknown;
43
+ }>;
44
+ connection: string | undefined;
45
+ folder: string | undefined;
46
+ /** The labels an unbound draft lacks, for the marker the source carries. */
47
+ missing: string[];
48
+ }
49
+ /**
50
+ * The subscription back from the node: the `where` scope from
51
+ * `detail.eventParameters`, which carries it verbatim, and the filters from the
52
+ * filter tree inside `detail.configuration`. Both are also encoded into the
53
+ * generated `filterExpression`, but reading the structured copies avoids parsing
54
+ * a string compile generated. `split` is the event the node's type names.
55
+ * `draftable` says whether an unbound node compiles as a draft (a wait, #1674)
56
+ * or is refused (a trigger), which the unbound warning tells the author.
57
+ */
58
+ export declare function liftSubscription(node: unknown, split: {
59
+ connector: string;
60
+ event: string;
61
+ }, ctx: FlowDeserializeContext, draftable: boolean): LiftedSubscription;
62
+ /**
63
+ * `<factory>({ … })` (`waitForEvent`, `onEvent`), the stringly form: the
64
+ * subscription as one object. The unbound marker sits inside the call, after the
65
+ * object, where the lift has always put it.
66
+ */
67
+ export declare function printSubscription(l: LiftedSubscription, factory: string, ctx: FlowPrintContext): FactoryCall;
33
68
  export declare const eventWaitNodeType: FlowVersionedNodeType<EventWaitSpec>;
@@ -6,11 +6,11 @@ import { eventDetail, eventTarget, libraryRequiredForEvent, refuseUnverifiedByoa
6
6
  import { Expr } from '../../../core/expr.js';
7
7
  import { tsLiteral, tsObject, tsOptions } from '../../../core/ts-literal.js';
8
8
  const EVENT_PREFIX = 'uipath.connector.event.';
9
- /** `<connector>.<event>` after the prefix, split on the last dot; undefined for a name with no event. */
10
- export function splitEvent(typeName) {
11
- if (!typeName.startsWith(EVENT_PREFIX))
9
+ /** `<connector>.<event>` after `prefix`, split on the last dot; undefined for a name with no event. */
10
+ export function splitEvent(typeName, prefix = EVENT_PREFIX) {
11
+ if (!typeName.startsWith(prefix))
12
12
  return undefined;
13
- const rest = typeName.slice(EVENT_PREFIX.length);
13
+ const rest = typeName.slice(prefix.length);
14
14
  const dot = rest.lastIndexOf('.');
15
15
  if (dot <= 0)
16
16
  return undefined;
@@ -88,13 +88,12 @@ function liftValue(v, ctx) {
88
88
  * `detail.eventParameters`, which carries it verbatim, and the filters from the
89
89
  * filter tree inside `detail.configuration`. Both are also encoded into the
90
90
  * generated `filterExpression`, but reading the structured copies avoids parsing
91
- * a string compile generated.
91
+ * a string compile generated. `split` is the event the node's type names.
92
+ * `draftable` says whether an unbound node compiles as a draft (a wait, #1674)
93
+ * or is refused (a trigger), which the unbound warning tells the author.
92
94
  */
93
- function liftEventWait(node, ctx) {
95
+ export function liftSubscription(node, split, ctx, draftable) {
94
96
  const n = node;
95
- const split = splitEvent(n.type);
96
- if (!split)
97
- return undefined;
98
97
  const detail = (n.inputs?.detail ?? undefined);
99
98
  const where = Object.entries((detail?.eventParameters ?? {}))
100
99
  .filter(([, v]) => v !== undefined && v !== null && String(v) !== '')
@@ -127,24 +126,27 @@ function liftEventWait(node, ctx) {
127
126
  const connection = typeof detail?.connectionId === 'string' ? detail.connectionId : undefined;
128
127
  const folder = typeof detail?.connectionFolderKey === 'string' ? detail.connectionFolderKey : undefined;
129
128
  // A connection the file never picked (`connectionId: null`): the source cannot
130
- // invent labels for it, and compile and check refuse a node without both
131
- // (BINDING_MISSING, flow-builder-sdk#890), so the source says so at the node
132
- // and the run warns once.
129
+ // invent labels for it, and check refuses a node without both (BINDING_MISSING,
130
+ // flow-builder-sdk#890); compile writes a draftable one as a draft and refuses
131
+ // the rest. The source says so at the node and the run warns once.
133
132
  const missing = missingBindingLabels({ connection, folder });
134
133
  if (missing.length > 0) {
135
134
  ctx.warn(`node ${tsLiteral(n.id)} (${n.type}) has no ${missing.join(' or ')} in the .flow (an unbound draft). `
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) `
135
+ + `The source leaves ${missing.length > 1 ? 'them' : 'it'} out`
136
+ + (draftable
137
+ ? `. With the file's definition the step is marked \`{ draft: true }\` and compile writes it as a draft; check refuses it (BINDING_MISSING) `
138
+ : `, and compile and check refuse it (BINDING_MISSING) `)
137
139
  + `until it names both labels: run \`${prepareCommand(split.connector, split.event)}\`, then pass `
138
140
  + `\`connection\` and \`folder\`.`);
139
141
  }
140
- return { kind: 'waitEvent', ...split, where, object, filters, connection, folder, missing };
142
+ return { ...split, where, object, filters, connection, folder, missing };
141
143
  }
142
144
  /**
143
- * `waitForEvent({ … })`, the stringly form: the subscription as one object. The
144
- * unbound marker sits inside the call, after the object, where the lift has
145
- * always put it.
145
+ * `<factory>({ … })` (`waitForEvent`, `onEvent`), the stringly form: the
146
+ * subscription as one object. The unbound marker sits inside the call, after the
147
+ * object, where the lift has always put it.
146
148
  */
147
- function printEventWait(l, ctx) {
149
+ export function printSubscription(l, factory, ctx) {
148
150
  const value = (v) => (v instanceof Expr ? ctx.value(v) : ctx.json(v));
149
151
  const filters = l.filters.map((f) => tsOptions([
150
152
  ['field', tsLiteral(f.field)],
@@ -162,7 +164,7 @@ function printEventWait(l, ctx) {
162
164
  const marker = l.missing.length > 0
163
165
  ? ` /* TODO: bind ${commentText(l.missing.join(' and '))}; check refuses this node until it has both labels (BINDING_MISSING) */`
164
166
  : '';
165
- return { factory: 'waitForEvent', positional: [subscription + marker] };
167
+ return { factory, positional: [subscription + marker] };
166
168
  }
167
169
  const eventWait10 = {
168
170
  kind: 'waitEvent', typeName: `${EVENT_PREFIX}*`, version: '1.0.0', factory: 'waitForEvent',
@@ -170,9 +172,12 @@ const eventWait10 = {
170
172
  // An event wait resumes or it does not: it has no error port to route.
171
173
  errorPort: false,
172
174
  serialize: (spec, ctx) => serializeEventWait(spec, ctx),
173
- deserialize: (node, ctx) => liftEventWait(node, ctx),
175
+ deserialize: (node, ctx) => {
176
+ const split = splitEvent(node.type);
177
+ return split ? { kind: 'waitEvent', ...liftSubscription(node, split, ctx, true) } : undefined;
178
+ },
174
179
  isDraft: (node) => isEventWaitDraft(node),
175
- print: (spec, ctx) => printEventWait(spec, ctx),
180
+ print: (spec, ctx) => printSubscription(spec, 'waitForEvent', ctx),
176
181
  check: (spec, ctx) => ctx.eventSubscription(spec.subscription, `waitForEvent "${ctx.step}"`),
177
182
  namedNode: (spec) => {
178
183
  const sub = spec.subscription;
@@ -1,3 +1,8 @@
1
- /** The connector node family, as flow-node-registry.ts lists it: an Integration Service connector operation, and a mid-flow event wait. */
2
- import type { FlowNodeFamily } from '../../../flow-node-type.js';
1
+ /**
2
+ * The connector node family, as flow-node-registry.ts lists it: an Integration
3
+ * Service connector operation and a mid-flow event wait (its steps), and a flow
4
+ * started by an event (its trigger, registered apart from the steps).
5
+ */
6
+ import type { FlowNodeFamily, FlowTriggerFamily } from '../../../flow-node-type.js';
3
7
  export declare const connectorFlowFamily: FlowNodeFamily;
8
+ export declare const connectorTriggerFamily: FlowTriggerFamily;
@@ -1,3 +1,4 @@
1
+ import { eventTriggerType } from './event-trigger.js';
1
2
  import { eventWaitNodeType } from './event-wait.js';
2
3
  import { connectorNodeType } from './node-type.js';
3
4
  export const connectorFlowFamily = {
@@ -7,3 +8,10 @@ export const connectorFlowFamily = {
7
8
  // Its rules' codes are the pipeline's, shared with the triggers (ctx.connector, ctx.eventSubscription).
8
9
  diagnostics: {},
9
10
  };
11
+ export const connectorTriggerFamily = {
12
+ id: 'connector',
13
+ title: 'Integration Service connector',
14
+ triggers: [eventTriggerType],
15
+ // Its rules' codes are the pipeline's (ctx.eventSubscription).
16
+ diagnostics: {},
17
+ };
package/dist/serialize.js CHANGED
@@ -63,7 +63,6 @@ import { SUBFLOW_START_LABEL } from './core/subflow-start.js';
63
63
  import { endContentKey } from './flow-end-content.js';
64
64
  import { terminateStepClashMessage, terminateTwiceMessage } from './flow-terminate-names.js';
65
65
  import { jsonClone } from './core/json-clone.js';
66
- import { eventDetail, eventTarget, libraryRequiredForEvent, refuseUnverifiedByoa, resolveEvent, } from './core/event-subscription.js';
67
66
  import { subNodeId } from './core/node-id-placeholder.js';
68
67
  import { JOB_ATTACHMENT_REF, jobAttachmentDefinition } from './core/agent-sidecar.js';
69
68
  // core-definitions.json is an object keyed by "<nodeType>@<version>".
@@ -558,8 +557,7 @@ export function resolveContributionDefinition(ref, requestedVersion, where) {
558
557
  */
559
558
  function refuseUnknownTrigger(spec, call) {
560
559
  const kind = spec?.kind;
561
- // A registered trigger, or the connector event the pipeline still places.
562
- if (typeof kind === 'string' && (FLOW_TRIGGER_TYPES.byKind(kind) !== undefined || kind === 'event'))
560
+ if (typeof kind === 'string' && FLOW_TRIGGER_TYPES.byKind(kind) !== undefined)
563
561
  return;
564
562
  throw new CompileRefusal('TRIGGER_UNKNOWN_KIND', `${call} was given ${JSON.stringify(kind)}, which is not a trigger. `
565
563
  + `Wrap it in a factory: scheduled({ every: 'R/PT1H' }) for a schedule, `
@@ -1878,7 +1876,7 @@ function serializeFlow(built, opts) {
1878
1876
  const kind = child.trigger?.kind;
1879
1877
  const registered = typeof kind === 'string' ? FLOW_TRIGGER_TYPES.byKind(kind)?.type : undefined;
1880
1878
  if (child.trigger !== undefined && !registered?.subflowStart) {
1881
- const noun = registered?.noun ?? (kind === 'event' ? 'event subscription' : 'trigger');
1879
+ const noun = registered?.noun ?? 'trigger';
1882
1880
  throw new CompileRefusal('SUBFLOW_CHILD_TRIGGER', `Subflow "${step}" runs a flow with its own \`.trigger(…)\`. A subflow is started by its caller, never by a `
1883
1881
  + `trigger of its own — the ${noun} would be dropped. Remove the .trigger() from "${child.id}" `
1884
1882
  + `(\`.trigger(manual(), { label })\` is allowed, to name the child's start node).`);
@@ -1994,34 +1992,20 @@ function serializeFlow(built, opts) {
1994
1992
  }
1995
1993
  // The start node. Manual unless the flow named another trigger — the node id
1996
1994
  // stays `start` either way, so edges, `triggerNodeId` on flow inputs, and the
1997
- // `successPort` default ('output', which both trigger defs use) are untouched.
1998
- // A connector EVENT trigger is resolved from the library like any connector
1999
- // node — its definition ships there with its `.v1def.json` sidecar — and it
2000
- // replaces the start node's TYPE, exactly as the scheduled trigger does. The
2001
- // node id stays `start`, so edges, `triggerNodeId` on flow inputs and the
2002
- // `output` success port are untouched. In collect mode a refused trigger is
2003
- // stood in (`emitRootNode`), so the steps after it are still judged.
1995
+ // `successPort` default ('output', which every trigger def uses) are untouched.
1996
+ // In collect mode a refused trigger is stood in (`emitRootNode`), so the steps
1997
+ // after it are still judged.
2004
1998
  //
2005
1999
  // The trigger node's id is `start` unless the flow renamed it. `input('x')`
2006
2000
  // lowered eagerly to `$vars.start.output.x`, so a rename is applied by the
2007
2001
  // same `renameRefs` pass that rewrites step names (see `rename.nodeIds`).
2008
2002
  const triggerId = built.triggerId ?? 'start';
2009
2003
  const trigger = emitRootNode('trigger', triggerId, built.trigger, built.triggerOptions?.version, () => {
2010
- const eventTriggerRc = built.trigger?.kind === 'event'
2011
- ? (() => {
2012
- const sub = built.trigger.subscription;
2013
- if (!opts.library)
2014
- throw libraryRequiredForEvent(eventEnv(opts), sub, built.triggerId ?? 'start', 'event trigger', 'onEvent()');
2015
- const rc = resolveEvent(opts.library, 'trigger', sub, 'trigger');
2016
- refuseUnverifiedByoa(eventEnv(opts), 'trigger', sub);
2017
- return rc;
2018
- })()
2019
- : undefined;
2020
2004
  // A custom FlowTrigger subclass (no `kind`) compiles through its own
2021
2005
  // contribution: exact definition, author inputs, definition-owned identity.
2022
2006
  // When the manifest declares `model.entryPointId: true` (how the platform
2023
2007
  // marks entry points), the serializer mints the stable entry-point identity
2024
- // exactly as it does for connector event triggers — an omitted one is the
2008
+ // as the connector event trigger writes it — an omitted one is the
2025
2009
  // classic validates-then-faults defect, so it cannot be forgotten here.
2026
2010
  const builtTrigger = built.trigger;
2027
2011
  const customTrigger = builtTrigger instanceof FlowTrigger && !('kind' in builtTrigger) ? builtTrigger : undefined;
@@ -2047,28 +2031,6 @@ function serializeFlow(built, opts) {
2047
2031
  if (customTrigger) {
2048
2032
  trigger = root.nodes[root.nodes.length - 1];
2049
2033
  }
2050
- else if (eventTriggerRc && built.trigger?.kind === 'event') {
2051
- trigger = makeNode(eventTriggerRc.nodeType, triggerId, rootLabel, { def: eventTriggerRc.v1def, requestedVersion: built.triggerOptions?.version });
2052
- trigger.inputs = {
2053
- // The deployed shape: 38 of 39 archived instances carry `entryPointId`,
2054
- // 28 carry `isDefaultEntryPoint: true`, and the subscription lives in
2055
- // `detail` (see eventDetail).
2056
- entryPointId: stableId(`${built.id}:start:entryPoint`),
2057
- isDefaultEntryPoint: true,
2058
- detail: eventDetail(eventTriggerRc, built.trigger.subscription, triggerId, eventEnv(opts), 'event trigger'),
2059
- };
2060
- // An event trigger's def declares the same connection binding names a
2061
- // mid-flow connector's does — close them (G-19; see connectionResourceBindings).
2062
- const sub = built.trigger.subscription;
2063
- const { entries } = connectionResourceBindings({
2064
- def: eventTriggerRc.v1def,
2065
- connectorKey: eventTriggerRc.connectorKey,
2066
- connectionId: resolveBinding(opts, sub.connection, 'connection', 'event trigger', eventTarget(sub)),
2067
- folderKey: resolveBinding(opts, sub.folder, 'folder', 'event trigger', eventTarget(sub)),
2068
- }, resourceBindings);
2069
- for (const b of entries)
2070
- resourceBindings.set(b.id, b);
2071
- }
2072
2034
  else {
2073
2035
  // No `.trigger()` is the manual trigger.
2074
2036
  trigger = placeTrigger(built.trigger ?? { kind: 'manual' }, { id: triggerId, isDefault: true, inputs: built.inputs }, built.triggerOptions?.version, rootLabel);
@@ -2634,8 +2596,9 @@ function serializeFlow(built, opts) {
2634
2596
  }
2635
2597
  /**
2636
2598
  * Place a registered start trigger's node for one root (FLOW_TRIGGER_TYPES):
2637
- * the type writes the node's inputs, and picks the version when its spec
2638
- * selects one; the pipeline makes the node, under the root's id and label.
2599
+ * the type writes the node's inputs, picks the version when its spec selects
2600
+ * one, and names the node's type and definition when it is per-tenant; the
2601
+ * pipeline makes the node, under the root's id and label.
2639
2602
  */
2640
2603
  function placeTrigger(spec, at, pin, label) {
2641
2604
  const registered = FLOW_TRIGGER_TYPES.byKind(spec.kind);
@@ -2644,9 +2607,23 @@ function serializeFlow(built, opts) {
2644
2607
  const c = registered.type.serialize(spec, {
2645
2608
  root: at,
2646
2609
  version: pin,
2647
- entryPointId: () => stableId(`${built.id}:${at.id}:entryPoint`),
2610
+ entryPointId: (seed = at.id) => stableId(`${built.id}:${seed}:entryPoint`),
2611
+ library: opts.library,
2612
+ events: eventEnv(opts),
2613
+ resolveBinding: (name, attribute, where, target) => resolveBinding(opts, name, attribute, where, target),
2614
+ bindConnection: (b) => {
2615
+ const { entries } = connectionResourceBindings({ def: { model: b.model }, ...b }, resourceBindings);
2616
+ for (const e of entries)
2617
+ resourceBindings.set(e.id, e);
2618
+ },
2619
+ });
2620
+ if (registered.type.typeNamePrefix !== undefined && (c.typeName === undefined || c.definition === undefined)) {
2621
+ throw new Error(`internal SDK error: trigger kind ${JSON.stringify(spec.kind)} is per-tenant and named no type or definition.`);
2622
+ }
2623
+ const node = makeNode(c.typeName ?? registered.type.typeName, at.id, label, {
2624
+ ...(c.definition !== undefined ? { def: c.definition } : {}),
2625
+ requestedVersion: c.version ?? pin,
2648
2626
  });
2649
- const node = makeNode(registered.type.typeName, at.id, label, { requestedVersion: c.version ?? pin });
2650
2627
  node.inputs = c.inputs;
2651
2628
  return node;
2652
2629
  }
@@ -3528,26 +3505,6 @@ function serializeFlow(built, opts) {
3528
3505
  };
3529
3506
  hoistContributionBindings(def, contribution.bindings, `entryPoint "${ep.id}"`);
3530
3507
  }
3531
- else if (epSpec.kind === 'event') {
3532
- const sub = epSpec.subscription;
3533
- if (!opts.library)
3534
- throw libraryRequiredForEvent(eventEnv(opts), sub, ep.id, `onEvent() entry point "${ep.id}"`, 'onEvent()');
3535
- const rc = resolveEvent(opts.library, 'trigger', sub, 'trigger');
3536
- refuseUnverifiedByoa(eventEnv(opts), 'trigger', sub);
3537
- node = makeNode(rc.nodeType, ep.id, epLabel, { def: rc.v1def, requestedVersion });
3538
- node.inputs = {
3539
- entryPointId: stableId(`${built.id}:${ep.id}:entryPoint`),
3540
- detail: eventDetail(rc, sub, ep.id, eventEnv(opts), `onEvent() entry point "${ep.id}"`),
3541
- };
3542
- const { entries } = connectionResourceBindings({
3543
- def: rc.v1def,
3544
- connectorKey: rc.connectorKey,
3545
- connectionId: resolveBinding(opts, sub.connection, 'connection', 'onEvent() entry point', eventTarget(sub)),
3546
- folderKey: resolveBinding(opts, sub.folder, 'folder', 'onEvent() entry point', eventTarget(sub)),
3547
- }, resourceBindings);
3548
- for (const b of entries)
3549
- resourceBindings.set(b.id, b);
3550
- }
3551
3508
  else {
3552
3509
  refuseUnknownTrigger(epSpec, `.entryPoint("${ep.id}")`);
3553
3510
  node = placeTrigger(epSpec, { id: ep.id, isDefault: false, inputs: ep.inputs }, requestedVersion, epLabel);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.86.9",
3
+ "version": "6.86.11",
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": "7d6b129cbb00860c5b83d8983da924649474cf23"
106
+ "gitref": "3bc7b01f506acd560cfde69c2ecaa2bc9e4b82c6"
107
107
  }