@theholocron/vercel-client 1.21.0 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -45,7 +45,7 @@ const { envs } = await vercel.env.list("project-id");
45
45
  // Set (upsert) an env var
46
46
  await vercel.env.set("project-id", "production", "API_URL", "https://api.example.com");
47
47
 
48
- // Trigger a deployment
48
+ // Trigger a deployment (requires a project linked to a Git repo)
49
49
  const deployment = await vercel.deployments.trigger({
50
50
  projectName: "my-app",
51
51
  branch: "main",
@@ -53,8 +53,26 @@ const deployment = await vercel.deployments.trigger({
53
53
  target: "production",
54
54
  });
55
55
 
56
+ // Create a deployment directly from source files — no linked repo required
57
+ const fnDeployment = await vercel.deployments.create({
58
+ projectName: "my-fn",
59
+ files: [{ file: "api/webhook.js", content: "export default () => new Response('ok');" }],
60
+ framework: null, // no framework preset — a bare function, not an app
61
+ target: "production",
62
+ });
63
+
56
64
  // Poll deployment status
57
65
  const status = await vercel.deployments.get(deployment.id);
66
+
67
+ // List a project's custom domains
68
+ const { domains } = await vercel.domains.list("project-id");
69
+
70
+ // Add a custom domain — the CNAME target is generated per-project by
71
+ // Vercel, not a fixed well-known host; always read it from the response
72
+ const added = await vercel.domains.add("project-id", "sentinel.example.com");
73
+ if (!added.verified) {
74
+ console.log(added.verification); // [{ type: "CNAME", domain, value }]
75
+ }
58
76
  ```
59
77
 
60
78
  ## Status
package/dist/index.d.mts CHANGED
@@ -34,6 +34,55 @@ interface VercelTriggerDeploymentInput {
34
34
  repoId: number;
35
35
  target?: VercelDeploymentTarget;
36
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
+ }
37
86
  //#endregion
38
87
  //#region src/env/env.d.ts
39
88
  type VercelEnvTarget = "production" | "preview" | "development";
@@ -91,8 +140,13 @@ interface VercelUserResponse {
91
140
  declare function createVercelClient(opts: VercelClientOptions): {
92
141
  deployments: {
93
142
  trigger: (input: VercelTriggerDeploymentInput) => Promise<VercelDeployment>;
143
+ create: (input: VercelCreateDeploymentInput) => Promise<VercelDeployment>;
94
144
  get: (deploymentId: string) => Promise<VercelDeployment>;
95
145
  };
146
+ domains: {
147
+ list: (projectId: string) => Promise<VercelDomainsResponse>;
148
+ add: (projectId: string, name: string) => Promise<VercelAddDomainResult>;
149
+ };
96
150
  env: {
97
151
  list: (projectId: string) => Promise<VercelEnvVarsResponse>;
98
152
  set: (projectId: string, target: VercelEnvTarget, name: string, value: string) => Promise<VercelEnvVar>;
@@ -109,4 +163,4 @@ declare function createVercelClient(opts: VercelClientOptions): {
109
163
  };
110
164
  type VercelClient = ReturnType<typeof createVercelClient>;
111
165
  //#endregion
112
- export { VercelClient, type VercelClientOptions, type VercelCreateProjectInput, type VercelDeployment, type VercelDeploymentState, type VercelDeploymentTarget, type VercelEnvTarget, type VercelEnvVar, type VercelEnvVarsResponse, type VercelProject, type VercelProjectLink, type VercelProjectsResponse, type VercelTriggerDeploymentInput, type VercelUpdateProjectInput, type VercelUser, type VercelUserResponse, createVercelClient };
166
+ export { type VercelAddDomainResult, VercelClient, type VercelClientOptions, type VercelCreateDeploymentInput, type VercelCreateProjectInput, type VercelDeployFile, type VercelDeployment, type VercelDeploymentState, type VercelDeploymentTarget, type VercelDomain, 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 CHANGED
@@ -14,10 +14,40 @@ function deployments(rest) {
14
14
  ...input.target ? { target: input.target } : {}
15
15
  }
16
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
+ }),
17
36
  get: (deploymentId) => rest.request(`/v13/deployments/${encodeURIComponent(deploymentId)}`)
18
37
  };
19
38
  }
20
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
+ }
50
+ //#endregion
21
51
  //#region src/env/env.ts
22
52
  function env(rest) {
23
53
  return {
@@ -90,6 +120,7 @@ function createVercelClient(opts) {
90
120
  const rest = createVercelRestClient(opts);
91
121
  return {
92
122
  deployments: deployments(rest),
123
+ domains: domains(rest),
93
124
  env: env(rest),
94
125
  projects: projects(rest),
95
126
  user: user(rest)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/vercel-client",
3
- "version": "1.21.0",
3
+ "version": "1.23.0",
4
4
  "description": "A TypeScript client for the Vercel API",
5
5
  "keywords": [
6
6
  "vercel",
@@ -33,7 +33,7 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@theholocron/observability": "^0.3.0",
36
- "@theholocron/http-client": "^1.21.0"
36
+ "@theholocron/http-client": "^1.23.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@theholocron/cli": "5.0.0-alpha.3",