index.d.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { Pool as BasePool, PoolOptions } from './lib/Pool.js';
  2. import {
  3. Connection as BaseConnection,
  4. ConnectionOptions,
  5. SslOptions,
  6. } from './lib/Connection.js';
  7. import {
  8. Query as BaseQuery,
  9. QueryOptions,
  10. QueryError,
  11. } from './lib/protocol/sequences/Query.js';
  12. import {
  13. PoolCluster as BasePoolCluster,
  14. PoolClusterOptions,
  15. PoolNamespace,
  16. } from './lib/PoolCluster.js';
  17. import { PoolConnection as BasePoolConnection } from './lib/PoolConnection.js';
  18. import {
  19. Prepare as BasePrepare,
  20. PrepareStatementInfo,
  21. } from './lib/protocol/sequences/Prepare.js';
  22. import { Server } from './lib/Server.js';
  23. export {
  24. ConnectionOptions,
  25. SslOptions,
  26. PoolOptions,
  27. PoolClusterOptions,
  28. PoolNamespace,
  29. QueryOptions,
  30. QueryError,
  31. PrepareStatementInfo,
  32. };
  33. export * from './lib/protocol/packets/index.js';
  34. export * from './lib/Auth.js';
  35. export * from './lib/constants/index.js';
  36. export * from './lib/parsers/index.js';
  37. // Expose class interfaces
  38. export interface Connection extends BaseConnection {}
  39. export interface Pool extends BasePool {}
  40. export interface PoolConnection extends BasePoolConnection {}
  41. export interface PoolCluster extends BasePoolCluster {}
  42. export interface Query extends BaseQuery {}
  43. export interface Prepare extends BasePrepare {}
  44. export function createConnection(connectionUri: string): BaseConnection;
  45. export function createConnection(config: ConnectionOptions): BaseConnection;
  46. export function createPool(connectionUri: string): BasePool;
  47. export function createPool(config: PoolOptions): BasePool;
  48. export function createPoolCluster(config?: PoolClusterOptions): PoolCluster;
  49. export function escape(value: any): string;
  50. export function escapeId(value: any): string;
  51. export function format(sql: string): string;
  52. export function format(
  53. sql: string,
  54. values: any[],
  55. stringifyObjects?: boolean,
  56. timeZone?: string,
  57. ): string;
  58. export function format(
  59. sql: string,
  60. values: any,
  61. stringifyObjects?: boolean,
  62. timeZone?: string,
  63. ): string;
  64. export function raw(sql: string): {
  65. toSqlString: () => string;
  66. };
  67. export interface ConnectionConfig extends ConnectionOptions {
  68. mergeFlags(defaultFlags: string[], userFlags: string[] | string): number;
  69. getDefaultFlags(options?: ConnectionOptions): string[];
  70. getCharsetNumber(charset: string): number;
  71. getSSLProfile(name: string): { ca: string[] };
  72. parseUrl(url: string): {
  73. host: string;
  74. port: number;
  75. database: string;
  76. user: string;
  77. password: string;
  78. [key: string]: any;
  79. };
  80. }
  81. export function createServer(handler: (conn: BaseConnection) => any): Server;