@theholocron/holocron-plugin-netlify 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,8 +1,10 @@
1
1
  import { AuthError, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, DnsRecordRequest, PluginToken, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
2
2
  import { NetlifyClient } from "@theholocron/netlify-client";
3
+ /** Resolves the Netlify token from `--token`, `HOLOCRON_NETLIFY_TOKEN`, `NETLIFY_AUTH_TOKEN` or the keyring entry for `netlify`, and throws `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[];
7
+ /** Options for the Netlify `deployment` capability. */
6
8
  interface NetlifyDeploymentOptions {
7
9
  /**
8
10
  * Required for `ensureProject` / `listProjects` (create/list use
@@ -17,13 +19,17 @@ interface NetlifyDeploymentOptions {
17
19
  /** Custom domain `holocron repo setup` should attach to the site. */
18
20
  domain?: string;
19
21
  }
22
+ /** `deployment` capability for Netlify, where a Holocron project is a Netlify site. */
20
23
  export declare class NetlifyDeployment implements Deployment {
21
24
  private readonly client;
22
25
  private readonly opts;
26
+ /** Capability key; always `"deployment"`. */
23
27
  readonly key: "deployment";
28
+ /** Provider name; always `"netlify"`. */
24
29
  readonly providerName = "netlify";
25
30
  readonly domain?: string;
26
31
  constructor(client: () => NetlifyClient, opts?: NetlifyDeploymentOptions);
32
+ /** Lists the sites the token can see, mapped to deployment projects. */
27
33
  listProjects(): Promise<DeploymentProject[]>;
28
34
  /** Create if missing, otherwise return existing — matched by exact name. */
29
35
  ensureProject(input: {
@@ -39,7 +45,9 @@ export declare class NetlifyDeployment implements Deployment {
39
45
  * project unchanged. Revisit if a future consumer needs a real mapping.
40
46
  */
41
47
  updateProjectSettings(projectId: string, _settings: DeploymentProjectSettings): Promise<DeploymentProject>;
48
+ /** Lists the names of the env vars that have a value for the given target; needs `accountId`. */
42
49
  listEnvVars(projectId: string, target: DeploymentTarget): Promise<string[]>;
50
+ /** Sets an env var for the given target (`production`, or the branch-deploy context for any other); needs `accountId`. */
43
51
  setEnvVar(projectId: string, target: DeploymentTarget, name: string, value: string): Promise<void>;
44
52
  /**
45
53
  * No Git integration in Sentinel's usage (file-based deploy only), but
@@ -52,6 +60,7 @@ export declare class NetlifyDeployment implements Deployment {
52
60
  branch: string;
53
61
  target?: DeploymentTrigger;
54
62
  }): Promise<DeploymentRecord>;
63
+ /** Fetches a deploy by id and maps its state to `ready`, `error` or `building`. */
55
64
  getDeployment(deploymentId: string): Promise<DeploymentRecord>;
56
65
  /**
57
66
  * Idempotent: PATCHing the same `custom_domain` twice is a no-op on
@@ -68,20 +77,27 @@ interface VerifyTokenOptions {
68
77
  baseUrl?: string;
69
78
  fetch?: typeof fetch;
70
79
  }
80
+ /** Checks a Netlify token by fetching the current user and reports who it belongs to, or why it was rejected. */
71
81
  export declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
82
+ /** Options for the Netlify plugin: the token lookup inputs plus the deployment settings. */
72
83
  export interface NetlifyPluginOptions extends ResolveTokenInput, NetlifyDeploymentOptions {
73
84
  /** Override base URL for tests. */
74
85
  baseUrl?: string;
75
86
  /** Override `fetch` for tests. */
76
87
  fetch?: typeof fetch;
77
88
  }
89
+ /** Shared state for one Netlify plugin instance: its options and a lazily created client. */
78
90
  export interface PluginContext {
91
+ /** The options the plugin was created with. */
79
92
  options: NetlifyPluginOptions;
80
93
  /** Memoized client — the token is resolved on first use, not at plugin load. */
81
94
  client: () => NetlifyClient;
82
95
  }
96
+ /** Builds the plugin context from its options. */
83
97
  export declare function createContext(options: NetlifyPluginOptions): PluginContext;
98
+ /** Builds the `deployment` capability, passing along only the account and domain options that are set. */
84
99
  export declare function deployment(ctx: PluginContext): Deployment;
100
+ /** Creates the Netlify plugin: its `connection` probe and the `deployment` capability. */
85
101
  export declare function createPlugin(options: NetlifyPluginOptions): {
86
102
  name: string;
87
103
  probes: {
package/dist/index.mjs CHANGED
@@ -3,6 +3,7 @@ import { createNetlifyClient } from "@theholocron/netlify-client";
3
3
  import { ProviderApiError } from "@theholocron/http-client";
4
4
  import { errorMessage } from "@theholocron/misc-utils";
5
5
  // src/auth.ts
6
+ /** Resolves the Netlify token from `--token`, `HOLOCRON_NETLIFY_TOKEN`, `NETLIFY_AUTH_TOKEN` or the keyring entry for `netlify`, and throws `AuthError` when none is set. */
6
7
  const resolveToken = createResolveToken({
7
8
  envName: "HOLOCRON_NETLIFY_TOKEN",
8
9
  vendorEnvName: "NETLIFY_AUTH_TOKEN",
@@ -37,10 +38,13 @@ function toDeploymentRecord(deploy) {
37
38
  function toNetlifyContext(target) {
38
39
  return target === "production" ? "production" : "branch-deploy";
39
40
  }
41
+ /** `deployment` capability for Netlify, where a Holocron project is a Netlify site. */
40
42
  var NetlifyDeployment = class {
41
43
  client;
42
44
  opts;
45
+ /** Capability key; always `"deployment"`. */
43
46
  key = "deployment";
47
+ /** Provider name; always `"netlify"`. */
44
48
  providerName = "netlify";
45
49
  domain;
46
50
  constructor(client, opts = {}) {
@@ -48,6 +52,7 @@ var NetlifyDeployment = class {
48
52
  this.opts = opts;
49
53
  if (opts.domain !== void 0) this.domain = opts.domain;
50
54
  }
55
+ /** Lists the sites the token can see, mapped to deployment projects. */
51
56
  async listProjects() {
52
57
  return (await this.client().sites.list()).map(toDeploymentProject);
53
58
  }
@@ -76,11 +81,13 @@ var NetlifyDeployment = class {
76
81
  async updateProjectSettings(projectId, _settings) {
77
82
  return toDeploymentProject(await this.client().sites.get(projectId));
78
83
  }
84
+ /** Lists the names of the env vars that have a value for the given target; needs `accountId`. */
79
85
  async listEnvVars(projectId, target) {
80
86
  const accountId = this.requireAccountId();
81
87
  const context = toNetlifyContext(target);
82
88
  return (await this.client().env.list(accountId, projectId)).filter((v) => v.values.some((value) => value.context === context)).map((v) => v.key);
83
89
  }
90
+ /** Sets an env var for the given target (`production`, or the branch-deploy context for any other); needs `accountId`. */
84
91
  async setEnvVar(projectId, target, name, value) {
85
92
  const accountId = this.requireAccountId();
86
93
  await this.client().env.set(accountId, projectId, name, toNetlifyContext(target), value);
@@ -96,6 +103,7 @@ var NetlifyDeployment = class {
96
103
  if (!build.deploy_id) throw new Error("@theholocron/holocron-plugin-netlify: triggerDeployment got no deploy_id back from Netlify");
97
104
  return toDeploymentRecord(await this.client().deploys.get(build.deploy_id));
98
105
  }
106
+ /** Fetches a deploy by id and maps its state to `ready`, `error` or `building`. */
99
107
  async getDeployment(deploymentId) {
100
108
  return toDeploymentRecord(await this.client().deploys.get(deploymentId));
101
109
  }
@@ -128,6 +136,7 @@ var NetlifyDeployment = class {
128
136
  }
129
137
  };
130
138
  // src/verify-token.ts
139
+ /** Checks a Netlify token by fetching the current user and reports who it belongs to, or why it was rejected. */
131
140
  async function verifyToken(token, opts = {}) {
132
141
  const client = createNetlifyClient({
133
142
  token,
@@ -148,6 +157,7 @@ async function verifyToken(token, opts = {}) {
148
157
  }
149
158
  }
150
159
  // src/index.ts
160
+ /** Builds the plugin context from its options. */
151
161
  function createContext(options) {
152
162
  let client;
153
163
  return {
@@ -159,6 +169,7 @@ function createContext(options) {
159
169
  })
160
170
  };
161
171
  }
172
+ /** Builds the `deployment` capability, passing along only the account and domain options that are set. */
162
173
  function deployment(ctx) {
163
174
  const opts = {};
164
175
  if (ctx.options.accountSlug !== void 0) opts.accountSlug = ctx.options.accountSlug;
@@ -166,6 +177,7 @@ function deployment(ctx) {
166
177
  if (ctx.options.domain !== void 0) opts.domain = ctx.options.domain;
167
178
  return new NetlifyDeployment(ctx.client, opts);
168
179
  }
180
+ /** Creates the Netlify plugin: its `connection` probe and the `deployment` capability. */
169
181
  function createPlugin(options) {
170
182
  const ctx = createContext(options);
171
183
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-netlify",
3
- "version": "5.0.0-alpha.278",
3
+ "version": "5.0.0-alpha.279",
4
4
  "description": "Holocron plugin for Netlify. Implements the deployment capability against Netlify's REST API, plus exports verifyToken + AUTH_HINT for `holocron auth`.",
5
5
  "keywords": [
6
6
  "deployment",
@@ -38,16 +38,16 @@
38
38
  "tsx": "4.23.15",
39
39
  "typescript": "^5.9.3",
40
40
  "vitest": "^5.0.5",
41
- "@theholocron/cli": "5.0.0-alpha.278",
42
- "@theholocron/netlify-client": "^1.58.0-alpha.3",
43
- "@theholocron/misc-utils": "^1.16.1-alpha.3",
44
41
  "@theholocron/http-client": "^1.58.0-alpha.3",
45
- "@theholocron/tsconfig": "^8.9.0-alpha.4"
42
+ "@theholocron/misc-utils": "^1.16.1-alpha.3",
43
+ "@theholocron/tsconfig": "^8.9.0-alpha.4",
44
+ "@theholocron/cli": "5.0.0-alpha.279",
45
+ "@theholocron/netlify-client": "^1.58.0-alpha.3"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@theholocron/misc-utils": "^1.16.0",
49
49
  "@theholocron/netlify-client": "^1.43.0",
50
- "@theholocron/cli": "5.0.0-alpha.278"
50
+ "@theholocron/cli": "5.0.0-alpha.279"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
53
  "@theholocron/netlify-client": {}