@uipath/maestro-builder-sdk 6.65.0 → 6.66.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.
@@ -1,7 +1,8 @@
1
1
  import { createTypedNode, typedNodeOutputVar } from './typed-node.js';
2
2
  import { connectorBindingRef } from './connector.js';
3
- import { eventFilterJmes, eventFilterProblem, jmesString, jmesStringProblem, readEventFilter } from '../core/event-filters.js';
3
+ import { eventFilterJmes, jmesString, jmesStringProblem, readEventFilterLeaf } from '../core/event-filters.js';
4
4
  import { resolveEventWhere } from '../core/lookups.js';
5
+ import { CompileRefusal } from '../core/compile-refusal.js';
5
6
  /**
6
7
  * Which extension type an external invocation lowers to.
7
8
  *
@@ -57,14 +58,14 @@ export function intsvcOutputVar(n) {
57
58
  */
58
59
  export function createConnectorEvent(ctx, n) {
59
60
  if (!ctx.library)
60
- throw new Error(`connector event "${n.id}" needs the connector library — pass { library } to serialize ` +
61
+ throw new CompileRefusal('LIBRARY_REQUIRED', `connector event "${n.id}" needs the connector library — pass { library } to serialize ` +
61
62
  `or use uip maestro bpmn compile --library.`);
62
63
  const rc = ctx.library.resolveEvent(n.subscribe, n.key, n.eventName, n.version, n.object);
63
64
  const op = (rc.entry.operation ?? {});
64
65
  const runtime = rc.entry.runtime ?? {};
65
66
  const type = runtime.serviceType;
66
67
  if (!type) {
67
- throw new Error(`connector event ${n.key}/${n.eventName} has no runtime.serviceType in the library; ` +
68
+ throw new CompileRefusal('BPMN_EVENT_NO_SERVICE_TYPE', `connector event ${n.key}/${n.eventName} has no runtime.serviceType in the library; ` +
68
69
  `it cannot be authored as a BPMN node.`);
69
70
  }
70
71
  // The PLACEMENT decides the extension type — `.eventTrigger()` starts the
@@ -79,13 +80,13 @@ export function createConnectorEvent(ctx, n) {
79
80
  // .eventTrigger() instead", while the unprepared same node compiled.
80
81
  const expected = intsvcServiceType(n);
81
82
  if (type !== 'Intsvc.EventTrigger' && type !== 'Intsvc.WaitForEvent') {
82
- throw new Error(`connector event "${n.id}" was authored as a ${n.subscribe} (${expected}), but the library ` +
83
+ throw new CompileRefusal('BPMN_EVENT_KIND_MISMATCH', `connector event "${n.id}" was authored as a ${n.subscribe} (${expected}), but the library ` +
83
84
  `describes ${n.key}/${n.eventName} as ${type}, which is not a connector event.`);
84
85
  }
85
86
  const conn = connectorBindingRef(ctx, n.connection, 'Connection', 'ConnectionId', `${rc.connectorKey} connection`);
86
87
  const folder = connectorBindingRef(ctx, n.folder, 'Connection', 'folderKey', 'FolderKey', conn?.resourceKey);
87
88
  if (!conn || !folder) {
88
- throw new Error(`connector event "${n.id}" needs both a connection and a folder binding name — ` +
89
+ throw new CompileRefusal('BPMN_EVENT_BINDINGS_MISSING', `connector event "${n.id}" needs both a connection and a folder binding name — ` +
89
90
  `the type declares connectionId, folderId, folderPath and folderKey all required.`);
90
91
  }
91
92
  // The registry marks `operation` and `objectName` required AND hidden, so an
@@ -144,20 +145,20 @@ export function eventFilterBody(nodeId, scope, filters) {
144
145
  const scopeClauses = scopeEntries.map(([k, v]) => {
145
146
  const problem = jmesStringProblem(String(v));
146
147
  if (problem)
147
- throw new Error(`connector event "${nodeId}": \`filter.${k}\`: ${problem}`);
148
+ throw new CompileRefusal('EVENT_FILTER_BACKSLASH', `connector event "${nodeId}": \`filter.${k}\`: ${problem}`);
148
149
  return `(${k} == ${jmesString(String(v))})`;
149
150
  });
150
151
  const conditions = (filters ?? []).map((leaf, i) => {
151
- const { read } = readEventFilter(leaf);
152
- if (!read) {
153
- throw new Error(`connector event "${nodeId}": filters[${i}] must carry a field and exactly ONE operator ` +
154
- `(contains, startsWith, endsWith, equals, notEquals, lessThan, lessThanOrEqual, greaterThan, ` +
155
- `greaterThanOrEqual) — got ${JSON.stringify(leaf)}.`);
152
+ // The code `check` gives the same leaf (`core/event-checks.ts`).
153
+ const judged = readEventFilterLeaf(leaf);
154
+ if (judged.code !== undefined) {
155
+ throw new CompileRefusal(judged.code, judged.problem !== undefined
156
+ ? `connector event "${nodeId}": filters[${i}] on \`${judged.read?.field}\`: ${judged.problem}`
157
+ : `connector event "${nodeId}": filters[${i}] must carry a field and exactly ONE operator ` +
158
+ `(contains, startsWith, endsWith, equals, notEquals, lessThan, lessThanOrEqual, greaterThan, ` +
159
+ `greaterThanOrEqual) — got ${JSON.stringify(leaf)}.`);
156
160
  }
157
- const problem = eventFilterProblem(read);
158
- if (problem)
159
- throw new Error(`connector event "${nodeId}": filters[${i}] on \`${read.field}\`: ${problem}`);
160
- return `(${eventFilterJmes(read)})`;
161
+ return `(${eventFilterJmes(judged.read)})`;
161
162
  });
162
163
  const expression = [...scopeClauses, ...conditions].join(' && ');
163
164
  const body = {};
@@ -176,7 +177,7 @@ export function eventFilterBody(nodeId, scope, filters) {
176
177
  */
177
178
  export function createExternalTask(ctx, n) {
178
179
  if (!ctx.library)
179
- throw new Error(`external ${n.family} "${n.id}" needs the connector library — pass { library } to serialize ` +
180
+ throw new CompileRefusal('LIBRARY_REQUIRED', `external ${n.family} "${n.id}" needs the connector library — pass { library } to serialize ` +
180
181
  `or use uip maestro bpmn compile --library.`);
181
182
  const rc = ctx.library.resolve(n.key, n.action, n.version);
182
183
  const op = (rc.entry.operation ?? {});
@@ -186,14 +187,14 @@ export function createExternalTask(ctx, n) {
186
187
  // validator accepts and the runtime dispatches to the wrong handler family —
187
188
  // the Case SDK records the same trap in its Phase 4.4 notes.
188
189
  if (op.subType !== wanted) {
189
- throw new Error(`external ${n.family} "${n.id}" needs ${wanted === 'AgentExecution' ? 'an' : 'a'} ${wanted} descriptor, but ` +
190
+ throw new CompileRefusal('EXTERNAL_TASK_DESCRIPTOR_CONTRACT', `external ${n.family} "${n.id}" needs ${wanted === 'AgentExecution' ? 'an' : 'a'} ${wanted} descriptor, but ` +
190
191
  `${n.key}/${n.action} is "${String(op.subType ?? 'untyped')}". ` +
191
192
  `The shipped library has very few of these — ${wanted === 'AgentExecution' ? '2' : '1'} operation(s).`);
192
193
  }
193
194
  const conn = connectorBindingRef(ctx, n.connection, 'Connection', 'ConnectionId', `${rc.connectorKey} connection`);
194
195
  const folder = connectorBindingRef(ctx, n.folder, 'Connection', 'folderKey', 'FolderKey', conn?.resourceKey);
195
196
  if (!conn || !folder) {
196
- throw new Error(`external ${n.family} "${n.id}" needs both a connection and a folder binding name.`);
197
+ throw new CompileRefusal(conn ? 'EXTERNAL_TASK_FOLDER' : 'EXTERNAL_TASK_CONNECTION', `external ${n.family} "${n.id}" needs both a connection and a folder binding name.`);
197
198
  }
198
199
  return createTypedNode(ctx.m, n.id, EXTERNAL_SERVICE_TYPE[n.family][n.mode], {
199
200
  name: n.name ?? rc.entry.display?.label ?? n.action,
package/dist/bpmn/load.js CHANGED
@@ -3,22 +3,23 @@ import { pathToFileURL } from 'node:url';
3
3
  import { resolve } from 'node:path';
4
4
  import { existsSync } from 'node:fs';
5
5
  import { useThisSdkForAuthoredSource } from '../sdk-resolve.js';
6
+ import { CompileRefusal } from '../core/compile-refusal.js';
6
7
  /** Resolve a user argument (a `.ts` path or a BaseName) to a bpmn source file. */
7
8
  export function resolveBpmnFile(arg) {
8
9
  const candidates = [arg, `${arg}.bpmn.ts`, `${arg}.ts`];
9
10
  for (const c of candidates)
10
11
  if (existsSync(resolve(c)))
11
12
  return resolve(c);
12
- throw new Error(`bpmn source not found: tried ${candidates.join(', ')}`);
13
+ throw new CompileRefusal('BPMN_SOURCE_NOT_FOUND', `bpmn source not found: tried ${candidates.join(', ')}`);
13
14
  }
14
15
  export async function loadBuiltBpmn(file) {
15
16
  useThisSdkForAuthoredSource();
16
17
  const mod = await import(pathToFileURL(file).href);
17
18
  const exp = mod.default ?? mod.bpmn;
18
19
  if (!exp)
19
- throw new Error(`${file} has no default export. Add: export default bpmn('id')...build();`);
20
+ throw new CompileRefusal('BPMN_NO_DEFAULT_EXPORT', `${file} has no default export. Add: export default bpmn('id')...build();`);
20
21
  const built = typeof exp.build === 'function' ? exp.build() : exp;
21
22
  if (!built || !Array.isArray(built.nodes))
22
- throw new Error(`${file} default export is not a built bpmn. Did you call .build()?`);
23
+ throw new CompileRefusal('BPMN_EXPORT_NOT_BUILT', `${file} default export is not a built bpmn. Did you call .build()?`);
23
24
  return built;
24
25
  }