taurusdb-core 0.1.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 +21 -0
- package/dist/auth/secret-resolver.d.ts +16 -0
- package/dist/auth/secret-resolver.js +64 -0
- package/dist/auth/sql-profile-loader/env-source.d.ts +3 -0
- package/dist/auth/sql-profile-loader/env-source.js +94 -0
- package/dist/auth/sql-profile-loader/file-source.d.ts +6 -0
- package/dist/auth/sql-profile-loader/file-source.js +40 -0
- package/dist/auth/sql-profile-loader/loader.d.ts +16 -0
- package/dist/auth/sql-profile-loader/loader.js +81 -0
- package/dist/auth/sql-profile-loader/parsing.d.ts +14 -0
- package/dist/auth/sql-profile-loader/parsing.js +216 -0
- package/dist/auth/sql-profile-loader/runtime-override.d.ts +14 -0
- package/dist/auth/sql-profile-loader/runtime-override.js +52 -0
- package/dist/auth/sql-profile-loader/types.d.ts +64 -0
- package/dist/auth/sql-profile-loader/types.js +1 -0
- package/dist/auth/sql-profile-loader.d.ts +4 -0
- package/dist/auth/sql-profile-loader.js +3 -0
- package/dist/capability/feature-matrix.d.ts +5 -0
- package/dist/capability/feature-matrix.js +237 -0
- package/dist/capability/probe.d.ts +19 -0
- package/dist/capability/probe.js +139 -0
- package/dist/capability/types.d.ts +49 -0
- package/dist/capability/types.js +16 -0
- package/dist/capability/version.d.ts +3 -0
- package/dist/capability/version.js +47 -0
- package/dist/cloud/auth.d.ts +26 -0
- package/dist/cloud/auth.js +198 -0
- package/dist/cloud/instances.d.ts +46 -0
- package/dist/cloud/instances.js +224 -0
- package/dist/config/env.d.ts +1 -0
- package/dist/config/env.js +194 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.js +21 -0
- package/dist/config/redaction.d.ts +2 -0
- package/dist/config/redaction.js +19 -0
- package/dist/config/schema.d.ts +417 -0
- package/dist/config/schema.js +100 -0
- package/dist/context/datasource-resolver.d.ts +19 -0
- package/dist/context/datasource-resolver.js +71 -0
- package/dist/context/session-context.d.ts +26 -0
- package/dist/context/session-context.js +1 -0
- package/dist/diagnostics/metrics-source.d.ts +65 -0
- package/dist/diagnostics/metrics-source.js +280 -0
- package/dist/diagnostics/slow-sql-source/das-source.d.ts +43 -0
- package/dist/diagnostics/slow-sql-source/das-source.js +170 -0
- package/dist/diagnostics/slow-sql-source/factory.d.ts +5 -0
- package/dist/diagnostics/slow-sql-source/factory.js +87 -0
- package/dist/diagnostics/slow-sql-source/parsers.d.ts +7 -0
- package/dist/diagnostics/slow-sql-source/parsers.js +125 -0
- package/dist/diagnostics/slow-sql-source/taurus-api-source.d.ts +42 -0
- package/dist/diagnostics/slow-sql-source/taurus-api-source.js +149 -0
- package/dist/diagnostics/slow-sql-source/types.d.ts +40 -0
- package/dist/diagnostics/slow-sql-source/types.js +1 -0
- package/dist/diagnostics/slow-sql-source/utils.d.ts +20 -0
- package/dist/diagnostics/slow-sql-source/utils.js +170 -0
- package/dist/diagnostics/slow-sql-source.d.ts +4 -0
- package/dist/diagnostics/slow-sql-source.js +3 -0
- package/dist/diagnostics/types.d.ts +189 -0
- package/dist/diagnostics/types.js +39 -0
- package/dist/engine/data-access/locks.d.ts +8 -0
- package/dist/engine/data-access/locks.js +146 -0
- package/dist/engine/data-access/processlist.d.ts +4 -0
- package/dist/engine/data-access/processlist.js +56 -0
- package/dist/engine/data-access/statements.d.ts +10 -0
- package/dist/engine/data-access/statements.js +203 -0
- package/dist/engine/data-access/storage.d.ts +6 -0
- package/dist/engine/data-access/storage.js +96 -0
- package/dist/engine/data-access.d.ts +4 -0
- package/dist/engine/data-access.js +4 -0
- package/dist/engine/diagnostics.d.ts +7 -0
- package/dist/engine/diagnostics.js +7 -0
- package/dist/engine/helper-modules/diagnostics.d.ts +57 -0
- package/dist/engine/helper-modules/diagnostics.js +322 -0
- package/dist/engine/helper-modules/parsers.d.ts +13 -0
- package/dist/engine/helper-modules/parsers.js +283 -0
- package/dist/engine/helper-modules/sql.d.ts +12 -0
- package/dist/engine/helper-modules/sql.js +119 -0
- package/dist/engine/helper-modules/types.d.ts +103 -0
- package/dist/engine/helper-modules/types.js +1 -0
- package/dist/engine/helpers.d.ts +4 -0
- package/dist/engine/helpers.js +4 -0
- package/dist/engine/runtime.d.ts +20 -0
- package/dist/engine/runtime.js +385 -0
- package/dist/engine/types.d.ts +125 -0
- package/dist/engine/types.js +1 -0
- package/dist/engine/workflows/connection-spike.d.ts +4 -0
- package/dist/engine/workflows/connection-spike.js +316 -0
- package/dist/engine/workflows/db-hotspot.d.ts +4 -0
- package/dist/engine/workflows/db-hotspot.js +182 -0
- package/dist/engine/workflows/lock-contention-helpers/entities.d.ts +9 -0
- package/dist/engine/workflows/lock-contention-helpers/entities.js +58 -0
- package/dist/engine/workflows/lock-contention-helpers/no-match.d.ts +3 -0
- package/dist/engine/workflows/lock-contention-helpers/no-match.js +65 -0
- package/dist/engine/workflows/lock-contention-helpers/report.d.ts +21 -0
- package/dist/engine/workflows/lock-contention-helpers/report.js +104 -0
- package/dist/engine/workflows/lock-contention-helpers/root-cause.d.ts +4 -0
- package/dist/engine/workflows/lock-contention-helpers/root-cause.js +79 -0
- package/dist/engine/workflows/lock-contention-helpers/signals.d.ts +22 -0
- package/dist/engine/workflows/lock-contention-helpers/signals.js +34 -0
- package/dist/engine/workflows/lock-contention-helpers.d.ts +5 -0
- package/dist/engine/workflows/lock-contention-helpers.js +5 -0
- package/dist/engine/workflows/lock-contention.d.ts +4 -0
- package/dist/engine/workflows/lock-contention.js +67 -0
- package/dist/engine/workflows/service-latency.d.ts +4 -0
- package/dist/engine/workflows/service-latency.js +262 -0
- package/dist/engine/workflows/slow-query-helpers.d.ts +41 -0
- package/dist/engine/workflows/slow-query-helpers.js +253 -0
- package/dist/engine/workflows/slow-query.d.ts +4 -0
- package/dist/engine/workflows/slow-query.js +156 -0
- package/dist/engine/workflows/storage-pressure-helpers.d.ts +12 -0
- package/dist/engine/workflows/storage-pressure-helpers.js +281 -0
- package/dist/engine/workflows/storage-pressure.d.ts +4 -0
- package/dist/engine/workflows/storage-pressure.js +27 -0
- package/dist/engine/workflows/top-slow-sql.d.ts +4 -0
- package/dist/engine/workflows/top-slow-sql.js +222 -0
- package/dist/engine.d.ts +77 -0
- package/dist/engine.js +240 -0
- package/dist/executor/adapters/mysql.d.ts +2 -0
- package/dist/executor/adapters/mysql.js +114 -0
- package/dist/executor/connection-pool.d.ts +105 -0
- package/dist/executor/connection-pool.js +236 -0
- package/dist/executor/explain.d.ts +5 -0
- package/dist/executor/explain.js +119 -0
- package/dist/executor/query-tracker.d.ts +45 -0
- package/dist/executor/query-tracker.js +83 -0
- package/dist/executor/result-normalizer.d.ts +6 -0
- package/dist/executor/result-normalizer.js +47 -0
- package/dist/executor/sql-executor.d.ts +32 -0
- package/dist/executor/sql-executor.js +250 -0
- package/dist/executor/types.d.ts +70 -0
- package/dist/executor/types.js +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +21 -0
- package/dist/safety/confirmation-store.d.ts +44 -0
- package/dist/safety/confirmation-store.js +130 -0
- package/dist/safety/guardrail.d.ts +39 -0
- package/dist/safety/guardrail.js +99 -0
- package/dist/safety/parser/adapter.d.ts +10 -0
- package/dist/safety/parser/adapter.js +72 -0
- package/dist/safety/parser/ast-utils.d.ts +10 -0
- package/dist/safety/parser/ast-utils.js +167 -0
- package/dist/safety/parser/features.d.ts +12 -0
- package/dist/safety/parser/features.js +113 -0
- package/dist/safety/parser/index.d.ts +2 -0
- package/dist/safety/parser/index.js +1 -0
- package/dist/safety/parser/types.d.ts +76 -0
- package/dist/safety/parser/types.js +1 -0
- package/dist/safety/redaction.d.ts +34 -0
- package/dist/safety/redaction.js +186 -0
- package/dist/safety/sql-classifier.d.ts +19 -0
- package/dist/safety/sql-classifier.js +43 -0
- package/dist/safety/sql-validator.d.ts +19 -0
- package/dist/safety/sql-validator.js +143 -0
- package/dist/schema/adapters/mysql.d.ts +16 -0
- package/dist/schema/adapters/mysql.js +287 -0
- package/dist/schema/introspector.d.ts +70 -0
- package/dist/schema/introspector.js +40 -0
- package/dist/taurus/flashback.d.ts +36 -0
- package/dist/taurus/flashback.js +149 -0
- package/dist/taurus/recycle-bin.d.ts +14 -0
- package/dist/taurus/recycle-bin.js +61 -0
- package/dist/utils/formatter.d.ts +70 -0
- package/dist/utils/formatter.js +60 -0
- package/dist/utils/hash.d.ts +2 -0
- package/dist/utils/hash.js +247 -0
- package/dist/utils/id.d.ts +2 -0
- package/dist/utils/id.js +11 -0
- package/dist/utils/logger.d.ts +9 -0
- package/dist/utils/logger.js +39 -0
- package/package.json +46 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ConfigSchema } from "./schema.js";
|
|
2
|
+
import { buildRawConfigFromEnv } from "./env.js";
|
|
3
|
+
export { redactConfigForLog } from "./redaction.js";
|
|
4
|
+
let configSingleton;
|
|
5
|
+
export function createConfigFromEnv(env = process.env) {
|
|
6
|
+
const parsed = ConfigSchema.safeParse(buildRawConfigFromEnv(env));
|
|
7
|
+
if (!parsed.success) {
|
|
8
|
+
const issues = parsed.error.issues.map((issue) => `${issue.path.join(".") || "<root>"}: ${issue.message}`);
|
|
9
|
+
throw new Error(`Invalid configuration:\n${issues.join("\n")}`);
|
|
10
|
+
}
|
|
11
|
+
return parsed.data;
|
|
12
|
+
}
|
|
13
|
+
export function getConfig() {
|
|
14
|
+
if (!configSingleton) {
|
|
15
|
+
configSingleton = createConfigFromEnv(process.env);
|
|
16
|
+
}
|
|
17
|
+
return configSingleton;
|
|
18
|
+
}
|
|
19
|
+
export function resetConfigForTests() {
|
|
20
|
+
configSingleton = undefined;
|
|
21
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const SENSITIVE_KEY_PATTERN = /(password|secret|token|credential|apikey|api_key|accesskey|access_key|secretaccesskey|secret_access_key)/i;
|
|
2
|
+
function deepRedact(value) {
|
|
3
|
+
if (Array.isArray(value)) {
|
|
4
|
+
return value.map((item) => deepRedact(item));
|
|
5
|
+
}
|
|
6
|
+
if (value && typeof value === "object") {
|
|
7
|
+
const output = {};
|
|
8
|
+
for (const [key, nestedValue] of Object.entries(value)) {
|
|
9
|
+
output[key] = SENSITIVE_KEY_PATTERN.test(key)
|
|
10
|
+
? "[REDACTED]"
|
|
11
|
+
: deepRedact(nestedValue);
|
|
12
|
+
}
|
|
13
|
+
return output;
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
export function redactConfigForLog(config) {
|
|
18
|
+
return deepRedact(config);
|
|
19
|
+
}
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ConfigSchema: z.ZodObject<{
|
|
3
|
+
defaultDatasource: z.ZodOptional<z.ZodString>;
|
|
4
|
+
profilesPath: z.ZodOptional<z.ZodString>;
|
|
5
|
+
enableMutations: z.ZodDefault<z.ZodBoolean>;
|
|
6
|
+
cloud: z.ZodDefault<z.ZodObject<{
|
|
7
|
+
provider: z.ZodDefault<z.ZodEnum<["huaweicloud"]>>;
|
|
8
|
+
region: z.ZodOptional<z.ZodString>;
|
|
9
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
10
|
+
instanceId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
nodeId: z.ZodOptional<z.ZodString>;
|
|
12
|
+
authToken: z.ZodOptional<z.ZodString>;
|
|
13
|
+
accessKeyId: z.ZodOptional<z.ZodString>;
|
|
14
|
+
secretAccessKey: z.ZodOptional<z.ZodString>;
|
|
15
|
+
securityToken: z.ZodOptional<z.ZodString>;
|
|
16
|
+
apiEndpoint: z.ZodOptional<z.ZodString>;
|
|
17
|
+
iamEndpoint: z.ZodOptional<z.ZodString>;
|
|
18
|
+
domainSuffix: z.ZodDefault<z.ZodString>;
|
|
19
|
+
language: z.ZodDefault<z.ZodEnum<["en-us", "zh-cn"]>>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
provider: "huaweicloud";
|
|
22
|
+
domainSuffix: string;
|
|
23
|
+
language: "en-us" | "zh-cn";
|
|
24
|
+
region?: string | undefined;
|
|
25
|
+
projectId?: string | undefined;
|
|
26
|
+
instanceId?: string | undefined;
|
|
27
|
+
nodeId?: string | undefined;
|
|
28
|
+
authToken?: string | undefined;
|
|
29
|
+
accessKeyId?: string | undefined;
|
|
30
|
+
secretAccessKey?: string | undefined;
|
|
31
|
+
securityToken?: string | undefined;
|
|
32
|
+
apiEndpoint?: string | undefined;
|
|
33
|
+
iamEndpoint?: string | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
provider?: "huaweicloud" | undefined;
|
|
36
|
+
region?: string | undefined;
|
|
37
|
+
projectId?: string | undefined;
|
|
38
|
+
instanceId?: string | undefined;
|
|
39
|
+
nodeId?: string | undefined;
|
|
40
|
+
authToken?: string | undefined;
|
|
41
|
+
accessKeyId?: string | undefined;
|
|
42
|
+
secretAccessKey?: string | undefined;
|
|
43
|
+
securityToken?: string | undefined;
|
|
44
|
+
apiEndpoint?: string | undefined;
|
|
45
|
+
iamEndpoint?: string | undefined;
|
|
46
|
+
domainSuffix?: string | undefined;
|
|
47
|
+
language?: "en-us" | "zh-cn" | undefined;
|
|
48
|
+
}>>;
|
|
49
|
+
limits: z.ZodDefault<z.ZodObject<{
|
|
50
|
+
maxRows: z.ZodDefault<z.ZodNumber>;
|
|
51
|
+
maxColumns: z.ZodDefault<z.ZodNumber>;
|
|
52
|
+
maxStatementMs: z.ZodDefault<z.ZodNumber>;
|
|
53
|
+
maxFieldChars: z.ZodDefault<z.ZodNumber>;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
maxRows: number;
|
|
56
|
+
maxColumns: number;
|
|
57
|
+
maxStatementMs: number;
|
|
58
|
+
maxFieldChars: number;
|
|
59
|
+
}, {
|
|
60
|
+
maxRows?: number | undefined;
|
|
61
|
+
maxColumns?: number | undefined;
|
|
62
|
+
maxStatementMs?: number | undefined;
|
|
63
|
+
maxFieldChars?: number | undefined;
|
|
64
|
+
}>>;
|
|
65
|
+
audit: z.ZodDefault<z.ZodObject<{
|
|
66
|
+
logPath: z.ZodDefault<z.ZodString>;
|
|
67
|
+
includeRawSql: z.ZodDefault<z.ZodBoolean>;
|
|
68
|
+
}, "strip", z.ZodTypeAny, {
|
|
69
|
+
logPath: string;
|
|
70
|
+
includeRawSql: boolean;
|
|
71
|
+
}, {
|
|
72
|
+
logPath?: string | undefined;
|
|
73
|
+
includeRawSql?: boolean | undefined;
|
|
74
|
+
}>>;
|
|
75
|
+
slowSqlSource: z.ZodDefault<z.ZodObject<{
|
|
76
|
+
taurusApi: z.ZodDefault<z.ZodObject<{
|
|
77
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
78
|
+
endpoint: z.ZodOptional<z.ZodString>;
|
|
79
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
80
|
+
instanceId: z.ZodOptional<z.ZodString>;
|
|
81
|
+
nodeId: z.ZodOptional<z.ZodString>;
|
|
82
|
+
authToken: z.ZodOptional<z.ZodString>;
|
|
83
|
+
language: z.ZodDefault<z.ZodEnum<["en-us", "zh-cn"]>>;
|
|
84
|
+
requestTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
85
|
+
defaultLookbackMinutes: z.ZodDefault<z.ZodNumber>;
|
|
86
|
+
maxRecords: z.ZodDefault<z.ZodNumber>;
|
|
87
|
+
}, "strip", z.ZodTypeAny, {
|
|
88
|
+
language: "en-us" | "zh-cn";
|
|
89
|
+
enabled: boolean;
|
|
90
|
+
requestTimeoutMs: number;
|
|
91
|
+
defaultLookbackMinutes: number;
|
|
92
|
+
maxRecords: number;
|
|
93
|
+
projectId?: string | undefined;
|
|
94
|
+
instanceId?: string | undefined;
|
|
95
|
+
nodeId?: string | undefined;
|
|
96
|
+
authToken?: string | undefined;
|
|
97
|
+
endpoint?: string | undefined;
|
|
98
|
+
}, {
|
|
99
|
+
projectId?: string | undefined;
|
|
100
|
+
instanceId?: string | undefined;
|
|
101
|
+
nodeId?: string | undefined;
|
|
102
|
+
authToken?: string | undefined;
|
|
103
|
+
language?: "en-us" | "zh-cn" | undefined;
|
|
104
|
+
enabled?: boolean | undefined;
|
|
105
|
+
endpoint?: string | undefined;
|
|
106
|
+
requestTimeoutMs?: number | undefined;
|
|
107
|
+
defaultLookbackMinutes?: number | undefined;
|
|
108
|
+
maxRecords?: number | undefined;
|
|
109
|
+
}>>;
|
|
110
|
+
das: z.ZodDefault<z.ZodObject<{
|
|
111
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
112
|
+
endpoint: z.ZodOptional<z.ZodString>;
|
|
113
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
114
|
+
instanceId: z.ZodOptional<z.ZodString>;
|
|
115
|
+
authToken: z.ZodOptional<z.ZodString>;
|
|
116
|
+
datastoreType: z.ZodDefault<z.ZodEnum<["MySQL", "TaurusDB"]>>;
|
|
117
|
+
requestTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
118
|
+
defaultLookbackMinutes: z.ZodDefault<z.ZodNumber>;
|
|
119
|
+
maxRecords: z.ZodDefault<z.ZodNumber>;
|
|
120
|
+
maxPages: z.ZodDefault<z.ZodNumber>;
|
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
|
122
|
+
enabled: boolean;
|
|
123
|
+
requestTimeoutMs: number;
|
|
124
|
+
defaultLookbackMinutes: number;
|
|
125
|
+
maxRecords: number;
|
|
126
|
+
datastoreType: "MySQL" | "TaurusDB";
|
|
127
|
+
maxPages: number;
|
|
128
|
+
projectId?: string | undefined;
|
|
129
|
+
instanceId?: string | undefined;
|
|
130
|
+
authToken?: string | undefined;
|
|
131
|
+
endpoint?: string | undefined;
|
|
132
|
+
}, {
|
|
133
|
+
projectId?: string | undefined;
|
|
134
|
+
instanceId?: string | undefined;
|
|
135
|
+
authToken?: string | undefined;
|
|
136
|
+
enabled?: boolean | undefined;
|
|
137
|
+
endpoint?: string | undefined;
|
|
138
|
+
requestTimeoutMs?: number | undefined;
|
|
139
|
+
defaultLookbackMinutes?: number | undefined;
|
|
140
|
+
maxRecords?: number | undefined;
|
|
141
|
+
datastoreType?: "MySQL" | "TaurusDB" | undefined;
|
|
142
|
+
maxPages?: number | undefined;
|
|
143
|
+
}>>;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
taurusApi: {
|
|
146
|
+
language: "en-us" | "zh-cn";
|
|
147
|
+
enabled: boolean;
|
|
148
|
+
requestTimeoutMs: number;
|
|
149
|
+
defaultLookbackMinutes: number;
|
|
150
|
+
maxRecords: number;
|
|
151
|
+
projectId?: string | undefined;
|
|
152
|
+
instanceId?: string | undefined;
|
|
153
|
+
nodeId?: string | undefined;
|
|
154
|
+
authToken?: string | undefined;
|
|
155
|
+
endpoint?: string | undefined;
|
|
156
|
+
};
|
|
157
|
+
das: {
|
|
158
|
+
enabled: boolean;
|
|
159
|
+
requestTimeoutMs: number;
|
|
160
|
+
defaultLookbackMinutes: number;
|
|
161
|
+
maxRecords: number;
|
|
162
|
+
datastoreType: "MySQL" | "TaurusDB";
|
|
163
|
+
maxPages: number;
|
|
164
|
+
projectId?: string | undefined;
|
|
165
|
+
instanceId?: string | undefined;
|
|
166
|
+
authToken?: string | undefined;
|
|
167
|
+
endpoint?: string | undefined;
|
|
168
|
+
};
|
|
169
|
+
}, {
|
|
170
|
+
taurusApi?: {
|
|
171
|
+
projectId?: string | undefined;
|
|
172
|
+
instanceId?: string | undefined;
|
|
173
|
+
nodeId?: string | undefined;
|
|
174
|
+
authToken?: string | undefined;
|
|
175
|
+
language?: "en-us" | "zh-cn" | undefined;
|
|
176
|
+
enabled?: boolean | undefined;
|
|
177
|
+
endpoint?: string | undefined;
|
|
178
|
+
requestTimeoutMs?: number | undefined;
|
|
179
|
+
defaultLookbackMinutes?: number | undefined;
|
|
180
|
+
maxRecords?: number | undefined;
|
|
181
|
+
} | undefined;
|
|
182
|
+
das?: {
|
|
183
|
+
projectId?: string | undefined;
|
|
184
|
+
instanceId?: string | undefined;
|
|
185
|
+
authToken?: string | undefined;
|
|
186
|
+
enabled?: boolean | undefined;
|
|
187
|
+
endpoint?: string | undefined;
|
|
188
|
+
requestTimeoutMs?: number | undefined;
|
|
189
|
+
defaultLookbackMinutes?: number | undefined;
|
|
190
|
+
maxRecords?: number | undefined;
|
|
191
|
+
datastoreType?: "MySQL" | "TaurusDB" | undefined;
|
|
192
|
+
maxPages?: number | undefined;
|
|
193
|
+
} | undefined;
|
|
194
|
+
}>>;
|
|
195
|
+
metricsSource: z.ZodDefault<z.ZodObject<{
|
|
196
|
+
ces: z.ZodDefault<z.ZodObject<{
|
|
197
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
198
|
+
endpoint: z.ZodOptional<z.ZodString>;
|
|
199
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
200
|
+
instanceId: z.ZodOptional<z.ZodString>;
|
|
201
|
+
nodeId: z.ZodOptional<z.ZodString>;
|
|
202
|
+
authToken: z.ZodOptional<z.ZodString>;
|
|
203
|
+
namespace: z.ZodDefault<z.ZodString>;
|
|
204
|
+
instanceDimension: z.ZodDefault<z.ZodString>;
|
|
205
|
+
nodeDimension: z.ZodDefault<z.ZodString>;
|
|
206
|
+
period: z.ZodDefault<z.ZodEnum<["1", "60", "300", "1200", "3600", "14400", "86400"]>>;
|
|
207
|
+
filter: z.ZodDefault<z.ZodEnum<["average", "max", "min", "sum", "variance"]>>;
|
|
208
|
+
requestTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
209
|
+
defaultLookbackMinutes: z.ZodDefault<z.ZodNumber>;
|
|
210
|
+
}, "strip", z.ZodTypeAny, {
|
|
211
|
+
filter: "average" | "max" | "min" | "sum" | "variance";
|
|
212
|
+
enabled: boolean;
|
|
213
|
+
requestTimeoutMs: number;
|
|
214
|
+
defaultLookbackMinutes: number;
|
|
215
|
+
namespace: string;
|
|
216
|
+
instanceDimension: string;
|
|
217
|
+
nodeDimension: string;
|
|
218
|
+
period: "1" | "60" | "300" | "1200" | "3600" | "14400" | "86400";
|
|
219
|
+
projectId?: string | undefined;
|
|
220
|
+
instanceId?: string | undefined;
|
|
221
|
+
nodeId?: string | undefined;
|
|
222
|
+
authToken?: string | undefined;
|
|
223
|
+
endpoint?: string | undefined;
|
|
224
|
+
}, {
|
|
225
|
+
filter?: "average" | "max" | "min" | "sum" | "variance" | undefined;
|
|
226
|
+
projectId?: string | undefined;
|
|
227
|
+
instanceId?: string | undefined;
|
|
228
|
+
nodeId?: string | undefined;
|
|
229
|
+
authToken?: string | undefined;
|
|
230
|
+
enabled?: boolean | undefined;
|
|
231
|
+
endpoint?: string | undefined;
|
|
232
|
+
requestTimeoutMs?: number | undefined;
|
|
233
|
+
defaultLookbackMinutes?: number | undefined;
|
|
234
|
+
namespace?: string | undefined;
|
|
235
|
+
instanceDimension?: string | undefined;
|
|
236
|
+
nodeDimension?: string | undefined;
|
|
237
|
+
period?: "1" | "60" | "300" | "1200" | "3600" | "14400" | "86400" | undefined;
|
|
238
|
+
}>>;
|
|
239
|
+
}, "strip", z.ZodTypeAny, {
|
|
240
|
+
ces: {
|
|
241
|
+
filter: "average" | "max" | "min" | "sum" | "variance";
|
|
242
|
+
enabled: boolean;
|
|
243
|
+
requestTimeoutMs: number;
|
|
244
|
+
defaultLookbackMinutes: number;
|
|
245
|
+
namespace: string;
|
|
246
|
+
instanceDimension: string;
|
|
247
|
+
nodeDimension: string;
|
|
248
|
+
period: "1" | "60" | "300" | "1200" | "3600" | "14400" | "86400";
|
|
249
|
+
projectId?: string | undefined;
|
|
250
|
+
instanceId?: string | undefined;
|
|
251
|
+
nodeId?: string | undefined;
|
|
252
|
+
authToken?: string | undefined;
|
|
253
|
+
endpoint?: string | undefined;
|
|
254
|
+
};
|
|
255
|
+
}, {
|
|
256
|
+
ces?: {
|
|
257
|
+
filter?: "average" | "max" | "min" | "sum" | "variance" | undefined;
|
|
258
|
+
projectId?: string | undefined;
|
|
259
|
+
instanceId?: string | undefined;
|
|
260
|
+
nodeId?: string | undefined;
|
|
261
|
+
authToken?: string | undefined;
|
|
262
|
+
enabled?: boolean | undefined;
|
|
263
|
+
endpoint?: string | undefined;
|
|
264
|
+
requestTimeoutMs?: number | undefined;
|
|
265
|
+
defaultLookbackMinutes?: number | undefined;
|
|
266
|
+
namespace?: string | undefined;
|
|
267
|
+
instanceDimension?: string | undefined;
|
|
268
|
+
nodeDimension?: string | undefined;
|
|
269
|
+
period?: "1" | "60" | "300" | "1200" | "3600" | "14400" | "86400" | undefined;
|
|
270
|
+
} | undefined;
|
|
271
|
+
}>>;
|
|
272
|
+
}, "strip", z.ZodTypeAny, {
|
|
273
|
+
enableMutations: boolean;
|
|
274
|
+
cloud: {
|
|
275
|
+
provider: "huaweicloud";
|
|
276
|
+
domainSuffix: string;
|
|
277
|
+
language: "en-us" | "zh-cn";
|
|
278
|
+
region?: string | undefined;
|
|
279
|
+
projectId?: string | undefined;
|
|
280
|
+
instanceId?: string | undefined;
|
|
281
|
+
nodeId?: string | undefined;
|
|
282
|
+
authToken?: string | undefined;
|
|
283
|
+
accessKeyId?: string | undefined;
|
|
284
|
+
secretAccessKey?: string | undefined;
|
|
285
|
+
securityToken?: string | undefined;
|
|
286
|
+
apiEndpoint?: string | undefined;
|
|
287
|
+
iamEndpoint?: string | undefined;
|
|
288
|
+
};
|
|
289
|
+
limits: {
|
|
290
|
+
maxRows: number;
|
|
291
|
+
maxColumns: number;
|
|
292
|
+
maxStatementMs: number;
|
|
293
|
+
maxFieldChars: number;
|
|
294
|
+
};
|
|
295
|
+
audit: {
|
|
296
|
+
logPath: string;
|
|
297
|
+
includeRawSql: boolean;
|
|
298
|
+
};
|
|
299
|
+
slowSqlSource: {
|
|
300
|
+
taurusApi: {
|
|
301
|
+
language: "en-us" | "zh-cn";
|
|
302
|
+
enabled: boolean;
|
|
303
|
+
requestTimeoutMs: number;
|
|
304
|
+
defaultLookbackMinutes: number;
|
|
305
|
+
maxRecords: number;
|
|
306
|
+
projectId?: string | undefined;
|
|
307
|
+
instanceId?: string | undefined;
|
|
308
|
+
nodeId?: string | undefined;
|
|
309
|
+
authToken?: string | undefined;
|
|
310
|
+
endpoint?: string | undefined;
|
|
311
|
+
};
|
|
312
|
+
das: {
|
|
313
|
+
enabled: boolean;
|
|
314
|
+
requestTimeoutMs: number;
|
|
315
|
+
defaultLookbackMinutes: number;
|
|
316
|
+
maxRecords: number;
|
|
317
|
+
datastoreType: "MySQL" | "TaurusDB";
|
|
318
|
+
maxPages: number;
|
|
319
|
+
projectId?: string | undefined;
|
|
320
|
+
instanceId?: string | undefined;
|
|
321
|
+
authToken?: string | undefined;
|
|
322
|
+
endpoint?: string | undefined;
|
|
323
|
+
};
|
|
324
|
+
};
|
|
325
|
+
metricsSource: {
|
|
326
|
+
ces: {
|
|
327
|
+
filter: "average" | "max" | "min" | "sum" | "variance";
|
|
328
|
+
enabled: boolean;
|
|
329
|
+
requestTimeoutMs: number;
|
|
330
|
+
defaultLookbackMinutes: number;
|
|
331
|
+
namespace: string;
|
|
332
|
+
instanceDimension: string;
|
|
333
|
+
nodeDimension: string;
|
|
334
|
+
period: "1" | "60" | "300" | "1200" | "3600" | "14400" | "86400";
|
|
335
|
+
projectId?: string | undefined;
|
|
336
|
+
instanceId?: string | undefined;
|
|
337
|
+
nodeId?: string | undefined;
|
|
338
|
+
authToken?: string | undefined;
|
|
339
|
+
endpoint?: string | undefined;
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
defaultDatasource?: string | undefined;
|
|
343
|
+
profilesPath?: string | undefined;
|
|
344
|
+
}, {
|
|
345
|
+
defaultDatasource?: string | undefined;
|
|
346
|
+
profilesPath?: string | undefined;
|
|
347
|
+
enableMutations?: boolean | undefined;
|
|
348
|
+
cloud?: {
|
|
349
|
+
provider?: "huaweicloud" | undefined;
|
|
350
|
+
region?: string | undefined;
|
|
351
|
+
projectId?: string | undefined;
|
|
352
|
+
instanceId?: string | undefined;
|
|
353
|
+
nodeId?: string | undefined;
|
|
354
|
+
authToken?: string | undefined;
|
|
355
|
+
accessKeyId?: string | undefined;
|
|
356
|
+
secretAccessKey?: string | undefined;
|
|
357
|
+
securityToken?: string | undefined;
|
|
358
|
+
apiEndpoint?: string | undefined;
|
|
359
|
+
iamEndpoint?: string | undefined;
|
|
360
|
+
domainSuffix?: string | undefined;
|
|
361
|
+
language?: "en-us" | "zh-cn" | undefined;
|
|
362
|
+
} | undefined;
|
|
363
|
+
limits?: {
|
|
364
|
+
maxRows?: number | undefined;
|
|
365
|
+
maxColumns?: number | undefined;
|
|
366
|
+
maxStatementMs?: number | undefined;
|
|
367
|
+
maxFieldChars?: number | undefined;
|
|
368
|
+
} | undefined;
|
|
369
|
+
audit?: {
|
|
370
|
+
logPath?: string | undefined;
|
|
371
|
+
includeRawSql?: boolean | undefined;
|
|
372
|
+
} | undefined;
|
|
373
|
+
slowSqlSource?: {
|
|
374
|
+
taurusApi?: {
|
|
375
|
+
projectId?: string | undefined;
|
|
376
|
+
instanceId?: string | undefined;
|
|
377
|
+
nodeId?: string | undefined;
|
|
378
|
+
authToken?: string | undefined;
|
|
379
|
+
language?: "en-us" | "zh-cn" | undefined;
|
|
380
|
+
enabled?: boolean | undefined;
|
|
381
|
+
endpoint?: string | undefined;
|
|
382
|
+
requestTimeoutMs?: number | undefined;
|
|
383
|
+
defaultLookbackMinutes?: number | undefined;
|
|
384
|
+
maxRecords?: number | undefined;
|
|
385
|
+
} | undefined;
|
|
386
|
+
das?: {
|
|
387
|
+
projectId?: string | undefined;
|
|
388
|
+
instanceId?: string | undefined;
|
|
389
|
+
authToken?: string | undefined;
|
|
390
|
+
enabled?: boolean | undefined;
|
|
391
|
+
endpoint?: string | undefined;
|
|
392
|
+
requestTimeoutMs?: number | undefined;
|
|
393
|
+
defaultLookbackMinutes?: number | undefined;
|
|
394
|
+
maxRecords?: number | undefined;
|
|
395
|
+
datastoreType?: "MySQL" | "TaurusDB" | undefined;
|
|
396
|
+
maxPages?: number | undefined;
|
|
397
|
+
} | undefined;
|
|
398
|
+
} | undefined;
|
|
399
|
+
metricsSource?: {
|
|
400
|
+
ces?: {
|
|
401
|
+
filter?: "average" | "max" | "min" | "sum" | "variance" | undefined;
|
|
402
|
+
projectId?: string | undefined;
|
|
403
|
+
instanceId?: string | undefined;
|
|
404
|
+
nodeId?: string | undefined;
|
|
405
|
+
authToken?: string | undefined;
|
|
406
|
+
enabled?: boolean | undefined;
|
|
407
|
+
endpoint?: string | undefined;
|
|
408
|
+
requestTimeoutMs?: number | undefined;
|
|
409
|
+
defaultLookbackMinutes?: number | undefined;
|
|
410
|
+
namespace?: string | undefined;
|
|
411
|
+
instanceDimension?: string | undefined;
|
|
412
|
+
nodeDimension?: string | undefined;
|
|
413
|
+
period?: "1" | "60" | "300" | "1200" | "3600" | "14400" | "86400" | undefined;
|
|
414
|
+
} | undefined;
|
|
415
|
+
} | undefined;
|
|
416
|
+
}>;
|
|
417
|
+
export type Config = z.infer<typeof ConfigSchema>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const LimitsSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
maxRows: z.number().int().positive().default(200),
|
|
5
|
+
maxColumns: z.number().int().positive().default(50),
|
|
6
|
+
maxStatementMs: z.number().int().positive().default(15000),
|
|
7
|
+
maxFieldChars: z.number().int().positive().default(2048),
|
|
8
|
+
})
|
|
9
|
+
.default({});
|
|
10
|
+
const AuditSchema = z
|
|
11
|
+
.object({
|
|
12
|
+
logPath: z.string().min(1).default("~/.taurusdb-mcp/audit.jsonl"),
|
|
13
|
+
includeRawSql: z.boolean().default(false),
|
|
14
|
+
})
|
|
15
|
+
.default({});
|
|
16
|
+
const CloudSchema = z
|
|
17
|
+
.object({
|
|
18
|
+
provider: z.enum(["huaweicloud"]).default("huaweicloud"),
|
|
19
|
+
region: z.string().min(1).optional(),
|
|
20
|
+
projectId: z.string().min(1).optional(),
|
|
21
|
+
instanceId: z.string().min(1).optional(),
|
|
22
|
+
nodeId: z.string().min(1).optional(),
|
|
23
|
+
authToken: z.string().min(1).optional(),
|
|
24
|
+
accessKeyId: z.string().min(1).optional(),
|
|
25
|
+
secretAccessKey: z.string().min(1).optional(),
|
|
26
|
+
securityToken: z.string().min(1).optional(),
|
|
27
|
+
apiEndpoint: z.string().min(1).optional(),
|
|
28
|
+
iamEndpoint: z.string().min(1).optional(),
|
|
29
|
+
domainSuffix: z.string().min(1).default("myhuaweicloud.com"),
|
|
30
|
+
language: z.enum(["en-us", "zh-cn"]).default("zh-cn"),
|
|
31
|
+
})
|
|
32
|
+
.default({});
|
|
33
|
+
const TaurusApiSlowSqlSourceSchema = z
|
|
34
|
+
.object({
|
|
35
|
+
enabled: z.boolean().default(false),
|
|
36
|
+
endpoint: z.string().min(1).optional(),
|
|
37
|
+
projectId: z.string().min(1).optional(),
|
|
38
|
+
instanceId: z.string().min(1).optional(),
|
|
39
|
+
nodeId: z.string().min(1).optional(),
|
|
40
|
+
authToken: z.string().min(1).optional(),
|
|
41
|
+
language: z.enum(["en-us", "zh-cn"]).default("zh-cn"),
|
|
42
|
+
requestTimeoutMs: z.number().int().positive().default(5000),
|
|
43
|
+
defaultLookbackMinutes: z.number().int().positive().max(43_200).default(60),
|
|
44
|
+
maxRecords: z.number().int().positive().max(100).default(20),
|
|
45
|
+
})
|
|
46
|
+
.default({});
|
|
47
|
+
const DasSlowSqlSourceSchema = z
|
|
48
|
+
.object({
|
|
49
|
+
enabled: z.boolean().default(false),
|
|
50
|
+
endpoint: z.string().min(1).optional(),
|
|
51
|
+
projectId: z.string().min(1).optional(),
|
|
52
|
+
instanceId: z.string().min(1).optional(),
|
|
53
|
+
authToken: z.string().min(1).optional(),
|
|
54
|
+
datastoreType: z.enum(["MySQL", "TaurusDB"]).default("TaurusDB"),
|
|
55
|
+
requestTimeoutMs: z.number().int().positive().default(5000),
|
|
56
|
+
defaultLookbackMinutes: z.number().int().positive().max(43_200).default(60),
|
|
57
|
+
maxRecords: z.number().int().positive().max(200).default(50),
|
|
58
|
+
maxPages: z.number().int().positive().max(10).default(2),
|
|
59
|
+
})
|
|
60
|
+
.default({});
|
|
61
|
+
const CesMetricsSourceSchema = z
|
|
62
|
+
.object({
|
|
63
|
+
enabled: z.boolean().default(false),
|
|
64
|
+
endpoint: z.string().min(1).optional(),
|
|
65
|
+
projectId: z.string().min(1).optional(),
|
|
66
|
+
instanceId: z.string().min(1).optional(),
|
|
67
|
+
nodeId: z.string().min(1).optional(),
|
|
68
|
+
authToken: z.string().min(1).optional(),
|
|
69
|
+
namespace: z.string().min(1).default("SYS.GAUSSDB"),
|
|
70
|
+
instanceDimension: z.string().min(1).default("gaussdb_mysql_instance_id"),
|
|
71
|
+
nodeDimension: z.string().min(1).default("gaussdb_mysql_node_id"),
|
|
72
|
+
period: z
|
|
73
|
+
.enum(["1", "60", "300", "1200", "3600", "14400", "86400"])
|
|
74
|
+
.default("60"),
|
|
75
|
+
filter: z
|
|
76
|
+
.enum(["average", "max", "min", "sum", "variance"])
|
|
77
|
+
.default("average"),
|
|
78
|
+
requestTimeoutMs: z.number().int().positive().default(5000),
|
|
79
|
+
defaultLookbackMinutes: z.number().int().positive().max(43_200).default(60),
|
|
80
|
+
})
|
|
81
|
+
.default({});
|
|
82
|
+
export const ConfigSchema = z.object({
|
|
83
|
+
defaultDatasource: z.string().min(1).optional(),
|
|
84
|
+
profilesPath: z.string().min(1).optional(),
|
|
85
|
+
enableMutations: z.boolean().default(true),
|
|
86
|
+
cloud: CloudSchema,
|
|
87
|
+
limits: LimitsSchema,
|
|
88
|
+
audit: AuditSchema,
|
|
89
|
+
slowSqlSource: z
|
|
90
|
+
.object({
|
|
91
|
+
taurusApi: TaurusApiSlowSqlSourceSchema,
|
|
92
|
+
das: DasSlowSqlSourceSchema,
|
|
93
|
+
})
|
|
94
|
+
.default({}),
|
|
95
|
+
metricsSource: z
|
|
96
|
+
.object({
|
|
97
|
+
ces: CesMetricsSourceSchema,
|
|
98
|
+
})
|
|
99
|
+
.default({}),
|
|
100
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Config } from "../config/index.js";
|
|
2
|
+
import type { ProfileLoader } from "../auth/sql-profile-loader.js";
|
|
3
|
+
import type { DatasourceResolveInput, DatasourceResolver, SessionContext } from "./session-context.js";
|
|
4
|
+
export declare class DatasourceResolutionError extends Error {
|
|
5
|
+
readonly code: "DATASOURCE_NOT_FOUND" | "INVALID_CONTEXT_INPUT";
|
|
6
|
+
constructor(code: "DATASOURCE_NOT_FOUND" | "INVALID_CONTEXT_INPUT", message: string);
|
|
7
|
+
}
|
|
8
|
+
export type DatasourceResolverOptions = {
|
|
9
|
+
config: Config;
|
|
10
|
+
profileLoader: ProfileLoader;
|
|
11
|
+
};
|
|
12
|
+
export declare class DefaultDatasourceResolver implements DatasourceResolver {
|
|
13
|
+
private readonly config;
|
|
14
|
+
private readonly profileLoader;
|
|
15
|
+
constructor(options: DatasourceResolverOptions);
|
|
16
|
+
resolve(input: DatasourceResolveInput, task_id: string): Promise<SessionContext>;
|
|
17
|
+
private resolveDatasourceName;
|
|
18
|
+
}
|
|
19
|
+
export declare function createDatasourceResolver(options: DatasourceResolverOptions): DatasourceResolver;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export class DatasourceResolutionError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
constructor(code, message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "DatasourceResolutionError";
|
|
6
|
+
this.code = code;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function normalizeString(value) {
|
|
10
|
+
if (typeof value !== "string") {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const trimmed = value.trim();
|
|
14
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
15
|
+
}
|
|
16
|
+
function resolveTimeoutMs(requested, fallbackMax) {
|
|
17
|
+
if (requested === undefined) {
|
|
18
|
+
return fallbackMax;
|
|
19
|
+
}
|
|
20
|
+
if (!Number.isInteger(requested) || requested <= 0) {
|
|
21
|
+
throw new DatasourceResolutionError("INVALID_CONTEXT_INPUT", `Invalid timeout_ms: ${requested}. It must be a positive integer.`);
|
|
22
|
+
}
|
|
23
|
+
return Math.min(requested, fallbackMax);
|
|
24
|
+
}
|
|
25
|
+
export class DefaultDatasourceResolver {
|
|
26
|
+
config;
|
|
27
|
+
profileLoader;
|
|
28
|
+
constructor(options) {
|
|
29
|
+
this.config = options.config;
|
|
30
|
+
this.profileLoader = options.profileLoader;
|
|
31
|
+
}
|
|
32
|
+
async resolve(input, task_id) {
|
|
33
|
+
const datasourceName = await this.resolveDatasourceName(input.datasource);
|
|
34
|
+
const profile = await this.profileLoader.get(datasourceName);
|
|
35
|
+
if (!profile) {
|
|
36
|
+
throw new DatasourceResolutionError("DATASOURCE_NOT_FOUND", `Datasource profile "${datasourceName}" was not found.`);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
task_id,
|
|
40
|
+
datasource: datasourceName,
|
|
41
|
+
engine: profile.engine,
|
|
42
|
+
database: normalizeString(input.database) ?? profile.database,
|
|
43
|
+
schema: normalizeString(input.schema),
|
|
44
|
+
limits: {
|
|
45
|
+
readonly: input.readonly ?? true,
|
|
46
|
+
timeoutMs: resolveTimeoutMs(input.timeout_ms, this.config.limits.maxStatementMs),
|
|
47
|
+
maxRows: this.config.limits.maxRows,
|
|
48
|
+
maxColumns: this.config.limits.maxColumns,
|
|
49
|
+
maxFieldChars: this.config.limits.maxFieldChars,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
async resolveDatasourceName(explicitDatasource) {
|
|
54
|
+
const inputDatasource = normalizeString(explicitDatasource);
|
|
55
|
+
if (inputDatasource) {
|
|
56
|
+
return inputDatasource;
|
|
57
|
+
}
|
|
58
|
+
if (this.config.defaultDatasource) {
|
|
59
|
+
return this.config.defaultDatasource;
|
|
60
|
+
}
|
|
61
|
+
const loadedDefault = await this.profileLoader.getDefault();
|
|
62
|
+
const profileDefault = normalizeString(loadedDefault);
|
|
63
|
+
if (profileDefault) {
|
|
64
|
+
return profileDefault;
|
|
65
|
+
}
|
|
66
|
+
throw new DatasourceResolutionError("DATASOURCE_NOT_FOUND", "No datasource selected. Provide input.datasource or configure a default datasource.");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export function createDatasourceResolver(options) {
|
|
70
|
+
return new DefaultDatasourceResolver(options);
|
|
71
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { DatabaseEngine } from "../auth/sql-profile-loader.js";
|
|
2
|
+
export interface RuntimeLimits {
|
|
3
|
+
readonly: boolean;
|
|
4
|
+
timeoutMs: number;
|
|
5
|
+
maxRows: number;
|
|
6
|
+
maxColumns: number;
|
|
7
|
+
maxFieldChars: number;
|
|
8
|
+
}
|
|
9
|
+
export interface SessionContext {
|
|
10
|
+
task_id: string;
|
|
11
|
+
datasource: string;
|
|
12
|
+
engine: DatabaseEngine;
|
|
13
|
+
database?: string;
|
|
14
|
+
schema?: string;
|
|
15
|
+
limits: RuntimeLimits;
|
|
16
|
+
}
|
|
17
|
+
export interface DatasourceResolveInput {
|
|
18
|
+
datasource?: string;
|
|
19
|
+
database?: string;
|
|
20
|
+
schema?: string;
|
|
21
|
+
timeout_ms?: number;
|
|
22
|
+
readonly?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface DatasourceResolver {
|
|
25
|
+
resolve(input: DatasourceResolveInput, task_id: string): Promise<SessionContext>;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|