|
| 1 | +// Type definitions for marklogic |
| 2 | +// Definitions by: GitHub Copilot |
| 3 | +// Project: https://github.com/marklogic/node-client-api |
| 4 | +// Documentation: https://docs.marklogic.com/guide/node-dev |
| 5 | + |
| 6 | +/** |
| 7 | + * MarkLogic Node.js Client API |
| 8 | + * |
| 9 | + * IMPORTANT: This library uses CommonJS exports. Import patterns: |
| 10 | + * |
| 11 | + * For TypeScript/ES Modules: |
| 12 | + * import marklogic from 'marklogic'; // Preferred |
| 13 | + * const db = marklogic.createDatabaseClient({...}); |
| 14 | + * |
| 15 | + * For CommonJS: |
| 16 | + * const marklogic = require('marklogic'); |
| 17 | + * const db = marklogic.createDatabaseClient({...}); |
| 18 | + */ |
| 19 | + |
| 20 | +declare module 'marklogic' { |
| 21 | + /** |
| 22 | + * Configuration object for creating a database client. |
| 23 | + * Used by the createDatabaseClient function to establish connection parameters. |
| 24 | + */ |
| 25 | + export interface DatabaseClientConfig { |
| 26 | + /** The host with the REST server for the database (defaults to 'localhost') */ |
| 27 | + host?: string; |
| 28 | + /** The port with the REST server for the database (defaults to 8000) */ |
| 29 | + port?: number; |
| 30 | + /** The user with permission to access the database */ |
| 31 | + user?: string; |
| 32 | + /** The password for the user with permission to access the database */ |
| 33 | + password?: string; |
| 34 | + /** The name of the database to access (defaults to the database for the REST server) */ |
| 35 | + database?: string; |
| 36 | + /** The authentication type (defaults to 'digest') */ |
| 37 | + authType?: 'basic' | 'digest' | 'application-level' | 'certificate' | 'kerberos' | 'saml' | 'cloud'; |
| 38 | + /** Whether the REST server uses SSL (defaults to false) */ |
| 39 | + ssl?: boolean; |
| 40 | + /** The trusted certificate(s), if required for SSL */ |
| 41 | + ca?: string | string[] | Buffer | Buffer[]; |
| 42 | + /** The public x509 certificate to use for SSL */ |
| 43 | + cert?: string | Buffer; |
| 44 | + /** The private key to use for SSL */ |
| 45 | + key?: string | Buffer; |
| 46 | + /** The public x509 certificate and private key as a single PKCS12 file to use for SSL */ |
| 47 | + pfx?: Buffer; |
| 48 | + /** The passphrase for the PKCS12 file or private key */ |
| 49 | + passphrase?: string; |
| 50 | + /** Whether to reject unauthorized SSL certificates (defaults to true) */ |
| 51 | + rejectUnauthorized?: boolean; |
| 52 | + /** The SAML token to use for authentication with the REST server */ |
| 53 | + token?: string; |
| 54 | + /** Connection pooling agent */ |
| 55 | + agent?: any; |
| 56 | + /** API version to use */ |
| 57 | + apiVersion?: string; |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * A database client object returned by createDatabaseClient. |
| 62 | + * Provides access to document, graph, and query operations. |
| 63 | + */ |
| 64 | + export interface DatabaseClient { |
| 65 | + // Methods will be added as we expand the type definitions |
| 66 | + // For now, this is a placeholder to enable basic typing |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Creates a DatabaseClient object for accessing a database. |
| 71 | + * @param config - Configuration for connecting to the database |
| 72 | + * @returns A DatabaseClient object for performing database operations |
| 73 | + */ |
| 74 | + export function createDatabaseClient(config: DatabaseClientConfig): DatabaseClient; |
| 75 | + |
| 76 | + const marklogic: { |
| 77 | + createDatabaseClient: typeof createDatabaseClient; |
| 78 | + }; |
| 79 | + |
| 80 | + export default marklogic; |
| 81 | +} |
0 commit comments