@theholocron/holocron-plugin-vercel 5.0.0-alpha.278 → 5.0.0-alpha.279

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 CHANGED
@@ -1,5 +1,6 @@
1
1
  import { AuthError, DeployFunctionConfig, DeployFunctionResult, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, DnsRecordRequest, PluginToken, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
2
2
  import { VercelClient, VercelClient as VercelClient$1, VercelClientOptions, createVercelClient } from "@theholocron/vercel-client";
3
+ /** Resolves the Vercel token from `--token`, `HOLOCRON_VERCEL_TOKEN`, `VERCEL_TOKEN` or the keyring, and throws an `AuthError` when none is set. */
3
4
  export declare const resolveToken: import("@theholocron/cli").TokenResolver;
4
5
  /** Every token this plugin takes, for `holocron doctor tokens`. */
5
6
  export declare const tokens: PluginToken[];
@@ -9,13 +10,17 @@ interface DeploymentOptions {
9
10
  /** Custom domain that `holocron repo setup` should attach to this project. */
10
11
  domain?: string;
11
12
  }
13
+ /** The `deployment` capability for Vercel: projects, environment variables, deployments, functions and custom domains. */
12
14
  export declare class VercelDeployment implements Deployment {
13
15
  private readonly client;
16
+ /** The capability key, always `deployment`. */
14
17
  readonly key: "deployment";
18
+ /** The provider name, `vercel`. */
15
19
  readonly providerName = "vercel";
16
20
  readonly domain?: string;
17
21
  private readonly defaultFramework;
18
22
  constructor(client: () => VercelClient$1, opts?: DeploymentOptions);
23
+ /** Lists the projects the token can see, mapped to the provider-neutral shape. */
19
24
  listProjects(): Promise<DeploymentProject[]>;
20
25
  ensureProject(input: {
21
26
  name: string;
@@ -23,14 +28,18 @@ export declare class VercelDeployment implements Deployment {
23
28
  repo?: string;
24
29
  rootDirectory?: string;
25
30
  }): Promise<DeploymentProject>;
31
+ /** Updates a project's preview-deployment and Git-provider deployment settings and returns the updated project. */
26
32
  updateProjectSettings(projectId: string, settings: DeploymentProjectSettings): Promise<DeploymentProject>;
33
+ /** Lists the names of the project's environment variables that apply to `target`. */
27
34
  listEnvVars(projectId: string, target: DeploymentTarget): Promise<string[]>;
35
+ /** Creates or updates (upsert) an environment variable on the project for `target`. */
28
36
  setEnvVar(projectId: string, target: DeploymentTarget, name: string, value: string): Promise<void>;
29
37
  triggerDeployment(input: {
30
38
  projectId: string;
31
39
  branch: string;
32
40
  target?: DeploymentTrigger;
33
41
  }): Promise<DeploymentRecord>;
42
+ /** Fetches a deployment by id; the record's branch is the deployment's Git commit ref, or `null` when it has none. */
34
43
  getDeployment(deploymentId: string): Promise<DeploymentRecord>;
35
44
  deployFunction(projectId: string, config: DeployFunctionConfig): Promise<DeployFunctionResult>;
36
45
  /**
@@ -59,7 +68,9 @@ interface VerifyTokenOptions {
59
68
  baseUrl?: string;
60
69
  fetch?: typeof fetch;
61
70
  }
71
+ /** Checks a Vercel token by fetching the current user; the success subject is `user @` followed by the email, username, name or id, the failure carries the error message. */
62
72
  export declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
73
+ /** Options for the Vercel plugin: token resolution, team, defaults for new projects and test overrides. */
63
74
  export interface VercelPluginOptions extends ResolveTokenInput {
64
75
  /** Vercel team id. Set when working with a team-owned project. */
65
76
  teamId?: string;
@@ -72,12 +83,18 @@ export interface VercelPluginOptions extends ResolveTokenInput {
72
83
  /** Override `fetch` for tests. */
73
84
  fetch?: typeof fetch;
74
85
  }
86
+ /** What the plugin's capabilities share: the options and a lazily built client. */
75
87
  export interface PluginContext {
88
+ /** The options the plugin was created with. */
76
89
  options: VercelPluginOptions;
90
+ /** Builds the Vercel client on first call and reuses it; the token is resolved then, not at plugin load. */
77
91
  client: () => VercelClient;
78
92
  }
93
+ /** Creates the shared context for the given options; no token is resolved until `client()` is first called. */
79
94
  export declare function createContext(options?: VercelPluginOptions): PluginContext;
95
+ /** Builds the `deployment` capability from a plugin context, passing on `defaultFramework` and `domain` when set. */
80
96
  export declare function deployment(ctx: PluginContext): Deployment;
97
+ /** Creates the Vercel plugin: a `connection` probe and the `deployment` capability. */
81
98
  export declare function createPlugin(options?: VercelPluginOptions): {
82
99
  name: string;
83
100
  probes: {
package/dist/index.mjs CHANGED
@@ -2,6 +2,7 @@ import { AuthError, ProviderApiError, connectionProbe, createResolveToken } from
2
2
  import { createVercelClient } from "@theholocron/vercel-client";
3
3
  import { errorMessage } from "@theholocron/misc-utils";
4
4
  // src/auth.ts
5
+ /** Resolves the Vercel token from `--token`, `HOLOCRON_VERCEL_TOKEN`, `VERCEL_TOKEN` or the keyring, and throws an `AuthError` when none is set. */
5
6
  const resolveToken = createResolveToken({
6
7
  envName: "HOLOCRON_VERCEL_TOKEN",
7
8
  vendorEnvName: "VERCEL_TOKEN",
@@ -11,9 +12,12 @@ const resolveToken = createResolveToken({
11
12
  /** Every token this plugin takes, for `holocron doctor tokens`. */
12
13
  const tokens = [resolveToken.token];
13
14
  // src/capabilities/deployment.ts
15
+ /** The `deployment` capability for Vercel: projects, environment variables, deployments, functions and custom domains. */
14
16
  var VercelDeployment = class {
15
17
  client;
18
+ /** The capability key, always `deployment`. */
16
19
  key = "deployment";
20
+ /** The provider name, `vercel`. */
17
21
  providerName = "vercel";
18
22
  domain;
19
23
  defaultFramework;
@@ -22,6 +26,7 @@ var VercelDeployment = class {
22
26
  this.defaultFramework = opts.defaultFramework ?? "nextjs";
23
27
  this.domain = opts.domain;
24
28
  }
29
+ /** Lists the projects the token can see, mapped to the provider-neutral shape. */
25
30
  async listProjects() {
26
31
  const { projects } = await this.client().projects.list();
27
32
  return projects.map(mapProject);
@@ -36,16 +41,19 @@ var VercelDeployment = class {
36
41
  rootDirectory: input.rootDirectory
37
42
  }));
38
43
  }
44
+ /** Updates a project's preview-deployment and Git-provider deployment settings and returns the updated project. */
39
45
  async updateProjectSettings(projectId, settings) {
40
46
  return mapProject(await this.client().projects.update(projectId, {
41
47
  previewDeploymentsDisabled: settings.previewDeploymentsDisabled,
42
48
  gitProviderOptions: settings.gitProviderCreateDeployments !== void 0 ? { createDeployments: settings.gitProviderCreateDeployments } : void 0
43
49
  }));
44
50
  }
51
+ /** Lists the names of the project's environment variables that apply to `target`. */
45
52
  async listEnvVars(projectId, target) {
46
53
  const { envs } = await this.client().env.list(projectId);
47
54
  return envs.filter((e) => e.target.includes(target)).map((e) => e.key);
48
55
  }
56
+ /** Creates or updates (upsert) an environment variable on the project for `target`. */
49
57
  async setEnvVar(projectId, target, name, value) {
50
58
  await this.client().env.set(projectId, target, name, value);
51
59
  }
@@ -60,6 +68,7 @@ var VercelDeployment = class {
60
68
  target: input.target
61
69
  }), input.branch);
62
70
  }
71
+ /** Fetches a deployment by id; the record's branch is the deployment's Git commit ref, or `null` when it has none. */
63
72
  async getDeployment(deploymentId) {
64
73
  const raw = await this.client().deployments.get(deploymentId);
65
74
  return mapDeployment(raw, raw.meta?.githubCommitRef ?? null);
@@ -163,6 +172,7 @@ function normalizeState(s) {
163
172
  }
164
173
  }
165
174
  // src/verify-token.ts
175
+ /** Checks a Vercel token by fetching the current user; the success subject is `user @` followed by the email, username, name or id, the failure carries the error message. */
166
176
  async function verifyToken(token, opts = {}) {
167
177
  const client = createVercelClient({
168
178
  token,
@@ -183,6 +193,7 @@ async function verifyToken(token, opts = {}) {
183
193
  }
184
194
  }
185
195
  // src/index.ts
196
+ /** Creates the shared context for the given options; no token is resolved until `client()` is first called. */
186
197
  function createContext(options = {}) {
187
198
  let client;
188
199
  return {
@@ -195,12 +206,14 @@ function createContext(options = {}) {
195
206
  })
196
207
  };
197
208
  }
209
+ /** Builds the `deployment` capability from a plugin context, passing on `defaultFramework` and `domain` when set. */
198
210
  function deployment(ctx) {
199
211
  const opts = {};
200
212
  if (ctx.options.defaultFramework !== void 0) opts.defaultFramework = ctx.options.defaultFramework;
201
213
  if (ctx.options.domain !== void 0) opts.domain = ctx.options.domain;
202
214
  return new VercelDeployment(ctx.client, opts);
203
215
  }
216
+ /** Creates the Vercel plugin: a `connection` probe and the `deployment` capability. */
204
217
  function createPlugin(options = {}) {
205
218
  const ctx = createContext(options);
206
219
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-vercel",
3
- "version": "5.0.0-alpha.278",
3
+ "version": "5.0.0-alpha.279",
4
4
  "description": "Holocron plugin for Vercel. Implements the deployment capability against the Vercel REST API.",
5
5
  "keywords": [
6
6
  "deployment",
@@ -40,19 +40,19 @@
40
40
  "tsx": "4.23.15",
41
41
  "typescript": "^5.9.3",
42
42
  "vitest": "^5.0.5",
43
- "@theholocron/cli": "5.0.0-alpha.278",
44
- "@theholocron/http-client": "^1.58.0-alpha.3",
43
+ "@theholocron/cli": "5.0.0-alpha.279",
45
44
  "@theholocron/eslint-config": "^8.9.0-alpha.4",
46
- "@theholocron/misc-utils": "^1.16.1-alpha.3",
45
+ "@theholocron/http-client": "^1.58.0-alpha.3",
47
46
  "@theholocron/tsconfig": "^8.9.0-alpha.4",
48
- "@theholocron/vercel-client": "^1.58.0-alpha.3",
49
47
  "@theholocron/tsdown-config": "^8.9.0-alpha.4",
50
- "@theholocron/vitest-config": "^8.9.0-alpha.4"
48
+ "@theholocron/vercel-client": "^1.58.0-alpha.3",
49
+ "@theholocron/vitest-config": "^8.9.0-alpha.4",
50
+ "@theholocron/misc-utils": "^1.16.1-alpha.3"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@theholocron/misc-utils": "^1.16.0",
54
54
  "@theholocron/vercel-client": "^1.43.1",
55
- "@theholocron/cli": "5.0.0-alpha.278"
55
+ "@theholocron/cli": "5.0.0-alpha.279"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "@theholocron/vercel-client": {}