@neon/tools 2.14.4 → 2.16.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/README.md +195 -5
- package/dist/descriptions.gen.js +2 -2
- package/dist/effect.d.ts +22 -0
- package/dist/effect.d.ts.map +1 -0
- package/dist/effect.js +3 -0
- package/dist/generated/output.gen.d.ts +3418 -0
- package/dist/generated/output.gen.d.ts.map +1 -0
- package/dist/generated/output.gen.js +1498 -0
- package/dist/generated/zod.gen.d.ts +3 -3
- package/dist/index.d.ts +17 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -9
- package/dist/lib/custom/auth-config.d.ts +63 -2
- package/dist/lib/custom/auth-config.d.ts.map +1 -1
- package/dist/lib/custom/auth-config.js +34 -7
- package/dist/lib/custom/docs.d.ts +32 -2
- package/dist/lib/custom/docs.d.ts.map +1 -1
- package/dist/lib/custom/docs.js +18 -1
- package/dist/lib/custom/feedback.d.ts +7 -2
- package/dist/lib/custom/feedback.d.ts.map +1 -1
- package/dist/lib/custom/feedback.js +3 -0
- package/dist/lib/custom/fetch.d.ts +15 -1
- package/dist/lib/custom/fetch.d.ts.map +1 -1
- package/dist/lib/custom/fetch.js +10 -1
- package/dist/lib/custom/organizations.d.ts +23 -1
- package/dist/lib/custom/organizations.d.ts.map +1 -1
- package/dist/lib/custom/organizations.js +3 -0
- package/dist/lib/custom/resources.d.ts +15 -1
- package/dist/lib/custom/resources.d.ts.map +1 -1
- package/dist/lib/custom/resources.js +8 -1
- package/dist/lib/custom/sql/connection.d.ts +6 -7
- package/dist/lib/custom/sql/connection.d.ts.map +1 -1
- package/dist/lib/custom/sql/connection.js +10 -12
- package/dist/lib/custom/sql/describe-branch.d.ts +99 -1
- package/dist/lib/custom/sql/describe-branch.d.ts.map +1 -1
- package/dist/lib/custom/sql/describe-branch.js +11 -2
- package/dist/lib/custom/sql/inspect/inspect.d.ts +27 -1
- package/dist/lib/custom/sql/inspect/inspect.d.ts.map +1 -1
- package/dist/lib/custom/sql/inspect/inspect.js +17 -3
- package/dist/lib/custom/sql/migrations.d.ts +46 -2
- package/dist/lib/custom/sql/migrations.d.ts.map +1 -1
- package/dist/lib/custom/sql/migrations.js +29 -7
- package/dist/lib/custom/sql/query-tuning.d.ts +90 -2
- package/dist/lib/custom/sql/query-tuning.d.ts.map +1 -1
- package/dist/lib/custom/sql/query-tuning.js +31 -8
- package/dist/lib/custom/sql/run.d.ts +30 -3
- package/dist/lib/custom/sql/run.d.ts.map +1 -1
- package/dist/lib/custom/sql/run.js +15 -6
- package/dist/lib/custom/sql/schema.d.ts +76 -2
- package/dist/lib/custom/sql/schema.d.ts.map +1 -1
- package/dist/lib/custom/sql/schema.js +34 -5
- package/dist/lib/custom/sql/slow-queries.d.ts +15 -1
- package/dist/lib/custom/sql/slow-queries.d.ts.map +1 -1
- package/dist/lib/custom/sql/slow-queries.js +11 -3
- package/dist/lib/customize.d.ts +1 -1
- package/dist/lib/customize.d.ts.map +1 -1
- package/dist/lib/customize.js +8 -4
- package/dist/lib/effect/errors.d.ts +51 -0
- package/dist/lib/effect/errors.d.ts.map +1 -0
- package/dist/lib/effect/errors.js +37 -0
- package/dist/lib/effect/tools.d.ts +56 -0
- package/dist/lib/effect/tools.d.ts.map +1 -0
- package/dist/lib/effect/tools.js +67 -0
- package/dist/lib/ergonomic/bind.d.ts +25 -7
- package/dist/lib/ergonomic/bind.d.ts.map +1 -1
- package/dist/lib/ergonomic/bind.js +13 -3
- package/dist/lib/ergonomic/catalog.d.ts +5335 -180
- package/dist/lib/ergonomic/catalog.d.ts.map +1 -1
- package/dist/lib/ergonomic/catalog.js +286 -23
- package/dist/lib/ergonomic/composed.d.ts +866 -12
- package/dist/lib/ergonomic/composed.d.ts.map +1 -1
- package/dist/lib/ergonomic/composed.js +63 -0
- package/dist/lib/mcp-json-schema.d.ts +20 -0
- package/dist/lib/mcp-json-schema.d.ts.map +1 -1
- package/dist/lib/mcp-json-schema.js +89 -1
- package/dist/lib/mcp-register.d.ts +1 -1
- package/dist/lib/mcp-register.d.ts.map +1 -1
- package/dist/lib/mcp-register.js +2 -1
- package/dist/lib/operation.d.ts +56 -5
- package/dist/lib/operation.d.ts.map +1 -1
- package/dist/lib/operation.js +6 -1
- package/dist/lib/policy.d.ts +24 -0
- package/dist/lib/policy.d.ts.map +1 -0
- package/dist/lib/policy.js +49 -0
- package/dist/lib/redact.d.ts +8 -0
- package/dist/lib/redact.d.ts.map +1 -0
- package/dist/lib/redact.js +40 -0
- package/dist/mastra.d.ts +2 -1
- package/dist/mastra.d.ts.map +1 -1
- package/dist/mcp-v1.d.ts.map +1 -1
- package/dist/mcp-v1.js +3 -1
- package/dist/mcp.d.ts +3 -3
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +3 -3
- package/dist/operations.gen.d.ts +194 -194
- package/package.json +21 -2
|
@@ -18,5 +18,19 @@ export declare const searchResourcesTool: (options: ToolClientOptions) => import
|
|
|
18
18
|
title: string;
|
|
19
19
|
url: string;
|
|
20
20
|
}[];
|
|
21
|
-
}
|
|
21
|
+
}, z.ZodObject<{
|
|
22
|
+
results: z.ZodArray<z.ZodObject<{
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
title: z.ZodString;
|
|
25
|
+
url: z.ZodString;
|
|
26
|
+
}, z.core.$loose>>;
|
|
27
|
+
}, z.core.$loose>> & {
|
|
28
|
+
outputSchema: z.ZodObject<{
|
|
29
|
+
results: z.ZodArray<z.ZodObject<{
|
|
30
|
+
id: z.ZodString;
|
|
31
|
+
title: z.ZodString;
|
|
32
|
+
url: z.ZodString;
|
|
33
|
+
}, z.core.$loose>>;
|
|
34
|
+
}, z.core.$loose>;
|
|
35
|
+
};
|
|
22
36
|
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/lib/custom/resources.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,sBAAsB,CAAC;AAG9B,eAAO,MAAM,oBAAoB,qCAAqC,CAAC;AAGvE,eAAO,MAAM,0BAA0B;;kBAOrC,CAAC;AAQH,eAAO,MAAM,cAAc,GAAI,YAAY,MAAM,WACT,CAAC;AAEzC;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,KAAG,OAEF,CAAC;
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/lib/custom/resources.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,sBAAsB,CAAC;AAG9B,eAAO,MAAM,oBAAoB,qCAAqC,CAAC;AAGvE,eAAO,MAAM,0BAA0B;;kBAOrC,CAAC;AAQH,eAAO,MAAM,cAAc,GAAI,YAAY,MAAM,WACT,CAAC;AAEzC;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,KAAG,OAEF,CAAC;AAwIhD,eAAO,MAAM,mBAAmB,GAAI,SAAS,iBAAiB;;;;YAtJzD,MAAM;eACH,MAAM;aACR,MAAM;;;;;;;;;;;;;;;;CAwLX,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { bindTool, publishedId } from "../ergonomic/bind.js";
|
|
2
2
|
import { matchesNameOrId } from "./organizations.js";
|
|
3
|
-
import { NeonApiError } from "@neon/sdk";
|
|
4
3
|
import * as z from "zod";
|
|
4
|
+
import { NeonApiError } from "@neon/sdk";
|
|
5
5
|
import { listSharedProjects } from "@neon/sdk/raw";
|
|
6
6
|
// src/lib/custom/resources.ts
|
|
7
7
|
const DEFAULT_API_BASE_URL = "https://console.neon.tech/api/v2";
|
|
@@ -86,6 +86,11 @@ const searchResources = async (neon, query, consoleUrl, signal) => {
|
|
|
86
86
|
}));
|
|
87
87
|
return { results };
|
|
88
88
|
};
|
|
89
|
+
const searchResourcesOutputSchema = z.looseObject({ results: z.array(z.looseObject({
|
|
90
|
+
id: z.string(),
|
|
91
|
+
title: z.string(),
|
|
92
|
+
url: z.string()
|
|
93
|
+
})).describe("Organizations, projects, branches, computes, and snapshots that match.") });
|
|
89
94
|
const searchResourcesTool = (options) => {
|
|
90
95
|
const consoleUrl = consoleBaseUrl(options.baseUrl ?? "https://console.neon.tech/api/v2");
|
|
91
96
|
return bindTool(options, {
|
|
@@ -94,6 +99,7 @@ const searchResourcesTool = (options) => {
|
|
|
94
99
|
title: "Search Neon resources",
|
|
95
100
|
description: "Finds organizations, projects (including shared ones), branches, computes, and snapshots whose name or id contains query, with ids for {{resources.fetch}}. To list projects, use {{projects.list}}; for docs, {{docs.search}}.",
|
|
96
101
|
inputSchema: searchResourcesInputSchema,
|
|
102
|
+
outputSchema: searchResourcesOutputSchema,
|
|
97
103
|
annotations: {
|
|
98
104
|
readOnlyHint: true,
|
|
99
105
|
destructiveHint: false,
|
|
@@ -103,6 +109,7 @@ const searchResourcesTool = (options) => {
|
|
|
103
109
|
requiresApproval: false,
|
|
104
110
|
metadata: {
|
|
105
111
|
method: "GET",
|
|
112
|
+
readOnlySafe: true,
|
|
106
113
|
path: "/projects",
|
|
107
114
|
stability: "stable",
|
|
108
115
|
deprecated: false,
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { type NeonClient } from "@neon/sdk";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
-
import type { NeonToolExecutionContext,
|
|
3
|
+
import type { NeonToolExecutionContext, NeonToolMetadataInput } from "../../operation.js";
|
|
4
4
|
export declare const NEON_DEFAULT_DATABASE_NAME = "neondb";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* `readOnlySafe` for a tool that runs caller SQL means it runs one statement
|
|
7
|
+
* in its own `READ ONLY` transaction when `readOnly` is set.
|
|
8
|
+
*/
|
|
9
|
+
export declare const sqlMetadata: (readOnlySafe: boolean) => NeonToolMetadataInput;
|
|
6
10
|
export declare const DATABASE_NAME_DESCRIPTION = "Database name. Omit for neondb, else the first database.";
|
|
7
11
|
export declare const projectIdField: z.ZodString;
|
|
8
12
|
export declare const branchIdField: z.ZodOptional<z.ZodString>;
|
|
@@ -38,9 +42,4 @@ export declare const defaultDatabase: (neonClient: NeonClient<true>, ids: {
|
|
|
38
42
|
*/
|
|
39
43
|
export declare const resolveConnection: (neonClient: NeonClient<true>, target: ConnectionTarget, context: NeonToolExecutionContext, signal?: AbortSignal) => Promise<ResolvedConnection>;
|
|
40
44
|
export declare const sqlClient: (uri: string, signal?: AbortSignal) => import("@neondatabase/serverless").NeonQueryFunction<false, false>;
|
|
41
|
-
/**
|
|
42
|
-
* Caller SQL that shares one transaction can escape `READ ONLY` with `COMMIT`
|
|
43
|
-
* or `SET TRANSACTION READ WRITE`, so these tools refuse instead.
|
|
44
|
-
*/
|
|
45
|
-
export declare const refuseInReadOnly: (context: NeonToolExecutionContext) => void;
|
|
46
45
|
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../src/lib/custom/sql/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAmB,MAAM,WAAW,CAAC;AAE7D,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,KAAK,EACX,wBAAwB,EACxB,
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../src/lib/custom/sql/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAmB,MAAM,WAAW,CAAC;AAE7D,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,KAAK,EACX,wBAAwB,EACxB,qBAAqB,EACrB,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,0BAA0B,WAAW,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,cAAc,OAAO,KAAG,qBAOlD,CAAC;AAEH,eAAO,MAAM,yBAAyB,6DAAoF,CAAC;AAE3H,eAAO,MAAM,cAAc,aAEiB,CAAC;AAE7C,eAAO,MAAM,aAAa,4BAKxB,CAAC;AAEH,eAAO,MAAM,iBAAiB,4BAGO,CAAC;AAEtC,eAAO,MAAM,aAAa,4BAG4C,CAAC;AAEvE,eAAO,MAAM,sBAAsB,mEAC8B,CAAC;AAElE,eAAO,MAAM,cAAc,4BAGO,CAAC;AAEnC,MAAM,WAAW,gBAAgB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qEAAqE;AACrE,eAAO,MAAM,eAAe,GAC3B,YAAY,UAAU,CAAC,IAAI,CAAC,EAC5B,KAAK;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC5C,SAAS,WAAW,0CAcpB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC7B,YAAY,UAAU,CAAC,IAAI,CAAC,EAC5B,QAAQ,gBAAgB,EACxB,SAAS,wBAAwB,EACjC,SAAS,WAAW,KAClB,OAAO,CAAC,kBAAkB,CAyD5B,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,EAAE,SAAS,WAAW,uEACS,CAAC"}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { pathInputDescriptions } from "../../../descriptions.gen.js";
|
|
2
|
-
import { NeonClientError } from "@neon/sdk";
|
|
3
2
|
import { neon } from "@neondatabase/serverless";
|
|
4
3
|
import * as z from "zod";
|
|
4
|
+
import { NeonClientError } from "@neon/sdk";
|
|
5
5
|
// src/lib/custom/sql/connection.ts
|
|
6
6
|
const NEON_DEFAULT_DATABASE_NAME = "neondb";
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* `readOnlySafe` for a tool that runs caller SQL means it runs one statement
|
|
9
|
+
* in its own `READ ONLY` transaction when `readOnly` is set.
|
|
10
|
+
*/
|
|
11
|
+
const sqlMetadata = (readOnlySafe) => ({
|
|
8
12
|
method: "SQL",
|
|
9
13
|
path: "/projects/{project_id}/connection_uri",
|
|
10
14
|
stability: "stable",
|
|
11
15
|
deprecated: false,
|
|
12
|
-
tags: ["SQL"]
|
|
13
|
-
|
|
16
|
+
tags: ["SQL"],
|
|
17
|
+
readOnlySafe
|
|
18
|
+
});
|
|
14
19
|
const DATABASE_NAME_DESCRIPTION = `Database name. Omit for ${NEON_DEFAULT_DATABASE_NAME}, else the first database.`;
|
|
15
20
|
const projectIdField = z.string().describe(pathInputDescriptions.project_id);
|
|
16
21
|
const branchIdField = z.string().optional().describe(`${pathInputDescriptions.branch_id} Omit it for the default branch.`);
|
|
@@ -68,11 +73,4 @@ const resolveConnection = async (neonClient, target, context, signal) => {
|
|
|
68
73
|
};
|
|
69
74
|
};
|
|
70
75
|
const sqlClient = (uri, signal) => neon(uri, signal === void 0 ? {} : { fetchOptions: { signal } });
|
|
71
|
-
|
|
72
|
-
* Caller SQL that shares one transaction can escape `READ ONLY` with `COMMIT`
|
|
73
|
-
* or `SET TRANSACTION READ WRITE`, so these tools refuse instead.
|
|
74
|
-
*/
|
|
75
|
-
const refuseInReadOnly = (context) => {
|
|
76
|
-
if (context.readOnly === true) throw new NeonClientError("This tool is unavailable in read-only mode because it runs caller SQL that can leave a read-only transaction.");
|
|
77
|
-
};
|
|
78
|
-
export { COMPUTE_ID_DESCRIPTION, DATABASE_NAME_DESCRIPTION, NEON_DEFAULT_DATABASE_NAME, SQL_METADATA, branchIdField, computeIdField, databaseNameField, defaultDatabase, projectIdField, refuseInReadOnly, resolveConnection, roleNameField, sqlClient };
|
|
76
|
+
export { COMPUTE_ID_DESCRIPTION, DATABASE_NAME_DESCRIPTION, NEON_DEFAULT_DATABASE_NAME, branchIdField, computeIdField, databaseNameField, defaultDatabase, projectIdField, resolveConnection, roleNameField, sqlClient, sqlMetadata };
|
|
@@ -80,5 +80,103 @@ export declare const describeBranchTool: (options: ToolClientOptions) => import(
|
|
|
80
80
|
[x: string]: unknown;
|
|
81
81
|
}[][] | null;
|
|
82
82
|
database_structure_error?: string | null | undefined;
|
|
83
|
-
}
|
|
83
|
+
}, z.ZodObject<{
|
|
84
|
+
branch: z.ZodObject<{
|
|
85
|
+
id: z.ZodString;
|
|
86
|
+
project_id: z.ZodString;
|
|
87
|
+
parent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
88
|
+
parent_lsn: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
89
|
+
parent_timestamp: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
90
|
+
name: z.ZodString;
|
|
91
|
+
current_state: z.ZodString;
|
|
92
|
+
pending_state: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
93
|
+
state_changed_at: z.ZodString;
|
|
94
|
+
logical_size: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
95
|
+
creation_source: z.ZodString;
|
|
96
|
+
primary: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
97
|
+
default: z.ZodBoolean;
|
|
98
|
+
protected: z.ZodBoolean;
|
|
99
|
+
cpu_used_sec: z.ZodNumber;
|
|
100
|
+
compute_time_seconds: z.ZodNumber;
|
|
101
|
+
active_time_seconds: z.ZodNumber;
|
|
102
|
+
written_data_bytes: z.ZodNumber;
|
|
103
|
+
data_transfer_bytes: z.ZodNumber;
|
|
104
|
+
created_at: z.ZodString;
|
|
105
|
+
updated_at: z.ZodString;
|
|
106
|
+
ttl_interval_seconds: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
107
|
+
expires_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
108
|
+
last_reset_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
109
|
+
created_by: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
110
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
111
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
112
|
+
}, z.core.$loose>>>;
|
|
113
|
+
init_source: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
114
|
+
restore_status: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
115
|
+
restored_from: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
116
|
+
restored_as: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
117
|
+
restricted_actions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
118
|
+
name: z.ZodString;
|
|
119
|
+
reason: z.ZodString;
|
|
120
|
+
}, z.core.$loose>>>>;
|
|
121
|
+
recovery: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
122
|
+
deleted_at: z.ZodString;
|
|
123
|
+
recoverable_until: z.ZodString;
|
|
124
|
+
deletion_method: z.ZodString;
|
|
125
|
+
}, z.core.$loose>>>;
|
|
126
|
+
}, z.core.$loose>;
|
|
127
|
+
console_url: z.ZodString;
|
|
128
|
+
text: z.ZodString;
|
|
129
|
+
database_structure: z.ZodNullable<z.ZodArray<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>>;
|
|
130
|
+
database_structure_error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
131
|
+
}, z.core.$loose>> & {
|
|
132
|
+
outputSchema: z.ZodObject<{
|
|
133
|
+
branch: z.ZodObject<{
|
|
134
|
+
id: z.ZodString;
|
|
135
|
+
project_id: z.ZodString;
|
|
136
|
+
parent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
137
|
+
parent_lsn: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
138
|
+
parent_timestamp: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
139
|
+
name: z.ZodString;
|
|
140
|
+
current_state: z.ZodString;
|
|
141
|
+
pending_state: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
142
|
+
state_changed_at: z.ZodString;
|
|
143
|
+
logical_size: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
144
|
+
creation_source: z.ZodString;
|
|
145
|
+
primary: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
146
|
+
default: z.ZodBoolean;
|
|
147
|
+
protected: z.ZodBoolean;
|
|
148
|
+
cpu_used_sec: z.ZodNumber;
|
|
149
|
+
compute_time_seconds: z.ZodNumber;
|
|
150
|
+
active_time_seconds: z.ZodNumber;
|
|
151
|
+
written_data_bytes: z.ZodNumber;
|
|
152
|
+
data_transfer_bytes: z.ZodNumber;
|
|
153
|
+
created_at: z.ZodString;
|
|
154
|
+
updated_at: z.ZodString;
|
|
155
|
+
ttl_interval_seconds: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
156
|
+
expires_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
157
|
+
last_reset_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
158
|
+
created_by: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
159
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
160
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
161
|
+
}, z.core.$loose>>>;
|
|
162
|
+
init_source: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
163
|
+
restore_status: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
164
|
+
restored_from: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
165
|
+
restored_as: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
166
|
+
restricted_actions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
167
|
+
name: z.ZodString;
|
|
168
|
+
reason: z.ZodString;
|
|
169
|
+
}, z.core.$loose>>>>;
|
|
170
|
+
recovery: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
171
|
+
deleted_at: z.ZodString;
|
|
172
|
+
recoverable_until: z.ZodString;
|
|
173
|
+
deletion_method: z.ZodString;
|
|
174
|
+
}, z.core.$loose>>>;
|
|
175
|
+
}, z.core.$loose>;
|
|
176
|
+
console_url: z.ZodString;
|
|
177
|
+
text: z.ZodString;
|
|
178
|
+
database_structure: z.ZodNullable<z.ZodArray<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>>;
|
|
179
|
+
database_structure_error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
180
|
+
}, z.core.$loose>;
|
|
181
|
+
};
|
|
84
182
|
//# sourceMappingURL=describe-branch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe-branch.d.ts","sourceRoot":"","sources":["../../../../src/lib/custom/sql/describe-branch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"describe-branch.d.ts","sourceRoot":"","sources":["../../../../src/lib/custom/sql/describe-branch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAGzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AASnE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGrC,eAAO,MAAM,yBAAyB;;;;kBAIpC,CAAC;AAkFH,eAAO,MAAM,gBAAgB,GAC5B,YAAY,MAAM,EAClB,WAAW,MAAM,EACjB,UAAU,MAAM,WAKJ,CAAC;AAoBd,MAAM,WAAW,iBAAiB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,kBAAkB,EAAE,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC;IACnC,wBAAwB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,eAAO,MAAM,cAAc,GAC1B,YAAY,UAAU,CAAC,IAAI,CAAC,EAC5B,OAAO;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,EACxE,SAAS,wBAAwB,EACjC,YAAY,MAAM,EAClB,SAAS,WAAW,KAClB,OAAO,CAAC,iBAAiB,CA6C3B,CAAC;AAaF,eAAO,MAAM,kBAAkB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA3E/C,MAAM;UAEb,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4FZ,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { pathInputDescriptions } from "../../../descriptions.gen.js";
|
|
2
2
|
import { bindTool, publishedId } from "../../ergonomic/bind.js";
|
|
3
|
-
import {
|
|
3
|
+
import { databaseNameField, projectIdField, resolveConnection, sqlClient, sqlMetadata } from "./connection.js";
|
|
4
4
|
import { sqlReadAnnotations } from "./schema.js";
|
|
5
|
+
import { Branch } from "../../../generated/output.gen.js";
|
|
5
6
|
import { consoleBaseUrl } from "../resources.js";
|
|
6
7
|
import * as z from "zod";
|
|
7
8
|
// src/lib/custom/sql/describe-branch.ts
|
|
@@ -139,6 +140,13 @@ const describeBranch = async (neonClient, input, context, consoleUrl, signal) =>
|
|
|
139
140
|
};
|
|
140
141
|
}
|
|
141
142
|
};
|
|
143
|
+
const describeBranchOutputSchema = z.looseObject({
|
|
144
|
+
branch: Branch,
|
|
145
|
+
console_url: z.string(),
|
|
146
|
+
text: z.string().describe("The branch details and database tree as text."),
|
|
147
|
+
database_structure: z.array(z.array(z.record(z.string(), z.unknown()))).nullable().describe("`[[], treeRows]`, or null when the tree query failed."),
|
|
148
|
+
database_structure_error: z.string().nullish()
|
|
149
|
+
});
|
|
142
150
|
const describeBranchTool = (options) => {
|
|
143
151
|
const consoleUrl = consoleBaseUrl(options.baseUrl ?? "https://console.neon.tech/api/v2");
|
|
144
152
|
return bindTool(options, {
|
|
@@ -147,9 +155,10 @@ const describeBranchTool = (options) => {
|
|
|
147
155
|
title: "Describe Branch",
|
|
148
156
|
description: "Returns a branch summary, its database names, and a tree of one database's schemas, tables, views, indexes, sequences, and functions. Starts a suspended compute. Branch record only: {{branches.get}}; table names: {{schema.listTables}}; columns: {{schema.describeTable}}.",
|
|
149
157
|
inputSchema: describeBranchInputSchema,
|
|
158
|
+
outputSchema: describeBranchOutputSchema,
|
|
150
159
|
annotations: sqlReadAnnotations,
|
|
151
160
|
requiresApproval: false,
|
|
152
|
-
metadata:
|
|
161
|
+
metadata: sqlMetadata(true)
|
|
153
162
|
}, (neonClient, input, signal, context) => describeBranch(neonClient, input, context, consoleUrl, signal));
|
|
154
163
|
};
|
|
155
164
|
export { branchConsoleUrl, describeBranch, describeBranchInputSchema, describeBranchTool };
|
|
@@ -71,5 +71,31 @@ export declare const inspectDatabaseTool: (options: ToolClientOptions) => import
|
|
|
71
71
|
}[];
|
|
72
72
|
truncated: boolean;
|
|
73
73
|
note?: string | null | undefined;
|
|
74
|
-
}
|
|
74
|
+
}, z.ZodObject<{
|
|
75
|
+
check: z.ZodString;
|
|
76
|
+
describe: z.ZodString;
|
|
77
|
+
projectId: z.ZodString;
|
|
78
|
+
branchId: z.ZodString;
|
|
79
|
+
databaseName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
80
|
+
databases: z.ZodArray<z.ZodString>;
|
|
81
|
+
fields: z.ZodArray<z.ZodString>;
|
|
82
|
+
totalRowCount: z.ZodNumber;
|
|
83
|
+
rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
84
|
+
truncated: z.ZodBoolean;
|
|
85
|
+
note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
86
|
+
}, z.core.$loose>> & {
|
|
87
|
+
outputSchema: z.ZodObject<{
|
|
88
|
+
check: z.ZodString;
|
|
89
|
+
describe: z.ZodString;
|
|
90
|
+
projectId: z.ZodString;
|
|
91
|
+
branchId: z.ZodString;
|
|
92
|
+
databaseName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
93
|
+
databases: z.ZodArray<z.ZodString>;
|
|
94
|
+
fields: z.ZodArray<z.ZodString>;
|
|
95
|
+
totalRowCount: z.ZodNumber;
|
|
96
|
+
rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
97
|
+
truncated: z.ZodBoolean;
|
|
98
|
+
note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
99
|
+
}, z.core.$loose>;
|
|
100
|
+
};
|
|
75
101
|
//# sourceMappingURL=inspect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../../../../src/lib/custom/sql/inspect/inspect.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,4BAA4B,CAAC;AAUpC,OAAO,EAKN,KAAK,YAAY,EACjB,MAAM,cAAc,CAAC;AAItB;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAChD,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO;CAKhE;AAED,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;kBAsBrC,CAAC;
|
|
1
|
+
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../../../../src/lib/custom/sql/inspect/inspect.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,4BAA4B,CAAC;AAUpC,OAAO,EAKN,KAAK,YAAY,EACjB,MAAM,cAAc,CAAC;AAItB;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAChD,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO;CAKhE;AAED,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;kBAsBrC,CAAC;AAuFH,eAAO,MAAM,mBAAmB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4G5D,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { INSPECT_CHECKS, INSPECT_MAX_LIMIT, INSPECT_QUERIES } from "./queries.js";
|
|
2
2
|
import { assembleInspectReport } from "./report.js";
|
|
3
3
|
import { bindTool, publishedId } from "../../../ergonomic/bind.js";
|
|
4
|
-
import {
|
|
4
|
+
import { branchIdField, computeIdField, projectIdField, resolveConnection, sqlClient, sqlMetadata } from "../connection.js";
|
|
5
5
|
import { sqlReadAnnotations } from "../schema.js";
|
|
6
6
|
import { formatInspectQueryError, selectInspectTargets } from "./targets.js";
|
|
7
|
-
import { NeonClientError } from "@neon/sdk";
|
|
8
7
|
import { NeonDbError } from "@neondatabase/serverless";
|
|
9
8
|
import * as z from "zod";
|
|
9
|
+
import { NeonClientError } from "@neon/sdk";
|
|
10
10
|
// src/lib/custom/sql/inspect/inspect.ts
|
|
11
11
|
/**
|
|
12
12
|
* Postgres rejected one of the package's own diagnostic queries. That is a bug
|
|
@@ -66,15 +66,29 @@ const rethrowInspectError = (error, wrapped) => {
|
|
|
66
66
|
}
|
|
67
67
|
throw new Error(wrapped, { cause: error });
|
|
68
68
|
};
|
|
69
|
+
const inspectDatabaseOutputSchema = z.looseObject({
|
|
70
|
+
check: z.string().describe("The check that ran."),
|
|
71
|
+
describe: z.string().describe("What the check reports."),
|
|
72
|
+
projectId: z.string(),
|
|
73
|
+
branchId: z.string(),
|
|
74
|
+
databaseName: z.string().nullish(),
|
|
75
|
+
databases: z.array(z.string()).describe("Databases the check covered."),
|
|
76
|
+
fields: z.array(z.string()).describe("Column names in rows."),
|
|
77
|
+
totalRowCount: z.number(),
|
|
78
|
+
rows: z.array(z.record(z.string(), z.unknown())),
|
|
79
|
+
truncated: z.boolean(),
|
|
80
|
+
note: z.string().nullish()
|
|
81
|
+
});
|
|
69
82
|
const inspectDatabaseTool = (options) => bindTool(options, {
|
|
70
83
|
operationId: "database.inspect",
|
|
71
84
|
id: publishedId("database.inspect"),
|
|
72
85
|
title: "Inspect Database",
|
|
73
86
|
description: "Runs one read-only neon inspect db check; some are compute-wide. outliers ranks queries by total time and calls by count, both via pg_stat_statements; lfc-hit-rate and working-set need the neon extension. If one is missing, the error gives the CREATE EXTENSION; ask before running it. Other SQL: {{sql.run}}; one plan: {{sql.explain}}; new indexes: {{queryTuning.prepare}}.",
|
|
74
87
|
inputSchema: inspectDatabaseInputSchema,
|
|
88
|
+
outputSchema: inspectDatabaseOutputSchema,
|
|
75
89
|
annotations: sqlReadAnnotations,
|
|
76
90
|
requiresApproval: false,
|
|
77
|
-
metadata:
|
|
91
|
+
metadata: sqlMetadata(true)
|
|
78
92
|
}, async (neonClient, input, signal, context) => {
|
|
79
93
|
const { check, database_name: databaseName, limit } = input;
|
|
80
94
|
const query = INSPECT_QUERIES[check];
|
|
@@ -44,7 +44,39 @@ export declare const prepareMigrationTool: (options: ToolClientOptions) => impor
|
|
|
44
44
|
migration_result: {
|
|
45
45
|
[x: string]: unknown;
|
|
46
46
|
}[][];
|
|
47
|
-
}
|
|
47
|
+
}, z.ZodObject<{
|
|
48
|
+
complete: z.ZodObject<{
|
|
49
|
+
migration_id: z.ZodString;
|
|
50
|
+
migration_sql: z.ZodString;
|
|
51
|
+
database_name: z.ZodString;
|
|
52
|
+
project_id: z.ZodString;
|
|
53
|
+
temporary_branch_id: z.ZodString;
|
|
54
|
+
parent_branch_id: z.ZodString;
|
|
55
|
+
}, z.core.$loose>;
|
|
56
|
+
temporary_branch: z.ZodObject<{
|
|
57
|
+
id: z.ZodString;
|
|
58
|
+
name: z.ZodString;
|
|
59
|
+
parent_id: z.ZodString;
|
|
60
|
+
}, z.core.$loose>;
|
|
61
|
+
migration_result: z.ZodArray<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
62
|
+
}, z.core.$loose>> & {
|
|
63
|
+
outputSchema: z.ZodObject<{
|
|
64
|
+
complete: z.ZodObject<{
|
|
65
|
+
migration_id: z.ZodString;
|
|
66
|
+
migration_sql: z.ZodString;
|
|
67
|
+
database_name: z.ZodString;
|
|
68
|
+
project_id: z.ZodString;
|
|
69
|
+
temporary_branch_id: z.ZodString;
|
|
70
|
+
parent_branch_id: z.ZodString;
|
|
71
|
+
}, z.core.$loose>;
|
|
72
|
+
temporary_branch: z.ZodObject<{
|
|
73
|
+
id: z.ZodString;
|
|
74
|
+
name: z.ZodString;
|
|
75
|
+
parent_id: z.ZodString;
|
|
76
|
+
}, z.core.$loose>;
|
|
77
|
+
migration_result: z.ZodArray<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
78
|
+
}, z.core.$loose>;
|
|
79
|
+
};
|
|
48
80
|
export declare const completeMigrationTool: (options: ToolClientOptions) => import("../../operation.js").NeonTool<z.ZodObject<{
|
|
49
81
|
migration_id: z.ZodString;
|
|
50
82
|
migration_sql: z.ZodString;
|
|
@@ -65,5 +97,17 @@ export declare const completeMigrationTool: (options: ToolClientOptions) => impo
|
|
|
65
97
|
}[][] | null | undefined;
|
|
66
98
|
cleanupError: string;
|
|
67
99
|
applied: boolean;
|
|
68
|
-
}
|
|
100
|
+
}, z.ZodObject<{
|
|
101
|
+
applied: z.ZodBoolean;
|
|
102
|
+
migrationResult: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>>>;
|
|
103
|
+
deletedBranchId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
104
|
+
cleanupError: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
105
|
+
}, z.core.$loose>> & {
|
|
106
|
+
outputSchema: z.ZodObject<{
|
|
107
|
+
applied: z.ZodBoolean;
|
|
108
|
+
migrationResult: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>>>;
|
|
109
|
+
deletedBranchId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
110
|
+
cleanupError: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
111
|
+
}, z.core.$loose>;
|
|
112
|
+
};
|
|
69
113
|
//# sourceMappingURL=migrations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../../src/lib/custom/sql/migrations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,UAAU,EAAmB,MAAM,WAAW,CAAC;AAE1E,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../../src/lib/custom/sql/migrations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,UAAU,EAAmB,MAAM,WAAW,CAAC;AAE1E,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,yBAAyB,CAAC;AAajC,mFAAmF;AACnF,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,KAAG,MAAM,EACxB,CAAC;AA8BhC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAU,CAAC,EAC1C,YAAY,UAAU,CAAC,IAAI,CAAC,EAC5B,WAAW,MAAM,EACjB,MAAM,MAAM,GAAG,SAAS,EACxB,QAAQ,WAAW,GAAG,SAAS,EAC/B,KAAK,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,KACjC,OAAO,CAAC,CAAC,CAgCX,CAAC;AAMF,eAAO,MAAM,2BAA2B;;;;kBAQtC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;kBAuBvC,CAAC;AAyBH,eAAO,MAAM,oBAAoB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyE7D,CAAC;AAcH,eAAO,MAAM,qBAAqB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoD9D,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { bindTool, publishedId } from "../../ergonomic/bind.js";
|
|
2
|
-
import { DATABASE_NAME_DESCRIPTION,
|
|
3
|
-
import { runTransaction, sqlWriteAnnotations } from "./run.js";
|
|
4
|
-
import { NeonClientError } from "@neon/sdk";
|
|
2
|
+
import { DATABASE_NAME_DESCRIPTION, defaultDatabase, projectIdField, sqlMetadata } from "./connection.js";
|
|
3
|
+
import { runTransaction, sqlRowsOutputSchema, sqlWriteAnnotations } from "./run.js";
|
|
5
4
|
import * as z from "zod";
|
|
5
|
+
import { NeonClientError } from "@neon/sdk";
|
|
6
6
|
import { createProjectBranch } from "@neon/sdk/raw";
|
|
7
7
|
import { randomUUID } from "node:crypto";
|
|
8
8
|
// src/lib/custom/sql/migrations.ts
|
|
@@ -63,12 +63,29 @@ const completeMigrationInputSchema = z.strictObject({
|
|
|
63
63
|
parent_branch_id: z.string().describe("The branch the migration is applied to."),
|
|
64
64
|
apply_changes: z.boolean().default(true).describe("Apply the migration to the parent branch. false only deletes the temporary branch.")
|
|
65
65
|
});
|
|
66
|
+
const prepareMigrationOutputSchema = z.looseObject({
|
|
67
|
+
complete: z.looseObject({
|
|
68
|
+
migration_id: z.string(),
|
|
69
|
+
migration_sql: z.string(),
|
|
70
|
+
database_name: z.string(),
|
|
71
|
+
project_id: z.string(),
|
|
72
|
+
temporary_branch_id: z.string(),
|
|
73
|
+
parent_branch_id: z.string()
|
|
74
|
+
}).describe("The values that apply or discard the migration."),
|
|
75
|
+
temporary_branch: z.looseObject({
|
|
76
|
+
id: z.string(),
|
|
77
|
+
name: z.string(),
|
|
78
|
+
parent_id: z.string()
|
|
79
|
+
}).describe("The branch the migration ran on."),
|
|
80
|
+
migration_result: z.array(sqlRowsOutputSchema).describe("Rows per statement.")
|
|
81
|
+
});
|
|
66
82
|
const prepareMigrationTool = (options) => bindTool(options, {
|
|
67
83
|
operationId: "migrations.prepare",
|
|
68
84
|
id: publishedId("migrations.prepare"),
|
|
69
85
|
title: "Prepare Database Migration",
|
|
70
86
|
description: "Applies a schema change on a new temporary branch and returns a migration_id. Test it there with {{sql.run}}, ask the user, then always call {{migrations.complete}} with the response's complete object so the branch is deleted.",
|
|
71
87
|
inputSchema: prepareMigrationInputSchema,
|
|
88
|
+
outputSchema: prepareMigrationOutputSchema,
|
|
72
89
|
annotations: {
|
|
73
90
|
readOnlyHint: false,
|
|
74
91
|
destructiveHint: false,
|
|
@@ -76,9 +93,8 @@ const prepareMigrationTool = (options) => bindTool(options, {
|
|
|
76
93
|
openWorldHint: false
|
|
77
94
|
},
|
|
78
95
|
requiresApproval: true,
|
|
79
|
-
metadata:
|
|
96
|
+
metadata: sqlMetadata(false)
|
|
80
97
|
}, async (neonClient, input, signal, context) => {
|
|
81
|
-
refuseInReadOnly(context);
|
|
82
98
|
const projectId = input.project_id;
|
|
83
99
|
return withTemporaryBranch(neonClient, projectId, migrationBranchName(), signal, async (branch) => {
|
|
84
100
|
const parentBranchId = branch.parent_id;
|
|
@@ -110,17 +126,23 @@ const prepareMigrationTool = (options) => bindTool(options, {
|
|
|
110
126
|
};
|
|
111
127
|
});
|
|
112
128
|
});
|
|
129
|
+
const completeMigrationOutputSchema = z.looseObject({
|
|
130
|
+
applied: z.boolean().describe("Whether the migration ran on the parent branch."),
|
|
131
|
+
migrationResult: z.array(sqlRowsOutputSchema).nullish(),
|
|
132
|
+
deletedBranchId: z.string().nullish(),
|
|
133
|
+
cleanupError: z.string().nullish().describe("Set when the temporary branch could not be deleted.")
|
|
134
|
+
});
|
|
113
135
|
const completeMigrationTool = (options) => bindTool(options, {
|
|
114
136
|
operationId: "migrations.complete",
|
|
115
137
|
id: publishedId("migrations.complete"),
|
|
116
138
|
title: "Complete Database Migration",
|
|
117
139
|
description: "Applies or discards a prepared migration and deletes the temporary branch. NEVER run autonomously; always ask the user first. Pass the complete object from {{migrations.prepare}}; apply_changes false discards.",
|
|
118
140
|
inputSchema: completeMigrationInputSchema,
|
|
141
|
+
outputSchema: completeMigrationOutputSchema,
|
|
119
142
|
annotations: sqlWriteAnnotations,
|
|
120
143
|
requiresApproval: true,
|
|
121
|
-
metadata:
|
|
144
|
+
metadata: sqlMetadata(false)
|
|
122
145
|
}, async (neonClient, input, signal, context) => {
|
|
123
|
-
refuseInReadOnly(context);
|
|
124
146
|
const migrationResult = input.apply_changes ? await runTransaction(neonClient, {
|
|
125
147
|
project_id: input.project_id,
|
|
126
148
|
branch_id: input.parent_branch_id,
|
|
@@ -85,7 +85,83 @@ export declare const prepareQueryTuningTool: (options: ToolClientOptions) => imp
|
|
|
85
85
|
};
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
|
-
}
|
|
88
|
+
}, z.ZodObject<{
|
|
89
|
+
complete: z.ZodObject<{
|
|
90
|
+
tuning_id: z.ZodString;
|
|
91
|
+
database_name: z.ZodString;
|
|
92
|
+
project_id: z.ZodString;
|
|
93
|
+
temporary_branch_id: z.ZodString;
|
|
94
|
+
role_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
95
|
+
}, z.core.$loose>;
|
|
96
|
+
execution_plan: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
97
|
+
table_schemas: z.ZodArray<z.ZodObject<{
|
|
98
|
+
tableName: z.ZodString;
|
|
99
|
+
schema: z.ZodObject<{
|
|
100
|
+
columns: z.ZodArray<z.ZodObject<{
|
|
101
|
+
name: z.ZodString;
|
|
102
|
+
type: z.ZodString;
|
|
103
|
+
nullable: z.ZodBoolean;
|
|
104
|
+
default: z.ZodNullable<z.ZodString>;
|
|
105
|
+
description: z.ZodNullable<z.ZodString>;
|
|
106
|
+
}, z.core.$loose>>;
|
|
107
|
+
indexes: z.ZodArray<z.ZodObject<{
|
|
108
|
+
name: z.ZodString;
|
|
109
|
+
definition: z.ZodString;
|
|
110
|
+
size: z.ZodString;
|
|
111
|
+
}, z.core.$loose>>;
|
|
112
|
+
constraints: z.ZodArray<z.ZodObject<{
|
|
113
|
+
name: z.ZodString;
|
|
114
|
+
type: z.ZodString;
|
|
115
|
+
definition: z.ZodString;
|
|
116
|
+
}, z.core.$loose>>;
|
|
117
|
+
tableSize: z.ZodString;
|
|
118
|
+
indexSize: z.ZodString;
|
|
119
|
+
totalSize: z.ZodString;
|
|
120
|
+
}, z.core.$loose>;
|
|
121
|
+
formatted: z.ZodString;
|
|
122
|
+
}, z.core.$loose>>;
|
|
123
|
+
sql: z.ZodString;
|
|
124
|
+
baseline_metrics: z.ZodObject<{}, z.core.$loose>;
|
|
125
|
+
}, z.core.$loose>> & {
|
|
126
|
+
outputSchema: z.ZodObject<{
|
|
127
|
+
complete: z.ZodObject<{
|
|
128
|
+
tuning_id: z.ZodString;
|
|
129
|
+
database_name: z.ZodString;
|
|
130
|
+
project_id: z.ZodString;
|
|
131
|
+
temporary_branch_id: z.ZodString;
|
|
132
|
+
role_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
133
|
+
}, z.core.$loose>;
|
|
134
|
+
execution_plan: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
135
|
+
table_schemas: z.ZodArray<z.ZodObject<{
|
|
136
|
+
tableName: z.ZodString;
|
|
137
|
+
schema: z.ZodObject<{
|
|
138
|
+
columns: z.ZodArray<z.ZodObject<{
|
|
139
|
+
name: z.ZodString;
|
|
140
|
+
type: z.ZodString;
|
|
141
|
+
nullable: z.ZodBoolean;
|
|
142
|
+
default: z.ZodNullable<z.ZodString>;
|
|
143
|
+
description: z.ZodNullable<z.ZodString>;
|
|
144
|
+
}, z.core.$loose>>;
|
|
145
|
+
indexes: z.ZodArray<z.ZodObject<{
|
|
146
|
+
name: z.ZodString;
|
|
147
|
+
definition: z.ZodString;
|
|
148
|
+
size: z.ZodString;
|
|
149
|
+
}, z.core.$loose>>;
|
|
150
|
+
constraints: z.ZodArray<z.ZodObject<{
|
|
151
|
+
name: z.ZodString;
|
|
152
|
+
type: z.ZodString;
|
|
153
|
+
definition: z.ZodString;
|
|
154
|
+
}, z.core.$loose>>;
|
|
155
|
+
tableSize: z.ZodString;
|
|
156
|
+
indexSize: z.ZodString;
|
|
157
|
+
totalSize: z.ZodString;
|
|
158
|
+
}, z.core.$loose>;
|
|
159
|
+
formatted: z.ZodString;
|
|
160
|
+
}, z.core.$loose>>;
|
|
161
|
+
sql: z.ZodString;
|
|
162
|
+
baseline_metrics: z.ZodObject<{}, z.core.$loose>;
|
|
163
|
+
}, z.core.$loose>;
|
|
164
|
+
};
|
|
89
165
|
export declare const completeQueryTuningTool: (options: ToolClientOptions) => import("../../operation.js").NeonTool<z.ZodObject<{
|
|
90
166
|
suggested_sql_statements: z.ZodArray<z.ZodString>;
|
|
91
167
|
apply_changes: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -103,5 +179,17 @@ export declare const completeQueryTuningTool: (options: ToolClientOptions) => im
|
|
|
103
179
|
[x: string]: unknown;
|
|
104
180
|
}[][] | null | undefined;
|
|
105
181
|
appliedChanges?: string[] | null | undefined;
|
|
106
|
-
}
|
|
182
|
+
}, z.ZodObject<{
|
|
183
|
+
message: z.ZodString;
|
|
184
|
+
appliedChanges: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
185
|
+
results: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>>>;
|
|
186
|
+
deletedBranches: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
187
|
+
}, z.core.$loose>> & {
|
|
188
|
+
outputSchema: z.ZodObject<{
|
|
189
|
+
message: z.ZodString;
|
|
190
|
+
appliedChanges: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
191
|
+
results: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>>>;
|
|
192
|
+
deletedBranches: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
193
|
+
}, z.core.$loose>;
|
|
194
|
+
};
|
|
107
195
|
//# sourceMappingURL=query-tuning.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-tuning.d.ts","sourceRoot":"","sources":["../../../../src/lib/custom/sql/query-tuning.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,yBAAyB,CAAC;AAgBjC,eAAO,MAAM,6BAA6B;;;;;kBAQxC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;kBAsCzC,CAAC;
|
|
1
|
+
{"version":3,"file":"query-tuning.d.ts","sourceRoot":"","sources":["../../../../src/lib/custom/sql/query-tuning.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,yBAAyB,CAAC;AAgBjC,eAAO,MAAM,6BAA6B;;;;;kBAQxC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;kBAsCzC,CAAC;AA4BH,eAAO,MAAM,sBAAsB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8F/D,CAAC;AASH,eAAO,MAAM,uBAAuB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmEhE,CAAC"}
|