@theholocron/holocron-plugin-neon 5.0.0-alpha.27 → 5.0.0-alpha.271
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 +16 -34
- package/dist/index.mjs +20 -17
- package/package.json +21 -19
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { AuthError, ConnectionStringOptions, ResolveTokenInput, Storage, StorageBranch } from "@theholocron/cli";
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//#region src/capabilities/storage.d.ts
|
|
3
|
+
export declare const resolveToken: import("@theholocron/cli").TokenResolver;
|
|
4
|
+
/** Every token this plugin takes, for `holocron doctor tokens`. */
|
|
5
|
+
export declare const tokens: PluginToken[];
|
|
7
6
|
interface StorageOptions {
|
|
8
7
|
projectId: string;
|
|
9
8
|
}
|
|
10
|
-
declare class NeonStorage implements Storage {
|
|
9
|
+
export declare class NeonStorage implements Storage {
|
|
11
10
|
private readonly client;
|
|
12
11
|
private readonly opts;
|
|
13
12
|
readonly key: "storage";
|
|
@@ -35,31 +34,12 @@ declare class NeonStorage implements Storage {
|
|
|
35
34
|
*/
|
|
36
35
|
private firstDatabase;
|
|
37
36
|
}
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/verify-token.d.ts
|
|
40
|
-
/**
|
|
41
|
-
* `verifyToken` — plugin-level export used by `holocron auth set` +
|
|
42
|
-
* `holocron auth check`. Hits Neon's `/users/me` endpoint and
|
|
43
|
-
* translates the response into the normalized `VerifyTokenResult`
|
|
44
|
-
* shape.
|
|
45
|
-
*/
|
|
46
|
-
interface VerifyTokenSuccess {
|
|
47
|
-
ok: true;
|
|
48
|
-
subject: string;
|
|
49
|
-
}
|
|
50
|
-
interface VerifyTokenFailure {
|
|
51
|
-
ok: false;
|
|
52
|
-
message: string;
|
|
53
|
-
}
|
|
54
|
-
type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
|
|
55
37
|
interface VerifyTokenOptions {
|
|
56
38
|
baseUrl?: string;
|
|
57
39
|
fetch?: typeof fetch;
|
|
58
40
|
}
|
|
59
|
-
declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult>;
|
|
60
|
-
|
|
61
|
-
//#region src/index.d.ts
|
|
62
|
-
interface NeonPluginOptions extends ResolveTokenInput {
|
|
41
|
+
export declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
|
|
42
|
+
export interface NeonPluginOptions extends ResolveTokenInput {
|
|
63
43
|
/** Neon project id this plugin is bound to. Required. */
|
|
64
44
|
projectId: string;
|
|
65
45
|
/** Override base URL for tests. */
|
|
@@ -67,14 +47,17 @@ interface NeonPluginOptions extends ResolveTokenInput {
|
|
|
67
47
|
/** Override `fetch` for tests. */
|
|
68
48
|
fetch?: typeof fetch;
|
|
69
49
|
}
|
|
70
|
-
interface PluginContext {
|
|
50
|
+
export interface PluginContext {
|
|
71
51
|
options: NeonPluginOptions;
|
|
72
52
|
client: () => NeonClient;
|
|
73
53
|
}
|
|
74
|
-
declare function createContext(options: NeonPluginOptions): PluginContext;
|
|
75
|
-
declare function storage(ctx: PluginContext): Storage;
|
|
76
|
-
declare function createPlugin(options: NeonPluginOptions): {
|
|
54
|
+
export declare function createContext(options: NeonPluginOptions): PluginContext;
|
|
55
|
+
export declare function storage(ctx: PluginContext): Storage;
|
|
56
|
+
export declare function createPlugin(options: NeonPluginOptions): {
|
|
77
57
|
name: string;
|
|
58
|
+
probes: {
|
|
59
|
+
connection: import("@theholocron/cli").Probe;
|
|
60
|
+
};
|
|
78
61
|
capabilities: {
|
|
79
62
|
storage: () => Storage;
|
|
80
63
|
};
|
|
@@ -85,6 +68,5 @@ declare function createPlugin(options: NeonPluginOptions): {
|
|
|
85
68
|
* at https://console.neon.tech/app/settings/api-keys where API keys
|
|
86
69
|
* are minted.
|
|
87
70
|
*/
|
|
88
|
-
declare const AUTH_HINT: string;
|
|
89
|
-
|
|
90
|
-
export { AUTH_HINT, AuthError, type NeonClient, type NeonClientOptions, NeonPluginOptions, NeonStorage, PluginContext, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createContext, createNeonClient, createPlugin, resolveToken, storage, verifyToken };
|
|
71
|
+
export declare const AUTH_HINT: string;
|
|
72
|
+
export { AuthError, type NeonClient, type NeonClientOptions, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createNeonClient };
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { AuthError, ProviderApiError, createResolveToken } from "@theholocron/cli";
|
|
1
|
+
import { AuthError, ProviderApiError, connectionProbe, createResolveToken } from "@theholocron/cli";
|
|
2
2
|
import { createNeonClient } from "@theholocron/neon-client";
|
|
3
|
-
|
|
3
|
+
import { errorMessage } from "@theholocron/misc-utils";
|
|
4
|
+
// src/auth.ts
|
|
4
5
|
const resolveToken = createResolveToken({
|
|
5
6
|
envName: "HOLOCRON_NEON_API_KEY",
|
|
6
7
|
vendorEnvName: "NEON_API_KEY",
|
|
7
8
|
keyringService: "neon",
|
|
8
9
|
errorMessage: "no Neon API key found. Pass --token <KEY>, set HOLOCRON_NEON_API_KEY / NEON_API_KEY, or run: holocron auth set neon <KEY>"
|
|
9
10
|
});
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
/** Every token this plugin takes, for `holocron doctor tokens`. */
|
|
12
|
+
const tokens = [resolveToken.token];
|
|
13
|
+
// src/capabilities/storage.ts
|
|
12
14
|
var NeonStorage = class {
|
|
13
15
|
client;
|
|
14
16
|
opts;
|
|
@@ -71,14 +73,7 @@ function mapBranch(raw) {
|
|
|
71
73
|
createdAt: raw.created_at
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
|
-
|
|
75
|
-
//#region src/verify-token.ts
|
|
76
|
-
/**
|
|
77
|
-
* `verifyToken` — plugin-level export used by `holocron auth set` +
|
|
78
|
-
* `holocron auth check`. Hits Neon's `/users/me` endpoint and
|
|
79
|
-
* translates the response into the normalized `VerifyTokenResult`
|
|
80
|
-
* shape.
|
|
81
|
-
*/
|
|
76
|
+
// src/verify-token.ts
|
|
82
77
|
async function verifyToken(token, opts = {}) {
|
|
83
78
|
const client = createNeonClient({
|
|
84
79
|
token,
|
|
@@ -94,12 +89,11 @@ async function verifyToken(token, opts = {}) {
|
|
|
94
89
|
} catch (err) {
|
|
95
90
|
return {
|
|
96
91
|
ok: false,
|
|
97
|
-
message:
|
|
92
|
+
message: errorMessage(err)
|
|
98
93
|
};
|
|
99
94
|
}
|
|
100
95
|
}
|
|
101
|
-
|
|
102
|
-
//#region src/index.ts
|
|
96
|
+
// src/index.ts
|
|
103
97
|
function createContext(options) {
|
|
104
98
|
if (!options.projectId) throw new Error("@theholocron/holocron-plugin-neon requires `projectId` in options");
|
|
105
99
|
let client;
|
|
@@ -119,6 +113,16 @@ function createPlugin(options) {
|
|
|
119
113
|
const ctx = createContext(options);
|
|
120
114
|
return {
|
|
121
115
|
name: "@theholocron/holocron-plugin-neon",
|
|
116
|
+
probes: { connection: connectionProbe({
|
|
117
|
+
provider: "Neon",
|
|
118
|
+
url: options.baseUrl ?? "https://console.neon.tech",
|
|
119
|
+
fetch: options.fetch,
|
|
120
|
+
token: () => resolveToken(options),
|
|
121
|
+
verify: (token) => verifyToken(token, {
|
|
122
|
+
baseUrl: options.baseUrl,
|
|
123
|
+
fetch: options.fetch
|
|
124
|
+
})
|
|
125
|
+
}) },
|
|
122
126
|
capabilities: { storage: () => storage(ctx) }
|
|
123
127
|
};
|
|
124
128
|
}
|
|
@@ -129,5 +133,4 @@ function createPlugin(options) {
|
|
|
129
133
|
* are minted.
|
|
130
134
|
*/
|
|
131
135
|
const AUTH_HINT = "generate a Neon API key at https://console.neon.tech/app/settings/api-keys, then run: holocron auth set neon <KEY>";
|
|
132
|
-
|
|
133
|
-
export { AUTH_HINT, AuthError, NeonStorage, createContext, createNeonClient, createPlugin, resolveToken, storage, verifyToken };
|
|
136
|
+
export { AUTH_HINT, AuthError, NeonStorage, createContext, createNeonClient, createPlugin, resolveToken, storage, tokens, verifyToken };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-neon",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.271",
|
|
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",
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"plugin",
|
|
9
9
|
"storage"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://
|
|
11
|
+
"homepage": "https://docs.theholocron.dev/holocron/plugins/neon/",
|
|
12
12
|
"bugs": "https://github.com/theholocron/holocron/issues",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/theholocron/holocron.git",
|
|
16
|
-
"directory": "
|
|
16
|
+
"directory": "plugins/holocron-plugin-neon"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"author": "Newton Koumantzelis",
|
|
@@ -30,27 +30,29 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@theholocron/eslint-config": "^8.0.0",
|
|
34
|
-
"@theholocron/http-client": "^1.23.0",
|
|
35
|
-
"@theholocron/neon-client": "^1.23.0",
|
|
36
|
-
"@theholocron/tsconfig": "^8.0.0",
|
|
37
|
-
"@theholocron/tsdown-config": "^8.0.0",
|
|
38
|
-
"@theholocron/vitest-config": "^8.0.0",
|
|
39
33
|
"@types/node": "^26",
|
|
40
|
-
"@vitest/coverage-v8": "^
|
|
34
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
41
35
|
"@vitest/eslint-plugin": "^1.6.27",
|
|
42
36
|
"eslint": "^10.8.1",
|
|
43
37
|
"eslint-plugin-n": "^18.3.0",
|
|
44
38
|
"globals": "^17.11.0",
|
|
45
|
-
"tsdown": "^0.
|
|
46
|
-
"tsx": "4.23.
|
|
39
|
+
"tsdown": "^0.23.3",
|
|
40
|
+
"tsx": "4.23.15",
|
|
47
41
|
"typescript": "^5.9.3",
|
|
48
|
-
"vitest": "^
|
|
49
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
42
|
+
"vitest": "^5.0.5",
|
|
43
|
+
"@theholocron/cli": "5.0.0-alpha.271",
|
|
44
|
+
"@theholocron/http-client": "^1.58.0-alpha.2",
|
|
45
|
+
"@theholocron/misc-utils": "^1.16.1-alpha.1",
|
|
46
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.3",
|
|
47
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.3",
|
|
48
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.3",
|
|
49
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.3",
|
|
50
|
+
"@theholocron/neon-client": "^1.58.0-alpha.2"
|
|
50
51
|
},
|
|
51
52
|
"peerDependencies": {
|
|
52
|
-
"@theholocron/
|
|
53
|
-
"@theholocron/
|
|
53
|
+
"@theholocron/misc-utils": "^1.16.0",
|
|
54
|
+
"@theholocron/neon-client": "^1.43.1",
|
|
55
|
+
"@theholocron/cli": "5.0.0-alpha.271"
|
|
54
56
|
},
|
|
55
57
|
"peerDependenciesMeta": {
|
|
56
58
|
"@theholocron/neon-client": {}
|
|
@@ -63,10 +65,10 @@
|
|
|
63
65
|
},
|
|
64
66
|
"scripts": {
|
|
65
67
|
"delivery.build": "tsdown",
|
|
66
|
-
"sourceQuality.staticAnalysis": "
|
|
68
|
+
"sourceQuality.staticAnalysis": "eslint .",
|
|
67
69
|
"test:watch": "vitest",
|
|
68
70
|
"validate": "tsx scripts/validate.mjs",
|
|
69
|
-
"verification.typeSafety": "
|
|
70
|
-
"verification.unitTests": "
|
|
71
|
+
"verification.typeSafety": "tsc --noEmit",
|
|
72
|
+
"verification.unitTests": "vitest run"
|
|
71
73
|
}
|
|
72
74
|
}
|