@uipath/maestro-builder-sdk 6.18.6 → 6.18.8

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.
@@ -10,6 +10,7 @@
10
10
  import type { BuiltCase } from './case-sdk.js';
11
11
  import { type ConnectorCheckOpts } from '../core/connector-checks.js';
12
12
  import type { EventSubscription } from '../core/actions.js';
13
+ import { type EventCheckOpts } from '../core/event-checks.js';
13
14
  export interface Diagnostic {
14
15
  level: 'error' | 'warning';
15
16
  code: string;
@@ -26,13 +27,13 @@ export interface Diagnostic {
26
27
  * the event, and validates a connector task's inputs and resolves its lookups
27
28
  * through the shared `buildConnectorInputs` (`connectorInputs`, `lookups`,
28
29
  * `resolutions`), and refuses a connection/folder label bindings.json cannot
29
- * turn into a resource key (`bindings`, `bindingLabelRefusal`). It does not
30
- * check BYOA, so that hook stays off until Case compile enforces it.
30
+ * turn into a resource key (`bindings`, `bindingLabelRefusal`), and refuses an
31
+ * event on an unverified BYOA connection (`eventFacts`, `byoa`).
31
32
  *
32
33
  * Every hook fails open: without a library, `check` stays a pure function of the
33
34
  * built model.
34
35
  */
35
- export type CaseCheckOpts = Pick<ConnectorCheckOpts, 'connectorResolveError' | 'connectorInputs' | 'lookups' | 'resolutions' | 'schemaReadiness' | 'bindings'> & {
36
+ export type CaseCheckOpts = Pick<ConnectorCheckOpts, 'connectorResolveError' | 'connectorInputs' | 'lookups' | 'resolutions' | 'schemaReadiness' | 'bindings'> & Pick<EventCheckOpts, 'eventFacts' | 'byoa'> & {
36
37
  /**
37
38
  * What Case `compile` would refuse an event subscription with, or `undefined`
38
39
  * when it resolves: `EVENT_UNKNOWN` (the event is not in the library, or
@@ -298,10 +298,17 @@ function checkLibraryConnectors(built, opts, diags) {
298
298
  const refused = opts.subscriptionError?.(kind, sub);
299
299
  if (refused !== undefined)
300
300
  diags.push({ level: 'error', code: refused.code, message: `${where}: ${refused.message}`, where: at });
301
- // A `where` lookup nobody recorded: Flow's LOOKUP_UNRESOLVED warning, from the
302
- // shared event rules. Only `resolutions` is passed, so nothing else in them fires.
303
301
  checkBindingLabels(where, sub, opts, (code, message) => diags.push({ level: 'error', code, message, where: at }), { key: sub.connector, action: sub.event });
304
- checkEventResolution(sub, where, kind, { resolutions: opts.resolutions ?? {} }, (code, message) => diags.push({ level: 'error', code, message, where: at }), (code, message) => diags.push({ level: 'warning', code, message, where: at }));
302
+ // From the shared event rules, the two Case compile enforces: a `where` lookup
303
+ // nobody recorded (LOOKUP_UNRESOLVED, a warning) and an unverified BYOA
304
+ // connection (EVENT_BYOA_UNVERIFIED). Only their hooks are passed, so nothing
305
+ // else in them fires.
306
+ checkEventResolution(sub, where, kind, {
307
+ resolutions: opts.resolutions ?? {},
308
+ ...(opts.eventFacts ? { eventFacts: opts.eventFacts } : {}),
309
+ ...(opts.byoa ? { byoa: opts.byoa } : {}),
310
+ ...(opts.bindings ? { bindings: opts.bindings } : {}),
311
+ }, (code, message) => diags.push({ level: 'error', code, message, where: at }), (code, message) => diags.push({ level: 'warning', code, message, where: at }));
305
312
  };
306
313
  const rules = (conditions, where) => {
307
314
  for (const c of conditions)
@@ -9,9 +9,8 @@ import type { CaseCheckOpts } from './check.js';
9
9
  * compile's own call), a connector task's field contract and lookups (the
10
10
  * `=`-expression validator Case compile runs), and the schema-readiness warnings.
11
11
  * With `bindings`, the binding-label rules (BINDING_SELF_NAME, BINDING_UNDECLARED),
12
- * which Case `serialize` enforces through the same `bindingLabelRefusal`. The
13
- * BYOA hooks of the shared bag are left out, because Case `serialize` does not
14
- * enforce them.
12
+ * which Case `serialize` enforces through the same `bindingLabelRefusal`, and the
13
+ * BYOA facts and ledger, for the refusal `resolveCaseSubscription` makes.
15
14
  *
16
15
  * @param library - The library `openCliLibrary` returned, or `undefined`.
17
16
  * @param bindings - The project's bindings.json, as compile reads it.
@@ -18,9 +18,8 @@ import { EVENT_GENERIC_NO_OBJECT, GenericEventNoObjectError, resolveCaseSubscrip
18
18
  * compile's own call), a connector task's field contract and lookups (the
19
19
  * `=`-expression validator Case compile runs), and the schema-readiness warnings.
20
20
  * With `bindings`, the binding-label rules (BINDING_SELF_NAME, BINDING_UNDECLARED),
21
- * which Case `serialize` enforces through the same `bindingLabelRefusal`. The
22
- * BYOA hooks of the shared bag are left out, because Case `serialize` does not
23
- * enforce them.
21
+ * which Case `serialize` enforces through the same `bindingLabelRefusal`, and the
22
+ * BYOA facts and ledger, for the refusal `resolveCaseSubscription` makes.
24
23
  *
25
24
  * @param library - The library `openCliLibrary` returned, or `undefined`.
26
25
  * @param bindings - The project's bindings.json, as compile reads it.
@@ -36,6 +35,8 @@ export function caseCheckOpts(library, bindings) {
36
35
  connectorInputs: shared.connectorInputs,
37
36
  lookups: shared.lookups,
38
37
  resolutions: shared.resolutions,
38
+ eventFacts: shared.eventFacts,
39
+ byoa: shared.byoa,
39
40
  schemaReadiness: shared.schemaReadiness,
40
41
  externalDescriptorError: (kind, d) => {
41
42
  let rc;
@@ -890,7 +890,7 @@ function resolvedSubscriptionBag(kind, spec, resolver, elementId, where) {
890
890
  if (!resolver.library)
891
891
  throw new Error(`${kind === 'trigger' ? 'event trigger' : 'wait-for-connector'} needs the connector library — `
892
892
  + `pass { library } to serialize or use uip maestro case compile --library.`);
893
- const rc = resolveCaseSubscription(resolver.library, kind, spec);
893
+ const rc = resolveCaseSubscription(resolver.library, kind, spec, { where, bindings: resolver.bindings });
894
894
  const op = rc.entry.operation ?? {};
895
895
  const context = [io('connectorKey', 'string', { value: rc.connectorKey })];
896
896
  const target = { key: spec.connector, action: spec.event };
@@ -10,6 +10,7 @@
10
10
  */
11
11
  import type { EventSubscription } from '../core/actions.js';
12
12
  import type { Library, ResolvedConnector } from '../core/library.js';
13
+ import type { BindingsView } from '../core/binding-messages.js';
13
14
  /** Check's code for {@link GenericEventNoObjectError}; Flow and BPMN `check` use the same one. */
14
15
  export declare const EVENT_GENERIC_NO_OBJECT = "EVENT_GENERIC_NO_OBJECT";
15
16
  /** A GENERIC event subscription that names no object. */
@@ -24,7 +25,13 @@ export declare class GenericEventNoObjectError extends Error {
24
25
  * @param library - The connector library.
25
26
  * @param kind - `trigger` for an event trigger, `event` for a wait-for-connector task or rule.
26
27
  * @param sub - The authored subscription.
28
+ * @param byoa - Where the subscription is and the bindings, to refuse an
29
+ * unverified BYOA connection; compile passes it, `check` does not (it reports
30
+ * that rule from the shared event rules).
27
31
  * @returns The resolved event.
28
- * @throws What `resolveEvent` throws, or {@link GenericEventNoObjectError}.
32
+ * @throws What `resolveEvent` throws, {@link GenericEventNoObjectError}, or a `ByoaRefusal`.
29
33
  */
30
- export declare function resolveCaseSubscription(library: Library, kind: 'trigger' | 'event', sub: EventSubscription): ResolvedConnector;
34
+ export declare function resolveCaseSubscription(library: Library, kind: 'trigger' | 'event', sub: EventSubscription, byoa?: {
35
+ where: string;
36
+ bindings?: BindingsView;
37
+ }): ResolvedConnector;
@@ -1,4 +1,5 @@
1
1
  import { genericEventObjectRefusal } from '../core/event-checks.js';
2
+ import { ByoaRefusal, byoaUnverified } from '../core/byoa.js';
2
3
  /** Check's code for {@link GenericEventNoObjectError}; Flow and BPMN `check` use the same one. */
3
4
  export const EVENT_GENERIC_NO_OBJECT = 'EVENT_GENERIC_NO_OBJECT';
4
5
  /** A GENERIC event subscription that names no object. */
@@ -17,13 +18,25 @@ function caseObjectOption(object) {
17
18
  * @param library - The connector library.
18
19
  * @param kind - `trigger` for an event trigger, `event` for a wait-for-connector task or rule.
19
20
  * @param sub - The authored subscription.
21
+ * @param byoa - Where the subscription is and the bindings, to refuse an
22
+ * unverified BYOA connection; compile passes it, `check` does not (it reports
23
+ * that rule from the shared event rules).
20
24
  * @returns The resolved event.
21
- * @throws What `resolveEvent` throws, or {@link GenericEventNoObjectError}.
25
+ * @throws What `resolveEvent` throws, {@link GenericEventNoObjectError}, or a `ByoaRefusal`.
22
26
  */
23
- export function resolveCaseSubscription(library, kind, sub) {
27
+ export function resolveCaseSubscription(library, kind, sub, byoa) {
24
28
  const rc = library.resolveEvent(kind, sub.connector, sub.event, sub.version, sub.object);
25
29
  const noObject = genericEventObjectRefusal(rc, sub, caseObjectOption);
26
30
  if (noObject)
27
31
  throw new GenericEventNoObjectError(noObject);
32
+ // A BYOA-only event on a connection `prepare` never checked deploys and never
33
+ // fires (#848). Flow's `refuseUnverifiedByoa` rule and text (`byoaUnverified`);
34
+ // Case `check` reports it from the shared event rules (`eventFacts` / `byoa`).
35
+ if (byoa && typeof library.eventFacts === 'function') {
36
+ const object = typeof sub.object === 'string' && sub.object !== '' ? sub.object : undefined;
37
+ const message = byoaUnverified(byoa.where, { connector: sub.connector, event: sub.event, ...(object ? { object } : {}), connection: sub.connection }, library.eventFacts(sub.connector, sub.event, object), library.byoaVerifications, byoa.bindings);
38
+ if (message)
39
+ throw new ByoaRefusal(message);
40
+ }
28
41
  return rc;
29
42
  }
@@ -4,6 +4,7 @@ import { createRequire } from "node:module";
4
4
  import { join } from "node:path";
5
5
  import { writeJsonFile } from "../../core/json-file.js";
6
6
  import { HostUipClient } from "./host.js";
7
+ import { launchFor } from "./launch.js";
7
8
  /**
8
9
  * Room for the largest `registry search` a tenant has answered, with margin.
9
10
  * `execFile`'s 1 MiB default cut that stream off, so the port raised it; a
@@ -35,6 +36,9 @@ export class SpawnUipClient {
35
36
  const [executable, ...args] = argv;
36
37
  const timeoutMs = options.timeoutMs ?? this.defaults.timeoutMs;
37
38
  return new Promise((resolve, reject) => {
39
+ // `uip` stays the logical name in argv (recordings are keyed by it);
40
+ // only here is it turned into what Windows can start (launch.ts, #940).
41
+ const launch = launchFor(executable, args);
38
42
  // stdin is `ignore`, not the default pipe. A pipe this process never
39
43
  // writes to stays open, so a `uip` that decides to prompt — an expired
40
44
  // login, a consent question — would block on it for as long as the
@@ -42,7 +46,7 @@ export class SpawnUipClient {
42
46
  // reads EOF at once and the CLI fails like any other call, which is
43
47
  // what Python's `subprocess.run` gave it: the parent's stdin, already at
44
48
  // EOF on an agent.
45
- const child = childProcess().spawn(executable, args, {
49
+ const child = childProcess().spawn(launch.file, launch.args, {
46
50
  cwd: options.cwd ?? this.defaults.cwd,
47
51
  stdio: ["ignore", "pipe", "pipe"],
48
52
  });
@@ -265,7 +269,8 @@ export function runUipSync(argv, options = {}) {
265
269
  if (replay)
266
270
  return { ...readRecording(replay, argv).result };
267
271
  const [executable, ...args] = argv;
268
- const r = childProcess().spawnSync(executable, args, {
272
+ const launch = launchFor(executable, args);
273
+ const r = childProcess().spawnSync(launch.file, launch.args, {
269
274
  cwd: options.cwd,
270
275
  stdio: ["ignore", "pipe", "pipe"],
271
276
  encoding: "utf8",
@@ -1,4 +1,5 @@
1
1
  import { createRequire } from "node:module";
2
+ import { launchFor } from "./launch.js";
2
3
  /** The MCP tool this client calls; a server without it is treated as absent. */
3
4
  export const HOST_TOOL = "run_argv";
4
5
  /** How long the host may take to start and list its tools before the client gives up on it. */
@@ -241,7 +242,8 @@ export class HostUipClient {
241
242
  // entries reach `client.ts`, so a static import would load a process API on
242
243
  // every builder import (FB009).
243
244
  const { spawn } = createRequire(import.meta.url)("node:child_process");
244
- child = spawn(command[0], command.slice(1), { stdio: ["pipe", "pipe", "pipe"] });
245
+ const launch = launchFor(command[0], command.slice(1));
246
+ child = spawn(launch.file, launch.args, { stdio: ["pipe", "pipe", "pipe"] });
245
247
  }
246
248
  catch (error) {
247
249
  this.giveUp(`could not start ${command.join(" ")}: ${error instanceof Error ? error.message : String(error)}`);
@@ -0,0 +1,24 @@
1
+ export interface Launch {
2
+ file: string;
3
+ args: string[];
4
+ }
5
+ /** The parts of the host the lookup reads; injected so the Windows branch is testable anywhere. */
6
+ export interface LaunchHost {
7
+ platform: NodeJS.Platform;
8
+ /** `PATH`, `;`-separated on Windows. */
9
+ path: string | undefined;
10
+ /** `PATHEXT`; cmd.exe's default when unset. */
11
+ pathExt: string | undefined;
12
+ /** The Node that runs a shim's script — this process's own. */
13
+ execPath: string;
14
+ isFile(path: string): boolean;
15
+ readFile(path: string): string;
16
+ }
17
+ /**
18
+ * The file and arguments to spawn for `executable args`, without a shell.
19
+ *
20
+ * @throws when, on Windows, the name resolves to a batch shim this cannot read
21
+ * a script out of — naming the shim, so the remedy is not "put uip on PATH"
22
+ * for a `uip` that is on PATH.
23
+ */
24
+ export declare function launchFor(executable: string, args: readonly string[], host?: LaunchHost): Launch;
@@ -0,0 +1,105 @@
1
+ /**
2
+ * What to actually spawn for a logical `uip` command line.
3
+ *
4
+ * Every argv in the registry starts with the bare name `uip` (`commands.ts`),
5
+ * and that name is what recordings are keyed by, so it stays bare everywhere
6
+ * above the spawn. On POSIX the bare name is also what `spawn` wants. On
7
+ * Windows it is not (flow-builder-sdk#940): npm installs the CLI as a `uip.cmd`
8
+ * shim (plus a POSIX `uip` script Windows cannot run), and Node starts neither
9
+ * without a shell — `uip` is `ENOENT`, and `uip.cmd` is `EINVAL` since the
10
+ * CVE-2024-27980 fix refused `.cmd`/`.bat` without `shell`.
11
+ *
12
+ * `shell: true` would start it, but every argument (`-f name=value`, a JSON
13
+ * value, a `|` in a JMESPath filter) would then go through cmd.exe quoting, and
14
+ * a timeout's `kill` would end cmd.exe and leave the CLI running. So on Windows
15
+ * a bare name is looked up on `PATH` the way cmd.exe would (`PATHEXT` order),
16
+ * and:
17
+ * - an `.exe`/`.com` is spawned by its full path;
18
+ * - a `.cmd`/`.bat` npm shim is read for the script it runs
19
+ * (`"%dp0%\node_modules\@uipath\cli\dist\index.js" %*`), and that script is
20
+ * run with this process's own Node, which is what the shim would do;
21
+ * - a shim that names no script is an error that says so, not a guess.
22
+ * A name that is not bare (a path, or one with an extension) is spawned as
23
+ * given, and so is anything on another platform.
24
+ *
25
+ * Example, on Windows with npm's global bin on PATH:
26
+ * launchFor("uip", ["--version"])
27
+ * // -> { file: "C:\\Program Files\\nodejs\\node.exe",
28
+ * // args: ["C:\\Users\\me\\AppData\\Roaming\\npm\\node_modules\\@uipath\\cli\\dist\\index.js", "--version"] }
29
+ */
30
+ import { readFileSync, statSync } from "node:fs";
31
+ import { win32 } from "node:path";
32
+ const DEFAULT_PATHEXT = ".COM;.EXE;.BAT;.CMD";
33
+ /**
34
+ * The script an npm (`cmd-shim`) or pnpm shim hands its arguments to: the last
35
+ * quoted `%dp0%\…` / `%~dp0\…` path followed by `%*`. Only a JavaScript target
36
+ * counts; a shim around something else is not one this module can run directly.
37
+ */
38
+ const SHIM_TARGET = /"%~?dp0%?\\([^"]+\.[cm]?js)"\s+%\*/g;
39
+ function ambientHost() {
40
+ return {
41
+ platform: process.platform,
42
+ path: process.env.PATH,
43
+ pathExt: process.env.PATHEXT,
44
+ execPath: process.execPath,
45
+ isFile: (path) => {
46
+ try {
47
+ return statSync(path).isFile();
48
+ }
49
+ catch {
50
+ return false;
51
+ }
52
+ },
53
+ readFile: (path) => readFileSync(path, "utf8"),
54
+ };
55
+ }
56
+ /** True for a name `PATH` lookup applies to: no directory part and no extension. */
57
+ function isBareName(executable) {
58
+ return executable !== "" && !/[\\/]/.test(executable) && win32.extname(executable) === "";
59
+ }
60
+ /** The first `<dir>\<executable><ext>` on PATH, in cmd.exe's order, or undefined. */
61
+ function findOnPath(executable, host) {
62
+ const extensions = (host.pathExt || DEFAULT_PATHEXT).split(";").filter(Boolean);
63
+ for (const dir of (host.path ?? "").split(";")) {
64
+ const trimmed = dir.trim().replace(/^"(.*)"$/, "$1");
65
+ if (trimmed === "")
66
+ continue;
67
+ for (const ext of extensions) {
68
+ const candidate = win32.join(trimmed, executable + ext.toLowerCase());
69
+ if (host.isFile(candidate))
70
+ return candidate;
71
+ }
72
+ }
73
+ return undefined;
74
+ }
75
+ /** The script a `.cmd`/`.bat` shim runs, as an absolute path, or undefined. */
76
+ function shimTarget(shim, host) {
77
+ const matches = [...host.readFile(shim).matchAll(SHIM_TARGET)];
78
+ const last = matches.at(-1);
79
+ return last ? win32.join(win32.dirname(shim), last[1]) : undefined;
80
+ }
81
+ /**
82
+ * The file and arguments to spawn for `executable args`, without a shell.
83
+ *
84
+ * @throws when, on Windows, the name resolves to a batch shim this cannot read
85
+ * a script out of — naming the shim, so the remedy is not "put uip on PATH"
86
+ * for a `uip` that is on PATH.
87
+ */
88
+ export function launchFor(executable, args, host = ambientHost()) {
89
+ if (host.platform !== "win32" || !isBareName(executable))
90
+ return { file: executable, args: [...args] };
91
+ const found = findOnPath(executable, host);
92
+ // Not on PATH: spawn the bare name and let the ENOENT say so.
93
+ if (!found)
94
+ return { file: executable, args: [...args] };
95
+ const ext = win32.extname(found).toLowerCase();
96
+ if (ext !== ".cmd" && ext !== ".bat")
97
+ return { file: found, args: [...args] };
98
+ const script = shimTarget(found, host);
99
+ if (!script || !host.isFile(script)) {
100
+ throw new Error(`Could not start ${executable}: ${found} is a batch file, which Node cannot run without a shell, ` +
101
+ (script ? `and the script it names (${script}) does not exist.` : "and it names no JavaScript entry point to run instead.") +
102
+ " Reinstall the UiPath CLI with npm (`npm install -g @uipath/cli`).");
103
+ }
104
+ return { file: host.execPath, args: [script, ...args] };
105
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.18.6",
3
+ "version": "6.18.8",
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",
@@ -92,5 +92,5 @@
92
92
  "@types/node": "^22.7.0",
93
93
  "esbuild": "^0.28.1"
94
94
  },
95
- "gitref": "27768f00ecc6986a54deba3c8f327d01ace642f8"
95
+ "gitref": "ce161efe130f6a6cdee895d8a7fab2faddcec0fd"
96
96
  }