@uipath/maestro-builder-sdk 6.96.7 → 6.97.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.
Files changed (55) hide show
  1. package/README.md +2 -1
  2. package/dist/api-index.md +62 -62
  3. package/dist/api-members.md +292 -289
  4. package/dist/bpmn/bpmn-sdk.d.ts +36 -0
  5. package/dist/bpmn/check-cli.js +8 -4
  6. package/dist/bpmn/compile-cli.js +4 -3
  7. package/dist/bpmn/decompile-cli.js +15 -1
  8. package/dist/bpmn/decompile-pipeline.d.ts +5 -0
  9. package/dist/bpmn/decompile-pipeline.js +3 -3
  10. package/dist/bpmn/decompile-stamp.d.ts +13 -0
  11. package/dist/bpmn/decompile-stamp.js +8 -0
  12. package/dist/bpmn/decompile.d.ts +17 -4
  13. package/dist/bpmn/decompile.js +19 -10
  14. package/dist/bpmn/merge-cli.js +32 -4
  15. package/dist/bpmn/merge-source.d.ts +2 -0
  16. package/dist/bpmn/merge-source.js +1 -0
  17. package/dist/bpmn/serialize.js +7 -1
  18. package/dist/bpmn/typed-node.d.ts +7 -0
  19. package/dist/bpmn/typed-node.js +50 -26
  20. package/dist/bpmn-api.md +3 -0
  21. package/dist/case/check-cli.js +4 -2
  22. package/dist/case/compile-cli.js +14 -9
  23. package/dist/case/decompile-cli.d.ts +1 -1
  24. package/dist/case/decompile-cli.js +12 -2
  25. package/dist/check-cli.js +12 -6
  26. package/dist/cli/commands/registry.js +2 -0
  27. package/dist/compile-cli.js +16 -10
  28. package/dist/core/cli-library.d.ts +18 -2
  29. package/dist/core/cli-library.js +25 -5
  30. package/dist/core/library.d.ts +74 -2
  31. package/dist/core/library.js +88 -11
  32. package/dist/decompile-cli.js +17 -2
  33. package/dist/decompile-stamp.d.ts +13 -0
  34. package/dist/decompile-stamp.js +7 -1
  35. package/dist/emit.js +5 -8
  36. package/dist/merge-cli.js +51 -1
  37. package/dist/registry/curated-overlay.d.ts +11 -0
  38. package/dist/registry/curated-overlay.js +27 -0
  39. package/dist/registry/describe-cli.d.ts +3 -0
  40. package/dist/registry/describe-cli.js +38 -6
  41. package/dist/registry/fetch/fetch-connectors.d.ts +21 -0
  42. package/dist/registry/fetch/fetch-connectors.js +84 -0
  43. package/dist/registry/fetch/fetch-definitions.d.ts +61 -0
  44. package/dist/registry/fetch/fetch-definitions.js +447 -0
  45. package/dist/registry/fetch/flow-requests.d.ts +14 -0
  46. package/dist/registry/fetch/flow-requests.js +81 -0
  47. package/dist/registry/fetch/with-fetched-definitions.d.ts +46 -0
  48. package/dist/registry/fetch/with-fetched-definitions.js +211 -0
  49. package/dist/registry/library-build/events.d.ts +9 -2
  50. package/dist/registry/library-build/events.js +4 -10
  51. package/dist/registry/pull-cli.d.ts +9 -0
  52. package/dist/registry/pull-cli.js +150 -10
  53. package/dist/registry/search-cli.d.ts +25 -0
  54. package/dist/registry/search-cli.js +94 -10
  55. package/package.json +4 -3
@@ -605,6 +605,14 @@ export interface ProcessMetadata {
605
605
  * the product's `name` is the SOURCE variable's display name, not the target's,
606
606
  * and no derivation reproduces that.
607
607
  *
608
+ * A payload can also CONFIGURE its element: Studio Web puts a connector call on a
609
+ * message end event or intermediate throw event (`Intsvc.ActivityExecution`), and a
610
+ * connector wait on an intermediate catch or boundary event (`Intsvc.WaitForEvent`),
611
+ * none of which is the element the registry names for the type. Those carry their
612
+ * connector key, connection binding, operation and request rows in
613
+ * {@link ExtensionPayload.contextRows} and {@link ExtensionPayload.inputRows}, and
614
+ * the runtime reads them there (`IntSvcIntermediateThrowEventWorkflowV2`).
615
+ *
608
616
  * @example
609
617
  * **A start event mapping two process inputs onto variables**
610
618
  * ```ts
@@ -647,6 +655,34 @@ export interface ExtensionPayload {
647
655
  tag?: 'uipath:activity' | 'uipath:event' | 'uipath:mapping';
648
656
  /** The `uipath:type` `version` attribute, when it is not `v1` — see `ActivityNodeOpts.typeVersion`. */
649
657
  typeVersion?: string;
658
+ /**
659
+ * The `uipath:context` rows, emitted verbatim — see {@link TypedContextRow}.
660
+ *
661
+ * Decompile writes these for a payload that configures its element, such as a
662
+ * connector call on an end event:
663
+ *
664
+ * ```ts
665
+ * .endEvent('notify', {
666
+ * message: '',
667
+ * payload: {
668
+ * type: 'Intsvc.ActivityExecution',
669
+ * contextRows: [
670
+ * { name: 'connectorKey', value: 'uipath-microsoft-outlook365' },
671
+ * { name: 'connection', value: '=bindings.outlook' },
672
+ * ],
673
+ * outputRows: [],
674
+ * },
675
+ * })
676
+ * ```
677
+ *
678
+ * Without them the recompiled element calls a connector with no connector key
679
+ * and no connection, and `check` reports `INTSVC_CONNECTION_MISSING`.
680
+ */
681
+ contextRows?: TypedContextRow[];
682
+ /** The `uipath:inputSchema` body inside `uipath:context` — see `ActivityNodeOpts.inputSchema`. */
683
+ inputSchema?: unknown;
684
+ /** The payload's own `uipath:input` rows, emitted verbatim — see {@link TypedInputRow}. */
685
+ inputRows?: TypedInputRow[];
650
686
  }
651
687
  /**
652
688
  * Options for `.startEvent()`. At most one of `message` / `timer` picks the
@@ -26,7 +26,8 @@ import { check } from './check.js';
26
26
  import { sourceTypeDiagnostics } from './source-types.js';
27
27
  import { graphModel, renderGraph } from './graph.js';
28
28
  import { Bindings } from '../core/bindings.js';
29
- import { connectorCheckOpts, openCliLibrary } from '../core/cli-library.js';
29
+ import { connectorCheckOpts } from '../core/cli-library.js';
30
+ import { withFetchedDefinitions } from '../registry/fetch/with-fetched-definitions.js';
30
31
  import { flagValue, runWhenInvokedDirectly } from '../cli-run.js';
31
32
  import { ensureTypeScriptRuntime } from '../node-runtime.js';
32
33
  import { readCliResources } from '../registry/prepare/resources.js';
@@ -39,11 +40,11 @@ const VALUE_FLAGS = new Set(['--library', '--connectors-local', '--bindings', '-
39
40
  * binding name. Silent when there is no library and no bindings.json — `check`
40
41
  * stays a pure function of the built model then, as it always was.
41
42
  */
42
- function bpmnCheckOpts(argv) {
43
+ function bpmnCheckOpts(argv, library) {
43
44
  const bindFile = flagValue(argv, '--bindings')
44
45
  ?? (existsSync('bindings.json') ? 'bindings.json' : undefined);
45
46
  const resources = readCliResources(argv, defaultResourcesFile());
46
- return { ...connectorCheckOpts(openCliLibrary(argv), bindFile ? new Bindings(bindFile) : undefined), ...(resources ? { resources } : {}) };
47
+ return { ...connectorCheckOpts(library, bindFile ? new Bindings(bindFile) : undefined), ...(resources ? { resources } : {}) };
47
48
  }
48
49
  function printDiagnostics(diags) {
49
50
  for (const d of diags)
@@ -72,7 +73,10 @@ export async function run(argv) {
72
73
  let diags;
73
74
  try {
74
75
  built = await loadBuiltBpmn(file);
75
- diags = [...typeDiags, ...check(built, bpmnCheckOpts(argv))];
76
+ // A connector operation no layer carries is fetched through `uip` and the check
77
+ // runs again, as `compile` does (docs/CONNECTOR_LIBRARY_OPTIONAL_DESIGN.md).
78
+ const loaded = built;
79
+ diags = [...typeDiags, ...(await withFetchedDefinitions(argv, (library) => check(loaded, bpmnCheckOpts(argv, library)), { who: 'check' }))];
76
80
  }
77
81
  catch (error) {
78
82
  // A value of the wrong type usually crashes the build or the check before
@@ -29,7 +29,7 @@ import { basename, resolve } from 'node:path';
29
29
  import { resolveBpmnFile, loadBuiltBpmn } from './load.js';
30
30
  import { serialize } from './serialize.js';
31
31
  import { Bindings } from '../core/bindings.js';
32
- import { openCliLibrary } from '../core/cli-library.js';
32
+ import { withFetchedDefinitions } from '../registry/fetch/with-fetched-definitions.js';
33
33
  import { flagValue, runWhenInvokedDirectly } from '../cli-run.js';
34
34
  import { ensureTypeScriptRuntime } from '../node-runtime.js';
35
35
  import { defaultBindingsFile, defaultResourcesFile } from '../workdir.js';
@@ -63,13 +63,14 @@ export async function run(argv) {
63
63
  // `uip maestro registry prepare` writes. BPMN used to construct the library
64
64
  // without it, so a prepare resolved an operation against the live connection,
65
65
  // wrote the overlay, and compile ignored it.
66
- const library = openCliLibrary(argv);
66
+ // A connector operation no layer carries is fetched through `uip` and the
67
+ // serializer runs again (`withFetchedDefinitions`, docs/CONNECTOR_LIBRARY_OPTIONAL_DESIGN.md).
67
68
  const bindFile = flagValue(argv, '--bindings') ?? defaultBindingsFile();
68
69
  const bindings = new Bindings(bindFile);
69
70
  const resources = readCliResources(argv, defaultResourcesFile());
70
71
  let xml;
71
72
  try {
72
- xml = await serialize(built, { library, bindings, resources });
73
+ xml = await withFetchedDefinitions(argv, (library) => serialize(built, { library, bindings, resources }));
73
74
  }
74
75
  catch (error) {
75
76
  // The serializer cannot write a correct `.bpmn`: a coded refusal, or a throw it
@@ -45,6 +45,8 @@ import { flagValue, runWhenInvokedDirectly } from '../cli-run.js';
45
45
  import { decompilePipeline } from './decompile-pipeline.js';
46
46
  import { sourceDigest, stampSource } from './decompile-stamp.js';
47
47
  import { openCliLibrary } from '../core/cli-library.js';
48
+ import { fetchDefinitionsEnabled } from '../registry/fetch/fetch-definitions.js';
49
+ import { fetchMissedBy } from '../registry/fetch/with-fetched-definitions.js';
48
50
  import { BPMN_IMPORT } from '../package-name.js';
49
51
  import { fileURLToPath } from 'node:url';
50
52
  /**
@@ -98,8 +100,15 @@ export async function run(argv) {
98
100
  // The connector lift (`--connectors lift`, the default when a library opens) and
99
101
  // the nested lift, each verified before it is written: decompile-pipeline.ts, which
100
102
  // `bpmn merge` also runs to derive its baseline from an original.
101
- const library = connectors === 'lift' ? openCliLibrary(argv) : undefined;
102
103
  const sdkEntry = fileURLToPath(new URL('./bpmn-sdk.js', import.meta.url));
104
+ // A connector a task uses and no layer carries is fetched through `uip` first,
105
+ // with its typed module (docs/CONNECTOR_LIBRARY_OPTIONAL_DESIGN.md): one probing
106
+ // lift records what it could not identify, then the real one lifts against what
107
+ // the tenant serves. `merge` fetches the same way, so it derives the same source.
108
+ if (connectors === 'lift') {
109
+ await fetchMissedBy(argv, (probe) => decompilePipeline(xml, { importSpecifier, style, keepFlowIds, keepUnusedBindings, sdkEntry, library: probe }), { who: 'decompile' });
110
+ }
111
+ const library = connectors === 'lift' ? openCliLibrary(argv, { always: fetchDefinitionsEnabled() }) : undefined;
103
112
  const { source, pruned, connectors: connectorSummary, lifted, fallback } = await decompilePipeline(xml, {
104
113
  importSpecifier, style, keepFlowIds, keepUnusedBindings, sdkEntry, ...(library ? { library } : {}),
105
114
  });
@@ -115,6 +124,11 @@ export async function run(argv) {
115
124
  connectors: library ? 'lift' : 'verbatim',
116
125
  keepFlowIds,
117
126
  keepUnusedBindings,
127
+ // Tasks kept verbatim because the library could not name them, so `bpmn merge`
128
+ // keeps them verbatim too after the definitions are fetched (decompile-stamp.ts).
129
+ // Every skip whose outcome depends on what the library holds (LiftSkipKind).
130
+ verbatim: (connectorSummary?.verbatim ?? []).filter((v) => v.kind !== undefined).map((v) => v.id).sort(),
131
+ fetch: true,
118
132
  }));
119
133
  console.log(`decompile: wrote ${out}`);
120
134
  if (pruned.length) {
@@ -25,6 +25,11 @@ export interface DecompilePipelineOptions {
25
25
  keepUnusedBindings?: boolean;
26
26
  /** The connector library; given, connector tasks it can name are lifted to `.connector()`. */
27
27
  library?: Library;
28
+ /**
29
+ * Connector tasks to keep verbatim whatever the library now names: the ones
30
+ * the decompile being reproduced could not name (`verbatim=` in its stamp).
31
+ */
32
+ keepVerbatim?: ReadonlySet<string>;
28
33
  /** Absolute path of the `bpmn-sdk.js` the verifications build against. */
29
34
  sdkEntry: string;
30
35
  }
@@ -17,7 +17,7 @@ export async function decompilePipeline(xml, opts) {
17
17
  // then rides into the nested-style passes below, so the flat and nested sources the
18
18
  // nested verify compares make the same connector decisions.
19
19
  let connectors;
20
- let verbatimConnectors = new Set();
20
+ let verbatimConnectors = new Set(opts.keepVerbatim ?? []);
21
21
  const base0 = {
22
22
  importSpecifier: opts.importSpecifier,
23
23
  keepUnusedBindings: opts.keepUnusedBindings === true,
@@ -33,12 +33,12 @@ export async function decompilePipeline(xml, opts) {
33
33
  if (library && planned && planned.lifted.length > 0) {
34
34
  const verdict = await verifyConnectorLifts(xml, planned, sdkEntry, library);
35
35
  if (verdict.failed.size > 0) {
36
- verbatimConnectors = new Set(verdict.failed.keys());
36
+ verbatimConnectors = new Set([...verbatimConnectors, ...verdict.failed.keys()]);
37
37
  source = await decompile(xml, { ...base0, verbatimConnectors });
38
38
  // The summary from the second pass says "did not verify"; carry the measured reason.
39
39
  const second = summary0();
40
40
  if (second) {
41
- second.verbatim = second.verbatim.map((v) => ({ id: v.id, reason: verdict.failed.get(v.id) ?? v.reason }));
41
+ second.verbatim = second.verbatim.map((v) => ({ ...v, reason: verdict.failed.get(v.id) ?? v.reason }));
42
42
  }
43
43
  }
44
44
  }
@@ -13,6 +13,19 @@ export interface DecompileStamp {
13
13
  keepFlowIds: boolean;
14
14
  /** Decompile was given `--keep-unused-bindings`. */
15
15
  keepUnusedBindings: boolean;
16
+ /**
17
+ * Connector tasks the lift kept verbatim because no library layer could name
18
+ * them. `bpmn merge` keeps them verbatim again to derive the baseline,
19
+ * whatever has been fetched or prepared for them since.
20
+ */
21
+ verbatim: string[];
22
+ /**
23
+ * Written by a decompile that records `verbatim` (the `fetch` token). Without
24
+ * it the stamp predates fetching through `uip`, and an empty `verbatim` says
25
+ * nothing: `bpmn merge` then hides every fetched row instead, which is the
26
+ * library such a decompile saw.
27
+ */
28
+ fetch: boolean;
16
29
  }
17
30
  /** The stamp line, without a line terminator. */
18
31
  export declare function formatStamp(stamp: DecompileStamp): string;
@@ -51,6 +51,8 @@ export function formatStamp(stamp) {
51
51
  `connectors=${stamp.connectors}`,
52
52
  ...(stamp.keepFlowIds ? ['keep-flow-ids'] : []),
53
53
  ...(stamp.keepUnusedBindings ? ['keep-unused-bindings'] : []),
54
+ ...(stamp.verbatim.length > 0 ? [`verbatim=${stamp.verbatim.join(',')}`] : []),
55
+ ...(stamp.fetch ? ['fetch'] : []),
54
56
  ],
55
57
  });
56
58
  }
@@ -77,6 +79,8 @@ export function readStamp(source) {
77
79
  connectors: 'verbatim',
78
80
  keepFlowIds: false,
79
81
  keepUnusedBindings: false,
82
+ verbatim: [],
83
+ fetch: false,
80
84
  };
81
85
  const seen = new Set();
82
86
  for (const token of read.options) {
@@ -92,6 +96,10 @@ export function readStamp(source) {
92
96
  stamp.keepFlowIds = true;
93
97
  else if (key === 'keep-unused-bindings' && value === undefined)
94
98
  stamp.keepUnusedBindings = true;
99
+ else if (key === 'verbatim' && value)
100
+ stamp.verbatim = value.split(',');
101
+ else if (key === 'fetch' && value === undefined)
102
+ stamp.fetch = true;
95
103
  else
96
104
  return { error: `unknown option \`${token}\`: ${line}` };
97
105
  }
@@ -129,15 +129,28 @@ export interface LiftSummary {
129
129
  /** Whether the top level was written in `.flowMode('sequence')`. */
130
130
  sequence: boolean;
131
131
  }
132
+ /**
133
+ * Why a connector task stayed verbatim, for the reasons that depend on what the
134
+ * library holds, so fetching or preparing a definition later changes the
135
+ * decision: `not-in-library`, no layer could name its operation;
136
+ * `library-cannot-resolve`, the operation was named but its entry (or the
137
+ * object asked for) could not be resolved; `field-not-in-library`, an input the
138
+ * entry does not declare. `bpmn decompile` records every such task in its
139
+ * stamp (`verbatim=`).
140
+ */
141
+ export type LiftSkipKind = 'not-in-library' | 'library-cannot-resolve' | 'field-not-in-library';
142
+ /** A connector task the lift keeps verbatim: why, and its kind when it is one a caller acts on. */
143
+ export interface LiftSkip {
144
+ id: string;
145
+ reason: string;
146
+ kind?: LiftSkipKind;
147
+ }
132
148
  /** What the connector lift did on one decompile — see `BpmnDecompileOptions.connectors`. */
133
149
  export interface ConnectorLiftSummary {
134
150
  /** Element ids written as `.connector()`. */
135
151
  lifted: string[];
136
152
  /** Connector tasks written verbatim, each with the reason. */
137
- verbatim: Array<{
138
- id: string;
139
- reason: string;
140
- }>;
153
+ verbatim: LiftSkip[];
141
154
  /**
142
155
  * The source up to the first element — the import, the process call, its metadata,
143
156
  * schemas, bindings and variables — so a verifier can compile one lifted call on its
@@ -327,6 +327,8 @@ function planConnectorLifts(container, skip) {
327
327
  const outcome = planConnectorLift(el, payload);
328
328
  if (typeof outcome === 'string')
329
329
  runLiftSkipped.push({ id: el.id, reason: outcome });
330
+ else if ('reason' in outcome)
331
+ runLiftSkipped.push({ id: el.id, ...outcome });
330
332
  else
331
333
  runLiftPlans.set(el.id, outcome);
332
334
  }
@@ -390,7 +392,7 @@ function planConnectorLift(el, payload) {
390
392
  });
391
393
  }
392
394
  catch (e) {
393
- return `not in the library: ${e.message}`;
395
+ return { reason: `not in the library: ${e.message}`, kind: 'not-in-library' };
394
396
  }
395
397
  const connection = bindingIdOf(ctx.connection);
396
398
  if (!connection)
@@ -406,7 +408,7 @@ function planConnectorLift(el, payload) {
406
408
  declared = new Set([...params.keys(), ...resolved.fields.map((f) => f.name)]);
407
409
  }
408
410
  catch (e) {
409
- return `the library cannot resolve ${identity.key}/${identity.action}: ${e.message}`;
411
+ return { reason: `the library cannot resolve ${identity.key}/${identity.action}: ${e.message}`, kind: 'library-cannot-resolve' };
410
412
  }
411
413
  const inputs = {};
412
414
  // `.connector()` validates every input against the library, and a field the static
@@ -415,8 +417,11 @@ function planConnectorLift(el, payload) {
415
417
  // given for every operation: the registry's own schema flags are not evidence that
416
418
  // prepare cannot help (it marks Jira `create-issue` `requiresConnectionForSchema:
417
419
  // false`, and `prepare -f` takes that operation from 5 fields to about 20).
418
- const notInLibrary = (where, k) => `${where} field "${k}" is not in the library for ${identity.key}/${identity.action} ` +
419
- '(if it is connection-specific, `registry prepare` loads it; `prepare -f <parent>=<value>` adds the fields a parent value unlocks)';
420
+ const notInLibrary = (where, k) => ({
421
+ reason: `${where} field "${k}" is not in the library for ${identity.key}/${identity.action} ` +
422
+ '(if it is connection-specific, `registry prepare` loads it; `prepare -f <parent>=<value>` adds the fields a parent value unlocks)',
423
+ kind: 'field-not-in-library',
424
+ });
420
425
  const put = (k, v, where) => {
421
426
  if (k in inputs)
422
427
  return `"${k}" appears both in ${where} and in another row`;
@@ -1068,6 +1073,11 @@ function emitDecorationPayload(payload, type) {
1068
1073
  ['type', tsText(type)],
1069
1074
  ['tag', isSnapshotType(type) ? undefined : tsText(payloadTagOf(payload))],
1070
1075
  ['typeVersion', version && version !== 'v1' ? tsText(version) : undefined],
1076
+ // A payload that configures its element (a connector call on an end event, a
1077
+ // connector wait on a catch or boundary event) keeps its context and input rows.
1078
+ ['contextRows', emitContextRows(payload)],
1079
+ ['inputSchema', payload.context?.inputSchema?.body !== undefined ? jsonLiteral(payload.context.inputSchema.body) : undefined],
1080
+ ['inputRows', emitInputRows(payload.input ?? [])],
1071
1081
  ['outputRows', emitOutputRows(payload) ?? '[]'],
1072
1082
  ]);
1073
1083
  }
@@ -2098,9 +2108,9 @@ function typeDescribesElement(kind, type) {
2098
2108
  * <bpmn:messageEventDefinition />
2099
2109
  * </bpmn:startEvent>
2100
2110
  *
2101
- * The decoration form (`payload: { type, outputRows }`) has no room for the context
2102
- * rows, and the typed form needs the element, the tag and the definition — all of
2103
- * which the file states. The typed form writes a definition with nothing in it, so
2111
+ * The typed form needs the element, the tag and the definition — all of which the
2112
+ * file states — and makes the trigger the node, not a decoration of a plain start
2113
+ * event, which is what an unlisted trigger is. The typed form writes a definition with nothing in it, so
2104
2114
  * only a bare one (no reference, no body; an `id` is fine) is carried; anything else, and an
2105
2115
  * attribute `.activity()` cannot write (a boundary's host, a non-interrupting start),
2106
2116
  * refuses here instead of losing it.
@@ -2149,9 +2159,8 @@ function definitionIsBare(def) {
2149
2159
  * legal, and the boundary's extra two are additive.
2150
2160
  */
2151
2161
  function emitEvent(chain, el, kind, payload, type) {
2152
- // `outputRows` is the only payload shape an event carries in the corpus. A
2153
- // `context` or `input` row on one would mean the registry describes the element
2154
- // after all, which is the branch this function is not on.
2162
+ // A decorating payload carries its output rows, and — on a connector call or wait
2163
+ // hosted by an event — its context and input rows too (`emitDecorationPayload`).
2155
2164
  const eventPayload = emitDecorationPayload(payload, type);
2156
2165
  if (kind === 'boundaryEvent') {
2157
2166
  chain.add(`.boundaryEvent(${tsText(el.id)}, ${opts([
@@ -49,6 +49,9 @@ import { loadBuiltBpmn } from './load.js';
49
49
  import { serialize } from './serialize.js';
50
50
  import { Bindings } from '../core/bindings.js';
51
51
  import { openCliLibrary } from '../core/cli-library.js';
52
+ import { fetchDefinitionsEnabled } from '../registry/fetch/fetch-definitions.js';
53
+ import { fetchMissedBy } from '../registry/fetch/with-fetched-definitions.js';
54
+ import { FETCHED_PROVENANCE } from '../core/library.js';
52
55
  import { readCliResources } from '../registry/prepare/resources.js';
53
56
  import { ensureTypeScriptRuntime } from '../node-runtime.js';
54
57
  import { defaultBindingsFile, defaultResourcesFile } from '../workdir.js';
@@ -74,6 +77,9 @@ function stampedDecompile(stamp, library) {
74
77
  keepFlowIds: stamp.keepFlowIds,
75
78
  keepUnusedBindings: stamp.keepUnusedBindings,
76
79
  ...(stamp.connectors === 'lift' && library ? { liftLibrary: library } : {}),
80
+ // The tasks that decompile could not name stay verbatim, whatever has been
81
+ // fetched for them since, so the stamped source comes back.
82
+ ...(stamp.verbatim.length > 0 ? { keepVerbatim: new Set(stamp.verbatim) } : {}),
77
83
  };
78
84
  }
79
85
  /** Refuse the merge with a coded diagnostic; nothing has been written. */
@@ -146,13 +152,27 @@ async function compileSides(argv, editedPath, originalPath, original, explicitBa
146
152
  // `.ts`; this re-executes under --experimental-strip-types where Node needs the flag.
147
153
  ensureTypeScriptRuntime();
148
154
  // `compile`'s context, shared by both compiles so they differ only by the edit.
149
- const library = openCliLibrary(argv);
150
155
  const resources = readCliResources(argv, defaultResourcesFile());
151
- const opts = {
156
+ const base = {
152
157
  bindings: new Bindings(flagValue(argv, '--bindings') ?? defaultBindingsFile()),
153
- ...(library ? { library } : {}),
154
158
  ...(resources ? { resources } : {}),
155
159
  };
160
+ // What either side uses and no layer carries is fetched through `uip` first
161
+ // (docs/CONNECTOR_LIBRARY_OPTIONAL_DESIGN.md): one probing compile of the edit
162
+ // and derivation of the baseline record it, and both sides then compile against
163
+ // one library, as `decompile` lifted against it.
164
+ // Each side on its own: a refusal in the edit must not keep the baseline's
165
+ // connectors from being found, or the derived baseline differs from the stamp.
166
+ await fetchMissedBy(argv, async (probe) => {
167
+ const probeOpts = { ...base, library: probe };
168
+ const edit = async () => serialize(await loadBuiltBpmn(resolve(editedPath)), probeOpts);
169
+ await Promise.allSettled([
170
+ edit(),
171
+ ...(decompiled !== undefined ? [deriveBaseline(original, { serialize: probeOpts, ...stampedDecompile(decompiled, probe) })] : []),
172
+ ]);
173
+ }, { who: 'bpmn-merge' });
174
+ const library = openCliLibrary(argv, { always: fetchDefinitionsEnabled() });
175
+ const opts = { ...base, ...(library ? { library } : {}) };
156
176
  // Two catches, as `compile` has them, so a broken source fails here exactly as it
157
177
  // fails there. While the source loads, only a builder refusal is printed by its code;
158
178
  // a syntax error or a missing import propagates with its own code and the JSON
@@ -175,7 +195,15 @@ async function compileSides(argv, editedPath, originalPath, original, explicitBa
175
195
  // No stamp options means `--baseline` was given: the baseline is the caller's.
176
196
  if (decompiled === undefined)
177
197
  return { edited, baseline: explicitBaseline };
178
- const derive = { serialize: opts, ...stampedDecompile(decompiled, library) };
198
+ // A stamp with no `fetch` token predates fetching through `uip`: that decompile
199
+ // saw no fetched row, so the baseline is derived with every one hidden.
200
+ const seen = decompiled.fetch || !library
201
+ ? library
202
+ : openCliLibrary(argv, { always: true, hide: (row) => row.provenance === FETCHED_PROVENANCE });
203
+ const derive = {
204
+ serialize: { ...base, ...(seen ? { library: seen } : {}) },
205
+ ...stampedDecompile(decompiled, seen),
206
+ };
179
207
  let derived;
180
208
  try {
181
209
  derived = await deriveBaseline(original, derive);
@@ -58,6 +58,8 @@ export interface SourceMergeOptions {
58
58
  keepFlowIds?: boolean;
59
59
  /** As `bpmn decompile --keep-unused-bindings`. */
60
60
  keepUnusedBindings?: boolean;
61
+ /** The tasks the decompile kept verbatim because its library could not name them (its stamp's `verbatim=`). */
62
+ keepVerbatim?: ReadonlySet<string>;
61
63
  }
62
64
  /** The baseline merge derived from the original. */
63
65
  export interface DerivedBaseline {
@@ -34,6 +34,7 @@ function decompileAs(xml, opts) {
34
34
  keepFlowIds: opts.keepFlowIds === true,
35
35
  keepUnusedBindings: opts.keepUnusedBindings === true,
36
36
  sdkEntry: opts.sdkEntry,
37
+ ...(opts.keepVerbatim ? { keepVerbatim: opts.keepVerbatim } : {}),
37
38
  ...(opts.liftLibrary ? { library: opts.liftLibrary } : {}),
38
39
  });
39
40
  }
@@ -872,7 +872,13 @@ function attachExtensionPayload(ctx, el, payload) {
872
872
  if (!payload)
873
873
  return;
874
874
  const ext = (el.extensionElements ??= ctx.m.create('bpmn:ExtensionElements', { values: [] }));
875
- (ext.values ??= []).unshift(createExtensionPayload(ctx.m, payload.type, payload.outputRows, { tag: payload.tag, typeVersion: payload.typeVersion }));
875
+ (ext.values ??= []).unshift(createExtensionPayload(ctx.m, payload.type, payload.outputRows, {
876
+ tag: payload.tag,
877
+ typeVersion: payload.typeVersion,
878
+ contextRows: payload.contextRows,
879
+ inputSchema: payload.inputSchema,
880
+ inputRows: payload.inputRows,
881
+ }));
876
882
  }
877
883
  /**
878
884
  * Attach what every ACTIVITY can carry — a retry policy and a multi-instance loop
@@ -449,11 +449,18 @@ export declare function verbatimOutputRows(m: BpmnModdle, rows: TypedOutputRow[]
449
449
  * @param m - The moddle instance.
450
450
  * @param type - The extension type, e.g. `BPMN.Variables` or `uipath:Activity`.
451
451
  * @param rows - Output rows, emitted verbatim.
452
+ * @param carried - What the file carried beside the outputs: the tag and type version
453
+ * for a type the snapshot lacks, and the context, input schema and input rows of a
454
+ * payload that configures its element (a connector call on an end event), each
455
+ * emitted verbatim.
452
456
  * @returns The payload element, ready to go inside a `bpmn:ExtensionElements`.
453
457
  */
454
458
  export declare function createExtensionPayload(m: BpmnModdle, type: string, rows: TypedOutputRow[], carried?: {
455
459
  tag?: string;
456
460
  typeVersion?: string;
461
+ contextRows?: TypedContextRow[];
462
+ inputSchema?: unknown;
463
+ inputRows?: TypedInputRow[];
457
464
  }): El;
458
465
  /**
459
466
  * The context fields this type requires to be a `=bindings.<id>` reference rather
@@ -488,6 +488,40 @@ export function verbatimInputRows(m, rows) {
488
488
  return m.create('uipath:Input', props);
489
489
  });
490
490
  }
491
+ /** `uipath:input` context rows exactly as the caller spelled them, deriving nothing. */
492
+ function verbatimContextRows(m, rows) {
493
+ return rows.map((row) => {
494
+ const props = { name: row.name, type: row.type ?? 'string' };
495
+ if (row.required)
496
+ props.required = 'true';
497
+ if (row.target !== undefined)
498
+ props.target = row.target;
499
+ if (row.value !== undefined)
500
+ props.value = row.value;
501
+ if (row.body !== undefined)
502
+ props.body = jsonBody(row.body);
503
+ return m.create('uipath:Input', props);
504
+ });
505
+ }
506
+ /**
507
+ * The `uipath:context` around `rows` and `inputSchema`, or `undefined` when there is
508
+ * neither. The schema is a sibling of the rows, and can be the only thing in it — a
509
+ * script task's context carries an inputSchema and no rows at all.
510
+ */
511
+ function contextElement(m, rows, inputSchema) {
512
+ if (!rows.length && inputSchema === undefined)
513
+ return undefined;
514
+ const context = {};
515
+ if (rows.length)
516
+ context.input = rows;
517
+ if (inputSchema !== undefined) {
518
+ context.inputSchema = m.create('uipath:InputSchema', {
519
+ type: 'jsonSchema',
520
+ body: typeof inputSchema === 'string' ? inputSchema : JSON.stringify(inputSchema),
521
+ });
522
+ }
523
+ return m.create('uipath:Context', context);
524
+ }
491
525
  /** The `uipath:output` row, when the type declares one. */
492
526
  function outputRow(m, spec, varName) {
493
527
  if (!spec.output)
@@ -536,33 +570,11 @@ varType) {
536
570
  payload.skipCondition = input.skipCondition;
537
571
  }
538
572
  const ctx = input.contextRows
539
- ? input.contextRows.map((row) => {
540
- const props = { name: row.name, type: row.type ?? 'string' };
541
- if (row.required)
542
- props.required = 'true';
543
- if (row.target !== undefined)
544
- props.target = row.target;
545
- if (row.value !== undefined)
546
- props.value = row.value;
547
- if (row.body !== undefined)
548
- props.body = jsonBody(row.body);
549
- return m.create('uipath:Input', props);
550
- })
573
+ ? verbatimContextRows(m, input.contextRows)
551
574
  : contextRows(m, type, spec, input.context ?? {}, input.contextVerbatim);
552
- // The schema is a sibling of the context's rows, and can be the only thing in it —
553
- // a script task's context carries an inputSchema and no rows at all.
554
- if (ctx.length || input.inputSchema !== undefined) {
555
- const context = {};
556
- if (ctx.length)
557
- context.input = ctx;
558
- if (input.inputSchema !== undefined) {
559
- context.inputSchema = m.create('uipath:InputSchema', {
560
- type: 'jsonSchema',
561
- body: typeof input.inputSchema === 'string' ? input.inputSchema : JSON.stringify(input.inputSchema),
562
- });
563
- }
564
- payload.context = m.create('uipath:Context', context);
565
- }
575
+ const context = contextElement(m, ctx, input.inputSchema);
576
+ if (context)
577
+ payload.context = context;
566
578
  // Spelled out by the caller: emit exactly these rows, deriving nothing — see
567
579
  // TypedNodeInput.inputRows. This is what lets a connector's per-parameter rows
568
580
  // (`name="start" type="string" value="0" target="query"`) survive a round trip.
@@ -653,6 +665,10 @@ export function verbatimOutputRows(m, rows) {
653
665
  * @param m - The moddle instance.
654
666
  * @param type - The extension type, e.g. `BPMN.Variables` or `uipath:Activity`.
655
667
  * @param rows - Output rows, emitted verbatim.
668
+ * @param carried - What the file carried beside the outputs: the tag and type version
669
+ * for a type the snapshot lacks, and the context, input schema and input rows of a
670
+ * payload that configures its element (a connector call on an end event), each
671
+ * emitted verbatim.
656
672
  * @returns The payload element, ready to go inside a `bpmn:ExtensionElements`.
657
673
  */
658
674
  export function createExtensionPayload(m, type, rows, carried) {
@@ -661,6 +677,14 @@ export function createExtensionPayload(m, type, rows, carried) {
661
677
  version: 'v1',
662
678
  type: m.create('uipath:Type', { value: type, version: carried?.typeVersion ?? 'v1' }),
663
679
  };
680
+ // The rows a decorated element carries beside its outputs, in the order a typed
681
+ // node writes them: context, then inputs, then outputs.
682
+ const context = contextElement(m, verbatimContextRows(m, carried?.contextRows ?? []), carried?.inputSchema);
683
+ if (context)
684
+ payload.context = context;
685
+ const ins = verbatimInputRows(m, carried?.inputRows ?? []);
686
+ if (ins.length)
687
+ payload.input = ins;
664
688
  const out = verbatimOutputRows(m, rows);
665
689
  if (out.length)
666
690
  payload.output = out;
package/dist/bpmn-api.md CHANGED
@@ -836,6 +836,9 @@ An extension payload carried by an element the payload does not describe.
836
836
  - `ExtensionPayload.outputRows: TypedOutputRow[]` — `uipath:output` rows, emitted exactly as given — see TypedOutputRow.
837
837
  - `ExtensionPayload.tag?: 'uipath:activity' | 'uipath:event' | 'uipath:mapping'` — The payload's own tag — `'uipath:activity'`, `'uipath:event'` or `'uipath:mapping'` — for a `type` the registry snapshot…
838
838
  - `ExtensionPayload.typeVersion?: string` — The `uipath:type` `version` attribute, when it is not `v1` — see `ActivityNodeOpts.typeVersion`.
839
+ - `ExtensionPayload.contextRows?: TypedContextRow[]` — The `uipath:context` rows, emitted verbatim — see TypedContextRow.
840
+ - `ExtensionPayload.inputSchema?: unknown` — The `uipath:inputSchema` body inside `uipath:context` — see `ActivityNodeOpts.inputSchema`.
841
+ - `ExtensionPayload.inputRows?: TypedInputRow[]` — The payload's own `uipath:input` rows, emitted verbatim — see TypedInputRow.
839
842
 
840
843
  ### `GatewayKind`
841
844
 
@@ -14,7 +14,7 @@ import { reportDiagnostics } from '../cli-result.js';
14
14
  import { resolveCaseFile, loadBuiltCase } from './load.js';
15
15
  import { check } from './check.js';
16
16
  import { caseCheckOpts } from './cli-library.js';
17
- import { openCliLibrary } from '../core/cli-library.js';
17
+ import { withFetchedDefinitions } from '../registry/fetch/with-fetched-definitions.js';
18
18
  import { caseCompileTarget } from './compile-cli.js';
19
19
  import { runWhenInvokedDirectly } from '../cli-run.js';
20
20
  import { ensureTypeScriptRuntime } from '../node-runtime.js';
@@ -40,7 +40,9 @@ export async function run(argv) {
40
40
  // binding-label rules (#1034): `-o` names the plan as it does for compile.
41
41
  const { bindings } = caseCompileTarget(argv);
42
42
  const resources = readCliResources(argv, defaultResourcesFile());
43
- const diags = check(built, { ...caseCheckOpts(openCliLibrary(argv), bindings), ...(resources ? { resources } : {}) });
43
+ // A connector operation no layer carries is fetched through `uip` and the check
44
+ // runs again, as `compile` does (docs/CONNECTOR_LIBRARY_OPTIONAL_DESIGN.md).
45
+ const diags = await withFetchedDefinitions(argv, (library) => check(built, { ...caseCheckOpts(library, bindings), ...(resources ? { resources } : {}) }), { who: 'check' });
44
46
  reportDiagnostics(diags);
45
47
  for (const d of diags)
46
48
  console.error(` ${d.level === 'error' ? '✗' : '⚠'} [${d.code}] ${d.message}`);