@theholocron/holocron-plugin-neon 3.59.0 → 3.61.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/dist/index.d.mts CHANGED
@@ -12,7 +12,7 @@ declare class NeonStorage implements Storage {
12
12
  private readonly opts;
13
13
  readonly key: "storage";
14
14
  readonly providerName = "neon";
15
- constructor(client: NeonClient$1, opts: StorageOptions);
15
+ constructor(client: () => NeonClient$1, opts: StorageOptions);
16
16
  getConnectionString(scope: string, options?: ConnectionStringOptions): Promise<string>;
17
17
  listBranches(): Promise<StorageBranch[]>;
18
18
  createBranch(input: {
@@ -69,7 +69,7 @@ interface NeonPluginOptions extends ResolveTokenInput {
69
69
  }
70
70
  interface PluginContext {
71
71
  options: NeonPluginOptions;
72
- client: NeonClient;
72
+ client: () => NeonClient;
73
73
  }
74
74
  declare function createContext(options: NeonPluginOptions): PluginContext;
75
75
  declare function storage(ctx: PluginContext): Storage;
package/dist/index.mjs CHANGED
@@ -21,7 +21,7 @@ var NeonStorage = class {
21
21
  }
22
22
  async getConnectionString(scope, options = {}) {
23
23
  const db = await this.firstDatabase(scope);
24
- const { uri } = await this.client.connection.uri(this.opts.projectId, {
24
+ const { uri } = await this.client().connection.uri(this.opts.projectId, {
25
25
  branch_id: scope,
26
26
  database_name: db.name,
27
27
  role_name: db.owner_name,
@@ -30,11 +30,11 @@ var NeonStorage = class {
30
30
  return uri;
31
31
  }
32
32
  async listBranches() {
33
- const { branches } = await this.client.branches.list(this.opts.projectId);
33
+ const { branches } = await this.client().branches.list(this.opts.projectId);
34
34
  return branches.map(mapBranch);
35
35
  }
36
36
  async createBranch(input) {
37
- const { branch } = await this.client.branches.create(this.opts.projectId, {
37
+ const { branch } = await this.client().branches.create(this.opts.projectId, {
38
38
  name: input.name,
39
39
  ...input.from ? { parent_id: input.from } : {},
40
40
  endpoints: [{ type: "read_write" }]
@@ -42,14 +42,14 @@ var NeonStorage = class {
42
42
  return mapBranch(branch);
43
43
  }
44
44
  async destroyBranch(branch) {
45
- await this.client.branches.destroy(this.opts.projectId, branch);
45
+ await this.client().branches.destroy(this.opts.projectId, branch);
46
46
  }
47
47
  async resetBranch(input) {
48
- await this.client.branches.restore(this.opts.projectId, input.branch, input.from);
48
+ await this.client().branches.restore(this.opts.projectId, input.branch, input.from);
49
49
  }
50
50
  async enableExtension(input) {
51
51
  const db = await this.firstDatabase(input.branch);
52
- await this.client.databases.runSql(this.opts.projectId, input.branch, db.name, `CREATE EXTENSION IF NOT EXISTS "${input.extension}"`);
52
+ await this.client().databases.runSql(this.opts.projectId, input.branch, db.name, `CREATE EXTENSION IF NOT EXISTS "${input.extension}"`);
53
53
  }
54
54
  /**
55
55
  * The first database on a branch — the "default" for connection-string
@@ -57,7 +57,7 @@ var NeonStorage = class {
57
57
  * means it was created without an endpoint and needs initialization).
58
58
  */
59
59
  async firstDatabase(branchId) {
60
- const { databases } = await this.client.databases.list(this.opts.projectId, branchId);
60
+ const { databases } = await this.client().databases.list(this.opts.projectId, branchId);
61
61
  const db = databases[0];
62
62
  if (!db) throw new ProviderApiError(`Neon branch ${branchId} has no databases — initialize the branch first`, 404, void 0);
63
63
  return db;
@@ -102,9 +102,10 @@ async function verifyToken(token, opts = {}) {
102
102
  //#region src/index.ts
103
103
  function createContext(options) {
104
104
  if (!options.projectId) throw new Error("@theholocron/holocron-plugin-neon requires `projectId` in options");
105
+ let client;
105
106
  return {
106
107
  options,
107
- client: createNeonClient({
108
+ client: () => client ??= createNeonClient({
108
109
  token: resolveToken(options),
109
110
  baseUrl: options.baseUrl,
110
111
  fetch: options.fetch
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-neon",
3
- "version": "3.59.0",
3
+ "version": "3.61.0",
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",
@@ -45,11 +45,11 @@
45
45
  "tsx": "4.23.12",
46
46
  "typescript": "^5.9.3",
47
47
  "vitest": "^4.1.11",
48
- "@theholocron/cli": "3.59.0"
48
+ "@theholocron/cli": "3.61.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@theholocron/neon-client": "^1.14.2",
52
- "@theholocron/cli": "3.59.0"
52
+ "@theholocron/cli": "3.61.0"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "@theholocron/neon-client": {}