@theholocron/holocron-plugin-neon 5.0.0-alpha.277 → 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,23 +1,30 @@
1
1
  import { AuthError, ConnectionStringOptions, PluginToken, ResolveTokenInput, Storage, StorageBranch, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
2
2
  import { NeonClient, NeonClient as NeonClient$1, NeonClientOptions, createNeonClient } from "@theholocron/neon-client";
3
+ /** Resolves the Neon API key from `--token`, `HOLOCRON_NEON_API_KEY`, `NEON_API_KEY` or the keyring entry for `neon`, 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[];
6
7
  interface StorageOptions {
7
8
  projectId: string;
8
9
  }
10
+ /** `storage` capability for Neon, bound to the single project named by the `projectId` option. */
9
11
  export declare class NeonStorage implements Storage {
10
12
  private readonly client;
11
13
  private readonly opts;
14
+ /** Capability key; always `"storage"`. */
12
15
  readonly key: "storage";
16
+ /** Provider name; always `"neon"`. */
13
17
  readonly providerName = "neon";
14
18
  constructor(client: () => NeonClient$1, opts: StorageOptions);
15
19
  getConnectionString(scope: string, options?: ConnectionStringOptions): Promise<string>;
20
+ /** Lists every branch of the bound project, mapped to `StorageBranch`. */
16
21
  listBranches(): Promise<StorageBranch[]>;
22
+ /** Creates a branch (optionally from the `from` parent branch id) with a read-write endpoint, so its connection string works at once. */
17
23
  createBranch(input: {
18
24
  name: string;
19
25
  from?: string;
20
26
  }): Promise<StorageBranch>;
27
+ /** Deletes the branch with the given id from the bound project. */
21
28
  destroyBranch(branch: string): Promise<void>;
22
29
  resetBranch(input: {
23
30
  branch: string;
@@ -38,7 +45,9 @@ interface VerifyTokenOptions {
38
45
  baseUrl?: string;
39
46
  fetch?: typeof fetch;
40
47
  }
48
+ /** Checks a Neon API key by calling `/users/me` and reports who it belongs to, or why it was rejected. */
41
49
  export declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
50
+ /** Options for the Neon plugin: the token lookup inputs plus the project it is bound to. */
42
51
  export interface NeonPluginOptions extends ResolveTokenInput {
43
52
  /** Neon project id this plugin is bound to. Required. */
44
53
  projectId: string;
@@ -47,12 +56,18 @@ export interface NeonPluginOptions extends ResolveTokenInput {
47
56
  /** Override `fetch` for tests. */
48
57
  fetch?: typeof fetch;
49
58
  }
59
+ /** Shared state for one Neon plugin instance: its options and a lazily created client. */
50
60
  export interface PluginContext {
61
+ /** The options the plugin was created with. */
51
62
  options: NeonPluginOptions;
63
+ /** Returns the memoized Neon client; the token is resolved on the first call, not at plugin load. */
52
64
  client: () => NeonClient;
53
65
  }
66
+ /** Builds the plugin context from its options; throws when `projectId` is missing. */
54
67
  export declare function createContext(options: NeonPluginOptions): PluginContext;
68
+ /** Builds the `storage` capability for the context's project. */
55
69
  export declare function storage(ctx: PluginContext): Storage;
70
+ /** Creates the Neon plugin: its `connection` probe and the `storage` capability. */
56
71
  export declare function createPlugin(options: NeonPluginOptions): {
57
72
  name: string;
58
73
  probes: {
package/dist/index.mjs CHANGED
@@ -2,6 +2,7 @@ import { AuthError, ProviderApiError, connectionProbe, createResolveToken } from
2
2
  import { createNeonClient } from "@theholocron/neon-client";
3
3
  import { errorMessage } from "@theholocron/misc-utils";
4
4
  // src/auth.ts
5
+ /** Resolves the Neon API key from `--token`, `HOLOCRON_NEON_API_KEY`, `NEON_API_KEY` or the keyring entry for `neon`, and throws `AuthError` when none is set. */
5
6
  const resolveToken = createResolveToken({
6
7
  envName: "HOLOCRON_NEON_API_KEY",
7
8
  vendorEnvName: "NEON_API_KEY",
@@ -11,10 +12,13 @@ const resolveToken = createResolveToken({
11
12
  /** Every token this plugin takes, for `holocron doctor tokens`. */
12
13
  const tokens = [resolveToken.token];
13
14
  // src/capabilities/storage.ts
15
+ /** `storage` capability for Neon, bound to the single project named by the `projectId` option. */
14
16
  var NeonStorage = class {
15
17
  client;
16
18
  opts;
19
+ /** Capability key; always `"storage"`. */
17
20
  key = "storage";
21
+ /** Provider name; always `"neon"`. */
18
22
  providerName = "neon";
19
23
  constructor(client, opts) {
20
24
  this.client = client;
@@ -31,10 +35,12 @@ var NeonStorage = class {
31
35
  });
32
36
  return uri;
33
37
  }
38
+ /** Lists every branch of the bound project, mapped to `StorageBranch`. */
34
39
  async listBranches() {
35
40
  const { branches } = await this.client().branches.list(this.opts.projectId);
36
41
  return branches.map(mapBranch);
37
42
  }
43
+ /** Creates a branch (optionally from the `from` parent branch id) with a read-write endpoint, so its connection string works at once. */
38
44
  async createBranch(input) {
39
45
  const { branch } = await this.client().branches.create(this.opts.projectId, {
40
46
  name: input.name,
@@ -43,6 +49,7 @@ var NeonStorage = class {
43
49
  });
44
50
  return mapBranch(branch);
45
51
  }
52
+ /** Deletes the branch with the given id from the bound project. */
46
53
  async destroyBranch(branch) {
47
54
  await this.client().branches.destroy(this.opts.projectId, branch);
48
55
  }
@@ -74,6 +81,7 @@ function mapBranch(raw) {
74
81
  };
75
82
  }
76
83
  // src/verify-token.ts
84
+ /** Checks a Neon API key by calling `/users/me` and reports who it belongs to, or why it was rejected. */
77
85
  async function verifyToken(token, opts = {}) {
78
86
  const client = createNeonClient({
79
87
  token,
@@ -94,6 +102,7 @@ async function verifyToken(token, opts = {}) {
94
102
  }
95
103
  }
96
104
  // src/index.ts
105
+ /** Builds the plugin context from its options; throws when `projectId` is missing. */
97
106
  function createContext(options) {
98
107
  if (!options.projectId) throw new Error("@theholocron/holocron-plugin-neon requires `projectId` in options");
99
108
  let client;
@@ -106,9 +115,11 @@ function createContext(options) {
106
115
  })
107
116
  };
108
117
  }
118
+ /** Builds the `storage` capability for the context's project. */
109
119
  function storage(ctx) {
110
120
  return new NeonStorage(ctx.client, { projectId: ctx.options.projectId });
111
121
  }
122
+ /** Creates the Neon plugin: its `connection` probe and the `storage` capability. */
112
123
  function createPlugin(options) {
113
124
  const ctx = createContext(options);
114
125
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-neon",
3
- "version": "5.0.0-alpha.277",
3
+ "version": "5.0.0-alpha.279",
4
4
  "description": "Holocron plugin for Neon. Implements the storage capability against Neon's REST API — branch ops, connection strings, extensions.",
5
5
  "keywords": [
6
6
  "holocron",
@@ -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.277",
44
- "@theholocron/http-client": "^1.58.0-alpha.3",
43
+ "@theholocron/cli": "5.0.0-alpha.279",
44
+ "@theholocron/eslint-config": "^8.9.0-alpha.4",
45
45
  "@theholocron/neon-client": "^1.58.0-alpha.3",
46
- "@theholocron/eslint-config": "^8.9.0-alpha.3",
47
- "@theholocron/misc-utils": "^1.16.1-alpha.2",
48
- "@theholocron/tsconfig": "^8.9.0-alpha.3",
49
- "@theholocron/tsdown-config": "^8.9.0-alpha.3",
50
- "@theholocron/vitest-config": "^8.9.0-alpha.3"
46
+ "@theholocron/misc-utils": "^1.16.1-alpha.3",
47
+ "@theholocron/tsconfig": "^8.9.0-alpha.4",
48
+ "@theholocron/tsdown-config": "^8.9.0-alpha.4",
49
+ "@theholocron/http-client": "^1.58.0-alpha.3",
50
+ "@theholocron/vitest-config": "^8.9.0-alpha.4"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@theholocron/misc-utils": "^1.16.0",
54
54
  "@theholocron/neon-client": "^1.43.1",
55
- "@theholocron/cli": "5.0.0-alpha.277"
55
+ "@theholocron/cli": "5.0.0-alpha.279"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "@theholocron/neon-client": {}