@event-driven-io/dumbo 0.13.0-beta.2 → 0.13.0-beta.20
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/dist/chunk-3B24ORM3.js +34 -0
- package/dist/chunk-3B24ORM3.js.map +1 -0
- package/dist/chunk-FXETEUW2.cjs +34 -0
- package/dist/chunk-FXETEUW2.cjs.map +1 -0
- package/dist/chunk-JDP6VMRY.cjs +556 -0
- package/dist/chunk-JDP6VMRY.cjs.map +1 -0
- package/dist/{chunk-OJ34O3Q2.cjs → chunk-PYTHH6WO.cjs} +2161 -1639
- package/dist/chunk-PYTHH6WO.cjs.map +1 -0
- package/dist/chunk-SQXAAA3N.cjs +481 -0
- package/dist/chunk-SQXAAA3N.cjs.map +1 -0
- package/dist/chunk-U445U32Q.js +83 -0
- package/dist/chunk-U445U32Q.js.map +1 -0
- package/dist/{chunk-XVV3OOQX.js → chunk-USPL7TWB.js} +209 -58
- package/dist/chunk-USPL7TWB.js.map +1 -0
- package/dist/chunk-V3QUMPUM.js +481 -0
- package/dist/chunk-V3QUMPUM.js.map +1 -0
- package/dist/chunk-VIQJEUVF.cjs +83 -0
- package/dist/chunk-VIQJEUVF.cjs.map +1 -0
- package/dist/{chunk-N7RWT46K.js → chunk-ZH6YVE3B.js} +2132 -1610
- package/dist/chunk-ZH6YVE3B.js.map +1 -0
- package/dist/cloudflare.cjs +451 -0
- package/dist/cloudflare.cjs.map +1 -0
- package/dist/cloudflare.d.cts +92 -0
- package/dist/cloudflare.d.ts +92 -0
- package/dist/cloudflare.js +451 -0
- package/dist/cloudflare.js.map +1 -0
- package/dist/{columnProcessors-DMPpTPqM.d.ts → columnProcessors-BwcyMnUX.d.ts} +1 -1
- package/dist/{columnProcessors-BX-sH7ah.d.cts → columnProcessors-CO9z2XBz.d.cts} +1 -1
- package/dist/{connectionString-B1wm0TFc.d.cts → connectionString-DHJiGj2D.d.cts} +339 -129
- package/dist/{connectionString-B1wm0TFc.d.ts → connectionString-DHJiGj2D.d.ts} +339 -129
- package/dist/index.cjs +96 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -18
- package/dist/index.d.ts +23 -18
- package/dist/index.js +99 -7
- package/dist/index.js.map +1 -1
- package/dist/pg.cjs +375 -9
- package/dist/pg.cjs.map +1 -1
- package/dist/pg.d.cts +76 -104
- package/dist/pg.d.ts +76 -104
- package/dist/pg.js +427 -61
- package/dist/pg.js.map +1 -1
- package/dist/postgresql.cjs +50 -0
- package/dist/postgresql.cjs.map +1 -0
- package/dist/postgresql.d.cts +61 -0
- package/dist/postgresql.d.ts +61 -0
- package/dist/postgresql.js +50 -0
- package/dist/sqlite.cjs +56 -0
- package/dist/sqlite.cjs.map +1 -0
- package/dist/{index-C0h0c380.d.cts → sqlite.d.cts} +24 -7
- package/dist/{index-C2z_XBn6.d.ts → sqlite.d.ts} +24 -7
- package/dist/sqlite.js +56 -0
- package/dist/sqlite3.cjs +240 -11
- package/dist/sqlite3.cjs.map +1 -1
- package/dist/sqlite3.d.cts +38 -18
- package/dist/sqlite3.d.ts +38 -18
- package/dist/sqlite3.js +251 -22
- package/dist/sqlite3.js.map +1 -1
- package/package.json +69 -29
- package/dist/chunk-A7TC7IOP.cjs +0 -55
- package/dist/chunk-A7TC7IOP.cjs.map +0 -1
- package/dist/chunk-F7JQ7BX7.js +0 -240
- package/dist/chunk-F7JQ7BX7.js.map +0 -1
- package/dist/chunk-I34X53VL.js +0 -688
- package/dist/chunk-I34X53VL.js.map +0 -1
- package/dist/chunk-ISNF6USX.cjs +0 -688
- package/dist/chunk-ISNF6USX.cjs.map +0 -1
- package/dist/chunk-IYEHOE4S.cjs +0 -405
- package/dist/chunk-IYEHOE4S.cjs.map +0 -1
- package/dist/chunk-L2YZQAG3.cjs +0 -240
- package/dist/chunk-L2YZQAG3.cjs.map +0 -1
- package/dist/chunk-N7RWT46K.js.map +0 -1
- package/dist/chunk-OJ34O3Q2.cjs.map +0 -1
- package/dist/chunk-TXSETOGH.js +0 -55
- package/dist/chunk-TXSETOGH.js.map +0 -1
- package/dist/chunk-XVV3OOQX.js.map +0 -1
- package/dist/d1.cjs +0 -277
- package/dist/d1.cjs.map +0 -1
- package/dist/d1.d.cts +0 -72
- package/dist/d1.d.ts +0 -72
- package/dist/d1.js +0 -277
- package/dist/d1.js.map +0 -1
- package/dist/pg-3ACXFMU4.cjs +0 -59
- package/dist/pg-3ACXFMU4.cjs.map +0 -1
- package/dist/pg-GHOW3XSG.js +0 -59
- package/dist/sqlite3-EEIKQCJR.js +0 -25
- package/dist/sqlite3-SE4DDYZE.cjs +0 -25
- package/dist/sqlite3-SE4DDYZE.cjs.map +0 -1
- /package/dist/{pg-GHOW3XSG.js.map → postgresql.js.map} +0 -0
- /package/dist/{sqlite3-EEIKQCJR.js.map → sqlite.js.map} +0 -0
package/dist/pg.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/pg.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,6iGAAC","file":"/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/pg.cjs"}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/pg.cjs","../src/storage/postgresql/pg/connections/connection.ts","../src/storage/postgresql/pg/execute/execute.ts","../src/storage/postgresql/pg/connections/transaction.ts","../src/storage/postgresql/pg/connections/pool.ts","../src/storage/postgresql/pg/serialization/index.ts","../src/storage/postgresql/pg/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACtCA,gEAAe;ADwCf;AACA;AEzCA;AAiBO,IAAM,eAAA,EAAiB,CAC5B,YAAA,EAAA,GAC4B;AAC5B,EAAA,OAAO,aAAA,WAAwB,YAAA,CAAG,IAAA;AACpC,CAAA;AAEO,IAAM,WAAA,EAAa,CACxB,YAAA,EAAA,GAC8B,aAAA,WAAwB,YAAA,CAAG,MAAA;AAEpD,IAAM,eAAA,EAAiB,CAC5B,YAAA,EAAA,GAEA,UAAA,GAAa,aAAA,GAAgB,OAAO,YAAA,CAAa,QAAA,IAAY,UAAA;AAExD,IAAM,UAAA,EAAY,MAAA,CACvB,YAAA,EACA,MAAA,EAAA,GACG;AACH,EAAA,MAAM,OAAA,EAAS,cAAA,CAAe,YAAY,EAAA,EACtC,MAAM,YAAA,CAAa,OAAA,CAAQ,EAAA,EAC3B,YAAA;AAEJ,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,MAAA,CAAO,MAAM,CAAA;AAAA,EAC5B,EAAA,QAAE;AAEA,IAAA,GAAA,CAAI,cAAA,CAAe,YAAY,EAAA,GAAK,cAAA,CAAe,MAAM,CAAA;AACvD,MAAA,MAAA,CAAO,OAAA,CAAQ,CAAA;AAAA,EACnB;AACF,CAAA;AAIO,IAAM,cAAA,EAAgB,CAAC;AAAA,EAC5B;AACF,CAAA,EAAA,GAA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AA;AAEkD,EAAA;AACd,EAAA;AAER,EAAA;AACd,IAAA;AACA,IAAA;AACZ,IAAA;AACA,IAAA;AACD,EAAA;AACH;AAuDgE;AACvB,EAAA;AAEiB,EAAA;AAErB,EAAA;AAC+B,IAAA;AAE3B,EAAA;AACN,IAAA;AACT,MAAA;AACrB,IAAA;AAE2C,EAAA;AACkB,IAAA;AAE/B,EAAA;AAC8B,IAAA;AAE3C,EAAA;AAClB,IAAA;AACA,IAAA;AACA,IAAA;AACD,EAAA;AACH;AAE4C;AACM;AAIpC;AAE2B,EAAA;AAKA,EAAA;AAMxB,EAAA;AAKiC,EAAA;AAEb,EAAA;AAIA,EAAA;AAErC;AAEgC;AAC9B,EAAA;AACA,EAAA;AACA,EAAA;AAKmB;AAC2C,EAAA;AACd,EAAA;AAEhB,EAAA;AAC2B,EAAA;AAC1B,IAAA;AACjC,EAAA;AACF;AAEqE;AAC/D,EAAA;AACa,IAAA;AACD,EAAA;AAC+C,IAAA;AAC/D,EAAA;AACsB,EAAA;AACxB;AAGU;AACoD,EAAA;AAC5D;AAGuB;AAEiD;AAClB,EAAA;AAClB,EAAA;AAEW,EAAA;AAExC,EAAA;AACT;AJ6EoE;AACA;AMjXL;AACzD,EAAA;AACgD,IAAA;AAC5C,EAAA;AACC,IAAA;AACT,EAAA;AACF;AAMI;AACU,EAAA;AAC4C,EAAA;AAC1C,EAAA;AACU,EAAA;AACb,EAAA;AACT,IAAA;AACA,IAAA;AACF,EAAA;AACkB,EAAA;AACpB;AAEsC;AAC4B,EAAA;AAClE;AAEiB;AN4WmD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/pg.cjs","sourcesContent":[null,"import pg from 'pg';\nimport type { JSONSerializer } from '../../../../core';\nimport { createConnection, type Connection } from '../../../../core';\nimport type { PostgreSQLDriverType } from '../../core';\nimport { pgSQLExecutor } from '../execute';\nimport { pgTransaction } from './transaction';\n\nexport type PgDriverType = PostgreSQLDriverType<'pg'>;\nexport const PgDriverType: PgDriverType = 'PostgreSQL:pg';\n\nexport type PgPoolClient = pg.PoolClient;\nexport type PgClient = pg.Client;\n\nexport type PgClientOrPoolClient = PgPoolClient | PgClient;\n\nexport type PgPoolOrClient = pg.Pool | PgPoolClient | PgClient;\n\nexport type PgClientConnection = Connection<\n PgClientConnection,\n PgDriverType,\n PgClient\n>;\n\nexport type PgPoolClientConnection = Connection<\n PgPoolClientConnection,\n PgDriverType,\n PgPoolClient\n>;\n\nexport type PgConnection = PgPoolClientConnection | PgClientConnection;\n\nexport type PgPoolClientOptions = {\n type: 'PoolClient';\n connect: () => Promise<PgPoolClient>;\n close: (client: PgPoolClient) => Promise<void>;\n};\n\nexport type PgClientOptions = {\n type: 'Client';\n connect: () => Promise<PgClient>;\n close: (client: PgClient) => Promise<void>;\n};\n\nexport type PgClientConnectionOptions = PgClientOptions & {\n serializer: JSONSerializer;\n};\n\nexport type PgPoolClientConnectionOptions = PgPoolClientOptions & {\n serializer: JSONSerializer;\n};\n\nexport const pgClientConnection = (\n options: PgClientConnectionOptions,\n): PgClientConnection => {\n const { connect, close } = options;\n\n return createConnection({\n driverType: PgDriverType,\n connect,\n close,\n initTransaction: (connection) =>\n pgTransaction(connection, options.serializer),\n executor: pgSQLExecutor,\n serializer: options.serializer,\n });\n};\n\nexport const pgPoolClientConnection = (\n options: PgPoolClientConnectionOptions,\n): PgPoolClientConnection => {\n const { connect, close } = options;\n\n return createConnection({\n driverType: PgDriverType,\n connect,\n close,\n initTransaction: (connection) =>\n pgTransaction(connection, options.serializer),\n executor: pgSQLExecutor,\n serializer: options.serializer,\n });\n};\n\nexport type PgConnectionOptions =\n | PgPoolClientConnectionOptions\n | PgClientConnectionOptions;\n\nexport function pgConnection(\n options: PgPoolClientConnectionOptions,\n): PgPoolClientConnection;\nexport function pgConnection(\n options: PgClientConnectionOptions,\n): PgClientConnection;\nexport function pgConnection(\n options: PgPoolClientConnectionOptions | PgClientConnectionOptions,\n): PgPoolClientConnection | PgClientConnection {\n return options.type === 'Client'\n ? pgClientConnection(options)\n : pgPoolClientConnection(options);\n}\n\nexport type ConnectionCheckResult =\n | { successful: true }\n | {\n successful: false;\n code: string | undefined;\n errorType: 'ConnectionRefused' | 'Authentication' | 'Unknown';\n error: unknown;\n };\n\nexport const checkConnection = async (\n connectionString: string,\n): Promise<ConnectionCheckResult> => {\n const client = new pg.Client({\n connectionString,\n });\n\n try {\n await client.connect();\n return { successful: true };\n } catch (error) {\n const code =\n error instanceof Error &&\n 'code' in error &&\n typeof error.code === 'string'\n ? error.code\n : undefined;\n\n return {\n successful: false,\n errorType:\n code === 'ECONNREFUSED'\n ? 'ConnectionRefused'\n : code === '28P01'\n ? 'Authentication'\n : 'Unknown',\n code,\n error,\n };\n } finally {\n // Ensure the client is closed properly if connected\n await client.end();\n }\n};\n","import pg from 'pg';\nimport type { JSONSerializer } from '../../../../core';\nimport {\n BatchCommandNoChangesError,\n mapSQLQueryResult,\n tracer,\n type BatchSQLCommandOptions,\n type DbSQLExecutor,\n type QueryResult,\n type QueryResultRow,\n type SQL,\n type SQLQueryOptions,\n} from '../../../../core';\nimport { pgFormatter } from '../../core';\nimport { mapPostgresError } from '../../core/errors/errorMapper';\nimport { PgDriverType, type PgClientOrPoolClient } from '../connections';\n\nexport const isPgNativePool = (\n poolOrClient: pg.Pool | pg.PoolClient | pg.Client,\n): poolOrClient is pg.Pool => {\n return poolOrClient instanceof pg.Pool;\n};\n\nexport const isPgClient = (\n poolOrClient: pg.Pool | pg.PoolClient | pg.Client,\n): poolOrClient is pg.Client => poolOrClient instanceof pg.Client;\n\nexport const isPgPoolClient = (\n poolOrClient: pg.Pool | pg.PoolClient | pg.Client,\n): poolOrClient is pg.PoolClient =>\n 'release' in poolOrClient && typeof poolOrClient.release === 'function';\n\nexport const pgExecute = async <Result = void>(\n poolOrClient: pg.Pool | pg.PoolClient | pg.Client,\n handle: (client: pg.PoolClient | pg.Client) => Promise<Result>,\n) => {\n const client = isPgNativePool(poolOrClient)\n ? await poolOrClient.connect()\n : poolOrClient;\n\n try {\n return await handle(client);\n } finally {\n // release only if client wasn't injected externally\n if (isPgNativePool(poolOrClient) && isPgPoolClient(client))\n client.release();\n }\n};\n\nexport type PgSQLExecutor = DbSQLExecutor<PgDriverType, PgClientOrPoolClient>;\n\nexport const pgSQLExecutor = ({\n serializer,\n}: {\n serializer: JSONSerializer;\n}): PgSQLExecutor => ({\n driverType: PgDriverType,\n query: async <Result extends QueryResultRow = QueryResultRow>(\n client: PgClientOrPoolClient,\n sql: SQL,\n options: SQLQueryOptions | undefined,\n ) => {\n const results = await batchQuery<Result>(\n client,\n [sql],\n serializer,\n options,\n );\n return results[0]!;\n },\n batchQuery: <Result extends QueryResultRow = QueryResultRow>(\n client: PgClientOrPoolClient,\n sqls: SQL[],\n options: SQLQueryOptions | undefined,\n ) => batchQuery<Result>(client, sqls, serializer, options),\n command: async <Result extends QueryResultRow = QueryResultRow>(\n client: PgClientOrPoolClient,\n sql: SQL,\n options: BatchSQLCommandOptions | undefined,\n ) => {\n const results = await batchCommand<Result>(\n client,\n [sql],\n serializer,\n options,\n );\n return results[0]!;\n },\n batchCommand: <Result extends QueryResultRow = QueryResultRow>(\n client: PgClientOrPoolClient,\n sqls: SQL[],\n options: BatchSQLCommandOptions | undefined,\n ) => batchCommand<Result>(client, sqls, serializer, options),\n formatter: pgFormatter,\n});\n\nasync function batchQuery<Result extends QueryResultRow = QueryResultRow>(\n client: PgClientOrPoolClient,\n sqls: SQL[],\n serializer: JSONSerializer,\n options?: SQLQueryOptions,\n): Promise<QueryResult<Result>[]> {\n const results: QueryResult<Result>[] = Array<QueryResult<Result>>(\n sqls.length,\n );\n\n if (options?.timeoutMs) {\n await client.query(`SET statement_timeout = ${options.timeoutMs}`);\n }\n\n //TODO: make it smarter at some point\n for (let i = 0; i < sqls.length; i++) {\n const { query, params } = pgFormatter.format(sqls[i]!, { serializer });\n tracer.info('db:sql:query', {\n query,\n params,\n debugSQL: pgFormatter.describe(sqls[i]!, { serializer }),\n });\n try {\n let result =\n params.length > 0\n ? await client.query<Result>(query, params)\n : await client.query<Result>(query);\n\n if (options?.mapping) {\n result = {\n ...result,\n rows: result.rows.map((row) =>\n mapSQLQueryResult(row, options.mapping!),\n ),\n };\n }\n\n results[i] = { rowCount: result.rowCount, rows: result.rows };\n } catch (error) {\n tracer.error('db:sql:batch_query:execute:error', { error });\n throw mapPostgresError(error);\n }\n }\n\n return results;\n}\n\nasync function batchCommand<Result extends QueryResultRow = QueryResultRow>(\n client: PgClientOrPoolClient,\n sqls: SQL[],\n serializer: JSONSerializer,\n options?: BatchSQLCommandOptions,\n): Promise<QueryResult<Result>[]> {\n const results: QueryResult<Result>[] = Array<QueryResult<Result>>(\n sqls.length,\n );\n\n if (options?.timeoutMs) {\n await client.query(`SET statement_timeout = ${options.timeoutMs}`);\n }\n\n //TODO: make it smarter at some point\n for (let i = 0; i < sqls.length; i++) {\n const { query, params } = pgFormatter.format(sqls[i]!, { serializer });\n tracer.info('db:sql:command', {\n query,\n params,\n debugSQL: pgFormatter.describe(sqls[i]!, { serializer }),\n });\n try {\n let result =\n params.length > 0\n ? await client.query<Result>(query, params)\n : await client.query<Result>(query);\n\n if (options?.mapping) {\n result = {\n ...result,\n rows: result.rows.map((row) =>\n mapSQLQueryResult(row, options.mapping!),\n ),\n };\n }\n\n results[i] = { rowCount: result.rowCount, rows: result.rows };\n\n if (options?.assertChanges && (results[i]!.rowCount ?? 0) === 0) {\n throw new BatchCommandNoChangesError(i);\n }\n } catch (error) {\n tracer.error('db:sql:batch_command:execute:error', { error });\n throw mapPostgresError(error);\n }\n }\n\n return results;\n}\n","import type { JSONSerializer } from '../../../../core';\nimport {\n sqlExecutor,\n type AnyConnection,\n type DatabaseTransaction,\n type DatabaseTransactionOptions,\n} from '../../../../core';\nimport { pgSQLExecutor } from '../execute';\nimport {\n PgDriverType,\n type PgConnection,\n type PgPoolOrClient,\n} from './connection';\n\nexport type PgTransaction = DatabaseTransaction<PgConnection>;\n\nexport const pgTransaction =\n <ConnectionType extends AnyConnection = AnyConnection>(\n connection: () => ConnectionType,\n serializer: JSONSerializer,\n ) =>\n <DbClient extends PgPoolOrClient = PgPoolOrClient>(\n getClient: Promise<DbClient>,\n options?: {\n close: (client: DbClient, error?: unknown) => Promise<void>;\n } & DatabaseTransactionOptions,\n ): DatabaseTransaction<ConnectionType> => ({\n connection: connection(),\n driverType: PgDriverType,\n begin: async () => {\n const client = await getClient;\n await client.query('BEGIN');\n },\n commit: async () => {\n const client = await getClient;\n\n try {\n await client.query('COMMIT');\n } finally {\n if (options?.close) await options?.close(client);\n }\n },\n rollback: async (error?: unknown) => {\n const client = await getClient;\n try {\n await client.query('ROLLBACK');\n } finally {\n if (options?.close) await options?.close(client, error);\n }\n },\n execute: sqlExecutor(pgSQLExecutor({ serializer }), {\n connect: () => getClient,\n }),\n });\n","import pg from 'pg';\nimport {\n createAmbientConnectionPool,\n createConnectionPool,\n JSONSerializer,\n tracer,\n type ConnectionPool,\n type JSONSerializationOptions,\n} from '../../../../core';\nimport { defaultPostgreSqlDatabase, parseDatabaseName } from '../../core';\nimport { setPgTypeParser } from '../serialization';\nimport {\n pgConnection,\n PgDriverType,\n type PgClientConnection,\n type PgPoolClientConnection,\n} from './connection';\n\nexport type PgNativePool = ConnectionPool<PgPoolClientConnection>;\n\nexport type PgAmbientClientPool = ConnectionPool<PgClientConnection>;\n\nexport type PgAmbientConnectionPool = ConnectionPool<\n PgPoolClientConnection | PgClientConnection\n>;\n\nexport type PgPool =\n | PgNativePool\n | PgAmbientClientPool\n | PgAmbientConnectionPool;\n\nexport const pgNativePool = (options: {\n connectionString: string;\n database?: string | undefined;\n serializer: JSONSerializer;\n}): PgNativePool => {\n const { connectionString, database } = options;\n const pool = getPgPool({ connectionString, database });\n\n const getConnection = () =>\n pgConnection({\n type: 'PoolClient',\n connect: async () => {\n const client = await pool.connect();\n\n setPgTypeParser(client, {\n parseBigInts: true,\n serializer: options.serializer,\n });\n\n return client;\n },\n close: (client) => Promise.resolve(client.release()),\n serializer: options.serializer,\n });\n\n const open = () => Promise.resolve(getConnection());\n const close = () => endPgPool({ connectionString, database });\n\n return createConnectionPool({\n driverType: PgDriverType,\n connection: open,\n close,\n getConnection,\n });\n};\n\nexport const pgAmbientNativePool = (options: {\n pool: pg.Pool;\n serializer: JSONSerializer;\n}): PgNativePool => {\n const { pool } = options;\n\n return createConnectionPool({\n driverType: PgDriverType,\n getConnection: () =>\n pgConnection({\n type: 'PoolClient',\n connect: () => pool.connect(),\n close: (client) => Promise.resolve(client.release()),\n serializer: options.serializer,\n }),\n });\n};\n\nexport const pgAmbientConnectionPool = (options: {\n connection: PgPoolClientConnection | PgClientConnection;\n}): PgAmbientConnectionPool => {\n const { connection } = options;\n\n return createAmbientConnectionPool({\n driverType: PgDriverType,\n connection,\n });\n};\n\nexport const pgClientPool = (options: {\n connectionString: string;\n database?: string | undefined;\n serializer: JSONSerializer;\n}): PgAmbientClientPool => {\n const { connectionString, database } = options;\n\n return createConnectionPool({\n driverType: PgDriverType,\n getConnection: () => {\n const connect = async () => {\n const client = new pg.Client({ connectionString, database });\n\n setPgTypeParser(client, {\n parseBigInts: true,\n serializer: options.serializer,\n });\n\n await client.connect();\n return client;\n };\n\n return pgConnection({\n type: 'Client',\n connect,\n close: (client) => client.end(),\n serializer: options.serializer,\n });\n },\n });\n};\n\nexport const pgAmbientClientPool = (options: {\n client: pg.Client;\n serializer: JSONSerializer;\n}): PgAmbientClientPool => {\n const { client } = options;\n\n const getConnection = () => {\n const connect = () => Promise.resolve(client);\n\n return pgConnection({\n type: 'Client',\n connect,\n close: () => Promise.resolve(),\n serializer: options.serializer,\n });\n };\n\n const open = () => Promise.resolve(getConnection());\n const close = () => Promise.resolve();\n\n return createConnectionPool({\n driverType: PgDriverType,\n connection: open,\n close,\n getConnection,\n });\n};\n\nexport type PgPoolPooledOptions =\n | {\n connectionString: string;\n database?: string;\n pooled: true;\n pool: pg.Pool;\n }\n | {\n connectionString: string;\n database?: string;\n pool: pg.Pool;\n }\n | {\n connectionString: string;\n database?: string;\n pooled: true;\n }\n | {\n connectionString: string;\n database?: string;\n };\n\nexport type PgPoolNotPooledOptions =\n | {\n connectionString: string;\n database?: string;\n pooled: false;\n client: pg.Client;\n }\n | {\n connectionString: string;\n database?: string;\n client: pg.Client;\n }\n | {\n connectionString: string;\n database?: string;\n pooled: false;\n }\n | {\n connectionString: string;\n database?: string;\n connection: PgPoolClientConnection | PgClientConnection;\n pooled?: false;\n };\n\nexport type PgPoolOptions = (PgPoolPooledOptions | PgPoolNotPooledOptions) &\n JSONSerializationOptions;\n\nexport function pgPool(options: PgPoolPooledOptions): PgNativePool;\nexport function pgPool(options: PgPoolNotPooledOptions): PgAmbientClientPool;\nexport function pgPool(\n options: PgPoolOptions,\n): PgNativePool | PgAmbientClientPool | PgAmbientConnectionPool {\n const { connectionString, database } = options;\n\n const serializer = options.serialization?.serializer ?? JSONSerializer;\n\n if ('client' in options && options.client)\n return pgAmbientClientPool({ client: options.client, serializer });\n\n if ('connection' in options && options.connection)\n return pgAmbientConnectionPool({\n connection: options.connection,\n });\n\n if ('pooled' in options && options.pooled === false)\n return pgClientPool({ connectionString, database, serializer });\n\n if ('pool' in options && options.pool)\n return pgAmbientNativePool({ pool: options.pool, serializer });\n\n return pgNativePool({\n connectionString,\n database,\n serializer,\n });\n}\n\nconst pools: Map<string, pg.Pool> = new Map();\nconst usageCounter: Map<string, number> = new Map();\n\nexport const getPgPool = (\n connectionStringOrOptions: string | pg.PoolConfig,\n): pg.Pool => {\n const connectionString =\n typeof connectionStringOrOptions === 'string'\n ? connectionStringOrOptions\n : connectionStringOrOptions.connectionString!;\n\n const poolOptions =\n typeof connectionStringOrOptions === 'string'\n ? { connectionString }\n : connectionStringOrOptions;\n\n const database =\n poolOptions.database ??\n (poolOptions.connectionString\n ? (parseDatabaseName(poolOptions.connectionString) ??\n defaultPostgreSqlDatabase)\n : undefined);\n\n const lookupKey = key(connectionString, database);\n\n updatePoolUsageCounter(lookupKey, 1);\n\n return (\n pools.get(lookupKey) ??\n pools.set(lookupKey, new pg.Pool(poolOptions)).get(lookupKey)!\n );\n};\n\nexport const endPgPool = async ({\n connectionString,\n database,\n force,\n}: {\n connectionString: string;\n database?: string | undefined;\n force?: boolean;\n}): Promise<void> => {\n database = database ?? parseDatabaseName(connectionString) ?? undefined;\n const lookupKey = key(connectionString, database);\n\n const pool = pools.get(lookupKey);\n if (pool && (updatePoolUsageCounter(lookupKey, -1) <= 0 || force === true)) {\n await onEndPool(lookupKey, pool);\n }\n};\n\nexport const onEndPool = async (lookupKey: string, pool: pg.Pool) => {\n try {\n await pool.end();\n } catch (error) {\n tracer.error('connection-closing-error', { lookupKey, error });\n }\n pools.delete(lookupKey);\n};\n\nexport const endAllPgPools = () =>\n Promise.all(\n [...pools.entries()].map(([lookupKey, pool]) => onEndPool(lookupKey, pool)),\n );\n\nconst key = (connectionString: string, database: string | undefined) =>\n `${connectionString}|${database ?? defaultPostgreSqlDatabase}`;\n\nconst updatePoolUsageCounter = (lookupKey: string, by: 1 | -1): number => {\n const currentCounter = usageCounter.get(lookupKey) ?? 0;\n const newCounter = currentCounter + by;\n\n usageCounter.set(lookupKey, currentCounter + by);\n\n return newCounter;\n};\n","import type pg from 'pg';\nimport type { JSONSerializer } from '../../../../core/serializer';\n\nexport const setPgTypeParser = (\n client: pg.Client | pg.PoolClient,\n options?: {\n parseBigInts?: boolean;\n serializer: JSONSerializer;\n },\n) => {\n // BigInt\n if (options?.parseBigInts === true)\n client.setTypeParser(20, (val) => BigInt(val));\n\n if (options?.serializer) {\n // JSONB\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n client.setTypeParser(3802, (val) => options.serializer.deserialize(val));\n\n // JSON\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n client.setTypeParser(114, (val) => options.serializer.deserialize(val));\n }\n};\n","import {\n canHandleDriverWithConnectionString,\n type DumboDatabaseDriver,\n dumboDatabaseDriverRegistry,\n} from '../../../core';\nimport {\n DefaultPostgreSQLMigratorOptions,\n pgFormatter,\n PostgreSQLConnectionString,\n postgreSQLMetadata,\n} from '../core';\nimport {\n type PgConnection,\n PgDriverType,\n pgPool,\n type PgPool,\n type PgPoolOptions,\n} from './connections';\n\nconst tryParseConnectionString = (connectionString: string) => {\n try {\n return PostgreSQLConnectionString(connectionString);\n } catch {\n return null;\n }\n};\n\nexport const pgDumboDriver: DumboDatabaseDriver<\n PgConnection,\n PgPoolOptions,\n PgPool\n> = {\n driverType: PgDriverType,\n createPool: (options) => pgPool(options as PgPoolOptions),\n sqlFormatter: pgFormatter,\n defaultMigratorOptions: DefaultPostgreSQLMigratorOptions,\n canHandle: canHandleDriverWithConnectionString(\n PgDriverType,\n tryParseConnectionString,\n ),\n databaseMetadata: postgreSQLMetadata,\n};\n\nexport const usePgDumboDriver = () => {\n dumboDatabaseDriverRegistry.register(PgDriverType, pgDumboDriver);\n};\n\nusePgDumboDriver();\n\nexport type PgDumboOptions = PgPoolOptions;\nexport * from './connections';\nexport * from './execute';\nexport * from './serialization';\n"]}
|
package/dist/pg.d.cts
CHANGED
|
@@ -1,68 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PostgreSQLDriverType } from './postgresql.cjs';
|
|
2
|
+
export { AdvisoryLock, DefaultPostgreSQLMigratorOptions, PostgreSQLArrayProcessor, PostgreSQLConnectionString, PostgreSQLDatabaseName, PostgreSQLExpandSQLInProcessor, acquireAdvisoryLock, advisoryLock, defaultPostgreSQLConnectionString, defaultPostgreSqlDatabase, functionExists, functionExistsSQL, mapPostgresError, parseDatabaseName, pgFormatter, postgreSQLColumnProcessors, postgreSQLMetadata, releaseAdvisoryLock, tableExists, tableExistsSQL, tryAcquireAdvisoryLock } from './postgresql.cjs';
|
|
3
|
+
import { C as Connection, J as JSONSerializer, h as ConnectionPool, i as JSONSerializationOptions, j as DatabaseTransaction, A as AnyConnection, c as DatabaseTransactionOptions, k as DbSQLExecutor, d as DumboDatabaseDriver } from './connectionString-DHJiGj2D.cjs';
|
|
2
4
|
import pg from 'pg';
|
|
3
|
-
import
|
|
5
|
+
import './columnProcessors-CO9z2XBz.cjs';
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
declare const
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
acquire: (acquireOptions?: {
|
|
16
|
-
mode: AcquireDatabaseLockMode;
|
|
17
|
-
}) => Promise<void>;
|
|
18
|
-
tryAcquire: (acquireOptions?: {
|
|
19
|
-
mode: AcquireDatabaseLockMode;
|
|
20
|
-
}) => Promise<boolean>;
|
|
21
|
-
release: () => Promise<boolean>;
|
|
22
|
-
withAcquire: <Result>(handle: () => Promise<Result>, acquireOptions?: {
|
|
23
|
-
mode: AcquireDatabaseLockMode;
|
|
24
|
-
}) => Promise<Result>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
declare const DefaultPostgreSQLMigratorOptions: MigratorOptions;
|
|
28
|
-
|
|
29
|
-
declare const defaultPostgreSqlDatabase = "postgres";
|
|
30
|
-
declare const tableExistsSQL: (tableName: string) => SQL;
|
|
31
|
-
declare const tableExists: (pool: ConnectionPool, tableName: string) => Promise<boolean>;
|
|
32
|
-
declare const functionExistsSQL: (functionName: string) => SQL;
|
|
33
|
-
declare const functionExists: (pool: ConnectionPool, tableName: string) => Promise<boolean>;
|
|
34
|
-
|
|
35
|
-
declare const pgFormatter: SQLFormatter;
|
|
36
|
-
|
|
37
|
-
declare const postgreSQLColumnProcessors: DefaultSQLColumnProcessors;
|
|
38
|
-
|
|
39
|
-
type PostgreSQLDatabaseName = 'PostgreSQL';
|
|
40
|
-
declare const PostgreSQLDatabaseName = "PostgreSQL";
|
|
41
|
-
type PostgreSQLDriverType<DriverName extends string = string> = DatabaseDriverType<PostgreSQLDatabaseName, DriverName>;
|
|
42
|
-
|
|
43
|
-
type NodePostgresDriverType = PostgreSQLDriverType<'pg'>;
|
|
44
|
-
declare const NodePostgresDriverType: NodePostgresDriverType;
|
|
45
|
-
type NodePostgresPoolClient = pg.PoolClient;
|
|
46
|
-
type NodePostgresClient = pg.Client;
|
|
47
|
-
type NodePostgresClientOrPoolClient = NodePostgresPoolClient | NodePostgresClient;
|
|
48
|
-
type NodePostgresPoolOrClient = pg.Pool | NodePostgresPoolClient | NodePostgresClient;
|
|
49
|
-
type NodePostgresClientConnection = Connection<NodePostgresClientConnection, NodePostgresDriverType, NodePostgresClient>;
|
|
50
|
-
type NodePostgresPoolClientConnection = Connection<NodePostgresPoolClientConnection, NodePostgresDriverType, NodePostgresPoolClient>;
|
|
51
|
-
type NodePostgresConnection = NodePostgresPoolClientConnection | NodePostgresClientConnection;
|
|
52
|
-
type NodePostgresPoolClientOptions = {
|
|
7
|
+
type PgDriverType = PostgreSQLDriverType<'pg'>;
|
|
8
|
+
declare const PgDriverType: PgDriverType;
|
|
9
|
+
type PgPoolClient = pg.PoolClient;
|
|
10
|
+
type PgClient = pg.Client;
|
|
11
|
+
type PgClientOrPoolClient = PgPoolClient | PgClient;
|
|
12
|
+
type PgPoolOrClient = pg.Pool | PgPoolClient | PgClient;
|
|
13
|
+
type PgClientConnection = Connection<PgClientConnection, PgDriverType, PgClient>;
|
|
14
|
+
type PgPoolClientConnection = Connection<PgPoolClientConnection, PgDriverType, PgPoolClient>;
|
|
15
|
+
type PgConnection = PgPoolClientConnection | PgClientConnection;
|
|
16
|
+
type PgPoolClientOptions = {
|
|
53
17
|
type: 'PoolClient';
|
|
54
|
-
connect: () => Promise<
|
|
55
|
-
close: (client:
|
|
18
|
+
connect: () => Promise<PgPoolClient>;
|
|
19
|
+
close: (client: PgPoolClient) => Promise<void>;
|
|
56
20
|
};
|
|
57
|
-
type
|
|
21
|
+
type PgClientOptions = {
|
|
58
22
|
type: 'Client';
|
|
59
|
-
connect: () => Promise<
|
|
60
|
-
close: (client:
|
|
23
|
+
connect: () => Promise<PgClient>;
|
|
24
|
+
close: (client: PgClient) => Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
type PgClientConnectionOptions = PgClientOptions & {
|
|
27
|
+
serializer: JSONSerializer;
|
|
61
28
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
declare
|
|
29
|
+
type PgPoolClientConnectionOptions = PgPoolClientOptions & {
|
|
30
|
+
serializer: JSONSerializer;
|
|
31
|
+
};
|
|
32
|
+
declare const pgClientConnection: (options: PgClientConnectionOptions) => PgClientConnection;
|
|
33
|
+
declare const pgPoolClientConnection: (options: PgPoolClientConnectionOptions) => PgPoolClientConnection;
|
|
34
|
+
type PgConnectionOptions = PgPoolClientConnectionOptions | PgClientConnectionOptions;
|
|
35
|
+
declare function pgConnection(options: PgPoolClientConnectionOptions): PgPoolClientConnection;
|
|
36
|
+
declare function pgConnection(options: PgClientConnectionOptions): PgClientConnection;
|
|
66
37
|
type ConnectionCheckResult = {
|
|
67
38
|
successful: true;
|
|
68
39
|
} | {
|
|
@@ -73,28 +44,32 @@ type ConnectionCheckResult = {
|
|
|
73
44
|
};
|
|
74
45
|
declare const checkConnection: (connectionString: string) => Promise<ConnectionCheckResult>;
|
|
75
46
|
|
|
76
|
-
type
|
|
77
|
-
type
|
|
78
|
-
type
|
|
79
|
-
type
|
|
80
|
-
declare const
|
|
47
|
+
type PgNativePool = ConnectionPool<PgPoolClientConnection>;
|
|
48
|
+
type PgAmbientClientPool = ConnectionPool<PgClientConnection>;
|
|
49
|
+
type PgAmbientConnectionPool = ConnectionPool<PgPoolClientConnection | PgClientConnection>;
|
|
50
|
+
type PgPool = PgNativePool | PgAmbientClientPool | PgAmbientConnectionPool;
|
|
51
|
+
declare const pgNativePool: (options: {
|
|
81
52
|
connectionString: string;
|
|
82
53
|
database?: string | undefined;
|
|
83
|
-
|
|
84
|
-
|
|
54
|
+
serializer: JSONSerializer;
|
|
55
|
+
}) => PgNativePool;
|
|
56
|
+
declare const pgAmbientNativePool: (options: {
|
|
85
57
|
pool: pg.Pool;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
58
|
+
serializer: JSONSerializer;
|
|
59
|
+
}) => PgNativePool;
|
|
60
|
+
declare const pgAmbientConnectionPool: (options: {
|
|
61
|
+
connection: PgPoolClientConnection | PgClientConnection;
|
|
62
|
+
}) => PgAmbientConnectionPool;
|
|
63
|
+
declare const pgClientPool: (options: {
|
|
91
64
|
connectionString: string;
|
|
92
65
|
database?: string | undefined;
|
|
93
|
-
|
|
94
|
-
|
|
66
|
+
serializer: JSONSerializer;
|
|
67
|
+
}) => PgAmbientClientPool;
|
|
68
|
+
declare const pgAmbientClientPool: (options: {
|
|
95
69
|
client: pg.Client;
|
|
96
|
-
|
|
97
|
-
|
|
70
|
+
serializer: JSONSerializer;
|
|
71
|
+
}) => PgAmbientClientPool;
|
|
72
|
+
type PgPoolPooledOptions = {
|
|
98
73
|
connectionString: string;
|
|
99
74
|
database?: string;
|
|
100
75
|
pooled: true;
|
|
@@ -111,7 +86,7 @@ type NodePostgresPoolPooledOptions = {
|
|
|
111
86
|
connectionString: string;
|
|
112
87
|
database?: string;
|
|
113
88
|
};
|
|
114
|
-
type
|
|
89
|
+
type PgPoolNotPooledOptions = {
|
|
115
90
|
connectionString: string;
|
|
116
91
|
database?: string;
|
|
117
92
|
pooled: false;
|
|
@@ -127,45 +102,42 @@ type NodePostgresPoolNotPooledOptions = {
|
|
|
127
102
|
} | {
|
|
128
103
|
connectionString: string;
|
|
129
104
|
database?: string;
|
|
130
|
-
connection:
|
|
105
|
+
connection: PgPoolClientConnection | PgClientConnection;
|
|
131
106
|
pooled?: false;
|
|
132
107
|
};
|
|
133
|
-
type
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
declare
|
|
137
|
-
declare
|
|
138
|
-
declare const getPool: (connectionStringOrOptions: string | pg.PoolConfig) => pg.Pool;
|
|
139
|
-
declare const endPool: ({ connectionString, database, force, }: {
|
|
108
|
+
type PgPoolOptions = (PgPoolPooledOptions | PgPoolNotPooledOptions) & JSONSerializationOptions;
|
|
109
|
+
declare function pgPool(options: PgPoolPooledOptions): PgNativePool;
|
|
110
|
+
declare function pgPool(options: PgPoolNotPooledOptions): PgAmbientClientPool;
|
|
111
|
+
declare const getPgPool: (connectionStringOrOptions: string | pg.PoolConfig) => pg.Pool;
|
|
112
|
+
declare const endPgPool: ({ connectionString, database, force, }: {
|
|
140
113
|
connectionString: string;
|
|
141
114
|
database?: string | undefined;
|
|
142
115
|
force?: boolean;
|
|
143
116
|
}) => Promise<void>;
|
|
144
117
|
declare const onEndPool: (lookupKey: string, pool: pg.Pool) => Promise<void>;
|
|
145
|
-
declare const
|
|
118
|
+
declare const endAllPgPools: () => Promise<void[]>;
|
|
146
119
|
|
|
147
|
-
type
|
|
148
|
-
declare const
|
|
120
|
+
type PgTransaction = DatabaseTransaction<PgConnection>;
|
|
121
|
+
declare const pgTransaction: <ConnectionType extends AnyConnection = AnyConnection>(connection: () => ConnectionType, serializer: JSONSerializer) => <DbClient extends PgPoolOrClient = PgPoolOrClient>(getClient: Promise<DbClient>, options?: {
|
|
149
122
|
close: (client: DbClient, error?: unknown) => Promise<void>;
|
|
150
123
|
} & DatabaseTransactionOptions) => DatabaseTransaction<ConnectionType>;
|
|
151
124
|
|
|
152
|
-
declare const
|
|
153
|
-
declare const
|
|
154
|
-
declare const
|
|
155
|
-
declare const
|
|
156
|
-
type
|
|
157
|
-
declare const
|
|
158
|
-
|
|
159
|
-
|
|
125
|
+
declare const isPgNativePool: (poolOrClient: pg.Pool | pg.PoolClient | pg.Client) => poolOrClient is pg.Pool;
|
|
126
|
+
declare const isPgClient: (poolOrClient: pg.Pool | pg.PoolClient | pg.Client) => poolOrClient is pg.Client;
|
|
127
|
+
declare const isPgPoolClient: (poolOrClient: pg.Pool | pg.PoolClient | pg.Client) => poolOrClient is pg.PoolClient;
|
|
128
|
+
declare const pgExecute: <Result = void>(poolOrClient: pg.Pool | pg.PoolClient | pg.Client, handle: (client: pg.PoolClient | pg.Client) => Promise<Result>) => Promise<Result>;
|
|
129
|
+
type PgSQLExecutor = DbSQLExecutor<PgDriverType, PgClientOrPoolClient>;
|
|
130
|
+
declare const pgSQLExecutor: ({ serializer, }: {
|
|
131
|
+
serializer: JSONSerializer;
|
|
132
|
+
}) => PgSQLExecutor;
|
|
160
133
|
|
|
161
|
-
declare const
|
|
162
|
-
|
|
134
|
+
declare const setPgTypeParser: (client: pg.Client | pg.PoolClient, options?: {
|
|
135
|
+
parseBigInts?: boolean;
|
|
136
|
+
serializer: JSONSerializer;
|
|
137
|
+
}) => void;
|
|
163
138
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
type
|
|
167
|
-
type PostgresPoolOptions = NodePostgresPoolOptions;
|
|
168
|
-
declare const postgresPool: typeof nodePostgresPool;
|
|
169
|
-
declare const connectionPool: typeof nodePostgresPool;
|
|
139
|
+
declare const pgDumboDriver: DumboDatabaseDriver<PgConnection, PgPoolOptions, PgPool>;
|
|
140
|
+
declare const usePgDumboDriver: () => void;
|
|
141
|
+
type PgDumboOptions = PgPoolOptions;
|
|
170
142
|
|
|
171
|
-
export {
|
|
143
|
+
export { type ConnectionCheckResult, type PgAmbientClientPool, type PgAmbientConnectionPool, type PgClient, type PgClientConnection, type PgClientConnectionOptions, type PgClientOptions, type PgClientOrPoolClient, type PgConnection, type PgConnectionOptions, PgDriverType, type PgDumboOptions, type PgNativePool, type PgPool, type PgPoolClient, type PgPoolClientConnection, type PgPoolClientConnectionOptions, type PgPoolClientOptions, type PgPoolNotPooledOptions, type PgPoolOptions, type PgPoolOrClient, type PgPoolPooledOptions, type PgSQLExecutor, type PgTransaction, PostgreSQLDriverType, checkConnection, endAllPgPools, endPgPool, getPgPool, isPgClient, isPgNativePool, isPgPoolClient, onEndPool, pgAmbientClientPool, pgAmbientConnectionPool, pgAmbientNativePool, pgClientConnection, pgClientPool, pgConnection, pgDumboDriver, pgExecute, pgNativePool, pgPool, pgPoolClientConnection, pgSQLExecutor, pgTransaction, setPgTypeParser, usePgDumboDriver };
|
package/dist/pg.d.ts
CHANGED
|
@@ -1,68 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PostgreSQLDriverType } from './postgresql.js';
|
|
2
|
+
export { AdvisoryLock, DefaultPostgreSQLMigratorOptions, PostgreSQLArrayProcessor, PostgreSQLConnectionString, PostgreSQLDatabaseName, PostgreSQLExpandSQLInProcessor, acquireAdvisoryLock, advisoryLock, defaultPostgreSQLConnectionString, defaultPostgreSqlDatabase, functionExists, functionExistsSQL, mapPostgresError, parseDatabaseName, pgFormatter, postgreSQLColumnProcessors, postgreSQLMetadata, releaseAdvisoryLock, tableExists, tableExistsSQL, tryAcquireAdvisoryLock } from './postgresql.js';
|
|
3
|
+
import { C as Connection, J as JSONSerializer, h as ConnectionPool, i as JSONSerializationOptions, j as DatabaseTransaction, A as AnyConnection, c as DatabaseTransactionOptions, k as DbSQLExecutor, d as DumboDatabaseDriver } from './connectionString-DHJiGj2D.js';
|
|
2
4
|
import pg from 'pg';
|
|
3
|
-
import
|
|
5
|
+
import './columnProcessors-BwcyMnUX.js';
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
declare const
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
acquire: (acquireOptions?: {
|
|
16
|
-
mode: AcquireDatabaseLockMode;
|
|
17
|
-
}) => Promise<void>;
|
|
18
|
-
tryAcquire: (acquireOptions?: {
|
|
19
|
-
mode: AcquireDatabaseLockMode;
|
|
20
|
-
}) => Promise<boolean>;
|
|
21
|
-
release: () => Promise<boolean>;
|
|
22
|
-
withAcquire: <Result>(handle: () => Promise<Result>, acquireOptions?: {
|
|
23
|
-
mode: AcquireDatabaseLockMode;
|
|
24
|
-
}) => Promise<Result>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
declare const DefaultPostgreSQLMigratorOptions: MigratorOptions;
|
|
28
|
-
|
|
29
|
-
declare const defaultPostgreSqlDatabase = "postgres";
|
|
30
|
-
declare const tableExistsSQL: (tableName: string) => SQL;
|
|
31
|
-
declare const tableExists: (pool: ConnectionPool, tableName: string) => Promise<boolean>;
|
|
32
|
-
declare const functionExistsSQL: (functionName: string) => SQL;
|
|
33
|
-
declare const functionExists: (pool: ConnectionPool, tableName: string) => Promise<boolean>;
|
|
34
|
-
|
|
35
|
-
declare const pgFormatter: SQLFormatter;
|
|
36
|
-
|
|
37
|
-
declare const postgreSQLColumnProcessors: DefaultSQLColumnProcessors;
|
|
38
|
-
|
|
39
|
-
type PostgreSQLDatabaseName = 'PostgreSQL';
|
|
40
|
-
declare const PostgreSQLDatabaseName = "PostgreSQL";
|
|
41
|
-
type PostgreSQLDriverType<DriverName extends string = string> = DatabaseDriverType<PostgreSQLDatabaseName, DriverName>;
|
|
42
|
-
|
|
43
|
-
type NodePostgresDriverType = PostgreSQLDriverType<'pg'>;
|
|
44
|
-
declare const NodePostgresDriverType: NodePostgresDriverType;
|
|
45
|
-
type NodePostgresPoolClient = pg.PoolClient;
|
|
46
|
-
type NodePostgresClient = pg.Client;
|
|
47
|
-
type NodePostgresClientOrPoolClient = NodePostgresPoolClient | NodePostgresClient;
|
|
48
|
-
type NodePostgresPoolOrClient = pg.Pool | NodePostgresPoolClient | NodePostgresClient;
|
|
49
|
-
type NodePostgresClientConnection = Connection<NodePostgresClientConnection, NodePostgresDriverType, NodePostgresClient>;
|
|
50
|
-
type NodePostgresPoolClientConnection = Connection<NodePostgresPoolClientConnection, NodePostgresDriverType, NodePostgresPoolClient>;
|
|
51
|
-
type NodePostgresConnection = NodePostgresPoolClientConnection | NodePostgresClientConnection;
|
|
52
|
-
type NodePostgresPoolClientOptions = {
|
|
7
|
+
type PgDriverType = PostgreSQLDriverType<'pg'>;
|
|
8
|
+
declare const PgDriverType: PgDriverType;
|
|
9
|
+
type PgPoolClient = pg.PoolClient;
|
|
10
|
+
type PgClient = pg.Client;
|
|
11
|
+
type PgClientOrPoolClient = PgPoolClient | PgClient;
|
|
12
|
+
type PgPoolOrClient = pg.Pool | PgPoolClient | PgClient;
|
|
13
|
+
type PgClientConnection = Connection<PgClientConnection, PgDriverType, PgClient>;
|
|
14
|
+
type PgPoolClientConnection = Connection<PgPoolClientConnection, PgDriverType, PgPoolClient>;
|
|
15
|
+
type PgConnection = PgPoolClientConnection | PgClientConnection;
|
|
16
|
+
type PgPoolClientOptions = {
|
|
53
17
|
type: 'PoolClient';
|
|
54
|
-
connect: () => Promise<
|
|
55
|
-
close: (client:
|
|
18
|
+
connect: () => Promise<PgPoolClient>;
|
|
19
|
+
close: (client: PgPoolClient) => Promise<void>;
|
|
56
20
|
};
|
|
57
|
-
type
|
|
21
|
+
type PgClientOptions = {
|
|
58
22
|
type: 'Client';
|
|
59
|
-
connect: () => Promise<
|
|
60
|
-
close: (client:
|
|
23
|
+
connect: () => Promise<PgClient>;
|
|
24
|
+
close: (client: PgClient) => Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
type PgClientConnectionOptions = PgClientOptions & {
|
|
27
|
+
serializer: JSONSerializer;
|
|
61
28
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
declare
|
|
29
|
+
type PgPoolClientConnectionOptions = PgPoolClientOptions & {
|
|
30
|
+
serializer: JSONSerializer;
|
|
31
|
+
};
|
|
32
|
+
declare const pgClientConnection: (options: PgClientConnectionOptions) => PgClientConnection;
|
|
33
|
+
declare const pgPoolClientConnection: (options: PgPoolClientConnectionOptions) => PgPoolClientConnection;
|
|
34
|
+
type PgConnectionOptions = PgPoolClientConnectionOptions | PgClientConnectionOptions;
|
|
35
|
+
declare function pgConnection(options: PgPoolClientConnectionOptions): PgPoolClientConnection;
|
|
36
|
+
declare function pgConnection(options: PgClientConnectionOptions): PgClientConnection;
|
|
66
37
|
type ConnectionCheckResult = {
|
|
67
38
|
successful: true;
|
|
68
39
|
} | {
|
|
@@ -73,28 +44,32 @@ type ConnectionCheckResult = {
|
|
|
73
44
|
};
|
|
74
45
|
declare const checkConnection: (connectionString: string) => Promise<ConnectionCheckResult>;
|
|
75
46
|
|
|
76
|
-
type
|
|
77
|
-
type
|
|
78
|
-
type
|
|
79
|
-
type
|
|
80
|
-
declare const
|
|
47
|
+
type PgNativePool = ConnectionPool<PgPoolClientConnection>;
|
|
48
|
+
type PgAmbientClientPool = ConnectionPool<PgClientConnection>;
|
|
49
|
+
type PgAmbientConnectionPool = ConnectionPool<PgPoolClientConnection | PgClientConnection>;
|
|
50
|
+
type PgPool = PgNativePool | PgAmbientClientPool | PgAmbientConnectionPool;
|
|
51
|
+
declare const pgNativePool: (options: {
|
|
81
52
|
connectionString: string;
|
|
82
53
|
database?: string | undefined;
|
|
83
|
-
|
|
84
|
-
|
|
54
|
+
serializer: JSONSerializer;
|
|
55
|
+
}) => PgNativePool;
|
|
56
|
+
declare const pgAmbientNativePool: (options: {
|
|
85
57
|
pool: pg.Pool;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
58
|
+
serializer: JSONSerializer;
|
|
59
|
+
}) => PgNativePool;
|
|
60
|
+
declare const pgAmbientConnectionPool: (options: {
|
|
61
|
+
connection: PgPoolClientConnection | PgClientConnection;
|
|
62
|
+
}) => PgAmbientConnectionPool;
|
|
63
|
+
declare const pgClientPool: (options: {
|
|
91
64
|
connectionString: string;
|
|
92
65
|
database?: string | undefined;
|
|
93
|
-
|
|
94
|
-
|
|
66
|
+
serializer: JSONSerializer;
|
|
67
|
+
}) => PgAmbientClientPool;
|
|
68
|
+
declare const pgAmbientClientPool: (options: {
|
|
95
69
|
client: pg.Client;
|
|
96
|
-
|
|
97
|
-
|
|
70
|
+
serializer: JSONSerializer;
|
|
71
|
+
}) => PgAmbientClientPool;
|
|
72
|
+
type PgPoolPooledOptions = {
|
|
98
73
|
connectionString: string;
|
|
99
74
|
database?: string;
|
|
100
75
|
pooled: true;
|
|
@@ -111,7 +86,7 @@ type NodePostgresPoolPooledOptions = {
|
|
|
111
86
|
connectionString: string;
|
|
112
87
|
database?: string;
|
|
113
88
|
};
|
|
114
|
-
type
|
|
89
|
+
type PgPoolNotPooledOptions = {
|
|
115
90
|
connectionString: string;
|
|
116
91
|
database?: string;
|
|
117
92
|
pooled: false;
|
|
@@ -127,45 +102,42 @@ type NodePostgresPoolNotPooledOptions = {
|
|
|
127
102
|
} | {
|
|
128
103
|
connectionString: string;
|
|
129
104
|
database?: string;
|
|
130
|
-
connection:
|
|
105
|
+
connection: PgPoolClientConnection | PgClientConnection;
|
|
131
106
|
pooled?: false;
|
|
132
107
|
};
|
|
133
|
-
type
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
declare
|
|
137
|
-
declare
|
|
138
|
-
declare const getPool: (connectionStringOrOptions: string | pg.PoolConfig) => pg.Pool;
|
|
139
|
-
declare const endPool: ({ connectionString, database, force, }: {
|
|
108
|
+
type PgPoolOptions = (PgPoolPooledOptions | PgPoolNotPooledOptions) & JSONSerializationOptions;
|
|
109
|
+
declare function pgPool(options: PgPoolPooledOptions): PgNativePool;
|
|
110
|
+
declare function pgPool(options: PgPoolNotPooledOptions): PgAmbientClientPool;
|
|
111
|
+
declare const getPgPool: (connectionStringOrOptions: string | pg.PoolConfig) => pg.Pool;
|
|
112
|
+
declare const endPgPool: ({ connectionString, database, force, }: {
|
|
140
113
|
connectionString: string;
|
|
141
114
|
database?: string | undefined;
|
|
142
115
|
force?: boolean;
|
|
143
116
|
}) => Promise<void>;
|
|
144
117
|
declare const onEndPool: (lookupKey: string, pool: pg.Pool) => Promise<void>;
|
|
145
|
-
declare const
|
|
118
|
+
declare const endAllPgPools: () => Promise<void[]>;
|
|
146
119
|
|
|
147
|
-
type
|
|
148
|
-
declare const
|
|
120
|
+
type PgTransaction = DatabaseTransaction<PgConnection>;
|
|
121
|
+
declare const pgTransaction: <ConnectionType extends AnyConnection = AnyConnection>(connection: () => ConnectionType, serializer: JSONSerializer) => <DbClient extends PgPoolOrClient = PgPoolOrClient>(getClient: Promise<DbClient>, options?: {
|
|
149
122
|
close: (client: DbClient, error?: unknown) => Promise<void>;
|
|
150
123
|
} & DatabaseTransactionOptions) => DatabaseTransaction<ConnectionType>;
|
|
151
124
|
|
|
152
|
-
declare const
|
|
153
|
-
declare const
|
|
154
|
-
declare const
|
|
155
|
-
declare const
|
|
156
|
-
type
|
|
157
|
-
declare const
|
|
158
|
-
|
|
159
|
-
|
|
125
|
+
declare const isPgNativePool: (poolOrClient: pg.Pool | pg.PoolClient | pg.Client) => poolOrClient is pg.Pool;
|
|
126
|
+
declare const isPgClient: (poolOrClient: pg.Pool | pg.PoolClient | pg.Client) => poolOrClient is pg.Client;
|
|
127
|
+
declare const isPgPoolClient: (poolOrClient: pg.Pool | pg.PoolClient | pg.Client) => poolOrClient is pg.PoolClient;
|
|
128
|
+
declare const pgExecute: <Result = void>(poolOrClient: pg.Pool | pg.PoolClient | pg.Client, handle: (client: pg.PoolClient | pg.Client) => Promise<Result>) => Promise<Result>;
|
|
129
|
+
type PgSQLExecutor = DbSQLExecutor<PgDriverType, PgClientOrPoolClient>;
|
|
130
|
+
declare const pgSQLExecutor: ({ serializer, }: {
|
|
131
|
+
serializer: JSONSerializer;
|
|
132
|
+
}) => PgSQLExecutor;
|
|
160
133
|
|
|
161
|
-
declare const
|
|
162
|
-
|
|
134
|
+
declare const setPgTypeParser: (client: pg.Client | pg.PoolClient, options?: {
|
|
135
|
+
parseBigInts?: boolean;
|
|
136
|
+
serializer: JSONSerializer;
|
|
137
|
+
}) => void;
|
|
163
138
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
type
|
|
167
|
-
type PostgresPoolOptions = NodePostgresPoolOptions;
|
|
168
|
-
declare const postgresPool: typeof nodePostgresPool;
|
|
169
|
-
declare const connectionPool: typeof nodePostgresPool;
|
|
139
|
+
declare const pgDumboDriver: DumboDatabaseDriver<PgConnection, PgPoolOptions, PgPool>;
|
|
140
|
+
declare const usePgDumboDriver: () => void;
|
|
141
|
+
type PgDumboOptions = PgPoolOptions;
|
|
170
142
|
|
|
171
|
-
export {
|
|
143
|
+
export { type ConnectionCheckResult, type PgAmbientClientPool, type PgAmbientConnectionPool, type PgClient, type PgClientConnection, type PgClientConnectionOptions, type PgClientOptions, type PgClientOrPoolClient, type PgConnection, type PgConnectionOptions, PgDriverType, type PgDumboOptions, type PgNativePool, type PgPool, type PgPoolClient, type PgPoolClientConnection, type PgPoolClientConnectionOptions, type PgPoolClientOptions, type PgPoolNotPooledOptions, type PgPoolOptions, type PgPoolOrClient, type PgPoolPooledOptions, type PgSQLExecutor, type PgTransaction, PostgreSQLDriverType, checkConnection, endAllPgPools, endPgPool, getPgPool, isPgClient, isPgNativePool, isPgPoolClient, onEndPool, pgAmbientClientPool, pgAmbientConnectionPool, pgAmbientNativePool, pgClientConnection, pgClientPool, pgConnection, pgDumboDriver, pgExecute, pgNativePool, pgPool, pgPoolClientConnection, pgSQLExecutor, pgTransaction, setPgTypeParser, usePgDumboDriver };
|