@uipath/maestro-builder-sdk 6.120.18 → 6.120.20

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.
@@ -0,0 +1,179 @@
1
+ /**
2
+ * bpmn/script-js — reading a BPMN script task's JavaScript: which names a piece of code
3
+ * binds, and where it reads one.
4
+ *
5
+ * Parsed with acorn, as the Case checks parse JavaScript, so only real references count:
6
+ * a property name, an object key, a string, template text, a regex or a comment is none.
7
+ * Shared by `check` (a script output's `result` reads) and the expression rules (a script
8
+ * body's `vars.<id>` reads, bpmn-expr-check).
9
+ */
10
+ import { parse } from 'acorn';
11
+ export const isJsNode = (v) => typeof v === 'object' && v !== null && typeof v.type === 'string';
12
+ /** The child nodes of `node`, in source order. */
13
+ export function jsChildren(node) {
14
+ const out = [];
15
+ for (const [field, v] of Object.entries(node)) {
16
+ if (field === 'type' || field === 'start' || field === 'end')
17
+ continue;
18
+ if (Array.isArray(v))
19
+ for (const item of v) {
20
+ if (isJsNode(item))
21
+ out.push(item);
22
+ }
23
+ else if (isJsNode(v))
24
+ out.push(v);
25
+ }
26
+ return out;
27
+ }
28
+ /** Whether a binding pattern (`result`, `{ a: result }`, `[result = 1]`, `...result`) declares `name`. */
29
+ export function patternBinds(p, name) {
30
+ switch (p.type) {
31
+ case 'Identifier': return p.name === name;
32
+ case 'AssignmentPattern': return patternBinds(p.left, name);
33
+ case 'RestElement': return patternBinds(p.argument, name);
34
+ case 'ArrayPattern': return p.elements.some((e) => e !== null && patternBinds(e, name));
35
+ // A pattern's computed key or default value is an expression, not a binding.
36
+ case 'ObjectPattern': return p.properties.some((pr) => patternBinds(pr.type === 'RestElement' ? pr : pr.value, name));
37
+ default: return false;
38
+ }
39
+ }
40
+ export const isFunction = (n) => /Function/.test(n.type);
41
+ /** Whether a `let`/`const`/`var` declaration of the given kinds declares `name`. */
42
+ export function declarationBinds(n, name, kinds) {
43
+ return isJsNode(n) && n.type === 'VariableDeclaration' && kinds(n.kind)
44
+ && n.declarations.some((d) => patternBinds(d.id, name));
45
+ }
46
+ /** Whether these statements, at the top of one block, declare `name` block-scoped: `let`, `const`, `class` or a function declaration. */
47
+ export function lexicallyBinds(statements, name) {
48
+ return statements.some((s) => declarationBinds(s, name, (k) => k !== 'var')
49
+ || ((s.type === 'ClassDeclaration' || s.type === 'FunctionDeclaration') && isJsNode(s.id) && s.id.name === name));
50
+ }
51
+ /** Whether a `var` under `node` declares `name` in the function `node` belongs to: nested functions and static blocks are their own `var` scope and are not walked. */
52
+ export function varBinds(node, name) {
53
+ if (declarationBinds(node, name, (k) => k === 'var'))
54
+ return true;
55
+ return jsChildren(node).some((c) => !isFunction(c) && c.type !== 'StaticBlock' && varBinds(c, name));
56
+ }
57
+ /**
58
+ * Whether `node` opens a scope that declares `name`, so every `name` inside it is that
59
+ * binding, not the outer one. A function: its own name (an expression's), a parameter,
60
+ * a `var` anywhere in its body outside a nested function, or a block-scoped declaration
61
+ * at the top of its body. A block, a `switch`, a `for` head or a `catch` parameter: the
62
+ * declarations scoped to it. A declaration in a nested function shadows only inside that
63
+ * function, so it is found when the walk reaches that function, never from outside.
64
+ */
65
+ export function scopeBinds(node, name) {
66
+ if (isFunction(node)) {
67
+ if (node.type === 'FunctionExpression' && isJsNode(node.id) && node.id.name === name)
68
+ return true;
69
+ if (node.params.some((p) => patternBinds(p, name)))
70
+ return true;
71
+ const body = node.body;
72
+ return body.type === 'BlockStatement' && (varBinds(body, name) || lexicallyBinds(body.body, name));
73
+ }
74
+ switch (node.type) {
75
+ case 'BlockStatement': return lexicallyBinds(node.body, name);
76
+ case 'StaticBlock': return varBinds(node, name) || lexicallyBinds(node.body, name);
77
+ case 'SwitchStatement': return lexicallyBinds(node.cases.flatMap((c) => c.consequent), name);
78
+ case 'CatchClause': return isJsNode(node.param) && patternBinds(node.param, name);
79
+ case 'ForStatement': return declarationBinds(node.init, name, (k) => k !== 'var');
80
+ case 'ForInStatement':
81
+ case 'ForOfStatement': return declarationBinds(node.left, name, (k) => k !== 'var');
82
+ case 'ClassExpression':
83
+ case 'ClassDeclaration': return isJsNode(node.id) && node.id.name === name;
84
+ default: return false;
85
+ }
86
+ }
87
+ /** The string a member selector names: `.response`, `['response']`, `` [`response`] ``; `undefined` for any other. */
88
+ export function memberName(member) {
89
+ const prop = member.property;
90
+ if (!member.computed)
91
+ return prop.type === 'Identifier' ? prop.name : undefined;
92
+ if (prop.type === 'Literal')
93
+ return typeof prop.value === 'string' ? prop.value : undefined;
94
+ const quasis = prop.quasis;
95
+ return prop.type === 'TemplateLiteral' && quasis?.length === 1 ? quasis[0].value.cooked : undefined;
96
+ }
97
+ /** Whether a `vars.<root>` met under a node is a read. */
98
+ var ReadContext;
99
+ (function (ReadContext) {
100
+ /** It is: the body uses the value. */
101
+ ReadContext[ReadContext["Read"] = 0] = "Read";
102
+ /** Under `typeof`: the body only asks whether it exists. */
103
+ ReadContext[ReadContext["TypeofOperand"] = 1] = "TypeofOperand";
104
+ })(ReadContext || (ReadContext = {}));
105
+ /**
106
+ * Every `vars.<root>` a script BODY reads, with the path after the root, or `undefined`
107
+ * when the body does not parse (nothing is claimed about code that does not run).
108
+ *
109
+ * The platform runs the body as a function (`(function(){<body>})()`, as the local
110
+ * engine does) with `vars` in scope. A read is a member selector on that `vars`: dotted
111
+ * (`vars.amount`), or a quoted key (`vars['amount']`). Not a read:
112
+ *
113
+ * - anything under a scope that binds its own `vars` (a parameter, `let`, `const`,
114
+ * `var`, a function or `catch` binding), which is not the platform's;
115
+ * - a computed key (`vars[name]`), which names no root this can see;
116
+ * - a call through `vars` (`vars.hasOwnProperty('x')`): an `Object.prototype` method,
117
+ * not a variable;
118
+ * - the operand of `typeof`, which a script uses to ask whether a variable exists;
119
+ * - a root the body itself ASSIGNS (`vars.total = …`, `vars.total ??= 0`) or deletes,
120
+ * whose later read is of the body's own value.
121
+ */
122
+ export function scriptVarReads(script) {
123
+ let program;
124
+ try {
125
+ program = parse(`(function(){${script}\n})`, { ecmaVersion: 'latest', sourceType: 'script' });
126
+ }
127
+ catch {
128
+ return undefined;
129
+ }
130
+ const reads = [];
131
+ const written = new Set();
132
+ /** `stack` is the ancestors of `node`, nearest last. */
133
+ const visit = (node, stack, context) => {
134
+ if (node.type === 'MemberExpression' && isJsNode(node.object) && node.object.type === 'Identifier' && node.object.name === 'vars') {
135
+ const root = memberName(node);
136
+ const parent = stack[stack.length - 1];
137
+ if (root !== undefined) {
138
+ const target = (parent?.type === 'AssignmentExpression' && parent.left === node)
139
+ || parent?.type === 'UpdateExpression'
140
+ || (parent?.type === 'UnaryExpression' && parent.operator === 'delete');
141
+ const callee = parent?.type === 'CallExpression' && parent.callee === node;
142
+ if (target)
143
+ written.add(root);
144
+ else if (!callee && context === ReadContext.Read) {
145
+ // The selectors after the root, outward: `vars.step1.output.ok` → ['output', 'ok'].
146
+ const path = [];
147
+ let inner = node;
148
+ for (let k = stack.length - 1; k >= 0; k--) {
149
+ const outer = stack[k];
150
+ if (outer.type !== 'MemberExpression' || outer.object !== inner)
151
+ break;
152
+ const name = memberName(outer);
153
+ if (name === undefined)
154
+ break;
155
+ path.push(name);
156
+ inner = outer;
157
+ }
158
+ reads.push({ root, path, raw: ['vars', root, ...path].join('.') });
159
+ }
160
+ }
161
+ // A computed key is code of its own (`vars[pick(vars.kind)]`).
162
+ if (node.computed)
163
+ visit(node.property, [...stack, node], context);
164
+ return;
165
+ }
166
+ if (scopeBinds(node, 'vars'))
167
+ return;
168
+ const typeofOperand = node.type === 'UnaryExpression' && node.operator === 'typeof';
169
+ for (const child of jsChildren(node)) {
170
+ // A name in a property position is not a reference: `a.vars`, `{ vars: … }`, a label.
171
+ const isName = child === node.key || child === node.property || child === node.label || child === node.meta;
172
+ if (isName && !node.computed)
173
+ continue;
174
+ visit(child, [...stack, node], typeofOperand ? ReadContext.TypeofOperand : context);
175
+ }
176
+ };
177
+ visit(program, [], ReadContext.Read);
178
+ return reads.filter((r) => !written.has(r.root));
179
+ }
@@ -181,32 +181,6 @@ export declare function implicitNodeVars(nodes: BpmnNode[], declared: BpmnVarDec
181
181
  * An explicit `resourceKey` on the declaration is never overridden.
182
182
  */
183
183
  export declare function folderCompanionKeys(built: BuiltBpmn, sink: Map<string, Record<string, unknown>>): Map<string, string>;
184
- /**
185
- * Where an unscoped PUBLIC declaration belongs at the top level of a process.
186
- *
187
- * Every real artifact agrees: across the 97 Studio Web exports and converter outputs
188
- * measured (`research/bpmn-roundtrip/corpus/`, the run-6 `v1` arm), all 107 public
189
- * `uipath:input` declarations are scoped to the process's manual START event and all
190
- * 37 `uipath:output` declarations to the END event whose mapping writes them — none to
191
- * the process. The engine does not need it (`BpmnDataManager.EvaluateProcessVariables`
192
- * seeds every declaration into one variables scope by id, and an expression resolves
193
- * `vars.<id>` there whatever the declaration's `elementId`), but the canvas, the
194
- * entry-point derivation and the graders that read a process's contract do: a process
195
- * input is "the start event's input". Until this, the SDK wrote the process id, which
196
- * validated and ran and was the one placement nothing else on the platform produces —
197
- * cluster D of docs/BPMN_AUTHORING_ERGONOMICS_DESIGN.md §1b.
198
- *
199
- * The rule, mirrored by `bpmn-decompile` so an unscoped declaration round-trips without
200
- * an explicit `elementId`:
201
- * - `input` → the one root start event with no event definition and no trigger,
202
- * when there is exactly one; else the process.
203
- * - `output` → the one root end event whose payload writes `var="<id>"`; else the one
204
- * root end event, when there is exactly one; else the process.
205
- * - `inputOutput` → the process (an internal variable is process-level state; the
206
- * engine's debug variables report lists exactly those).
207
- * An explicit `elementId` always wins, and `null` still means "write none".
208
- */
209
- export declare function publicDeclarationScope(nodes: BpmnNode[], processId: string): (v: BpmnVarDecl) => string;
210
184
  /** Flatten a scope's nodes (recursing sub-processes) for global scans. */
211
185
  export declare function allNodes(nodes: BpmnNode[]): BpmnNode[];
212
186
  export {};
@@ -21,8 +21,9 @@ import { createConnectorEvent, createExternalTask } from './intsvc.js';
21
21
  import { connectorEventErrorVar, intsvcOutputVar } from './intsvc-vars.js';
22
22
  import { IMPLICIT_CONNECTION } from './managed-http.js';
23
23
  import { createExtensionPayload, createTypedNode, rowDeclaration, typedNodeOutputVar, verbatimOutputRows } from './typed-node.js';
24
- import { connectorOutputVars, nodeDeclaredVars, typedNodeDeclaredVars } from './declared-vars.js';
24
+ import { connectorOutputVars, nodeDeclaredVars, publicDeclarationScope, typedNodeDeclaredVars } from './declared-vars.js';
25
25
  import { defaultEntryPointId } from './entry-point-id.js';
26
+ import { isExpressionValue } from './expression-value.js';
26
27
  import { parseXmlRanges } from './xml-ranges.js';
27
28
  import { ownEntry } from '../core/own-entry.js';
28
29
  import { CompileRefusal } from '../core/compile-refusal.js';
@@ -1130,7 +1131,7 @@ function outputRows(ctx, map, custom = false) {
1130
1131
  * too, since JSON permits them raw and only ES2019+ accepts them in a literal.
1131
1132
  */
1132
1133
  function assignmentSource(value) {
1133
- if (value.startsWith('='))
1134
+ if (isExpressionValue(value))
1134
1135
  return value;
1135
1136
  // Escape sequences, not the raw characters, so the regexes survive an editor.
1136
1137
  const literal = JSON.stringify(value).replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
@@ -1437,46 +1438,6 @@ function orderVars(vars, order) {
1437
1438
  .sort((a, b) => a.r - b.r || a.i - b.i)
1438
1439
  .map((e) => e.v);
1439
1440
  }
1440
- /**
1441
- * Where an unscoped PUBLIC declaration belongs at the top level of a process.
1442
- *
1443
- * Every real artifact agrees: across the 97 Studio Web exports and converter outputs
1444
- * measured (`research/bpmn-roundtrip/corpus/`, the run-6 `v1` arm), all 107 public
1445
- * `uipath:input` declarations are scoped to the process's manual START event and all
1446
- * 37 `uipath:output` declarations to the END event whose mapping writes them — none to
1447
- * the process. The engine does not need it (`BpmnDataManager.EvaluateProcessVariables`
1448
- * seeds every declaration into one variables scope by id, and an expression resolves
1449
- * `vars.<id>` there whatever the declaration's `elementId`), but the canvas, the
1450
- * entry-point derivation and the graders that read a process's contract do: a process
1451
- * input is "the start event's input". Until this, the SDK wrote the process id, which
1452
- * validated and ran and was the one placement nothing else on the platform produces —
1453
- * cluster D of docs/BPMN_AUTHORING_ERGONOMICS_DESIGN.md §1b.
1454
- *
1455
- * The rule, mirrored by `bpmn-decompile` so an unscoped declaration round-trips without
1456
- * an explicit `elementId`:
1457
- * - `input` → the one root start event with no event definition and no trigger,
1458
- * when there is exactly one; else the process.
1459
- * - `output` → the one root end event whose payload writes `var="<id>"`; else the one
1460
- * root end event, when there is exactly one; else the process.
1461
- * - `inputOutput` → the process (an internal variable is process-level state; the
1462
- * engine's debug variables report lists exactly those).
1463
- * An explicit `elementId` always wins, and `null` still means "write none".
1464
- */
1465
- export function publicDeclarationScope(nodes, processId) {
1466
- const manualStarts = nodes.filter((n) => n.kind === 'startEvent' && n.event === undefined && n.trigger === undefined);
1467
- const ends = nodes.filter((n) => n.kind === 'endEvent');
1468
- return (v) => {
1469
- if (v.direction === 'input')
1470
- return manualStarts.length === 1 ? manualStarts[0].id : processId;
1471
- if (v.direction === 'output') {
1472
- const writers = ends.filter((e) => (e.payload?.outputRows ?? []).some((r) => r.var === v.id));
1473
- if (writers.length === 1)
1474
- return writers[0].id;
1475
- return ends.length === 1 ? ends[0].id : processId;
1476
- }
1477
- return processId;
1478
- };
1479
- }
1480
1441
  // ─── Small helpers ────────────────────────────────────────────────────────────
1481
1442
  function cap(s) {
1482
1443
  return s.charAt(0).toUpperCase() + s.slice(1);
package/dist/bpmn-api.md CHANGED
@@ -95,7 +95,7 @@ The set of node/flow/variable methods common to the process root and every sub-p
95
95
  - `ScopeBuilder.flowIds(entries: PinnedFlowId[]): this` — Give the edges the nesting constructs IMPLY the ids you choose.
96
96
  - `ScopeBuilder.sequenceFlow(source: string, target: string, opts?: FlowOpts): this` — A sequence flow from `source` to `target` (1-1 with `bpmn:sequenceFlow`).
97
97
  - `ScopeBuilder.var(id: string, type: BpmnVarType, opts?: VarOpts): this` — A mutable flow variable (`uipath:inputOutput`).
98
- - `ScopeBuilder.input(id: string, type: BpmnVarType, opts?: VarOpts): this` — A read-only entry input (`uipath:input`).
98
+ - `ScopeBuilder.input(id: string, type: BpmnVarType, opts?: VarOpts): this` — A read-only entry input (`uipath:input`), scoped to the manual start event.
99
99
  - `ScopeBuilder.output(id: string, type: BpmnVarType, opts?: VarOpts): this` — A return value (`uipath:output`).
100
100
  - `ScopeBuilder.vars(entries: VarEntry[]): this` — Several declarations as one call — the array form of `.var()` / `.input()` / `.output()`.
101
101
 
@@ -479,7 +479,7 @@ What every ACTIVITY accepts, on top of its own options — a script task, a vari
479
479
  - `ConnectorOpts.version?: string` — Connector action version (defaults to the library's newest match).
480
480
  - `ConnectorOpts.connection?: string` — Symbolic connection name declared in bindings.json (→ ConnectionId).
481
481
  - `ConnectorOpts.folder?: string` — Symbolic folder name declared in bindings.json (→ connectionFolderKey).
482
- - `ConnectorOpts.object?: string` — Which OBJECT a **generic** operation addresses — e.g. ServiceNow's "List All Records" on `'acr_user'`, NetSuite's "Get…
482
+ - `ConnectorOpts.object?: string` — Which OBJECT a **generic** operation addresses — e.g. ServiceNow's "List Records" on `'acr_user'`, NetSuite's "Get…
483
483
  - `ConnectorOpts.carried?: CarriedConnectorOperation` — Flow only, and written by decompile, not by an author: the `.flow` file's own description of an operation the connector…
484
484
 
485
485
  ### `HumanTaskAppOpts`
@@ -24,7 +24,7 @@ export interface ConnectorOpts {
24
24
  /** Symbolic folder name declared in bindings.json (→ connectionFolderKey). Required with `connection`. */
25
25
  folder?: string;
26
26
  /**
27
- * Which OBJECT a **generic** operation addresses — e.g. ServiceNow's "List All
27
+ * Which OBJECT a **generic** operation addresses — e.g. ServiceNow's "List
28
28
  * Records" on `'acr_user'`, NetSuite's "Get Record" on `'AccountingPeriod'`.
29
29
  *
30
30
  * A generic (`GenericExpanded`) operation encodes only the VERB in its node
@@ -37,7 +37,7 @@ export interface ConnectorOpts {
37
37
  * sorted first, silently.
38
38
  *
39
39
  * ```ts
40
- * connector('uipath-servicenow-servicenow', 'list-all-records', {},
40
+ * connector('uipath-servicenow-servicenow', 'list-records', {},
41
41
  * { connection: 'servicenow', folder: 'shared', object: 'acr_user' })
42
42
  * ```
43
43
  *
@@ -159,3 +159,10 @@ export declare function quotedOnlyMentions(expr: string, namespace?: string): Qu
159
159
  * "fully valid"; the `validate` CLI is what proves the rest.
160
160
  */
161
161
  export declare function checkExpression(expr: string, scope: ExprScope, escapes?: readonly CookedEscape[]): ExprDiagnostic[];
162
+ /**
163
+ * The resolution half of {@link checkExpression}, for references found some other way
164
+ * than by scanning an expression's text — a BPMN script body's `vars.<id>` reads, which
165
+ * are found by parsing the JavaScript (`bpmn/script-js.ts`). Every reference's root must
166
+ * resolve; one diagnostic per unresolved root.
167
+ */
168
+ export declare function checkRefs(refs: readonly ExprRef[], scope: ExprScope): ExprDiagnostic[];
@@ -316,9 +316,6 @@ function nearMiss(name, roots) {
316
316
  */
317
317
  export function checkExpression(expr, scope, escapes = []) {
318
318
  const namespace = scope.namespace ?? DEFAULT_NAMESPACE;
319
- const noun = scope.noun ?? 'input, variable, or step';
320
- const diags = [];
321
- const seen = new Set();
322
319
  // Syntax first: an expression that does not parse cannot have meaningful
323
320
  // references, and reporting both would just be noise on one root cause.
324
321
  const syntax = scope.syntax === 'javascript' ? syntaxError(expr) : undefined;
@@ -340,8 +337,21 @@ export function checkExpression(expr, scope, escapes = []) {
340
337
  : {}),
341
338
  }];
342
339
  }
340
+ return checkRefs(extractRefs(expr, namespace), scope);
341
+ }
342
+ /**
343
+ * The resolution half of {@link checkExpression}, for references found some other way
344
+ * than by scanning an expression's text — a BPMN script body's `vars.<id>` reads, which
345
+ * are found by parsing the JavaScript (`bpmn/script-js.ts`). Every reference's root must
346
+ * resolve; one diagnostic per unresolved root.
347
+ */
348
+ export function checkRefs(refs, scope) {
349
+ const namespace = scope.namespace ?? DEFAULT_NAMESPACE;
350
+ const noun = scope.noun ?? 'input, variable, or step';
351
+ const diags = [];
352
+ const seen = new Set();
343
353
  const dotted = dottedRoots(scope.roots);
344
- for (const ref of extractRefs(expr, namespace)) {
354
+ for (const ref of refs) {
345
355
  if (scope.roots.has(ref.root))
346
356
  continue;
347
357
  const name = dotted.length ? unresolvedDottedName(ref, dotted) : ref.root;
@@ -50,6 +50,13 @@ export interface ListEnvelopeRow {
50
50
  * a dispatcher that needs to normalise between the CLI and the platform.
51
51
  */
52
52
  cliShape?: string;
53
+ /**
54
+ * Set on a row whose `nodeType` the current library no longer serves (the
55
+ * operation was renamed and the measurement re-keyed). Readers still match
56
+ * it, for libraries built before the rename; `checkCuratedOverlay` does not
57
+ * require the library to carry it.
58
+ */
59
+ keyRetired?: string;
53
60
  }
54
61
  /**
55
62
  * Every declared row, from `<libraryDir>/list-envelopes.json`. An absent file is
@@ -354,6 +354,7 @@ export declare const REFUSALS: {
354
354
  readonly EVENT_UNPREPARED: "lint";
355
355
  readonly EVENT_WHERE_NOT_SCALAR: "lowering";
356
356
  readonly EXCEPTION_STAGE_REQUIRED: "lint";
357
+ readonly EXPR_ARGUMENT_REF: "lint";
357
358
  readonly EXPR_BARE_VAR_REF: "lint";
358
359
  readonly EXPR_SYNTAX: "lowering";
359
360
  readonly EXPR_UNDECLARED_REF: "lint";
@@ -428,6 +428,7 @@ export const REFUSALS = {
428
428
  EVENT_UNPREPARED: 'lint',
429
429
  EVENT_WHERE_NOT_SCALAR: 'lowering',
430
430
  EXCEPTION_STAGE_REQUIRED: 'lint',
431
+ EXPR_ARGUMENT_REF: 'lint',
431
432
  EXPR_BARE_VAR_REF: 'lint',
432
433
  EXPR_SYNTAX: 'lowering',
433
434
  EXPR_UNDECLARED_REF: 'lint',
@@ -5,6 +5,8 @@ export declare function bundledOverlayPath(): string;
5
5
  export declare function curatedOverlayIdentity(overlayPath?: string): Promise<string>;
6
6
  /** The ledger of deliberate patches; read here, never copied into a library. */
7
7
  export declare const CORRECTIONS_FILE = "overlay-corrections.json";
8
+ /** SDK-owned side-tables the published library does not carry; always copied. */
9
+ export declare const SIDE_TABLES: ReadonlySet<string>;
8
10
  /** One row of {@link CORRECTIONS_FILE}. */
9
11
  export interface OverlayCorrection {
10
12
  path: string;
@@ -94,12 +96,25 @@ export interface CuratedOverlayCheck {
94
96
  * was renamed or re-versioned. `registry pull` only warns about these too.
95
97
  */
96
98
  staleCorrections: string[];
99
+ /**
100
+ * Side-table rows keyed on something the library no longer carries, so the
101
+ * row has stopped applying: a `list-envelopes.json` row whose `nodeType` the
102
+ * library does not index (or whose `objectName` is not among the per-object
103
+ * rows of that node type), or an `invariant-collections.json` row whose
104
+ * collection no input field references. A refresh that renames an operation
105
+ * silently drops a measured row otherwise (#853: `list-all-records` became
106
+ * `list-records`). A row marked `keyRetired` is kept for older libraries
107
+ * and not checked.
108
+ */
109
+ staleSideTableRows: string[];
97
110
  }
98
111
  /**
99
- * Check `libraryPath` against the curated overlay. Both lists are empty once
100
- * {@link applyCuratedOverlay} has run on it, unless a correction went stale.
112
+ * Check `libraryPath` against the curated overlay. All three lists are empty
113
+ * once {@link applyCuratedOverlay} has run on it, unless a correction or a
114
+ * side-table row went stale.
101
115
  * Every overlay identity that is not a correction must be indexed at a file
102
- * that exists, and each side-table must equal the bundled copy.
116
+ * that exists, each side-table must equal the bundled copy, and each
117
+ * side-table row must still key on something the library carries.
103
118
  *
104
119
  * The connector library pipeline runs this on the archive it publishes,
105
120
  * because readers that load that archive directly apply no overlay.
@@ -62,7 +62,7 @@ export const CORRECTIONS_FILE = "overlay-corrections.json";
62
62
  */
63
63
  const RECORD_FILE = ".curated-overlay.json";
64
64
  /** SDK-owned side-tables the published library does not carry; always copied. */
65
- const SIDE_TABLES = new Set(["list-envelopes.json", "invariant-collections.json"]);
65
+ export const SIDE_TABLES = new Set(["list-envelopes.json", "invariant-collections.json"]);
66
66
  /** The sidecar that travels with an entry file, and has no index row of its own. */
67
67
  function sidecarOf(rel) {
68
68
  return `${rel.slice(0, -".json".length)}.v1def.json`;
@@ -365,11 +365,103 @@ reporter = consoleReporter) {
365
365
  `, kept ${result.kept.length + result.skipped.length} published definition(s) unchanged.`);
366
366
  return result;
367
367
  }
368
+ /** The `nodeType` → `objectName`s index of a library (`''` for an entry with none). */
369
+ function objectsByNodeType(entries) {
370
+ const out = new Map();
371
+ for (const entry of entries) {
372
+ if (typeof entry.nodeType !== "string")
373
+ continue;
374
+ const objects = out.get(entry.nodeType) ?? new Set();
375
+ objects.add(typeof entry.objectName === "string" ? entry.objectName : "");
376
+ out.set(entry.nodeType, objects);
377
+ }
378
+ return out;
379
+ }
380
+ /**
381
+ * Every collection an INPUT field of the library references: its
382
+ * `reference.objectName`, and the last segment of its `reference.path` (90
383
+ * registry references carry no `objectName`). Only the places a reader takes
384
+ * input fields from are read — the entry's `inputSchema.fields` and
385
+ * `operation.parameters`, and the sidecar's `inputDefinition.fields` — so a
386
+ * collection only an output names does not keep an input row alive.
387
+ */
388
+ async function referencedCollections(libraryPath, entries) {
389
+ const out = new Set();
390
+ const add = (fields) => {
391
+ if (!Array.isArray(fields))
392
+ return;
393
+ for (const field of fields) {
394
+ const reference = isDict(field) ? field.reference : undefined;
395
+ if (!isDict(reference))
396
+ continue;
397
+ if (typeof reference.objectName === "string" && reference.objectName)
398
+ out.add(reference.objectName);
399
+ if (typeof reference.path === "string") {
400
+ const last = reference.path.split("/").filter(Boolean).pop();
401
+ if (last)
402
+ out.add(last);
403
+ }
404
+ }
405
+ };
406
+ for (const path of new Set(entries.map((entry) => entry.path).filter((path) => typeof path === "string"))) {
407
+ const file = join(libraryPath, path);
408
+ if (await exists(file)) {
409
+ const entry = await readJson(file);
410
+ if (isDict(entry)) {
411
+ add(entry.inputSchema?.fields);
412
+ add(entry.operation?.parameters);
413
+ }
414
+ }
415
+ const sidecar = join(libraryPath, sidecarOf(path));
416
+ if (await exists(sidecar))
417
+ add(sidecarBody(await readJson(sidecar))?.inputDefinition?.fields);
418
+ }
419
+ return out;
420
+ }
421
+ async function readSideTableRows(overlayPath, table, key) {
422
+ const parsed = await readJson(join(overlayPath, table));
423
+ const rows = isDict(parsed) ? parsed[key] : undefined;
424
+ return Array.isArray(rows) ? rows.filter(isDict) : [];
425
+ }
426
+ /** {@link CuratedOverlayCheck.staleSideTableRows} for `libraryPath`. */
427
+ async function staleSideTableRowsOf(libraryPath, overlayPath, entries) {
428
+ const stale = [];
429
+ const objects = objectsByNodeType(entries);
430
+ for (const row of await readSideTableRows(overlayPath, "list-envelopes.json", "operations")) {
431
+ if (row.keyRetired !== undefined)
432
+ continue;
433
+ const nodeType = String(row.nodeType);
434
+ const objectName = typeof row.objectName === "string" ? row.objectName : undefined;
435
+ const where = `list-envelopes.json row ${nodeType}${objectName ? ` (${objectName})` : ""}`;
436
+ const served = objects.get(nodeType);
437
+ if (served === undefined) {
438
+ stale.push(`${where}: the library has no definition of that node type`);
439
+ continue;
440
+ }
441
+ // An entry with no objectName is a discovered object (connection-scoped
442
+ // Generic): any object may be addressed. Otherwise the object must be one of its rows.
443
+ if (objectName !== undefined && !served.has("") && !served.has(objectName)) {
444
+ stale.push(`${where}: the library serves that node type only for ${sortedStrings([...served]).join(", ")}`);
445
+ }
446
+ }
447
+ const collections = await readSideTableRows(overlayPath, "invariant-collections.json", "collections");
448
+ if (collections.length > 0) {
449
+ const referenced = await referencedCollections(libraryPath, entries);
450
+ for (const row of collections) {
451
+ if (row.keyRetired !== undefined || referenced.has(String(row.objectName)))
452
+ continue;
453
+ stale.push(`invariant-collections.json row ${String(row.objectName)}: no input field of the library references that collection`);
454
+ }
455
+ }
456
+ return stale;
457
+ }
368
458
  /**
369
- * Check `libraryPath` against the curated overlay. Both lists are empty once
370
- * {@link applyCuratedOverlay} has run on it, unless a correction went stale.
459
+ * Check `libraryPath` against the curated overlay. All three lists are empty
460
+ * once {@link applyCuratedOverlay} has run on it, unless a correction or a
461
+ * side-table row went stale.
371
462
  * Every overlay identity that is not a correction must be indexed at a file
372
- * that exists, and each side-table must equal the bundled copy.
463
+ * that exists, each side-table must equal the bundled copy, and each
464
+ * side-table row must still key on something the library carries.
373
465
  *
374
466
  * The connector library pipeline runs this on the archive it publishes,
375
467
  * because readers that load that archive directly apply no overlay.
@@ -442,7 +534,8 @@ export async function checkCuratedOverlay(libraryPath, overlayPath = bundledOver
442
534
  missing.push(`side-table ${table}: differs from the SDK's copy`);
443
535
  }
444
536
  }
445
- return { missing, staleCorrections };
537
+ const staleSideTableRows = await staleSideTableRowsOf(libraryPath, overlayPath, library.entries ?? []);
538
+ return { missing, staleCorrections, staleSideTableRows };
446
539
  }
447
540
  /**
448
541
  * The curated overlay's two connection-free contributions to a library that
@@ -13,7 +13,7 @@ export declare function registryActionIds(payload: unknown, connectorKey: string
13
13
  * Candidates ranked by shared hyphen tokens, best first.
14
14
  *
15
15
  * Token overlap rather than edit distance because the two namespaces differ by
16
- * whole words, not typos: the baked library's `list-all-records` against the
16
+ * whole words, not typos: an older library's `list-all-records` against the
17
17
  * registry's `list-records`. Python sorted `(overlap, -len, name)` descending,
18
18
  * so ties on overlap prefer the SHORTER id, and ties on both fall back to the
19
19
  * name in reverse code-point order.
@@ -56,7 +56,7 @@ export function registryActionIds(payload, connectorKey) {
56
56
  * Candidates ranked by shared hyphen tokens, best first.
57
57
  *
58
58
  * Token overlap rather than edit distance because the two namespaces differ by
59
- * whole words, not typos: the baked library's `list-all-records` against the
59
+ * whole words, not typos: an older library's `list-all-records` against the
60
60
  * registry's `list-records`. Python sorted `(overlap, -len, name)` descending,
61
61
  * so ties on overlap prefer the SHORTER id, and ties on both fall back to the
62
62
  * name in reverse code-point order.
@@ -238,7 +238,7 @@ export function unresolvedOperationMessage(input) {
238
238
  // where it would point an event request at action ids again.
239
239
  const wanted = new Set(name.split("-")).size;
240
240
  if (close.length > 0 && sharedTokens(name, close[0]) * 2 > wanted) {
241
- lines.push("The baked library's action id is not always the registry's key — a Generic", "op is `list-all-records` in the library and materializes per object, while", "the registry serves the un-expanded form. For an action, re-run with a registry action id.");
241
+ lines.push("The baked library's action id is not always the registry's key — a library built", "before 2026-11 calls a Generic op `list-all-records`, while the registry serves", "`list-records`. For an action, re-run with a registry action id.");
242
242
  }
243
243
  lines.push("", `All actions the registry serves for ${key}:`, ...catalog.actions.map((a) => ` ${a}`));
244
244
  }
@@ -44,7 +44,15 @@
44
44
  "",
45
45
  "This is NOT a licence to default the whole verb to bare. Eight of 2,149 is",
46
46
  "0.4%, and campaign lesson 25 is this issue's own history: card G1 measured",
47
- "three operations, generalised to the verb, and the corpus refused it."
47
+ "three operations, generalised to the verb, and the corpus refused it.",
48
+ "",
49
+ "A ROW IS KEYED ON THE LIBRARY'S nodeType, AND A REFRESH CAN RENAME IT. The",
50
+ "#853 rebuild turned the generic `list-all-records` into `list-records`, and",
51
+ "the two generic rows silently stopped applying. `curated-overlay.mjs",
52
+ "--check` (checkCuratedOverlay) now fails on a row whose nodeType, or",
53
+ "objectName, the library no longer carries. When an operation is renamed,",
54
+ "re-key the row and keep the old one with a `keyRetired` note for libraries",
55
+ "built before the rename; the check skips a retired row."
48
56
  ],
49
57
  "operations": [
50
58
  {
@@ -92,8 +100,18 @@
92
100
  "source": "card G13 probe-box — `flow debug` jobKey a7015865-44c8-4a1a-82f5-6af3ae0d1b7e; globals `boxItems.output` = array(2) of {name,sequence_id,etag,id,type}. The prediction test: Box's own API answers `{\"entries\":[…],\"total_count\":…}` and none of that reaches the flow.",
93
101
  "cliShape": "{items,Pagination}"
94
102
  },
103
+ {
104
+ "nodeType": "uipath.connector.uipath-coupa-coupa.list-records",
105
+ "objectName": "accounts",
106
+ "envelope": null,
107
+ "tier": "A1",
108
+ "measuredAt": "2026-08-02",
109
+ "source": "card G13 probe-coupa — `flow debug` jobKey af7bfdcc-2fb2-4606-9665-45500ae49148; globals `coupaAccounts.output` = array(2). The GENERIC `list-all-records` family, on a connector no corpus artifact has ever touched. Measured under the operation's pre-#853 id `list-all-records`.",
110
+ "cliShape": "{items,Pagination}"
111
+ },
95
112
  {
96
113
  "nodeType": "uipath.connector.uipath-coupa-coupa.list-all-records",
114
+ "keyRetired": "The registry serves this operation as `list-records` since the #853 library rebuild (2026-11-15); the row above carries the measurement. Kept for libraries built before it.",
97
115
  "objectName": "accounts",
98
116
  "envelope": null,
99
117
  "tier": "A1",
@@ -101,8 +119,18 @@
101
119
  "source": "card G13 probe-coupa — `flow debug` jobKey af7bfdcc-2fb2-4606-9665-45500ae49148; globals `coupaAccounts.output` = array(2). The GENERIC `list-all-records` family, on a connector no corpus artifact has ever touched.",
102
120
  "cliShape": "{items,Pagination}"
103
121
  },
122
+ {
123
+ "nodeType": "uipath.connector.uipath-servicenow-servicenow.list-records",
124
+ "objectName": "acr_user",
125
+ "envelope": null,
126
+ "tier": "A3",
127
+ "measuredAt": "2026-06-23",
128
+ "source": "seven executing 1.0 runs of `skill-flow-generic-dynamic-node` (2026-06-16 … 06-23). `check_generic_dynamic_node.py` runs `flow debug`, then asserts a LIST-valued entry in `variables.globals` and names it — `\"OK: connector completed and surfaced an array output 'listAcrUserRecords1.output'\"`. A wrapper would have failed that assertion. Measured under the operation's pre-#853 id `list-all-records`.",
129
+ "cliShape": "{items,Pagination}"
130
+ },
104
131
  {
105
132
  "nodeType": "uipath.connector.uipath-servicenow-servicenow.list-all-records",
133
+ "keyRetired": "The registry serves this operation as `list-records` since the #853 library rebuild (2026-11-15); the row above carries the measurement. Kept for libraries built before it.",
106
134
  "objectName": "acr_user",
107
135
  "envelope": null,
108
136
  "tier": "A3",