fms-odata-mcp 0.1.2

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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +154 -0
  3. package/dist/config.d.ts +104 -0
  4. package/dist/config.d.ts.map +1 -0
  5. package/dist/config.js +248 -0
  6. package/dist/config.js.map +1 -0
  7. package/dist/connection.d.ts +49 -0
  8. package/dist/connection.d.ts.map +1 -0
  9. package/dist/connection.js +126 -0
  10. package/dist/connection.js.map +1 -0
  11. package/dist/index.d.ts +7 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +90 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/logger.d.ts +15 -0
  16. package/dist/logger.d.ts.map +1 -0
  17. package/dist/logger.js +57 -0
  18. package/dist/logger.js.map +1 -0
  19. package/dist/odata-client.d.ts +102 -0
  20. package/dist/odata-client.d.ts.map +1 -0
  21. package/dist/odata-client.js +226 -0
  22. package/dist/odata-client.js.map +1 -0
  23. package/dist/odata-parser.d.ts +64 -0
  24. package/dist/odata-parser.d.ts.map +1 -0
  25. package/dist/odata-parser.js +126 -0
  26. package/dist/odata-parser.js.map +1 -0
  27. package/dist/tools/configuration.d.ts +69 -0
  28. package/dist/tools/configuration.d.ts.map +1 -0
  29. package/dist/tools/configuration.js +221 -0
  30. package/dist/tools/configuration.js.map +1 -0
  31. package/dist/tools/connection.d.ts +66 -0
  32. package/dist/tools/connection.d.ts.map +1 -0
  33. package/dist/tools/connection.js +230 -0
  34. package/dist/tools/connection.js.map +1 -0
  35. package/dist/tools/index.d.ts +319 -0
  36. package/dist/tools/index.d.ts.map +1 -0
  37. package/dist/tools/index.js +48 -0
  38. package/dist/tools/index.js.map +1 -0
  39. package/dist/tools/odata.d.ts +233 -0
  40. package/dist/tools/odata.d.ts.map +1 -0
  41. package/dist/tools/odata.js +404 -0
  42. package/dist/tools/odata.js.map +1 -0
  43. package/dist/transport.d.ts +18 -0
  44. package/dist/transport.d.ts.map +1 -0
  45. package/dist/transport.js +138 -0
  46. package/dist/transport.js.map +1 -0
  47. package/package.json +72 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Francesc Sans
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,154 @@
1
+ # FileMaker Server OData MCP
2
+
3
+ [![npm version](https://img.shields.io/npm/v/fms-odata-mcp.svg)](https://www.npmjs.com/package/fms-odata-mcp)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ Model Context Protocol (MCP) server providing FileMaker Server OData 4.01 API integration for AI assistants like Claude Desktop, Windsurf, Cursor, and Cline.
7
+
8
+ ## Features
9
+
10
+ - 🔌 **19 MCP Tools** for FileMaker database operations
11
+ - 🔍 **Database Discovery** - Explore tables, fields, and metadata
12
+ - 📊 **CRUD Operations** - Create, read, update, and delete records
13
+ - 🔐 **Secure Connections** - SSL support for self-signed certificates
14
+ - 💾 **Connection Management** - Save and reuse database connections
15
+ - 📝 **OData 4.01 Standard** - Full query capabilities ($filter, $select, $orderby, etc.)
16
+
17
+ ## Quick Start
18
+
19
+ ### Installation
20
+
21
+ ```bash
22
+ # Via NPM (recommended)
23
+ npm install -g fms-odata-mcp
24
+
25
+ # Or local development
26
+ git clone https://github.com/fsans/FMS-ODATA-MCP.git
27
+ cd FMS-ODATA-MCP
28
+ npm install
29
+ npm run build
30
+ ```
31
+
32
+ ### Setup for Claude Desktop
33
+
34
+ 1. **Locate your Claude config file:**
35
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
36
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
37
+
38
+ 2. **Add the MCP server:**
39
+
40
+ ```json
41
+ {
42
+ "mcpServers": {
43
+ "filemaker": {
44
+ "command": "npx",
45
+ "args": ["-y", "fms-odata-mcp"],
46
+ "env": {
47
+ "FM_SERVER": "https://your-filemaker-server.com",
48
+ "FM_DATABASE": "YourDatabase",
49
+ "FM_USER": "your-username",
50
+ "FM_PASSWORD": "your-password",
51
+ "FM_VERIFY_SSL": "true"
52
+ }
53
+ }
54
+ }
55
+ }
56
+ ```
57
+
58
+ 3. **For self-signed SSL certificates**, set `FM_VERIFY_SSL` to `"false"`
59
+
60
+ 4. **Restart Claude Desktop**
61
+
62
+ ### First Steps
63
+
64
+ Once connected, try these prompts in Claude:
65
+
66
+ ```
67
+ What tables are in my FileMaker database?
68
+
69
+ Show me the first 5 records from the Contacts table
70
+
71
+ Find all contacts where LastName equals "Smith"
72
+
73
+ Create a new contact with name "John Doe" and email "john@example.com"
74
+ ```
75
+
76
+ ## Documentation
77
+
78
+ - **[Quick Reference](./dev_stuf/QUICK_REFERENCE.md)** - One-page setup guide
79
+ - **[Prompt Examples](./dev_stuf/CLAUDE_DESKTOP_PROMPTS.md)** - Complete prompt reference
80
+ - **[Claude Desktop Setup](./dev_stuf/CLAUDE_DESKTOP_SETUP.md)** - Detailed configuration
81
+ - **[Windsurf Setup](./dev_stuf/WINDSURF_SETUP.md)** - IDE integration guide
82
+
83
+ ## Available Tools
84
+
85
+ | Category | Tools |
86
+ |----------|-------|
87
+ | **Discovery** | `fm_odata_list_tables`, `fm_odata_get_metadata`, `fm_odata_get_service_document` |
88
+ | **Queries** | `fm_odata_query_records`, `fm_odata_get_record`, `fm_odata_get_records`, `fm_odata_count_records` |
89
+ | **CRUD** | `fm_odata_create_record`, `fm_odata_update_record`, `fm_odata_delete_record` |
90
+ | **Connection** | `fm_odata_connect`, `fm_odata_set_connection`, `fm_odata_list_connections`, `fm_odata_get_current_connection` |
91
+ | **Config** | `fm_odata_config_add_connection`, `fm_odata_config_remove_connection`, `fm_odata_config_list_connections` |
92
+
93
+ ## Requirements
94
+
95
+ - **Node.js** 18.0.0 or higher
96
+ - **FileMaker Server** with OData API enabled
97
+ - **FileMaker Account** with appropriate access privileges
98
+
99
+ ## Environment Variables
100
+
101
+ | Variable | Description | Required | Default |
102
+ |----------|-------------|----------|---------|
103
+ | `FM_SERVER` | FileMaker Server URL | Yes | - |
104
+ | `FM_DATABASE` | Database name | Yes | - |
105
+ | `FM_USER` | Username | Yes | - |
106
+ | `FM_PASSWORD` | Password | Yes | - |
107
+ | `FM_VERIFY_SSL` | Verify SSL certificates | No | `true` |
108
+ | `FM_TIMEOUT` | Request timeout (ms) | No | `30000` |
109
+
110
+ ## OData Query Syntax
111
+
112
+ The server supports OData 4.01 query options:
113
+
114
+ ```
115
+ $filter - Filter records (e.g., "Age gt 18")
116
+ $select - Select specific fields
117
+ $orderby - Sort results
118
+ $top - Limit results
119
+ $skip - Skip records (pagination)
120
+ $expand - Include related records
121
+ $count - Include total count
122
+ ```
123
+
124
+ **Example prompts:**
125
+ ```
126
+ Get contacts where Age is greater than 18
127
+
128
+ Show only Name and Email fields from Contacts
129
+
130
+ Sort contacts by LastName in descending order
131
+
132
+ Get the first 10 contacts, skip the first 20
133
+ ```
134
+
135
+ ## Contributing
136
+
137
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for development guidelines.
138
+
139
+ ## License
140
+
141
+ MIT License - see [LICENSE](./LICENSE) file for details.
142
+
143
+ ## Support
144
+
145
+ - **Issues**: [GitHub Issues](https://github.com/fsans/FMS-ODATA-MCP/issues)
146
+ - **Discussions**: [GitHub Discussions](https://github.com/fsans/FMS-ODATA-MCP/discussions)
147
+
148
+ ## Changelog
149
+
150
+ See [dev_stuf/VERSIONING.md](./dev_stuf/VERSIONING.md) for version history.
151
+
152
+ ---
153
+
154
+ Made with ❤️ for the FileMaker and AI communities
@@ -0,0 +1,104 @@
1
+ export interface ServerConfig {
2
+ transport: "stdio" | "http" | "https";
3
+ port: number;
4
+ host: string;
5
+ }
6
+ export interface FileMakerConfig {
7
+ server: string;
8
+ database: string;
9
+ user: string;
10
+ password?: string;
11
+ verifySsl?: boolean;
12
+ timeout?: number;
13
+ }
14
+ export interface SecurityConfig {
15
+ certPath?: string;
16
+ keyPath?: string;
17
+ }
18
+ export interface Connection {
19
+ name?: string;
20
+ server: string;
21
+ database: string;
22
+ user: string;
23
+ password: string;
24
+ }
25
+ export interface AppConfig {
26
+ server: ServerConfig;
27
+ filemaker: FileMakerConfig;
28
+ security?: SecurityConfig;
29
+ connections?: Record<string, Connection>;
30
+ defaultConnection?: string;
31
+ }
32
+ /**
33
+ * Get config directory (dynamically resolves home directory)
34
+ * Uses process.env.HOME for testability
35
+ */
36
+ export declare function getConfigDir(): string;
37
+ /**
38
+ * Load configuration from file
39
+ */
40
+ export declare function loadConfigFile(): Partial<AppConfig>;
41
+ /**
42
+ * Save configuration to file
43
+ */
44
+ export declare function saveConfigFile(config: AppConfig): void;
45
+ /**
46
+ * Load environment variables from .env file
47
+ */
48
+ export declare function loadEnvFile(): void;
49
+ /**
50
+ * Get configuration with precedence: env vars > config file > defaults
51
+ */
52
+ export declare function getConfig(): AppConfig;
53
+ /**
54
+ * Validate configuration
55
+ */
56
+ export declare function validateConfig(config: AppConfig): {
57
+ valid: boolean;
58
+ errors: string[];
59
+ };
60
+ /**
61
+ * Get configuration file path
62
+ */
63
+ export declare function getConfigFilePath(): string;
64
+ /**
65
+ * Get environment file path
66
+ */
67
+ export declare function getEnvFilePath(): string;
68
+ /**
69
+ * Check if configuration exists
70
+ */
71
+ export declare function hasConfig(): boolean;
72
+ /**
73
+ * Get connections from config file
74
+ */
75
+ export declare function getConnections(): Record<string, Connection>;
76
+ /**
77
+ * Get a specific connection from config
78
+ */
79
+ export declare function getConnection(name: string): Connection | null;
80
+ /**
81
+ * Add a connection to config file
82
+ */
83
+ export declare function addConnection(name: string, connection: Connection): void;
84
+ /**
85
+ * Remove a connection from config file
86
+ */
87
+ export declare function removeConnection(name: string): void;
88
+ /**
89
+ * List all connections from config
90
+ */
91
+ export declare function listConnections(): Connection[];
92
+ /**
93
+ * Set default connection in config
94
+ */
95
+ export declare function setDefaultConnection(name: string): void;
96
+ /**
97
+ * Get default connection name from config
98
+ */
99
+ export declare function getDefaultConnectionName(): string | undefined;
100
+ /**
101
+ * Get default connection from config
102
+ */
103
+ export declare function getDefaultConnection(): Connection | null;
104
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WA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E,MAAM,GAAG,UAAU,GAAG,IAAI,CAG7D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CA4BxE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAgBnD;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,UAAU,EAAE,CAG9C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CASvD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,GAAG,SAAS,CAG7D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,UAAU,GAAG,IAAI,CAMxD"}
package/dist/config.js ADDED
@@ -0,0 +1,248 @@
1
+ import * as fs from "fs";
2
+ import * as path from "path";
3
+ import * as os from "os";
4
+ import * as dotenv from "dotenv";
5
+ /**
6
+ * Get config directory (dynamically resolves home directory)
7
+ * Uses process.env.HOME for testability
8
+ */
9
+ export function getConfigDir() {
10
+ const homeDir = process.env.HOME || process.env.USERPROFILE || os.homedir();
11
+ return path.join(homeDir, ".fms-odata-mcp");
12
+ }
13
+ /**
14
+ * Get config file path
15
+ */
16
+ function getConfigFile() {
17
+ return path.join(getConfigDir(), "config.json");
18
+ }
19
+ /**
20
+ * Get env file path
21
+ */
22
+ function getEnvFile() {
23
+ return path.join(getConfigDir(), ".env");
24
+ }
25
+ /**
26
+ * Load configuration from file
27
+ */
28
+ export function loadConfigFile() {
29
+ const configFile = getConfigFile();
30
+ if (fs.existsSync(configFile)) {
31
+ try {
32
+ return JSON.parse(fs.readFileSync(configFile, "utf-8"));
33
+ }
34
+ catch (error) {
35
+ console.error("Error reading config file:", error);
36
+ return {};
37
+ }
38
+ }
39
+ return {};
40
+ }
41
+ /**
42
+ * Save configuration to file
43
+ */
44
+ export function saveConfigFile(config) {
45
+ const configDir = getConfigDir();
46
+ const configFile = getConfigFile();
47
+ if (!fs.existsSync(configDir)) {
48
+ fs.mkdirSync(configDir, { recursive: true });
49
+ }
50
+ fs.writeFileSync(configFile, JSON.stringify(config, null, 2));
51
+ fs.chmodSync(configFile, 0o600); // Restrict permissions for security
52
+ }
53
+ /**
54
+ * Load environment variables from .env file
55
+ */
56
+ export function loadEnvFile() {
57
+ const envFile = getEnvFile();
58
+ if (fs.existsSync(envFile)) {
59
+ dotenv.config({ path: envFile });
60
+ }
61
+ }
62
+ /**
63
+ * Get configuration with precedence: env vars > config file > defaults
64
+ */
65
+ export function getConfig() {
66
+ // Load from file first
67
+ const fileConfig = loadConfigFile();
68
+ // Load environment variables
69
+ loadEnvFile();
70
+ // Build final config with precedence
71
+ const config = {
72
+ server: {
73
+ transport: process.env.MCP_TRANSPORT ||
74
+ fileConfig.server?.transport ||
75
+ "stdio",
76
+ port: parseInt(process.env.MCP_PORT || String(fileConfig.server?.port || 3000), 10),
77
+ host: process.env.MCP_HOST || fileConfig.server?.host || "localhost",
78
+ },
79
+ filemaker: {
80
+ server: process.env.FM_SERVER || fileConfig.filemaker?.server || "",
81
+ database: process.env.FM_DATABASE || fileConfig.filemaker?.database || "",
82
+ user: process.env.FM_USER || fileConfig.filemaker?.user || "",
83
+ password: process.env.FM_PASSWORD || fileConfig.filemaker?.password,
84
+ verifySsl: process.env.FM_VERIFY_SSL
85
+ ? process.env.FM_VERIFY_SSL.toLowerCase() === "true"
86
+ : fileConfig.filemaker?.verifySsl !== false, // Default to true
87
+ timeout: parseInt(process.env.FM_TIMEOUT || String(fileConfig.filemaker?.timeout || 30000), 10),
88
+ },
89
+ security: {
90
+ certPath: process.env.MCP_CERT_PATH || fileConfig.security?.certPath,
91
+ keyPath: process.env.MCP_KEY_PATH || fileConfig.security?.keyPath,
92
+ },
93
+ };
94
+ return config;
95
+ }
96
+ /**
97
+ * Validate configuration
98
+ */
99
+ export function validateConfig(config) {
100
+ const errors = [];
101
+ // Validate FileMaker configuration
102
+ if (!config.filemaker.server) {
103
+ errors.push("FM_SERVER is required");
104
+ }
105
+ if (!config.filemaker.database) {
106
+ errors.push("FM_DATABASE is required");
107
+ }
108
+ if (!config.filemaker.user) {
109
+ errors.push("FM_USER is required");
110
+ }
111
+ // Validate server configuration
112
+ if (config.server.transport !== "stdio") {
113
+ if (config.server.port < 1 || config.server.port > 65535) {
114
+ errors.push("MCP_PORT must be between 1 and 65535");
115
+ }
116
+ }
117
+ // Validate HTTPS configuration
118
+ if (config.server.transport === "https") {
119
+ if (!config.security?.certPath) {
120
+ errors.push("MCP_CERT_PATH is required for HTTPS transport");
121
+ }
122
+ if (!config.security?.keyPath) {
123
+ errors.push("MCP_KEY_PATH is required for HTTPS transport");
124
+ }
125
+ if (config.security?.certPath && !fs.existsSync(config.security.certPath)) {
126
+ errors.push(`Certificate file not found: ${config.security.certPath}`);
127
+ }
128
+ if (config.security?.keyPath && !fs.existsSync(config.security.keyPath)) {
129
+ errors.push(`Key file not found: ${config.security.keyPath}`);
130
+ }
131
+ }
132
+ return {
133
+ valid: errors.length === 0,
134
+ errors,
135
+ };
136
+ }
137
+ /**
138
+ * Get configuration file path
139
+ */
140
+ export function getConfigFilePath() {
141
+ return getConfigFile();
142
+ }
143
+ /**
144
+ * Get environment file path
145
+ */
146
+ export function getEnvFilePath() {
147
+ return getEnvFile();
148
+ }
149
+ /**
150
+ * Check if configuration exists
151
+ */
152
+ export function hasConfig() {
153
+ return fs.existsSync(getConfigFile());
154
+ }
155
+ /**
156
+ * Get connections from config file
157
+ */
158
+ export function getConnections() {
159
+ const config = loadConfigFile();
160
+ return config.connections || {};
161
+ }
162
+ /**
163
+ * Get a specific connection from config
164
+ */
165
+ export function getConnection(name) {
166
+ const connections = getConnections();
167
+ return connections[name] || null;
168
+ }
169
+ /**
170
+ * Add a connection to config file
171
+ */
172
+ export function addConnection(name, connection) {
173
+ const config = loadConfigFile();
174
+ if (!config.connections) {
175
+ config.connections = {};
176
+ }
177
+ // Check if connection already exists
178
+ if (config.connections[name]) {
179
+ throw new Error(`Connection "${name}" already exists`);
180
+ }
181
+ // Validate connection data
182
+ if (!connection.server || connection.server.trim() === "") {
183
+ throw new Error("Server is required");
184
+ }
185
+ if (!connection.database || connection.database.trim() === "") {
186
+ throw new Error("Database is required");
187
+ }
188
+ if (!connection.user || connection.user.trim() === "") {
189
+ throw new Error("User is required");
190
+ }
191
+ if (!connection.password || connection.password.trim() === "") {
192
+ throw new Error("Password is required");
193
+ }
194
+ config.connections[name] = { ...connection, name };
195
+ saveConfigFile(config);
196
+ }
197
+ /**
198
+ * Remove a connection from config file
199
+ */
200
+ export function removeConnection(name) {
201
+ const config = loadConfigFile();
202
+ // Check if connection exists
203
+ if (!config.connections || !config.connections[name]) {
204
+ throw new Error(`Connection "${name}" not found`);
205
+ }
206
+ delete config.connections[name];
207
+ // If this was the default connection, clear it
208
+ if (config.defaultConnection === name) {
209
+ config.defaultConnection = undefined;
210
+ }
211
+ saveConfigFile(config);
212
+ }
213
+ /**
214
+ * List all connections from config
215
+ */
216
+ export function listConnections() {
217
+ const connections = getConnections();
218
+ return Object.values(connections);
219
+ }
220
+ /**
221
+ * Set default connection in config
222
+ */
223
+ export function setDefaultConnection(name) {
224
+ const config = loadConfigFile();
225
+ if (!config.connections || !config.connections[name]) {
226
+ throw new Error(`Connection "${name}" not found`);
227
+ }
228
+ config.defaultConnection = name;
229
+ saveConfigFile(config);
230
+ }
231
+ /**
232
+ * Get default connection name from config
233
+ */
234
+ export function getDefaultConnectionName() {
235
+ const config = loadConfigFile();
236
+ return config.defaultConnection;
237
+ }
238
+ /**
239
+ * Get default connection from config
240
+ */
241
+ export function getDefaultConnection() {
242
+ const defaultName = getDefaultConnectionName();
243
+ if (!defaultName) {
244
+ return null;
245
+ }
246
+ return getConnection(defaultName);
247
+ }
248
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MA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IAAY;IAC/C,MAAM,MAAM,GAAG,cAAc,EAAe,CAAC;IAE7C,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,aAAa,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAChC,cAAc,CAAC,MAAM,CAAC,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB;IACtC,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,OAAO,MAAM,CAAC,iBAAiB,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,WAAW,GAAG,wBAAwB,EAAE,CAAC;IAC/C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,aAAa,CAAC,WAAW,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { ODataClient } from "./odata-client.js";
2
+ import { Connection } from "./config.js";
3
+ /**
4
+ * Connection Manager for OData clients
5
+ * Manages multiple OData client instances for different connections
6
+ */
7
+ export declare class ConnectionManager {
8
+ private clients;
9
+ private currentConnectionName?;
10
+ constructor();
11
+ /**
12
+ * Create an OData client from a connection configuration
13
+ */
14
+ private createClient;
15
+ /**
16
+ * Get or create a client for a connection
17
+ */
18
+ getClient(connectionName: string, verifySsl?: boolean, timeout?: number): ODataClient;
19
+ /**
20
+ * Create a client with inline credentials (temporary, not saved)
21
+ */
22
+ createInlineClient(connection: Connection, verifySsl?: boolean, timeout?: number): ODataClient;
23
+ /**
24
+ * Get the current active client
25
+ */
26
+ getCurrentClient(): ODataClient | null;
27
+ /**
28
+ * Get current connection name
29
+ */
30
+ getCurrentConnectionName(): string | undefined;
31
+ /**
32
+ * Set the current connection
33
+ */
34
+ setCurrentConnection(connectionName: string, verifySsl?: boolean, timeout?: number): void;
35
+ /**
36
+ * Test a connection
37
+ */
38
+ testConnection(connectionName: string): Promise<boolean>;
39
+ /**
40
+ * Clear all cached clients
41
+ */
42
+ clearClients(): void;
43
+ /**
44
+ * Remove a specific client from cache
45
+ */
46
+ removeClient(connectionName: string): void;
47
+ }
48
+ export declare const connectionManager: ConnectionManager;
49
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAuC,MAAM,aAAa,CAAC;AAG9E;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,qBAAqB,CAAC,CAAS;;IAMvC;;OAEG;IACH,OAAO,CAAC,YAAY;IAapB;;OAEG;IACH,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW;IAqBrF;;OAEG;IACH,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW;IAY9F;;OAEG;IACH,gBAAgB,IAAI,WAAW,GAAG,IAAI;IAatC;;OAEG;IACH,wBAAwB,IAAI,MAAM,GAAG,SAAS;IAI9C;;OAEG;IACH,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAWzF;;OAEG;IACG,cAAc,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAU9D;;OAEG;IACH,YAAY,IAAI,IAAI;IAMpB;;OAEG;IACH,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;CAO3C;AAGD,eAAO,MAAM,iBAAiB,mBAA0B,CAAC"}