@uipath/maestro-builder-sdk 6.103.0 → 6.104.1

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.
@@ -26,6 +26,7 @@ import { bindingRequiredFields, CASE_RUNTIME_INTERNAL_TYPES, CONNECTOR_ACTIVITY_
26
26
  import { ownEntry } from '../core/own-entry.js';
27
27
  import { MANAGED_HTTP_TYPE, isManagedHttpV2, managedHttpAbsoluteUrl, managedHttpMissing } from './managed-http.js';
28
28
  import { connectorV2Missing, isConnectorV2 } from './connector.js';
29
+ import { lookupConnectionIndex } from '../core/lookup-connection.js';
29
30
  /**
30
31
  * The node row a diagnostic is about, where two rules can report one row: the
31
32
  * authored-task rules (`checkIntsvcActivities`, EMPTY_REQUIRED_FIELD) and the
@@ -120,6 +121,9 @@ export function check(built, opts = {}) {
120
121
  }
121
122
  /** {@link check}, saying whether the serializer pass stopped early, for `check --baseline` (check-baseline.ts). */
122
123
  export function checkModel(built, opts = {}) {
124
+ // Which steps share a recorded lookup row across connections (LOOKUP_CONNECTION_MISMATCH), file-wide.
125
+ if (opts.resolutions && !opts.lookupConnections)
126
+ opts = { ...opts, lookupConnections: lookupConnectionIndex(built, opts.resolutions, opts.bindings) };
123
127
  const diags = [];
124
128
  // Duplicate and missing ids (`documentIdProblems`) are the serializer's.
125
129
  checkScope(built.nodes, built.flows, 'process', diags, true);
@@ -40,7 +40,7 @@ export interface Diagnostic {
40
40
  * Every hook fails open: without a library, `check` judges a connector task up
41
41
  * to the library, as `compile` would.
42
42
  */
43
- export type CaseCheckOpts = Pick<ConnectorCheckOpts, 'lookups' | 'resolutions' | 'resources' | 'schemaReadiness' | 'bindings'> & {
43
+ export type CaseCheckOpts = Pick<ConnectorCheckOpts, 'lookups' | 'resolutions' | 'resources' | 'schemaReadiness' | 'bindings' | 'lookupConnections'> & {
44
44
  /** The library `compile` serializes against, for the serializer `check` runs. */
45
45
  library?: Library;
46
46
  };
@@ -13,6 +13,7 @@ import { checkRuleSemantics } from './check-rule-semantics.js';
13
13
  import { serialize } from './serialize.js';
14
14
  import { lintPlanFindings, planReport } from './plan-check/index.js';
15
15
  import { caseExprLints } from './case-expr-check.js';
16
+ import { lookupConnectionIndex } from '../core/lookup-connection.js';
16
17
  const TYPE_NAMES = new Set(Object.values(types));
17
18
  // audit-case-coverage: rule-slot table start
18
19
  // This runtime table must equal the committed matrix's rejected cells. The audit
@@ -27,6 +28,9 @@ const ILLEGAL = [];
27
28
  * @returns Every diagnostic found. An `error` fails `check`; only a `lowering` error stops `compile`.
28
29
  */
29
30
  export function check(built, opts = {}) {
31
+ // Which steps share a recorded lookup row across connections (LOOKUP_CONNECTION_MISMATCH), file-wide.
32
+ if (opts.resolutions && !opts.lookupConnections)
33
+ opts = { ...opts, lookupConnections: lookupConnectionIndex(built, opts.resolutions, opts.bindings) };
30
34
  const diags = [];
31
35
  if (!built.id)
32
36
  diags.push({ level: 'error', code: 'NO_ID', message: 'casePlan() requires an id.' });
package/dist/check.js CHANGED
@@ -26,6 +26,7 @@ import { loopParallelWarning, resolveLoopDefinition, loopVersion } from './loop-
26
26
  import { refusalClass } from './core/refusals.js';
27
27
  import { classifyDrafts, placeDiagnostics } from './edit-scope.js';
28
28
  import { preExistingFindings, scopeFindings } from './core/baseline-scope.js';
29
+ import { lookupConnectionIndex } from './core/lookup-connection.js';
29
30
  export function check(built, opts = {}) {
30
31
  return checkCompiled(built, opts).diagnostics;
31
32
  }
@@ -36,6 +37,9 @@ export function check(built, opts = {}) {
36
37
  * code's `class`.
37
38
  */
38
39
  export function checkCompiled(built, opts = {}) {
40
+ // Which steps share a recorded lookup row across connections (LOOKUP_CONNECTION_MISMATCH), file-wide.
41
+ if (opts.resolutions && !opts.lookupConnections)
42
+ opts = { ...opts, lookupConnections: lookupConnectionIndex(built, opts.resolutions, opts.bindings) };
39
43
  // A connection two connectors use, and an agent resource's `nodeId` another
40
44
  // node of the file has, are the serializer's CONNECTION_CONNECTOR_CONFLICT /
41
45
  // FLOW_AGENT_RESOURCE_NODE_ID: it claims ids and resolves connections file-wide.
@@ -219,8 +219,28 @@ export interface FormFieldSettings {
219
219
  /** Guidance for an agent that pre-fills the field. */
220
220
  description?: string;
221
221
  }
222
+ /**
223
+ * The form-row keys a field carries that the SDK has no option for (#1989).
224
+ */
225
+ export interface FormFieldRowExtra {
226
+ /**
227
+ * Keys written onto the field's row as they are, after the ones the SDK
228
+ * writes itself. A key the SDK writes from one of the field's own options
229
+ * (`id`, `label`, `type`, `direction`, a setting, a `required` or
230
+ * `variable` also set as an option, a shown field's `binding`) is refused:
231
+ * `HITL_FIELD_EXTRA_CONFLICT`. An asked field's `variable` with no typed
232
+ * `variable` replaces the SDK's default `vars.<id>`. Decompile fills
233
+ * it from a `.flow` row the designer wrote, so an edit to the node keeps what
234
+ * the SDK cannot model: a key the platform's field schema does not define, a
235
+ * `variable` other than `vars.<name>`, a `binding` on an asked field. The SDK
236
+ * does not check what is inside. For instance
237
+ * `{ id: 'note', type: 'string', direction: 'output', extra: { variable: 'vars.order.note' } }`
238
+ * writes `"variable": "vars.order.note"` in place of `"vars.note"`.
239
+ */
240
+ extra?: Record<string, unknown>;
241
+ }
222
242
  /** A value the reviewer READS: shown on the form, filled in from the flow. */
223
- export interface ShownField extends FormFieldSettings {
243
+ export interface ShownField extends FormFieldSettings, FormFieldRowExtra {
224
244
  /** Field id — the key the answer object uses. Must be unique on the form. */
225
245
  id: string;
226
246
  /** Label the reviewer sees. Defaults to `id`. */
@@ -236,7 +256,7 @@ export interface ShownField extends FormFieldSettings {
236
256
  value: Expr;
237
257
  }
238
258
  /** A value the reviewer FILLS IN: read downstream with `out('<step>', '<id>')`. */
239
- export interface AskedField extends FormFieldSettings {
259
+ export interface AskedField extends FormFieldSettings, FormFieldRowExtra {
240
260
  /** Field id — the key the answer object uses. Must be unique on the form. */
241
261
  id: string;
242
262
  /** Label the reviewer sees. Defaults to `id`. */
@@ -261,7 +281,7 @@ export interface AskedField extends FormFieldSettings {
261
281
  * answer. Read it downstream with `out('<step>', '<id>')` — the write target is
262
282
  * the field's own id, deliberately decoupled from where the pre-fill came from.
263
283
  */
264
- export interface InOutField extends FormFieldSettings {
284
+ export interface InOutField extends FormFieldSettings, FormFieldRowExtra {
265
285
  /** Field id — the key the answer object uses. Must be unique on the form. */
266
286
  id: string;
267
287
  /** Label the reviewer sees. Defaults to `id`. */
@@ -25,6 +25,7 @@
25
25
  import { type LookupResolutions, type LookupSpec } from './lookups.js';
26
26
  import type { SchemaReadiness } from './library.js';
27
27
  import { CompileRefusal } from './compile-refusal.js';
28
+ import { type LookupConnectionIndex } from './lookup-connection.js';
28
29
  import { type ResourceResolutions } from './resource-resolution.js';
29
30
  import { type BindingsView, type PrepareTarget } from './binding-messages.js';
30
31
  /** One connector activity, as every family already models it. */
@@ -152,6 +153,12 @@ export interface ConnectorCheckOpts {
152
153
  }, inputs: Record<string, unknown>) => string | undefined;
153
154
  /** The project's `bindings.json`, for the label rules. */
154
155
  bindings?: BindingsView;
156
+ /**
157
+ * Which bound connections use each recorded lookup row, file-wide
158
+ * (`lookupConnectionIndex`), so LOOKUP_CONNECTION_MISMATCH can tell a row two
159
+ * steps share across connections from one `prepare` can fix.
160
+ */
161
+ lookupConnections?: LookupConnectionIndex;
155
162
  }
156
163
  /**
157
164
  * The `resource()` / `entity()` inputs.
@@ -22,12 +22,13 @@
22
22
  * over `vars`. Without this a BPMN `'=vars.channelId'` would read as a pasted
23
23
  * literal id and warn about itself.
24
24
  */
25
- import { isLookupToken, resolvedValue, } from './lookups.js';
25
+ import { isLookupToken, recordedResolution, } from './lookups.js';
26
26
  import { Expr } from './expr.js';
27
27
  import { isRecord } from './node-envelope.js';
28
28
  import { extractRefs } from './expr-check.js';
29
29
  import { prepareCommand, resolveFlagArg } from './cli-spelling.js';
30
30
  import { CompileRefusal } from './compile-refusal.js';
31
+ import { LOOKUP_CONNECTION_MISMATCH, lookupConnectionMismatch } from './lookup-connection.js';
31
32
  import { isResourceToken, resolveRecordedResource } from './resource-resolution.js';
32
33
  import { bindingLabelRefusal, bindingMissingMessage, missingBindingLabels, } from './binding-messages.js';
33
34
  /**
@@ -187,6 +188,9 @@ unresolvedWarning = true) {
187
188
  // `integration_service_boundary` eval card went from 70 turns to 86 and from
188
189
  // 0/3 to 3/3 `max_turns_exhausted` when BPMN started reporting them at all.
189
190
  const unresolved = [];
191
+ // Recorded lookups, for LOOKUP_CONNECTION_MISMATCH: each row names the
192
+ // connection it was resolved on, and the step names the one it runs on.
193
+ const resolved = [];
190
194
  const literals = [];
191
195
  const visit = (value, path) => {
192
196
  if (isLookupToken(value)) {
@@ -213,8 +217,11 @@ unresolvedWarning = true) {
213
217
  });
214
218
  return;
215
219
  }
216
- if (resolvedValue(value, resolutions) === undefined)
220
+ const row = recordedResolution(value, resolutions);
221
+ if (row?.value === undefined)
217
222
  unresolved.push(value);
223
+ else
224
+ resolved.push({ token: value, row, name: named });
218
225
  return;
219
226
  }
220
227
  const reading = dialect.classify(value);
@@ -263,6 +270,9 @@ unresolvedWarning = true) {
263
270
  visit(value, [name]);
264
271
  if (unresolved.length && unresolvedWarning)
265
272
  report(unresolvedDiagnostic(where, spec, unresolved));
273
+ const mismatch = lookupConnectionMismatch(where, resolved, spec.connection, opts.bindings, { key: spec.key, action: spec.action }, opts.lookupConnections);
274
+ if (mismatch)
275
+ report({ level: 'error', code: LOOKUP_CONNECTION_MISMATCH, message: mismatch });
266
276
  if (literals.length)
267
277
  report(literalIdDiagnostic(where, spec, literals, dialect.descriptors));
268
278
  }
@@ -19,6 +19,7 @@
19
19
  * question, and in run 12 on having nowhere to put a payload condition.
20
20
  */
21
21
  import { type LookupResolutions } from './lookups.js';
22
+ import { type LookupConnectionIndex } from './lookup-connection.js';
22
23
  import { type ByoaEventFacts, type ByoaLedger } from './byoa.js';
23
24
  import type { BindingsView } from './binding-messages.js';
24
25
  /** A code/message sink, as each family's check supplies one. */
@@ -95,6 +96,8 @@ export interface EventCheckOpts {
95
96
  resolutions?: LookupResolutions;
96
97
  /** The project's `bindings.json`, for the BYOA connection check. */
97
98
  bindings?: BindingsView;
99
+ /** Which bound connections use each recorded lookup row, file-wide (`lookupConnectionIndex`). */
100
+ lookupConnections?: LookupConnectionIndex;
98
101
  }
99
102
  /**
100
103
  * Ask the library what event parameters a subscription's operation declares.
@@ -18,7 +18,8 @@
18
18
  * `skill-bpmn-outlook-waitfor-email` in `flow-v2-run-8` failed on exactly that last
19
19
  * question, and in run 12 on having nowhere to put a payload condition.
20
20
  */
21
- import { isLookupToken, resolvedEventValue, unresolvedLookupMessage, } from './lookups.js';
21
+ import { isLookupToken, recordedEventResolution, unresolvedLookupMessage, } from './lookups.js';
22
+ import { LOOKUP_CONNECTION_MISMATCH, lookupConnectionMismatch } from './lookup-connection.js';
22
23
  import { prepareCommand } from './cli-spelling.js';
23
24
  import { EVENT_FILTER_OPERATORS, eventFiltersNotArray, readEventFilter, eventFilterExpressionRefusal, eventFilterProblem, jmesStringProblem } from './event-filters.js';
24
25
  import { EVENT_BYOA_UNVERIFIED, byoaUnverified } from './byoa.js';
@@ -134,14 +135,27 @@ compileRefusals = true) {
134
135
  const resolutions = opts.resolutions ?? {};
135
136
  const scope = sub.where && typeof sub.where === 'object'
136
137
  ? Object.entries(sub.where) : [];
137
- for (const [key, value] of compileRefusals ? scope : []) {
138
+ // Recorded `where` lookups, for LOOKUP_CONNECTION_MISMATCH. Reported whatever
139
+ // `compileRefusals` says: compile writes a mismatched id without a word.
140
+ const recorded = [];
141
+ for (const [key, value] of scope) {
138
142
  if (!isLookupToken(value))
139
143
  continue;
140
- if (resolvedEventValue(value, resolutions) !== undefined)
144
+ const row = recordedEventResolution(value, resolutions);
145
+ if (row?.value !== undefined) {
146
+ recorded.push({ token: value, row, name: `where.${key}` });
147
+ continue;
148
+ }
149
+ if (!compileRefusals)
141
150
  continue;
142
151
  warn('LOOKUP_UNRESOLVED', `${where}: \`where.${key}\` ` + unresolvedLookupMessage(value)
143
152
  + `\nCompile will fail until this is recorded.`);
144
153
  }
154
+ const mismatch = lookupConnectionMismatch(where, recorded, sub.connection, opts.bindings, {
155
+ key: connectorKey, action: eventName, ...(object ? { extra: ['--object', object] } : {}),
156
+ }, opts.lookupConnections);
157
+ if (mismatch)
158
+ error(LOOKUP_CONNECTION_MISMATCH, mismatch);
145
159
  const names = opts.eventFilterFields?.(sub.connector, sub.event, object);
146
160
  if (names && names.length > 0 && Array.isArray(sub.filters)) {
147
161
  const known = new Set(names);
@@ -216,13 +216,67 @@ export declare function formFieldVariableName(variable: unknown): string | undef
216
216
  * The keys of a form row the SDK cannot carry into source, each with why.
217
217
  * Empty when decompile → compile writes the row back as it was. The lifts
218
218
  * report a non-empty list as a warning (an error under `--strict`), so no key
219
- * is dropped silently.
219
+ * is dropped silently. What is left is a value the platform refuses or drops
220
+ * itself: a setting of the wrong shape, an unknown key inside `options` or
221
+ * `rules`, a label or `required` of the wrong type. Every other key the SDK
222
+ * has no option for is carried in the field's `extra` (`formFieldRowExtra`).
220
223
  *
221
224
  * @example
222
225
  * formFieldRowLoss({ id: 'a', label: 'A', type: 'string', direction: 'output', colSpan: 13 }, 'human task')
223
226
  * // ['colSpan: 13 (not the platform\'s shape for it)']
224
227
  */
225
228
  export declare function formFieldRowLoss(row: Record<string, unknown>, site: FormRowSite): string[];
229
+ /**
230
+ * The keys of a form row the SDK has no option for, which decompile lifts into
231
+ * the field's `extra` so compile writes them back as they were (#1989): a key
232
+ * the platform's field schema does not define, a `variable` other than the
233
+ * `vars.<name>` the SDK writes on an asked field, a `binding` or `variable`
234
+ * where the SDK writes none, the form editor's `value`, `required: true` on a
235
+ * shown field. Empty when there is none.
236
+ *
237
+ * @example
238
+ * formFieldRowExtra({ id: 'a', type: 'string', direction: 'output', variable: 'vars.order.note', hint: 'x' }, 'human task')
239
+ * // { variable: 'vars.order.note', hint: 'x' }
240
+ */
241
+ export declare function formFieldRowExtra(row: Record<string, unknown>, site: FormRowSite): Record<string, unknown>;
242
+ /**
243
+ * The `extra` keys that would replace a row key the SDK writes from one of the
244
+ * field's typed options, in `extra`'s order. Empty when there is none.
245
+ *
246
+ * The serializers refuse a field with one (`HITL_FIELD_EXTRA_CONFLICT`,
247
+ * `FLOW_AGENT_ESCALATION_FIELD_EXTRA_CONFLICT`): with `extra` spread last, the
248
+ * row would say one thing and the rest of the node another. For instance
249
+ * `{ id: 'amt', type: 'string', direction: 'output', extra: { type: 'number' } }`
250
+ * would write a number row while the task's outputs still say `amt: string`.
251
+ * The keys:
252
+ * - `id`, `label`, `type`, `direction` and every settings key, always;
253
+ * - `required`, when the typed `required` is set too;
254
+ * - on a human task, `variable` when the typed `variable` is set too, and
255
+ * `binding` on a shown or pre-filled field, whose `binding` the SDK writes
256
+ * from `value`.
257
+ * What decompile carries never conflicts (`formFieldRowExtra`): each key it
258
+ * lifts into `extra` is one the SDK did not write for that row.
259
+ *
260
+ * @example
261
+ * formFieldExtraConflicts({ id: 'a', direction: 'output', variable: 'v', extra: { variable: 'vars.x', hint: 1 } }, 'human task') // ['variable']
262
+ */
263
+ export declare function formFieldExtraConflicts(f: {
264
+ direction?: unknown;
265
+ required?: unknown;
266
+ variable?: unknown;
267
+ extra?: Record<string, unknown>;
268
+ }, site: FormRowSite): string[];
269
+ /**
270
+ * A field's `extra` as the form row carries it: each key copied, so the wire
271
+ * never aliases the author's objects. The serializers spread it LAST, so a key
272
+ * the SDK also writes (an asked field's `variable`) takes the `extra` value.
273
+ *
274
+ * @example
275
+ * formFieldExtraWire({ extra: { hint: 'x' } }) // { hint: 'x' }
276
+ */
277
+ export declare function formFieldExtraWire(f: {
278
+ extra?: Record<string, unknown>;
279
+ }): Record<string, unknown>;
226
280
  /**
227
281
  * The warning (or `--strict` error) for a row `formFieldRowLoss` reported.
228
282
  * `where` names the form, e.g. `human task "review"`.
@@ -472,36 +472,31 @@ export function formFieldVariableName(variable) {
472
472
  const m = typeof variable === 'string' ? /^vars\.([A-Za-z_$][\w$]*)$/.exec(variable) : null;
473
473
  return m ? m[1] : undefined;
474
474
  }
475
- /**
476
- * The keys of a form row the SDK cannot carry into source, each with why.
477
- * Empty when decompile → compile writes the row back as it was. The lifts
478
- * report a non-empty list as a warning (an error under `--strict`), so no key
479
- * is dropped silently.
480
- *
481
- * @example
482
- * formFieldRowLoss({ id: 'a', label: 'A', type: 'string', direction: 'output', colSpan: 13 }, 'human task')
483
- * // ['colSpan: 13 (not the platform\'s shape for it)']
484
- */
485
- export function formFieldRowLoss(row, site) {
475
+ /** A form row's keys sorted by what decompile can do with them (`formFieldRowLoss`, `formFieldRowExtra`). */
476
+ function sortRowKeys(row, site) {
486
477
  const loss = [];
487
- const id = String(row.id ?? '');
478
+ const extra = {};
488
479
  const direction = row.direction;
489
480
  const say = (key, why) => {
490
481
  loss.push(`${key}: ${JSON.stringify(row[key])} (${why})`);
491
482
  };
483
+ // A key the SDK has no option for, written back as it is (#1989).
484
+ const carry = (key) => {
485
+ extra[key] = jsonClone(row[key]);
486
+ };
492
487
  for (const key of Object.keys(row)) {
493
488
  if (row[key] === undefined)
494
489
  continue;
495
490
  if (!FORM_FIELD_ROW_KEYS.includes(key)) {
496
- say(key, 'not a key of the platform\'s field schema');
491
+ carry(key);
497
492
  }
498
493
  else if (Object.hasOwn(SETTINGS, key)) {
499
494
  if (!validSetting(key, row[key]))
500
495
  say(key, 'not the platform\'s shape for it');
501
496
  else {
502
- const extra = settingExtraKeys(key, row[key]);
503
- if (extra.length > 0)
504
- say(key, `${extra.join(', ')}: not in the platform's schema, which drops it too`);
497
+ const extraKeys = settingExtraKeys(key, row[key]);
498
+ if (extraKeys.length > 0)
499
+ say(key, `${extraKeys.join(', ')}: not in the platform's schema, which drops it too`);
505
500
  }
506
501
  }
507
502
  else if (key === 'label') {
@@ -509,33 +504,110 @@ export function formFieldRowLoss(row, site) {
509
504
  say(key, 'not a string');
510
505
  }
511
506
  else if (key === 'value') {
512
- say(key, 'the form editor\'s structured binding; a .flow stores it as `binding`, which is all the SDK reads');
507
+ // The form editor's structured binding: a .flow stores it as `binding`, which is all the SDK reads.
508
+ carry(key);
513
509
  }
514
510
  else if (key === 'required') {
515
511
  // `required: false` is the default: compile omits it, and the form behaves the same.
516
512
  if (typeof row.required !== 'boolean')
517
513
  say(key, 'not a boolean');
518
514
  else if (direction === 'input' && row.required)
519
- say(key, 'on a shown field, which the SDK does not model');
515
+ carry(key);
520
516
  }
521
517
  else if (key === 'binding') {
522
- if (site === 'escalation')
523
- say(key, 'on an escalation form, which the SDK writes without bindings');
524
- else if (direction === 'output')
525
- say(key, 'on an asked field, which the SDK writes without one');
518
+ if (site === 'escalation' || direction === 'output')
519
+ carry(key);
526
520
  else if (!isString(row.binding))
527
521
  say(key, 'not a string');
528
522
  }
529
523
  else if (key === 'variable') {
530
- if (site === 'escalation')
531
- say(key, 'on an escalation form, which the SDK writes without variables');
532
- else if (direction !== 'output')
533
- say(key, 'on a shown or pre-filled field, which the SDK writes without one');
534
- else if (formFieldVariableName(row.variable) === undefined)
535
- say(key, `not a 'vars.<name>' path, which is what the SDK writes ('vars.${id}' by default)`);
524
+ // The SDK writes `vars.<variable or id>` on an asked field and nothing elsewhere; any other spelling is carried.
525
+ if (site === 'escalation' || direction !== 'output' || formFieldVariableName(row.variable) === undefined)
526
+ carry(key);
536
527
  }
537
528
  }
538
- return loss;
529
+ return { loss, extra };
530
+ }
531
+ /**
532
+ * The keys of a form row the SDK cannot carry into source, each with why.
533
+ * Empty when decompile → compile writes the row back as it was. The lifts
534
+ * report a non-empty list as a warning (an error under `--strict`), so no key
535
+ * is dropped silently. What is left is a value the platform refuses or drops
536
+ * itself: a setting of the wrong shape, an unknown key inside `options` or
537
+ * `rules`, a label or `required` of the wrong type. Every other key the SDK
538
+ * has no option for is carried in the field's `extra` (`formFieldRowExtra`).
539
+ *
540
+ * @example
541
+ * formFieldRowLoss({ id: 'a', label: 'A', type: 'string', direction: 'output', colSpan: 13 }, 'human task')
542
+ * // ['colSpan: 13 (not the platform\'s shape for it)']
543
+ */
544
+ export function formFieldRowLoss(row, site) {
545
+ return sortRowKeys(row, site).loss;
546
+ }
547
+ /**
548
+ * The keys of a form row the SDK has no option for, which decompile lifts into
549
+ * the field's `extra` so compile writes them back as they were (#1989): a key
550
+ * the platform's field schema does not define, a `variable` other than the
551
+ * `vars.<name>` the SDK writes on an asked field, a `binding` or `variable`
552
+ * where the SDK writes none, the form editor's `value`, `required: true` on a
553
+ * shown field. Empty when there is none.
554
+ *
555
+ * @example
556
+ * formFieldRowExtra({ id: 'a', type: 'string', direction: 'output', variable: 'vars.order.note', hint: 'x' }, 'human task')
557
+ * // { variable: 'vars.order.note', hint: 'x' }
558
+ */
559
+ export function formFieldRowExtra(row, site) {
560
+ return sortRowKeys(row, site).extra;
561
+ }
562
+ /**
563
+ * The `extra` keys that would replace a row key the SDK writes from one of the
564
+ * field's typed options, in `extra`'s order. Empty when there is none.
565
+ *
566
+ * The serializers refuse a field with one (`HITL_FIELD_EXTRA_CONFLICT`,
567
+ * `FLOW_AGENT_ESCALATION_FIELD_EXTRA_CONFLICT`): with `extra` spread last, the
568
+ * row would say one thing and the rest of the node another. For instance
569
+ * `{ id: 'amt', type: 'string', direction: 'output', extra: { type: 'number' } }`
570
+ * would write a number row while the task's outputs still say `amt: string`.
571
+ * The keys:
572
+ * - `id`, `label`, `type`, `direction` and every settings key, always;
573
+ * - `required`, when the typed `required` is set too;
574
+ * - on a human task, `variable` when the typed `variable` is set too, and
575
+ * `binding` on a shown or pre-filled field, whose `binding` the SDK writes
576
+ * from `value`.
577
+ * What decompile carries never conflicts (`formFieldRowExtra`): each key it
578
+ * lifts into `extra` is one the SDK did not write for that row.
579
+ *
580
+ * @example
581
+ * formFieldExtraConflicts({ id: 'a', direction: 'output', variable: 'v', extra: { variable: 'vars.x', hint: 1 } }, 'human task') // ['variable']
582
+ */
583
+ export function formFieldExtraConflicts(f, site) {
584
+ if (f.extra === undefined || f.extra === null || typeof f.extra !== 'object')
585
+ return [];
586
+ const always = ['id', 'label', 'type', 'direction', ...FORM_FIELD_SETTINGS_KEYS];
587
+ return Object.keys(f.extra).filter((key) => {
588
+ if (always.includes(key))
589
+ return true;
590
+ if (key === 'required')
591
+ return f.required !== undefined;
592
+ if (site !== 'human task')
593
+ return false;
594
+ if (key === 'variable')
595
+ return f.variable !== undefined;
596
+ if (key === 'binding')
597
+ return f.direction === 'input' || f.direction === 'inOut';
598
+ return false;
599
+ });
600
+ }
601
+ /**
602
+ * A field's `extra` as the form row carries it: each key copied, so the wire
603
+ * never aliases the author's objects. The serializers spread it LAST, so a key
604
+ * the SDK also writes (an asked field's `variable`) takes the `extra` value.
605
+ *
606
+ * @example
607
+ * formFieldExtraWire({ extra: { hint: 'x' } }) // { hint: 'x' }
608
+ */
609
+ export function formFieldExtraWire(f) {
610
+ return f.extra !== undefined && f.extra !== null && typeof f.extra === 'object' ? jsonClone(f.extra) : {};
539
611
  }
540
612
  /**
541
613
  * The warning (or `--strict` error) for a row `formFieldRowLoss` reported.
@@ -0,0 +1,90 @@
1
+ /**
2
+ * core/lookup-connection — a recorded lookup id used on a different connection
3
+ * than the one it was resolved on (#1982).
4
+ *
5
+ * A lookup id belongs to one connection. Slack user `U123` exists on the
6
+ * workspace it was looked up in and nowhere else; a Jira issue-type id is valid
7
+ * in one site. `prepare --resolve` records the connection each id came from
8
+ * (`connectionId` on the row in `connectors-local/resolutions.json`), and this
9
+ * module compares it with the connection the step is bound to. Before the
10
+ * field existed, an id resolved on connection A and bound to connection B
11
+ * compiled cleanly and failed at run time, and the skill told the agent to
12
+ * compare the two by hand.
13
+ *
14
+ * `lint`, not `lowering`: the serializer writes exactly the id that was
15
+ * recorded, and some lookups are the same on every connection (Slack's
16
+ * `send_as` sends the word `bot`), so the id is probably wrong, not certainly.
17
+ * The remedy is cheap either way: resolve again on the bound connection.
18
+ *
19
+ * One row cannot serve two connections yet (#2042): rows are keyed
20
+ * `[nodeType, field, by, value]`, not by connection. When two steps use the
21
+ * same row on two different bound connections, re-running `prepare` on one
22
+ * only moves the error to the other, so the message says so and prints no
23
+ * command ({@link lookupConnectionIndex}).
24
+ *
25
+ * Silent when there is nothing to compare: a row without `connectionId` (an
26
+ * older ledger), or a step whose connection does not resolve to a real id (no
27
+ * bindings.json, an undeclared label, a placeholder GUID). The binding rules
28
+ * already report the last two.
29
+ *
30
+ * No `node:` imports: `check` imports this module (FB015).
31
+ */
32
+ import { type BindingsView } from './binding-messages.js';
33
+ import { type LookupResolution, type LookupResolutions, type LookupToken } from './lookups.js';
34
+ /** The diagnostic code. */
35
+ export declare const LOOKUP_CONNECTION_MISMATCH = "LOOKUP_CONNECTION_MISMATCH";
36
+ /** One resolved lookup on a step: the token, the row it resolved to, and how the message names the field. */
37
+ export interface ResolvedLookupUse {
38
+ token: LookupToken;
39
+ row: LookupResolution;
40
+ /** The field as the author wrote it, e.g. `channel` or `where.parentFolderId`. */
41
+ name: string;
42
+ }
43
+ /**
44
+ * The connection id a step is bound to, or `undefined` when it does not
45
+ * resolve to a real one. Same reading as `byoaUnverified`: the label through
46
+ * bindings.json, else the label itself when it is already an id.
47
+ */
48
+ export declare function boundConnectionId(connection: unknown, bindings: Pick<BindingsView, 'resolve'> | undefined): string | undefined;
49
+ /**
50
+ * Which bound connections use each recorded row, across a whole built flow,
51
+ * case or process. Keyed by the row object itself (the ledger's own entry), so
52
+ * an event token found under the event-form key and an activity token under
53
+ * its own key land on the same row when they share one.
54
+ */
55
+ export type LookupConnectionIndex = ReadonlyMap<LookupResolution, ReadonlySet<string>>;
56
+ /**
57
+ * Build the {@link LookupConnectionIndex} for one built artifact.
58
+ *
59
+ * Family-agnostic, like the rules it feeds: it walks the built object and
60
+ * reads every object that carries a string `connection` beside `inputs` (a
61
+ * connector activity) or `where` (an event subscription) — the same
62
+ * `{ inputs, connection }` and `{ where, connection }` shapes
63
+ * `checkConnectorLookups` and `checkEventResolution` read. Connections are
64
+ * read through bindings.json as {@link boundConnectionId} reads them, and
65
+ * stored lower-cased.
66
+ *
67
+ * @param root - The built flow, case or process.
68
+ * @param resolutions - Everything `prepare --resolve` has recorded.
69
+ * @param bindings - Resolves a `connection:` label to an id.
70
+ */
71
+ export declare function lookupConnectionIndex(root: unknown, resolutions: LookupResolutions | undefined, bindings: Pick<BindingsView, 'resolve'> | undefined): LookupConnectionIndex;
72
+ /**
73
+ * The LOOKUP_CONNECTION_MISMATCH message for one step, or `undefined` when no
74
+ * recorded lookup on it came from another connection. One message per step,
75
+ * like LOOKUP_UNRESOLVED: the remedy is one `prepare` with every `--resolve`.
76
+ * A row another step uses on a different connection gets no command (see the
77
+ * module header): one row cannot serve two connections yet.
78
+ *
79
+ * @param where - How the message opens (`Connector step "post"`, `trigger`).
80
+ * @param uses - Every resolved lookup on the step.
81
+ * @param connection - The step's `connection:` as authored.
82
+ * @param bindings - Resolves the label to an id.
83
+ * @param command - The `<key> <action-or-event>` the prepare command takes, plus any extra flags (`--object x`).
84
+ * @param index - Which bound connections use each row, file-wide; without it every row reads as used by this step alone.
85
+ */
86
+ export declare function lookupConnectionMismatch(where: string, uses: readonly ResolvedLookupUse[], connection: unknown, bindings: Pick<BindingsView, 'resolve'> | undefined, command: {
87
+ key: string;
88
+ action: string;
89
+ extra?: readonly string[];
90
+ }, index?: LookupConnectionIndex): string | undefined;