@antelopejs/dms 0.18.0 → 0.18.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +3 -3
  3. package/bin/control/backend-records.test.mjs +276 -0
  4. package/bin/control/backend.mjs +212 -0
  5. package/bin/control/backend.test.mjs +325 -0
  6. package/bin/control/base.mjs +3 -7
  7. package/bin/control/browser-client.mjs +6 -4
  8. package/bin/control/browser.mjs +173 -36
  9. package/bin/control/build-cache.mjs +394 -0
  10. package/bin/control/build-cache.test.mjs +270 -0
  11. package/bin/control/build-inputs.mjs +172 -0
  12. package/bin/control/build-key-refusals.test.mjs +138 -0
  13. package/bin/control/build-key.mjs +479 -0
  14. package/bin/control/build-key.test.mjs +392 -0
  15. package/bin/control/build-layout.test.mjs +314 -0
  16. package/bin/control/commands-stack.mjs +46 -6
  17. package/bin/control/commands-verify.mjs +9 -2
  18. package/bin/control/doctor.mjs +87 -16
  19. package/bin/control/forwarder.mjs +86 -0
  20. package/bin/control/forwarder.test.mjs +141 -0
  21. package/bin/control/frontend-check.mjs +54 -0
  22. package/bin/control/frontend-workspace.mjs +150 -0
  23. package/bin/control/frontend-workspace.test.mjs +133 -0
  24. package/bin/control/helpers/env.mjs +21 -0
  25. package/bin/control/helpers/evidence.mjs +13 -0
  26. package/bin/control/helpers/fake-run.mjs +290 -0
  27. package/bin/control/helpers/key-fixture.mjs +82 -0
  28. package/bin/control/helpers/pids.mjs +27 -0
  29. package/bin/control/helpers/repo.mjs +13 -0
  30. package/bin/control/helpers/tree.mjs +40 -0
  31. package/bin/control/identity.mjs +238 -0
  32. package/bin/control/identity.test.mjs +166 -0
  33. package/bin/control/journey.mjs +64 -16
  34. package/bin/control/journey.test.mjs +60 -2
  35. package/bin/control/namespaces.test.mjs +211 -0
  36. package/bin/control/options.mjs +2 -0
  37. package/bin/control/pid-guard.test.mjs +202 -0
  38. package/bin/control/prepared-workspace.mjs +20 -0
  39. package/bin/control/processes.mjs +122 -33
  40. package/bin/control/processes.test.mjs +255 -0
  41. package/bin/control/renderer.test.mjs +2 -1
  42. package/bin/control/run-copy.mjs +77 -0
  43. package/bin/control/run-state.mjs +142 -16
  44. package/bin/control/stack.mjs +259 -210
  45. package/bin/control/tab.mjs +13 -6
  46. package/bin/control/tab.test.mjs +444 -0
  47. package/bin/control/timing.mjs +244 -0
  48. package/bin/control/timing.test.mjs +197 -0
  49. package/bin/control/verify/decode.mjs +34 -21
  50. package/bin/control/verify/decode.test.mjs +39 -0
  51. package/bin/control/verify/doors.test.mjs +2 -0
  52. package/bin/control/verify/map.mjs +57 -7
  53. package/bin/control/verify/map.test.mjs +264 -0
  54. package/bin/control/verify/skill.mjs +12 -3
  55. package/bin/control/verify/types.mjs +2 -2
  56. package/bin/control/verify/verdict.mjs +37 -7
  57. package/bin/dms-control.mjs +14 -6
  58. package/frontend-vue/layers/dms-layout/app/components/layout/DashboardSearch.vue +24 -1
  59. package/package.json +1 -1
  60. package/skills/dms-project/SKILL.md +6 -3
@@ -0,0 +1,479 @@
1
+ import { createHash } from "node:crypto";
2
+ import {
3
+ existsSync,
4
+ lstatSync,
5
+ readdirSync,
6
+ readFileSync,
7
+ readlinkSync,
8
+ realpathSync,
9
+ } from "node:fs";
10
+ import { basename, dirname, isAbsolute, join, relative, sep } from "node:path";
11
+
12
+ /**
13
+ * @typedef {{ format: number, node: string, frontend: string, environment: string, env: string[], envFiles: string, sources: string, installed: string, outside: string }} BuildInputs Everything a frontend build reads, with the run's own values left out: the code of the dms-frontend that builds, the variables Vite bakes in, the project's `.env` files, the sources the workspace setup wrote, the versions its install resolved and the installs above the workspace a bare import can resolve from
14
+ * @typedef {Pick<import("./run-state.mjs").RunState, "environment" | "extraEnv" | "webUrl" | "bakedEnv">} KeyedRun The fields of a run its build inputs depend on
15
+ * @typedef {{ project: string, workspace: string, names: string[], installed: string }} PreparedWorkspace A workspace set up for a build: the project it was set up from, its folder, the entries the setup wrote there (see {@link sourceNames}) and the workspace whose install the build uses
16
+ * @typedef {ReadonlyMap<string, (content: Buffer) => Buffer>} Rewrites What a file is keyed as instead of its content, by path
17
+ * @typedef {{ rewrites: Rewrites, skipped: ReadonlySet<string>, links?: string[], installs?: string[] }} Walk How a folder is keyed: what its files are keyed as (see {@link Rewrites}), the entry names left out at every depth, and, for a package above the workspace, where to collect the links it holds and the `node_modules` folders it leaves out
18
+ * @typedef {{ linked: Map<string, string>, links: string[], installs: string[] }} Outside What keying the installs above a workspace read: the content hash of each linked folder by its real path, the links met inside a linked or copied package, and the `node_modules` folders of linked packages, which the key does not read file by file
19
+ */
20
+
21
+ const FORMAT = 5;
22
+ const BAKED_VARIABLE = /^(?:VITE_|NODE_ENV$)/u;
23
+ const MODULES_FOLDER = "node_modules";
24
+ const VIRTUAL_STORE = ".pnpm";
25
+ const LOCKFILE = "pnpm-lock.yaml";
26
+ const INSTALL_MARK = ".deps-hash";
27
+ const ENV_FILES = [".env.local", ".env"];
28
+ const FRONTEND_CODE = ["package.json", "dist", "templates"];
29
+ const RUN_VALUE_FILES = [
30
+ "dms-main.css",
31
+ "frontend-modules.generated.ts",
32
+ "generated-frontend-modules.json",
33
+ ];
34
+ const ESCAPE = "%";
35
+ const MODULES_RECORD = join(MODULES_FOLDER, ".modules.yaml");
36
+ const INSTALL_RECORDS = [
37
+ LOCKFILE,
38
+ join(MODULES_FOLDER, VIRTUAL_STORE, "lock.yaml"),
39
+ MODULES_RECORD,
40
+ ];
41
+ const LAYOUT_FIELDS = new Set([
42
+ "hoistPattern",
43
+ "hoistedDependencies",
44
+ "hoistedLocations",
45
+ "included",
46
+ "injectedDeps",
47
+ "layoutVersion",
48
+ "nodeLinker",
49
+ "publicHoistPattern",
50
+ "skipped",
51
+ "virtualStoreDir",
52
+ "virtualStoreDirMaxLength",
53
+ ]);
54
+ const TOP_LEVEL_FIELD = /^[^\s-]/u;
55
+ const FIELD_LINE = /^[A-Za-z][\w-]*:(?: |$)/u;
56
+
57
+ /** The folder `ajs dms build` builds in, in the project. */
58
+ export const WORKSPACE_FOLDER = ".dms-frontend";
59
+
60
+ /** @type {Walk} */
61
+ const SOURCES = { rewrites: new Map(), skipped: new Set([MODULES_FOLDER]) };
62
+ /** @type {Walk} */
63
+ const COPIED_PACKAGE = { rewrites: new Map(), skipped: new Set() };
64
+ /** @type {Walk} */
65
+ const LINKED_PACKAGE = {
66
+ rewrites: new Map(),
67
+ skipped: new Set([MODULES_FOLDER, ".git", ".antelope", WORKSPACE_FOLDER]),
68
+ };
69
+
70
+ /**
71
+ * @param {string} text
72
+ * @returns {string}
73
+ */
74
+ function escaped(text) {
75
+ return text.replaceAll(ESCAPE, `${ESCAPE}25`);
76
+ }
77
+
78
+ /**
79
+ * Replaces the run's web URL, where a file holds it as a whole
80
+ * double-quoted value, and the workspace folder, where a file holds it or a
81
+ * path under it as one, with placeholders. `%` is escaped first, so no text
82
+ * of the file reads as a placeholder.
83
+ *
84
+ * @param {string} webUrl The run's web URL
85
+ * @param {string[]} folders The workspace folder, as given and resolved
86
+ * @returns {(content: Buffer) => Buffer} The rewrite
87
+ */
88
+ function leavingOutRunValues(webUrl, folders) {
89
+ /** @type {Array<[string, string]>} */
90
+ const values = [
91
+ [JSON.stringify(webUrl), `"${ESCAPE}W"`],
92
+ ...folders.flatMap((folder) => {
93
+ const quoted = JSON.stringify(folder);
94
+ /** @type {Array<[string, string]>} */
95
+ const forms = [
96
+ [quoted, `"${ESCAPE}P"`],
97
+ [`${quoted.slice(0, -1)}/`, `"${ESCAPE}P/`],
98
+ ];
99
+ return forms;
100
+ }),
101
+ ];
102
+ const pairs = values.map(([from, to]) => [
103
+ escaped(Buffer.from(from).toString("latin1")),
104
+ to,
105
+ ]);
106
+ return (content) => {
107
+ let text = escaped(content.toString("latin1"));
108
+ for (const [from, to] of pairs) text = text.replaceAll(from, to);
109
+ return Buffer.from(text, "latin1");
110
+ };
111
+ }
112
+
113
+ /**
114
+ * @param {import("node:crypto").Hash} hash
115
+ * @param {string} path
116
+ * @param {Walk} walk
117
+ */
118
+ function hashEntry(hash, path, walk) {
119
+ const stat = lstatSync(path, { throwIfNoEntry: false });
120
+ if (!stat) {
121
+ hash.update("missing\0");
122
+ } else if (stat.isSymbolicLink()) {
123
+ walk.links?.push(path);
124
+ const link = Buffer.from(readlinkSync(path));
125
+ hash.update(`link ${link.length}\0`).update(link);
126
+ } else if (stat.isDirectory()) {
127
+ hash.update("folder\0");
128
+ hashNames(hash, path, readdirSync(path), walk);
129
+ hash.update("end\0");
130
+ } else {
131
+ const read = readFileSync(path);
132
+ const content = walk.rewrites.get(path)?.(read) ?? read;
133
+ hash.update(`file ${content.length}\0`).update(content);
134
+ }
135
+ }
136
+
137
+ /**
138
+ * @param {import("node:crypto").Hash} hash
139
+ * @param {string} folder
140
+ * @param {string[]} names
141
+ * @param {Walk} walk
142
+ */
143
+ function hashNames(hash, folder, names, walk) {
144
+ for (const name of [...names].sort()) {
145
+ if (walk.skipped.has(name)) {
146
+ if (name === MODULES_FOLDER) walk.installs?.push(join(folder, name));
147
+ continue;
148
+ }
149
+ hash.update(`${name}\0`);
150
+ hashEntry(hash, join(folder, name), walk);
151
+ }
152
+ }
153
+
154
+ /**
155
+ * @param {string} folder
156
+ * @param {string[]} names
157
+ * @param {Walk} [walk]
158
+ * @returns {string}
159
+ */
160
+ function hashFolder(folder, names, walk = SOURCES) {
161
+ const hash = createHash("sha256");
162
+ hashNames(hash, folder, names, walk);
163
+ return hash.digest("hex");
164
+ }
165
+
166
+ /**
167
+ * Keys an entry at the top of a `node_modules` above the workspace, or in a
168
+ * scope folder there. A scope folder is keyed entry by entry. A link is keyed
169
+ * by its target, and, when the target is not a package of pnpm's virtual
170
+ * store (a `link:` or `workspace:` package), by the content hash of the
171
+ * folder it resolves to, its installs left out, read once however many links
172
+ * reach it. A package copied in is keyed by its files, its own
173
+ * `node_modules` included.
174
+ *
175
+ * @param {import("node:crypto").Hash} hash
176
+ * @param {string} path The entry
177
+ * @param {Outside} outside What keying the installs above the workspace read so far
178
+ */
179
+ function hashInstalled(hash, path, outside) {
180
+ const stat = lstatSync(path, { throwIfNoEntry: false });
181
+ if (stat?.isDirectory() && basename(path).startsWith("@")) {
182
+ hash.update("scope\0");
183
+ for (const name of readdirSync(path).sort()) {
184
+ hash.update(`${name}\0`);
185
+ hashInstalled(hash, join(path, name), outside);
186
+ }
187
+ hash.update("end\0");
188
+ return;
189
+ }
190
+ if (!stat?.isSymbolicLink()) {
191
+ hashEntry(hash, path, { ...COPIED_PACKAGE, links: outside.links });
192
+ return;
193
+ }
194
+ hashEntry(hash, path, COPIED_PACKAGE);
195
+ if (!existsSync(path)) return;
196
+ const target = realpathSync(path);
197
+ if (inVirtualStore(target)) return;
198
+ let digest = outside.linked.get(target);
199
+ if (digest === undefined) {
200
+ const content = createHash("sha256");
201
+ hashEntry(content, target, { ...LINKED_PACKAGE, ...outside });
202
+ digest = content.digest("hex");
203
+ outside.linked.set(target, digest);
204
+ }
205
+ hash.update(`linked ${digest}\0`);
206
+ }
207
+
208
+ /**
209
+ * @param {string} path A real path
210
+ * @returns {boolean}
211
+ */
212
+ function inVirtualStore(path) {
213
+ return path.split(sep).includes(VIRTUAL_STORE);
214
+ }
215
+
216
+ /**
217
+ * The packages at the top of a `node_modules` and in its scope folders, dot
218
+ * entries such as `.bin` left out.
219
+ *
220
+ * @param {string} modules A `node_modules` folder
221
+ * @returns {string[]} Their paths
222
+ */
223
+ function packagesIn(modules) {
224
+ return readdirSync(modules)
225
+ .filter((name) => !name.startsWith("."))
226
+ .flatMap((name) => {
227
+ const path = join(modules, name);
228
+ return name.startsWith("@") && lstatSync(path).isDirectory()
229
+ ? readdirSync(path).map((scoped) => join(path, scoped))
230
+ : [path];
231
+ });
232
+ }
233
+
234
+ /**
235
+ * Whether the key reads what `target` holds: a package of pnpm's virtual
236
+ * store, which the install records cover, or a file or folder inside a
237
+ * linked folder the key hashed, outside the entries it leaves out there.
238
+ *
239
+ * @param {string} target A real path
240
+ * @param {Iterable<string>} linked The linked folders the key hashed
241
+ * @returns {boolean}
242
+ */
243
+ function isKeyed(target, linked) {
244
+ if (inVirtualStore(target)) return true;
245
+ for (const folder of linked) {
246
+ const inside = relative(folder, target);
247
+ if (isAbsolute(inside) || inside.split(sep)[0] === "..") continue;
248
+ if (!inside.split(sep).some((name) => LINKED_PACKAGE.skipped.has(name))) {
249
+ return true;
250
+ }
251
+ }
252
+ return false;
253
+ }
254
+
255
+ /**
256
+ * Refuses installs above the workspace that a build can resolve through
257
+ * while the key does not read them: a package copied by hand into the
258
+ * `node_modules` of a linked package, and a link, inside a linked or copied
259
+ * package or in a linked package's `node_modules`, to a folder the key does
260
+ * not hash (a workspace package linked only from inside a linked one, or a
261
+ * file outside every keyed package). A dangling link resolves nothing.
262
+ *
263
+ * @param {Outside} outside What keying the installs read
264
+ * @throws When the build can resolve through such an entry, naming it
265
+ */
266
+ function assertKeyed(outside) {
267
+ const links = [...outside.links];
268
+ for (const modules of outside.installs) {
269
+ for (const path of packagesIn(modules)) {
270
+ if (!lstatSync(path).isSymbolicLink()) {
271
+ throw new Error(
272
+ `${path} is a package copied into a linked package's node_modules, which the build cache does not key`,
273
+ );
274
+ }
275
+ links.push(path);
276
+ }
277
+ }
278
+ for (const link of links) {
279
+ if (!existsSync(link)) continue;
280
+ const target = realpathSync(link);
281
+ if (!isKeyed(target, outside.linked.keys())) {
282
+ throw new Error(
283
+ `${link} links to ${target}, which the build cache does not key`,
284
+ );
285
+ }
286
+ }
287
+ }
288
+
289
+ /**
290
+ * @param {string} folder
291
+ * @returns {string[]}
292
+ */
293
+ function upFrom(folder) {
294
+ const folders = [folder];
295
+ let current = folder;
296
+ while (dirname(current) !== current) {
297
+ current = dirname(current);
298
+ folders.push(current);
299
+ }
300
+ return folders;
301
+ }
302
+
303
+ /**
304
+ * The content of an install record the key reads. Of `.modules.yaml`, only
305
+ * the fields that say what pnpm linked where.
306
+ *
307
+ * @param {string} path The record
308
+ * @returns {string} What the key hashes
309
+ * @throws When `.modules.yaml` is not the YAML of top-level fields pnpm 10 writes (pnpm 12 writes JSON), since its layout fields could not be told apart
310
+ */
311
+ function installRecord(path) {
312
+ const content = readFileSync(path, "utf8");
313
+ if (!path.endsWith(MODULES_RECORD)) return content;
314
+ const lines = content.split("\n");
315
+ const unread = lines.findIndex(
316
+ (line) => TOP_LEVEL_FIELD.test(line) && !FIELD_LINE.test(line),
317
+ );
318
+ if (
319
+ unread !== -1 ||
320
+ !lines.some((line) => line.startsWith("layoutVersion:"))
321
+ ) {
322
+ throw new Error(
323
+ `${path} is not the YAML layout the build cache reads (${unread === -1 ? "no layoutVersion field" : `line ${unread + 1}`})`,
324
+ );
325
+ }
326
+ let layout = false;
327
+ return lines
328
+ .filter((line) => {
329
+ if (TOP_LEVEL_FIELD.test(line)) {
330
+ layout = LAYOUT_FIELDS.has(line.slice(0, line.indexOf(":")));
331
+ }
332
+ return layout;
333
+ })
334
+ .join("\n");
335
+ }
336
+
337
+ /**
338
+ * What the `node_modules` folders above a workspace hold, which its build
339
+ * resolves a bare import from when the workspace's own install lacks it.
340
+ * For each, nearest first: its top-level packages (see `hashInstalled`, dot
341
+ * entries such as `.cache` left out), then the pnpm install records
342
+ * (`pnpm-lock.yaml`, `node_modules/.pnpm/lock.yaml`, and the fields of
343
+ * `node_modules/.modules.yaml` that describe what pnpm linked where, not how
344
+ * or when it last installed) of the folder it resolves to and of every
345
+ * folder above that, and of each `node_modules` of a linked package.
346
+ *
347
+ * @param {string} workspace The workspace
348
+ * @returns {string} A sha256, in hex
349
+ * @throws When the build can resolve through an install the key does not read (see `assertKeyed`), or `.modules.yaml` cannot be read (see `installRecord`)
350
+ */
351
+ function hashOutsideInstalls(workspace) {
352
+ const hash = createHash("sha256");
353
+ /** @type {Outside} */
354
+ const outside = { linked: new Map(), links: [], installs: [] };
355
+ /** @type {string[]} */
356
+ const reached = [];
357
+ for (const folder of upFrom(dirname(workspace))) {
358
+ const modules = join(folder, MODULES_FOLDER);
359
+ if (!existsSync(modules)) continue;
360
+ reached.push(modules);
361
+ hash.update("modules\0");
362
+ for (const name of readdirSync(modules).sort()) {
363
+ if (name.startsWith(".")) continue;
364
+ hash.update(`${name}\0`);
365
+ hashInstalled(hash, join(modules, name), outside);
366
+ }
367
+ hash.update("end\0");
368
+ }
369
+ assertKeyed(outside);
370
+ /** @type {Map<string, string>} */
371
+ const records = new Map();
372
+ for (const modules of [...reached, ...outside.installs]) {
373
+ for (const owner of upFrom(dirname(realpathSync(modules)))) {
374
+ for (const name of INSTALL_RECORDS) {
375
+ const record = join(owner, name);
376
+ if (existsSync(record)) records.set(record, name);
377
+ }
378
+ }
379
+ }
380
+ for (const [record, name] of records) {
381
+ const content = installRecord(record);
382
+ hash.update(`${name} ${Buffer.byteLength(content)}\0`).update(content);
383
+ }
384
+ return hash.digest("hex");
385
+ }
386
+
387
+ /**
388
+ * The entries of a workspace other than its installed modules. Read right
389
+ * after its setup, they are the sources the setup wrote; a build adds its
390
+ * output beside them.
391
+ *
392
+ * @param {string} workspace The workspace
393
+ * @returns {string[]} The entries, sorted
394
+ */
395
+ export function sourceNames(workspace) {
396
+ return readdirSync(workspace)
397
+ .filter((name) => name !== MODULES_FOLDER)
398
+ .sort();
399
+ }
400
+
401
+ /**
402
+ * The variables of an environment that Vite bakes into a build: `VITE_*`
403
+ * and `NODE_ENV`.
404
+ *
405
+ * @param {NodeJS.ProcessEnv} env The environment
406
+ * @returns {Record<string, string>} The variables, by name
407
+ */
408
+ export function bakedVariables(env) {
409
+ /** @type {Array<[string, string]>} */
410
+ const baked = Object.entries(env).flatMap(([name, value]) =>
411
+ value !== undefined && BAKED_VARIABLE.test(name) ? [[name, value]] : [],
412
+ );
413
+ return Object.fromEntries(baked);
414
+ }
415
+
416
+ /**
417
+ * What a frontend build reads, with the run's own values left out: the
418
+ * sources the workspace setup wrote (the templates, each module's copied
419
+ * frontend and what the setup generated from the project's configuration),
420
+ * the versions the install resolved (`pnpm-lock.yaml`), the installs above
421
+ * the workspace (see `hashOutsideInstalls`), the project's `.env.local` and
422
+ * `.env`, the code of the dms-frontend that builds, the Node version, the
423
+ * environment, the `--env` pairs and the `VITE_*` and `NODE_ENV` variables
424
+ * the run recorded (`bakedEnv`). The files the setup writes the workspace's
425
+ * folder and the run's web URL into (the module registries and the CSS
426
+ * entry) are keyed with those values replaced, since `ajs dms start` serves
427
+ * the run's own in their place; every other source is keyed as it is.
428
+ *
429
+ * @param {KeyedRun} run The run
430
+ * @param {string} frontendPackage The `@antelopejs/dms-frontend` folder that builds
431
+ * @param {PreparedWorkspace} prepared The workspace, right after its setup
432
+ * @returns {BuildInputs} The inputs
433
+ * @throws When the build can resolve through an install above the workspace that the key does not read, such as a package copied into a linked package's `node_modules`, or a `.modules.yaml` it cannot read
434
+ */
435
+ export function buildInputs(run, frontendPackage, prepared) {
436
+ const { project, workspace, names, installed } = prepared;
437
+ const rewrite = leavingOutRunValues(run.webUrl, [
438
+ realpathSync(workspace),
439
+ workspace,
440
+ ]);
441
+ return {
442
+ format: FORMAT,
443
+ node: process.version,
444
+ frontend: hashFolder(realpathSync(frontendPackage), FRONTEND_CODE),
445
+ environment: run.environment,
446
+ env: [
447
+ ...Object.entries(run.bakedEnv ?? {}),
448
+ ...Object.entries(run.extraEnv).map(([name, value]) => [
449
+ `--env ${name}`,
450
+ value,
451
+ ]),
452
+ ]
453
+ .map(([name, value]) => `${name}=${value}`)
454
+ .sort(),
455
+ envFiles: hashFolder(project, ENV_FILES),
456
+ sources: hashFolder(
457
+ workspace,
458
+ names.filter((name) => name !== LOCKFILE && name !== INSTALL_MARK),
459
+ {
460
+ ...SOURCES,
461
+ rewrites: new Map(
462
+ RUN_VALUE_FILES.map((name) => [join(workspace, name), rewrite]),
463
+ ),
464
+ },
465
+ ),
466
+ installed: hashFolder(installed, [LOCKFILE]),
467
+ outside: hashOutsideInstalls(workspace),
468
+ };
469
+ }
470
+
471
+ /**
472
+ * The cache key of a build's inputs.
473
+ *
474
+ * @param {BuildInputs} inputs The inputs
475
+ * @returns {string} A sha256, in hex
476
+ */
477
+ export function buildKey(inputs) {
478
+ return createHash("sha256").update(JSON.stringify(inputs)).digest("hex");
479
+ }