@michaelrwalker/stagehand 0.3.0 → 0.4.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 +193 -1
- package/dist/cache.d.ts +33 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +120 -0
- package/dist/cache.js.map +1 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +19 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/script.d.ts +130 -1
- package/dist/script.d.ts.map +1 -1
- package/dist/script.js +221 -14
- package/dist/script.js.map +1 -1
- package/dist/state.d.ts +6 -0
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +18 -1
- package/dist/state.js.map +1 -1
- package/dist/types.d.ts +99 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/frame.d.ts.map +1 -1
- package/dist/ui/frame.js +28 -7
- package/dist/ui/frame.js.map +1 -1
- package/dist/ui/renderer.d.ts.map +1 -1
- package/dist/ui/renderer.js +9 -6
- package/dist/ui/renderer.js.map +1 -1
- package/dist/ui/theme.d.ts +1 -0
- package/dist/ui/theme.d.ts.map +1 -1
- package/dist/ui/theme.js +2 -0
- package/dist/ui/theme.js.map +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -303,6 +303,85 @@ per placement.
|
|
|
303
303
|
`when` returning false marks the step **skipped** — its rollback never runs.
|
|
304
304
|
Phases accept `when` too, which skips all their steps.
|
|
305
305
|
|
|
306
|
+
## Caching
|
|
307
|
+
|
|
308
|
+
A phase or a step can reuse what it produced on an earlier run. Point it at a
|
|
309
|
+
store and it stops repeating work:
|
|
310
|
+
|
|
311
|
+
```ts
|
|
312
|
+
import { Script, fileStore } from "@michaelrwalker/stagehand";
|
|
313
|
+
|
|
314
|
+
const cache = fileStore("./.stagehand-cache.json");
|
|
315
|
+
|
|
316
|
+
new Script<Input>({ name: "deploy" })
|
|
317
|
+
.addPhase("Build", { cache })
|
|
318
|
+
.addStep({ name: "install", handler: … })
|
|
319
|
+
.addStep({ name: "compile", handler: … })
|
|
320
|
+
|
|
321
|
+
.addPhase("Release")
|
|
322
|
+
.addStep({ name: "warm CDN", cache, handler: … })
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
On a hit the work is skipped and the stored value is merged into the context —
|
|
326
|
+
downstream steps see the same keys, at the same types, either way.
|
|
327
|
+
|
|
328
|
+
**What gets stored.** A phase stores its **delta**: the keys its steps
|
|
329
|
+
contributed, minus anything they `clean`ed. Keys from earlier phases are never
|
|
330
|
+
part of it, so a hit can't overwrite a value this run just computed. A step
|
|
331
|
+
stores exactly what its handler returned.
|
|
332
|
+
|
|
333
|
+
**There is no key.** The store is the identity. Say when an entry stops being
|
|
334
|
+
good with `stale`, or delete the file:
|
|
335
|
+
|
|
336
|
+
```ts
|
|
337
|
+
.addPhase("Build", {
|
|
338
|
+
cache: {
|
|
339
|
+
store: cache,
|
|
340
|
+
stale: ({ value, ctx, ageMs }) => ageMs > 3_600_000 || value.sha !== ctx.sha,
|
|
341
|
+
schema: BuildSchema, // optional; a value that no longer fits is a miss
|
|
342
|
+
},
|
|
343
|
+
})
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
`stale` and `schema` both see the context as it stands when the phase is
|
|
347
|
+
reached, so `ctx` is typed with no annotation. `value` arrives as `unknown` —
|
|
348
|
+
annotate the parameter, or hand over a `schema` and let it narrow. A stored
|
|
349
|
+
value that fails its schema is treated as a **miss**, not an error, which is
|
|
350
|
+
what stops a cache written by an older version of the script from feeding the
|
|
351
|
+
wrong shape into the context.
|
|
352
|
+
|
|
353
|
+
**Rollback.** Cached work never ran, so its `rollback` can't fire during a
|
|
354
|
+
later unwind — the side effect belongs to the run that wrote the entry and was
|
|
355
|
+
never undone. For the same reason a failure downstream leaves entries alone.
|
|
356
|
+
|
|
357
|
+
**Per run**, without touching the script:
|
|
358
|
+
|
|
359
|
+
```ts
|
|
360
|
+
await deploy.run(input, { cache: argv.includes("--no-cache") ? "off" : "on" });
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
`"on"` (default) reads and writes · `"off"` ignores caching entirely ·
|
|
364
|
+
`"refresh"` runs everything and overwrites · `"read-only"` uses hits but never
|
|
365
|
+
writes.
|
|
366
|
+
|
|
367
|
+
**Stores** are three methods, so Redis or S3 is a dozen lines:
|
|
368
|
+
|
|
369
|
+
```ts
|
|
370
|
+
interface CacheStore {
|
|
371
|
+
read(slot: string): Awaitable<CachedEntry | undefined>;
|
|
372
|
+
write(slot: string, entry: CachedEntry): Awaitable<void>;
|
|
373
|
+
clear(slot: string): Awaitable<void>;
|
|
374
|
+
}
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
`slot` is derived from the phase or step name so several phases can share one
|
|
378
|
+
store; scripts never write it. `fileStore(path)` keeps every slot in one JSON
|
|
379
|
+
file — a missing, unreadable or corrupt file all read as no cache at all, so
|
|
380
|
+
deleting it is always a valid reset. `memoryStore()` lasts for the process.
|
|
381
|
+
|
|
382
|
+
A store that throws — unreadable file, full disk, a `stale` predicate with a bug
|
|
383
|
+
— logs a warning and does the work. Caching never decides whether a run passes.
|
|
384
|
+
|
|
306
385
|
## Script options
|
|
307
386
|
|
|
308
387
|
```ts
|
|
@@ -350,9 +429,119 @@ script has actually produced `Ctx` by that point. Dropping a step that needs
|
|
|
350
429
|
`{ user: User }` into a script that has not loaded a user yet is a compile
|
|
351
430
|
error, not a runtime `undefined`.
|
|
352
431
|
|
|
432
|
+
## Reusable scripts
|
|
433
|
+
|
|
434
|
+
`routineFor` does for whole phases what `stepFor` does for one step. Declare a
|
|
435
|
+
fragment once, mount it wherever it fits:
|
|
436
|
+
|
|
437
|
+
```ts
|
|
438
|
+
// routines/channel.ts
|
|
439
|
+
export const pullChannel = routineFor<{ channel: string; since: string }>()(
|
|
440
|
+
"pull channel",
|
|
441
|
+
(script) =>
|
|
442
|
+
script
|
|
443
|
+
.addPhase("Fetch", { cache: { store: cache, stale: … } })
|
|
444
|
+
.addStep({ name: "authenticate", handler: … })
|
|
445
|
+
.addStep({ name: "pull orders", handler: … })
|
|
446
|
+
.addPhase("Normalize")
|
|
447
|
+
.addStep({ name: "dedupe and total", handler: … }),
|
|
448
|
+
);
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
```ts
|
|
452
|
+
new Script<Input>({ name: "channel sync" })
|
|
453
|
+
.use(pullChannel)
|
|
454
|
+
.addPhase("Validation")
|
|
455
|
+
.addStep({ name: "check totals", handler: ({ ctx }) => … }) // ctx.orderCount, ctx.gross
|
|
456
|
+
|
|
457
|
+
// months later, a different job entirely
|
|
458
|
+
new Script<ReportInput>({ name: "monthly report" })
|
|
459
|
+
.use(pullChannel)
|
|
460
|
+
.addPhase("Report")
|
|
461
|
+
.addStep({ name: "build summary", handler: ({ ctx }) => … })
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
The two parameters on `routineFor<In, Ctx>()` are the **minimum** the fragment
|
|
465
|
+
needs — the input it reads, and the context it expects to already exist. Both
|
|
466
|
+
are checked at the `use()` call:
|
|
467
|
+
|
|
468
|
+
```
|
|
469
|
+
Property 'hash' is missing in type '{}' but required in type '{ hash: string; }'.
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
A plain `Script` mounts too, which is what keeps a pipeline runnable on its
|
|
473
|
+
own — `pipeline.run(input)` today, `.use(pipeline)` tomorrow. Its own
|
|
474
|
+
`ScriptOptions` (rollback mode, `logPlacement`, `silent`) are ignored in favour
|
|
475
|
+
of the host's; only its phases and steps come across.
|
|
476
|
+
|
|
477
|
+
**Everything travels with the fragment.** Phase-level `when` and `cache`,
|
|
478
|
+
step-level `retry`, `clean`, `rollback` — a spliced rollback compensates during
|
|
479
|
+
the host's unwind, and keys it reserved through `rollbackKeys` stay reserved in
|
|
480
|
+
the host, so a later `clean` there still can't delete them.
|
|
481
|
+
|
|
482
|
+
That combines well with caching: mount a routine whose phase caches, and the
|
|
483
|
+
second script to mount it gets the data the first one pulled.
|
|
484
|
+
|
|
485
|
+
```
|
|
486
|
+
› Fetch
|
|
487
|
+
⊙ authenticate cached
|
|
488
|
+
⊙ pull orders cached
|
|
489
|
+
› Report
|
|
490
|
+
✔ build summary (avg 24.50) 263ms
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
### Giving a mount its own input
|
|
494
|
+
|
|
495
|
+
A mount can feed its fragment something other than the host's input — which is
|
|
496
|
+
what lets one routine serve two storefronts, each with its own credentials:
|
|
497
|
+
|
|
498
|
+
```ts
|
|
499
|
+
new Script<{ since: string; amazonKey: string; shopifyKey: string }>({ name: "all channels" })
|
|
500
|
+
.use(pullChannel, {
|
|
501
|
+
as: "Amazon",
|
|
502
|
+
input: ({ input }) => ({ channel: "amazon", since: input.since, apiKey: input.amazonKey }),
|
|
503
|
+
})
|
|
504
|
+
.use(pullChannel, {
|
|
505
|
+
as: "Shopify",
|
|
506
|
+
input: ({ input }) => ({ channel: "shopify", since: input.since, apiKey: input.shopifyKey }),
|
|
507
|
+
})
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
`input` takes a fixed value or a function of `{ input, ctx }`, and may be
|
|
511
|
+
async. It is resolved **once per mount**, when the mount is reached, and every
|
|
512
|
+
phase and step of that fragment sees the result — including its `when`, its
|
|
513
|
+
`cache`, and its rollbacks during an unwind.
|
|
514
|
+
|
|
515
|
+
With a mapper the host no longer has to match the routine's input shape at all;
|
|
516
|
+
it only has to produce it. TypeScript checks the return value:
|
|
517
|
+
|
|
518
|
+
```
|
|
519
|
+
Property 'apiKey' is missing in type '{ channel: string; }' but required in type 'ChannelInput'.
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
Without one, the host's own input must satisfy the routine, as `stepFor` steps
|
|
523
|
+
require.
|
|
524
|
+
|
|
525
|
+
**Mounting twice** needs `as`, because phase names have to stay unique:
|
|
526
|
+
|
|
527
|
+
```ts
|
|
528
|
+
.use(pullChannel, { as: "Amazon" }) // → "Amazon / Fetch", "Amazon / Normalize"
|
|
529
|
+
.use(pullChannel, { as: "Shopify" })
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
Without it you get a `DuplicateNameError` at build time. That rule is not
|
|
533
|
+
routine-specific — two phases anywhere in a script, or two steps within one
|
|
534
|
+
phase, are refused. Names label the frame, are what `outline()` reports, and
|
|
535
|
+
identify a cache entry; two units sharing a name share a slot, which surfaces
|
|
536
|
+
as wrong data rather than as a failure.
|
|
537
|
+
|
|
538
|
+
A routine owns whole phases, so `addStep` directly after `use()` is refused
|
|
539
|
+
too — open a phase of your own first, rather than quietly appending to a
|
|
540
|
+
fragment someone else's script also mounts.
|
|
541
|
+
|
|
353
542
|
## Examples
|
|
354
543
|
|
|
355
|
-
|
|
544
|
+
Nine runnable scripts, each aimed at a different part of the API. Most take a
|
|
356
545
|
flag to switch between the happy path and the interesting one.
|
|
357
546
|
|
|
358
547
|
| | |
|
|
@@ -363,6 +552,8 @@ flag to switch between the happy path and the interesting one.
|
|
|
363
552
|
| [`intake.ts`](examples/intake.ts) | `defineInput` with a hand-rolled Standard Schema, plus the full handler UI surface. `-- --bad` to watch validation reject the run, `-- --dirty` for a failing checklist item |
|
|
364
553
|
| [`modular.ts`](examples/modular.ts) | `stepFor` steps living in [`steps/tenancy.ts`](examples/steps/tenancy.ts), shared by two unrelated scripts — the imported rollback compensates in both. `-- --fail` |
|
|
365
554
|
| [`log-placement.ts`](examples/log-placement.ts) | The same script run three times, once per `logPlacement` value, so the difference is visible directly |
|
|
555
|
+
| [`cache.ts`](examples/cache.ts) | A cached `Build` phase and a cached step. Run it twice to watch the second run skip both. `-- --fresh` to rebuild and overwrite |
|
|
556
|
+
| [`routine.ts`](examples/routine.ts) | One reusable fragment in [`routines/channel.ts`](examples/routines/channel.ts), mounted by a sync script and, months later, a report that maps its own input onto the routine's — and gets the pull from cache. `-- --multi` mounts it twice, one storefront and API key per mount |
|
|
366
557
|
| [`validate.ts`](examples/validate.ts) | The smallest thing that runs: two steps, `rollback: "none"` |
|
|
367
558
|
|
|
368
559
|
```
|
|
@@ -370,6 +561,7 @@ npm run example:checkout -- --ok
|
|
|
370
561
|
npm run example:resilience -- --cancel
|
|
371
562
|
npm run example:intake -- --bad
|
|
372
563
|
npm run example:modular -- --fail
|
|
564
|
+
npm run example:routine -- --multi
|
|
373
565
|
npm run example:log-placement
|
|
374
566
|
```
|
|
375
567
|
|
package/dist/cache.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CacheMode, CacheOptions, CacheSource, CacheStore } from "./types.js";
|
|
2
|
+
/** Lives for the lifetime of the process. Useful in tests, and for re-runs. */
|
|
3
|
+
export declare function memoryStore(): CacheStore;
|
|
4
|
+
/**
|
|
5
|
+
* One JSON file, holding every slot that points at it. Several phases may
|
|
6
|
+
* share a path safely.
|
|
7
|
+
*
|
|
8
|
+
* A missing, unreadable or malformed file all mean the same thing — no cache
|
|
9
|
+
* yet — so deleting the file is always a valid way to start over. Values must
|
|
10
|
+
* survive `JSON.stringify`; anything that does not (a `Date`, a class
|
|
11
|
+
* instance) comes back as its JSON shape, which is what `schema` is for.
|
|
12
|
+
*/
|
|
13
|
+
export declare function fileStore(filePath: string): CacheStore;
|
|
14
|
+
/** `cache: someStore` is shorthand for `cache: { store: someStore }`. */
|
|
15
|
+
export declare function normalizeCache(source: CacheSource | undefined): CacheOptions | undefined;
|
|
16
|
+
export type CacheLookup = {
|
|
17
|
+
hit: true;
|
|
18
|
+
value: unknown;
|
|
19
|
+
ageMs: number;
|
|
20
|
+
} | {
|
|
21
|
+
hit: false;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Read an entry and put it through every gate. A failure at any gate is a
|
|
25
|
+
* miss — the work runs and the entry is replaced — never an error.
|
|
26
|
+
*/
|
|
27
|
+
export declare function readCache(cache: CacheOptions, slot: string, input: unknown, ctx: unknown, mode: CacheMode): Promise<CacheLookup>;
|
|
28
|
+
/** Only ever called after the phase or step has fully succeeded. */
|
|
29
|
+
export declare function writeCache(cache: CacheOptions, slot: string, value: unknown, mode: CacheMode): Promise<void>;
|
|
30
|
+
/** Identifies a phase's entry. Steps hang off their phase to avoid collisions. */
|
|
31
|
+
export declare const phaseSlot: (phase: string) => string;
|
|
32
|
+
export declare const stepSlot: (phase: string, step: string) => string;
|
|
33
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,WAAW,EACX,UAAU,EAEX,MAAM,YAAY,CAAC;AAMpB,+EAA+E;AAC/E,wBAAgB,WAAW,IAAI,UAAU,CAWxC;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAuCtD;AAgBD,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAMxF;AAED,MAAM,MAAM,WAAW,GACnB;IAAE,GAAG,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,GAAG,EAAE,KAAK,CAAA;CAAE,CAAC;AAInB;;;GAGG;AACH,wBAAsB,SAAS,CAC7B,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,WAAW,CAAC,CAoBtB;AAED,oEAAoE;AACpE,wBAAsB,UAAU,CAC9B,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,IAAI,CAAC,CAGf;AAED,kFAAkF;AAClF,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,MAAe,CAAC;AAC1D,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,EAAE,MAAM,MAAM,KAAG,MAA6B,CAAC"}
|
package/dist/cache.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
/* -------------------------------------------------------------------------- */
|
|
4
|
+
/* Stores */
|
|
5
|
+
/* -------------------------------------------------------------------------- */
|
|
6
|
+
/** Lives for the lifetime of the process. Useful in tests, and for re-runs. */
|
|
7
|
+
export function memoryStore() {
|
|
8
|
+
const slots = new Map();
|
|
9
|
+
return {
|
|
10
|
+
read: (slot) => slots.get(slot),
|
|
11
|
+
write: (slot, entry) => {
|
|
12
|
+
slots.set(slot, entry);
|
|
13
|
+
},
|
|
14
|
+
clear: (slot) => {
|
|
15
|
+
slots.delete(slot);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* One JSON file, holding every slot that points at it. Several phases may
|
|
21
|
+
* share a path safely.
|
|
22
|
+
*
|
|
23
|
+
* A missing, unreadable or malformed file all mean the same thing — no cache
|
|
24
|
+
* yet — so deleting the file is always a valid way to start over. Values must
|
|
25
|
+
* survive `JSON.stringify`; anything that does not (a `Date`, a class
|
|
26
|
+
* instance) comes back as its JSON shape, which is what `schema` is for.
|
|
27
|
+
*/
|
|
28
|
+
export function fileStore(filePath) {
|
|
29
|
+
const target = resolve(filePath);
|
|
30
|
+
const readAll = async () => {
|
|
31
|
+
try {
|
|
32
|
+
const parsed = JSON.parse(await readFile(target, "utf8"));
|
|
33
|
+
if (parsed === null || typeof parsed !== "object")
|
|
34
|
+
return {};
|
|
35
|
+
return parsed;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
// Written through a temp file so an interrupted run cannot leave a
|
|
42
|
+
// half-serialised cache behind for the next one to choke on.
|
|
43
|
+
const writeAll = async (data) => {
|
|
44
|
+
await mkdir(dirname(target), { recursive: true });
|
|
45
|
+
const temp = `${target}.${process.pid}.tmp`;
|
|
46
|
+
await writeFile(temp, `${JSON.stringify(data, null, 2)}\n`, "utf8");
|
|
47
|
+
await rename(temp, target);
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
async read(slot) {
|
|
51
|
+
const entry = (await readAll())[slot];
|
|
52
|
+
return isEntry(entry) ? entry : undefined;
|
|
53
|
+
},
|
|
54
|
+
async write(slot, entry) {
|
|
55
|
+
const data = await readAll();
|
|
56
|
+
data[slot] = entry;
|
|
57
|
+
await writeAll(data);
|
|
58
|
+
},
|
|
59
|
+
async clear(slot) {
|
|
60
|
+
const data = await readAll();
|
|
61
|
+
if (!Object.hasOwn(data, slot))
|
|
62
|
+
return;
|
|
63
|
+
delete data[slot];
|
|
64
|
+
await writeAll(data);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** A hand-edited or older-format file should read as a miss, not as a crash. */
|
|
69
|
+
function isEntry(value) {
|
|
70
|
+
return (typeof value === "object" &&
|
|
71
|
+
value !== null &&
|
|
72
|
+
"value" in value &&
|
|
73
|
+
typeof value.savedAt === "number");
|
|
74
|
+
}
|
|
75
|
+
/* -------------------------------------------------------------------------- */
|
|
76
|
+
/* Runtime */
|
|
77
|
+
/* -------------------------------------------------------------------------- */
|
|
78
|
+
/** `cache: someStore` is shorthand for `cache: { store: someStore }`. */
|
|
79
|
+
export function normalizeCache(source) {
|
|
80
|
+
if (!source)
|
|
81
|
+
return undefined;
|
|
82
|
+
if (typeof source.read === "function") {
|
|
83
|
+
return { store: source };
|
|
84
|
+
}
|
|
85
|
+
return source;
|
|
86
|
+
}
|
|
87
|
+
const MISS = { hit: false };
|
|
88
|
+
/**
|
|
89
|
+
* Read an entry and put it through every gate. A failure at any gate is a
|
|
90
|
+
* miss — the work runs and the entry is replaced — never an error.
|
|
91
|
+
*/
|
|
92
|
+
export async function readCache(cache, slot, input, ctx, mode) {
|
|
93
|
+
if (mode === "off" || mode === "refresh")
|
|
94
|
+
return MISS;
|
|
95
|
+
const entry = await cache.store.read(slot);
|
|
96
|
+
if (!entry)
|
|
97
|
+
return MISS;
|
|
98
|
+
let value = entry.value;
|
|
99
|
+
if (cache.schema) {
|
|
100
|
+
const result = await cache.schema["~standard"].validate(value);
|
|
101
|
+
if (result.issues)
|
|
102
|
+
return MISS;
|
|
103
|
+
value = result.value;
|
|
104
|
+
}
|
|
105
|
+
const ageMs = Math.max(0, Date.now() - entry.savedAt);
|
|
106
|
+
if (cache.stale && (await cache.stale({ value, input, ctx, savedAt: entry.savedAt, ageMs }))) {
|
|
107
|
+
return MISS;
|
|
108
|
+
}
|
|
109
|
+
return { hit: true, value, ageMs };
|
|
110
|
+
}
|
|
111
|
+
/** Only ever called after the phase or step has fully succeeded. */
|
|
112
|
+
export async function writeCache(cache, slot, value, mode) {
|
|
113
|
+
if (mode === "off" || mode === "read-only")
|
|
114
|
+
return;
|
|
115
|
+
await cache.store.write(slot, { value, savedAt: Date.now() });
|
|
116
|
+
}
|
|
117
|
+
/** Identifies a phase's entry. Steps hang off their phase to avoid collisions. */
|
|
118
|
+
export const phaseSlot = (phase) => phase;
|
|
119
|
+
export const stepSlot = (phase, step) => `${phase}::${step}`;
|
|
120
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAU7C,gFAAgF;AAChF,iFAAiF;AACjF,gFAA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C;AACrC,CAAC;AAED,oEAAoE;AACpE,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,KAAmB,EACnB,IAAY,EACZ,KAAc,EACd,IAAe;IAEf,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,WAAW;QAAE,OAAO;IACnD,MAAM,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAChE,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC;AAC1D,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,IAAY,EAAU,EAAE,CAAC,GAAG,KAAK,KAAK,IAAI,EAAE,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -13,6 +13,20 @@ export declare class StepDefinitionError extends Error {
|
|
|
13
13
|
readonly step: string;
|
|
14
14
|
constructor(step: string, message: string);
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Two phases, or two steps within one phase, were given the same name. Thrown
|
|
18
|
+
* while the script is being built.
|
|
19
|
+
*
|
|
20
|
+
* Names are not decoration: they label the frame, they are what `outline()`
|
|
21
|
+
* reports, and they identify a phase's or step's cache entry. Two units
|
|
22
|
+
* sharing a name share a slot, which surfaces as wrong data rather than as a
|
|
23
|
+
* failure — so it is refused up front.
|
|
24
|
+
*/
|
|
25
|
+
export declare class DuplicateNameError extends Error {
|
|
26
|
+
readonly kind: "phase" | "step";
|
|
27
|
+
readonly duplicate: string;
|
|
28
|
+
constructor(kind: "phase" | "step", duplicate: string, message: string);
|
|
29
|
+
}
|
|
16
30
|
/** A step's handler threw. `cause` holds whatever it actually threw. */
|
|
17
31
|
export declare class StepFailedError extends Error {
|
|
18
32
|
readonly phase: string;
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|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Q,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAM5C;AAED,4EAA4E;AAC5E,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM;CAK3B;AAED,+EAA+E;AAC/E,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;gBAEpB,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO;CAOhF;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAK/C"}
|
package/dist/errors.js
CHANGED
|
@@ -27,6 +27,25 @@ export class StepDefinitionError extends Error {
|
|
|
27
27
|
this.step = step;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Two phases, or two steps within one phase, were given the same name. Thrown
|
|
32
|
+
* while the script is being built.
|
|
33
|
+
*
|
|
34
|
+
* Names are not decoration: they label the frame, they are what `outline()`
|
|
35
|
+
* reports, and they identify a phase's or step's cache entry. Two units
|
|
36
|
+
* sharing a name share a slot, which surfaces as wrong data rather than as a
|
|
37
|
+
* failure — so it is refused up front.
|
|
38
|
+
*/
|
|
39
|
+
export class DuplicateNameError extends Error {
|
|
40
|
+
kind;
|
|
41
|
+
duplicate;
|
|
42
|
+
constructor(kind, duplicate, message) {
|
|
43
|
+
super(message);
|
|
44
|
+
this.name = "DuplicateNameError";
|
|
45
|
+
this.kind = kind;
|
|
46
|
+
this.duplicate = duplicate;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
30
49
|
/** A step's handler threw. `cause` holds whatever it actually threw. */
|
|
31
50
|
export class StepFailedError extends Error {
|
|
32
51
|
phase;
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,oFAAoF;AACpF,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IACrC,MAAM,CAAwC;IAEvD,YAAY,MAA6C;QACvD,KAAK,CACH,MAAM;aACH,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACb,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI;gBACrB,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAChB,MAAM,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAChF;iBACA,IAAI,CAAC,GAAG,CAAC,CAAC;YACb,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;QAC5D,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CACd,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,wEAAwE;AACxE,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,KAAK,CAAS;IACd,IAAI,CAAS;IACb,QAA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c;QACxB,KAAK,CAAC,mBAAmB,MAAM,GAAG,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,+EAA+E;AAC/E,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,KAAK,CAAS;IACd,IAAI,CAAS;IACb,aAAa,CAAU;IAEhC,YAAY,KAAa,EAAE,IAAY,EAAE,aAAsB,EAAE,KAAc;QAC7E,KAAK,CAAC,iBAAiB,IAAI,eAAe,KAAK,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACtE,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;CACF;AAED,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,OAAO,CACL,KAAK,YAAY,kBAAkB;QACnC,CAAC,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC,CACxD,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { Script, script, stepFor, type RunOptions } from "./script.js";
|
|
2
|
-
export {
|
|
3
|
-
export
|
|
1
|
+
export { Script, script, stepFor, routineFor, type MountOptions, type Routine, type RunOptions, } from "./script.js";
|
|
2
|
+
export { fileStore, memoryStore } from "./cache.js";
|
|
3
|
+
export { DuplicateNameError, RollbackFailedError, SchemaValidationError, ScriptAbortedError, StepDefinitionError, StepFailedError, StepTimeoutError, isAbort, } from "./errors.js";
|
|
4
|
+
export type { Awaitable, CacheMode, CacheOptions, CacheSource, CacheStore, CachedEntry, CleanField, Cleaned, LogPlacement, Merge, PhaseOptions, PhaseStatus, Prettify, ProgressHandle, RetryPolicy, RollbackContext, RollbackData, RollbackReport, RunResult, RunStatus, ScriptOptions, StaleContext, StepContext, StepDef, StepReport, StepStatus, TaskHandle, TaskListHandle, } from "./types.js";
|
|
4
5
|
export { formatDuration } from "./state.js";
|
|
5
6
|
export { setColorEnabled, isColorEnabled } from "./ui/ansi.js";
|
|
6
7
|
export { palette, symbols } from "./ui/theme.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,OAAO,GACR,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,SAAS,EACT,SAAS,EACT,YAAY,EACZ,WAAW,EACX,UAAU,EACV,WAAW,EACX,UAAU,EACV,OAAO,EACP,YAAY,EACZ,KAAK,EACL,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,cAAc,EACd,WAAW,EACX,eAAe,EACf,YAAY,EACZ,cAAc,EACd,SAAS,EACT,SAAS,EACT,aAAa,EACb,YAAY,EACZ,WAAW,EACX,OAAO,EACP,UAAU,EACV,UAAU,EACV,UAAU,EACV,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { Script, script, stepFor } from "./script.js";
|
|
2
|
-
export {
|
|
1
|
+
export { Script, script, stepFor, routineFor, } from "./script.js";
|
|
2
|
+
export { fileStore, memoryStore } from "./cache.js";
|
|
3
|
+
export { DuplicateNameError, RollbackFailedError, SchemaValidationError, ScriptAbortedError, StepDefinitionError, StepFailedError, StepTimeoutError, isAbort, } from "./errors.js";
|
|
3
4
|
export { formatDuration } from "./state.js";
|
|
4
5
|
export { setColorEnabled, isColorEnabled } from "./ui/ansi.js";
|
|
5
6
|
export { palette, symbols } from "./ui/theme.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,UAAU,GAIX,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,OAAO,GACR,MAAM,aAAa,CAAC;AAiCrB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC"}
|