@uipath/maestro-builder-sdk 6.96.3 → 6.96.4

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.
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Every module the extractor and the generators load, as absolute paths,
3
+ * sorted: what {@link generatorIdentity} hashes. Exported so a test can check
4
+ * the walk reaches every generator module; a module it missed would drop out of
5
+ * the hash without any error.
6
+ *
7
+ * @param here - The URL to resolve the entry modules against.
8
+ */
9
+ export declare function generatorModules(here?: string): Promise<string[]>;
10
+ /**
11
+ * The sha256 of every module the extractor and the generators load.
12
+ *
13
+ * @param here - The URL to resolve the entry modules against; a parameter so
14
+ * tests can point it at a tree of their own.
15
+ */
16
+ export declare function generatorIdentity(here?: string): Promise<string>;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Identity of the code that turns a connector archive into the cached library.
3
+ *
4
+ * `registry pull` keys its cache on the archive and the curated overlay, and
5
+ * reuses an entry whose key matches. The extracted JSON and the generated
6
+ * Markdown are also a function of the extractor and the generators, so an SDK
7
+ * release that changes either would keep serving the old output under the same
8
+ * key, and `--force` was the only way out. This hashes that code, as it runs, so
9
+ * a changed generator gets a new cache entry.
10
+ *
11
+ * The code is found by following the relative imports of the two entry modules
12
+ * (`extractor`, `materializer`), file by file, and hashing each file reached
13
+ * with its path. Running from source, a `.js` specifier is read as the `.ts`
14
+ * beside it. Inside a bundle the entry modules are not separate files, so the
15
+ * bundle itself is hashed: any change to it then counts, which costs an
16
+ * unneeded regeneration but never serves stale output.
17
+ */
18
+ import { createHash } from "node:crypto";
19
+ import { readFile, stat } from "node:fs/promises";
20
+ import { dirname, relative, resolve } from "node:path";
21
+ import { fileURLToPath } from "node:url";
22
+ /** The modules whose output the cache holds: extraction and generation. */
23
+ const ENTRY_MODULES = ["./extractor.js", "./materializer.js"];
24
+ /** A static or dynamic import, or a re-export, of a relative specifier. */
25
+ const RELATIVE_IMPORT_RE = /(?:\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)["'](\.{1,2}\/[^"']+)["']/g;
26
+ async function isFileAsync(path) {
27
+ try {
28
+ return (await stat(path)).isFile();
29
+ }
30
+ catch {
31
+ return false;
32
+ }
33
+ }
34
+ /** The file a specifier names, or its `.ts` source when running from source. */
35
+ async function moduleFile(path) {
36
+ if (await isFileAsync(path))
37
+ return path;
38
+ const source = path.replace(/\.js$/, ".ts");
39
+ return source !== path && (await isFileAsync(source)) ? source : undefined;
40
+ }
41
+ /**
42
+ * Every module the extractor and the generators load, as absolute paths,
43
+ * sorted: what {@link generatorIdentity} hashes. Exported so a test can check
44
+ * the walk reaches every generator module; a module it missed would drop out of
45
+ * the hash without any error.
46
+ *
47
+ * @param here - The URL to resolve the entry modules against.
48
+ */
49
+ export async function generatorModules(here = import.meta.url) {
50
+ const self = fileURLToPath(here);
51
+ const root = dirname(self);
52
+ const pending = [];
53
+ for (const specifier of ENTRY_MODULES) {
54
+ const file = await moduleFile(resolve(root, specifier));
55
+ if (file !== undefined)
56
+ pending.push(file);
57
+ }
58
+ // Bundled: the entry modules are inside this file, so it is the code.
59
+ if (pending.length === 0)
60
+ pending.push(self);
61
+ const seen = new Set();
62
+ while (pending.length > 0) {
63
+ const file = pending.pop();
64
+ if (seen.has(file))
65
+ continue;
66
+ seen.add(file);
67
+ const text = await readFile(file, "utf8");
68
+ for (const match of text.matchAll(RELATIVE_IMPORT_RE)) {
69
+ const next = await moduleFile(resolve(dirname(file), match[1]));
70
+ if (next !== undefined && !seen.has(next))
71
+ pending.push(next);
72
+ }
73
+ }
74
+ return [...seen].sort();
75
+ }
76
+ /**
77
+ * The sha256 of every module the extractor and the generators load.
78
+ *
79
+ * @param here - The URL to resolve the entry modules against; a parameter so
80
+ * tests can point it at a tree of their own.
81
+ */
82
+ export async function generatorIdentity(here = import.meta.url) {
83
+ const root = dirname(fileURLToPath(here));
84
+ const hash = createHash("sha256");
85
+ for (const file of await generatorModules(here)) {
86
+ hash.update(relative(root, file));
87
+ hash.update("\0");
88
+ hash.update(await readFile(file));
89
+ hash.update("\0");
90
+ }
91
+ return hash.digest("hex");
92
+ }
@@ -7,6 +7,7 @@ import { CURRENT_LINK, LIBRARY_JSON_DIR, LIBRARY_MARKDOWN_DIR, cacheEntry, libra
7
7
  import { extractLibrary } from "./extractor.js";
8
8
  import { materializeRegistry } from "./materializer.js";
9
9
  import { curatedOverlayIdentity } from "./curated-overlay.js";
10
+ import { generatorIdentity } from "./generator-identity.js";
10
11
  import { WORK_DIR, workPath } from "../workdir.js";
11
12
  /**
12
13
  * Fetch the published connector library into the shared cache, and generate the
@@ -191,12 +192,17 @@ async function archiveIdentity(archive) {
191
192
  return archive.checksum;
192
193
  return createHash("sha256").update(await readFile(archive.path)).digest("hex");
193
194
  }
194
- /** The extracted library is a function of both the dump and SDK corrections. */
195
- function libraryIdentity(archiveSha256, overlaySha256) {
195
+ /**
196
+ * The extracted library and its Markdown are a function of the dump, the SDK's
197
+ * corrections, and the SDK code that extracts and generates them.
198
+ */
199
+ function libraryIdentity(archiveSha256, overlaySha256, generatorSha256) {
196
200
  return createHash("sha256")
197
201
  .update(archiveSha256)
198
202
  .update("\0")
199
203
  .update(overlaySha256)
204
+ .update("\0")
205
+ .update(generatorSha256)
200
206
  .digest("hex");
201
207
  }
202
208
  async function isCurrentLibrary(libraryPath, sha256) {
@@ -210,11 +216,12 @@ async function isCurrentLibrary(libraryPath, sha256) {
210
216
  return false;
211
217
  }
212
218
  }
213
- async function writeSource(libraryPath, archive, sha256, archiveSha256, overlaySha256) {
219
+ async function writeSource(libraryPath, archive, sha256, archiveSha256, overlaySha256, generatorSha256) {
214
220
  writeJsonFile(join(libraryPath, SOURCE_FILE), {
215
221
  sha256,
216
222
  archiveSha256,
217
223
  overlaySha256,
224
+ generatorSha256,
218
225
  url: archive.url ?? null,
219
226
  archive: archive.checksum ? undefined : archive.path,
220
227
  pulledAt: new Date().toISOString(),
@@ -317,7 +324,8 @@ export async function run(argv) {
317
324
  const archive = await resolveArchive(argv, cacheDir, force);
318
325
  const archiveSha256 = await archiveIdentity(archive);
319
326
  const overlaySha256 = await curatedOverlayIdentity();
320
- const sha256 = libraryIdentity(archiveSha256, overlaySha256);
327
+ const generatorSha256 = await generatorIdentity();
328
+ const sha256 = libraryIdentity(archiveSha256, overlaySha256, generatorSha256);
321
329
  const entry = cacheEntry(sha256, cacheDir);
322
330
  // Destination overrides: a caller can still put the trees somewhere of their
323
331
  // own choosing instead of in the cache.
@@ -340,7 +348,7 @@ export async function run(argv) {
340
348
  await rm(libraryPath, { recursive: true, force: true });
341
349
  await mkdir(join(libraryPath, ".."), { recursive: true });
342
350
  await rename(staging, libraryPath);
343
- await writeSource(libraryPath, archive, sha256, archiveSha256, overlaySha256);
351
+ await writeSource(libraryPath, archive, sha256, archiveSha256, overlaySha256, generatorSha256);
344
352
  }
345
353
  // Which descriptors this project will actually import. Generating all 30
346
354
  // costs 1.1 MB in someone's repository for operations they never call.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.96.3",
3
+ "version": "6.96.4",
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",
@@ -113,5 +113,5 @@
113
113
  "@types/node": "^22.7.0",
114
114
  "esbuild": "^0.28.1"
115
115
  },
116
- "gitref": "d97600fbb95a5ab3e1a4332daee538e99ae6aed9"
116
+ "gitref": "0439ae5d0fdb447fb350759a56d3ffd7f8c859dd"
117
117
  }