db-mcp 1.0.1
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/LICENSE +21 -0
- package/README.md +860 -0
- package/dist/adapters/DatabaseAdapter.d.ts +141 -0
- package/dist/adapters/DatabaseAdapter.d.ts.map +1 -0
- package/dist/adapters/DatabaseAdapter.js +131 -0
- package/dist/adapters/DatabaseAdapter.js.map +1 -0
- package/dist/adapters/sqlite/SchemaManager.d.ts +58 -0
- package/dist/adapters/sqlite/SchemaManager.d.ts.map +1 -0
- package/dist/adapters/sqlite/SchemaManager.js +187 -0
- package/dist/adapters/sqlite/SchemaManager.js.map +1 -0
- package/dist/adapters/sqlite/SqliteAdapter.d.ts +161 -0
- package/dist/adapters/sqlite/SqliteAdapter.d.ts.map +1 -0
- package/dist/adapters/sqlite/SqliteAdapter.js +741 -0
- package/dist/adapters/sqlite/SqliteAdapter.js.map +1 -0
- package/dist/adapters/sqlite/index.d.ts +9 -0
- package/dist/adapters/sqlite/index.d.ts.map +1 -0
- package/dist/adapters/sqlite/index.js +8 -0
- package/dist/adapters/sqlite/index.js.map +1 -0
- package/dist/adapters/sqlite/json-utils.d.ts +100 -0
- package/dist/adapters/sqlite/json-utils.d.ts.map +1 -0
- package/dist/adapters/sqlite/json-utils.js +274 -0
- package/dist/adapters/sqlite/json-utils.js.map +1 -0
- package/dist/adapters/sqlite/output-schemas.d.ts +1187 -0
- package/dist/adapters/sqlite/output-schemas.d.ts.map +1 -0
- package/dist/adapters/sqlite/output-schemas.js +1337 -0
- package/dist/adapters/sqlite/output-schemas.js.map +1 -0
- package/dist/adapters/sqlite/prompts.d.ts +13 -0
- package/dist/adapters/sqlite/prompts.d.ts.map +1 -0
- package/dist/adapters/sqlite/prompts.js +605 -0
- package/dist/adapters/sqlite/prompts.js.map +1 -0
- package/dist/adapters/sqlite/resources.d.ts +13 -0
- package/dist/adapters/sqlite/resources.d.ts.map +1 -0
- package/dist/adapters/sqlite/resources.js +251 -0
- package/dist/adapters/sqlite/resources.js.map +1 -0
- package/dist/adapters/sqlite/tools/admin.d.ts +14 -0
- package/dist/adapters/sqlite/tools/admin.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/admin.js +788 -0
- package/dist/adapters/sqlite/tools/admin.js.map +1 -0
- package/dist/adapters/sqlite/tools/core.d.ts +25 -0
- package/dist/adapters/sqlite/tools/core.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/core.js +359 -0
- package/dist/adapters/sqlite/tools/core.js.map +1 -0
- package/dist/adapters/sqlite/tools/fts.d.ts +13 -0
- package/dist/adapters/sqlite/tools/fts.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/fts.js +347 -0
- package/dist/adapters/sqlite/tools/fts.js.map +1 -0
- package/dist/adapters/sqlite/tools/geo.d.ts +14 -0
- package/dist/adapters/sqlite/tools/geo.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/geo.js +252 -0
- package/dist/adapters/sqlite/tools/geo.js.map +1 -0
- package/dist/adapters/sqlite/tools/index.d.ts +30 -0
- package/dist/adapters/sqlite/tools/index.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/index.js +61 -0
- package/dist/adapters/sqlite/tools/index.js.map +1 -0
- package/dist/adapters/sqlite/tools/json-helpers.d.ts +14 -0
- package/dist/adapters/sqlite/tools/json-helpers.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/json-helpers.js +477 -0
- package/dist/adapters/sqlite/tools/json-helpers.js.map +1 -0
- package/dist/adapters/sqlite/tools/json-operations.d.ts +14 -0
- package/dist/adapters/sqlite/tools/json-operations.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/json-operations.js +839 -0
- package/dist/adapters/sqlite/tools/json-operations.js.map +1 -0
- package/dist/adapters/sqlite/tools/stats.d.ts +15 -0
- package/dist/adapters/sqlite/tools/stats.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/stats.js +1219 -0
- package/dist/adapters/sqlite/tools/stats.js.map +1 -0
- package/dist/adapters/sqlite/tools/text.d.ts +14 -0
- package/dist/adapters/sqlite/tools/text.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/text.js +1141 -0
- package/dist/adapters/sqlite/tools/text.js.map +1 -0
- package/dist/adapters/sqlite/tools/vector.d.ts +14 -0
- package/dist/adapters/sqlite/tools/vector.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/vector.js +613 -0
- package/dist/adapters/sqlite/tools/vector.js.map +1 -0
- package/dist/adapters/sqlite/tools/virtual.d.ts +13 -0
- package/dist/adapters/sqlite/tools/virtual.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/virtual.js +930 -0
- package/dist/adapters/sqlite/tools/virtual.js.map +1 -0
- package/dist/adapters/sqlite/types.d.ts +207 -0
- package/dist/adapters/sqlite/types.d.ts.map +1 -0
- package/dist/adapters/sqlite/types.js +186 -0
- package/dist/adapters/sqlite/types.js.map +1 -0
- package/dist/adapters/sqlite-native/NativeSqliteAdapter.d.ts +163 -0
- package/dist/adapters/sqlite-native/NativeSqliteAdapter.d.ts.map +1 -0
- package/dist/adapters/sqlite-native/NativeSqliteAdapter.js +748 -0
- package/dist/adapters/sqlite-native/NativeSqliteAdapter.js.map +1 -0
- package/dist/adapters/sqlite-native/index.d.ts +11 -0
- package/dist/adapters/sqlite-native/index.d.ts.map +1 -0
- package/dist/adapters/sqlite-native/index.js +11 -0
- package/dist/adapters/sqlite-native/index.js.map +1 -0
- package/dist/adapters/sqlite-native/tools/spatialite.d.ts +19 -0
- package/dist/adapters/sqlite-native/tools/spatialite.d.ts.map +1 -0
- package/dist/adapters/sqlite-native/tools/spatialite.js +628 -0
- package/dist/adapters/sqlite-native/tools/spatialite.js.map +1 -0
- package/dist/adapters/sqlite-native/tools/transactions.d.ts +12 -0
- package/dist/adapters/sqlite-native/tools/transactions.d.ts.map +1 -0
- package/dist/adapters/sqlite-native/tools/transactions.js +255 -0
- package/dist/adapters/sqlite-native/tools/transactions.js.map +1 -0
- package/dist/adapters/sqlite-native/tools/window.d.ts +12 -0
- package/dist/adapters/sqlite-native/tools/window.d.ts.map +1 -0
- package/dist/adapters/sqlite-native/tools/window.js +370 -0
- package/dist/adapters/sqlite-native/tools/window.js.map +1 -0
- package/dist/auth/AuthorizationServerDiscovery.d.ts +90 -0
- package/dist/auth/AuthorizationServerDiscovery.d.ts.map +1 -0
- package/dist/auth/AuthorizationServerDiscovery.js +204 -0
- package/dist/auth/AuthorizationServerDiscovery.js.map +1 -0
- package/dist/auth/OAuthResourceServer.d.ts +65 -0
- package/dist/auth/OAuthResourceServer.d.ts.map +1 -0
- package/dist/auth/OAuthResourceServer.js +121 -0
- package/dist/auth/OAuthResourceServer.js.map +1 -0
- package/dist/auth/TokenValidator.d.ts +60 -0
- package/dist/auth/TokenValidator.d.ts.map +1 -0
- package/dist/auth/TokenValidator.js +235 -0
- package/dist/auth/TokenValidator.js.map +1 -0
- package/dist/auth/errors.d.ts +74 -0
- package/dist/auth/errors.d.ts.map +1 -0
- package/dist/auth/errors.js +133 -0
- package/dist/auth/errors.js.map +1 -0
- package/dist/auth/index.d.ts +13 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +15 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/middleware.d.ts +81 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +291 -0
- package/dist/auth/middleware.js.map +1 -0
- package/dist/auth/scopes.d.ts +136 -0
- package/dist/auth/scopes.d.ts.map +1 -0
- package/dist/auth/scopes.js +349 -0
- package/dist/auth/scopes.js.map +1 -0
- package/dist/auth/types.d.ts +257 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +8 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +236 -0
- package/dist/cli.js.map +1 -0
- package/dist/constants/ServerInstructions.d.ts +45 -0
- package/dist/constants/ServerInstructions.d.ts.map +1 -0
- package/dist/constants/ServerInstructions.js +356 -0
- package/dist/constants/ServerInstructions.js.map +1 -0
- package/dist/filtering/ToolConstants.d.ts +34 -0
- package/dist/filtering/ToolConstants.d.ts.map +1 -0
- package/dist/filtering/ToolConstants.js +174 -0
- package/dist/filtering/ToolConstants.js.map +1 -0
- package/dist/filtering/ToolFilter.d.ts +82 -0
- package/dist/filtering/ToolFilter.d.ts.map +1 -0
- package/dist/filtering/ToolFilter.js +296 -0
- package/dist/filtering/ToolFilter.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/server/McpServer.d.ts +61 -0
- package/dist/server/McpServer.d.ts.map +1 -0
- package/dist/server/McpServer.js +270 -0
- package/dist/server/McpServer.js.map +1 -0
- package/dist/transports/http.d.ts +134 -0
- package/dist/transports/http.d.ts.map +1 -0
- package/dist/transports/http.js +516 -0
- package/dist/transports/http.js.map +1 -0
- package/dist/transports/index.d.ts +5 -0
- package/dist/transports/index.d.ts.map +1 -0
- package/dist/transports/index.js +5 -0
- package/dist/transports/index.js.map +1 -0
- package/dist/types/index.d.ts +380 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +68 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/annotations.d.ts +44 -0
- package/dist/utils/annotations.d.ts.map +1 -0
- package/dist/utils/annotations.js +77 -0
- package/dist/utils/annotations.js.map +1 -0
- package/dist/utils/errors.d.ts +155 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +329 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/identifiers.d.ts +121 -0
- package/dist/utils/identifiers.d.ts.map +1 -0
- package/dist/utils/identifiers.js +319 -0
- package/dist/utils/identifiers.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/insightsManager.d.ts +39 -0
- package/dist/utils/insightsManager.d.ts.map +1 -0
- package/dist/utils/insightsManager.js +63 -0
- package/dist/utils/insightsManager.js.map +1 -0
- package/dist/utils/logger.d.ts +189 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +394 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/progress-utils.d.ts +54 -0
- package/dist/utils/progress-utils.d.ts.map +1 -0
- package/dist/utils/progress-utils.js +74 -0
- package/dist/utils/progress-utils.js.map +1 -0
- package/dist/utils/resourceAnnotations.d.ts +36 -0
- package/dist/utils/resourceAnnotations.d.ts.map +1 -0
- package/dist/utils/resourceAnnotations.js +57 -0
- package/dist/utils/resourceAnnotations.js.map +1 -0
- package/dist/utils/where-clause.d.ts +41 -0
- package/dist/utils/where-clause.d.ts.map +1 -0
- package/dist/utils/where-clause.js +116 -0
- package/dist/utils/where-clause.js.map +1 -0
- package/package.json +83 -0
- package/server.json +53 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* db-mcp - SQLite MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for the MCP server, database adapters,
|
|
5
|
+
* OAuth 2.0 authentication, and tool filtering.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Supported database types
|
|
9
|
+
*
|
|
10
|
+
* Note: This MCP server only supports SQLite. Other database types are listed
|
|
11
|
+
* here for type compatibility but would require separate MCP server projects.
|
|
12
|
+
*/
|
|
13
|
+
export type DatabaseType = "sqlite" | "postgresql" | "mysql" | "mongodb" | "redis" | "sqlserver";
|
|
14
|
+
/**
|
|
15
|
+
* Database connection configuration
|
|
16
|
+
*/
|
|
17
|
+
export interface DatabaseConfig {
|
|
18
|
+
/** Database type identifier */
|
|
19
|
+
type: DatabaseType;
|
|
20
|
+
/** Connection string (format varies by database type) */
|
|
21
|
+
connectionString?: string;
|
|
22
|
+
/** Individual connection parameters (alternative to connectionString) */
|
|
23
|
+
host?: string;
|
|
24
|
+
port?: number;
|
|
25
|
+
database?: string;
|
|
26
|
+
username?: string;
|
|
27
|
+
password?: string;
|
|
28
|
+
/** Additional database-specific options */
|
|
29
|
+
options?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Database connection health status
|
|
33
|
+
*/
|
|
34
|
+
export interface HealthStatus {
|
|
35
|
+
connected: boolean;
|
|
36
|
+
latencyMs?: number;
|
|
37
|
+
version?: string;
|
|
38
|
+
details?: Record<string, unknown>;
|
|
39
|
+
error?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Query execution result
|
|
43
|
+
*/
|
|
44
|
+
export interface QueryResult {
|
|
45
|
+
/** Rows returned (for SELECT queries) */
|
|
46
|
+
rows?: Record<string, unknown>[];
|
|
47
|
+
/** Number of rows affected (for INSERT/UPDATE/DELETE) */
|
|
48
|
+
rowsAffected?: number;
|
|
49
|
+
/** Last inserted ID (for INSERT with auto-increment) */
|
|
50
|
+
lastInsertId?: number | string;
|
|
51
|
+
/** Query execution time in milliseconds */
|
|
52
|
+
executionTimeMs?: number;
|
|
53
|
+
/** Column metadata */
|
|
54
|
+
columns?: ColumnInfo[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Column metadata information
|
|
58
|
+
*/
|
|
59
|
+
export interface ColumnInfo {
|
|
60
|
+
name: string;
|
|
61
|
+
type: string;
|
|
62
|
+
nullable?: boolean;
|
|
63
|
+
primaryKey?: boolean;
|
|
64
|
+
defaultValue?: unknown;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Table information
|
|
68
|
+
*/
|
|
69
|
+
export interface TableInfo {
|
|
70
|
+
name: string;
|
|
71
|
+
schema?: string;
|
|
72
|
+
type: "table" | "view" | "materialized_view";
|
|
73
|
+
rowCount?: number;
|
|
74
|
+
columns?: ColumnInfo[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Schema information for a database
|
|
78
|
+
*/
|
|
79
|
+
export interface SchemaInfo {
|
|
80
|
+
tables: TableInfo[];
|
|
81
|
+
views?: TableInfo[];
|
|
82
|
+
indexes?: IndexInfo[];
|
|
83
|
+
constraints?: ConstraintInfo[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Index information
|
|
87
|
+
*/
|
|
88
|
+
export interface IndexInfo {
|
|
89
|
+
name: string;
|
|
90
|
+
tableName: string;
|
|
91
|
+
columns: string[];
|
|
92
|
+
unique: boolean;
|
|
93
|
+
type?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Constraint information
|
|
97
|
+
*/
|
|
98
|
+
export interface ConstraintInfo {
|
|
99
|
+
name: string;
|
|
100
|
+
tableName: string;
|
|
101
|
+
type: "primary_key" | "foreign_key" | "unique" | "check";
|
|
102
|
+
columns: string[];
|
|
103
|
+
referencedTable?: string;
|
|
104
|
+
referencedColumns?: string[];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Transport type for MCP communication
|
|
108
|
+
*/
|
|
109
|
+
export type TransportType = "stdio" | "http" | "sse";
|
|
110
|
+
/**
|
|
111
|
+
* MCP Server configuration
|
|
112
|
+
*/
|
|
113
|
+
export interface McpServerConfig {
|
|
114
|
+
/** Server name */
|
|
115
|
+
name: string;
|
|
116
|
+
/** Server version */
|
|
117
|
+
version: string;
|
|
118
|
+
/** Transport configuration */
|
|
119
|
+
transport: TransportType;
|
|
120
|
+
/** HTTP port (for http/sse transports) */
|
|
121
|
+
port?: number;
|
|
122
|
+
/** Database configurations */
|
|
123
|
+
databases: DatabaseConfig[];
|
|
124
|
+
/** OAuth configuration */
|
|
125
|
+
oauth?: OAuthConfig;
|
|
126
|
+
/** Tool filtering configuration */
|
|
127
|
+
toolFilter?: string;
|
|
128
|
+
/**
|
|
129
|
+
* Enable stateless HTTP mode (no session management, no SSE streaming).
|
|
130
|
+
* Ideal for serverless deployments (Lambda, Workers, Vercel).
|
|
131
|
+
* Default: false (stateful mode with session management and SSE support)
|
|
132
|
+
*/
|
|
133
|
+
statelessHttp?: boolean;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* OAuth 2.0 configuration
|
|
137
|
+
*/
|
|
138
|
+
export interface OAuthConfig {
|
|
139
|
+
/** Enable OAuth authentication */
|
|
140
|
+
enabled: boolean;
|
|
141
|
+
/** Authorization server URL */
|
|
142
|
+
authorizationServerUrl?: string;
|
|
143
|
+
/** Token validation endpoint */
|
|
144
|
+
tokenEndpoint?: string;
|
|
145
|
+
/** JWKS URI for token verification */
|
|
146
|
+
jwksUri?: string;
|
|
147
|
+
/** Expected audience in tokens */
|
|
148
|
+
audience?: string;
|
|
149
|
+
/** Expected issuer in tokens */
|
|
150
|
+
issuer?: string;
|
|
151
|
+
/** Clock tolerance for token validation (seconds) */
|
|
152
|
+
clockTolerance?: number;
|
|
153
|
+
/** JWKS cache TTL (seconds) */
|
|
154
|
+
jwksCacheTtl?: number;
|
|
155
|
+
/** Paths that bypass authentication */
|
|
156
|
+
publicPaths?: string[];
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* OAuth scopes for access control
|
|
160
|
+
*/
|
|
161
|
+
export type OAuthScope = "read" | "write" | "admin" | `db:${string}` | `table:${string}:${string}`;
|
|
162
|
+
/**
|
|
163
|
+
* Validated OAuth token claims
|
|
164
|
+
*/
|
|
165
|
+
export interface TokenClaims {
|
|
166
|
+
/** Subject (user ID) */
|
|
167
|
+
sub: string;
|
|
168
|
+
/** Granted scopes */
|
|
169
|
+
scopes: OAuthScope[];
|
|
170
|
+
/** Token expiration time */
|
|
171
|
+
exp: number;
|
|
172
|
+
/** Token issued at time */
|
|
173
|
+
iat: number;
|
|
174
|
+
/** Token issuer */
|
|
175
|
+
iss?: string;
|
|
176
|
+
/** Token audience */
|
|
177
|
+
aud?: string | string[];
|
|
178
|
+
/** Additional claims */
|
|
179
|
+
[key: string]: unknown;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Request context with authentication info
|
|
183
|
+
*/
|
|
184
|
+
export interface RequestContext {
|
|
185
|
+
/** Validated token claims (if authenticated) */
|
|
186
|
+
auth?: TokenClaims;
|
|
187
|
+
/** Raw access token */
|
|
188
|
+
accessToken?: string;
|
|
189
|
+
/** Request timestamp */
|
|
190
|
+
timestamp: Date;
|
|
191
|
+
/** Request ID for tracing */
|
|
192
|
+
requestId: string;
|
|
193
|
+
/**
|
|
194
|
+
* MCP Server instance for sending progress notifications.
|
|
195
|
+
* Only available when running in HTTP/SSE transport with stateful sessions.
|
|
196
|
+
*/
|
|
197
|
+
server?: unknown;
|
|
198
|
+
/**
|
|
199
|
+
* Progress token from client request _meta (MCP 2025-11-25).
|
|
200
|
+
* If present, the client has requested progress updates.
|
|
201
|
+
*/
|
|
202
|
+
progressToken?: string | number;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Tool group identifiers
|
|
206
|
+
*/
|
|
207
|
+
export type ToolGroup = "core" | "json" | "text" | "stats" | "vector" | "admin" | "geo";
|
|
208
|
+
/**
|
|
209
|
+
* Meta-group identifiers for common multi-group selections.
|
|
210
|
+
* These are shortcuts that expand to multiple ToolGroups.
|
|
211
|
+
*/
|
|
212
|
+
export type MetaGroup = "starter" | "analytics" | "search" | "spatial" | "minimal" | "full";
|
|
213
|
+
/**
|
|
214
|
+
* Tool filter rule
|
|
215
|
+
*/
|
|
216
|
+
export interface ToolFilterRule {
|
|
217
|
+
/** Rule type: include or exclude */
|
|
218
|
+
type: "include" | "exclude";
|
|
219
|
+
/** Target: group name or tool name */
|
|
220
|
+
target: string;
|
|
221
|
+
/** Whether target is a group (true) or individual tool (false) */
|
|
222
|
+
isGroup: boolean;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Parsed tool filter configuration
|
|
226
|
+
*/
|
|
227
|
+
export interface ToolFilterConfig {
|
|
228
|
+
/** Original filter string */
|
|
229
|
+
raw: string;
|
|
230
|
+
/** Parsed rules in order */
|
|
231
|
+
rules: ToolFilterRule[];
|
|
232
|
+
/** Set of enabled tool groups after applying rules */
|
|
233
|
+
enabledGroups: Set<ToolGroup>;
|
|
234
|
+
/** Set of explicitly excluded tool names (base names without prefix) */
|
|
235
|
+
excludedTools: Set<string>;
|
|
236
|
+
/** Set of explicitly included tool names (base names without prefix) */
|
|
237
|
+
includedTools: Set<string>;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Tool annotations provide behavioral hints to clients
|
|
241
|
+
* following the MCP 2025-11-25 specification.
|
|
242
|
+
*/
|
|
243
|
+
export interface ToolAnnotations {
|
|
244
|
+
/** Human-readable title for the tool */
|
|
245
|
+
title?: string;
|
|
246
|
+
/** If true, the tool is guaranteed not to modify any state */
|
|
247
|
+
readOnlyHint?: boolean;
|
|
248
|
+
/** If true, multiple identical requests have the same effect as a single request */
|
|
249
|
+
idempotentHint?: boolean;
|
|
250
|
+
/** If true, the operation is irreversible or causes significant data loss */
|
|
251
|
+
destructiveHint?: boolean;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Capabilities supported by a database adapter
|
|
255
|
+
*/
|
|
256
|
+
export interface AdapterCapabilities {
|
|
257
|
+
/** Supports JSON operations */
|
|
258
|
+
json: boolean;
|
|
259
|
+
/** Supports full-text search */
|
|
260
|
+
fullTextSearch: boolean;
|
|
261
|
+
/** Supports vector/embedding operations */
|
|
262
|
+
vector: boolean;
|
|
263
|
+
/** Supports geospatial operations */
|
|
264
|
+
geospatial: boolean;
|
|
265
|
+
/** Supports transactions */
|
|
266
|
+
transactions: boolean;
|
|
267
|
+
/** Supports prepared statements */
|
|
268
|
+
preparedStatements: boolean;
|
|
269
|
+
/** Supports connection pooling */
|
|
270
|
+
connectionPooling: boolean;
|
|
271
|
+
/** Additional capability flags */
|
|
272
|
+
[key: string]: boolean;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Tool definition for registration
|
|
276
|
+
*/
|
|
277
|
+
export interface ToolDefinition {
|
|
278
|
+
/** Unique tool name */
|
|
279
|
+
name: string;
|
|
280
|
+
/** Human-readable description */
|
|
281
|
+
description: string;
|
|
282
|
+
/** Tool group for filtering */
|
|
283
|
+
group: ToolGroup;
|
|
284
|
+
/** Zod schema for input validation */
|
|
285
|
+
inputSchema: unknown;
|
|
286
|
+
/** Zod schema for output validation (MCP 2025-11-25) */
|
|
287
|
+
outputSchema?: unknown;
|
|
288
|
+
/** Required OAuth scopes */
|
|
289
|
+
requiredScopes?: OAuthScope[];
|
|
290
|
+
/** MCP tool annotations (behavioral hints) */
|
|
291
|
+
annotations?: ToolAnnotations;
|
|
292
|
+
/** Tool handler function */
|
|
293
|
+
handler: (params: unknown, context: RequestContext) => Promise<unknown>;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* MCP Resource Annotations (SDK 1.25+)
|
|
297
|
+
* Provides metadata hints about resource content to help clients
|
|
298
|
+
* manage and display resources appropriately.
|
|
299
|
+
*/
|
|
300
|
+
export interface ResourceAnnotations {
|
|
301
|
+
/** Intended audience for the resource content */
|
|
302
|
+
audience?: ("user" | "assistant")[];
|
|
303
|
+
/** Priority hint for display ordering (0-1 range) */
|
|
304
|
+
priority?: number;
|
|
305
|
+
/** ISO 8601 timestamp of last modification for cache invalidation */
|
|
306
|
+
lastModified?: string;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Resource definition for MCP
|
|
310
|
+
*/
|
|
311
|
+
export interface ResourceDefinition {
|
|
312
|
+
/** Resource URI template */
|
|
313
|
+
uri: string;
|
|
314
|
+
/** Human-readable name */
|
|
315
|
+
name: string;
|
|
316
|
+
/** Description */
|
|
317
|
+
description: string;
|
|
318
|
+
/** MIME type */
|
|
319
|
+
mimeType?: string;
|
|
320
|
+
/** MCP Resource Annotations for behavior hints */
|
|
321
|
+
annotations?: ResourceAnnotations;
|
|
322
|
+
/** Resource handler */
|
|
323
|
+
handler: (uri: string, context: RequestContext) => Promise<unknown>;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Prompt definition for MCP
|
|
327
|
+
*/
|
|
328
|
+
export interface PromptDefinition {
|
|
329
|
+
/** Prompt name */
|
|
330
|
+
name: string;
|
|
331
|
+
/** Description */
|
|
332
|
+
description: string;
|
|
333
|
+
/** Argument definitions */
|
|
334
|
+
arguments?: {
|
|
335
|
+
name: string;
|
|
336
|
+
description: string;
|
|
337
|
+
required?: boolean;
|
|
338
|
+
}[];
|
|
339
|
+
/** Prompt handler */
|
|
340
|
+
handler: (args: Record<string, string>, context: RequestContext) => Promise<unknown>;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Base error class for db-mcp
|
|
344
|
+
*/
|
|
345
|
+
export declare class DbMcpError extends Error {
|
|
346
|
+
readonly code: string;
|
|
347
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
348
|
+
constructor(message: string, code: string, details?: Record<string, unknown> | undefined);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Database connection error
|
|
352
|
+
*/
|
|
353
|
+
export declare class ConnectionError extends DbMcpError {
|
|
354
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Query execution error
|
|
358
|
+
*/
|
|
359
|
+
export declare class QueryError extends DbMcpError {
|
|
360
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Authentication error
|
|
364
|
+
*/
|
|
365
|
+
export declare class AuthenticationError extends DbMcpError {
|
|
366
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Authorization error (insufficient permissions)
|
|
370
|
+
*/
|
|
371
|
+
export declare class AuthorizationError extends DbMcpError {
|
|
372
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Validation error for input parameters
|
|
376
|
+
*/
|
|
377
|
+
export declare class ValidationError extends DbMcpError {
|
|
378
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
379
|
+
}
|
|
380
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,YAAY,GACZ,OAAO,GACP,SAAS,GACT,OAAO,GACP,WAAW,CAAC;AAEhB;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,+BAA+B;IAC/B,IAAI,EAAE,YAAY,CAAC;IAEnB,yDAAyD;IACzD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,yCAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAEjC,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE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,OAAO,CAAC,OAAO,CAAC,CAAC;CACvB;AAMD;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAK;aAGjB,IAAI,EAAE,MAAM;aACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAFjD,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;CAKpD;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,UAAU;gBACjC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAI/D;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,UAAU;gBAC5B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAI/D;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,UAAU;gBACrC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAI/D;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,UAAU;gBACpC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAI/D;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,UAAU;gBACjC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAI/D"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* db-mcp - SQLite MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for the MCP server, database adapters,
|
|
5
|
+
* OAuth 2.0 authentication, and tool filtering.
|
|
6
|
+
*/
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// Error Types
|
|
9
|
+
// =============================================================================
|
|
10
|
+
/**
|
|
11
|
+
* Base error class for db-mcp
|
|
12
|
+
*/
|
|
13
|
+
export class DbMcpError extends Error {
|
|
14
|
+
code;
|
|
15
|
+
details;
|
|
16
|
+
constructor(message, code, details) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.code = code;
|
|
19
|
+
this.details = details;
|
|
20
|
+
this.name = "DbMcpError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Database connection error
|
|
25
|
+
*/
|
|
26
|
+
export class ConnectionError extends DbMcpError {
|
|
27
|
+
constructor(message, details) {
|
|
28
|
+
super(message, "CONNECTION_ERROR", details);
|
|
29
|
+
this.name = "ConnectionError";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Query execution error
|
|
34
|
+
*/
|
|
35
|
+
export class QueryError extends DbMcpError {
|
|
36
|
+
constructor(message, details) {
|
|
37
|
+
super(message, "QUERY_ERROR", details);
|
|
38
|
+
this.name = "QueryError";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Authentication error
|
|
43
|
+
*/
|
|
44
|
+
export class AuthenticationError extends DbMcpError {
|
|
45
|
+
constructor(message, details) {
|
|
46
|
+
super(message, "AUTHENTICATION_ERROR", details);
|
|
47
|
+
this.name = "AuthenticationError";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Authorization error (insufficient permissions)
|
|
52
|
+
*/
|
|
53
|
+
export class AuthorizationError extends DbMcpError {
|
|
54
|
+
constructor(message, details) {
|
|
55
|
+
super(message, "AUTHORIZATION_ERROR", details);
|
|
56
|
+
this.name = "AuthorizationError";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Validation error for input parameters
|
|
61
|
+
*/
|
|
62
|
+
export class ValidationError extends DbMcpError {
|
|
63
|
+
constructor(message, details) {
|
|
64
|
+
super(message, "VALIDATION_ERROR", details);
|
|
65
|
+
this.name = "ValidationError";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA+dH,gFAAgF;AAChF,cAAc;AACd,gFAAgF;AAEhF;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IAGjB;IACA;IAHlB,YACE,OAAe,EACC,IAAY,EACZ,OAAiC;QAEjD,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAA0B;QAGjD,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC7C,YAAY,OAAe,EAAE,OAAiC;QAC5D,KAAK,CAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;IACxC,YAAY,OAAe,EAAE,OAAiC;QAC5D,KAAK,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,UAAU;IACjD,YAAY,OAAe,EAAE,OAAiC;QAC5D,KAAK,CAAC,OAAO,EAAE,sBAAsB,EAAE,OAAO,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,UAAU;IAChD,YAAY,OAAe,EAAE,OAAiC;QAC5D,KAAK,CAAC,OAAO,EAAE,qBAAqB,EAAE,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC7C,YAAY,OAAe,EAAE,OAAiC;QAC5D,KAAK,CAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Annotations Presets
|
|
3
|
+
*
|
|
4
|
+
* Reusable annotation configurations for common tool behavior patterns.
|
|
5
|
+
* Used by all tool definition files for consistency.
|
|
6
|
+
*
|
|
7
|
+
* Follows MCP 2025-11-25 specification.
|
|
8
|
+
*/
|
|
9
|
+
import type { ToolAnnotations } from "../types/index.js";
|
|
10
|
+
/** Read-only query tools (SELECT, schema retrieval, metadata) */
|
|
11
|
+
export declare const READ_ONLY: ToolAnnotations;
|
|
12
|
+
/** Standard write tools (INSERT, UPDATE, CREATE) */
|
|
13
|
+
export declare const WRITE: ToolAnnotations;
|
|
14
|
+
/** Destructive tools (DELETE, DROP, TRUNCATE) */
|
|
15
|
+
export declare const DESTRUCTIVE: ToolAnnotations;
|
|
16
|
+
/** Idempotent tools (CREATE IF NOT EXISTS, upserts) */
|
|
17
|
+
export declare const IDEMPOTENT: ToolAnnotations;
|
|
18
|
+
/** Admin/maintenance tools (VACUUM, ANALYZE, PRAGMA) */
|
|
19
|
+
export declare const ADMIN: ToolAnnotations;
|
|
20
|
+
/**
|
|
21
|
+
* Create annotations with a custom title
|
|
22
|
+
*/
|
|
23
|
+
export declare function withTitle(title: string, base?: ToolAnnotations): ToolAnnotations;
|
|
24
|
+
/**
|
|
25
|
+
* Create read-only annotations with title
|
|
26
|
+
*/
|
|
27
|
+
export declare function readOnly(title: string): ToolAnnotations;
|
|
28
|
+
/**
|
|
29
|
+
* Create write annotations with title
|
|
30
|
+
*/
|
|
31
|
+
export declare function write(title: string): ToolAnnotations;
|
|
32
|
+
/**
|
|
33
|
+
* Create destructive annotations with title
|
|
34
|
+
*/
|
|
35
|
+
export declare function destructive(title: string): ToolAnnotations;
|
|
36
|
+
/**
|
|
37
|
+
* Create idempotent annotations with title
|
|
38
|
+
*/
|
|
39
|
+
export declare function idempotent(title: string): ToolAnnotations;
|
|
40
|
+
/**
|
|
41
|
+
* Create admin annotations with title
|
|
42
|
+
*/
|
|
43
|
+
export declare function admin(title: string): ToolAnnotations;
|
|
44
|
+
//# sourceMappingURL=annotations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../src/utils/annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMzD,iEAAiE;AACjE,eAAO,MAAM,SAAS,EAAE,eAGvB,CAAC;AAEF,oDAAoD;AACpD,eAAO,MAAM,KAAK,EAAE,eAGnB,CAAC;AAEF,iDAAiD;AACjD,eAAO,MAAM,WAAW,EAAE,eAGzB,CAAC;AAEF,uDAAuD;AACvD,eAAO,MAAM,UAAU,EAAE,eAIxB,CAAC;AAEF,wDAAwD;AACxD,eAAO,MAAM,KAAK,EAAE,eAGnB,CAAC;AAMF;;GAEG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,eAA2B,GAChC,eAAe,CAEjB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAEvD;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAEpD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAE1D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAEzD;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAEpD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Annotations Presets
|
|
3
|
+
*
|
|
4
|
+
* Reusable annotation configurations for common tool behavior patterns.
|
|
5
|
+
* Used by all tool definition files for consistency.
|
|
6
|
+
*
|
|
7
|
+
* Follows MCP 2025-11-25 specification.
|
|
8
|
+
*/
|
|
9
|
+
// =============================================================================
|
|
10
|
+
// Base Annotation Presets
|
|
11
|
+
// =============================================================================
|
|
12
|
+
/** Read-only query tools (SELECT, schema retrieval, metadata) */
|
|
13
|
+
export const READ_ONLY = {
|
|
14
|
+
readOnlyHint: true,
|
|
15
|
+
destructiveHint: false,
|
|
16
|
+
};
|
|
17
|
+
/** Standard write tools (INSERT, UPDATE, CREATE) */
|
|
18
|
+
export const WRITE = {
|
|
19
|
+
readOnlyHint: false,
|
|
20
|
+
destructiveHint: false,
|
|
21
|
+
};
|
|
22
|
+
/** Destructive tools (DELETE, DROP, TRUNCATE) */
|
|
23
|
+
export const DESTRUCTIVE = {
|
|
24
|
+
readOnlyHint: false,
|
|
25
|
+
destructiveHint: true,
|
|
26
|
+
};
|
|
27
|
+
/** Idempotent tools (CREATE IF NOT EXISTS, upserts) */
|
|
28
|
+
export const IDEMPOTENT = {
|
|
29
|
+
readOnlyHint: false,
|
|
30
|
+
destructiveHint: false,
|
|
31
|
+
idempotentHint: true,
|
|
32
|
+
};
|
|
33
|
+
/** Admin/maintenance tools (VACUUM, ANALYZE, PRAGMA) */
|
|
34
|
+
export const ADMIN = {
|
|
35
|
+
readOnlyHint: false,
|
|
36
|
+
destructiveHint: false,
|
|
37
|
+
};
|
|
38
|
+
// =============================================================================
|
|
39
|
+
// Helper Functions
|
|
40
|
+
// =============================================================================
|
|
41
|
+
/**
|
|
42
|
+
* Create annotations with a custom title
|
|
43
|
+
*/
|
|
44
|
+
export function withTitle(title, base = READ_ONLY) {
|
|
45
|
+
return { title, ...base };
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create read-only annotations with title
|
|
49
|
+
*/
|
|
50
|
+
export function readOnly(title) {
|
|
51
|
+
return { title, ...READ_ONLY };
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Create write annotations with title
|
|
55
|
+
*/
|
|
56
|
+
export function write(title) {
|
|
57
|
+
return { title, ...WRITE };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create destructive annotations with title
|
|
61
|
+
*/
|
|
62
|
+
export function destructive(title) {
|
|
63
|
+
return { title, ...DESTRUCTIVE };
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create idempotent annotations with title
|
|
67
|
+
*/
|
|
68
|
+
export function idempotent(title) {
|
|
69
|
+
return { title, ...IDEMPOTENT };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Create admin annotations with title
|
|
73
|
+
*/
|
|
74
|
+
export function admin(title) {
|
|
75
|
+
return { title, ...ADMIN };
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=annotations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.js","sourceRoot":"","sources":["../../src/utils/annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,gFAAgF;AAChF,0BAA0B;AAC1B,gFAAgF;AAEhF,iEAAiE;AACjE,MAAM,CAAC,MAAM,SAAS,GAAoB;IACxC,YAAY,EAAE,IAAI;IAClB,eAAe,EAAE,KAAK;CACvB,CAAC;AAEF,oDAAoD;AACpD,MAAM,CAAC,MAAM,KAAK,GAAoB;IACpC,YAAY,EAAE,KAAK;IACnB,eAAe,EAAE,KAAK;CACvB,CAAC;AAEF,iDAAiD;AACjD,MAAM,CAAC,MAAM,WAAW,GAAoB;IAC1C,YAAY,EAAE,KAAK;IACnB,eAAe,EAAE,IAAI;CACtB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