@uipath/maestro-builder-sdk 6.13.0 → 6.14.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.
package/README.md CHANGED
@@ -8,12 +8,18 @@ Data flows through named variables and expressions — you never write native `i
8
8
 
9
9
  ## Quick start
10
10
 
11
- Install the SDK:
11
+ Install the SDK globally:
12
12
 
13
13
  ```bash
14
- npm install @uipath/maestro-builder-sdk
14
+ npm install -g @uipath/maestro-builder-sdk
15
15
  ```
16
16
 
17
+ A global install is enough: the workspace needs no `package.json` or
18
+ `node_modules`. When the SDK loads an authored file, every
19
+ `import … from '@uipath/maestro-builder-sdk'` (and `/case`, `/bpmn`) resolves
20
+ to the copy that is running, wherever it is installed. A project-local install
21
+ (`npm install --save-dev`) still works, for a project that pins a version.
22
+
17
23
  ### Author
18
24
 
19
25
  A whole flow is one file. `HelloWorld.flow.ts`:
package/dist/bpmn/load.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { pathToFileURL } from 'node:url';
3
3
  import { resolve } from 'node:path';
4
4
  import { existsSync } from 'node:fs';
5
+ import { useThisSdkForAuthoredSource } from '../sdk-resolve.js';
5
6
  /** Resolve a user argument (a `.ts` path or a BaseName) to a bpmn source file. */
6
7
  export function resolveBpmnFile(arg) {
7
8
  const candidates = [arg, `${arg}.bpmn.ts`, `${arg}.ts`];
@@ -11,6 +12,7 @@ export function resolveBpmnFile(arg) {
11
12
  throw new Error(`bpmn source not found: tried ${candidates.join(', ')}`);
12
13
  }
13
14
  export async function loadBuiltBpmn(file) {
15
+ useThisSdkForAuthoredSource();
14
16
  const mod = await import(pathToFileURL(file).href);
15
17
  const exp = mod.default ?? mod.bpmn;
16
18
  if (!exp)
package/dist/case/load.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { pathToFileURL } from 'node:url';
3
3
  import { resolve } from 'node:path';
4
4
  import { existsSync, statSync } from 'node:fs';
5
+ import { useThisSdkForAuthoredSource } from '../sdk-resolve.js';
5
6
  /**
6
7
  * Resolve a user argument (a `.ts` path or a BaseName) to a case source file.
7
8
  *
@@ -21,6 +22,7 @@ export function resolveCaseFile(arg) {
21
22
  throw new Error(`case source not found: tried ${candidates.join(', ')}`);
22
23
  }
23
24
  export async function loadBuiltCase(file) {
25
+ useThisSdkForAuthoredSource();
24
26
  const mod = await import(pathToFileURL(file).href);
25
27
  const exp = mod.default ?? mod.casePlan ?? mod.case;
26
28
  if (!exp)
package/dist/load.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { fileURLToPath, pathToFileURL } from 'node:url';
3
3
  import { basename, dirname, join, resolve } from 'node:path';
4
4
  import { statSync } from 'node:fs';
5
+ import { useThisSdkForAuthoredSource } from './sdk-resolve.js';
5
6
  /** Resolve a user argument (a `.ts` path or a BaseName) to a flow source file. */
6
7
  export function resolveFlowFile(arg) {
7
8
  const candidates = [arg, `${arg}.flow.ts`, `${arg}.ts`];
@@ -19,6 +20,7 @@ export function resolveFlowFile(arg) {
19
20
  throw new Error(`flow source not found: tried ${candidates.join(', ')}`);
20
21
  }
21
22
  export async function loadBuiltFlow(file) {
23
+ useThisSdkForAuthoredSource();
22
24
  let mod;
23
25
  try {
24
26
  mod = await import(pathToFileURL(file).href);
@@ -0,0 +1,9 @@
1
+ interface ResolveContext {
2
+ parentURL?: string;
3
+ [key: string]: unknown;
4
+ }
5
+ type NextResolve = (specifier: string, context?: ResolveContext) => unknown;
6
+ /** True for the package name and its subpath exports (`/case`, `/bpmn`, …). */
7
+ export declare function isSdkSpecifier(specifier: string): boolean;
8
+ export declare function resolve(specifier: string, context: ResolveContext, nextResolve: NextResolve): Promise<unknown>;
9
+ export {};
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Node resolve hook: authored source always imports THIS copy of the SDK.
3
+ *
4
+ * Authored `.flow.ts` / `.case.ts` / `.bpmn.ts` files, and the `connectors/*.ts`
5
+ * modules the registry generates, import the package by name. Node resolves a
6
+ * bare specifier by walking `node_modules` up from the importing file, so the
7
+ * name only resolved when the workspace had its own install. A global install
8
+ * (`npm install -g`) is never on that path, and ESM ignores `NODE_PATH`.
9
+ *
10
+ * The hook re-resolves those specifiers from inside this package instead.
11
+ * Node's package self-reference (a package may import its own name when it
12
+ * declares `exports`) then maps them to the files beside this one. The same
13
+ * mapping also guarantees one copy: the serializer checks builders with
14
+ * `instanceof`, and a second copy of the package in the workspace would fail
15
+ * those checks with errors that do not name the cause.
16
+ *
17
+ * Registered by `sdk-resolve.ts` before any authored module is imported.
18
+ */
19
+ import { PACKAGE_NAME } from './package-name.js';
20
+ /** True for the package name and its subpath exports (`/case`, `/bpmn`, …). */
21
+ export function isSdkSpecifier(specifier) {
22
+ return specifier === PACKAGE_NAME || specifier.startsWith(`${PACKAGE_NAME}/`);
23
+ }
24
+ export async function resolve(specifier, context, nextResolve) {
25
+ if (isSdkSpecifier(specifier)) {
26
+ return nextResolve(specifier, { ...context, parentURL: import.meta.url });
27
+ }
28
+ return nextResolve(specifier, context);
29
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Make `import … from '@uipath/maestro-builder-sdk'` in authored source resolve
3
+ * to the running package, installed locally or globally. See
4
+ * `sdk-resolve-hook.ts` for why. Idempotent; call it before importing authored
5
+ * source.
6
+ *
7
+ * Does nothing when the compiled hook is absent, which is the case only when
8
+ * the SDK runs from its TypeScript source under the test runner. The runner
9
+ * resolves imports itself, so no hook is needed there.
10
+ */
11
+ export declare function useThisSdkForAuthoredSource(): void;
@@ -0,0 +1,24 @@
1
+ /** Register the resolve hook that points authored source at this SDK copy. */
2
+ import { existsSync } from 'node:fs';
3
+ import { register } from 'node:module';
4
+ import { fileURLToPath } from 'node:url';
5
+ let registered = false;
6
+ /**
7
+ * Make `import … from '@uipath/maestro-builder-sdk'` in authored source resolve
8
+ * to the running package, installed locally or globally. See
9
+ * `sdk-resolve-hook.ts` for why. Idempotent; call it before importing authored
10
+ * source.
11
+ *
12
+ * Does nothing when the compiled hook is absent, which is the case only when
13
+ * the SDK runs from its TypeScript source under the test runner. The runner
14
+ * resolves imports itself, so no hook is needed there.
15
+ */
16
+ export function useThisSdkForAuthoredSource() {
17
+ if (registered)
18
+ return;
19
+ registered = true;
20
+ const hook = new URL('./sdk-resolve-hook.js', import.meta.url);
21
+ if (!existsSync(fileURLToPath(hook)))
22
+ return;
23
+ register(hook);
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.13.0",
3
+ "version": "6.14.0",
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": "bf85d17e1d820f584329913c9ac836a2fbc23dec"
95
+ "gitref": "84bd49a28ffaae311bcb7b3207a311dfeaf1c08f"
96
96
  }