@cnc-tools/storm 0.7.0 → 0.8.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 (120) hide show
  1. package/dist/build-info.js +1 -1
  2. package/dist/commands/exec/cleanup.d.ts +3 -3
  3. package/dist/commands/exec/cleanup.js +1 -1
  4. package/dist/commands/exec/command.d.ts +771 -1
  5. package/dist/commands/exec/command.js +1 -1
  6. package/dist/commands/exec/live-view.js +3 -2
  7. package/dist/commands/exec/metadata.d.ts +1 -1
  8. package/dist/commands/exec/metadata.js +4 -0
  9. package/dist/commands/exec/mint-failed.d.ts +28 -0
  10. package/dist/commands/exec/outcomes.d.ts +476 -0
  11. package/dist/commands/exec/progress.js +3 -5
  12. package/dist/commands/exec/run-command.d.ts +2 -2
  13. package/dist/commands/exec/run-metadata.d.ts +1 -1
  14. package/dist/commands/exec/run-metadata.js +1 -1
  15. package/dist/commands/exec/tests-summary.d.ts +1 -1
  16. package/dist/commands/exec/tests-summary.js +1 -1
  17. package/dist/commands/runs/facts.d.ts +2 -2
  18. package/dist/commands/runs/facts.js +1 -1
  19. package/dist/commands/runs/list/command.d.ts +129 -1
  20. package/dist/commands/runs/list/command.js +1 -1
  21. package/dist/commands/runs/list/outcomes.d.ts +16 -0
  22. package/dist/commands/runs/list/outcomes.js +1 -1
  23. package/dist/commands/runs/logs/command.d.ts +263 -1
  24. package/dist/commands/runs/logs/command.js +1 -1
  25. package/dist/commands/runs/logs/outcomes.d.ts +105 -0
  26. package/dist/commands/runs/logs/outcomes.js +1 -1
  27. package/dist/commands/runs/show/command.d.ts +329 -1
  28. package/dist/commands/runs/show/command.js +1 -1
  29. package/dist/commands/runs/show/outcomes.d.ts +71 -0
  30. package/dist/commands/runs/show/outcomes.js +3 -3
  31. package/dist/commands/vitest/command.d.ts +886 -1
  32. package/dist/commands/vitest/command.js +1 -1
  33. package/dist/commands/vitest/metadata.d.ts +1 -1
  34. package/dist/commands/vitest/metadata.js +4 -0
  35. package/dist/commands/vitest/outcomes.d.ts +295 -0
  36. package/dist/config/errors.d.ts +73 -0
  37. package/dist/config/schema.d.ts +1 -1
  38. package/dist/config-file/define.d.ts +4 -3
  39. package/dist/config-file/define.js +1 -1
  40. package/dist/config-file/toolchain.js +1 -1
  41. package/dist/core/command-slots.d.ts +8 -2
  42. package/dist/core/command-slots.js +6 -2
  43. package/dist/core/index.d.ts +1 -1
  44. package/dist/credential/index.d.ts +1 -0
  45. package/dist/credential/index.js +1 -0
  46. package/dist/credential/settle.d.ts +20 -0
  47. package/dist/credential/target.d.ts +6 -0
  48. package/dist/credential/target.js +7 -0
  49. package/dist/resources/github/command.d.ts +54 -2
  50. package/dist/resources/github/config.js +1 -1
  51. package/dist/resources/github/index.js +1 -1
  52. package/dist/resources/github/resource.js +2 -2
  53. package/dist/resources/testserver/command.d.ts +208 -10
  54. package/dist/resources/testserver/command.js +7 -0
  55. package/dist/resources/testserver/commands/create/command.d.ts +810 -1
  56. package/dist/resources/testserver/commands/create/command.js +73 -23
  57. package/dist/resources/testserver/commands/create/metadata.js +6 -2
  58. package/dist/resources/testserver/commands/create/outcomes.d.ts +347 -0
  59. package/dist/resources/testserver/commands/create/outcomes.js +14 -1
  60. package/dist/resources/testserver/commands/list/command.d.ts +84 -1
  61. package/dist/resources/testserver/commands/list/command.js +1 -1
  62. package/dist/resources/testserver/commands/list/outcomes.d.ts +16 -0
  63. package/dist/resources/testserver/config.js +14 -4
  64. package/dist/resources/testserver/events.d.ts +11 -0
  65. package/dist/resources/testserver/index.js +8 -7
  66. package/dist/resources/testserver/lane.js +1 -0
  67. package/dist/resources/testserver/live/gateways.d.ts +2 -0
  68. package/dist/resources/testserver/live/gateways.js +16 -3
  69. package/dist/resources/testserver/pool/channels.d.ts +5 -2
  70. package/dist/resources/testserver/pool/channels.js +1 -1
  71. package/dist/resources/testserver/pool/create.d.ts +9 -2
  72. package/dist/resources/testserver/pool/create.js +8 -5
  73. package/dist/resources/testserver/pool/gateways.d.ts +6 -0
  74. package/dist/resources/testserver/pool/index.d.ts +1 -0
  75. package/dist/resources/testserver/pool/index.js +1 -0
  76. package/dist/resources/testserver/pool/live/pool-records.js +6 -2
  77. package/dist/resources/testserver/pool/pull-request.d.ts +96 -0
  78. package/dist/resources/testserver/pool/pull-request.js +118 -0
  79. package/dist/resources/testserver/pr-build-facts.d.ts +130 -0
  80. package/dist/resources/testserver/pr-build-facts.js +261 -0
  81. package/dist/resources/testserver/presentation.d.ts +2 -2
  82. package/dist/resources/testserver/presentation.js +13 -3
  83. package/dist/resources/testserver/provider.d.ts +16 -6
  84. package/dist/resources/testserver/provider.js +55 -16
  85. package/dist/resources/testserver/pull-request/gateways.d.ts +117 -0
  86. package/dist/resources/testserver/pull-request/gateways.js +5 -0
  87. package/dist/resources/testserver/pull-request/index.d.ts +5 -0
  88. package/dist/resources/testserver/pull-request/index.js +6 -0
  89. package/dist/resources/testserver/pull-request/live/github-rest.d.ts +28 -0
  90. package/dist/resources/testserver/pull-request/live/github-rest.js +114 -0
  91. package/dist/resources/testserver/pull-request/live/github-token-gateway.d.ts +12 -0
  92. package/dist/resources/testserver/pull-request/live/github-token-gateway.js +39 -0
  93. package/dist/resources/testserver/pull-request/live/pull-request-gateway.d.ts +10 -0
  94. package/dist/resources/testserver/pull-request/live/pull-request-gateway.js +27 -0
  95. package/dist/resources/testserver/pull-request/live/testserver-workflow-gateway.d.ts +21 -0
  96. package/dist/resources/testserver/pull-request/live/testserver-workflow-gateway.js +64 -0
  97. package/dist/resources/testserver/ran.d.ts +5 -0
  98. package/dist/resources/testserver/ran.js +19 -3
  99. package/dist/resources/testserver/resource.d.ts +5 -1
  100. package/dist/resources/testserver/resource.js +2 -2
  101. package/dist/resources/testserver/sandbox/build-reference.d.ts +38 -0
  102. package/dist/resources/testserver/sandbox/build-reference.js +79 -0
  103. package/dist/resources/testserver/sandbox/index.d.ts +1 -0
  104. package/dist/resources/testserver/sandbox/index.js +1 -0
  105. package/dist/resources.d.ts +265 -15
  106. package/dist/sdk/index.js +2 -2
  107. package/dist/story/command-line.d.ts +34 -0
  108. package/dist/story/command-line.js +100 -0
  109. package/dist/story/index.d.ts +1 -0
  110. package/dist/story/index.js +3 -2
  111. package/dist/vercel-cli/context.js +1 -1
  112. package/dist/vercel-cli/index.js +1 -1
  113. package/dist/vitest/config.js +2 -2
  114. package/dist/vitest/fixtures.d.ts +1 -1
  115. package/dist/vitest/fixtures.js +1 -1
  116. package/dist/vitest/index.js +3 -3
  117. package/dist/vitest/plan.js +1 -1
  118. package/package.json +2 -3
  119. package/skills/overview.md +2 -0
  120. package/skills/testserver-builds.md +82 -0
@@ -1,11 +1,12 @@
1
1
  import { z } from "zod";
2
2
  import { fileOptions, fileSettings, invalidResourceOptions, loadSettingsFile, mergeResourceOptions, } from "../../../../config/index.js";
3
- import { credentialSourceFor, describeMintFailure, settleCredential, } from "../../../../credential/index.js";
3
+ import { credentialSourceFor, describeMintFailure, mintTargetText, settleCredential, } from "../../../../credential/index.js";
4
4
  import { parseTtl } from "../../../../time/index.js";
5
5
  import { testserverPoolConfig } from "../../config.js";
6
6
  import { rejectedCredentialFacts, REQUESTING_TOKEN_LINE, tokenRequestFailureFacts } from "../../credential-facts.js";
7
- import { createPooledSandbox } from "../../pool/index.js";
8
- import { CREATE_ATTEMPTS, DEFAULT_TTL_MINUTES, invalidTtlMessage, mayLeaveSandbox, } from "../../sandbox/index.js";
7
+ import { createPooledSandbox, resolvePrBuild } from "../../pool/index.js";
8
+ import { prBuildRefusalFacts } from "../../pr-build-facts.js";
9
+ import { CREATE_ATTEMPTS, DEFAULT_TTL_MINUTES, invalidTtlMessage, mayLeaveSandbox, parseBuildReference, shortSha, TESTSERVER_REPO, } from "../../sandbox/index.js";
9
10
  import { outcomes } from "./outcomes.js";
10
11
  /**
11
12
  * Makes sure the pool is usable, then gets a credential from the credential source `--credential` picks (no config
@@ -15,6 +16,13 @@ import { outcomes } from "./outcomes.js";
15
16
  * the pool, unleased. In text output it reports each step, and each progress message the control plane sends, indented,
16
17
  * as it arrives.
17
18
  *
19
+ * A PR build reference (`pr:<N>`, or the vercel/api pull request's URL) is resolved first, as a run resolves it, with
20
+ * the host's GitHub token: the pull request's head commit from GitHub, then the PR build of a pool entry created for
21
+ * `pr:<N>` on that commit, or else the newest PR build vercel/api's `Testserver` workflow published from it. The
22
+ * Testserver sandbox is created on that PR build, and its pool entry records `pr:<N>` as its requested build and the
23
+ * head commit, so a later run on that head finds the PR build in the pool. A PR build reference that can't be resolved
24
+ * refuses, and nothing is created.
25
+ *
18
26
  * Each setting comes from its flag, else `storm.config.ts` (found from the working directory), else its built-in
19
27
  * default; `--scope` and `--project` have none, so one of the two must give them. `pool create` only ever makes
20
28
  * Testserver sandboxes, so it reads `build` and `ttl` through the Testserver pool resource's config, from the file's
@@ -32,15 +40,11 @@ export function command(cmd) {
32
40
  credential: z.enum(["mint", "github-actions"]).default("mint"),
33
41
  }),
34
42
  cli: { options: { project: { short: "p" } } },
35
- outcomes,
36
- validate: ({ ttl }) => ttl !== undefined && parseTtl(ttl) === undefined
37
- ? [
38
- {
39
- field: "ttl",
40
- message: invalidTtlMessage(ttl),
41
- },
42
- ]
43
- : [],
43
+ response: outcomes,
44
+ validate: ({ ttl, build }) => [
45
+ ...(ttl !== undefined && parseTtl(ttl) === undefined ? [{ field: "ttl", message: invalidTtlMessage(ttl) }] : []),
46
+ ...(build === undefined ? [] : buildProblems(build)),
47
+ ],
44
48
  handler: async ({ app, ui }, request) => {
45
49
  const { credential: source, scope, project } = request;
46
50
  const file = await loadSettingsFile(app.context.config, app.cwd, app.resourceConfigs);
@@ -49,7 +53,7 @@ export function command(cmd) {
49
53
  const configFile = file.path;
50
54
  const settings = fileSettings(file, { scope, project });
51
55
  const pool = mergeResourceOptions(testserverPoolConfig, fileOptions(file, testserverPoolConfig), {
52
- ...(request.build === undefined ? {} : { build: request.build }),
56
+ ...(request.build === undefined ? {} : { build: settledBuild(request.build) }),
53
57
  ...(request.ttl === undefined ? {} : { ttl: request.ttl }),
54
58
  });
55
59
  if (!pool.ok)
@@ -57,7 +61,7 @@ export function command(cmd) {
57
61
  const chosen = settleCredential(source, settings.scope, settings.project);
58
62
  if (!chosen.ok)
59
63
  return chosen.refusal;
60
- const build = pool.value.build.value;
64
+ const requestedBuild = pool.value.build.value;
61
65
  const ttlMinutes = parseTtl(pool.value.ttl.value) ?? DEFAULT_TTL_MINUTES;
62
66
  if (configFile !== null)
63
67
  await ui.progress?.(`Config: ${configFile}`);
@@ -67,28 +71,55 @@ export function command(cmd) {
67
71
  return outcomes.poolUnavailable({ ...prepared.failure });
68
72
  const credential = credentialSourceFor(chosen.credential, context, {
69
73
  onMint: async (target) => {
70
- await ui.progress?.(`Minting a credential for project ${target.project} on team ${target.team}…`);
74
+ await ui.progress?.(`Minting a credential for ${mintTargetText(target)}…`);
71
75
  },
72
76
  onRequest: async () => {
73
77
  await ui.progress?.(REQUESTING_TOKEN_LINE);
74
78
  },
75
79
  });
76
- const got = await credential.get();
77
- if (!got.ok) {
78
- const { failure } = got;
79
- return failure.source === "mint"
80
- ? outcomes.mintFailed({ ...failure.target, ...describeMintFailure(failure.failure, failure.target) })
81
- : outcomes.tokenRequestFailed(tokenRequestFailureFacts(failure.failure));
80
+ let resolution;
81
+ const reference = parseBuildReference(requestedBuild);
82
+ if (reference.ok && reference.reference.kind === "pull-request") {
83
+ const resolved = await resolvePrBuild(context, { pr: reference.reference.number });
84
+ if (!resolved.ok) {
85
+ const { key, data } = prBuildRefusalFacts(resolved.refusal);
86
+ // Each key names one of the four errors, with that error's data.
87
+ switch (key) {
88
+ case "pullRequestUnreadable":
89
+ return outcomes.pullRequestUnreadable(data);
90
+ case "prBuildsUnlisted":
91
+ return outcomes.prBuildsUnlisted(data);
92
+ case "prBuildNotReady":
93
+ return outcomes.prBuildNotReady(data);
94
+ case "prBuildExpired":
95
+ return outcomes.prBuildExpired(data);
96
+ }
97
+ }
98
+ resolution = resolved.resolution;
99
+ await ui.progress?.(`${TESTSERVER_REPO}#${resolution.pr} at ${shortSha(resolution.headSha)} → build ${resolution.build}${resolution.from === "pool" ? " (from the pool)" : ""}`);
82
100
  }
101
+ const build = resolution?.build ?? requestedBuild;
102
+ const got = await credential.get();
103
+ if (!got.ok)
104
+ return credentialFailed(got.failure);
83
105
  await ui.progress?.(`Creating a Testserver sandbox on ${build}…`);
84
106
  const progress = ui.progress;
85
- const created = await createPooledSandbox(app.context, { credential: got.credential, build, ttlMinutes, lease: false }, progress === undefined ? {} : { onProgress: (message) => progress(` ${message}`) });
107
+ const created = await createPooledSandbox(app.context, {
108
+ credential: got.credential,
109
+ build,
110
+ requestedBuild,
111
+ ...(resolution === undefined ? {} : { headSha: resolution.headSha }),
112
+ ttlMinutes,
113
+ lease: false,
114
+ }, progress === undefined ? {} : { onProgress: (message) => progress(` ${message}`) });
115
+ const pullRequest = resolution === undefined ? null : { repo: TESTSERVER_REPO, number: resolution.pr, headSha: resolution.headSha };
86
116
  switch (created.kind) {
87
117
  case "pooled":
88
- return outcomes.created({ ...sandboxFacts(created.entry), configFile });
118
+ return outcomes.created({ ...sandboxFacts(created.entry), pullRequest, configFile });
89
119
  case "pool-write-failed":
90
120
  return outcomes.poolWriteFailed({
91
121
  ...sandboxFacts(created.entry),
122
+ pullRequest,
92
123
  configFile,
93
124
  path: created.failure.path,
94
125
  message: created.failure.message,
@@ -99,6 +130,25 @@ export function command(cmd) {
99
130
  },
100
131
  });
101
132
  }
133
+ /** The `--build` problems the Testserver pool's `build` rule finds, as `validate` reports them. */
134
+ function buildProblems(build) {
135
+ const checked = testserverPoolConfig.options.build.check(build);
136
+ return checked.ok ? [] : checked.problems.map(({ problem }) => ({ field: "build", message: `--build ${problem}.` }));
137
+ }
138
+ /** `--build` as the Testserver pool's `build` rule settles it: a PR build reference as `pr:<N>`. */
139
+ function settledBuild(build) {
140
+ const checked = testserverPoolConfig.options.build.check(build);
141
+ // `validate` refused every `--build` the rule refuses.
142
+ if (!checked.ok)
143
+ throw new Error(`--build ${build} should have been refused`);
144
+ return checked.value;
145
+ }
146
+ /** The outcome of a credential source that couldn't give a credential. */
147
+ function credentialFailed(failure) {
148
+ return failure.source === "mint"
149
+ ? outcomes.mintFailed({ ...failure.target, ...describeMintFailure(failure.failure, failure.target) })
150
+ : outcomes.tokenRequestFailed(tokenRequestFailureFacts(failure.failure));
151
+ }
102
152
  function sandboxFacts(entry) {
103
153
  const { testserverUrl, logViewerUrl, requestedBuild, resolvedBuild, ttlMinutes } = entry;
104
154
  return { testserverUrl, logViewerUrl, requestedBuild, resolvedBuild, ttlMinutes };
@@ -1,5 +1,5 @@
1
1
  export const metadata = {
2
- description: "Get a credential (mint one, or with --credential github-actions request a GitHub Actions OIDC token), create one Testserver sandbox with the TTL --ttl gives, and add it to the pool, unleased. Prints its Testserver URL, log viewer URL, and the build it resolved to. A flag overrides storm.config.ts, found in the working directory or a parent up to the git worktree's root and checked whole, which overrides the built-in default.",
2
+ description: "Get a credential (mint one, or with --credential github-actions request a GitHub Actions OIDC token), create one Testserver sandbox with the TTL --ttl gives, and add it to the pool, unleased. Prints its Testserver URL, log viewer URL, and the build it resolved to; for a vercel/api pull request, also the head commit. A flag overrides storm.config.ts, found in the working directory or a parent up to the git worktree's root and checked whole, which overrides the built-in default.",
3
3
  usages: ["[--build <BUILD>] [--ttl <DURATION>] [--credential <SOURCE>] [--scope <TEAM> --project <PROJECT>]"],
4
4
  summary: "Create a Testserver sandbox and add it to the pool.",
5
5
  fields: {
@@ -13,7 +13,7 @@ export const metadata = {
13
13
  },
14
14
  build: {
15
15
  valueLabel: "BUILD",
16
- description: "The build to create the Testserver sandbox on: a build name, or the build channel stable or latest_main. Default stable, or resources.testserverPool.build in storm.config.ts.",
16
+ description: "The build to create the Testserver sandbox on: a build name, the build channel stable or latest_main, or a vercel/api pull request as pr:<N> or its URL. A pull request creates on the newest build made from its head commit, which storm reads from GitHub with GITHUB_TOKEN, GH_TOKEN or gh auth token, or refuses. Default stable, or resources.testserverPool.build in storm.config.ts.",
17
17
  },
18
18
  ttl: {
19
19
  valueLabel: "DURATION",
@@ -37,6 +37,10 @@ export const metadata = {
37
37
  argv: "--scope vercel --project vercel --build latest_main --json",
38
38
  description: "Create one on the newest main build and print its details as JSON.",
39
39
  },
40
+ {
41
+ argv: "--scope vercel --project vercel --build pr:104196 --json",
42
+ description: "Create one on the Testserver build of vercel/api pull request 104196's head commit.",
43
+ },
40
44
  {
41
45
  argv: "--credential github-actions --ttl 10m",
42
46
  description: "In a GitHub Actions job, create one with a GitHub Actions OIDC token.",
@@ -6,12 +6,67 @@ export declare const outcomes: import("@vercel/clinkr").Outcomes<{
6
6
  logViewerUrl: z.ZodString;
7
7
  requestedBuild: z.ZodString;
8
8
  resolvedBuild: z.ZodString;
9
+ pullRequest: z.ZodNullable<z.ZodObject<{
10
+ repo: z.ZodString;
11
+ number: z.ZodNumber;
12
+ headSha: z.ZodString;
13
+ }, z.core.$strip>>;
9
14
  ttlMinutes: z.ZodNumber;
10
15
  configFile: z.ZodNullable<z.ZodString>;
11
16
  }, z.core.$strip>;
12
17
  }, {
13
18
  created: unknown;
14
19
  }, {
20
+ pullRequestUnreadable: z.ZodObject<{
21
+ pr: z.ZodNumber;
22
+ repo: z.ZodString;
23
+ kind: z.ZodEnum<{
24
+ "connect-failed": "connect-failed";
25
+ "http-error": "http-error";
26
+ malformed: "malformed";
27
+ "no-token": "no-token";
28
+ "not-found": "not-found";
29
+ rejected: "rejected";
30
+ timeout: "timeout";
31
+ }>;
32
+ status: z.ZodNullable<z.ZodNumber>;
33
+ message: z.ZodNullable<z.ZodString>;
34
+ tokenOrigin: z.ZodNullable<z.ZodEnum<{
35
+ GH_TOKEN: "GH_TOKEN";
36
+ GITHUB_TOKEN: "GITHUB_TOKEN";
37
+ "gh auth token": "gh auth token";
38
+ }>>;
39
+ }, z.core.$strip>;
40
+ prBuildsUnlisted: z.ZodObject<{
41
+ pr: z.ZodNumber;
42
+ failure: z.ZodObject<{
43
+ kind: z.ZodEnum<{
44
+ "connect-failed": "connect-failed";
45
+ "http-error": "http-error";
46
+ malformed: "malformed";
47
+ "not-found": "not-found";
48
+ rejected: "rejected";
49
+ timeout: "timeout";
50
+ }>;
51
+ status: z.ZodNullable<z.ZodNumber>;
52
+ detail: z.ZodString;
53
+ }, z.core.$strip>;
54
+ }, z.core.$strip>;
55
+ prBuildNotReady: z.ZodObject<{
56
+ pr: z.ZodNumber;
57
+ headSha: z.ZodString;
58
+ newest: z.ZodNullable<z.ZodObject<{
59
+ build: z.ZodString;
60
+ headSha: z.ZodString;
61
+ createdAt: z.ZodString;
62
+ }, z.core.$strip>>;
63
+ }, z.core.$strip>;
64
+ prBuildExpired: z.ZodObject<{
65
+ pr: z.ZodNumber;
66
+ headSha: z.ZodString;
67
+ build: z.ZodString;
68
+ expiresAt: z.ZodString;
69
+ }, z.core.$strip>;
15
70
  poolUnavailable: z.ZodObject<{
16
71
  path: z.ZodString;
17
72
  message: z.ZodString;
@@ -61,6 +116,11 @@ export declare const outcomes: import("@vercel/clinkr").Outcomes<{
61
116
  logViewerUrl: z.ZodString;
62
117
  requestedBuild: z.ZodString;
63
118
  resolvedBuild: z.ZodString;
119
+ pullRequest: z.ZodNullable<z.ZodObject<{
120
+ repo: z.ZodString;
121
+ number: z.ZodNumber;
122
+ headSha: z.ZodString;
123
+ }, z.core.$strip>>;
64
124
  ttlMinutes: z.ZodNumber;
65
125
  configFile: z.ZodNullable<z.ZodString>;
66
126
  path: z.ZodString;
@@ -108,4 +168,291 @@ export declare const outcomes: import("@vercel/clinkr").Outcomes<{
108
168
  missingTarget: import("@vercel/clinkr").SharedError<"missing_target", [data: {
109
169
  missing: ("project" | "scope")[];
110
170
  }]>;
171
+ }, {
172
+ readonly pullRequestUnreadable: import("@vercel/clinkr").DataErrorDefinition<z.ZodObject<{
173
+ pr: z.ZodNumber;
174
+ repo: z.ZodString;
175
+ kind: z.ZodEnum<{
176
+ "connect-failed": "connect-failed";
177
+ "http-error": "http-error";
178
+ malformed: "malformed";
179
+ "no-token": "no-token";
180
+ "not-found": "not-found";
181
+ rejected: "rejected";
182
+ timeout: "timeout";
183
+ }>;
184
+ status: z.ZodNullable<z.ZodNumber>;
185
+ message: z.ZodNullable<z.ZodString>;
186
+ tokenOrigin: z.ZodNullable<z.ZodEnum<{
187
+ GH_TOKEN: "GH_TOKEN";
188
+ GITHUB_TOKEN: "GITHUB_TOKEN";
189
+ "gh auth token": "gh auth token";
190
+ }>>;
191
+ }, z.core.$strip>, readonly []>;
192
+ readonly prBuildsUnlisted: import("@vercel/clinkr").DataErrorDefinition<z.ZodObject<{
193
+ pr: z.ZodNumber;
194
+ failure: z.ZodObject<{
195
+ kind: z.ZodEnum<{
196
+ "connect-failed": "connect-failed";
197
+ "http-error": "http-error";
198
+ malformed: "malformed";
199
+ "not-found": "not-found";
200
+ rejected: "rejected";
201
+ timeout: "timeout";
202
+ }>;
203
+ status: z.ZodNullable<z.ZodNumber>;
204
+ detail: z.ZodString;
205
+ }, z.core.$strip>;
206
+ }, z.core.$strip>, readonly []>;
207
+ readonly prBuildNotReady: import("@vercel/clinkr").DataErrorDefinition<z.ZodObject<{
208
+ pr: z.ZodNumber;
209
+ headSha: z.ZodString;
210
+ newest: z.ZodNullable<z.ZodObject<{
211
+ build: z.ZodString;
212
+ headSha: z.ZodString;
213
+ createdAt: z.ZodString;
214
+ }, z.core.$strip>>;
215
+ }, z.core.$strip>, readonly []>;
216
+ readonly prBuildExpired: import("@vercel/clinkr").DataErrorDefinition<z.ZodObject<{
217
+ pr: z.ZodNumber;
218
+ headSha: z.ZodString;
219
+ build: z.ZodString;
220
+ expiresAt: z.ZodString;
221
+ }, z.core.$strip>, readonly []>;
222
+ readonly poolUnavailable: {
223
+ readonly exitCode: 1;
224
+ readonly description: "storm couldn't use the pool, so it minted no credential and created no Testserver sandbox.";
225
+ readonly schema: z.ZodObject<{
226
+ path: z.ZodString;
227
+ message: z.ZodString;
228
+ }, z.core.$strip>;
229
+ readonly render: ({ path, message }: {
230
+ path: string;
231
+ message: string;
232
+ }) => {
233
+ message: string;
234
+ rows: [string, string][];
235
+ next: {
236
+ type: "text";
237
+ text: string;
238
+ }[];
239
+ };
240
+ };
241
+ readonly mintFailed: {
242
+ readonly exitCode: 1;
243
+ readonly description: "The vercel CLI couldn't mint a credential for the team and project.";
244
+ readonly schema: z.ZodObject<{
245
+ team: z.ZodString;
246
+ project: z.ZodString;
247
+ cause: z.ZodString;
248
+ fix: z.ZodString;
249
+ }, z.core.$strip>;
250
+ readonly render: ({ cause, fix }: {
251
+ team: string;
252
+ project: string;
253
+ cause: string;
254
+ fix: string;
255
+ }) => {
256
+ message: string;
257
+ next: {
258
+ type: "text";
259
+ text: string;
260
+ }[];
261
+ };
262
+ };
263
+ readonly tokenRequestFailed: {
264
+ readonly exitCode: 1;
265
+ readonly description: "With --credential github-actions, the GitHub Actions OIDC token request failed.";
266
+ readonly schema: z.ZodObject<{
267
+ cause: z.ZodEnum<{
268
+ "request-failed": "request-failed";
269
+ "variables-missing": "variables-missing";
270
+ }>;
271
+ missing: z.ZodNullable<z.ZodArray<z.ZodEnum<{
272
+ ACTIONS_ID_TOKEN_REQUEST_TOKEN: "ACTIONS_ID_TOKEN_REQUEST_TOKEN";
273
+ ACTIONS_ID_TOKEN_REQUEST_URL: "ACTIONS_ID_TOKEN_REQUEST_URL";
274
+ }>>>;
275
+ status: z.ZodNullable<z.ZodNumber>;
276
+ said: z.ZodNullable<z.ZodString>;
277
+ detail: z.ZodString;
278
+ fix: z.ZodString;
279
+ }, z.core.$strip>;
280
+ readonly render: ({ detail, fix }: {
281
+ cause: "request-failed" | "variables-missing";
282
+ missing: ("ACTIONS_ID_TOKEN_REQUEST_TOKEN" | "ACTIONS_ID_TOKEN_REQUEST_URL")[] | null;
283
+ status: number | null;
284
+ said: string | null;
285
+ detail: string;
286
+ fix: string;
287
+ }) => {
288
+ message: string;
289
+ next: {
290
+ type: "text";
291
+ text: string;
292
+ }[];
293
+ };
294
+ };
295
+ readonly credentialRejected: {
296
+ readonly exitCode: 1;
297
+ readonly description: "The Testserver control plane refused the credential, minted or a GitHub Actions OIDC token (a redirect to SSO, a 401 or a 403).";
298
+ readonly schema: z.ZodObject<{
299
+ origin: z.ZodDiscriminatedUnion<[z.ZodObject<{
300
+ source: z.ZodLiteral<"mint">;
301
+ team: z.ZodString;
302
+ project: z.ZodString;
303
+ }, z.core.$strip>, z.ZodObject<{
304
+ source: z.ZodLiteral<"github-actions">;
305
+ claims: z.ZodNullable<z.ZodObject<{
306
+ aud: z.ZodString;
307
+ repository: z.ZodString;
308
+ }, z.core.$strip>>;
309
+ }, z.core.$strip>], "source">;
310
+ fix: z.ZodString;
311
+ status: z.ZodNumber;
312
+ vercelId: z.ZodNullable<z.ZodString>;
313
+ }, z.core.$strip>;
314
+ readonly render: ({ origin, fix, status, vercelId }: {
315
+ origin: {
316
+ source: "mint";
317
+ team: string;
318
+ project: string;
319
+ } | {
320
+ source: "github-actions";
321
+ claims: {
322
+ aud: string;
323
+ repository: string;
324
+ } | null;
325
+ };
326
+ fix: string;
327
+ status: number;
328
+ vercelId: string | null;
329
+ }) => {
330
+ message: string;
331
+ rows: (readonly ["Project", string] | readonly ["Team", string])[] | (readonly ["aud", string] | readonly ["repository", string])[];
332
+ next: {
333
+ type: "text";
334
+ text: string;
335
+ }[];
336
+ };
337
+ };
338
+ readonly testserverUnreachable: {
339
+ readonly exitCode: 1;
340
+ readonly description: "No create reached the Testserver control plane, after every attempt.";
341
+ readonly schema: z.ZodObject<{
342
+ attempts: z.ZodNumber;
343
+ code: z.ZodString;
344
+ }, z.core.$strip>;
345
+ readonly render: ({ attempts, code }: {
346
+ attempts: number;
347
+ code: string;
348
+ }) => {
349
+ message: string;
350
+ next: {
351
+ type: "text";
352
+ text: string;
353
+ }[];
354
+ };
355
+ };
356
+ readonly poolWriteFailed: {
357
+ readonly exitCode: 1;
358
+ readonly description: "Created the Testserver sandbox, but couldn't add it to the pool.";
359
+ readonly schema: z.ZodObject<{
360
+ testserverUrl: z.ZodString;
361
+ logViewerUrl: z.ZodString;
362
+ requestedBuild: z.ZodString;
363
+ resolvedBuild: z.ZodString;
364
+ pullRequest: z.ZodNullable<z.ZodObject<{
365
+ repo: z.ZodString;
366
+ number: z.ZodNumber;
367
+ headSha: z.ZodString;
368
+ }, z.core.$strip>>;
369
+ ttlMinutes: z.ZodNumber;
370
+ configFile: z.ZodNullable<z.ZodString>;
371
+ path: z.ZodString;
372
+ message: z.ZodString;
373
+ }, z.core.$strip>;
374
+ readonly render: (failure: {
375
+ testserverUrl: string;
376
+ logViewerUrl: string;
377
+ requestedBuild: string;
378
+ resolvedBuild: string;
379
+ pullRequest: {
380
+ repo: string;
381
+ number: number;
382
+ headSha: string;
383
+ } | null;
384
+ ttlMinutes: number;
385
+ configFile: string | null;
386
+ path: string;
387
+ message: string;
388
+ }) => {
389
+ message: string;
390
+ rows: [string, string][];
391
+ next: {
392
+ type: "text";
393
+ text: string;
394
+ }[];
395
+ };
396
+ };
397
+ readonly createFailed: {
398
+ readonly exitCode: 1;
399
+ readonly description: "The create reached the Testserver control plane and failed.";
400
+ readonly schema: z.ZodObject<{
401
+ kind: z.ZodEnum<{
402
+ dropped: "dropped";
403
+ "http-error": "http-error";
404
+ malformed: "malformed";
405
+ "stream-ended": "stream-ended";
406
+ "stream-error": "stream-error";
407
+ timeout: "timeout";
408
+ }>;
409
+ build: z.ZodString;
410
+ ttlMinutes: z.ZodNumber;
411
+ detail: z.ZodNullable<z.ZodString>;
412
+ status: z.ZodNullable<z.ZodNumber>;
413
+ seconds: z.ZodNullable<z.ZodNumber>;
414
+ sandboxMayExist: z.ZodBoolean;
415
+ }, z.core.$strip>;
416
+ readonly render: (failure: {
417
+ kind: "dropped" | "http-error" | "malformed" | "stream-ended" | "stream-error" | "timeout";
418
+ build: string;
419
+ ttlMinutes: number;
420
+ detail: string | null;
421
+ status: number | null;
422
+ seconds: number | null;
423
+ sandboxMayExist: boolean;
424
+ }) => {
425
+ message: string;
426
+ next?: {
427
+ type: "text";
428
+ text: string;
429
+ }[];
430
+ };
431
+ };
432
+ readonly invalidConfig: import("@vercel/clinkr").SharedError<"invalid_config", [data: {
433
+ file: string;
434
+ problems: {
435
+ key: string | null;
436
+ location: {
437
+ line: number;
438
+ column: number | null;
439
+ } | null;
440
+ problem: string;
441
+ }[];
442
+ }]>;
443
+ readonly invalidResourceOptions: import("@vercel/clinkr").SharedError<"invalid_resource_options", [data: {
444
+ configFile: string | null;
445
+ problems: {
446
+ key: string;
447
+ problem: string;
448
+ values: {
449
+ key: string;
450
+ value: string;
451
+ source: "default" | "file" | "flag";
452
+ }[];
453
+ }[];
454
+ }]>;
455
+ readonly missingTarget: import("@vercel/clinkr").SharedError<"missing_target", [data: {
456
+ missing: ("project" | "scope")[];
457
+ }]>;
111
458
  }>;
@@ -3,6 +3,7 @@ import { z } from "zod";
3
3
  import { configErrors } from "../../../../config/index.js";
4
4
  import { credentialErrors } from "../../../../credential/index.js";
5
5
  import { credentialOriginRows, rejectedCredentialShape, rejectedCredentialText, tokenRequestFailureShape, } from "../../credential-facts.js";
6
+ import { prBuildRefusalErrors } from "../../pr-build-facts.js";
6
7
  import { describeTtl } from "../../sandbox/index.js";
7
8
  /** The `next` hint for a failed create that may have left a Testserver sandbox (`mayLeaveSandbox`), living `ttlMinutes`. */
8
9
  function sandboxMayExist(ttlMinutes) {
@@ -15,10 +16,20 @@ const sandboxSchema = z.object({
15
16
  testserverUrl: z.string(),
16
17
  /** The log viewer URL, with no trailing slash. */
17
18
  logViewerUrl: z.string(),
18
- /** The build or build channel given with --build. */
19
+ /** The build, build channel or PR build reference (pr:<N>) given with --build. */
19
20
  requestedBuild: z.string(),
20
21
  /** The build the Testserver sandbox runs. */
21
22
  resolvedBuild: z.string(),
23
+ /** For a PR build reference, the pull request and the head commit the resolved PR build was made from; null otherwise. */
24
+ pullRequest: z
25
+ .object({
26
+ /** The repository, vercel/api. */
27
+ repo: z.string(),
28
+ number: z.number(),
29
+ /** The pull request's head commit, 40 hex characters. */
30
+ headSha: z.string(),
31
+ })
32
+ .nullable(),
22
33
  /** Its TTL, in minutes. */
23
34
  ttlMinutes: z.number(),
24
35
  /** The config file the settings came from (its absolute path); null when none applied. */
@@ -36,6 +47,7 @@ export const outcomes = defineOutcomes({
36
47
  ["Log viewer URL", sandbox.logViewerUrl],
37
48
  ["Requested build", sandbox.requestedBuild],
38
49
  ["Resolved build", sandbox.resolvedBuild],
50
+ ...(sandbox.pullRequest === null ? [] : [["Head commit", sandbox.pullRequest.headSha]]),
39
51
  ["TTL", describeTtl(sandbox.ttlMinutes)],
40
52
  ],
41
53
  message: "Added it to the pool, unleased.",
@@ -45,6 +57,7 @@ export const outcomes = defineOutcomes({
45
57
  errors: {
46
58
  ...configErrors,
47
59
  ...credentialErrors,
60
+ ...prBuildRefusalErrors("No Testserver sandbox was created."),
48
61
  poolUnavailable: {
49
62
  exitCode: 1,
50
63
  description: "storm couldn't use the pool, so it minted no credential and created no Testserver sandbox.",