@event-driven-io/dumbo 0.13.0-beta.2 → 0.13.0-beta.21
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-65DKXURG.js +481 -0
- package/dist/chunk-65DKXURG.js.map +1 -0
- package/dist/chunk-7WEBHXZD.cjs +481 -0
- package/dist/chunk-7WEBHXZD.cjs.map +1 -0
- package/dist/chunk-AMACBMAZ.cjs +556 -0
- package/dist/chunk-AMACBMAZ.cjs.map +1 -0
- package/dist/chunk-FC4JR2R3.js +83 -0
- package/dist/chunk-FC4JR2R3.js.map +1 -0
- package/dist/chunk-H7ZKIJHB.cjs +83 -0
- package/dist/chunk-H7ZKIJHB.cjs.map +1 -0
- package/dist/chunk-IVJ3SNPJ.js +34 -0
- package/dist/chunk-IVJ3SNPJ.js.map +1 -0
- package/dist/chunk-R7P7CNMK.cjs +34 -0
- package/dist/chunk-R7P7CNMK.cjs.map +1 -0
- package/dist/{chunk-XVV3OOQX.js → chunk-T4A6BQRA.js} +209 -58
- package/dist/chunk-T4A6BQRA.js.map +1 -0
- package/dist/{chunk-N7RWT46K.js → chunk-XO5T5N5S.js} +2135 -1613
- package/dist/chunk-XO5T5N5S.js.map +1 -0
- package/dist/{chunk-OJ34O3Q2.cjs → chunk-XOQHZABK.cjs} +2161 -1639
- package/dist/chunk-XOQHZABK.cjs.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-C7fRa54L.d.ts} +1 -1
- package/dist/{columnProcessors-BX-sH7ah.d.cts → columnProcessors-Difrrk4c.d.cts} +1 -1
- package/dist/{connectionString-B1wm0TFc.d.cts → connectionString-oeg1LD5V.d.cts} +352 -137
- package/dist/{connectionString-B1wm0TFc.d.ts → connectionString-oeg1LD5V.d.ts} +352 -137
- 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 +101 -9
- package/dist/index.js.map +1 -1
- package/dist/pg.cjs +382 -9
- package/dist/pg.cjs.map +1 -1
- package/dist/pg.d.cts +81 -105
- package/dist/pg.d.ts +81 -105
- package/dist/pg.js +434 -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} +31 -10
- package/dist/{index-C2z_XBn6.d.ts → sqlite.d.ts} +31 -10
- package/dist/sqlite.js +56 -0
- package/dist/sqlite3.cjs +240 -11
- package/dist/sqlite3.cjs.map +1 -1
- package/dist/sqlite3.d.cts +39 -19
- package/dist/sqlite3.d.ts +39 -19
- 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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/chunk-ISNF6USX.cjs","../src/storage/postgresql/core/connections/connectionString.ts","../src/storage/postgresql/core/locks/advisoryLocks.ts","../src/storage/postgresql/core/schema/migrations.ts","../src/storage/postgresql/core/schema/schema.ts","../src/storage/postgresql/core/sql/processors/columProcessors.ts","../src/storage/postgresql/core/sql/formatter/reserved.ts","../src/storage/postgresql/core/sql/formatter/index.ts","../src/storage/postgresql/core/index.ts","../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":["advisoryLock"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACtBA,kIAAiB;ADwBjB;AACA;AEbO,IAAM,uBAAA,EAAyB,M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,EAAA;AACJ,EAAA;AACA,EAAA;AACC,EAAA;AACE,EAAA;AACD,EAAA;AACI,EAAA;AACJ,EAAA;AACK,EAAA;AACN,EAAA;AACO,EAAA;AACA,EAAA;AACd,EAAA;AACc,EAAA;AACG,EAAA;AACR,EAAA;AACG,EAAA;AACH,EAAA;AACD,EAAA;AACD,EAAA;AACG,EAAA;AACJ,EAAA;AACG,EAAA;AACC,EAAA;AACN,EAAA;AACE,EAAA;AACO,EAAA;AACL,EAAA;AACA,EAAA;AACC,EAAA;AACG,EAAA;AACP,EAAA;AACG,EAAA;AACE,EAAA;AACH,EAAA;AACF,EAAA;AACI,EAAA;AACD,EAAA;AACF,EAAA;AACA,EAAA;AACS,EAAA;AACA,EAAA;AACR,EAAA;AACA,EAAA;AACD,EAAA;AACE,EAAA;AACE,EAAA;AACF,EAAA;AACD,EAAA;AACH,EAAA;AACO,EAAA;AACJ,EAAA;AACI,EAAA;AACL,EAAA;AACF,EAAA;AACI,EAAA;AACF,EAAA;AACG,EAAA;AACH,EAAA;AACA,EAAA;AACC,EAAA;AACI,EAAA;AACK,EAAA;AACX,EAAA;AACC,EAAA;AACD,EAAA;AACC,EAAA;AACC,EAAA;AACG,EAAA;AACA,EAAA;AACD,EAAA;AACA,EAAA;AACJ,EAAA;AACA,EAAA;AACI,EAAA;AACH,EAAA;AACC,EAAA;AACF,EAAA;AACI,EAAA;AACD,EAAA;AACH,EAAA;AACD,EAAA;AACE,EAAA;AACA,EAAA;AACF,EAAA;AACG,EAAA;AACA,EAAA;AACG,EAAA;AACA,EAAA;AACC,EAAA;AACF,EAAA;AACA,EAAA;AACA,EAAA;AACJ,EAAA;AACM,EAAA;AACF,EAAA;AACG,EAAA;AACD,EAAA;AACH,EAAA;AACC,EAAA;AACF,EAAA;AACC,EAAA;AACM,EAAA;AACL,EAAA;AACH,EAAA;AACG,EAAA;AACD,EAAA;AACD,EAAA;AACF,EAAA;AACC,EAAA;AACG,EAAA;AACA,EAAA;AACH,EAAA;AACF,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O,MAAA;AACb,IAAA;AAEa,EAAA;AACP,IAAA;AAEK,EAAA;AACL,IAAA;AAEF,EAAA;AACL,IAAA;AACA,IAAA;AACD,EAAA;AACH;AAEoC;AACM;AAGxC;AAEM,EAAA;AAKA,EAAA;AAMJ,EAAA;AAKI,EAAA;AAEN,EAAA;AAGY,EAAA;AAGd;AAEuB;AACrB,EAAA;AACA,EAAA;AACA,EAAA;AAKmB;AACR,EAAA;AACL,EAAA;AAEO,EAAA;AACA,EAAA;AACL,IAAA;AACR,EAAA;AACF;AAEyB;AACnB,EAAA;AACa,IAAA;AACD,EAAA;AACD,IAAA;AACf,EAAA;AACa,EAAA;AACf;AAE2B;AAEb,EAAA;AACZ;AAEW;AAGP;AACE,EAAA;AACA,EAAA;AAEW,EAAA;AAEV,EAAA;AACT;AZsTmB;AACA;AcllBb;AACA,EAAA;AACK,IAAA;AACD,EAAA;AACC,IAAA;AACT,EAAA;AACF;AAEa;AAIC,EAAA;AACC,EAAA;AACC,EAAA;AACd,EAAA;AACA,EAAA;AACW,EAAA;AACT,IAAA;AACA,IAAA;AACF,EAAA;AACF;AAEa;AACX,EAAA;AACE,IAAA;AACA,IAAA;AACF,EAAA;AACF;AAEA;AAe4B;AAEf;Ad+jBM;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/chunk-ISNF6USX.cjs","sourcesContent":[null,"import pgcs from 'pg-connection-string';\nimport type { DatabaseConnectionString } from '../../../all';\nimport { defaultPostgreSqlDatabase } from '../schema';\n\nexport const defaultPostgreSQLConnectionString: PostgreSQLConnectionString =\n 'postgresql://postgres@localhost:5432/postgres' as PostgreSQLConnectionString;\n\nexport const getDatabaseNameOrDefault = (connectionString: string) =>\n pgcs.parse(connectionString).database ?? defaultPostgreSqlDatabase;\n\nexport type PostgreSQLConnectionString = DatabaseConnectionString<\n 'PostgreSQL',\n `postgresql://${string}` | `postgres://${string}`\n>;\n\nexport const PostgreSQLConnectionString = (\n connectionString: string,\n): PostgreSQLConnectionString => {\n if (\n !connectionString.startsWith('postgresql://') &&\n !connectionString.startsWith('postgres://')\n ) {\n throw new Error(\n `Invalid PostgreSQL connection string: ${connectionString}. It should start with \"postgresql://\".`,\n );\n }\n return connectionString as PostgreSQLConnectionString;\n};\n","import {\n defaultDatabaseLockOptions,\n single,\n SQL,\n type AcquireDatabaseLockMode,\n type AcquireDatabaseLockOptions,\n type DatabaseLock,\n type DatabaseLockOptions,\n type ReleaseDatabaseLockOptions,\n type SQLExecutor,\n} from '../../../../core';\n\nexport const tryAcquireAdvisoryLock = async (\n execute: SQLExecutor,\n options: AcquireDatabaseLockOptions,\n): Promise<boolean> => {\n const timeoutMs = options.timeoutMs ?? defaultDatabaseLockOptions.timeoutMs;\n\n const advisoryLock =\n options.mode === 'Permanent' ? 'pg_advisory_lock' : 'pg_advisory_xact_lock';\n\n try {\n await single(\n execute.query<{ locked: boolean }>(\n SQL`SELECT ${SQL.plain(advisoryLock)}(${options.lockId}) AS locked`,\n { timeoutMs },\n ),\n );\n return true;\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === '57014')\n return false;\n\n throw error;\n }\n};\n\nexport const releaseAdvisoryLock = async (\n execute: SQLExecutor,\n options: ReleaseDatabaseLockOptions,\n): Promise<boolean> => {\n const timeoutMs = options.timeoutMs ?? defaultDatabaseLockOptions.timeoutMs;\n\n try {\n await single(\n execute.query<{ locked: boolean }>(\n SQL`SELECT pg_advisory_unlock(${options.lockId}) AS locked`,\n { timeoutMs },\n ),\n );\n return true;\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === '57014')\n return false;\n\n throw error;\n }\n};\n\nexport const acquireAdvisoryLock = async (\n execute: SQLExecutor,\n options: AcquireDatabaseLockOptions,\n) => {\n const lockAcquired = await tryAcquireAdvisoryLock(execute, options);\n if (!lockAcquired) {\n throw new Error(\n 'Failed to acquire advisory lock within the specified timeout. Migration aborted.',\n );\n }\n};\n\nexport const AdvisoryLock: DatabaseLock = {\n acquire: acquireAdvisoryLock,\n tryAcquire: tryAcquireAdvisoryLock,\n release: releaseAdvisoryLock,\n withAcquire: async <Result>(\n execute: SQLExecutor,\n handle: () => Promise<Result>,\n options: AcquireDatabaseLockOptions,\n ) => {\n await acquireAdvisoryLock(execute, options);\n try {\n return await handle();\n } finally {\n if (options.mode === 'Permanent')\n await releaseAdvisoryLock(execute, options);\n }\n },\n};\n\nexport const advisoryLock = (\n execute: SQLExecutor,\n options: DatabaseLockOptions,\n) => ({\n acquire: (acquireOptions?: { mode: AcquireDatabaseLockMode }) =>\n acquireAdvisoryLock(execute, {\n ...options,\n ...(acquireOptions ?? {}),\n }),\n tryAcquire: (acquireOptions?: { mode: AcquireDatabaseLockMode }) =>\n tryAcquireAdvisoryLock(execute, {\n ...options,\n ...(acquireOptions ?? {}),\n }),\n release: () => releaseAdvisoryLock(execute, options),\n withAcquire: async <Result>(\n handle: () => Promise<Result>,\n acquireOptions?: { mode: AcquireDatabaseLockMode },\n ) => {\n await acquireAdvisoryLock(execute, {\n ...options,\n ...(acquireOptions ?? {}),\n });\n try {\n return await handle();\n } finally {\n await releaseAdvisoryLock(execute, options);\n }\n },\n});\n","import {\n type MigratorOptions,\n registerDefaultMigratorOptions,\n} from '../../../../core';\nimport { AdvisoryLock } from '../locks';\n\nexport const DefaultPostgreSQLMigratorOptions: MigratorOptions = {\n lock: {\n databaseLock: AdvisoryLock,\n },\n};\n\nregisterDefaultMigratorOptions('PostgreSQL', DefaultPostgreSQLMigratorOptions);\n","import { exists, SQL, type ConnectionPool } from '../../../../core';\nexport * from './schema';\n\nexport const defaultPostgreSqlDatabase = 'postgres';\n\nexport const tableExistsSQL = (tableName: string): SQL =>\n SQL`\n SELECT EXISTS (\n SELECT FROM pg_tables\n WHERE tablename = ${tableName}\n ) AS exists;`;\n\nexport const tableExists = async (\n pool: ConnectionPool,\n tableName: string,\n): Promise<boolean> => exists(pool.execute.query(tableExistsSQL(tableName)));\n\nexport const functionExistsSQL = (functionName: string): SQL =>\n SQL`\n SELECT EXISTS (\n SELECT FROM pg_proc\n WHERE\n proname = ${functionName}\n ) AS exists;`;\n\nexport const functionExists = async (\n pool: ConnectionPool,\n tableName: string,\n): Promise<boolean> => exists(pool.execute.query(functionExistsSQL(tableName)));\n","import {\n mapDefaultSQLColumnProcessors,\n type DefaultSQLColumnProcessors,\n type DefaultSQLColumnToken,\n type SQLProcessorContext,\n} from '../../../../../core';\n\nconst mapColumnType = (\n token: DefaultSQLColumnToken,\n { builder }: SQLProcessorContext,\n): void => {\n let columnSQL: string;\n const { sqlTokenType } = token;\n switch (sqlTokenType) {\n case 'SQL_COLUMN_AUTO_INCREMENT':\n columnSQL = `${token.bigint ? 'BIGSERIAL' : 'SERIAL'} ${token.primaryKey ? 'PRIMARY KEY' : ''}`;\n break;\n case 'SQL_COLUMN_BIGINT':\n columnSQL = 'BIGINT';\n break;\n case 'SQL_COLUMN_SERIAL':\n columnSQL = 'SERIAL';\n break;\n case 'SQL_COLUMN_INTEGER':\n columnSQL = 'INTEGER';\n break;\n case 'SQL_COLUMN_JSONB':\n columnSQL = 'JSONB';\n break;\n case 'SQL_COLUMN_BIGSERIAL':\n columnSQL = 'BIGSERIAL';\n break;\n case 'SQL_COLUMN_TIMESTAMP':\n columnSQL = 'TIMESTAMP';\n break;\n case 'SQL_COLUMN_TIMESTAMPTZ':\n columnSQL = 'TIMESTAMPTZ';\n break;\n case 'SQL_COLUMN_VARCHAR':\n columnSQL = `VARCHAR ${Number.isNaN(token.length) ? '' : `(${token.length})`}`;\n break;\n default: {\n const exhaustiveCheck: never = sqlTokenType;\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n throw new Error(`Unknown column type: ${exhaustiveCheck}`);\n }\n }\n builder.addSQL(columnSQL);\n};\n\nexport const postgreSQLColumnProcessors: DefaultSQLColumnProcessors =\n mapDefaultSQLColumnProcessors(mapColumnType);\n","// Ported from: https://github.com/datalanche/node-pg-format/blob/master/lib/reserved.js\n//\n// PostgreSQL reserved words\n//\nconst reservedMap: { [key: string]: boolean } = {\n AES128: true,\n AES256: true,\n ALL: true,\n ALLOWOVERWRITE: true,\n ANALYSE: true,\n ANALYZE: true,\n AND: true,\n ANY: true,\n ARRAY: true,\n AS: true,\n ASC: true,\n AUTHORIZATION: true,\n BACKUP: true,\n BETWEEN: true,\n BINARY: true,\n BLANKSASNULL: true,\n BOTH: true,\n BYTEDICT: true,\n CASE: true,\n CAST: true,\n CHECK: true,\n COLLATE: true,\n COLUMN: true,\n CONSTRAINT: true,\n CREATE: true,\n CREDENTIALS: true,\n CROSS: true,\n CURRENT_DATE: true,\n CURRENT_TIME: true,\n CURRENT_TIMESTAMP: true,\n CURRENT_USER: true,\n CURRENT_USER_ID: true,\n DEFAULT: true,\n DEFERRABLE: true,\n DEFLATE: true,\n DEFRAG: true,\n DELTA: true,\n DELTA32K: true,\n DESC: true,\n DISABLE: true,\n DISTINCT: true,\n DO: true,\n ELSE: true,\n EMPTYASNULL: true,\n ENABLE: true,\n ENCODE: true,\n ENCRYPT: true,\n ENCRYPTION: true,\n END: true,\n EXCEPT: true,\n EXPLICIT: true,\n FALSE: true,\n FOR: true,\n FOREIGN: true,\n FREEZE: true,\n FROM: true,\n FULL: true,\n GLOBALDICT256: true,\n GLOBALDICT64K: true,\n GRANT: true,\n GROUP: true,\n GZIP: true,\n HAVING: true,\n IDENTITY: true,\n IGNORE: true,\n ILIKE: true,\n IN: true,\n INITIALLY: true,\n INNER: true,\n INTERSECT: true,\n INTO: true,\n IS: true,\n ISNULL: true,\n JOIN: true,\n LEADING: true,\n LEFT: true,\n LIKE: true,\n LIMIT: true,\n LOCALTIME: true,\n LOCALTIMESTAMP: true,\n LUN: true,\n LUNS: true,\n LZO: true,\n LZOP: true,\n MINUS: true,\n MOSTLY13: true,\n MOSTLY32: true,\n MOSTLY8: true,\n NATURAL: true,\n NEW: true,\n NOT: true,\n NOTNULL: true,\n NULL: true,\n NULLS: true,\n OFF: true,\n OFFLINE: true,\n OFFSET: true,\n OLD: true,\n ON: true,\n ONLY: true,\n OPEN: true,\n OR: true,\n ORDER: true,\n OUTER: true,\n OVERLAPS: true,\n PARALLEL: true,\n PARTITION: true,\n PERCENT: true,\n PLACING: true,\n PRIMARY: true,\n RAW: true,\n READRATIO: true,\n RECOVER: true,\n REFERENCES: true,\n REJECTLOG: true,\n RESORT: true,\n RESTORE: true,\n RIGHT: true,\n SELECT: true,\n SESSION_USER: true,\n SIMILAR: true,\n SOME: true,\n SYSDATE: true,\n SYSTEM: true,\n TABLE: true,\n TAG: true,\n TDES: true,\n TEXT255: true,\n TEXT32K: true,\n THEN: true,\n TO: true,\n TOP: true,\n TRAILING: true,\n TRUE: true,\n TRUNCATECOLUMNS: true,\n UNION: true,\n UNIQUE: true,\n USER: true,\n USING: true,\n VERBOSE: true,\n WALLET: true,\n WHEN: true,\n WHERE: true,\n WITH: true,\n WITHOUT: true,\n};\n\nexport default reservedMap;\n","import {\n SQLFormatter,\n SQLProcessorsRegistry,\n defaultProcessorsRegistry,\n mapSQLIdentifier,\n registerFormatter,\n} from '../../../../../core';\nimport { postgreSQLColumnProcessors } from '../processors';\nimport reservedMap from './reserved';\n\nconst postgreSQLProcessorsRegistry = SQLProcessorsRegistry({\n from: defaultProcessorsRegistry,\n}).register(postgreSQLColumnProcessors);\n\nconst pgFormatter: SQLFormatter = SQLFormatter({\n processorsRegistry: postgreSQLProcessorsRegistry,\n valueMapper: {\n mapDate: (value: Date): unknown =>\n value.toISOString().replace('T', ' ').replace('Z', '+00'),\n mapPlaceholder: (index: number): string => `$${index + 1}`,\n mapIdentifier: (value: string): string =>\n mapSQLIdentifier(value, { reservedWords: reservedMap }),\n },\n});\n\nregisterFormatter('PostgreSQL', pgFormatter);\n\n// Export the original functions if needed\nexport { pgFormatter };\n","import type { DatabaseDriverType } from '../../../core';\n\nexport * from './connections';\nexport * from './locks';\nexport * from './schema';\nexport * from './sql';\n\nexport type PostgreSQLDatabaseName = 'PostgreSQL';\nexport const PostgreSQLDatabaseName = 'PostgreSQL';\n\nexport type PostgreSQLDriverType<DriverName extends string = string> =\n DatabaseDriverType<PostgreSQLDatabaseName, DriverName>;\n","import pg from 'pg';\nimport { createConnection, type Connection } from '../../../../core';\nimport type { PostgreSQLDriverType } from '../../core';\nimport { nodePostgresSQLExecutor } from '../execute';\nimport { nodePostgresTransaction } from './transaction';\n\nexport type NodePostgresDriverType = PostgreSQLDriverType<'pg'>;\nexport const NodePostgresDriverType: NodePostgresDriverType = 'PostgreSQL:pg';\n\nexport type NodePostgresPoolClient = pg.PoolClient;\nexport type NodePostgresClient = pg.Client;\n\nexport type NodePostgresClientOrPoolClient =\n | NodePostgresPoolClient\n | NodePostgresClient;\n\nexport type NodePostgresPoolOrClient =\n | pg.Pool\n | NodePostgresPoolClient\n | NodePostgresClient;\n\nexport type NodePostgresClientConnection = Connection<\n NodePostgresClientConnection,\n NodePostgresDriverType,\n NodePostgresClient\n>;\n\nexport type NodePostgresPoolClientConnection = Connection<\n NodePostgresPoolClientConnection,\n NodePostgresDriverType,\n NodePostgresPoolClient\n>;\n\nexport type NodePostgresConnection =\n | NodePostgresPoolClientConnection\n | NodePostgresClientConnection;\n\nexport type NodePostgresPoolClientOptions = {\n type: 'PoolClient';\n connect: () => Promise<NodePostgresPoolClient>;\n close: (client: NodePostgresPoolClient) => Promise<void>;\n};\n\nexport type NodePostgresClientOptions = {\n type: 'Client';\n connect: () => Promise<NodePostgresClient>;\n close: (client: NodePostgresClient) => Promise<void>;\n};\n\nexport const nodePostgresClientConnection = (\n options: NodePostgresClientOptions,\n): NodePostgresClientConnection => {\n const { connect, close } = options;\n\n return createConnection({\n driverType: NodePostgresDriverType,\n connect,\n close,\n initTransaction: (connection) => nodePostgresTransaction(connection),\n executor: nodePostgresSQLExecutor,\n });\n};\n\nexport const nodePostgresPoolClientConnection = (\n options: NodePostgresPoolClientOptions,\n): NodePostgresPoolClientConnection => {\n const { connect, close } = options;\n\n return createConnection({\n driverType: NodePostgresDriverType,\n connect,\n close,\n initTransaction: (connection) => nodePostgresTransaction(connection),\n executor: nodePostgresSQLExecutor,\n });\n};\n\nexport function nodePostgresConnection(\n options: NodePostgresPoolClientOptions,\n): NodePostgresPoolClientConnection;\nexport function nodePostgresConnection(\n options: NodePostgresClientOptions,\n): NodePostgresClientConnection;\nexport function nodePostgresConnection(\n options: NodePostgresPoolClientOptions | NodePostgresClientOptions,\n): NodePostgresPoolClientConnection | NodePostgresClientConnection {\n return options.type === 'Client'\n ? nodePostgresClientConnection(options)\n : nodePostgresPoolClientConnection(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 {\n tracer,\n type DbSQLExecutor,\n type QueryResult,\n type QueryResultRow,\n type SQL,\n type SQLCommandOptions,\n type SQLQueryOptions,\n} from '../../../../core';\nimport { pgFormatter } from '../../core';\nimport {\n NodePostgresDriverType,\n type NodePostgresClientOrPoolClient,\n} from '../connections';\n\nexport const isNodePostgresNativePool = (\n poolOrClient: pg.Pool | pg.PoolClient | pg.Client,\n): poolOrClient is pg.Pool => {\n return poolOrClient instanceof pg.Pool;\n};\n\nexport const isNodePostgresClient = (\n poolOrClient: pg.Pool | pg.PoolClient | pg.Client,\n): poolOrClient is pg.Client => poolOrClient instanceof pg.Client;\n\nexport const isNodePostgresPoolClient = (\n poolOrClient: pg.Pool | pg.PoolClient | pg.Client,\n): poolOrClient is pg.PoolClient =>\n 'release' in poolOrClient && typeof poolOrClient.release === 'function';\n\nexport const nodePostgresExecute = async <Result = void>(\n poolOrClient: pg.Pool | pg.PoolClient | pg.Client,\n handle: (client: pg.PoolClient | pg.Client) => Promise<Result>,\n) => {\n const client = isNodePostgresNativePool(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 (\n isNodePostgresNativePool(poolOrClient) &&\n isNodePostgresPoolClient(client)\n )\n client.release();\n }\n};\n\nexport type NodePostgresSQLExecutor = DbSQLExecutor<\n NodePostgresDriverType,\n NodePostgresClientOrPoolClient\n>;\n\nexport const nodePostgresSQLExecutor = (): NodePostgresSQLExecutor => ({\n driverType: NodePostgresDriverType,\n query: batch,\n batchQuery: batch,\n command: batch,\n batchCommand: batch,\n formatter: pgFormatter,\n});\n\nfunction batch<Result extends QueryResultRow = QueryResultRow>(\n client: NodePostgresClientOrPoolClient,\n sqlOrSqls: SQL,\n options?: SQLQueryOptions | SQLCommandOptions,\n): Promise<QueryResult<Result>>;\nfunction batch<Result extends QueryResultRow = QueryResultRow>(\n client: NodePostgresClientOrPoolClient,\n sqlOrSqls: SQL[],\n options?: SQLQueryOptions | SQLCommandOptions,\n): Promise<QueryResult<Result>[]>;\nasync function batch<Result extends QueryResultRow = QueryResultRow>(\n client: NodePostgresClientOrPoolClient,\n sqlOrSqls: SQL | SQL[],\n options?: SQLQueryOptions | SQLCommandOptions,\n): Promise<QueryResult<Result> | QueryResult<Result>[]> {\n const sqls = Array.isArray(sqlOrSqls) ? sqlOrSqls : [sqlOrSqls];\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]!);\n tracer.info('db:sql:query', {\n query,\n params,\n debugSQL: pgFormatter.describe(sqls[i]!),\n });\n const result = await client.query<Result>(query, params);\n results[i] = { rowCount: result.rowCount, rows: result.rows };\n }\n return Array.isArray(sqlOrSqls) ? results : results[0]!;\n}\n","import {\n sqlExecutor,\n type AnyConnection,\n type DatabaseTransaction,\n type DatabaseTransactionOptions,\n} from '../../../../core';\nimport { nodePostgresSQLExecutor } from '../execute';\nimport {\n NodePostgresDriverType,\n type NodePostgresConnection,\n type NodePostgresPoolOrClient,\n} from './connection';\n\nexport type NodePostgresTransaction =\n DatabaseTransaction<NodePostgresConnection>;\n\nexport const nodePostgresTransaction =\n <ConnectionType extends AnyConnection = AnyConnection>(\n connection: () => ConnectionType,\n ) =>\n <DbClient extends NodePostgresPoolOrClient = NodePostgresPoolOrClient>(\n getClient: Promise<DbClient>,\n options?: {\n close: (client: DbClient, error?: unknown) => Promise<void>;\n } & DatabaseTransactionOptions,\n ): DatabaseTransaction<ConnectionType> => ({\n connection: connection(),\n driverType: NodePostgresDriverType,\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(nodePostgresSQLExecutor(), {\n connect: () => getClient,\n }),\n });\n","import pg from 'pg';\nimport {\n createAmbientConnectionPool,\n createConnectionPool,\n JSONSerializer,\n tracer,\n type ConnectionPool,\n} from '../../../../core';\nimport {\n defaultPostgreSqlDatabase,\n getDatabaseNameOrDefault,\n} from '../../core';\nimport { setNodePostgresTypeParser } from '../serialization';\nimport {\n nodePostgresConnection,\n NodePostgresDriverType,\n type NodePostgresClientConnection,\n type NodePostgresPoolClientConnection,\n} from './connection';\n\nexport type NodePostgresNativePool =\n ConnectionPool<NodePostgresPoolClientConnection>;\n\nexport type NodePostgresAmbientClientPool =\n ConnectionPool<NodePostgresClientConnection>;\n\nexport type NodePostgresAmbientConnectionPool = ConnectionPool<\n NodePostgresPoolClientConnection | NodePostgresClientConnection\n>;\n\nexport type NodePostgresPool =\n | NodePostgresNativePool\n | NodePostgresAmbientClientPool\n | NodePostgresAmbientConnectionPool;\n\nexport const nodePostgresNativePool = (options: {\n connectionString: string;\n database?: string | undefined;\n}): NodePostgresNativePool => {\n const { connectionString, database } = options;\n const pool = getPool({ connectionString, database });\n\n const getConnection = () =>\n nodePostgresConnection({\n type: 'PoolClient',\n connect: () => pool.connect(),\n close: (client) => Promise.resolve(client.release()),\n });\n\n const open = () => Promise.resolve(getConnection());\n const close = () => endPool({ connectionString, database });\n\n return createConnectionPool({\n driverType: NodePostgresDriverType,\n connection: open,\n close,\n getConnection,\n });\n};\n\nexport const nodePostgresAmbientNativePool = (options: {\n pool: pg.Pool;\n}): NodePostgresNativePool => {\n const { pool } = options;\n\n return createConnectionPool({\n driverType: NodePostgresDriverType,\n getConnection: () =>\n nodePostgresConnection({\n type: 'PoolClient',\n connect: () => pool.connect(),\n close: (client) => Promise.resolve(client.release()),\n }),\n });\n};\n\nexport const nodePostgresAmbientConnectionPool = (options: {\n connection: NodePostgresPoolClientConnection | NodePostgresClientConnection;\n}): NodePostgresAmbientConnectionPool => {\n const { connection } = options;\n\n return createAmbientConnectionPool({\n driverType: NodePostgresDriverType,\n connection,\n });\n};\n\nexport const nodePostgresClientPool = (options: {\n connectionString: string;\n database?: string | undefined;\n}): NodePostgresAmbientClientPool => {\n const { connectionString, database } = options;\n\n return createConnectionPool({\n driverType: NodePostgresDriverType,\n getConnection: () => {\n const connect = async () => {\n const client = new pg.Client({ connectionString, database });\n await client.connect();\n return client;\n };\n\n return nodePostgresConnection({\n type: 'Client',\n connect,\n close: (client) => client.end(),\n });\n },\n });\n};\n\nexport const nodePostgresAmbientClientPool = (options: {\n client: pg.Client;\n}): NodePostgresAmbientClientPool => {\n const { client } = options;\n\n const getConnection = () => {\n const connect = () => Promise.resolve(client);\n\n return nodePostgresConnection({\n type: 'Client',\n connect,\n close: () => Promise.resolve(),\n });\n };\n\n const open = () => Promise.resolve(getConnection());\n const close = () => Promise.resolve();\n\n return createConnectionPool({\n driverType: NodePostgresDriverType,\n connection: open,\n close,\n getConnection,\n });\n};\n\nexport type NodePostgresPoolPooledOptions =\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 NodePostgresPoolNotPooledOptions =\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:\n | NodePostgresPoolClientConnection\n | NodePostgresClientConnection;\n pooled?: false;\n };\n\nexport type NodePostgresPoolOptions = (\n | NodePostgresPoolPooledOptions\n | NodePostgresPoolNotPooledOptions\n) & {\n serializer?: JSONSerializer;\n};\n\nexport function nodePostgresPool(\n options: NodePostgresPoolPooledOptions,\n): NodePostgresNativePool;\nexport function nodePostgresPool(\n options: NodePostgresPoolNotPooledOptions,\n): NodePostgresAmbientClientPool;\nexport function nodePostgresPool(\n options: NodePostgresPoolOptions,\n):\n | NodePostgresNativePool\n | NodePostgresAmbientClientPool\n | NodePostgresAmbientConnectionPool {\n const { connectionString, database, serializer } = options;\n\n setNodePostgresTypeParser(serializer ?? JSONSerializer);\n\n if ('client' in options && options.client)\n return nodePostgresAmbientClientPool({ client: options.client });\n\n if ('connection' in options && options.connection)\n return nodePostgresAmbientConnectionPool({\n connection: options.connection,\n });\n\n if ('pooled' in options && options.pooled === false)\n return nodePostgresClientPool({ connectionString, database });\n\n if ('pool' in options && options.pool)\n return nodePostgresAmbientNativePool({ pool: options.pool });\n\n return nodePostgresNativePool({\n connectionString,\n database,\n });\n}\n\nconst pools: Map<string, pg.Pool> = new Map();\nconst usageCounter: Map<string, number> = new Map();\n\nexport const getPool = (\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 ? getDatabaseNameOrDefault(poolOptions.connectionString)\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 endPool = async ({\n connectionString,\n database,\n force,\n}: {\n connectionString: string;\n database?: string | undefined;\n force?: boolean;\n}): Promise<void> => {\n database = database ?? getDatabaseNameOrDefault(connectionString);\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 endAllPools = () =>\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 pg from 'pg';\nimport { JSONSerializer } from '../../../../core/serializer';\n\nexport const setNodePostgresTypeParser = (jsonSerializer: JSONSerializer) => {\n // BigInt\n pg.types.setTypeParser(20, (val) => BigInt(val));\n\n // JSONB\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n pg.types.setTypeParser(3802, (val) => jsonSerializer.deserialize(val));\n\n // JSON\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n pg.types.setTypeParser(114, (val) => jsonSerializer.deserialize(val));\n};\n","import {\n canHandleDriverWithConnectionString,\n type DumboDatabaseDriver,\n dumboDatabaseDriverRegistry,\n} from '../../../core';\nimport {\n DefaultPostgreSQLMigratorOptions,\n getDatabaseNameOrDefault,\n pgFormatter,\n PostgreSQLConnectionString,\n} from '../core';\nimport {\n type NodePostgresConnection,\n NodePostgresDriverType,\n type NodePostgresPool,\n nodePostgresPool,\n type NodePostgresPoolOptions,\n} from './connections';\n\nconst tryParseConnectionString = (connectionString: string) => {\n try {\n return PostgreSQLConnectionString(connectionString);\n } catch {\n return null;\n }\n};\n\nexport const pgDatabaseDriver: DumboDatabaseDriver<\n NodePostgresConnection,\n NodePostgresPoolOptions\n> = {\n driverType: NodePostgresDriverType,\n createPool: (options) => nodePostgresPool(options as NodePostgresPoolOptions),\n sqlFormatter: pgFormatter,\n defaultMigratorOptions: DefaultPostgreSQLMigratorOptions,\n getDatabaseNameOrDefault,\n canHandle: canHandleDriverWithConnectionString(\n NodePostgresDriverType,\n tryParseConnectionString,\n ),\n};\n\nexport const usePgDatabaseDriver = () => {\n dumboDatabaseDriverRegistry.register(\n NodePostgresDriverType,\n pgDatabaseDriver,\n );\n};\n\nusePgDatabaseDriver();\n\nexport * from './connections';\nexport * from './execute';\nexport * from './serialization';\n\nexport { pgDatabaseDriver as databaseDriver };\n\n// TODO: Remove stuff below\n\nexport type PostgresDriverType = NodePostgresDriverType;\nexport type PostgresPool = NodePostgresPool;\nexport type PostgresConnection = NodePostgresConnection;\n\nexport type PostgresPoolOptions = NodePostgresPoolOptions;\nexport const postgresPool = nodePostgresPool;\n\nexport const connectionPool = postgresPool;\n"]}
|
package/dist/chunk-IYEHOE4S.cjs
DELETED
|
@@ -1,405 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _chunkOJ34O3Q2cjs = require('./chunk-OJ34O3Q2.cjs');
|
|
19
|
-
|
|
20
|
-
// src/storage/sqlite/core/sql/processors/columProcessors.ts
|
|
21
|
-
var mapColumnType = (token, { builder }) => {
|
|
22
|
-
let columnSQL;
|
|
23
|
-
const { sqlTokenType } = token;
|
|
24
|
-
switch (sqlTokenType) {
|
|
25
|
-
case "SQL_COLUMN_AUTO_INCREMENT":
|
|
26
|
-
columnSQL = `INTEGER ${token.primaryKey ? "PRIMARY KEY" : ""} AUTOINCREMENT`;
|
|
27
|
-
break;
|
|
28
|
-
case "SQL_COLUMN_BIGINT":
|
|
29
|
-
columnSQL = "INTEGER";
|
|
30
|
-
break;
|
|
31
|
-
case "SQL_COLUMN_SERIAL":
|
|
32
|
-
columnSQL = "INTEGER";
|
|
33
|
-
break;
|
|
34
|
-
case "SQL_COLUMN_INTEGER":
|
|
35
|
-
columnSQL = "INTEGER";
|
|
36
|
-
break;
|
|
37
|
-
case "SQL_COLUMN_JSONB":
|
|
38
|
-
columnSQL = "BLOB";
|
|
39
|
-
break;
|
|
40
|
-
case "SQL_COLUMN_BIGSERIAL":
|
|
41
|
-
columnSQL = "INTEGER";
|
|
42
|
-
break;
|
|
43
|
-
case "SQL_COLUMN_TIMESTAMP":
|
|
44
|
-
columnSQL = "DATETIME";
|
|
45
|
-
break;
|
|
46
|
-
case "SQL_COLUMN_TIMESTAMPTZ":
|
|
47
|
-
columnSQL = "DATETIME";
|
|
48
|
-
break;
|
|
49
|
-
case "SQL_COLUMN_VARCHAR":
|
|
50
|
-
columnSQL = `VARCHAR ${Number.isNaN(token.length) ? "" : `(${token.length})`}`;
|
|
51
|
-
break;
|
|
52
|
-
default: {
|
|
53
|
-
const exhaustiveCheck = sqlTokenType;
|
|
54
|
-
throw new Error(`Unknown column type: ${exhaustiveCheck}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
builder.addSQL(columnSQL);
|
|
58
|
-
};
|
|
59
|
-
var sqliteColumnProcessors = _chunkOJ34O3Q2cjs.mapDefaultSQLColumnProcessors.call(void 0, mapColumnType);
|
|
60
|
-
|
|
61
|
-
// src/storage/sqlite/core/sql/formatter/index.ts
|
|
62
|
-
var sqliteSQLProcessorsRegistry = _chunkOJ34O3Q2cjs.SQLProcessorsRegistry.call(void 0, {
|
|
63
|
-
from: _chunkOJ34O3Q2cjs.defaultProcessorsRegistry
|
|
64
|
-
}).register(sqliteColumnProcessors);
|
|
65
|
-
var sqliteFormatter = _chunkOJ34O3Q2cjs.SQLFormatter.call(void 0, {
|
|
66
|
-
processorsRegistry: sqliteSQLProcessorsRegistry
|
|
67
|
-
});
|
|
68
|
-
_chunkOJ34O3Q2cjs.registerFormatter.call(void 0, "SQLite", sqliteFormatter);
|
|
69
|
-
|
|
70
|
-
// src/storage/sqlite/core/execute/execute.ts
|
|
71
|
-
var sqliteExecute = async (database, handle) => {
|
|
72
|
-
try {
|
|
73
|
-
return await handle(database);
|
|
74
|
-
} finally {
|
|
75
|
-
await database.close();
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
var sqliteSQLExecutor = (driverType, formatter) => ({
|
|
79
|
-
driverType,
|
|
80
|
-
query: async (client, sql, options) => {
|
|
81
|
-
if (_optionalChain([options, 'optionalAccess', _ => _.timeoutMs])) {
|
|
82
|
-
await client.query(_chunkOJ34O3Q2cjs.SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);
|
|
83
|
-
}
|
|
84
|
-
_chunkOJ34O3Q2cjs.tracer.info("db:sql:query", {
|
|
85
|
-
query: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql).query,
|
|
86
|
-
params: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql).params,
|
|
87
|
-
debugSQL: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).describe(sql)
|
|
88
|
-
});
|
|
89
|
-
let result = await client.query(sql, options);
|
|
90
|
-
if (_optionalChain([options, 'optionalAccess', _2 => _2.mapping])) {
|
|
91
|
-
result = {
|
|
92
|
-
...result,
|
|
93
|
-
rows: result.rows.map(
|
|
94
|
-
(row) => _chunkOJ34O3Q2cjs.mapSQLQueryResult.call(void 0, row, options.mapping)
|
|
95
|
-
)
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
return result;
|
|
99
|
-
},
|
|
100
|
-
batchQuery: async (client, sqls, options) => {
|
|
101
|
-
if (_optionalChain([options, 'optionalAccess', _3 => _3.timeoutMs])) {
|
|
102
|
-
await client.query(_chunkOJ34O3Q2cjs.SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);
|
|
103
|
-
}
|
|
104
|
-
const results = await client.batchQuery(sqls, options);
|
|
105
|
-
if (_optionalChain([options, 'optionalAccess', _4 => _4.mapping])) {
|
|
106
|
-
return results.map((result) => ({
|
|
107
|
-
...result,
|
|
108
|
-
rows: result.rows.map(
|
|
109
|
-
(row) => _chunkOJ34O3Q2cjs.mapSQLQueryResult.call(void 0, row, options.mapping)
|
|
110
|
-
)
|
|
111
|
-
}));
|
|
112
|
-
}
|
|
113
|
-
return results;
|
|
114
|
-
},
|
|
115
|
-
command: async (client, sql, options) => {
|
|
116
|
-
if (_optionalChain([options, 'optionalAccess', _5 => _5.timeoutMs])) {
|
|
117
|
-
await client.query(_chunkOJ34O3Q2cjs.SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);
|
|
118
|
-
}
|
|
119
|
-
_chunkOJ34O3Q2cjs.tracer.info("db:sql:command", {
|
|
120
|
-
query: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql).query,
|
|
121
|
-
params: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql).params,
|
|
122
|
-
debugSQL: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).describe(sql)
|
|
123
|
-
});
|
|
124
|
-
return await client.command(sql, options);
|
|
125
|
-
},
|
|
126
|
-
batchCommand: async (client, sqls, options) => {
|
|
127
|
-
if (_optionalChain([options, 'optionalAccess', _6 => _6.timeoutMs])) {
|
|
128
|
-
await client.query(_chunkOJ34O3Q2cjs.SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);
|
|
129
|
-
}
|
|
130
|
-
return await client.batchCommand(sqls, options);
|
|
131
|
-
},
|
|
132
|
-
formatter: _nullishCoalesce(formatter, () => ( sqliteFormatter))
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
// src/storage/sqlite/core/pool/pool.ts
|
|
136
|
-
var isInMemoryDatabase = (options) => {
|
|
137
|
-
if ("fileName" in options) {
|
|
138
|
-
return options.fileName === InMemorySQLiteDatabase;
|
|
139
|
-
}
|
|
140
|
-
if ("connectionString" in options) {
|
|
141
|
-
return options.connectionString === InMemorySQLiteDatabase;
|
|
142
|
-
}
|
|
143
|
-
return false;
|
|
144
|
-
};
|
|
145
|
-
var sqliteAmbientConnectionPool = (options) => {
|
|
146
|
-
const { connection, driverType } = options;
|
|
147
|
-
return _chunkOJ34O3Q2cjs.createAmbientConnectionPool.call(void 0, {
|
|
148
|
-
driverType,
|
|
149
|
-
connection
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
var sqliteSingletonConnectionPool = (options) => {
|
|
153
|
-
const { driverType, sqliteConnectionFactory, connectionOptions } = options;
|
|
154
|
-
return _chunkOJ34O3Q2cjs.createSingletonConnectionPool.call(void 0, {
|
|
155
|
-
driverType,
|
|
156
|
-
getConnection: () => sqliteConnectionFactory(connectionOptions)
|
|
157
|
-
});
|
|
158
|
-
};
|
|
159
|
-
var sqliteAlwaysNewConnectionPool = (options) => {
|
|
160
|
-
const { driverType, sqliteConnectionFactory, connectionOptions } = options;
|
|
161
|
-
return _chunkOJ34O3Q2cjs.createAlwaysNewConnectionPool.call(void 0, {
|
|
162
|
-
driverType,
|
|
163
|
-
getConnection: () => sqliteConnectionFactory(connectionOptions)
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
var toSqlitePoolOptions = (options) => {
|
|
167
|
-
const { singleton, ...rest } = options;
|
|
168
|
-
const useSingleton = _nullishCoalesce(singleton, () => ( isInMemoryDatabase(options)));
|
|
169
|
-
if (useSingleton) {
|
|
170
|
-
return { ...rest, singleton: true };
|
|
171
|
-
}
|
|
172
|
-
return { ...rest, singleton: false };
|
|
173
|
-
};
|
|
174
|
-
function sqlitePool(options) {
|
|
175
|
-
const { driverType } = options;
|
|
176
|
-
if (options.connection)
|
|
177
|
-
return _chunkOJ34O3Q2cjs.createAmbientConnectionPool.call(void 0, {
|
|
178
|
-
driverType,
|
|
179
|
-
connection: options.connection
|
|
180
|
-
});
|
|
181
|
-
if (options.singleton === true && options.sqliteConnectionFactory) {
|
|
182
|
-
return _chunkOJ34O3Q2cjs.createSingletonConnectionPool.call(void 0, {
|
|
183
|
-
driverType,
|
|
184
|
-
getConnection: () => options.sqliteConnectionFactory(options.connectionOptions)
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
return _chunkOJ34O3Q2cjs.createAlwaysNewConnectionPool.call(void 0, {
|
|
188
|
-
driverType,
|
|
189
|
-
getConnection: () => options.sqliteConnectionFactory(options.connectionOptions)
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// src/storage/sqlite/core/schema/migrations.ts
|
|
194
|
-
var DefaultSQLiteMigratorOptions = {};
|
|
195
|
-
_chunkOJ34O3Q2cjs.registerDefaultMigratorOptions.call(void 0, "SQLite", DefaultSQLiteMigratorOptions);
|
|
196
|
-
|
|
197
|
-
// src/storage/sqlite/core/schema/schema.ts
|
|
198
|
-
var defaultPostgreSqlDatabase = "postgres";
|
|
199
|
-
var tableExistsSQL = (tableName) => _chunkOJ34O3Q2cjs.SQL`
|
|
200
|
-
SELECT EXISTS (
|
|
201
|
-
SELECT 1
|
|
202
|
-
FROM sqlite_master
|
|
203
|
-
WHERE type = 'table' AND name = ${tableName}
|
|
204
|
-
) AS "exists"
|
|
205
|
-
`;
|
|
206
|
-
var tableExists = async (pool, tableName) => _chunkOJ34O3Q2cjs.exists.call(void 0, pool.execute.query(tableExistsSQL(tableName)));
|
|
207
|
-
|
|
208
|
-
// src/storage/sqlite/core/index.ts
|
|
209
|
-
var SQLiteDatabaseName = "SQLite";
|
|
210
|
-
|
|
211
|
-
// src/storage/sqlite/core/connections/connectionString.ts
|
|
212
|
-
var SQLiteConnectionString2 = (connectionString) => {
|
|
213
|
-
if (!connectionString.startsWith("file:") && connectionString !== ":memory:" && !connectionString.startsWith("/") && !connectionString.startsWith("./")) {
|
|
214
|
-
throw new Error(
|
|
215
|
-
`Invalid SQLite connection string: ${connectionString}. It should start with "file:", ":memory:", "/", or "./".`
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
return connectionString;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
// src/storage/sqlite/core/connections/index.ts
|
|
222
|
-
var isSQLiteError = (error) => {
|
|
223
|
-
if (error instanceof Error && "code" in error) {
|
|
224
|
-
return true;
|
|
225
|
-
}
|
|
226
|
-
return false;
|
|
227
|
-
};
|
|
228
|
-
var transactionNestingCounter = () => {
|
|
229
|
-
let transactionLevel = 0;
|
|
230
|
-
return {
|
|
231
|
-
reset: () => {
|
|
232
|
-
transactionLevel = 0;
|
|
233
|
-
},
|
|
234
|
-
increment: () => {
|
|
235
|
-
transactionLevel++;
|
|
236
|
-
},
|
|
237
|
-
decrement: () => {
|
|
238
|
-
transactionLevel--;
|
|
239
|
-
if (transactionLevel < 0) {
|
|
240
|
-
throw new Error("Transaction level is out of bounds");
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
get level() {
|
|
244
|
-
return transactionLevel;
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
};
|
|
248
|
-
var sqliteAmbientClientConnection = (options) => {
|
|
249
|
-
const { client, driverType, initTransaction, allowNestedTransactions } = options;
|
|
250
|
-
return _chunkOJ34O3Q2cjs.createAmbientConnection.call(void 0, {
|
|
251
|
-
driverType,
|
|
252
|
-
client,
|
|
253
|
-
initTransaction: _nullishCoalesce(initTransaction, () => ( ((connection) => sqliteTransaction(
|
|
254
|
-
driverType,
|
|
255
|
-
connection,
|
|
256
|
-
_nullishCoalesce(allowNestedTransactions, () => ( false))
|
|
257
|
-
)))),
|
|
258
|
-
executor: () => sqliteSQLExecutor(driverType)
|
|
259
|
-
});
|
|
260
|
-
};
|
|
261
|
-
var sqliteClientConnection = (options) => {
|
|
262
|
-
const { connectionOptions, sqliteClientFactory } = options;
|
|
263
|
-
let client = null;
|
|
264
|
-
const connect = async () => {
|
|
265
|
-
if (client) return Promise.resolve(client);
|
|
266
|
-
client = sqliteClientFactory(connectionOptions);
|
|
267
|
-
if (client && "connect" in client && typeof client.connect === "function")
|
|
268
|
-
await client.connect();
|
|
269
|
-
return client;
|
|
270
|
-
};
|
|
271
|
-
return _chunkOJ34O3Q2cjs.createConnection.call(void 0, {
|
|
272
|
-
driverType: options.driverType,
|
|
273
|
-
connect,
|
|
274
|
-
close: async () => {
|
|
275
|
-
if (client && "close" in client && typeof client.close === "function")
|
|
276
|
-
await client.close();
|
|
277
|
-
else if (client && "release" in client && typeof client.release === "function")
|
|
278
|
-
client.release();
|
|
279
|
-
},
|
|
280
|
-
initTransaction: (connection) => sqliteTransaction(
|
|
281
|
-
options.driverType,
|
|
282
|
-
connection,
|
|
283
|
-
_nullishCoalesce(_optionalChain([connectionOptions, 'access', _7 => _7.transactionOptions, 'optionalAccess', _8 => _8.allowNestedTransactions]), () => ( false))
|
|
284
|
-
),
|
|
285
|
-
executor: () => sqliteSQLExecutor(options.driverType)
|
|
286
|
-
});
|
|
287
|
-
};
|
|
288
|
-
var sqlitePoolClientConnection = (options) => {
|
|
289
|
-
const { connectionOptions, sqliteClientFactory } = options;
|
|
290
|
-
let client = null;
|
|
291
|
-
const connect = async () => {
|
|
292
|
-
if (client) return Promise.resolve(client);
|
|
293
|
-
client = sqliteClientFactory(connectionOptions);
|
|
294
|
-
await client.connect();
|
|
295
|
-
return client;
|
|
296
|
-
};
|
|
297
|
-
return _chunkOJ34O3Q2cjs.createConnection.call(void 0, {
|
|
298
|
-
driverType: options.driverType,
|
|
299
|
-
connect,
|
|
300
|
-
close: () => client !== null ? Promise.resolve(client.release()) : Promise.resolve(),
|
|
301
|
-
initTransaction: (connection) => sqliteTransaction(
|
|
302
|
-
options.driverType,
|
|
303
|
-
connection,
|
|
304
|
-
_nullishCoalesce(_optionalChain([connectionOptions, 'access', _9 => _9.transactionOptions, 'optionalAccess', _10 => _10.allowNestedTransactions]), () => ( false))
|
|
305
|
-
),
|
|
306
|
-
executor: () => sqliteSQLExecutor(options.driverType)
|
|
307
|
-
});
|
|
308
|
-
};
|
|
309
|
-
function sqliteConnection(options) {
|
|
310
|
-
return options.type === "Client" ? sqliteClientConnection(options) : sqlitePoolClientConnection(options);
|
|
311
|
-
}
|
|
312
|
-
var InMemorySQLiteDatabase = SQLiteConnectionString2(":memory:");
|
|
313
|
-
|
|
314
|
-
// src/storage/sqlite/core/transactions/index.ts
|
|
315
|
-
var sqliteTransaction = (driverType, connection, allowNestedTransactions) => (getClient, options) => {
|
|
316
|
-
const transactionCounter = transactionNestingCounter();
|
|
317
|
-
allowNestedTransactions = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _11 => _11.allowNestedTransactions]), () => ( allowNestedTransactions));
|
|
318
|
-
return {
|
|
319
|
-
connection: connection(),
|
|
320
|
-
driverType,
|
|
321
|
-
begin: async function() {
|
|
322
|
-
const client = await getClient;
|
|
323
|
-
if (allowNestedTransactions) {
|
|
324
|
-
if (transactionCounter.level >= 1) {
|
|
325
|
-
transactionCounter.increment();
|
|
326
|
-
await client.query(
|
|
327
|
-
_chunkOJ34O3Q2cjs.SQL`SAVEPOINT transaction${_chunkOJ34O3Q2cjs.SQL.plain(transactionCounter.level.toString())}`
|
|
328
|
-
);
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
transactionCounter.increment();
|
|
332
|
-
}
|
|
333
|
-
await client.query(_chunkOJ34O3Q2cjs.SQL`BEGIN TRANSACTION`);
|
|
334
|
-
},
|
|
335
|
-
commit: async function() {
|
|
336
|
-
const client = await getClient;
|
|
337
|
-
try {
|
|
338
|
-
if (allowNestedTransactions) {
|
|
339
|
-
if (transactionCounter.level > 1) {
|
|
340
|
-
await client.query(
|
|
341
|
-
_chunkOJ34O3Q2cjs.SQL`RELEASE transaction${_chunkOJ34O3Q2cjs.SQL.plain(transactionCounter.level.toString())}`
|
|
342
|
-
);
|
|
343
|
-
transactionCounter.decrement();
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
transactionCounter.reset();
|
|
347
|
-
}
|
|
348
|
-
await client.query(_chunkOJ34O3Q2cjs.SQL`COMMIT`);
|
|
349
|
-
} finally {
|
|
350
|
-
if (_optionalChain([options, 'optionalAccess', _12 => _12.close]))
|
|
351
|
-
await _optionalChain([options, 'optionalAccess', _13 => _13.close, 'call', _14 => _14(
|
|
352
|
-
client
|
|
353
|
-
)]);
|
|
354
|
-
}
|
|
355
|
-
},
|
|
356
|
-
rollback: async function(error) {
|
|
357
|
-
const client = await getClient;
|
|
358
|
-
try {
|
|
359
|
-
if (allowNestedTransactions) {
|
|
360
|
-
if (transactionCounter.level > 1) {
|
|
361
|
-
transactionCounter.decrement();
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
await client.query(_chunkOJ34O3Q2cjs.SQL`ROLLBACK`);
|
|
366
|
-
} finally {
|
|
367
|
-
if (_optionalChain([options, 'optionalAccess', _15 => _15.close]))
|
|
368
|
-
await _optionalChain([options, 'optionalAccess', _16 => _16.close, 'call', _17 => _17(
|
|
369
|
-
client,
|
|
370
|
-
error
|
|
371
|
-
)]);
|
|
372
|
-
}
|
|
373
|
-
},
|
|
374
|
-
execute: _chunkOJ34O3Q2cjs.sqlExecutor.call(void 0, sqliteSQLExecutor(driverType), {
|
|
375
|
-
connect: () => getClient
|
|
376
|
-
})
|
|
377
|
-
};
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
exports.sqliteFormatter = sqliteFormatter; exports.sqliteExecute = sqliteExecute; exports.sqliteSQLExecutor = sqliteSQLExecutor; exports.sqliteTransaction = sqliteTransaction; exports.SQLiteConnectionString = SQLiteConnectionString2; exports.isSQLiteError = isSQLiteError; exports.transactionNestingCounter = transactionNestingCounter; exports.sqliteAmbientClientConnection = sqliteAmbientClientConnection; exports.sqliteClientConnection = sqliteClientConnection; exports.sqlitePoolClientConnection = sqlitePoolClientConnection; exports.sqliteConnection = sqliteConnection; exports.InMemorySQLiteDatabase = InMemorySQLiteDatabase; exports.isInMemoryDatabase = isInMemoryDatabase; exports.sqliteAmbientConnectionPool = sqliteAmbientConnectionPool; exports.sqliteSingletonConnectionPool = sqliteSingletonConnectionPool; exports.sqliteAlwaysNewConnectionPool = sqliteAlwaysNewConnectionPool; exports.toSqlitePoolOptions = toSqlitePoolOptions; exports.sqlitePool = sqlitePool; exports.DefaultSQLiteMigratorOptions = DefaultSQLiteMigratorOptions; exports.defaultPostgreSqlDatabase = defaultPostgreSqlDatabase; exports.tableExistsSQL = tableExistsSQL; exports.tableExists = tableExists; exports.SQLiteDatabaseName = SQLiteDatabaseName;
|
|
405
|
-
//# sourceMappingURL=chunk-IYEHOE4S.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/chunk-IYEHOE4S.cjs","../src/storage/sqlite/core/sql/processors/columProcessors.ts","../src/storage/sqlite/core/sql/formatter/index.ts","../src/storage/sqlite/core/execute/execute.ts","../src/storage/sqlite/core/pool/pool.ts","../src/storage/sqlite/core/schema/migrations.ts","../src/storage/sqlite/core/schema/schema.ts","../src/storage/sqlite/core/index.ts","../src/storage/sqlite/core/connections/connectionString.ts","../src/storage/sqlite/core/connections/index.ts","../src/storage/sqlite/core/transactions/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACZA,IAAM,cAAA,EAAgB,CACpB,KAAA,EACA,EAAE,QAAQ,CAAA,EAAA,GACD;AACT,EAAA,IAAI,SAAA;AACJ,EAAA,MAAM,EAA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;AAUwB;AAGlB,EAAA;AACN;AAGuE;AT9CY;AACA;AUhS/E;AAQqD,EAAA;AAEf,EAAA;AAE/B,EAAA;AACkB,IAAA;AACvB,IAAA;AACyB,IAAA;AACD,MAAA;AAEO,MAAA;AACQ,QAAA;AACJ,UAAA;AAChB,UAAA;AAC4D,YAAA;AACzE,UAAA;AACA,UAAA;AACF,QAAA;AAE6B,QAAA;AAC/B,MAAA;AAEyC,MAAA;AAC3C,IAAA;AAC0B,IAAA;AACF,MAAA;AAElB,MAAA;AAC2B,QAAA;AACO,UAAA;AACnB,YAAA;AAC0D,cAAA;AACvE,YAAA;AAC6B,YAAA;AAE7B,YAAA;AACF,UAAA;AAEyB,UAAA;AAC3B,QAAA;AAC8B,QAAA;AAC9B,MAAA;AACa,QAAA;AACI,UAAA;AACb,YAAA;AACF,UAAA;AACJ,MAAA;AACF,IAAA;AAC2C,IAAA;AACnB,MAAA;AAClB,MAAA;AAC2B,QAAA;AACO,UAAA;AACH,YAAA;AAC7B,YAAA;AACF,UAAA;AACF,QAAA;AAEgC,QAAA;AAChC,MAAA;AACa,QAAA;AACI,UAAA;AACb,YAAA;AACA,YAAA;AACF,UAAA;AACJ,MAAA;AACF,IAAA;AACoD,IAAA;AACnC,MAAA;AAChB,IAAA;AACH,EAAA;AACF;AVkRiF;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/chunk-IYEHOE4S.cjs","sourcesContent":[null,"import {\n mapDefaultSQLColumnProcessors,\n type DefaultSQLColumnProcessors,\n type DefaultSQLColumnToken,\n type SQLProcessorContext,\n} from '../../../../../core';\n\nconst mapColumnType = (\n token: DefaultSQLColumnToken,\n { builder }: SQLProcessorContext,\n): void => {\n let columnSQL: string;\n const { sqlTokenType } = token;\n switch (sqlTokenType) {\n case 'SQL_COLUMN_AUTO_INCREMENT':\n columnSQL = `INTEGER ${token.primaryKey ? 'PRIMARY KEY' : ''} AUTOINCREMENT`;\n break;\n case 'SQL_COLUMN_BIGINT':\n columnSQL = 'INTEGER';\n break;\n case 'SQL_COLUMN_SERIAL':\n columnSQL = 'INTEGER';\n break;\n case 'SQL_COLUMN_INTEGER':\n columnSQL = 'INTEGER';\n break;\n case 'SQL_COLUMN_JSONB':\n columnSQL = 'BLOB';\n break;\n case 'SQL_COLUMN_BIGSERIAL':\n columnSQL = 'INTEGER';\n break;\n case 'SQL_COLUMN_TIMESTAMP':\n columnSQL = 'DATETIME';\n break;\n case 'SQL_COLUMN_TIMESTAMPTZ':\n columnSQL = 'DATETIME';\n break;\n case 'SQL_COLUMN_VARCHAR':\n columnSQL = `VARCHAR ${Number.isNaN(token.length) ? '' : `(${token.length})`}`;\n break;\n default: {\n const exhaustiveCheck: never = sqlTokenType;\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n throw new Error(`Unknown column type: ${exhaustiveCheck}`);\n }\n }\n builder.addSQL(columnSQL);\n};\n\nexport const sqliteColumnProcessors: DefaultSQLColumnProcessors =\n mapDefaultSQLColumnProcessors(mapColumnType);\n","import {\n defaultProcessorsRegistry,\n registerFormatter,\n SQLFormatter,\n SQLProcessorsRegistry,\n} from '../../../../../core/sql';\nimport { sqliteColumnProcessors } from '../processors';\n\nconst sqliteSQLProcessorsRegistry = SQLProcessorsRegistry({\n from: defaultProcessorsRegistry,\n}).register(sqliteColumnProcessors);\n\nconst sqliteFormatter: SQLFormatter = SQLFormatter({\n processorsRegistry: sqliteSQLProcessorsRegistry,\n});\n\nregisterFormatter('SQLite', sqliteFormatter);\n\nexport { sqliteFormatter };\n","import type { SQLiteDriverType } from '..';\nimport {\n mapSQLQueryResult,\n SQL,\n SQLFormatter,\n tracer,\n type DbSQLExecutor,\n type QueryResult,\n type QueryResultRow,\n type SQLCommandOptions,\n type SQLQueryOptions,\n} from '../../../../core';\nimport type { SQLiteClient } from '../connections';\nimport { sqliteFormatter } from '../sql/formatter';\n\nexport const sqliteExecute = async <Result = void>(\n database: SQLiteClient,\n handle: (client: SQLiteClient) => Promise<Result>,\n) => {\n try {\n return await handle(database);\n } finally {\n await database.close();\n }\n};\n\nexport type SQLiteSQLExecutor<\n DriverType extends SQLiteDriverType = SQLiteDriverType,\n> = DbSQLExecutor<DriverType, SQLiteClient>;\n\nexport const sqliteSQLExecutor = <\n DriverType extends SQLiteDriverType = SQLiteDriverType,\n>(\n driverType: DriverType,\n formatter?: SQLFormatter,\n): SQLiteSQLExecutor<DriverType> => ({\n driverType,\n query: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sql: SQL,\n options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>> => {\n if (options?.timeoutMs) {\n await client.query(SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);\n }\n\n tracer.info('db:sql:query', {\n query: (formatter ?? sqliteFormatter).format(sql).query,\n params: (formatter ?? sqliteFormatter).format(sql).params,\n debugSQL: (formatter ?? sqliteFormatter).describe(sql),\n });\n\n let result = await client.query<Result>(sql, options);\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 return result;\n },\n batchQuery: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sqls: SQL[],\n options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>[]> => {\n if (options?.timeoutMs) {\n await client.query(SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);\n }\n\n const results = await client.batchQuery<Result>(sqls, options);\n\n if (options?.mapping) {\n return results.map((result) => ({\n ...result,\n rows: result.rows.map((row) =>\n mapSQLQueryResult(row, options.mapping!),\n ),\n }));\n }\n\n return results;\n },\n command: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sql: SQL,\n options?: SQLCommandOptions,\n ): Promise<QueryResult<Result>> => {\n if (options?.timeoutMs) {\n await client.query(SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);\n }\n\n tracer.info('db:sql:command', {\n query: (formatter ?? sqliteFormatter).format(sql).query,\n params: (formatter ?? sqliteFormatter).format(sql).params,\n debugSQL: (formatter ?? sqliteFormatter).describe(sql),\n });\n\n return await client.command<Result>(sql, options);\n },\n batchCommand: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sqls: SQL[],\n options?: SQLCommandOptions,\n ): Promise<QueryResult<Result>[]> => {\n if (options?.timeoutMs) {\n await client.query(SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);\n }\n\n return await client.batchCommand<Result>(sqls, options);\n },\n formatter: formatter ?? sqliteFormatter,\n});\n","import {\n InMemorySQLiteDatabase,\n SQLiteConnectionString,\n type AnySQLiteConnection,\n type SQLiteConnectionFactory,\n type SQLiteConnectionOptions,\n} from '..';\nimport {\n createAlwaysNewConnectionPool,\n createAmbientConnectionPool,\n createSingletonConnectionPool,\n JSONSerializer,\n type ConnectionPool,\n} from '../../../../core';\n\nexport type SQLiteFileNameOrConnectionString =\n | {\n fileName: string | SQLiteConnectionString;\n connectionString?: never;\n }\n | {\n connectionString: string | SQLiteConnectionString;\n fileName?: never;\n };\n\nexport const isInMemoryDatabase = (\n options: Record<string, unknown>,\n): boolean => {\n if ('fileName' in options) {\n return options.fileName === InMemorySQLiteDatabase;\n }\n if ('connectionString' in options) {\n return options.connectionString === InMemorySQLiteDatabase;\n }\n return false;\n};\n\nexport type SQLiteAmbientConnectionPool<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = ConnectionPool<SQLiteConnectionType>;\n\ntype SQLiteAmbientConnectionPoolOptions<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = {\n singleton?: true;\n pooled?: false;\n sqliteConnectionFactory?: never;\n connection: SQLiteConnectionType;\n connectionOptions?: never;\n};\n\nexport const sqliteAmbientConnectionPool = <\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n>(\n options: {\n driverType: SQLiteConnectionType['driverType'];\n } & SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType['driverType']>,\n): SQLiteAmbientConnectionPool<SQLiteConnectionType['driverType']> => {\n const { connection, driverType } = options;\n\n return createAmbientConnectionPool<SQLiteConnectionType>({\n driverType,\n connection: connection,\n });\n};\n\ntype SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions,\n> = {\n singleton: true;\n pooled?: true;\n sqliteConnectionFactory: SQLiteConnectionFactory<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n connection?: never;\n connectionOptions: ConnectionOptions;\n};\n\nexport type SQLiteSingletonConnectionPool<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = ConnectionPool<SQLiteConnectionType>;\n\nexport const sqliteSingletonConnectionPool = <\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions &\n Record<string, unknown> = SQLiteConnectionOptions & Record<string, unknown>,\n>(\n options: {\n driverType: SQLiteConnectionType['driverType'];\n } & SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >,\n): SQLiteSingletonConnectionPool<SQLiteConnectionType> => {\n const { driverType, sqliteConnectionFactory, connectionOptions } = options;\n\n return createSingletonConnectionPool<SQLiteConnectionType>({\n driverType,\n getConnection: () => sqliteConnectionFactory(connectionOptions),\n });\n};\n\ntype SQLiteAlwaysNewPoolOptions<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions,\n> = {\n singleton?: false;\n pooled?: true;\n sqliteConnectionFactory: SQLiteConnectionFactory<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n connection?: never;\n connectionOptions: ConnectionOptions;\n};\n\nexport type SQLiteAlwaysNewConnectionPool<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = ConnectionPool<SQLiteConnectionType>;\n\nexport const sqliteAlwaysNewConnectionPool = <\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions &\n Record<string, unknown> = SQLiteConnectionOptions & Record<string, unknown>,\n>(\n options: {\n driverType: SQLiteConnectionType['driverType'];\n } & SQLiteAlwaysNewPoolOptions<SQLiteConnectionType, ConnectionOptions>,\n): SQLiteAlwaysNewConnectionPool<SQLiteConnectionType> => {\n const { driverType, sqliteConnectionFactory, connectionOptions } = options;\n\n return createAlwaysNewConnectionPool<SQLiteConnectionType>({\n driverType,\n getConnection: () => sqliteConnectionFactory(connectionOptions),\n });\n};\n\nexport type SQLitePoolOptions<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions,\n> = (\n | SQLiteAlwaysNewPoolOptions<SQLiteConnectionType, ConnectionOptions>\n | SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >\n | SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType>\n) & {\n driverType: SQLiteConnectionType['driverType'];\n serializer?: JSONSerializer;\n};\n\nexport type SQLitePool<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> =\n | SQLiteAmbientConnectionPool<SQLiteConnectionType>\n | SQLiteSingletonConnectionPool<SQLiteConnectionType>\n | SQLiteAlwaysNewConnectionPool<SQLiteConnectionType>;\n\nexport type SQLitePoolFactoryOptions<\n SQLiteConnectionType extends AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions,\n> = Omit<\n SQLitePoolOptions<SQLiteConnectionType, ConnectionOptions>,\n 'singleton'\n> & {\n singleton?: boolean;\n};\n\nexport const toSqlitePoolOptions = <\n SQLiteConnectionType extends AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions,\n>(\n options: SQLitePoolFactoryOptions<SQLiteConnectionType, ConnectionOptions>,\n): SQLitePoolOptions<SQLiteConnectionType, ConnectionOptions> => {\n const { singleton, ...rest } = options;\n const useSingleton = singleton ?? isInMemoryDatabase(options);\n\n if (useSingleton) {\n return { ...rest, singleton: true } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n }\n return { ...rest, singleton: false } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n};\n\nexport function sqlitePool<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions,\n>(\n options: SQLitePoolOptions<SQLiteConnectionType, ConnectionOptions>,\n): SQLitePool<SQLiteConnectionType> {\n const { driverType } = options;\n\n // TODO: Handle dates and bigints\n // setSQLiteTypeParser(serializer ?? JSONSerializer);\n\n if (options.connection)\n return createAmbientConnectionPool<SQLiteConnectionType>({\n driverType,\n connection: options.connection,\n });\n\n if (options.singleton === true && options.sqliteConnectionFactory) {\n return createSingletonConnectionPool({\n driverType,\n getConnection: () =>\n options.sqliteConnectionFactory(options.connectionOptions),\n });\n }\n\n return createAlwaysNewConnectionPool({\n driverType,\n getConnection: () =>\n options.sqliteConnectionFactory!(options.connectionOptions!),\n });\n}\n","import {\n registerDefaultMigratorOptions,\n type MigratorOptions,\n} from '../../../../core';\n\nexport const DefaultSQLiteMigratorOptions: MigratorOptions = {};\n\nregisterDefaultMigratorOptions('SQLite', DefaultSQLiteMigratorOptions);\n","import { exists, SQL, type ConnectionPool } from '../../../../core';\nexport * from './schema';\n\nexport const defaultPostgreSqlDatabase = 'postgres';\n\nexport const tableExistsSQL = (tableName: string): SQL =>\n SQL`\n SELECT EXISTS (\n SELECT 1\n FROM sqlite_master\n WHERE type = 'table' AND name = ${tableName}\n ) AS \"exists\"\n `;\n\nexport const tableExists = async (\n pool: ConnectionPool,\n tableName: string,\n): Promise<boolean> => exists(pool.execute.query(tableExistsSQL(tableName)));\n","import { type DatabaseDriverType } from '../../..';\n\nexport * from './connections';\nexport * from './execute';\nexport * from './pool';\nexport * from './schema';\nexport * from './sql';\nexport * from './transactions';\n\nexport type SQLiteDatabaseName = 'SQLite';\nexport const SQLiteDatabaseName = 'SQLite';\n\nexport type SQLiteDriverType<DriverName extends string = string> =\n DatabaseDriverType<SQLiteDatabaseName, DriverName>;\n\nexport type SQLiteDatabaseType = 'SQLite';\n","import type { DatabaseConnectionString } from '../../../all';\n\nexport type SQLiteConnectionString = DatabaseConnectionString<\n 'SQLite',\n `file:${string}` | `:memory:` | `/${string}` | `./${string}`\n>;\n\nexport const SQLiteConnectionString = (\n connectionString: string,\n): SQLiteConnectionString => {\n if (\n !connectionString.startsWith('file:') &&\n connectionString !== ':memory:' &&\n !connectionString.startsWith('/') &&\n !connectionString.startsWith('./')\n ) {\n throw new Error(\n `Invalid SQLite connection string: ${connectionString}. It should start with \"file:\", \":memory:\", \"/\", or \"./\".`,\n );\n }\n return connectionString as SQLiteConnectionString;\n};\n","import {\n SQLiteConnectionString,\n sqliteSQLExecutor,\n type SQLiteDriverType,\n} from '..';\nimport {\n createAmbientConnection,\n createConnection,\n type AnyConnection,\n type Connection,\n type ConnectionOptions,\n type DatabaseTransaction,\n type DatabaseTransactionOptions,\n type InferDbClientFromConnection,\n type InferDriverTypeFromConnection,\n type InitTransaction,\n type SQLCommandOptions,\n type SQLExecutor,\n} from '../../../../core';\nimport { sqliteTransaction } from '../transactions';\n\nexport type SQLiteCommandOptions = SQLCommandOptions & {\n ignoreChangesCount?: boolean;\n};\n\nexport type SQLiteParameters =\n | object\n | string\n | bigint\n | number\n | boolean\n | null;\n\nexport type SQLiteClient = {\n connect: () => Promise<void>;\n close: () => Promise<void>;\n} & SQLExecutor;\n\nexport type SQLitePoolClient = {\n release: () => void;\n} & SQLExecutor;\n\nexport type SQLiteClientFactory<\n SQLiteClientType extends SQLiteClient = SQLiteClient,\n ClientOptions = SQLiteClientOptions,\n> = (options: ClientOptions) => SQLiteClientType;\n\nexport type SQLiteClientOrPoolClient = SQLitePoolClient | SQLiteClient;\n\nexport interface SQLiteError extends Error {\n errno: number;\n}\n\nexport const isSQLiteError = (error: unknown): error is SQLiteError => {\n if (error instanceof Error && 'code' in error) {\n return true;\n }\n\n return false;\n};\n\nexport type SQLiteClientConnection<\n Self extends AnyConnection = AnyConnection,\n DriverType extends SQLiteDriverType = SQLiteDriverType,\n SQLiteClientType extends SQLiteClient = SQLiteClient,\n TransactionType extends DatabaseTransaction<Self> = DatabaseTransaction<Self>,\n TransactionOptionsType extends\n DatabaseTransactionOptions = DatabaseTransactionOptions,\n> = Connection<\n Self,\n DriverType,\n SQLiteClientType,\n TransactionType,\n TransactionOptionsType\n>;\n\nexport type SQLitePoolClientConnection<\n Self extends AnyConnection = AnyConnection,\n DriverType extends SQLiteDriverType = SQLiteDriverType,\n SQLitePoolClientType extends SQLitePoolClient = SQLitePoolClient,\n TransactionType extends DatabaseTransaction<Self> = DatabaseTransaction<Self>,\n TransactionOptionsType extends\n DatabaseTransactionOptions = DatabaseTransactionOptions,\n> = Connection<\n Self,\n DriverType,\n SQLitePoolClientType,\n TransactionType,\n TransactionOptionsType\n>;\n\nexport type SQLiteConnection<\n Self extends AnyConnection = AnyConnection,\n DriverType extends SQLiteDriverType = SQLiteDriverType,\n SQLiteClientType extends SQLiteClientOrPoolClient =\n | SQLiteClient\n | SQLitePoolClient,\n TransactionType extends DatabaseTransaction<Self> = DatabaseTransaction<Self>,\n TransactionOptionsType extends\n DatabaseTransactionOptions = DatabaseTransactionOptions,\n> =\n | (SQLiteClientType extends SQLiteClient\n ? SQLiteClientConnection<\n Self,\n DriverType,\n SQLiteClientType,\n TransactionType,\n TransactionOptionsType\n >\n : never)\n | (SQLiteClientType extends SQLitePoolClient\n ? SQLitePoolClientConnection<\n Self,\n DriverType,\n SQLiteClientType,\n TransactionType,\n TransactionOptionsType\n >\n : never);\n\nexport type AnySQLiteClientConnection =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n SQLiteClientConnection<any, any>;\n\nexport type AnySQLitePoolClientConnection =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n SQLitePoolClientConnection<any, any, any, any, any>;\n\nexport type AnySQLiteConnection =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n SQLiteConnection<any, any, any, any, any>;\n\nexport type SQLiteConnectionOptions<\n ConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = ConnectionOptions<ConnectionType> & SQLiteClientOptions;\n\nexport type SQLiteClientConnectionDefinitionOptions<\n SQLiteConnectionType extends\n AnySQLiteClientConnection = AnySQLiteClientConnection,\n ConnectionOptions = SQLiteConnectionOptions,\n> = {\n driverType: InferDriverTypeFromConnection<SQLiteConnectionType>;\n type: 'Client';\n sqliteClientFactory: SQLiteClientFactory<\n InferDbClientFromConnection<SQLiteConnectionType>,\n ConnectionOptions\n >;\n connectionOptions: SQLiteConnectionOptions<SQLiteConnectionType>;\n};\n\nexport type SQLitePoolConnectionDefinitionOptions<\n SQLiteConnectionType extends\n AnySQLitePoolClientConnection = AnySQLitePoolClientConnection,\n ConnectionOptions = SQLiteConnectionOptions,\n> = {\n driverType: InferDriverTypeFromConnection<SQLiteConnectionType>;\n type: 'PoolClient';\n sqliteClientFactory: SQLiteClientFactory<\n InferDbClientFromConnection<SQLiteConnectionType>,\n ConnectionOptions\n >;\n connectionOptions: SQLiteConnectionOptions<SQLiteConnectionType>;\n};\n\nexport type SQLiteConnectionDefinitionOptions<\n SQLiteConnectionType extends\n AnySQLitePoolClientConnection = AnySQLitePoolClientConnection,\n ClientOptions = SQLiteClientOptions,\n> =\n | SQLiteClientConnectionDefinitionOptions<SQLiteConnectionType, ClientOptions>\n | SQLitePoolConnectionDefinitionOptions<SQLiteConnectionType, ClientOptions>;\n\nexport type SQLiteConnectionFactory<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions,\n> = (options: ConnectionOptions) => SQLiteConnectionType;\n\nexport type TransactionNestingCounter = {\n increment: () => void;\n decrement: () => void;\n reset: () => void;\n level: number;\n};\n\nexport const transactionNestingCounter = (): TransactionNestingCounter => {\n let transactionLevel = 0;\n\n return {\n reset: () => {\n transactionLevel = 0;\n },\n increment: () => {\n transactionLevel++;\n },\n decrement: () => {\n transactionLevel--;\n\n if (transactionLevel < 0) {\n throw new Error('Transaction level is out of bounds');\n }\n },\n get level() {\n return transactionLevel;\n },\n };\n};\n\nexport type SqliteAmbientClientConnectionOptions<\n SQLiteConnectionType extends\n AnySQLiteClientConnection = AnySQLiteClientConnection,\n TransactionType extends\n DatabaseTransaction<SQLiteConnectionType> = DatabaseTransaction<SQLiteConnectionType>,\n TransactionOptionsType extends\n DatabaseTransactionOptions = DatabaseTransactionOptions,\n> = {\n driverType: SQLiteConnectionType['driverType'];\n client: InferDbClientFromConnection<SQLiteConnectionType>;\n initTransaction?: InitTransaction<\n SQLiteConnectionType,\n TransactionType,\n TransactionOptionsType\n >;\n allowNestedTransactions?: boolean;\n};\n\nexport const sqliteAmbientClientConnection = <\n SQLiteConnectionType extends\n AnySQLiteClientConnection = AnySQLiteClientConnection,\n>(\n options: SqliteAmbientClientConnectionOptions<SQLiteConnectionType>,\n) => {\n const { client, driverType, initTransaction, allowNestedTransactions } =\n options;\n\n return createAmbientConnection<SQLiteConnectionType>({\n driverType,\n client,\n initTransaction:\n initTransaction ??\n ((connection) =>\n sqliteTransaction(\n driverType,\n connection,\n allowNestedTransactions ?? false,\n )),\n executor: () => sqliteSQLExecutor(driverType),\n });\n};\n\nexport const sqliteClientConnection = <\n SQLiteConnectionType extends\n AnySQLiteClientConnection = AnySQLiteClientConnection,\n ClientOptions = SQLiteClientOptions,\n>(\n options: SQLiteClientConnectionDefinitionOptions<\n SQLiteConnectionType,\n ClientOptions\n >,\n): SQLiteConnectionType => {\n const { connectionOptions, sqliteClientFactory } = options;\n\n let client: InferDbClientFromConnection<SQLiteConnectionType> | null = null;\n\n const connect = async (): Promise<\n InferDbClientFromConnection<SQLiteConnectionType>\n > => {\n if (client) return Promise.resolve(client);\n\n client = sqliteClientFactory(connectionOptions as ClientOptions);\n\n if (client && 'connect' in client && typeof client.connect === 'function')\n await client.connect();\n\n return client;\n };\n\n return createConnection({\n driverType: options.driverType,\n connect,\n close: async () => {\n if (client && 'close' in client && typeof client.close === 'function')\n await client.close();\n else if (\n client &&\n 'release' in client &&\n typeof client.release === 'function'\n )\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n client.release();\n },\n initTransaction: (connection) =>\n sqliteTransaction(\n options.driverType,\n connection,\n connectionOptions.transactionOptions?.allowNestedTransactions ?? false,\n ),\n executor: () => sqliteSQLExecutor(options.driverType),\n });\n};\n\nexport const sqlitePoolClientConnection = <\n SQLiteConnectionType extends\n AnySQLiteClientConnection = AnySQLiteClientConnection,\n ClientOptions = SQLiteClientOptions,\n>(\n options: SQLitePoolConnectionDefinitionOptions<\n SQLiteConnectionType,\n ClientOptions\n >,\n): SQLiteConnectionType => {\n const { connectionOptions, sqliteClientFactory } = options;\n\n let client: InferDbClientFromConnection<SQLiteConnectionType> | null = null;\n\n const connect = async (): Promise<\n InferDbClientFromConnection<SQLiteConnectionType>\n > => {\n if (client) return Promise.resolve(client);\n\n client = sqliteClientFactory(connectionOptions as ClientOptions);\n\n await client.connect();\n\n return client;\n };\n\n return createConnection({\n driverType: options.driverType,\n connect,\n close: () =>\n client !== null\n ? Promise.resolve((client as unknown as SQLitePoolClient).release())\n : Promise.resolve(),\n initTransaction: (connection) =>\n sqliteTransaction(\n options.driverType,\n connection,\n connectionOptions.transactionOptions?.allowNestedTransactions ?? false,\n ),\n executor: () => sqliteSQLExecutor(options.driverType),\n });\n};\n\nexport function sqliteConnection<\n SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n ClientOptions = SQLiteClientOptions,\n>(\n options: SQLiteConnectionDefinitionOptions<\n SQLiteConnectionType,\n ClientOptions\n >,\n): SQLiteConnectionType {\n return options.type === 'Client'\n ? sqliteClientConnection(options)\n : sqlitePoolClientConnection(options);\n}\n\nexport type InMemorySQLiteDatabase = ':memory:';\nexport const InMemorySQLiteDatabase = SQLiteConnectionString(':memory:');\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport type SQLiteClientOptions = {};\n\nexport * from './connectionString';\n","import {\n SQL,\n sqlExecutor,\n type DatabaseTransaction,\n type DatabaseTransactionOptions,\n type InferDbClientFromConnection,\n} from '../../../../core';\nimport { sqliteSQLExecutor } from '../../core/execute';\nimport {\n transactionNestingCounter,\n type AnySQLiteConnection,\n type SQLiteClientOrPoolClient,\n} from '../connections';\n\nexport type SQLiteTransaction<\n ConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = DatabaseTransaction<ConnectionType>;\n\nexport const sqliteTransaction =\n <ConnectionType extends AnySQLiteConnection = AnySQLiteConnection>(\n driverType: ConnectionType['driverType'],\n connection: () => ConnectionType,\n allowNestedTransactions: boolean,\n ) =>\n (\n getClient: Promise<InferDbClientFromConnection<ConnectionType>>,\n options?: {\n close: (\n client: InferDbClientFromConnection<ConnectionType>,\n error?: unknown,\n ) => Promise<void>;\n } & DatabaseTransactionOptions,\n ): DatabaseTransaction<ConnectionType> => {\n const transactionCounter = transactionNestingCounter();\n allowNestedTransactions =\n options?.allowNestedTransactions ?? allowNestedTransactions;\n\n return {\n connection: connection(),\n driverType,\n begin: async function () {\n const client = (await getClient) as SQLiteClientOrPoolClient;\n\n if (allowNestedTransactions) {\n if (transactionCounter.level >= 1) {\n transactionCounter.increment();\n await client.query(\n SQL`SAVEPOINT transaction${SQL.plain(transactionCounter.level.toString())}`,\n );\n return;\n }\n\n transactionCounter.increment();\n }\n\n await client.query(SQL`BEGIN TRANSACTION`);\n },\n commit: async function () {\n const client = (await getClient) as SQLiteClientOrPoolClient;\n\n try {\n if (allowNestedTransactions) {\n if (transactionCounter.level > 1) {\n await client.query(\n SQL`RELEASE transaction${SQL.plain(transactionCounter.level.toString())}`,\n );\n transactionCounter.decrement();\n\n return;\n }\n\n transactionCounter.reset();\n }\n await client.query(SQL`COMMIT`);\n } finally {\n if (options?.close)\n await options?.close(\n client as InferDbClientFromConnection<ConnectionType>,\n );\n }\n },\n rollback: async function (error?: unknown) {\n const client = (await getClient) as SQLiteClientOrPoolClient;\n try {\n if (allowNestedTransactions) {\n if (transactionCounter.level > 1) {\n transactionCounter.decrement();\n return;\n }\n }\n\n await client.query(SQL`ROLLBACK`);\n } finally {\n if (options?.close)\n await options?.close(\n client as InferDbClientFromConnection<ConnectionType>,\n error,\n );\n }\n },\n execute: sqlExecutor(sqliteSQLExecutor(driverType), {\n connect: () => getClient,\n }),\n };\n };\n"]}
|