@theholocron/neon-client 1.30.0 → 1.32.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/package.json +5 -5
- package/dist/index.d.mts +0 -88
- package/dist/index.mjs +0 -76
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/neon-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.32.0",
|
|
4
4
|
"description": "A TypeScript client for the Neon API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"neon",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@theholocron/observability": "^0.3.0",
|
|
36
|
-
"@theholocron/http-client": "^1.
|
|
36
|
+
"@theholocron/http-client": "^1.32.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
39
|
+
"@theholocron/cli": "5.0.0-alpha.79",
|
|
40
40
|
"@theholocron/eslint-config": "^8.4.3",
|
|
41
41
|
"@theholocron/tsconfig": "^8.2.0",
|
|
42
|
-
"@theholocron/tsdown-config": "^8.2
|
|
42
|
+
"@theholocron/tsdown-config": "^8.5.2",
|
|
43
43
|
"@theholocron/vitest-config": "^8.2.0",
|
|
44
44
|
"@types/node": "^26.4.1",
|
|
45
45
|
"@vitest/coverage-v8": "^5.0.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"releases": "https://github.com/theholocron/clients/releases",
|
|
62
62
|
"wiki": "https://github.com/theholocron/clients/wiki",
|
|
63
63
|
"scripts": {
|
|
64
|
-
"delivery.build": "
|
|
64
|
+
"delivery.build": "holocron run delivery.build -- && node ../../scripts/check-bundle-size.mjs",
|
|
65
65
|
"sourceQuality.staticAnalysis": "holocron run sourceQuality.staticAnalysis --",
|
|
66
66
|
"test:watch": "vitest",
|
|
67
67
|
"verification.typeSafety": "holocron run verification.typeSafety --",
|
package/dist/index.d.mts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import "@theholocron/http-client";
|
|
2
|
-
import { ErrorSink, Logger } from "@theholocron/observability/core";
|
|
3
|
-
//#region src/utils.d.ts
|
|
4
|
-
interface NeonClientOptions {
|
|
5
|
-
/** Neon API key. */
|
|
6
|
-
token: string;
|
|
7
|
-
/** Override base URL for testing. Defaults to https://console.neon.tech/api/v2. */
|
|
8
|
-
baseUrl?: string;
|
|
9
|
-
/** Override fetch for testing. Defaults to globalThis.fetch. */
|
|
10
|
-
fetch?: typeof fetch;
|
|
11
|
-
/** Structured logger for request/response diagnostics. Defaults to a no-op. */
|
|
12
|
-
logger?: Logger;
|
|
13
|
-
/** Reports transport failures and unexpected 5xx. Defaults to a no-op. */
|
|
14
|
-
errors?: ErrorSink;
|
|
15
|
-
}
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/branches/branches.d.ts
|
|
18
|
-
interface NeonBranch {
|
|
19
|
-
id: string;
|
|
20
|
-
name: string;
|
|
21
|
-
parent_id?: string;
|
|
22
|
-
created_at: string;
|
|
23
|
-
}
|
|
24
|
-
interface NeonBranchesResponse {
|
|
25
|
-
branches: NeonBranch[];
|
|
26
|
-
}
|
|
27
|
-
interface NeonBranchResponse {
|
|
28
|
-
branch: NeonBranch;
|
|
29
|
-
}
|
|
30
|
-
interface CreateNeonBranchInput {
|
|
31
|
-
name: string;
|
|
32
|
-
parent_id?: string;
|
|
33
|
-
endpoints?: Array<{
|
|
34
|
-
type: "read_write" | "read_only";
|
|
35
|
-
}>;
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/connection/connection.d.ts
|
|
39
|
-
interface NeonConnectionUriParams {
|
|
40
|
-
branch_id: string;
|
|
41
|
-
database_name: string;
|
|
42
|
-
role_name: string;
|
|
43
|
-
pooled?: "true" | "false";
|
|
44
|
-
}
|
|
45
|
-
interface NeonConnectionUriResponse {
|
|
46
|
-
uri: string;
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/databases/databases.d.ts
|
|
50
|
-
interface NeonDatabase {
|
|
51
|
-
id: number;
|
|
52
|
-
name: string;
|
|
53
|
-
owner_name: string;
|
|
54
|
-
}
|
|
55
|
-
interface NeonDatabasesResponse {
|
|
56
|
-
databases: NeonDatabase[];
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/users/users.d.ts
|
|
60
|
-
interface NeonMe {
|
|
61
|
-
id?: string;
|
|
62
|
-
email?: string;
|
|
63
|
-
name?: string;
|
|
64
|
-
login?: string;
|
|
65
|
-
}
|
|
66
|
-
//#endregion
|
|
67
|
-
//#region src/index.d.ts
|
|
68
|
-
declare function createNeonClient(opts: NeonClientOptions): {
|
|
69
|
-
branches: {
|
|
70
|
-
list: (projectId: string) => Promise<NeonBranchesResponse>;
|
|
71
|
-
create: (projectId: string, input: CreateNeonBranchInput) => Promise<NeonBranchResponse>;
|
|
72
|
-
destroy: (projectId: string, branchId: string) => Promise<void>;
|
|
73
|
-
restore: (projectId: string, branchId: string, sourceBranchId: string) => Promise<void>;
|
|
74
|
-
};
|
|
75
|
-
connection: {
|
|
76
|
-
uri: (projectId: string, params: NeonConnectionUriParams) => Promise<NeonConnectionUriResponse>;
|
|
77
|
-
};
|
|
78
|
-
databases: {
|
|
79
|
-
list: (projectId: string, branchId: string) => Promise<NeonDatabasesResponse>;
|
|
80
|
-
runSql: (projectId: string, branchId: string, dbName: string, query: string) => Promise<void>;
|
|
81
|
-
};
|
|
82
|
-
users: {
|
|
83
|
-
me: () => Promise<NeonMe>;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
type NeonClient = ReturnType<typeof createNeonClient>;
|
|
87
|
-
//#endregion
|
|
88
|
-
export { type CreateNeonBranchInput, type NeonBranch, type NeonBranchResponse, type NeonBranchesResponse, NeonClient, type NeonClientOptions, type NeonConnectionUriParams, type NeonConnectionUriResponse, type NeonDatabase, type NeonDatabasesResponse, type NeonMe, createNeonClient };
|
package/dist/index.mjs
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { createRestClient } from "@theholocron/http-client";
|
|
2
|
-
//#region src/branches/branches.ts
|
|
3
|
-
function branches(rest) {
|
|
4
|
-
return {
|
|
5
|
-
list: (projectId) => rest.request(`/projects/${projectId}/branches`),
|
|
6
|
-
create: (projectId, input) => rest.request(`/projects/${projectId}/branches`, {
|
|
7
|
-
method: "POST",
|
|
8
|
-
body: {
|
|
9
|
-
branch: {
|
|
10
|
-
name: input.name,
|
|
11
|
-
...input.parent_id !== void 0 ? { parent_id: input.parent_id } : {}
|
|
12
|
-
},
|
|
13
|
-
...input.endpoints !== void 0 ? { endpoints: input.endpoints } : {}
|
|
14
|
-
}
|
|
15
|
-
}),
|
|
16
|
-
destroy: (projectId, branchId) => rest.request(`/projects/${projectId}/branches/${encodeURIComponent(branchId)}`, { method: "DELETE" }),
|
|
17
|
-
restore: (projectId, branchId, sourceBranchId) => rest.request(`/projects/${projectId}/branches/${encodeURIComponent(branchId)}/restore`, {
|
|
18
|
-
method: "POST",
|
|
19
|
-
body: { source_branch_id: sourceBranchId }
|
|
20
|
-
})
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/connection/connection.ts
|
|
25
|
-
function connection(rest) {
|
|
26
|
-
return { uri: (projectId, params) => {
|
|
27
|
-
const query = {
|
|
28
|
-
branch_id: params.branch_id,
|
|
29
|
-
database_name: params.database_name,
|
|
30
|
-
role_name: params.role_name
|
|
31
|
-
};
|
|
32
|
-
if (params.pooled !== void 0) query["pooled"] = params.pooled;
|
|
33
|
-
return rest.request(`/projects/${projectId}/connection_uri`, { query });
|
|
34
|
-
} };
|
|
35
|
-
}
|
|
36
|
-
//#endregion
|
|
37
|
-
//#region src/databases/databases.ts
|
|
38
|
-
function databases(rest) {
|
|
39
|
-
return {
|
|
40
|
-
list: (projectId, branchId) => rest.request(`/projects/${projectId}/branches/${encodeURIComponent(branchId)}/databases`),
|
|
41
|
-
runSql: (projectId, branchId, dbName, query) => rest.request(`/projects/${projectId}/branches/${encodeURIComponent(branchId)}/databases/${encodeURIComponent(dbName)}/run_sql`, {
|
|
42
|
-
method: "POST",
|
|
43
|
-
body: { query }
|
|
44
|
-
})
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/users/users.ts
|
|
49
|
-
function users(rest) {
|
|
50
|
-
return { me: () => rest.request("/users/me") };
|
|
51
|
-
}
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region src/utils.ts
|
|
54
|
-
function createNeonRestClient(opts) {
|
|
55
|
-
return createRestClient({
|
|
56
|
-
baseUrl: opts.baseUrl ?? "https://console.neon.tech/api/v2",
|
|
57
|
-
token: opts.token,
|
|
58
|
-
vendor: "Neon",
|
|
59
|
-
fetch: opts.fetch,
|
|
60
|
-
logger: opts.logger,
|
|
61
|
-
errors: opts.errors
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region src/index.ts
|
|
66
|
-
function createNeonClient(opts) {
|
|
67
|
-
const rest = createNeonRestClient(opts);
|
|
68
|
-
return {
|
|
69
|
-
branches: branches(rest),
|
|
70
|
-
connection: connection(rest),
|
|
71
|
-
databases: databases(rest),
|
|
72
|
-
users: users(rest)
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
//#endregion
|
|
76
|
-
export { createNeonClient };
|