@uipath/maestro-builder-sdk 6.86.26 → 6.86.27

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.
@@ -0,0 +1,55 @@
1
+ /**
2
+ * bpmn/refresh-connections — what `uip maestro bpmn refresh` refuses about a
3
+ * process's Integration Service connections, judged on the model `compile`
4
+ * writes (`collectSerializerModel`), so the bindings a label synthesizes and
5
+ * bindings.json resolves are the ones judged (#1809).
6
+ *
7
+ * Sources (uipcli, `@uipath/maestro-sdk`): `bpmn-packaging/connection-resources.ts`
8
+ * (`buildConnectionResources`, which refresh runs before it validates) and
9
+ * `bpmn-validation/project-validator.ts`. Rule → code:
10
+ *
11
+ * - a root `Connection` / `ConnectionId` binding other than `ImplicitConnection`
12
+ * has a `resourceKey` and a GUID `default` — CONNECTION_BINDING_NOT_GUID (warning);
13
+ * - a connector node that names a connection names it as `=bindings.<id>`
14
+ * — INTSVC_CONNECTION_NOT_BINDING;
15
+ * - a bound node names its connector (`connectorKey`; an HTTP request's
16
+ * `body.targetConnector`) — INTSVC_CONNECTOR_KEY_MISSING;
17
+ * - the id is a root binding spelled exactly `Connection` / `ConnectionId`,
18
+ * except on an HTTP request — INTSVC_CONNECTION_BINDING_MISSING;
19
+ * - one connection resource serves one connector and one connection id
20
+ * — INTSVC_CONNECTION_RESOURCE_CONFLICT;
21
+ * - an `Intsvc.WaitForEvent` / `Intsvc.EventTrigger` names a connection
22
+ * — INTSVC_EVENT_NO_CONNECTION;
23
+ * - an activity's connection and folder bindings carry the same resourceKey
24
+ * (refresh on a V1 activity; `validate`'s MISSING_BINDING on any version)
25
+ * — INTSVC_CONNECTION_FOLDER_MISMATCH;
26
+ * - an activity names a connection (`connection`, else `connectionId`,
27
+ * non-blank) — INTSVC_CONNECTION_MISSING, an error on V1, which refresh
28
+ * refuses, and a warning otherwise.
29
+ *
30
+ * "V1" is refresh's reading (`isIntsvcActivityExecutionV1`): the row absent or
31
+ * `v1`; an explicitly empty row is not V1 there.
32
+ */
33
+ import type { ModdleElement } from 'bpmn-moddle';
34
+ type El = ModdleElement;
35
+ /** A finding, in `check`'s `Diagnostic` shape (placed on the element it is about). */
36
+ export interface RefreshConnectionDiagnostic {
37
+ level: 'error' | 'warning';
38
+ code: 'CONNECTION_BINDING_NOT_GUID' | 'INTSVC_CONNECTION_NOT_BINDING' | 'INTSVC_CONNECTION_BINDING_MISSING' | 'INTSVC_CONNECTION_RESOURCE_CONFLICT' | 'INTSVC_EVENT_NO_CONNECTION' | 'INTSVC_CONNECTION_FOLDER_MISMATCH' | 'INTSVC_CONNECTION_MISSING' | 'INTSVC_CONNECTOR_KEY_MISSING';
39
+ message: string;
40
+ where?: string;
41
+ nodeId?: string;
42
+ /** The binding a INTSVC_CONNECTION_BINDING_MISSING finding names. */
43
+ bindingId?: string;
44
+ /** The node row a finding is about, for `check` to match it against the authored-task rules. */
45
+ field?: 'connection' | 'connectionId' | 'connectorKey' | 'body';
46
+ }
47
+ /**
48
+ * Every condition `uip maestro bpmn refresh` refuses about the connections of
49
+ * `definitions` (the model `compile` writes), each placed on its element.
50
+ *
51
+ * @param definitions - The `bpmn:Definitions` the serializer built.
52
+ * @returns The diagnostics, in document order.
53
+ */
54
+ export declare function refreshConnectionDiagnostics(definitions: El): RefreshConnectionDiagnostic[];
55
+ export {};
@@ -0,0 +1,258 @@
1
+ import { GUID_RE } from '../core/binding-messages.js';
2
+ import { placeholder, prepareCommand } from '../core/cli-spelling.js';
3
+ /** The connector node types refresh binds a connection for (`BINDING_NODE_TYPES`). */
4
+ const BINDING_NODE_TYPES = new Set([
5
+ 'Intsvc.ActivityExecution',
6
+ 'Intsvc.EventTrigger',
7
+ 'Intsvc.WaitForEvent',
8
+ 'Intsvc.AsyncExecution',
9
+ 'Intsvc.SyncAgentExecution',
10
+ 'Intsvc.AsyncAgentExecution',
11
+ 'Intsvc.AsyncWorkflowExecution',
12
+ 'Intsvc.SyncWorkflowExecution',
13
+ 'Intsvc.UnifiedHttpRequest',
14
+ ]);
15
+ /** A manual HTTP request's placeholder connection: refresh packages no resource for it. */
16
+ const IMPLICIT_CONNECTION = 'ImplicitConnection';
17
+ /** refresh's `bindingIdOf`: the id in a `=bindings.<id>` reference, or `undefined`. */
18
+ const BINDING_REF = /^=bindings\.([A-Za-z_][\w.-]*)$/;
19
+ const extensionValues = (el) => (el?.extensionElements?.values ?? []);
20
+ /** Every flow element under `scope`, sub-process contents included (refresh's `allFlowElements`). */
21
+ function allFlowElements(scope) {
22
+ const out = [];
23
+ for (const child of (scope.flowElements ?? []))
24
+ out.push(child, ...allFlowElements(child));
25
+ return out;
26
+ }
27
+ /**
28
+ * The process's connector nodes, with every named input from the `uipath:context`
29
+ * and the payload's direct inputs (refresh reads both, the context first).
30
+ */
31
+ function connectorNodes(process) {
32
+ return allFlowElements(process).flatMap((element) => {
33
+ const payload = extensionValues(element).find((v) => v.$type === 'uipath:Activity' || v.$type === 'uipath:Event');
34
+ const type = payload?.type?.value;
35
+ if (!payload || type === undefined || !BINDING_NODE_TYPES.has(type))
36
+ return [];
37
+ const rows = [...(payload.context?.input ?? []), ...(payload.input ?? [])];
38
+ const values = new Map();
39
+ for (const row of rows)
40
+ if (row.name)
41
+ values.set(row.name, (row.value ?? row.body));
42
+ return [{ element, type, values }];
43
+ });
44
+ }
45
+ /** refresh's `connectionReference`: `connection`, else `connectionId`, the first non-blank. */
46
+ const connectionReference = (values) => [values.get('connection'), values.get('connectionId')].find((v) => v?.trim());
47
+ /** How refresh names the node in its messages. */
48
+ const nodeLabel = (type) => type === 'Intsvc.EventTrigger' ? 'Trigger' : type === 'Intsvc.WaitForEvent' ? 'Wait' : 'Activity';
49
+ /** The connector an HTTP request authenticates with: its body's `targetConnector`. */
50
+ function targetConnector(body) {
51
+ if (!body?.trim())
52
+ return undefined;
53
+ try {
54
+ const parsed = JSON.parse(body);
55
+ return typeof parsed.targetConnector === 'string' ? parsed.targetConnector : undefined;
56
+ }
57
+ catch {
58
+ return undefined;
59
+ }
60
+ }
61
+ /** A V1 `Intsvc.ActivityExecution`: no `activityConfigurationVersion`, or `v1`. */
62
+ const isV1Activity = (n) => {
63
+ if (n.type !== 'Intsvc.ActivityExecution')
64
+ return false;
65
+ const version = n.values.get('activityConfigurationVersion');
66
+ return version === undefined || version === 'v1';
67
+ };
68
+ /**
69
+ * Every condition `uip maestro bpmn refresh` refuses about the connections of
70
+ * `definitions` (the model `compile` writes), each placed on its element.
71
+ *
72
+ * @param definitions - The `bpmn:Definitions` the serializer built.
73
+ * @returns The diagnostics, in document order.
74
+ */
75
+ export function refreshConnectionDiagnostics(definitions) {
76
+ const out = [];
77
+ const processes = (definitions.rootElements ?? []).filter((e) => e.$type === 'bpmn:Process');
78
+ for (const process of processes) {
79
+ const rootBindings = (extensionValues(process).find((v) => v.$type === 'uipath:Bindings')?.binding ?? []);
80
+ const byId = new Map(rootBindings.map((b) => [b.id, b]));
81
+ const connections = new Map(rootBindings
82
+ .filter((b) => b.resource === 'Connection' && b.propertyAttribute === 'ConnectionId' && b.resourceKey !== IMPLICIT_CONNECTION)
83
+ .map((b) => [b.id, b]));
84
+ const nodes = connectorNodes(process);
85
+ // The connector each binding serves, for the command that binds it.
86
+ const connectorOf = new Map();
87
+ for (const n of nodes) {
88
+ const bindingId = BINDING_REF.exec(connectionReference(n.values) ?? '')?.[1];
89
+ const key = n.values.get('connectorKey')?.trim();
90
+ if (bindingId !== undefined && key && !connectorOf.has(bindingId))
91
+ connectorOf.set(bindingId, key);
92
+ }
93
+ // 1. The binding's default is the connection id the package declares.
94
+ for (const b of connections.values()) {
95
+ const value = typeof b.default === 'string' ? b.default.trim() : '';
96
+ if (GUID_RE.test(value))
97
+ continue;
98
+ const key = connectorOf.get(b.id);
99
+ // refresh's `toConnectionBinding` requires resourceKey, then default, then a GUID.
100
+ const keyed = typeof b.resourceKey === 'string' && b.resourceKey.trim() !== '';
101
+ const refusal = !keyed ? 'resourceKey is required' : value ? 'default must be a GUID' : 'default is required';
102
+ out.push({
103
+ level: 'warning',
104
+ code: 'CONNECTION_BINDING_NOT_GUID',
105
+ message: `Connection binding "${b.id}" ${value ? `has the value "${value}", which is not a GUID` : 'has no value'}; ` +
106
+ `\`uip maestro bpmn refresh\` refuses it ("Connection binding "${b.id}" ${refusal}."), so the ` +
107
+ `process cannot be packaged until it carries the connection's id. Bind the real connection: ` +
108
+ `\`${prepareCommand(key ?? placeholder('<connector-key>'), placeholder('<action>'))}\` writes it into bindings.json under this label, ` +
109
+ `or read its Id from \`uip is connections list ${key ?? '<connector-key>'} --all-folders --output json\` and declare ` +
110
+ `\`.binding('${b.id}', { resource: 'Connection', propertyAttribute: 'ConnectionId', value: '<connection id>' })\`. ` +
111
+ `A symbolic label checks and compiles offline; refresh is the first rung that needs the id.`,
112
+ where: b.id,
113
+ });
114
+ }
115
+ // 2–6. Each connector node's connection, as refresh reads it.
116
+ const resources = new Map();
117
+ for (const n of nodes) {
118
+ const id = n.element.id;
119
+ const name = n.element.name?.trim() || id;
120
+ const label = nodeLabel(n.type);
121
+ const at = { where: id, nodeId: id };
122
+ const ref = connectionReference(n.values);
123
+ if (ref === undefined) {
124
+ // refresh skips an unconnected trigger or wait; its validator refuses it.
125
+ if (n.type === 'Intsvc.WaitForEvent' || n.type === 'Intsvc.EventTrigger') {
126
+ out.push({
127
+ level: 'error',
128
+ code: 'INTSVC_EVENT_NO_CONNECTION',
129
+ message: `"${id}" (${n.type}) names no connection; \`uip maestro bpmn refresh\` and \`validate\` refuse it ` +
130
+ `("${n.type} has no connection. The runtime faults with "Value cannot be null. (Parameter 'Connection')"."). ` +
131
+ `Declare the connection at the root — \`.binding('conn', { resource: 'Connection', propertyAttribute: 'ConnectionId', value: '<connection id>' })\` — ` +
132
+ `and read it as connectionId: '=bindings.conn', or author the node with \`.${n.type === 'Intsvc.EventTrigger' ? 'eventTrigger' : 'waitForEvent'}()\` ` +
133
+ `and its \`connection\` / \`folder\` labels.`,
134
+ ...at,
135
+ field: 'connectionId',
136
+ });
137
+ }
138
+ else if (n.type === 'Intsvc.ActivityExecution') {
139
+ const v1 = isV1Activity(n);
140
+ const key = n.values.get('connectorKey')?.trim() || '<connector-key>';
141
+ out.push({
142
+ level: v1 ? 'error' : 'warning',
143
+ code: 'INTSVC_CONNECTION_MISSING',
144
+ message: `"${id}" (Intsvc.ActivityExecution) names no connection (no non-blank \`connection\` or \`connectionId\`). ` +
145
+ (v1
146
+ ? `\`uip maestro bpmn refresh\` refuses a V1 task without one ("${label} "${name}" connection must reference a root binding as "=bindings.<id>"."). `
147
+ : `The registry says to omit \`connection\` and \`folderKey\` only when the activity uses none; a connector activity almost always does. `) +
148
+ `Declare a Connection binding and read it as connection: '=bindings.<id>' ` +
149
+ `(\`uip is connections list ${key} --all-folders --output json\` lists the ids).`,
150
+ ...at,
151
+ });
152
+ }
153
+ continue;
154
+ }
155
+ const field = n.values.get('connection')?.trim() ? 'connection' : 'connectionId';
156
+ const bindingId = BINDING_REF.exec(ref)?.[1];
157
+ if (bindingId === undefined) {
158
+ out.push({
159
+ level: 'error',
160
+ code: 'INTSVC_CONNECTION_NOT_BINDING',
161
+ message: `"${id}" (${n.type}) has ${field}="${ref}"; ` +
162
+ `\`uip maestro bpmn refresh\` refuses it ("${label} "${name}" connection must reference a root binding as "=bindings.<id>"."). ` +
163
+ `A connection is resolved from a root binding, never written inline or computed: declare ` +
164
+ `\`.binding('conn', { resource: 'Connection', propertyAttribute: 'ConnectionId', value: '<connection id>' })\` ` +
165
+ `and read it as '=bindings.conn'.`,
166
+ ...at,
167
+ field,
168
+ });
169
+ continue;
170
+ }
171
+ const binding = connections.get(bindingId);
172
+ // A manual HTTP request without its binding packages no resource.
173
+ if (!binding && n.type === 'Intsvc.UnifiedHttpRequest')
174
+ continue;
175
+ // 3. refresh names the resource's connector before it looks the binding up.
176
+ const http = n.type === 'Intsvc.UnifiedHttpRequest';
177
+ const connector = http ? targetConnector(n.values.get('body')) : n.values.get('connectorKey')?.trim();
178
+ if (!connector) {
179
+ out.push({
180
+ level: 'error',
181
+ code: 'INTSVC_CONNECTOR_KEY_MISSING',
182
+ message: http
183
+ ? `"${id}" (${n.type}) is bound to "=bindings.${bindingId}" but its \`body\` names no \`targetConnector\`; ` +
184
+ `\`uip maestro bpmn refresh\` refuses it ("HTTP request "${name}" body.targetConnector is required."). ` +
185
+ `Set \`targetConnector\` in the request body to the connector key the connection belongs to.`
186
+ : `"${id}" (${n.type}) is bound to "=bindings.${bindingId}" but has no \`connectorKey\`; ` +
187
+ `\`uip maestro bpmn refresh\` refuses it ("${label} "${name}" connectorKey is required."): the connection resource ` +
188
+ `is declared for a connector. Add a \`connectorKey\` row naming the connector the connection belongs to.`,
189
+ ...at,
190
+ field: http ? 'body' : 'connectorKey',
191
+ });
192
+ }
193
+ if (!binding) {
194
+ const declared = byId.get(bindingId);
195
+ out.push({
196
+ level: 'error',
197
+ code: 'INTSVC_CONNECTION_BINDING_MISSING',
198
+ message: `"${id}" (${n.type}) reads its connection from "=bindings.${bindingId}", but ` +
199
+ (declared
200
+ ? `binding "${bindingId}" is resource "${declared.resource ?? ''}" / propertyAttribute "${declared.propertyAttribute ?? ''}"` +
201
+ (declared.resourceKey === IMPLICIT_CONNECTION ? ` keyed "${IMPLICIT_CONNECTION}"` : '') +
202
+ `, not a Connection / ConnectionId binding (both spelled exactly so)`
203
+ : `the process declares no root binding "${bindingId}"`) +
204
+ `; \`uip maestro bpmn refresh\` refuses it ("${label} "${name}" references missing Connection binding "${bindingId}"."). ` +
205
+ `Declare it at the root: \`.binding('${bindingId}', { resource: 'Connection', propertyAttribute: 'ConnectionId', value: '<connection id>' })\`.`,
206
+ ...at,
207
+ bindingId,
208
+ field,
209
+ });
210
+ continue;
211
+ }
212
+ // One resource, one connector and one connection id.
213
+ const resourceKey = typeof binding.resourceKey === 'string' ? binding.resourceKey.trim() : '';
214
+ const connectionId = typeof binding.default === 'string' ? binding.default.trim() : '';
215
+ if (connector && resourceKey) {
216
+ const prior = resources.get(resourceKey);
217
+ if (!prior)
218
+ resources.set(resourceKey, { connector, connectionId, node: id });
219
+ else if (prior.connector !== connector || prior.connectionId !== connectionId) {
220
+ out.push({
221
+ level: 'error',
222
+ code: 'INTSVC_CONNECTION_RESOURCE_CONFLICT',
223
+ message: `"${id}" (${connector}) and "${prior.node}" (${prior.connector}) both use connection resource "${resourceKey}"` +
224
+ (prior.connector === connector ? ` with different connection ids` : '') +
225
+ `; \`uip maestro bpmn refresh\` refuses it ("Connection resource "${resourceKey}" is used by Integration Service nodes with ` +
226
+ `different connectors or connections."). An Integration Service connection belongs to one connector: give each ` +
227
+ `connector its own Connection binding, with its own resourceKey.`,
228
+ ...at,
229
+ });
230
+ }
231
+ }
232
+ // An activity's folder binding is keyed by the same connection resource.
233
+ if (n.type === 'Intsvc.ActivityExecution') {
234
+ const folderRef = n.values.get('folderKey')?.trim();
235
+ const folderId = folderRef?.startsWith('=bindings.') ? folderRef.slice('=bindings.'.length) : undefined;
236
+ const folder = folderId === undefined ? undefined : byId.get(folderId);
237
+ const folderKey = typeof folder?.resourceKey === 'string' ? folder.resourceKey.trim() : '';
238
+ if (folder && folder.resource === 'Connection' && folder.propertyAttribute === 'folderKey' && resourceKey && folderKey && folderKey !== resourceKey) {
239
+ out.push({
240
+ level: 'error',
241
+ code: 'INTSVC_CONNECTION_FOLDER_MISMATCH',
242
+ message: `"${id}" (Intsvc.ActivityExecution) reads connection binding "${bindingId}" (resourceKey "${resourceKey}") and folder ` +
243
+ `binding "${folderId}" (resourceKey "${folderKey}"); ` +
244
+ (isV1Activity(n)
245
+ ? `\`uip maestro bpmn refresh\` and \`validate\` refuse it ("Integration Service activity connection and folder bindings ` +
246
+ `refer to different connection resources."). `
247
+ : `\`uip maestro bpmn validate\` refuses it as MISSING_BINDING ("incorrectly configured"). `) +
248
+ `A folder binding is keyed ` +
249
+ `by its connection: drop the folder binding's \`resourceKey\` (the builder pairs it with the connection this task reads) ` +
250
+ `or set it to "${resourceKey}".`,
251
+ ...at,
252
+ });
253
+ }
254
+ }
255
+ }
256
+ }
257
+ return out;
258
+ }
@@ -1,7 +1,9 @@
1
+ import type { ModdleElement } from 'bpmn-moddle';
1
2
  import { type BuiltBpmn, type BpmnNode, type BpmnVarDecl } from './bpmn-sdk.js';
2
3
  import type { Library } from '../core/library.js';
3
4
  import type { BindingsView } from '../core/binding-messages.js';
4
5
  import type { ResourceResolutions } from '../core/resource-resolution.js';
6
+ type El = ModdleElement;
5
7
  /** A refusal a collect-mode serialize reported instead of throwing (see {@link BpmnSerializeOpts.collect}). */
6
8
  export interface BpmnCollectedRefusal {
7
9
  code: string;
@@ -54,6 +56,18 @@ export declare function serialize(built: BuiltBpmn, opts?: BpmnSerializeOpts): P
54
56
  * under its own catch, and the XML is not written. Synchronous, for `check`.
55
57
  */
56
58
  export declare function collectSerializerRefusals(built: BuiltBpmn, opts?: Omit<BpmnSerializeOpts, 'collect'>): BpmnCollectedRefusal[];
59
+ /**
60
+ * {@link collectSerializerRefusals}, and the model it built: the
61
+ * `bpmn:Definitions` `compile` would write, with each refused element stood
62
+ * in. `definitions` is absent when collection stopped at a scope-level
63
+ * refusal, which leaves no model to judge. `check` reads it for the rules
64
+ * `uip maestro bpmn refresh` applies to the emitted bindings
65
+ * (`refresh-connections.ts`).
66
+ */
67
+ export declare function collectSerializerModel(built: BuiltBpmn, opts?: Omit<BpmnSerializeOpts, 'collect'>): {
68
+ refusals: BpmnCollectedRefusal[];
69
+ definitions?: El;
70
+ };
57
71
  /**
58
72
  * Make schema-default attributes explicit for canvas fidelity. bpmn-moddle omits
59
73
  * an attribute whose value equals the BPMN default, but Studio Web (and the
@@ -195,3 +209,4 @@ export declare function folderCompanionKeys(built: BuiltBpmn, sink: Map<string,
195
209
  export declare function publicDeclarationScope(nodes: BpmnNode[], processId: string): (v: BpmnVarDecl) => string;
196
210
  /** Flatten a scope's nodes (recursing sub-processes) for global scans. */
197
211
  export declare function allNodes(nodes: BpmnNode[]): BpmnNode[];
212
+ export {};
@@ -66,23 +66,34 @@ export async function serialize(built, opts = {}) {
66
66
  * under its own catch, and the XML is not written. Synchronous, for `check`.
67
67
  */
68
68
  export function collectSerializerRefusals(built, opts = {}) {
69
+ return collectSerializerModel(built, opts).refusals;
70
+ }
71
+ /**
72
+ * {@link collectSerializerRefusals}, and the model it built: the
73
+ * `bpmn:Definitions` `compile` would write, with each refused element stood
74
+ * in. `definitions` is absent when collection stopped at a scope-level
75
+ * refusal, which leaves no model to judge. `check` reads it for the rules
76
+ * `uip maestro bpmn refresh` applies to the emitted bindings
77
+ * (`refresh-connections.ts`).
78
+ */
79
+ export function collectSerializerModel(built, opts = {}) {
69
80
  const refusals = [];
70
81
  const collect = (r) => {
71
82
  refusals.push(r);
72
83
  };
73
84
  try {
74
- buildDefinitions(built, { ...opts, collect });
85
+ return { refusals, definitions: buildDefinitions(built, { ...opts, collect }).definitions };
75
86
  }
76
87
  catch (error) {
77
88
  if (error === COLLECTION_STOPPED)
78
- return refusals;
89
+ return { refusals };
79
90
  // An element's own refusal was taken by its catch (`createNodeCollected`),
80
91
  // so one that gets here was thrown outside any one element: scope-level,
81
92
  // and collection stops. An internal SDK error is passed on.
82
93
  const refusal = refusalOf(error);
83
94
  collect({ code: refusal.code, message: refusal.message, ...(refusal.suggestion !== undefined ? { suggestion: refusal.suggestion } : {}) });
84
95
  }
85
- return refusals;
96
+ return { refusals };
86
97
  }
87
98
  /** Thrown in collect mode once the scope-level refusals are reported, to stop collection. */
88
99
  const COLLECTION_STOPPED = Symbol('collection stopped');
@@ -216,6 +216,7 @@ export declare const REFUSALS: {
216
216
  readonly CEQL_UNPARSEABLE: "lowering";
217
217
  readonly CHECK_INCOMPLETE: "lowering";
218
218
  readonly COMPILE_FAILED: "lowering";
219
+ readonly CONNECTION_BINDING_NOT_GUID: "lint";
219
220
  readonly CONNECTION_CONNECTOR_CONFLICT: "draft";
220
221
  readonly CONNECTION_STUB: "lint";
221
222
  readonly CONNECTOR_IMPORT_NOT_A_FILE: "lowering";
@@ -493,8 +494,13 @@ export declare const REFUSALS: {
493
494
  readonly INTSVC_BINDING_MISMATCH: "lint";
494
495
  readonly INTSVC_BINDING_UNDECLARED: "lint";
495
496
  readonly INTSVC_CATALOG_PLACEHOLDER: "lint";
497
+ readonly INTSVC_CONNECTION_BINDING_MISSING: "lint";
498
+ readonly INTSVC_CONNECTION_FOLDER_MISMATCH: "lint";
496
499
  readonly INTSVC_CONNECTION_MISSING: "lint";
497
500
  readonly INTSVC_CONNECTION_NOT_BINDING: "lint";
501
+ readonly INTSVC_CONNECTION_RESOURCE_CONFLICT: "lint";
502
+ readonly INTSVC_CONNECTOR_KEY_MISSING: "lint";
503
+ readonly INTSVC_EVENT_NO_CONNECTION: "lint";
498
504
  readonly INTSVC_METHOD_UNKNOWN: "lint";
499
505
  readonly INTSVC_OBJECT_NAME_SLUG: "lint";
500
506
  readonly INTSVC_OPERATION_NOT_IDENTIFIER: "lint";
@@ -289,6 +289,7 @@ export const REFUSALS = {
289
289
  CHECK_INCOMPLETE: 'lowering',
290
290
  // A throw that is no refusal, which `compile` cannot get past: check reports it on its step.
291
291
  COMPILE_FAILED: 'lowering',
292
+ CONNECTION_BINDING_NOT_GUID: 'lint',
292
293
  CONNECTION_CONNECTOR_CONFLICT: 'draft',
293
294
  CONNECTION_STUB: 'lint',
294
295
  CONNECTOR_IMPORT_NOT_A_FILE: 'lowering',
@@ -566,8 +567,13 @@ export const REFUSALS = {
566
567
  INTSVC_BINDING_MISMATCH: 'lint',
567
568
  INTSVC_BINDING_UNDECLARED: 'lint',
568
569
  INTSVC_CATALOG_PLACEHOLDER: 'lint',
570
+ INTSVC_CONNECTION_BINDING_MISSING: 'lint',
571
+ INTSVC_CONNECTION_FOLDER_MISMATCH: 'lint',
569
572
  INTSVC_CONNECTION_MISSING: 'lint',
570
573
  INTSVC_CONNECTION_NOT_BINDING: 'lint',
574
+ INTSVC_CONNECTION_RESOURCE_CONFLICT: 'lint',
575
+ INTSVC_CONNECTOR_KEY_MISSING: 'lint',
576
+ INTSVC_EVENT_NO_CONNECTION: 'lint',
571
577
  INTSVC_METHOD_UNKNOWN: 'lint',
572
578
  INTSVC_OBJECT_NAME_SLUG: 'lint',
573
579
  INTSVC_OPERATION_NOT_IDENTIFIER: 'lint',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.86.26",
3
+ "version": "6.86.27",
4
4
  "description": "Build UiPath Flow, Case, and BPMN artifacts by writing TypeScript.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.uipath.com/maestro",
@@ -110,5 +110,5 @@
110
110
  "@types/node": "^22.7.0",
111
111
  "esbuild": "^0.28.1"
112
112
  },
113
- "gitref": "bc4ddcf0729693541e961a3e409278eac606cb4c"
113
+ "gitref": "c094adf2e550683e159edfc08df46e5d842e76a8"
114
114
  }