@theholocron/vercel-client 1.32.0 → 1.33.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/index.d.mts +191 -0
- package/dist/index.mjs +138 -0
- package/package.json +3 -3
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import "@theholocron/http-client";
|
|
2
|
+
import { ErrorSink, Logger } from "@theholocron/observability/core";
|
|
3
|
+
//#region ../../../../../src/utils.d.ts
|
|
4
|
+
interface VercelClientOptions {
|
|
5
|
+
/** Vercel API token. */
|
|
6
|
+
token: string;
|
|
7
|
+
/** Team ID — appended as `?teamId=` on every request. Omit for personal accounts. */
|
|
8
|
+
teamId?: string;
|
|
9
|
+
/** Override base URL for testing. Defaults to https://api.vercel.com. */
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
/** Override fetch for testing. Defaults to globalThis.fetch. */
|
|
12
|
+
fetch?: typeof fetch;
|
|
13
|
+
/** Structured logger for request/response diagnostics. Defaults to a no-op. */
|
|
14
|
+
logger?: Logger;
|
|
15
|
+
/** Reports transport failures and unexpected 5xx. Defaults to a no-op. */
|
|
16
|
+
errors?: ErrorSink;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region ../../../../../src/deployments/deployments.d.ts
|
|
20
|
+
type VercelDeploymentState = "INITIALIZING" | "QUEUED" | "BUILDING" | "READY" | "ERROR" | "CANCELED";
|
|
21
|
+
type VercelDeploymentTarget = "production" | "staging";
|
|
22
|
+
interface VercelDeployment {
|
|
23
|
+
id: string;
|
|
24
|
+
url: string;
|
|
25
|
+
readyState: VercelDeploymentState;
|
|
26
|
+
target?: VercelDeploymentTarget | null;
|
|
27
|
+
meta?: {
|
|
28
|
+
githubCommitRef?: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
interface VercelTriggerDeploymentInput {
|
|
32
|
+
projectName: string;
|
|
33
|
+
branch: string;
|
|
34
|
+
repoId: number;
|
|
35
|
+
target?: VercelDeploymentTarget;
|
|
36
|
+
}
|
|
37
|
+
/** One file for `deployments.create()` — content is sent inline, base64-encoded. */
|
|
38
|
+
interface VercelDeployFile {
|
|
39
|
+
/** Path relative to the project root, e.g. "api/webhook.js". */
|
|
40
|
+
file: string;
|
|
41
|
+
/** File content, plain text — base64-encoded by `create()` before the request goes out. */
|
|
42
|
+
content: string;
|
|
43
|
+
}
|
|
44
|
+
interface VercelCreateDeploymentInput {
|
|
45
|
+
projectName: string;
|
|
46
|
+
files: VercelDeployFile[];
|
|
47
|
+
/**
|
|
48
|
+
* `projectSettings.framework`. `null` (the default) deploys with no
|
|
49
|
+
* framework preset — the right choice for a bare serverless function,
|
|
50
|
+
* not an app. Vercel requires this on a project's first deployment;
|
|
51
|
+
* later deployments inherit it unless overridden here again.
|
|
52
|
+
*/
|
|
53
|
+
framework?: string | null;
|
|
54
|
+
target?: VercelDeploymentTarget;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region ../../../../../src/domains/domains.d.ts
|
|
58
|
+
interface VercelDomain {
|
|
59
|
+
name: string;
|
|
60
|
+
apexName: string;
|
|
61
|
+
verified: boolean;
|
|
62
|
+
}
|
|
63
|
+
interface VercelDomainsResponse {
|
|
64
|
+
domains: VercelDomain[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* One DNS verification challenge — complete any one of these (usually
|
|
68
|
+
* just one is returned) to prove ownership. `type: "CNAME"` means
|
|
69
|
+
* `domain` needs a CNAME record pointing at `value`; `type: "TXT"`
|
|
70
|
+
* means a TXT record on `domain` with content `value`. The CNAME
|
|
71
|
+
* target is generated per-project by Vercel, not a fixed well-known
|
|
72
|
+
* host — always read it from this response, never hardcode it.
|
|
73
|
+
*/
|
|
74
|
+
interface VercelDomainVerification {
|
|
75
|
+
type: string;
|
|
76
|
+
domain: string;
|
|
77
|
+
value: string;
|
|
78
|
+
reason: string;
|
|
79
|
+
}
|
|
80
|
+
interface VercelAddDomainResult {
|
|
81
|
+
name: string;
|
|
82
|
+
apexName: string;
|
|
83
|
+
verified: boolean;
|
|
84
|
+
verification?: VercelDomainVerification[];
|
|
85
|
+
}
|
|
86
|
+
/** One ranked CNAME/IPv4 recommendation — `rank: 1` is the preferred value. */
|
|
87
|
+
interface VercelDomainConfigRecommendation<T> {
|
|
88
|
+
rank: number;
|
|
89
|
+
value: T;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* DNS *routing* status for a domain — distinct from ownership (`verified`
|
|
93
|
+
* on `VercelDomain`/`VercelAddDomainResult`). A domain can be verified
|
|
94
|
+
* (Vercel trusts you own it) with no record actually pointing traffic at
|
|
95
|
+
* Vercel yet, e.g. re-adding a domain whose apex is already verified on
|
|
96
|
+
* this team short-circuits to `verified: true` with no `verification`
|
|
97
|
+
* challenge (`domains.add` returns 409, not a fresh challenge) — this is
|
|
98
|
+
* the only source for that domain's CNAME target in that case.
|
|
99
|
+
*/
|
|
100
|
+
interface VercelDomainConfig {
|
|
101
|
+
/** How Vercel currently sees the domain resolving. `null` = not resolving to Vercel at all. */
|
|
102
|
+
configuredBy: "A" | "CNAME" | "http" | "dns-01" | null;
|
|
103
|
+
/** `false` once DNS is correctly configured and a TLS cert can be issued. */
|
|
104
|
+
misconfigured: boolean;
|
|
105
|
+
/** Recommended CNAME target(s) for a subdomain, ranked; `[0]` is preferred. Per-project, never a fixed host. */
|
|
106
|
+
recommendedCNAME: VercelDomainConfigRecommendation<string>[];
|
|
107
|
+
/** Recommended A-record IPv4(s) for an apex domain, ranked. */
|
|
108
|
+
recommendedIPv4: VercelDomainConfigRecommendation<string[]>[];
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region ../../../../../src/env/env.d.ts
|
|
112
|
+
type VercelEnvTarget = "production" | "preview" | "development";
|
|
113
|
+
interface VercelEnvVar {
|
|
114
|
+
id: string;
|
|
115
|
+
key: string;
|
|
116
|
+
target: VercelEnvTarget[];
|
|
117
|
+
}
|
|
118
|
+
interface VercelEnvVarsResponse {
|
|
119
|
+
envs: VercelEnvVar[];
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region ../../../../../src/projects/projects.d.ts
|
|
123
|
+
interface VercelProjectLink {
|
|
124
|
+
type?: string;
|
|
125
|
+
repoId?: number;
|
|
126
|
+
repo?: string;
|
|
127
|
+
org?: string;
|
|
128
|
+
}
|
|
129
|
+
interface VercelProject {
|
|
130
|
+
id: string;
|
|
131
|
+
name: string;
|
|
132
|
+
framework?: string | null;
|
|
133
|
+
rootDirectory?: string | null;
|
|
134
|
+
link?: VercelProjectLink | null;
|
|
135
|
+
}
|
|
136
|
+
interface VercelProjectsResponse {
|
|
137
|
+
projects: VercelProject[];
|
|
138
|
+
}
|
|
139
|
+
interface VercelCreateProjectInput {
|
|
140
|
+
name: string;
|
|
141
|
+
framework?: string;
|
|
142
|
+
repo?: string;
|
|
143
|
+
rootDirectory?: string;
|
|
144
|
+
}
|
|
145
|
+
interface VercelUpdateProjectInput {
|
|
146
|
+
previewDeploymentsDisabled?: boolean;
|
|
147
|
+
gitProviderOptions?: {
|
|
148
|
+
createDeployments?: boolean | string;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region ../../../../../src/user/user.d.ts
|
|
153
|
+
interface VercelUser {
|
|
154
|
+
id?: string;
|
|
155
|
+
username?: string;
|
|
156
|
+
email?: string;
|
|
157
|
+
name?: string;
|
|
158
|
+
}
|
|
159
|
+
interface VercelUserResponse {
|
|
160
|
+
user?: VercelUser;
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region ../../../../../src/index.d.ts
|
|
164
|
+
declare function createVercelClient(opts: VercelClientOptions): {
|
|
165
|
+
deployments: {
|
|
166
|
+
trigger: (input: VercelTriggerDeploymentInput) => Promise<VercelDeployment>;
|
|
167
|
+
create: (input: VercelCreateDeploymentInput) => Promise<VercelDeployment>;
|
|
168
|
+
get: (deploymentId: string) => Promise<VercelDeployment>;
|
|
169
|
+
};
|
|
170
|
+
domains: {
|
|
171
|
+
list: (projectId: string) => Promise<VercelDomainsResponse>;
|
|
172
|
+
add: (projectId: string, name: string) => Promise<VercelAddDomainResult>;
|
|
173
|
+
config: (domain: string, projectIdOrName?: string) => Promise<VercelDomainConfig>;
|
|
174
|
+
};
|
|
175
|
+
env: {
|
|
176
|
+
list: (projectId: string) => Promise<VercelEnvVarsResponse>;
|
|
177
|
+
set: (projectId: string, target: VercelEnvTarget, name: string, value: string) => Promise<VercelEnvVar>;
|
|
178
|
+
};
|
|
179
|
+
projects: {
|
|
180
|
+
list: () => Promise<VercelProjectsResponse>;
|
|
181
|
+
get: (nameOrId: string) => Promise<VercelProject>;
|
|
182
|
+
create: (input: VercelCreateProjectInput) => Promise<VercelProject>;
|
|
183
|
+
update: (projectId: string, input: VercelUpdateProjectInput) => Promise<VercelProject>;
|
|
184
|
+
};
|
|
185
|
+
user: {
|
|
186
|
+
get: () => Promise<VercelUserResponse>;
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
type VercelClient = ReturnType<typeof createVercelClient>;
|
|
190
|
+
//#endregion
|
|
191
|
+
export { type VercelAddDomainResult, VercelClient, type VercelClientOptions, type VercelCreateDeploymentInput, type VercelCreateProjectInput, type VercelDeployFile, type VercelDeployment, type VercelDeploymentState, type VercelDeploymentTarget, type VercelDomain, type VercelDomainConfig, type VercelDomainConfigRecommendation, type VercelDomainVerification, type VercelDomainsResponse, type VercelEnvTarget, type VercelEnvVar, type VercelEnvVarsResponse, type VercelProject, type VercelProjectLink, type VercelProjectsResponse, type VercelTriggerDeploymentInput, type VercelUpdateProjectInput, type VercelUser, type VercelUserResponse, createVercelClient };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { createRestClient } from "@theholocron/http-client";
|
|
2
|
+
//#region ../../../../../src/deployments/deployments.ts
|
|
3
|
+
function deployments(rest) {
|
|
4
|
+
return {
|
|
5
|
+
trigger: (input) => rest.request("/v13/deployments", {
|
|
6
|
+
method: "POST",
|
|
7
|
+
body: {
|
|
8
|
+
name: input.projectName,
|
|
9
|
+
gitSource: {
|
|
10
|
+
type: "github",
|
|
11
|
+
ref: input.branch,
|
|
12
|
+
repoId: input.repoId
|
|
13
|
+
},
|
|
14
|
+
...input.target ? { target: input.target } : {}
|
|
15
|
+
}
|
|
16
|
+
}),
|
|
17
|
+
/**
|
|
18
|
+
* Create a deployment directly from source files — no `gitSource`,
|
|
19
|
+
* no linked repo required. The non-git counterpart to `trigger()`,
|
|
20
|
+
* for a consumer with no repo to deploy from (a webhook receiver
|
|
21
|
+
* bundled and shipped as an npm package, for instance).
|
|
22
|
+
*/
|
|
23
|
+
create: (input) => rest.request("/v13/deployments", {
|
|
24
|
+
method: "POST",
|
|
25
|
+
body: {
|
|
26
|
+
name: input.projectName,
|
|
27
|
+
files: input.files.map((f) => ({
|
|
28
|
+
file: f.file,
|
|
29
|
+
data: Buffer.from(f.content, "utf8").toString("base64"),
|
|
30
|
+
encoding: "base64"
|
|
31
|
+
})),
|
|
32
|
+
projectSettings: { framework: input.framework ?? null },
|
|
33
|
+
...input.target ? { target: input.target } : {}
|
|
34
|
+
}
|
|
35
|
+
}),
|
|
36
|
+
get: (deploymentId) => rest.request(`/v13/deployments/${encodeURIComponent(deploymentId)}`)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region ../../../../../src/domains/domains.ts
|
|
41
|
+
function domains(rest) {
|
|
42
|
+
return {
|
|
43
|
+
list: (projectId) => rest.request(`/v9/projects/${encodeURIComponent(projectId)}/domains`),
|
|
44
|
+
add: (projectId, name) => rest.request(`/v10/projects/${encodeURIComponent(projectId)}/domains`, {
|
|
45
|
+
method: "POST",
|
|
46
|
+
body: { name }
|
|
47
|
+
}),
|
|
48
|
+
/**
|
|
49
|
+
* DNS routing status for `domain` — works regardless of whether the
|
|
50
|
+
* domain is already attached/verified on a project. `projectIdOrName`
|
|
51
|
+
* is optional per Vercel's docs ("use this when the domain is not yet
|
|
52
|
+
* associated with a project") but passed through when known to scope
|
|
53
|
+
* the recommendation to that project.
|
|
54
|
+
*/
|
|
55
|
+
config: (domain, projectIdOrName) => rest.request(`/v6/domains/${encodeURIComponent(domain)}/config`, { query: projectIdOrName ? { projectIdOrName } : void 0 })
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region ../../../../../src/env/env.ts
|
|
60
|
+
function env(rest) {
|
|
61
|
+
return {
|
|
62
|
+
list: (projectId) => rest.request(`/v9/projects/${encodeURIComponent(projectId)}/env`),
|
|
63
|
+
set: (projectId, target, name, value) => rest.request(`/v10/projects/${encodeURIComponent(projectId)}/env`, {
|
|
64
|
+
method: "POST",
|
|
65
|
+
query: { upsert: "true" },
|
|
66
|
+
body: {
|
|
67
|
+
key: name,
|
|
68
|
+
value,
|
|
69
|
+
target: [target],
|
|
70
|
+
type: "encrypted"
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region ../../../../../src/projects/projects.ts
|
|
77
|
+
function projects(rest) {
|
|
78
|
+
return {
|
|
79
|
+
list: () => rest.request("/v10/projects"),
|
|
80
|
+
get: (nameOrId) => rest.request(`/v10/projects/${encodeURIComponent(nameOrId)}`),
|
|
81
|
+
create: (input) => {
|
|
82
|
+
const body = {
|
|
83
|
+
name: input.name,
|
|
84
|
+
...input.framework !== void 0 ? { framework: input.framework } : {},
|
|
85
|
+
...input.repo ? { gitRepository: {
|
|
86
|
+
type: "github",
|
|
87
|
+
repo: input.repo
|
|
88
|
+
} } : {},
|
|
89
|
+
...input.rootDirectory ? { rootDirectory: input.rootDirectory } : {}
|
|
90
|
+
};
|
|
91
|
+
return rest.request("/v11/projects", {
|
|
92
|
+
method: "POST",
|
|
93
|
+
body
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
update: (projectId, input) => {
|
|
97
|
+
const body = {};
|
|
98
|
+
if (input.previewDeploymentsDisabled !== void 0) body.previewDeploymentsDisabled = input.previewDeploymentsDisabled;
|
|
99
|
+
if (input.gitProviderOptions !== void 0) body.gitProviderOptions = input.gitProviderOptions;
|
|
100
|
+
return rest.request(`/v9/projects/${encodeURIComponent(projectId)}`, {
|
|
101
|
+
method: "PATCH",
|
|
102
|
+
body
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region ../../../../../src/user/user.ts
|
|
109
|
+
function user(rest) {
|
|
110
|
+
return { get: () => rest.request("/v2/user") };
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region ../../../../../src/utils.ts
|
|
114
|
+
function createVercelRestClient(opts) {
|
|
115
|
+
return createRestClient({
|
|
116
|
+
baseUrl: opts.baseUrl ?? "https://api.vercel.com",
|
|
117
|
+
token: opts.token,
|
|
118
|
+
defaultQuery: opts.teamId ? { teamId: opts.teamId } : void 0,
|
|
119
|
+
vendor: "Vercel",
|
|
120
|
+
fetch: opts.fetch,
|
|
121
|
+
logger: opts.logger,
|
|
122
|
+
errors: opts.errors
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region ../../../../../src/index.ts
|
|
127
|
+
function createVercelClient(opts) {
|
|
128
|
+
const rest = createVercelRestClient(opts);
|
|
129
|
+
return {
|
|
130
|
+
deployments: deployments(rest),
|
|
131
|
+
domains: domains(rest),
|
|
132
|
+
env: env(rest),
|
|
133
|
+
projects: projects(rest),
|
|
134
|
+
user: user(rest)
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
export { createVercelClient };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/vercel-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.33.0",
|
|
4
4
|
"description": "A TypeScript client for the Vercel API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vercel",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@theholocron/observability": "^0.3.0",
|
|
36
|
-
"@theholocron/http-client": "^1.
|
|
36
|
+
"@theholocron/http-client": "^1.33.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@theholocron/cli": "5.0.0-alpha.79",
|
|
40
40
|
"@theholocron/eslint-config": "^8.4.3",
|
|
41
41
|
"@theholocron/tsconfig": "^8.2.0",
|
|
42
|
-
"@theholocron/tsdown-config": "^8.
|
|
42
|
+
"@theholocron/tsdown-config": "^8.6.1",
|
|
43
43
|
"@theholocron/vitest-config": "^8.2.0",
|
|
44
44
|
"@types/node": "^26.4.1",
|
|
45
45
|
"@vitest/coverage-v8": "^5.0.0",
|