@cnc-tools/storm 0.7.0 → 0.8.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/dist/build-info.js +1 -1
- package/dist/commands/exec/cleanup.d.ts +3 -3
- package/dist/commands/exec/cleanup.js +1 -1
- package/dist/commands/exec/command.d.ts +771 -1
- package/dist/commands/exec/command.js +1 -1
- package/dist/commands/exec/live-view.js +3 -2
- package/dist/commands/exec/metadata.d.ts +1 -1
- package/dist/commands/exec/metadata.js +4 -0
- package/dist/commands/exec/mint-failed.d.ts +28 -0
- package/dist/commands/exec/outcomes.d.ts +476 -0
- package/dist/commands/exec/progress.js +3 -5
- package/dist/commands/exec/run-command.d.ts +2 -2
- package/dist/commands/exec/run-metadata.d.ts +1 -1
- package/dist/commands/exec/run-metadata.js +1 -1
- package/dist/commands/exec/tests-summary.d.ts +1 -1
- package/dist/commands/exec/tests-summary.js +1 -1
- package/dist/commands/runs/list/command.d.ts +129 -1
- package/dist/commands/runs/list/command.js +1 -1
- package/dist/commands/runs/list/outcomes.d.ts +16 -0
- package/dist/commands/runs/logs/command.d.ts +263 -1
- package/dist/commands/runs/logs/command.js +1 -1
- package/dist/commands/runs/logs/outcomes.d.ts +105 -0
- package/dist/commands/runs/show/command.d.ts +329 -1
- package/dist/commands/runs/show/command.js +1 -1
- package/dist/commands/runs/show/outcomes.d.ts +71 -0
- package/dist/commands/vitest/command.d.ts +886 -1
- package/dist/commands/vitest/command.js +1 -1
- package/dist/commands/vitest/metadata.d.ts +1 -1
- package/dist/commands/vitest/metadata.js +4 -0
- package/dist/commands/vitest/outcomes.d.ts +295 -0
- package/dist/config/errors.d.ts +73 -0
- package/dist/config/schema.d.ts +1 -1
- package/dist/config-file/define.d.ts +4 -3
- package/dist/config-file/define.js +1 -1
- package/dist/config-file/toolchain.js +1 -1
- package/dist/core/command-slots.d.ts +8 -2
- package/dist/core/command-slots.js +6 -2
- package/dist/core/index.d.ts +1 -1
- package/dist/credential/index.d.ts +1 -0
- package/dist/credential/index.js +1 -0
- package/dist/credential/settle.d.ts +20 -0
- package/dist/credential/target.d.ts +6 -0
- package/dist/credential/target.js +7 -0
- package/dist/resources/github/command.d.ts +54 -2
- package/dist/resources/github/config.js +1 -1
- package/dist/resources/github/index.js +1 -1
- package/dist/resources/github/resource.js +2 -2
- package/dist/resources/testserver/command.d.ts +208 -10
- package/dist/resources/testserver/command.js +7 -0
- package/dist/resources/testserver/commands/create/command.d.ts +808 -1
- package/dist/resources/testserver/commands/create/command.js +64 -23
- package/dist/resources/testserver/commands/create/metadata.js +6 -2
- package/dist/resources/testserver/commands/create/outcomes.d.ts +347 -0
- package/dist/resources/testserver/commands/create/outcomes.js +14 -1
- package/dist/resources/testserver/commands/list/command.d.ts +84 -1
- package/dist/resources/testserver/commands/list/command.js +1 -1
- package/dist/resources/testserver/commands/list/outcomes.d.ts +16 -0
- package/dist/resources/testserver/config.js +14 -4
- package/dist/resources/testserver/events.d.ts +9 -0
- package/dist/resources/testserver/index.js +8 -7
- package/dist/resources/testserver/lane.js +1 -0
- package/dist/resources/testserver/live/gateways.d.ts +2 -0
- package/dist/resources/testserver/live/gateways.js +16 -3
- package/dist/resources/testserver/pool/channels.d.ts +5 -2
- package/dist/resources/testserver/pool/channels.js +1 -1
- package/dist/resources/testserver/pool/create.d.ts +6 -2
- package/dist/resources/testserver/pool/create.js +6 -5
- package/dist/resources/testserver/pool/index.d.ts +1 -0
- package/dist/resources/testserver/pool/index.js +1 -0
- package/dist/resources/testserver/pool/pull-request.d.ts +89 -0
- package/dist/resources/testserver/pool/pull-request.js +85 -0
- package/dist/resources/testserver/pr-build-facts.d.ts +130 -0
- package/dist/resources/testserver/pr-build-facts.js +261 -0
- package/dist/resources/testserver/presentation.d.ts +2 -2
- package/dist/resources/testserver/presentation.js +12 -3
- package/dist/resources/testserver/provider.d.ts +16 -6
- package/dist/resources/testserver/provider.js +46 -15
- package/dist/resources/testserver/pull-request/gateways.d.ts +117 -0
- package/dist/resources/testserver/pull-request/gateways.js +5 -0
- package/dist/resources/testserver/pull-request/index.d.ts +5 -0
- package/dist/resources/testserver/pull-request/index.js +6 -0
- package/dist/resources/testserver/pull-request/live/github-rest.d.ts +28 -0
- package/dist/resources/testserver/pull-request/live/github-rest.js +114 -0
- package/dist/resources/testserver/pull-request/live/github-token-gateway.d.ts +12 -0
- package/dist/resources/testserver/pull-request/live/github-token-gateway.js +39 -0
- package/dist/resources/testserver/pull-request/live/pull-request-gateway.d.ts +10 -0
- package/dist/resources/testserver/pull-request/live/pull-request-gateway.js +27 -0
- package/dist/resources/testserver/pull-request/live/testserver-workflow-gateway.d.ts +21 -0
- package/dist/resources/testserver/pull-request/live/testserver-workflow-gateway.js +64 -0
- package/dist/resources/testserver/ran.d.ts +5 -0
- package/dist/resources/testserver/ran.js +19 -3
- package/dist/resources/testserver/resource.d.ts +5 -1
- package/dist/resources/testserver/resource.js +2 -2
- package/dist/resources/testserver/sandbox/build-reference.d.ts +38 -0
- package/dist/resources/testserver/sandbox/build-reference.js +79 -0
- package/dist/resources/testserver/sandbox/index.d.ts +1 -0
- package/dist/resources/testserver/sandbox/index.js +1 -0
- package/dist/resources.d.ts +265 -15
- package/dist/sdk/index.js +2 -2
- package/dist/story/command-line.d.ts +34 -0
- package/dist/story/command-line.js +100 -0
- package/dist/story/index.d.ts +1 -0
- package/dist/story/index.js +3 -2
- package/dist/vercel-cli/context.js +1 -1
- package/dist/vercel-cli/index.js +1 -1
- package/dist/vitest/config.js +2 -2
- package/dist/vitest/fixtures.d.ts +1 -1
- package/dist/vitest/fixtures.js +1 -1
- package/dist/vitest/index.js +3 -3
- package/dist/vitest/plan.js +1 -1
- package/package.json +3 -3
- package/skills/overview.md +2 -0
- package/skills/testserver-builds.md +80 -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 {
|
|
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,11 @@ 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, from
|
|
20
|
+
* GitHub with the host's GitHub token: the pull request's head commit, then the newest PR build vercel/api's
|
|
21
|
+
* `Testserver` workflow published from it. The Testserver sandbox is created on that PR build, and its pool entry records `pr:<N>` as
|
|
22
|
+
* its requested build. A PR build reference that can't be resolved refuses, and nothing is created.
|
|
23
|
+
*
|
|
18
24
|
* Each setting comes from its flag, else `storm.config.ts` (found from the working directory), else its built-in
|
|
19
25
|
* default; `--scope` and `--project` have none, so one of the two must give them. `pool create` only ever makes
|
|
20
26
|
* Testserver sandboxes, so it reads `build` and `ttl` through the Testserver pool resource's config, from the file's
|
|
@@ -32,15 +38,11 @@ export function command(cmd) {
|
|
|
32
38
|
credential: z.enum(["mint", "github-actions"]).default("mint"),
|
|
33
39
|
}),
|
|
34
40
|
cli: { options: { project: { short: "p" } } },
|
|
35
|
-
outcomes,
|
|
36
|
-
validate: ({ ttl }) =>
|
|
37
|
-
? [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
message: invalidTtlMessage(ttl),
|
|
41
|
-
},
|
|
42
|
-
]
|
|
43
|
-
: [],
|
|
41
|
+
response: outcomes,
|
|
42
|
+
validate: ({ ttl, build }) => [
|
|
43
|
+
...(ttl !== undefined && parseTtl(ttl) === undefined ? [{ field: "ttl", message: invalidTtlMessage(ttl) }] : []),
|
|
44
|
+
...(build === undefined ? [] : buildProblems(build)),
|
|
45
|
+
],
|
|
44
46
|
handler: async ({ app, ui }, request) => {
|
|
45
47
|
const { credential: source, scope, project } = request;
|
|
46
48
|
const file = await loadSettingsFile(app.context.config, app.cwd, app.resourceConfigs);
|
|
@@ -49,7 +51,7 @@ export function command(cmd) {
|
|
|
49
51
|
const configFile = file.path;
|
|
50
52
|
const settings = fileSettings(file, { scope, project });
|
|
51
53
|
const pool = mergeResourceOptions(testserverPoolConfig, fileOptions(file, testserverPoolConfig), {
|
|
52
|
-
...(request.build === undefined ? {} : { build: request.build }),
|
|
54
|
+
...(request.build === undefined ? {} : { build: settledBuild(request.build) }),
|
|
53
55
|
...(request.ttl === undefined ? {} : { ttl: request.ttl }),
|
|
54
56
|
});
|
|
55
57
|
if (!pool.ok)
|
|
@@ -57,7 +59,7 @@ export function command(cmd) {
|
|
|
57
59
|
const chosen = settleCredential(source, settings.scope, settings.project);
|
|
58
60
|
if (!chosen.ok)
|
|
59
61
|
return chosen.refusal;
|
|
60
|
-
const
|
|
62
|
+
const requestedBuild = pool.value.build.value;
|
|
61
63
|
const ttlMinutes = parseTtl(pool.value.ttl.value) ?? DEFAULT_TTL_MINUTES;
|
|
62
64
|
if (configFile !== null)
|
|
63
65
|
await ui.progress?.(`Config: ${configFile}`);
|
|
@@ -67,28 +69,48 @@ export function command(cmd) {
|
|
|
67
69
|
return outcomes.poolUnavailable({ ...prepared.failure });
|
|
68
70
|
const credential = credentialSourceFor(chosen.credential, context, {
|
|
69
71
|
onMint: async (target) => {
|
|
70
|
-
await ui.progress?.(`Minting a credential for
|
|
72
|
+
await ui.progress?.(`Minting a credential for ${mintTargetText(target)}…`);
|
|
71
73
|
},
|
|
72
74
|
onRequest: async () => {
|
|
73
75
|
await ui.progress?.(REQUESTING_TOKEN_LINE);
|
|
74
76
|
},
|
|
75
77
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
let resolution;
|
|
79
|
+
const reference = parseBuildReference(requestedBuild);
|
|
80
|
+
if (reference.ok && reference.reference.kind === "pull-request") {
|
|
81
|
+
const resolved = await resolvePrBuild(context, { pr: reference.reference.number });
|
|
82
|
+
if (!resolved.ok) {
|
|
83
|
+
const { key, data } = prBuildRefusalFacts(resolved.refusal);
|
|
84
|
+
// Each key names one of the four errors, with that error's data.
|
|
85
|
+
switch (key) {
|
|
86
|
+
case "pullRequestUnreadable":
|
|
87
|
+
return outcomes.pullRequestUnreadable(data);
|
|
88
|
+
case "prBuildsUnlisted":
|
|
89
|
+
return outcomes.prBuildsUnlisted(data);
|
|
90
|
+
case "prBuildNotReady":
|
|
91
|
+
return outcomes.prBuildNotReady(data);
|
|
92
|
+
case "prBuildExpired":
|
|
93
|
+
return outcomes.prBuildExpired(data);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
resolution = resolved.resolution;
|
|
97
|
+
await ui.progress?.(`${TESTSERVER_REPO}#${resolution.pr} at ${shortSha(resolution.headSha)} → build ${resolution.build}`);
|
|
82
98
|
}
|
|
99
|
+
const build = resolution?.build ?? requestedBuild;
|
|
100
|
+
const got = await credential.get();
|
|
101
|
+
if (!got.ok)
|
|
102
|
+
return credentialFailed(got.failure);
|
|
83
103
|
await ui.progress?.(`Creating a Testserver sandbox on ${build}…`);
|
|
84
104
|
const progress = ui.progress;
|
|
85
|
-
const created = await createPooledSandbox(app.context, { credential: got.credential, build, ttlMinutes, lease: false }, progress === undefined ? {} : { onProgress: (message) => progress(` ${message}`) });
|
|
105
|
+
const created = await createPooledSandbox(app.context, { credential: got.credential, build, requestedBuild, ttlMinutes, lease: false }, progress === undefined ? {} : { onProgress: (message) => progress(` ${message}`) });
|
|
106
|
+
const pullRequest = resolution === undefined ? null : { repo: TESTSERVER_REPO, number: resolution.pr, headSha: resolution.headSha };
|
|
86
107
|
switch (created.kind) {
|
|
87
108
|
case "pooled":
|
|
88
|
-
return outcomes.created({ ...sandboxFacts(created.entry), configFile });
|
|
109
|
+
return outcomes.created({ ...sandboxFacts(created.entry), pullRequest, configFile });
|
|
89
110
|
case "pool-write-failed":
|
|
90
111
|
return outcomes.poolWriteFailed({
|
|
91
112
|
...sandboxFacts(created.entry),
|
|
113
|
+
pullRequest,
|
|
92
114
|
configFile,
|
|
93
115
|
path: created.failure.path,
|
|
94
116
|
message: created.failure.message,
|
|
@@ -99,6 +121,25 @@ export function command(cmd) {
|
|
|
99
121
|
},
|
|
100
122
|
});
|
|
101
123
|
}
|
|
124
|
+
/** The `--build` problems the Testserver pool's `build` rule finds, as `validate` reports them. */
|
|
125
|
+
function buildProblems(build) {
|
|
126
|
+
const checked = testserverPoolConfig.options.build.check(build);
|
|
127
|
+
return checked.ok ? [] : checked.problems.map(({ problem }) => ({ field: "build", message: `--build ${problem}.` }));
|
|
128
|
+
}
|
|
129
|
+
/** `--build` as the Testserver pool's `build` rule settles it: a PR build reference as `pr:<N>`. */
|
|
130
|
+
function settledBuild(build) {
|
|
131
|
+
const checked = testserverPoolConfig.options.build.check(build);
|
|
132
|
+
// `validate` refused every `--build` the rule refuses.
|
|
133
|
+
if (!checked.ok)
|
|
134
|
+
throw new Error(`--build ${build} should have been refused`);
|
|
135
|
+
return checked.value;
|
|
136
|
+
}
|
|
137
|
+
/** The outcome of a credential source that couldn't give a credential. */
|
|
138
|
+
function credentialFailed(failure) {
|
|
139
|
+
return failure.source === "mint"
|
|
140
|
+
? outcomes.mintFailed({ ...failure.target, ...describeMintFailure(failure.failure, failure.target) })
|
|
141
|
+
: outcomes.tokenRequestFailed(tokenRequestFailureFacts(failure.failure));
|
|
142
|
+
}
|
|
102
143
|
function sandboxFacts(entry) {
|
|
103
144
|
const { testserverUrl, logViewerUrl, requestedBuild, resolvedBuild, ttlMinutes } = entry;
|
|
104
145
|
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,
|
|
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
|
|
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.",
|