@theholocron/vercel-client 1.20.0 → 1.22.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,6 +53,14 @@ 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);
58
66
  ```
package/dist/index.d.mts CHANGED
@@ -34,6 +34,25 @@ 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
+ }
37
56
  //#endregion
38
57
  //#region src/env/env.d.ts
39
58
  type VercelEnvTarget = "production" | "preview" | "development";
@@ -91,6 +110,7 @@ interface VercelUserResponse {
91
110
  declare function createVercelClient(opts: VercelClientOptions): {
92
111
  deployments: {
93
112
  trigger: (input: VercelTriggerDeploymentInput) => Promise<VercelDeployment>;
113
+ create: (input: VercelCreateDeploymentInput) => Promise<VercelDeployment>;
94
114
  get: (deploymentId: string) => Promise<VercelDeployment>;
95
115
  };
96
116
  env: {
@@ -109,4 +129,4 @@ declare function createVercelClient(opts: VercelClientOptions): {
109
129
  };
110
130
  type VercelClient = ReturnType<typeof createVercelClient>;
111
131
  //#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 };
132
+ export { VercelClient, type VercelClientOptions, type VercelCreateDeploymentInput, type VercelCreateProjectInput, type VercelDeployFile, 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 };
package/dist/index.mjs CHANGED
@@ -14,6 +14,25 @@ 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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/vercel-client",
3
- "version": "1.20.0",
3
+ "version": "1.22.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.20.0"
36
+ "@theholocron/http-client": "^1.22.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@theholocron/cli": "5.0.0-alpha.3",