@cnc-tools/storm 0.15.0 → 0.16.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.
Files changed (109) hide show
  1. package/dist/bin/storm.js +1 -1
  2. package/dist/build-info.js +1 -1
  3. package/dist/chunks/{chunk-QUHY6FGN.js → chunk-2MAD5NKK.js} +1 -1
  4. package/dist/chunks/{chunk-XEVHP5ZW.js → chunk-3L52KNQA.js} +1 -1
  5. package/dist/chunks/{chunk-E4PJNZVG.js → chunk-7EENF73W.js} +12 -13
  6. package/dist/chunks/{chunk-4U4DZ7VG.js → chunk-CK2GZEPK.js} +1 -1
  7. package/dist/chunks/{chunk-L36GBUBB.js → chunk-DC2CDHNK.js} +398 -158
  8. package/dist/chunks/{chunk-PN5ULTTH.js → chunk-DWEAHX4T.js} +1 -1
  9. package/dist/chunks/{chunk-5GBMR4HM.js → chunk-FCQUJDA4.js} +4 -7
  10. package/dist/chunks/{chunk-YV7GE6EV.js → chunk-FOZWA52V.js} +1 -1
  11. package/dist/chunks/{chunk-OX7X4B2L.js → chunk-G3PHMXH5.js} +1 -1
  12. package/dist/chunks/{chunk-CXAT7ZKP.js → chunk-HVNK3I45.js} +1 -1
  13. package/dist/chunks/{chunk-QVS7HRU7.js → chunk-OIY3DMF2.js} +2 -2
  14. package/dist/chunks/{chunk-SZEURWRS.js → chunk-P357TZAY.js} +2 -2
  15. package/dist/chunks/{chunk-KC4KDJ5K.js → chunk-V4IKA3WI.js} +153 -139
  16. package/dist/chunks/{chunk-RAQEXKL6.js → chunk-Z5PBVG3Y.js} +26 -18
  17. package/dist/chunks/{live-app-PI3BAN6Y.js → live-app-WECQOQ4C.js} +4 -4
  18. package/dist/commands/exec/across-sandboxes-outcomes.js +2 -1
  19. package/dist/commands/exec/command.d.ts +8 -2
  20. package/dist/commands/exec/command.js +11 -11
  21. package/dist/commands/exec/metadata.js +1 -1
  22. package/dist/commands/exec/outcomes.d.ts +4 -1
  23. package/dist/commands/exec/outcomes.js +2 -2
  24. package/dist/commands/exec/plan-only.js +1 -2
  25. package/dist/commands/exec/planned-outcome.js +8 -1
  26. package/dist/commands/exec/run-command.d.ts +6 -7
  27. package/dist/commands/exec/run-command.js +8 -9
  28. package/dist/commands/exec/run-metadata.js +1 -1
  29. package/dist/commands/runs/facts.d.ts +2 -1
  30. package/dist/commands/runs/facts.js +11 -3
  31. package/dist/commands/runs/list/command.d.ts +2 -0
  32. package/dist/commands/runs/list/command.js +6 -6
  33. package/dist/commands/runs/list/outcomes.d.ts +1 -0
  34. package/dist/commands/runs/logs/command.d.ts +6 -2
  35. package/dist/commands/runs/logs/command.js +6 -6
  36. package/dist/commands/runs/logs/outcomes.d.ts +3 -1
  37. package/dist/commands/runs/past-run.d.ts +14 -5
  38. package/dist/commands/runs/past-run.js +16 -5
  39. package/dist/commands/runs/show/command.d.ts +6 -2
  40. package/dist/commands/runs/show/command.js +9 -9
  41. package/dist/commands/runs/show/outcomes.d.ts +3 -1
  42. package/dist/commands/snapshots/build/command.js +11 -11
  43. package/dist/commands/snapshots/list/command.d.ts +3 -3
  44. package/dist/commands/snapshots/list/command.js +6 -6
  45. package/dist/commands/snapshots/list/metadata.js +1 -1
  46. package/dist/commands/suites/list/command.js +7 -6
  47. package/dist/commands/suites/list/outcomes.js +2 -2
  48. package/dist/commands/test/command.d.ts +8 -2
  49. package/dist/commands/test/command.js +38 -40
  50. package/dist/commands/test/metadata.js +1 -1
  51. package/dist/commands/test/outcomes.d.ts +4 -1
  52. package/dist/commands/test/outcomes.js +2 -2
  53. package/dist/commands/test/plan.d.ts +2 -2
  54. package/dist/commands/test/plan.js +2 -5
  55. package/dist/config/check-runner.d.ts +4 -2
  56. package/dist/config/check-runner.js +27 -2
  57. package/dist/config/check-suites.js +1 -0
  58. package/dist/config/gateways.d.ts +7 -3
  59. package/dist/config/index.d.ts +2 -3
  60. package/dist/config/index.js +2 -3
  61. package/dist/config/live/config-gateway.js +5 -2
  62. package/dist/config/load.d.ts +21 -4
  63. package/dist/config/load.js +129 -15
  64. package/dist/config/runner.d.ts +5 -6
  65. package/dist/config/runner.js +1 -1
  66. package/dist/config/schema.d.ts +15 -3
  67. package/dist/config/schema.js +10 -2
  68. package/dist/config/typed-options.d.ts +1 -6
  69. package/dist/config/typed-options.js +2 -10
  70. package/dist/config-file/define.d.ts +1 -11
  71. package/dist/config-file/define.js +3 -3
  72. package/dist/config-file/runner.d.ts +2 -3
  73. package/dist/config-file/toolchain.d.ts +13 -7
  74. package/dist/config-file/toolchain.js +51 -35
  75. package/dist/extensions/github/resource.d.ts +1 -1
  76. package/dist/extensions/github/resource.js +1 -1
  77. package/dist/extensions/testserver/commands/pool/create/command.js +1 -1
  78. package/dist/extensions/testserver/resource.d.ts +2 -2
  79. package/dist/extensions/testserver/resource.js +2 -2
  80. package/dist/planning/plan-only.d.ts +4 -1
  81. package/dist/planning/plan-only.js +5 -2
  82. package/dist/planning/run-plan.d.ts +1 -2
  83. package/dist/planning/test-plan.js +1 -2
  84. package/dist/runner/base.d.ts +0 -6
  85. package/dist/runner/base.js +0 -15
  86. package/dist/runner/build-snapshots.js +7 -8
  87. package/dist/runner/gateways.d.ts +5 -0
  88. package/dist/runner/index.d.ts +1 -1
  89. package/dist/runner/live/sandbox-gateway.js +12 -0
  90. package/dist/runner/prepare.d.ts +16 -15
  91. package/dist/runner/prepare.js +11 -12
  92. package/dist/runner/recipe.d.ts +66 -67
  93. package/dist/runner/recipe.js +204 -120
  94. package/dist/runner/snapshot-build.d.ts +1 -1
  95. package/dist/runner/snapshot-build.js +10 -3
  96. package/dist/runner/snapshot-inspect.d.ts +4 -4
  97. package/dist/runner/snapshot-inspect.js +7 -7
  98. package/dist/runner/snapshot-key.d.ts +23 -15
  99. package/dist/runner/snapshot-key.js +46 -27
  100. package/dist/sdk/extension/resource-definition.d.ts +3 -2
  101. package/dist/sdk/extension/resource-definition.js +3 -2
  102. package/dist/sdk/extension/resource-factory.js +3 -4
  103. package/dist/sdk/run/present.d.ts +3 -3
  104. package/dist/sdk/run/present.js +1 -3
  105. package/package.json +1 -1
  106. package/skills/overview.md +2 -0
  107. package/skills/plan-runs.md +1 -1
  108. package/dist/config/recipe-run.d.ts +0 -33
  109. package/dist/config/recipe-run.js +0 -28
@@ -1,16 +1,16 @@
1
1
  // What a runner snapshot is built from, and the scripts that commit a base in a build sandbox and a run's changes in
2
- // a runner sandbox. The snapshot key hashes the steps' text and the secret source identities the recipe's credentials
3
- // read, so editing a step means a new snapshot.
2
+ // a runner sandbox. The snapshot key hashes the declared base files' paths and contents, the steps' text, and the
3
+ // secret source identities the recipe's credentials read, so editing a step or a declared base file means a new
4
+ // snapshot.
4
5
  import { createHash } from "node:crypto";
5
- import { baseStepContext } from "./base.js";
6
- import { credentialSourceIds, resolveSteps } from "./recipe.js";
6
+ import { credentialSourceIds, declaredBaseFilePaths } from "./recipe.js";
7
7
  /**
8
8
  * Bump when a runner snapshot changes in a way its steps' text doesn't show (the scripts between the steps, what is
9
9
  * uploaded, the build sandbox), or the key's encoding changes, so earlier snapshots stop matching. 2 added each step's
10
10
  * runner secret names. 3 dropped dev snapshots. 4 replaced per-step runner secret names with the recipe's credential
11
- * source identities (`credentials=`).
11
+ * source identities (`credentials=`). 5 added declared base files' paths and contents (`baseFiles=`).
12
12
  */
13
- export const SNAPSHOT_FORMAT = 4;
13
+ export const SNAPSHOT_FORMAT = 5;
14
14
  /** Where the repository lives in every runner and build sandbox. */
15
15
  export const SANDBOX_ROOT = "/vercel/sandbox";
16
16
  /** The names of the files uploaded to a sandbox's staging directory. */
@@ -71,18 +71,23 @@ export function applyScript(staging, root = SANDBOX_ROOT) {
71
71
  }
72
72
  /**
73
73
  * The snapshot key: sha256 hex over `format=<SNAPSHOT_FORMAT>`, `credentials=<the secret source identities the recipe's
74
- * credentials read, sorted, once each, joined with ",">`, each toolchain step's label and script, the base-index script
75
- * with the placeholders `<base>` and `<staging>`, and each prebuild step's label and script, joined with NUL. A recipe
76
- * without credentials gives `credentials=`. Every snapshot step gets every credential, so the source identities are in
77
- * the key once, never the values, domains, or headers: a recipe that reads another source builds another snapshot, and
78
- * every machine with the same recipe shares one. The base isn't in the key: a cache entry records it beside the key.
74
+ * credentials read, sorted, once each, joined with ",">`, `baseFiles=<count>` followed by each sorted declared base
75
+ * file's path and text, each toolchain step's label and script, the base-index script with the placeholders `<base>`
76
+ * and `<staging>`, and each prebuild step's label and script, joined with NUL. A recipe without credentials gives
77
+ * `credentials=`, and one without declared base files gives `baseFiles=0`. Every snapshot step gets every credential,
78
+ * so the source identities are in the key once, never the values, domains, or headers: a recipe that reads another
79
+ * source builds another snapshot, and every machine with the same recipe shares one. The base isn't in the key: a
80
+ * cache entry records it beside the key.
79
81
  */
80
82
  export function snapshotKey(steps) {
81
83
  const text = (list) => list.flatMap(({ label, script }) => [label, script]);
84
+ const baseFiles = [...steps.baseFiles].toSorted((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
82
85
  return createHash("sha256")
83
86
  .update([
84
87
  `format=${SNAPSHOT_FORMAT}`,
85
88
  `credentials=${[...new Set(steps.credentials)].toSorted().join(",")}`,
89
+ `baseFiles=${baseFiles.length}`,
90
+ ...baseFiles.flatMap(({ path, text: content }) => [path, content]),
86
91
  ...text(steps.toolchains),
87
92
  baseIndexScript("<base>", "<staging>"),
88
93
  ...text(steps.prebuild),
@@ -90,26 +95,40 @@ export function snapshotKey(steps) {
90
95
  .digest("hex");
91
96
  }
92
97
  /**
93
- * Evaluates `recipe`'s toolchain and prebuild steps at `base`, and computes their snapshot key with the secret source
94
- * identities the recipe's credentials read.
98
+ * Reads `recipe`'s declared base files at `base` and computes its snapshot key with the secret source identities the
99
+ * recipe's credentials read. Fails with `path: ["snapshot", "toolchains"]` if any declared base file is missing or
100
+ * unreadable at `base`.
95
101
  */
96
- export async function snapshotStepsAt(checkout, request) {
97
- const context = baseStepContext(checkout, request);
98
- const { snapshot } = request.recipe;
99
- const toolchains = await resolveSteps(snapshot.toolchains, context);
100
- if (!toolchains.ok)
101
- return { ok: false, path: ["snapshot", "toolchains"], problem: toolchains.problem };
102
- const prebuild = await resolveSteps(snapshot.prebuild, context);
103
- if (!prebuild.ok)
104
- return { ok: false, path: ["snapshot", "prebuild"], problem: prebuild.problem };
102
+ export async function snapshotInputsAt(checkout, request) {
103
+ const { repoRoot, base, recipe } = request;
104
+ const { snapshot } = recipe;
105
+ const baseFiles = [];
106
+ for (const path of declaredBaseFilePaths(snapshot.toolchains)) {
107
+ const file = await checkout.readFileAt({ repoRoot, commit: base, path });
108
+ if (file.kind === "missing") {
109
+ return {
110
+ ok: false,
111
+ path: ["snapshot", "toolchains"],
112
+ problem: `declared base file "${path}" doesn't exist at base ${base.slice(0, 12)}`,
113
+ };
114
+ }
115
+ if (file.kind === "failed") {
116
+ return {
117
+ ok: false,
118
+ path: ["snapshot", "toolchains"],
119
+ problem: `can't read declared base file "${path}" at base ${base.slice(0, 12)}: ${file.failure.message}`,
120
+ };
121
+ }
122
+ baseFiles.push({ path, text: file.text });
123
+ }
105
124
  return {
106
125
  ok: true,
107
- toolchains: toolchains.steps,
108
- prebuild: prebuild.steps,
126
+ baseFiles,
109
127
  key: snapshotKey({
110
- credentials: credentialSourceIds(request.recipe),
111
- toolchains: toolchains.steps,
112
- prebuild: prebuild.steps,
128
+ credentials: credentialSourceIds(recipe),
129
+ baseFiles,
130
+ toolchains: snapshot.toolchains,
131
+ prebuild: snapshot.prebuild,
113
132
  }),
114
133
  };
115
134
  }
@@ -195,8 +195,9 @@ export type PayloadOf<D extends ResourceDefinition> = D["payload"] extends Paylo
195
195
  export type SourcesOf<D extends ResourceDefinition> = OptionSources<D["options"]>;
196
196
  /**
197
197
  * The key of definition `definition`'s default resource under `resources`: its name. A run's own flags for the
198
- * definition's options set this resource, and a read that names no key, such as a runner recipe's `run.get(<name>)`,
199
- * reads it. For now a config file may hold only default resources (`defineConfig` and `loadConfig` check each key).
198
+ * definition's options set this resource, and a read that names no key, such as a command's
199
+ * `readRunPayload().get(contract)`, reads it. For now a config file may hold only default resources (`defineConfig`
200
+ * and `loadConfig` check each key).
200
201
  */
201
202
  export declare function defaultResourceKey(definition: {
202
203
  readonly name: string;
@@ -13,8 +13,9 @@ export const NOT_COUNTED = Object.freeze({
13
13
  });
14
14
  /**
15
15
  * The key of definition `definition`'s default resource under `resources`: its name. A run's own flags for the
16
- * definition's options set this resource, and a read that names no key, such as a runner recipe's `run.get(<name>)`,
17
- * reads it. For now a config file may hold only default resources (`defineConfig` and `loadConfig` check each key).
16
+ * definition's options set this resource, and a read that names no key, such as a command's
17
+ * `readRunPayload().get(contract)`, reads it. For now a config file may hold only default resources (`defineConfig`
18
+ * and `loadConfig` check each key).
18
19
  */
19
20
  export function defaultResourceKey(definition) {
20
21
  return definition.name;
@@ -1,9 +1,8 @@
1
1
  // A resource factory (`GLOSSARY.md`, **Resource factory**): what a config file calls to make a resource
2
2
  // (`<name>({ … })`). Each extension folder's `resource.ts`, its published export, makes its factory from its definition
3
- // with `resourceFactory`. The factory holds its definition, which a runner recipe reads a resource by
4
- // (`run.get(<name>)`, `config/recipe-run.ts`). A list of definitions holds definitions, not factories: a
5
- // factory's call signature checks its options contravariantly, so a definition with a required option wouldn't fit a
6
- // list of factories. It names no resource.
3
+ // with `resourceFactory`. The factory holds its definition (`definition`). A list of definitions holds definitions, not
4
+ // factories: a factory's call signature checks its options contravariantly, so a definition with a required option
5
+ // wouldn't fit a list of factories. It names no resource.
7
6
  /** The resource factory of `definition`: what a config file calls to make a resource of it. */
8
7
  export function resourceFactory(definition) {
9
8
  const make = (given = {}) => ({
@@ -1,7 +1,7 @@
1
1
  /**
2
- * A resource read by its resource factory or its payload contract: `present: true` with `value`, what the reader gets
3
- * of it, when the run has the resource; `present: false` when the run doesn't, such as a run whose config file and
4
- * flags give it nothing, or whose `beforeRun` skipped it.
2
+ * A resource read by its payload contract: `present: true` with `value`, what the reader gets of it, when the run has
3
+ * the resource; `present: false` when the run doesn't, such as a run whose config file and flags give it nothing, or
4
+ * whose `beforeRun` skipped it.
5
5
  */
6
6
  export type Present<T> = {
7
7
  readonly present: true;
@@ -1,4 +1,2 @@
1
- // Whether a run has a resource, and what of it the reader gets when it does. A runner recipe's `vcpus` function
2
- // reads a resource's options by its resource factory, `run.get(<name>)`, which returns one; it lives in the SDK, which
3
- // imports nothing outside `src/sdk/`, so the run payload's reads can return it too.
1
+ // Whether a run has a resource, and what of it the reader gets when it does. A command's run payload reads return one.
4
2
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cnc-tools/storm",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "A test orchestrator: run your tests in the inner loop of development, in the cloud, in a test environment that you define",
5
5
  "repository": {
6
6
  "type": "git",
@@ -7,6 +7,8 @@ description: Start here. What a run, a run id, a run directory, test output, and
7
7
 
8
8
  `storm test` runs the project's tests declared in `storm.config.ts`, or a named suite with `--suite <name>`, in a runner sandbox or on this machine. When `storm.config.ts` sets `testPlan: true` or the command takes `--count-tests`, it first counts the test files (or each test) on this machine, and a resource can size itself from that count. `storm exec` runs any other command, such as `pnpm test`, in the same way, without counting tests. After the run, the `runs` commands read the run back on this machine.
9
9
 
10
+ storm finds `storm.config.ts` in the working directory or the nearest parent up to the git worktree's root. It also takes `storm.config.mts`, which Node always loads as an ES module: use it in a package whose `package.json` has no `"type": "module"`, where Node warns `MODULE_TYPELESS_PACKAGE_JSON` for a `storm.config.ts`. One directory may hold only one of the two, else every command that reads the file refuses with `invalid_config`. This text names the file `storm.config.ts`.
11
+
10
12
  ## Concepts
11
13
 
12
14
  - A **run** is one `storm test` or one `storm exec`. It runs one command: the driver's program with arguments from the command line and `storm.config.ts` for `storm test`, or the command after `--` for `storm exec`.
@@ -20,7 +20,7 @@ The parts are:
20
20
  2. storm loads `storm.config.ts`, does the local checks, and lists the test files on this machine. It mints nothing, acquires no resource, starts no sandbox, and opens no run directory. It does not need a credential. It exits 0.
21
21
  3. Read the result. Its `outcome` is `planned`. Read these fields:
22
22
  - `testFiles`: the test files of the run, as paths relative to the project. Use these paths in your lists. It is `null` when the run lists no test files: a `storm exec` run, or a run that is not across runner sandboxes and counts nothing. Add `--sandboxes 1` to list them.
23
- - `runnerSandboxes`: `sandboxes` in the run's `vercelSandbox({ … })` runner (`runner.sandboxes`), the suite's laid over the top level's. `max` is the most runner sandboxes a run can have. `default` is the number of runner sandboxes of a `storm test` run with no `--sandboxes` and no `--file-lists`: a number, `"function"` when `storm.config.ts` gives a function of the test plan, or `null` when it gives no default. `runnerSandboxes` is `null` when the runner has no `sandboxes`, or is `launchMachine()`. Then no run can be a run across runner sandboxes.
23
+ - `runnerSandboxes`: `sandboxes` in the run's `vercelSandbox({ … })` runner (`runner.sandboxes`), the suite's laid over the top level's. `max` is the most runner sandboxes a run can have. `default` is the number of runner sandboxes of a `storm test` run with no `--sandboxes` and no `--file-lists`: a number, a `{ filesPerSandbox, max? }` rule object when `storm.config.ts` declares one, or `null` when it gives no default. `runnerSandboxes` is `null` when the runner has no `sandboxes`, or is `launchMachine()`. Then no run can be a run across runner sandboxes.
24
24
  - `plan.sandboxes`: the number of runner sandboxes (`count`), where it came from (`from`: `flag` for `--sandboxes`, `file-lists` for `--file-lists`, `default` for `runner.sandboxes.default`), and its max (`max`). For `default`, `default` is the number that the default gave for this run. When that number is more than `max`, the run has `max` runner sandboxes. `requested` is the number asked for when the run has fewer test files than that. `leftOut` is the number of test files that your lists leave out.
25
25
  - `sandboxes`: one item for each runner sandbox, with `sandbox` (the runner sandbox index, from 0), `argv` (the command of the runner sandbox, unchanged across runner sandboxes for `storm test`), and `files` (its file list, delivered in `STORM_RUN.sandbox.files`, or `null` for `storm exec`).
26
26
  - `options`: each option of each resource, with its `value` and where the value came from (`from`: `flag`, `file`, or `default`). With `--sandboxes` or `--file-lists`, a default is the total for the whole run with that number of runner sandboxes, and each runner sandbox gets its own part of the resource.
@@ -1,33 +0,0 @@
1
- import type { VcpusRun } from "../runner/recipe.ts";
2
- import type { Present } from "../sdk/run/launcher.ts";
3
- import { type OptionsOf, type ResourceDefinition, type ResourceFactory } from "../sdk/extension/index.ts";
4
- /** The run, as a runner recipe's `vcpus` function sees it. */
5
- export interface RecipeRun {
6
- /**
7
- * The default resource of the resource factory `factory`'s definition (`run.get(<name>)`), the resource keyed by
8
- * the definition's name: `present: true` with its options, the plain values once its defaults (a function default's
9
- * value included), the file and the flags are merged, when the run has it, and `present: false` when the run
10
- * doesn't, such as a resource nothing gives or whose `beforeRun` skipped it.
11
- */
12
- get<D extends ResourceDefinition>(factory: ResourceFactory<D>): Present<OptionsOf<D>>;
13
- /**
14
- * The run's number of runner sandboxes: 1 unless the run is across runner sandboxes. storm calls the function once
15
- * for the run, and every runner sandbox has the size it gives, while a resource's option, such as a count of what the
16
- * resource provides, is the run's total. So a recipe that sizes the runner sandbox from such an option divides it by
17
- * this: `Math.ceil(count / run.sandboxes)`.
18
- */
19
- readonly sandboxes: number;
20
- }
21
- /** One of the run's resources, as a recipe's `vcpus` function reads it: its definition's name and its options. */
22
- export interface RecipeResource {
23
- readonly definition: string;
24
- readonly options: object;
25
- }
26
- /**
27
- * The run a recipe's `vcpus` function is called with, for a run with `resources`, each by its resource key, in order,
28
- * and the resource keys a problem with the function names. Each value `get` returns is a frozen copy, so a function
29
- * can't change the run's resources.
30
- */
31
- export declare function recipeRun(resources: {
32
- readonly [key: string]: RecipeResource;
33
- }, sandboxes?: number): VcpusRun<RecipeRun>;
@@ -1,28 +0,0 @@
1
- // What a runner recipe's `vcpus` function is called with: the run, which reads each of its resources by its resource
2
- // factory, `run.get(<name>)`, the factory's definition's default resource. The runner module calls the
3
- // function and names no resource or definition, so it takes the run as a type parameter; this module declares the run,
4
- // since it knows the definitions.
5
- import { defaultResourceKey, } from "../sdk/extension/index.js";
6
- import { resourceOptionsOf } from "./typed-options.js";
7
- const NOT_PRESENT = Object.freeze({ present: false });
8
- /**
9
- * The run a recipe's `vcpus` function is called with, for a run with `resources`, each by its resource key, in order,
10
- * and the resource keys a problem with the function names. Each value `get` returns is a frozen copy, so a function
11
- * can't change the run's resources.
12
- */
13
- export function recipeRun(resources, sandboxes = 1) {
14
- const run = {
15
- sandboxes,
16
- get: ({ definition }) => {
17
- const key = defaultResourceKey(definition);
18
- const resource = Object.hasOwn(resources, key) ? resources[key] : undefined;
19
- if (resource === undefined || resource.definition !== definition.name)
20
- return NOT_PRESENT;
21
- return Object.freeze({
22
- present: true,
23
- value: resourceOptionsOf(definition, Object.freeze({ ...resource.options })),
24
- });
25
- },
26
- };
27
- return { run: Object.freeze(run), resourceKeys: Object.keys(resources) };
28
- }