@uipath/maestro-builder-sdk 6.86.26 → 6.87.0

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.
@@ -1,5 +1,6 @@
1
1
  import { checkBpmnExpressions } from './bpmn-expr-check.js';
2
- import { allNodes, collectSerializerRefusals, folderCompanionKeys, implicitNodeVars, processId } from './serialize.js';
2
+ import { allNodes, collectSerializerModel, folderCompanionKeys, implicitNodeVars, processId } from './serialize.js';
3
+ import { refreshConnectionDiagnostics } from './refresh-connections.js';
3
4
  import { KNOWN_METHOD_SET } from './known-methods.js';
4
5
  import { EQUALS_EXPR_DIALECT, checkConnectorLookups, checkConnectorResources, checkConnectorSchema, } from '../core/connector-checks.js';
5
6
  import { checkEventResolution, checkEventSubscription, eventParamsFor, } from '../core/event-checks.js';
@@ -7,6 +8,18 @@ import { bindingRequiredFields, CASE_RUNTIME_INTERNAL_TYPES, CONNECTOR_ACTIVITY_
7
8
  import { ownEntry } from '../core/own-entry.js';
8
9
  import { isManagedHttpV2, managedHttpAbsoluteUrl, managedHttpMissing } from './managed-http.js';
9
10
  import { connectorV2Missing, isConnectorV2 } from './connector.js';
11
+ /**
12
+ * The node row a diagnostic is about, where two rules can report one row: the
13
+ * authored-task rules (`checkIntsvcActivities`, EMPTY_REQUIRED_FIELD) and the
14
+ * emitted-model rules (`refreshConnections`) are matched on code, element and row.
15
+ * Kept off the public `Diagnostic`.
16
+ */
17
+ const DIAG_FIELD = new WeakMap();
18
+ /** `d`, recorded as being about `field`. */
19
+ function aboutField(d, field) {
20
+ DIAG_FIELD.set(d, field);
21
+ return d;
22
+ }
10
23
  /**
11
24
  * The job-start family — the types whose engine handler switches addressing on the
12
25
  * `uipath:type` version: v2 reads `name`/`folderPath`, v1 reads `releaseKey`/`folderKey`.
@@ -99,9 +112,60 @@ export function check(built, opts = {}) {
99
112
  checkConnectors(built, opts, diags);
100
113
  checkConnectorEvents(built, opts, diags);
101
114
  // A `.dataService()` entity's recorded row is the serializer's (`lowerDataServiceEntity`).
102
- diags.push(...serializerRefusals(built, opts, diags));
115
+ const { refusals, definitions, stoodIn } = serializerRefusals(built, opts, diags);
116
+ diags.push(...refusals);
117
+ if (definitions)
118
+ diags.push(...refreshConnections(built, definitions, stoodIn, diags));
103
119
  return diags;
104
120
  }
121
+ /**
122
+ * What `uip maestro bpmn refresh` refuses about the emitted connections
123
+ * (`refresh-connections.ts`, #1809), judged on the model the serializer built.
124
+ *
125
+ * A finding the authored-task rules already made on the same element
126
+ * (`checkIntsvcActivities`: a literal connection, an undeclared or mismatched
127
+ * binding, about the same row) is not repeated, nor a missing connector the
128
+ * required-field rule already refuses. An `Intsvc.WaitForEvent` / `EventTrigger` with no
129
+ * connection is INTSVC_EVENT_NO_CONNECTION, so the EMPTY_REQUIRED_FIELD
130
+ * warning on its `connectionId` input, which says validate does not need it,
131
+ * is dropped there: refresh's validator does.
132
+ */
133
+ function refreshConnections(built, definitions, stoodIn, diags) {
134
+ const on = (where, codes, field, level) => diags.some((d) => d.where === where && codes.includes(d.code) && DIAG_FIELD.get(d) === field && (level === undefined || d.level === level));
135
+ // A connector, connector event or external task the serializer refused (LIBRARY_REQUIRED
136
+ // without a library, which `check` does not report, or any refusal of its own) was stood
137
+ // in, so the binding its label would synthesize is not in the model: a node that reads
138
+ // that label is not missing it.
139
+ // An author-declared binding is in the model whatever happened to the node, and wins over
140
+ // a synthesized row, so a finding on one stands.
141
+ const declared = new Set(built.bindings.map((b) => b.id));
142
+ const unbuilt = new Set(allNodes(built.nodes).flatMap((n) => (n.kind === 'connector' || n.kind === 'connectorEvent' || n.kind === 'externalTask') && stoodIn.has(n.id) && n.connection
143
+ && !declared.has(n.connection) ? [n.connection] : []));
144
+ const out = [];
145
+ for (const d of refreshConnectionDiagnostics(definitions)) {
146
+ if (d.bindingId !== undefined && unbuilt.has(d.bindingId))
147
+ continue;
148
+ const { bindingId: _bindingId, field, ...diag } = d;
149
+ const where = diag.where;
150
+ if (where !== undefined) {
151
+ if (diag.code === 'INTSVC_CONNECTION_NOT_BINDING' && on(where, ['INTSVC_CONNECTION_NOT_BINDING'], field))
152
+ continue;
153
+ if (diag.code === 'INTSVC_CONNECTION_BINDING_MISSING' && on(where, ['INTSVC_BINDING_UNDECLARED', 'INTSVC_BINDING_MISMATCH'], field))
154
+ continue;
155
+ if (diag.code === 'INTSVC_CONNECTOR_KEY_MISSING' && on(where, ['EMPTY_REQUIRED_FIELD'], field, 'error'))
156
+ continue;
157
+ if (diag.code === 'INTSVC_EVENT_NO_CONNECTION') {
158
+ for (let i = diags.length - 1; i >= 0; i--) {
159
+ const e = diags[i];
160
+ if (e.where === where && e.code === 'EMPTY_REQUIRED_FIELD' && e.level === 'warning' && DIAG_FIELD.get(e) === field)
161
+ diags.splice(i, 1);
162
+ }
163
+ }
164
+ }
165
+ out.push(diag);
166
+ }
167
+ return out;
168
+ }
105
169
  /**
106
170
  * The first-level expression check (bpmn-expr-check): an undeclared `vars.<name>` or
107
171
  * `bindings.<name>` read, or a declared variable read without `vars.`.
@@ -128,7 +192,8 @@ function checkExpressions(built, diags) {
128
192
  }
129
193
  /**
130
194
  * Every refusal `compile` would raise for `built`: the serializer's model step,
131
- * run in collect mode (`collectSerializerRefusals`), each placed on its element.
195
+ * run in collect mode (`collectSerializerModel`), each placed on its element,
196
+ * and the model it built, for the rules refresh applies to it.
132
197
  *
133
198
  * LIBRARY_REQUIRED is not reported: without a library `check` fails open, as
134
199
  * its library rules always have. A throw that is no refusal comes back as
@@ -139,18 +204,20 @@ function checkExpressions(built, diags) {
139
204
  */
140
205
  function serializerRefusals(built, opts, found) {
141
206
  let collected;
207
+ let definitions;
142
208
  try {
143
- collected = collectSerializerRefusals(built, {
209
+ ({ refusals: collected, definitions } = collectSerializerModel(built, {
144
210
  ...(opts.library ? { library: opts.library } : {}),
145
211
  ...(opts.bindings ? { bindings: opts.bindings } : {}),
146
212
  ...(opts.resources ? { resources: opts.resources } : {}),
147
- });
213
+ }));
148
214
  }
149
215
  catch (error) {
150
216
  if (!found.some((d) => d.level === 'error'))
151
217
  throw error;
152
- return [];
218
+ return { refusals: [], stoodIn: new Set() };
153
219
  }
220
+ const stoodIn = new Set(collected.flatMap((r) => (r.nodeId !== undefined ? [r.nodeId] : [])));
154
221
  const out = [];
155
222
  const seen = new Set();
156
223
  for (const r of collected) {
@@ -172,7 +239,7 @@ function serializerRefusals(built, opts, found) {
172
239
  ...(r.nodeId !== undefined ? { nodeId: r.nodeId } : {}),
173
240
  });
174
241
  }
175
- return out;
242
+ return { refusals: out, stoodIn, ...(definitions ? { definitions } : {}) };
176
243
  }
177
244
  /**
178
245
  * The library-backed connector rules, shared with Flow (`core/connector-checks.ts`).
@@ -696,7 +763,7 @@ function checkIntsvcActivities(built, diags) {
696
763
  // connection is resolved from a root binding, never computed at run time.
697
764
  const label = field === 'connection' ? 'conn' : 'folder';
698
765
  const refusal = `\`uip maestro bpmn refresh\` refuses it with \`${field} must reference a root binding as "=bindings.<id>"\``;
699
- diags.push({
766
+ diags.push(aboutField({
700
767
  level: 'error',
701
768
  code: 'INTSVC_CONNECTION_NOT_BINDING',
702
769
  message: expr(v)
@@ -707,13 +774,13 @@ function checkIntsvcActivities(built, diags) {
707
774
  `\`.binding('${label}', { resource: 'Connection', propertyAttribute: '${attribute}', value: '${v}' })\` ` +
708
775
  `and write ${field}: '=bindings.${label}'.`,
709
776
  where,
710
- });
777
+ }, field));
711
778
  return;
712
779
  }
713
780
  const id = v.slice('=bindings.'.length);
714
781
  const b = declared.get(id);
715
782
  if (!b) {
716
- diags.push({
783
+ diags.push(aboutField({
717
784
  level: 'error',
718
785
  code: 'INTSVC_BINDING_UNDECLARED',
719
786
  message: `"${n.id}" (Intsvc.ActivityExecution) reads ${field}="${v}" but the process declares no binding "${id}" ` +
@@ -721,33 +788,25 @@ function checkIntsvcActivities(built, diags) {
721
788
  `\`.binding('${id}', { resource: 'Connection', propertyAttribute: '${attribute}', value: '<${field === 'connection' ? 'connection id' : 'folder key'}>' })\`` +
722
789
  (field === 'folderKey' ? ' — keyed by its connection; the builder pairs it with the connection this task reads.' : '.'),
723
790
  where,
724
- });
791
+ }, field));
725
792
  return;
726
793
  }
727
794
  const attr = b.propertyAttribute;
728
795
  const resource = b.resource;
729
796
  if (attr.toLowerCase() !== attribute.toLowerCase() || resource.toLowerCase() !== 'connection') {
730
- diags.push({
797
+ diags.push(aboutField({
731
798
  level: 'error',
732
799
  code: 'INTSVC_BINDING_MISMATCH',
733
800
  message: `"${n.id}" (Intsvc.ActivityExecution) reads ${field}="${v}", but binding "${id}" is resource "${resource}" / ` +
734
801
  `propertyAttribute "${attr}"; the ${field} row needs resource "Connection" / propertyAttribute "${attribute}".`,
735
802
  where,
736
- });
803
+ }, field));
737
804
  }
738
805
  };
739
806
  bindingRow('connection', 'ConnectionId');
740
807
  bindingRow('folderKey', 'folderKey');
741
- if (text(ctx['connection']) === undefined) {
742
- diags.push({
743
- level: 'warning',
744
- code: 'INTSVC_CONNECTION_MISSING',
745
- message: `"${n.id}" (Intsvc.ActivityExecution) names no connection. The registry says to omit \`connection\` and \`folderKey\` only ` +
746
- `when the activity uses none; a connector activity almost always does. Declare a Connection binding and read it as ` +
747
- `connection: '=bindings.<id>' (\`uip is connections list ${key} --all-folders --output json\` lists the ids).`,
748
- where,
749
- });
750
- }
808
+ // A task that names no connection is INTSVC_CONNECTION_MISSING, judged on the emitted
809
+ // rows with refresh's `connection` / `connectionId` fallback (`refresh-connections.ts`).
751
810
  }
752
811
  }
753
812
  /**
@@ -1560,12 +1619,12 @@ inEventSubProcess = false) {
1560
1619
  const notEnforcedNote = ' `uip maestro bpmn validate` does not require it for this type, so check only warns.';
1561
1620
  for (const field of requiredContext) {
1562
1621
  const gate = managedHttp || connectorV2 || enforced.context;
1563
- diags.push({
1622
+ diags.push(aboutField({
1564
1623
  level: gate ? 'error' : 'warning',
1565
1624
  code: 'EMPTY_REQUIRED_FIELD',
1566
1625
  message: `"${n.id}" (${n.type}) is missing required field "${field}".${gate ? '' : notEnforcedNote}`,
1567
1626
  where: n.id,
1568
- });
1627
+ }, field));
1569
1628
  }
1570
1629
  const absoluteUrl = managedHttp ? managedHttpAbsoluteUrl(httpRequest) : undefined;
1571
1630
  if (absoluteUrl !== undefined) {
@@ -1586,12 +1645,12 @@ inEventSubProcess = false) {
1586
1645
  for (const row of n.inputRows ?? [])
1587
1646
  inputView[row.name] = row.value ?? row.body ?? '';
1588
1647
  for (const field of connectorV2 ? [] : missingRequiredInputs(n.type, inputView, contextNames, n.spec)) {
1589
- diags.push({
1648
+ diags.push(aboutField({
1590
1649
  level: enforced.inputs ? 'error' : 'warning',
1591
1650
  code: 'EMPTY_REQUIRED_FIELD',
1592
1651
  message: `"${n.id}" (${n.type}) is missing required input "${field}".${enforced.inputs ? '' : notEnforcedNote}`,
1593
1652
  where: n.id,
1594
- });
1653
+ }, field));
1595
1654
  }
1596
1655
  // A type that permits only the output row its spec declares. Reachable via
1597
1656
  // the generic `.activity()`; the typed wrapper does not offer the option.
@@ -21,9 +21,10 @@
21
21
  * resolves for a package consumer; the library default in `decompile.ts` stays
22
22
  * repo-relative for in-tree callers, mirroring the Flow and Case arms.
23
23
  *
24
- * Diagram layout is not read or emitted — the SDK emits semantic-only XML and
25
- * `uip maestro bpmn format` regenerates `bpmndi`. Run it on the recompiled artifact
26
- * when a canvas needs one.
24
+ * Diagram layout is not read or emitted — the SDK emits semantic-only XML. For a
25
+ * brownfield edit, `bpmn-merge` puts the original diagram back and draws only what the
26
+ * edit added (merge-placement.ts); `uip maestro bpmn format`, which lays the whole
27
+ * diagram out again, is for a greenfield file.
27
28
  *
28
29
  * `--style nested` lifts the regions the builder's nesting constructs lower to —
29
30
  * see `BpmnDecompileOptions.style`. It is written only after both sources have been
@@ -16,9 +16,10 @@
16
16
  *
17
17
  * What does NOT survive, and why:
18
18
  *
19
- * - **`bpmndi` diagram layout.** The SDK emits none and `uip maestro bpmn format`
20
- * regenerates it, so there is nothing to preserve. A decompiled file recompiles
21
- * to semantic-only XML; re-run `format` for a canvas.
19
+ * - **`bpmndi` diagram layout.** The SDK emits none, so there is nothing to
20
+ * preserve here. A decompiled file recompiles to semantic-only XML; `bpmn-merge`
21
+ * puts the original diagram back and draws only what the edit added
22
+ * (merge-placement.ts). `format` is for a greenfield file.
22
23
  * - **Comments, method order, and formatting.** Regenerated, not preserved.
23
24
  *
24
25
  * Everything else round-trips: events and their definitions, all four gateways,
@@ -33,11 +33,29 @@ export function run(argv) {
33
33
  });
34
34
  const out = flagValue(argv, '-o') ?? 'merged.bpmn';
35
35
  writeFileSync(out, result.xml);
36
- reportResult({ path: resolve(out), preserved: result.preserved.length, authored: result.authored.length, removed: result.removed.length });
36
+ const { layout } = result;
37
+ reportResult({
38
+ path: resolve(out),
39
+ preserved: result.preserved.length,
40
+ authored: result.authored.length,
41
+ removed: result.removed.length,
42
+ placed: layout.placed.length,
43
+ routed: layout.routed.length + layout.rerouted.length,
44
+ ...(layout.resized.length || layout.moved.length ? { resized: layout.resized, moved: layout.moved } : {}),
45
+ });
37
46
  // Say what was kept and what was rewritten: on a surgical edit the preserved count
38
47
  // should dwarf the authored one, and a reader who sees otherwise has learned something.
39
48
  console.log(`bpmn-merge: wrote ${basename(out)} (${result.preserved.length} preserved, ` +
40
49
  `${result.authored.length} authored, ${result.removed.length} removed)`);
50
+ // The diagram: what the edit added is drawn, and an existing shape moves only when a
51
+ // full lane, pool or sub-process had to grow — say so, by id, when it did.
52
+ if (layout.placed.length || layout.routed.length || layout.rerouted.length) {
53
+ console.log(`bpmn-merge: drew ${layout.placed.length} new shape(s) and ${layout.routed.length + layout.rerouted.length} edge(s); ` +
54
+ (layout.resized.length || layout.moved.length
55
+ ? `no room in its container, so grew ${layout.resized.join(', ') || 'nothing'}` +
56
+ (layout.moved.length ? ` and moved ${layout.moved.join(', ')} down by the same offset` : '')
57
+ : 'every existing shape kept its bounds'));
58
+ }
41
59
  return 0;
42
60
  }
43
61
  runWhenInvokedDirectly(import.meta.url, 'bpmn-merge', run);
@@ -0,0 +1,33 @@
1
+ /** What placement did to the diagram, by semantic element id. */
2
+ export interface BpmnPlacementReport {
3
+ /** Flow nodes the edit added that now have a shape. */
4
+ placed: string[];
5
+ /** Sequence flows the edit added that now have an edge. */
6
+ routed: string[];
7
+ /** Sequence flows kept by id but rewired, whose existing edge got a new route. */
8
+ rerouted: string[];
9
+ /** Existing containers (lane, pool, expanded sub-process) grown to fit a placed node. */
10
+ resized: string[];
11
+ /** Existing shapes shifted, with every other shape below a grown container. */
12
+ moved: string[];
13
+ }
14
+ export interface BpmnPlacementOptions {
15
+ /** True for an element id the edit added (absent from the original). Only those are drawn. */
16
+ isAdded: (id: string) => boolean;
17
+ /** Ids of existing sequence flows whose source or target the edit changed. */
18
+ rewired?: ReadonlySet<string>;
19
+ /**
20
+ * Ids of existing flow nodes the edit moved into another scope (into a sub-process it
21
+ * added, say). Their old shapes sit outside their new parent, so they are drawn again
22
+ * inside it, and their flows rerouted; they are reported as `moved`.
23
+ */
24
+ rescoped?: ReadonlySet<string>;
25
+ }
26
+ /**
27
+ * Draw the flow nodes and sequence flows the edit added, and only those, into the
28
+ * document's existing diagram. See the file header for the rules.
29
+ */
30
+ export declare function placeAddedElements(xml: string, options: BpmnPlacementOptions): {
31
+ xml: string;
32
+ report: BpmnPlacementReport;
33
+ };