@event-driven-io/dumbo 0.13.0-beta.21 → 0.13.0-beta.23
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-FC4JR2R3.js → chunk-56QRSCG5.js} +2 -2
- package/dist/{chunk-65DKXURG.js → chunk-5OX6NE4Z.js} +2 -2
- package/dist/{chunk-IVJ3SNPJ.js → chunk-5SCFH2HY.js} +2 -2
- package/dist/{chunk-AMACBMAZ.cjs → chunk-7D7WADBK.cjs} +186 -98
- package/dist/chunk-7D7WADBK.cjs.map +1 -0
- package/dist/{chunk-H7ZKIJHB.cjs → chunk-7RMJPFU5.cjs} +6 -6
- package/dist/{chunk-H7ZKIJHB.cjs.map → chunk-7RMJPFU5.cjs.map} +1 -1
- package/dist/{chunk-7WEBHXZD.cjs → chunk-HXQYRDCR.cjs} +43 -43
- package/dist/{chunk-7WEBHXZD.cjs.map → chunk-HXQYRDCR.cjs.map} +1 -1
- package/dist/{chunk-T4A6BQRA.js → chunk-LPIIB75Q.js} +120 -32
- package/dist/chunk-LPIIB75Q.js.map +1 -0
- package/dist/{chunk-XO5T5N5S.js → chunk-QUAG4MBP.js} +294 -14
- package/dist/chunk-QUAG4MBP.js.map +1 -0
- package/dist/{chunk-XOQHZABK.cjs → chunk-QVEVSWG6.cjs} +307 -27
- package/dist/chunk-QVEVSWG6.cjs.map +1 -0
- package/dist/{chunk-R7P7CNMK.cjs → chunk-TMFEMKPE.cjs} +4 -4
- package/dist/{chunk-R7P7CNMK.cjs.map → chunk-TMFEMKPE.cjs.map} +1 -1
- package/dist/cloudflare.cjs +66 -61
- package/dist/cloudflare.cjs.map +1 -1
- package/dist/cloudflare.d.cts +4 -4
- package/dist/cloudflare.d.ts +4 -4
- package/dist/cloudflare.js +9 -4
- package/dist/cloudflare.js.map +1 -1
- package/dist/{columnProcessors-Difrrk4c.d.cts → columnProcessors-CsQjv8si.d.cts} +1 -1
- package/dist/{columnProcessors-C7fRa54L.d.ts → columnProcessors-giHzjHuv.d.ts} +1 -1
- package/dist/{connectionString-oeg1LD5V.d.ts → connectionString-J4yRT71A.d.cts} +40 -31
- package/dist/{connectionString-oeg1LD5V.d.cts → connectionString-J4yRT71A.d.ts} +40 -31
- package/dist/index.cjs +7 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/pg.cjs +39 -38
- package/dist/pg.cjs.map +1 -1
- package/dist/pg.d.cts +7 -7
- package/dist/pg.d.ts +7 -7
- package/dist/pg.js +5 -4
- package/dist/pg.js.map +1 -1
- package/dist/postgresql.cjs +4 -4
- package/dist/postgresql.d.cts +2 -2
- package/dist/postgresql.d.ts +2 -2
- package/dist/postgresql.js +3 -3
- package/dist/sqlite.cjs +8 -4
- package/dist/sqlite.cjs.map +1 -1
- package/dist/sqlite.d.cts +49 -23
- package/dist/sqlite.d.ts +49 -23
- package/dist/sqlite.js +7 -3
- package/dist/sqlite3.cjs +65 -28
- package/dist/sqlite3.cjs.map +1 -1
- package/dist/sqlite3.d.cts +11 -11
- package/dist/sqlite3.d.ts +11 -11
- package/dist/sqlite3.js +48 -11
- package/dist/sqlite3.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-AMACBMAZ.cjs.map +0 -1
- package/dist/chunk-T4A6BQRA.js.map +0 -1
- package/dist/chunk-XO5T5N5S.js.map +0 -1
- package/dist/chunk-XOQHZABK.cjs.map +0 -1
- /package/dist/{chunk-FC4JR2R3.js.map → chunk-56QRSCG5.js.map} +0 -0
- /package/dist/{chunk-65DKXURG.js.map → chunk-5OX6NE4Z.js.map} +0 -0
- /package/dist/{chunk-IVJ3SNPJ.js.map → chunk-5SCFH2HY.js.map} +0 -0
package/dist/cloudflare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/storage/sqlite/d1/connections/d1Client.ts","../src/storage/sqlite/d1/errors/errorMapper.ts","../src/storage/sqlite/d1/execute/d1SqlExecutor.ts","../src/storage/sqlite/d1/transactions/d1Transaction.ts","../src/storage/sqlite/d1/connections/d1Connection.ts","../src/storage/sqlite/d1/pool/d1ConnectionPool.ts","../src/storage/sqlite/d1/index.ts"],"sourcesContent":["import type {\n D1Database,\n D1DatabaseSession,\n D1SessionBookmark,\n D1SessionConstraint,\n} from '@cloudflare/workers-types';\nimport {\n BatchCommandNoChangesError,\n type BatchSQLCommandOptions,\n type JSONSerializer,\n type QueryResult,\n type QueryResultRow,\n type SQL,\n type SQLCommandOptions,\n type SQLQueryOptions,\n} from '../../../../core';\nimport { sqliteFormatter, type SQLiteClient } from '../../core';\n\nexport type D1DatabaseOrSession = D1Database | D1DatabaseSession;\n\nexport type D1ClientOptions = {\n database: D1Database;\n session?: D1DatabaseSession | undefined;\n serializer: JSONSerializer;\n};\n\nexport type D1SessionOptions = {\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint;\n};\n\nexport type D1Client = SQLiteClient & {\n database: D1Database;\n session?: D1DatabaseSession | undefined;\n\n withSession: (constraintOrBookmark?: D1SessionOptions) => Promise<D1Client>;\n};\n\nexport const d1Client = (options: D1ClientOptions): D1Client => {\n const { database, session, serializer } = options;\n\n const execute = session ?? database;\n\n return {\n database,\n session: session,\n connect: () => Promise.resolve(),\n close: () => Promise.resolve(),\n withSession: async (constraintOrBookmark?: D1SessionOptions) => {\n const newSession = constraintOrBookmark\n ? database.withSession(constraintOrBookmark as string)\n : database.withSession();\n\n return Promise.resolve(\n d1Client({\n database,\n session: newSession,\n serializer,\n }),\n );\n },\n\n query: async <Result extends QueryResultRow = QueryResultRow>(\n sql: SQL,\n _options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>> => {\n const { query, params } = sqliteFormatter.format(sql, { serializer });\n const stmt = execute.prepare(query);\n const bound = params?.length ? stmt.bind(...params) : stmt;\n const { results } = await bound.all<Result>();\n return { rowCount: results?.length ?? 0, rows: results ?? [] };\n },\n\n batchQuery: async <Result extends QueryResultRow = QueryResultRow>(\n sqls: SQL[],\n _options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>[]> => {\n const statements = sqls.map((sql) => {\n const { query, params } = sqliteFormatter.format(sql, { serializer });\n const stmt = execute.prepare(query);\n return params?.length ? stmt.bind(...params) : stmt;\n });\n const results = await execute.batch<Result>(statements);\n return results.map((result) => ({\n rowCount: result.results?.length ?? 0,\n rows: result.results ?? [],\n }));\n },\n\n command: async <Result extends QueryResultRow = QueryResultRow>(\n sql: SQL,\n _options?: SQLCommandOptions,\n ): Promise<QueryResult<Result>> => {\n const { query, params } = sqliteFormatter.format(sql, { serializer });\n const stmt = execute.prepare(query);\n const bound = params?.length ? stmt.bind(...params) : stmt;\n const result = await bound.run<Result>();\n return {\n rowCount: result.meta?.changes ?? 0,\n rows: result.results ?? [],\n };\n },\n\n batchCommand: async <Result extends QueryResultRow = QueryResultRow>(\n sqls: SQL[],\n options?: BatchSQLCommandOptions,\n ): Promise<QueryResult<Result>[]> => {\n const statements = sqls.map((sql) => {\n const { query, params } = sqliteFormatter.format(sql, { serializer });\n const stmt = execute.prepare(query);\n return params?.length ? stmt.bind(...params) : stmt;\n });\n const batchResults = await execute.batch<Result>(statements);\n\n return batchResults.map((result, i) => {\n const qr: QueryResult<Result> = {\n rowCount: result.meta?.changes ?? 0,\n rows: result.results ?? [],\n };\n\n if (options?.assertChanges && (qr.rowCount ?? 0) === 0) {\n throw new BatchCommandNoChangesError(i);\n }\n\n return qr;\n });\n },\n };\n};\n","import {\n CheckViolationError,\n ConnectionError,\n DataError,\n DeadlockError,\n DumboError,\n ForeignKeyViolationError,\n InsufficientResourcesError,\n IntegrityConstraintViolationError,\n InvalidOperationError,\n LockNotAvailableError,\n NotNullViolationError,\n SerializationError,\n SystemError,\n UniqueConstraintError,\n} from '../../../../core/errors';\n\nconst getErrorMessage = (error: unknown): string | undefined =>\n error instanceof Error ? error.message : undefined;\n\nconst asError = (error: unknown): Error | undefined =>\n error instanceof Error ? error : undefined;\n\n/**\n * Determines the constraint subtype from the error message.\n *\n * D1 embeds the SQLite constraint detail in the message string, e.g.:\n * \"D1_ERROR: UNIQUE constraint failed: users.email\"\n * \"D1_ERROR: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed\"\n */\nconst mapConstraintError = (\n message: string | undefined,\n innerError: Error | undefined,\n): DumboError => {\n const upperMessage = message?.toUpperCase() ?? '';\n\n if (upperMessage.includes('UNIQUE') || upperMessage.includes('PRIMARY KEY'))\n return new UniqueConstraintError(message, innerError);\n\n if (upperMessage.includes('FOREIGN KEY'))\n return new ForeignKeyViolationError(message, innerError);\n\n if (upperMessage.includes('NOT NULL'))\n return new NotNullViolationError(message, innerError);\n\n if (upperMessage.includes('CHECK'))\n return new CheckViolationError(message, innerError);\n\n return new IntegrityConstraintViolationError(message, innerError);\n};\n\nconst isConstraintMessage = (upper: string): boolean =>\n upper.includes('CONSTRAINT') ||\n upper.includes('UNIQUE') ||\n upper.includes('PRIMARY KEY') ||\n upper.includes('FOREIGN KEY') ||\n upper.includes('NOT NULL');\n\n/** Extracts the first `SQLITE_<CODE>` token from a message string. */\nconst SQLITE_CODE_RE = /SQLITE_([A-Z]+)/;\n\nconst extractEmbeddedSqliteCode = (message: string): string | undefined => {\n const match = SQLITE_CODE_RE.exec(message);\n return match ? `SQLITE_${match[1]}` : undefined;\n};\n\n/**\n * Maps a `SQLITE_*` code found in the D1 message to a DumboError.\n *\n * D1 sometimes forwards raw SQLite result codes from the C++ layer, e.g.:\n * \"D1_ERROR: SQLITE_BUSY: database is locked\"\n * \"SQLITE_READONLY: attempt to write a readonly database\"\n *\n * See https://www.sqlite.org/rescode.html for the full code list.\n */\nconst mapEmbeddedSqliteCode = (\n code: string,\n message: string | undefined,\n innerError: Error | undefined,\n): DumboError | undefined => {\n switch (code) {\n case 'SQLITE_CONSTRAINT':\n return mapConstraintError(message, innerError);\n case 'SQLITE_BUSY':\n return new LockNotAvailableError(message, innerError);\n case 'SQLITE_LOCKED':\n return new DeadlockError(message, innerError);\n case 'SQLITE_PROTOCOL':\n return new LockNotAvailableError(message, innerError);\n case 'SQLITE_CANTOPEN':\n return new ConnectionError(message, innerError);\n case 'SQLITE_NOTADB':\n return new ConnectionError(message, innerError);\n case 'SQLITE_NOMEM':\n return new InsufficientResourcesError(message, innerError);\n case 'SQLITE_FULL':\n return new InsufficientResourcesError(message, innerError);\n case 'SQLITE_IOERR':\n return new SystemError(message, innerError);\n case 'SQLITE_CORRUPT':\n return new SystemError(message, innerError);\n case 'SQLITE_INTERNAL':\n return new SystemError(message, innerError);\n case 'SQLITE_NOLFS':\n return new SystemError(message, innerError);\n case 'SQLITE_TOOBIG':\n return new DataError(message, innerError);\n case 'SQLITE_MISMATCH':\n return new DataError(message, innerError);\n case 'SQLITE_RANGE':\n return new DataError(message, innerError);\n case 'SQLITE_ERROR':\n return new InvalidOperationError(message, innerError);\n case 'SQLITE_READONLY':\n return new InvalidOperationError(message, innerError);\n case 'SQLITE_MISUSE':\n return new InvalidOperationError(message, innerError);\n case 'SQLITE_AUTH':\n return new InvalidOperationError(message, innerError);\n case 'SQLITE_PERM':\n return new InvalidOperationError(message, innerError);\n case 'SQLITE_SCHEMA':\n return new InvalidOperationError(message, innerError);\n case 'SQLITE_ABORT':\n return new SerializationError(message, innerError);\n case 'SQLITE_INTERRUPT':\n return new SerializationError(message, innerError);\n }\n return undefined;\n};\n\n/**\n * Maps a Cloudflare D1 error to a typed DumboError.\n *\n * Unlike node-sqlite3, D1 throws **plain `Error` objects** with no `code`\n * property. All error information is embedded in `error.message`, using\n * well-known prefixes from the `workerd` runtime:\n *\n * | Prefix | Meaning |\n * |-----------------------|----------------------------------------------|\n * | `D1_ERROR:` | General D1 / SQLite error |\n * | `D1_EXEC_ERROR:` | Error during `.exec()` batch |\n * | `D1_TYPE_ERROR:` | Type mismatch (e.g. `undefined` vs `null`) |\n * | `D1_COLUMN_NOTFOUND` | Referenced column does not exist |\n * | `D1_DUMP_ERROR:` | Error during database dump |\n * | `D1_SESSION_ERROR:` | Session bookmark / constraint error |\n *\n * D1 also surfaces platform-level messages (no prefix) for transient errors:\n * - \"Network connection lost.\"\n * - \"D1 DB is overloaded. Too many requests queued.\"\n * - \"Memory limit would be exceeded by this operation.\"\n * - \"Cannot resolve D1 DB due to transient issue on remote node.\"\n * - \"D1 DB reset because its code was updated.\"\n *\n * Reference:\n * - https://developers.cloudflare.com/d1/platform/client-api/\n * - https://github.com/cloudflare/workerd (src/cloudflare/internal/d1-api.ts)\n *\n * Falls back to a generic DumboError (500) if the error is not a recognized D1 error.\n */\nexport const mapD1Error = (error: unknown): DumboError => {\n if (DumboError.isInstanceOf<DumboError>(error)) return error;\n\n const message = getErrorMessage(error);\n if (!message)\n return new DumboError({\n errorCode: 500,\n message: error instanceof Error ? error.message : String(error),\n innerError: asError(error),\n });\n\n const innerError = asError(error);\n const upper = message.toUpperCase();\n\n // D1-specific prefixes are checked first because some (e.g. D1_SESSION_ERROR)\n // contain constraint keywords in their message but have different semantics.\n if (upper.startsWith('D1_TYPE_ERROR'))\n return new DataError(message, innerError);\n\n if (upper.startsWith('D1_COLUMN_NOTFOUND'))\n return new DataError(message, innerError);\n\n if (upper.startsWith('D1_DUMP_ERROR'))\n return new SystemError(message, innerError);\n\n if (upper.startsWith('D1_SESSION_ERROR'))\n return new ConnectionError(message, innerError);\n\n if (isConstraintMessage(upper)) {\n return mapConstraintError(message, innerError);\n }\n\n if (\n upper.includes('NETWORK CONNECTION LOST') ||\n upper.includes('CANNOT RESOLVE D1 DB DUE TO TRANSIENT ISSUE') ||\n upper.includes('D1 DB RESET BECAUSE')\n )\n return new ConnectionError(message, innerError);\n\n if (\n upper.includes('D1 DB IS OVERLOADED') ||\n upper.includes('TOO MANY REQUESTS') ||\n upper.includes('MEMORY LIMIT WOULD BE EXCEEDED')\n )\n return new InsufficientResourcesError(message, innerError);\n\n if (upper.startsWith('D1_ERROR') || upper.startsWith('D1_EXEC_ERROR')) {\n const embeddedCode = extractEmbeddedSqliteCode(message);\n if (embeddedCode) {\n const mapped = mapEmbeddedSqliteCode(embeddedCode, message, innerError);\n if (mapped) return mapped;\n }\n\n return new InvalidOperationError(message, innerError);\n }\n\n const embeddedCode = extractEmbeddedSqliteCode(message);\n if (embeddedCode) {\n const mapped = mapEmbeddedSqliteCode(embeddedCode, message, innerError);\n if (mapped) return mapped;\n }\n\n return new DumboError({\n errorCode: 500,\n message,\n innerError,\n });\n};\n","import type {\n BatchSQLCommandOptions,\n DbSQLExecutor,\n QueryResult,\n QueryResultRow,\n SQL,\n SQLCommandOptions,\n SQLQueryOptions,\n} from '../../../../core';\nimport { tracer } from '../../../../core';\nimport { sqliteFormatter } from '../../core';\nimport type { D1Client, D1DriverType } from '../connections';\nimport { mapD1Error } from '../errors/errorMapper';\n\nexport const d1SQLExecutor = (): DbSQLExecutor<D1DriverType, D1Client> => ({\n driverType: 'SQLite:d1',\n formatter: sqliteFormatter,\n\n query: async <Result extends QueryResultRow>(\n client: D1Client,\n sql: SQL,\n options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>> => {\n try {\n return await client.query<Result>(sql, options);\n } catch (error) {\n tracer.error('db:sql:query:execute:error', { error });\n throw mapD1Error(error);\n }\n },\n\n batchQuery: async <Result extends QueryResultRow>(\n client: D1Client,\n sqls: SQL[],\n options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>[]> => {\n try {\n return await client.batchQuery<Result>(sqls, options);\n } catch (error) {\n tracer.error('db:sql:batch_query:execute:error', { error });\n throw mapD1Error(error);\n }\n },\n\n command: async <Result extends QueryResultRow>(\n client: D1Client,\n sql: SQL,\n options?: SQLCommandOptions,\n ): Promise<QueryResult<Result>> => {\n try {\n return await client.command<Result>(sql, options);\n } catch (error) {\n tracer.error('db:sql:command:execute:error', { error });\n throw mapD1Error(error);\n }\n },\n\n batchCommand: async <Result extends QueryResultRow>(\n client: D1Client,\n sqls: SQL[],\n options?: BatchSQLCommandOptions,\n ): Promise<QueryResult<Result>[]> => {\n try {\n return await client.batchCommand<Result>(sqls, options);\n } catch (error) {\n tracer.error('db:sql:batch_command:execute:error', { error });\n throw mapD1Error(error);\n }\n },\n});\n","import type { JSONSerializer } from '../../../../core';\nimport {\n sqlExecutor,\n type DatabaseTransaction,\n type DatabaseTransactionOptions,\n} from '../../../../core';\nimport { transactionNestingCounter } from '../../core';\nimport {\n D1DriverType,\n type D1Client,\n type D1Connection,\n type D1SessionOptions,\n} from '../connections';\nimport { d1SQLExecutor } from '../execute';\n\nexport type D1Transaction = DatabaseTransaction<D1Connection>;\n\nexport type D1TransactionOptions = DatabaseTransactionOptions & {\n d1Session?: D1SessionOptions;\n mode?: D1TransactionMode;\n};\n\nexport type D1TransactionMode = 'session_based' | 'strict';\n\nexport class D1TransactionNotSupportedError extends Error {\n constructor() {\n super(\n 'D1 does not support SQL transactions (BEGIN/COMMIT/ROLLBACK/SAVEPOINT). ' +\n 'Use { mode: \"session_based\" } to opt-in to session+batch semantics, or use ' +\n 'connection.execute.batchCommand() for atomic multi-statement execution.',\n );\n this.name = 'D1TransactionNotSupportedError';\n }\n}\n\nexport const d1Transaction =\n (\n connection: () => D1Connection,\n serializer: JSONSerializer,\n defaultOptions?: D1TransactionOptions,\n ) =>\n (\n getClient: Promise<D1Client>,\n options?: {\n close: (client: D1Client, error?: unknown) => Promise<void>;\n } & D1TransactionOptions,\n ): D1Transaction => {\n const transactionCounter = transactionNestingCounter();\n\n const allowNestedTransactions =\n options?.allowNestedTransactions ??\n defaultOptions?.allowNestedTransactions;\n\n const mode = options?.mode ?? defaultOptions?.mode;\n\n let client: D1Client | null = null;\n let sessionClient: D1Client | null = null;\n\n const getDatabaseClient = async () => {\n if (client) return Promise.resolve(client);\n\n client = await getClient;\n return client;\n };\n\n return {\n connection: connection(),\n driverType: D1DriverType,\n begin: async function () {\n if (mode !== 'session_based') {\n throw new D1TransactionNotSupportedError();\n }\n\n const client = await getDatabaseClient();\n\n if (allowNestedTransactions) {\n if (transactionCounter.level >= 1) {\n transactionCounter.increment();\n return;\n }\n\n transactionCounter.increment();\n }\n\n sessionClient = await client.withSession(options?.d1Session);\n },\n commit: async function () {\n const client = await getDatabaseClient();\n\n try {\n if (allowNestedTransactions) {\n if (transactionCounter.level > 1) {\n transactionCounter.decrement();\n\n return;\n }\n\n transactionCounter.reset();\n }\n sessionClient = null;\n } finally {\n if (options?.close) await options?.close(client);\n }\n },\n rollback: async function (error?: unknown) {\n const client = await getDatabaseClient();\n try {\n if (allowNestedTransactions) {\n if (transactionCounter.level > 1) {\n transactionCounter.decrement();\n return;\n }\n }\n\n sessionClient = null;\n } finally {\n if (options?.close) await options?.close(client, error);\n }\n },\n execute: sqlExecutor(d1SQLExecutor(), {\n connect: () => {\n if (!sessionClient) {\n throw new Error(\n 'Transaction has not been started. Call begin() first.',\n );\n }\n return Promise.resolve(sessionClient);\n },\n }),\n };\n };\n","import type { Connection } from '../../../../core';\nimport {\n sqliteAmbientClientConnection,\n type SQLiteConnectionOptions,\n type SQLiteDriverType,\n} from '../../core';\nimport { mapD1Error } from '../errors/errorMapper';\nimport {\n d1Transaction,\n type D1Transaction,\n type D1TransactionOptions,\n} from '../transactions';\nimport {\n d1Client,\n type D1Client,\n type D1ClientOptions,\n type D1SessionOptions,\n} from './d1Client';\n\nexport type D1DriverType = SQLiteDriverType<'d1'>;\nexport const D1DriverType: D1DriverType = 'SQLite:d1';\n\nexport type D1Connection = Connection<\n D1Connection,\n D1DriverType,\n D1Client,\n D1Transaction,\n D1TransactionOptions\n> & {\n d1Session: (constraintOrBookmark?: D1SessionOptions) => Promise<D1Connection>;\n withD1Session: <Result = never>(\n handle: (connection: D1Connection) => Promise<Result>,\n options?: D1SessionOptions,\n ) => Promise<Result>;\n};\n\nexport type D1ConnectionOptions = SQLiteConnectionOptions<D1Connection> & {\n client?: D1Client;\n connection?: D1Connection;\n transaction?: D1Transaction;\n} & D1ClientOptions;\n\nexport const d1Connection = (options: D1ConnectionOptions) => {\n const connection = options.connection ??\n options.transaction?.connection ?? {\n ...sqliteAmbientClientConnection<D1Connection>({\n driverType: D1DriverType,\n client: options.client ?? d1Client(options),\n initTransaction: (connection) =>\n d1Transaction(\n connection,\n options.serializer,\n options.transactionOptions,\n ),\n serializer: options.serializer,\n errorMapper: mapD1Error,\n }),\n };\n\n connection.d1Session = async (\n constraintOrBookmark?: D1SessionOptions,\n ): Promise<D1Connection> => {\n const client = await connection.open();\n\n const sessionClient = await client.withSession(constraintOrBookmark);\n\n return d1Connection({\n ...options,\n client: sessionClient,\n });\n };\n\n connection.withD1Session = async <Result = never>(\n handle: (connection: D1Connection) => Promise<Result>,\n options?: D1SessionOptions,\n ): Promise<Result> => {\n const sessionConnection = await connection.d1Session(options);\n\n try {\n return await handle(sessionConnection);\n } finally {\n await sessionConnection.close();\n }\n };\n\n return connection;\n};\n","import type { D1ConnectionOptions } from '..';\nimport {\n createSingletonConnectionPool,\n JSONSerializer,\n type ConnectionPool,\n type JSONSerializationOptions,\n} from '../../../../core';\nimport {\n d1Connection,\n D1DriverType,\n type D1Connection,\n} from '../connections/d1Connection';\n\nexport type D1PoolOptions = Omit<D1ConnectionOptions, 'serializer'> &\n JSONSerializationOptions;\n\nexport type D1ConnectionPool = ConnectionPool<D1Connection>;\n\nexport const d1Pool = (options: D1PoolOptions): D1ConnectionPool =>\n createSingletonConnectionPool<D1Connection>({\n driverType: D1DriverType,\n getConnection: () =>\n d1Connection({\n ...options,\n serializer: JSONSerializer.from(options),\n }),\n });\n","export * from './connections';\nimport type { D1Database } from '@cloudflare/workers-types';\nimport type { D1ConnectionPool } from '../../../cloudflare';\nimport {\n dumboDatabaseDriverRegistry,\n type DumboConnectionOptions,\n type DumboDatabaseDriver,\n} from '../../../core';\nimport {\n DefaultSQLiteMigratorOptions,\n sqliteFormatter,\n sqliteMetadata,\n} from '../core';\nimport { D1DriverType, type D1Connection } from './connections';\nimport { d1Pool, type D1PoolOptions } from './pool';\n\nexport type D1DumboOptions = D1PoolOptions;\n\nexport const d1DumboDriver: DumboDatabaseDriver<\n D1Connection,\n D1DumboOptions,\n D1ConnectionPool\n> = {\n driverType: D1DriverType,\n createPool: (options) => d1Pool(options),\n sqlFormatter: sqliteFormatter,\n defaultMigratorOptions: DefaultSQLiteMigratorOptions,\n canHandle: (options) => {\n return options.driverType === D1DriverType && 'database' in options;\n },\n databaseMetadata: sqliteMetadata,\n};\n\nexport const useD1DumboDriver = () => {\n dumboDatabaseDriverRegistry.register(D1DriverType, d1DumboDriver);\n};\n\nexport type D1DumboConnectionOptions = DumboConnectionOptions<\n typeof d1DumboDriver\n> & { database: D1Database };\n\nuseD1DumboDriver();\n\nexport * from './connections';\nexport * from './errors';\nexport * from './execute';\nexport * from './formatter';\nexport * from './pool';\nexport * from './transactions';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCO,IAAM,WAAW,CAAC,YAAuC;AAC9D,QAAM,EAAE,UAAU,SAAS,WAAW,IAAI;AAE1C,QAAM,UAAU,WAAW;AAE3B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,SAAS,MAAM,QAAQ,QAAQ;AAAA,IAC/B,OAAO,MAAM,QAAQ,QAAQ;AAAA,IAC7B,aAAa,OAAO,yBAA4C;AAC9D,YAAM,aAAa,uBACf,SAAS,YAAY,oBAA8B,IACnD,SAAS,YAAY;AAEzB,aAAO,QAAQ;AAAA,QACb,SAAS;AAAA,UACP;AAAA,UACA,SAAS;AAAA,UACT;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IAEA,OAAO,OACL,KACA,aACiC;AACjC,YAAM,EAAE,OAAO,OAAO,IAAI,gBAAgB,OAAO,KAAK,EAAE,WAAW,CAAC;AACpE,YAAM,OAAO,QAAQ,QAAQ,KAAK;AAClC,YAAM,QAAQ,QAAQ,SAAS,KAAK,KAAK,GAAG,MAAM,IAAI;AACtD,YAAM,EAAE,QAAQ,IAAI,MAAM,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AC,YAAY,OAAO,OAAO;AAAA,EACvC,cAAc;AAAA,EACd,wBAAwB;AAAA,EACxB,WAAW,CAAC,YAAY;AACtB,WAAO,QAAQ,eAAe,gBAAgB,cAAc;AAAA,EAC9D;AAAA,EACA,kBAAkB;AACpB;AAEO,IAAM,mBAAmB,MAAM;AACpC,8BAA4B,SAAS,cAAc,aAAa;AAClE;AAMA,iBAAiB;","names":["options","embeddedCode","client","connection","options"]}
|
|
1
|
+
{"version":3,"sources":["../src/storage/sqlite/d1/connections/d1Client.ts","../src/storage/sqlite/d1/errors/errorMapper.ts","../src/storage/sqlite/d1/execute/d1SqlExecutor.ts","../src/storage/sqlite/d1/transactions/d1Transaction.ts","../src/storage/sqlite/d1/connections/d1Connection.ts","../src/storage/sqlite/d1/pool/d1ConnectionPool.ts","../src/storage/sqlite/d1/index.ts"],"sourcesContent":["import type {\n D1Database,\n D1DatabaseSession,\n D1SessionBookmark,\n D1SessionConstraint,\n} from '@cloudflare/workers-types';\nimport {\n BatchCommandNoChangesError,\n type BatchSQLCommandOptions,\n type JSONSerializer,\n type QueryResult,\n type QueryResultRow,\n type SQL,\n type SQLCommandOptions,\n type SQLQueryOptions,\n} from '../../../../core';\nimport { sqliteFormatter, type SQLiteClient } from '../../core';\n\nexport type D1DatabaseOrSession = D1Database | D1DatabaseSession;\n\nexport type D1ClientOptions = {\n database: D1Database;\n session?: D1DatabaseSession | undefined;\n serializer: JSONSerializer;\n};\n\nexport type D1SessionOptions = {\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint;\n};\n\nexport type D1Client = SQLiteClient & {\n database: D1Database;\n session?: D1DatabaseSession | undefined;\n\n withSession: (constraintOrBookmark?: D1SessionOptions) => Promise<D1Client>;\n};\n\nexport const d1Client = (options: D1ClientOptions): D1Client => {\n const { database, session, serializer } = options;\n\n const execute = session ?? database;\n\n return {\n database,\n session: session,\n connect: () => Promise.resolve(),\n close: () => Promise.resolve(),\n withSession: async (constraintOrBookmark?: D1SessionOptions) => {\n const newSession = constraintOrBookmark\n ? database.withSession(constraintOrBookmark as string)\n : database.withSession();\n\n return Promise.resolve(\n d1Client({\n database,\n session: newSession,\n serializer,\n }),\n );\n },\n\n query: async <Result extends QueryResultRow = QueryResultRow>(\n sql: SQL,\n _options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>> => {\n const { query, params } = sqliteFormatter.format(sql, { serializer });\n const stmt = execute.prepare(query);\n const bound = params?.length ? stmt.bind(...params) : stmt;\n const { results } = await bound.all<Result>();\n return { rowCount: results?.length ?? 0, rows: results ?? [] };\n },\n\n batchQuery: async <Result extends QueryResultRow = QueryResultRow>(\n sqls: SQL[],\n _options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>[]> => {\n const statements = sqls.map((sql) => {\n const { query, params } = sqliteFormatter.format(sql, { serializer });\n const stmt = execute.prepare(query);\n return params?.length ? stmt.bind(...params) : stmt;\n });\n const results = await execute.batch<Result>(statements);\n return results.map((result) => ({\n rowCount: result.results?.length ?? 0,\n rows: result.results ?? [],\n }));\n },\n\n command: async <Result extends QueryResultRow = QueryResultRow>(\n sql: SQL,\n _options?: SQLCommandOptions,\n ): Promise<QueryResult<Result>> => {\n const { query, params } = sqliteFormatter.format(sql, { serializer });\n const stmt = execute.prepare(query);\n const bound = params?.length ? stmt.bind(...params) : stmt;\n const result = await bound.run<Result>();\n return {\n rowCount: result.meta?.changes ?? 0,\n rows: result.results ?? [],\n };\n },\n\n batchCommand: async <Result extends QueryResultRow = QueryResultRow>(\n sqls: SQL[],\n options?: BatchSQLCommandOptions,\n ): Promise<QueryResult<Result>[]> => {\n const statements = sqls.map((sql) => {\n const { query, params } = sqliteFormatter.format(sql, { serializer });\n const stmt = execute.prepare(query);\n return params?.length ? stmt.bind(...params) : stmt;\n });\n const batchResults = await execute.batch<Result>(statements);\n\n return batchResults.map((result, i) => {\n const qr: QueryResult<Result> = {\n rowCount: result.meta?.changes ?? 0,\n rows: result.results ?? [],\n };\n\n if (options?.assertChanges && (qr.rowCount ?? 0) === 0) {\n throw new BatchCommandNoChangesError(i);\n }\n\n return qr;\n });\n },\n };\n};\n","import {\n CheckViolationError,\n ConnectionError,\n DataError,\n DeadlockError,\n DumboError,\n ForeignKeyViolationError,\n InsufficientResourcesError,\n IntegrityConstraintViolationError,\n InvalidOperationError,\n LockNotAvailableError,\n NotNullViolationError,\n SerializationError,\n SystemError,\n UniqueConstraintError,\n} from '../../../../core/errors';\n\nconst getErrorMessage = (error: unknown): string | undefined =>\n error instanceof Error ? error.message : undefined;\n\nconst asError = (error: unknown): Error | undefined =>\n error instanceof Error ? error : undefined;\n\n/**\n * Determines the constraint subtype from the error message.\n *\n * D1 embeds the SQLite constraint detail in the message string, e.g.:\n * \"D1_ERROR: UNIQUE constraint failed: users.email\"\n * \"D1_ERROR: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed\"\n */\nconst mapConstraintError = (\n message: string | undefined,\n innerError: Error | undefined,\n): DumboError => {\n const upperMessage = message?.toUpperCase() ?? '';\n\n if (upperMessage.includes('UNIQUE') || upperMessage.includes('PRIMARY KEY'))\n return new UniqueConstraintError(message, innerError);\n\n if (upperMessage.includes('FOREIGN KEY'))\n return new ForeignKeyViolationError(message, innerError);\n\n if (upperMessage.includes('NOT NULL'))\n return new NotNullViolationError(message, innerError);\n\n if (upperMessage.includes('CHECK'))\n return new CheckViolationError(message, innerError);\n\n return new IntegrityConstraintViolationError(message, innerError);\n};\n\nconst isConstraintMessage = (upper: string): boolean =>\n upper.includes('CONSTRAINT') ||\n upper.includes('UNIQUE') ||\n upper.includes('PRIMARY KEY') ||\n upper.includes('FOREIGN KEY') ||\n upper.includes('NOT NULL');\n\n/** Extracts the first `SQLITE_<CODE>` token from a message string. */\nconst SQLITE_CODE_RE = /SQLITE_([A-Z]+)/;\n\nconst extractEmbeddedSqliteCode = (message: string): string | undefined => {\n const match = SQLITE_CODE_RE.exec(message);\n return match ? `SQLITE_${match[1]}` : undefined;\n};\n\n/**\n * Maps a `SQLITE_*` code found in the D1 message to a DumboError.\n *\n * D1 sometimes forwards raw SQLite result codes from the C++ layer, e.g.:\n * \"D1_ERROR: SQLITE_BUSY: database is locked\"\n * \"SQLITE_READONLY: attempt to write a readonly database\"\n *\n * See https://www.sqlite.org/rescode.html for the full code list.\n */\nconst mapEmbeddedSqliteCode = (\n code: string,\n message: string | undefined,\n innerError: Error | undefined,\n): DumboError | undefined => {\n switch (code) {\n case 'SQLITE_CONSTRAINT':\n return mapConstraintError(message, innerError);\n case 'SQLITE_BUSY':\n return new LockNotAvailableError(message, innerError);\n case 'SQLITE_LOCKED':\n return new DeadlockError(message, innerError);\n case 'SQLITE_PROTOCOL':\n return new LockNotAvailableError(message, innerError);\n case 'SQLITE_CANTOPEN':\n return new ConnectionError(message, innerError);\n case 'SQLITE_NOTADB':\n return new ConnectionError(message, innerError);\n case 'SQLITE_NOMEM':\n return new InsufficientResourcesError(message, innerError);\n case 'SQLITE_FULL':\n return new InsufficientResourcesError(message, innerError);\n case 'SQLITE_IOERR':\n return new SystemError(message, innerError);\n case 'SQLITE_CORRUPT':\n return new SystemError(message, innerError);\n case 'SQLITE_INTERNAL':\n return new SystemError(message, innerError);\n case 'SQLITE_NOLFS':\n return new SystemError(message, innerError);\n case 'SQLITE_TOOBIG':\n return new DataError(message, innerError);\n case 'SQLITE_MISMATCH':\n return new DataError(message, innerError);\n case 'SQLITE_RANGE':\n return new DataError(message, innerError);\n case 'SQLITE_ERROR':\n return new InvalidOperationError(message, innerError);\n case 'SQLITE_READONLY':\n return new InvalidOperationError(message, innerError);\n case 'SQLITE_MISUSE':\n return new InvalidOperationError(message, innerError);\n case 'SQLITE_AUTH':\n return new InvalidOperationError(message, innerError);\n case 'SQLITE_PERM':\n return new InvalidOperationError(message, innerError);\n case 'SQLITE_SCHEMA':\n return new InvalidOperationError(message, innerError);\n case 'SQLITE_ABORT':\n return new SerializationError(message, innerError);\n case 'SQLITE_INTERRUPT':\n return new SerializationError(message, innerError);\n }\n return undefined;\n};\n\n/**\n * Maps a Cloudflare D1 error to a typed DumboError.\n *\n * Unlike node-sqlite3, D1 throws **plain `Error` objects** with no `code`\n * property. All error information is embedded in `error.message`, using\n * well-known prefixes from the `workerd` runtime:\n *\n * | Prefix | Meaning |\n * |-----------------------|----------------------------------------------|\n * | `D1_ERROR:` | General D1 / SQLite error |\n * | `D1_EXEC_ERROR:` | Error during `.exec()` batch |\n * | `D1_TYPE_ERROR:` | Type mismatch (e.g. `undefined` vs `null`) |\n * | `D1_COLUMN_NOTFOUND` | Referenced column does not exist |\n * | `D1_DUMP_ERROR:` | Error during database dump |\n * | `D1_SESSION_ERROR:` | Session bookmark / constraint error |\n *\n * D1 also surfaces platform-level messages (no prefix) for transient errors:\n * - \"Network connection lost.\"\n * - \"D1 DB is overloaded. Too many requests queued.\"\n * - \"Memory limit would be exceeded by this operation.\"\n * - \"Cannot resolve D1 DB due to transient issue on remote node.\"\n * - \"D1 DB reset because its code was updated.\"\n *\n * Reference:\n * - https://developers.cloudflare.com/d1/platform/client-api/\n * - https://github.com/cloudflare/workerd (src/cloudflare/internal/d1-api.ts)\n *\n * Falls back to a generic DumboError (500) if the error is not a recognized D1 error.\n */\nexport const mapD1Error = (error: unknown): DumboError => {\n if (DumboError.isInstanceOf<DumboError>(error)) return error;\n\n const message = getErrorMessage(error);\n if (!message)\n return new DumboError({\n errorCode: 500,\n message: error instanceof Error ? error.message : String(error),\n innerError: asError(error),\n });\n\n const innerError = asError(error);\n const upper = message.toUpperCase();\n\n // D1-specific prefixes are checked first because some (e.g. D1_SESSION_ERROR)\n // contain constraint keywords in their message but have different semantics.\n if (upper.startsWith('D1_TYPE_ERROR'))\n return new DataError(message, innerError);\n\n if (upper.startsWith('D1_COLUMN_NOTFOUND'))\n return new DataError(message, innerError);\n\n if (upper.startsWith('D1_DUMP_ERROR'))\n return new SystemError(message, innerError);\n\n if (upper.startsWith('D1_SESSION_ERROR'))\n return new ConnectionError(message, innerError);\n\n if (isConstraintMessage(upper)) {\n return mapConstraintError(message, innerError);\n }\n\n if (\n upper.includes('NETWORK CONNECTION LOST') ||\n upper.includes('CANNOT RESOLVE D1 DB DUE TO TRANSIENT ISSUE') ||\n upper.includes('D1 DB RESET BECAUSE')\n )\n return new ConnectionError(message, innerError);\n\n if (\n upper.includes('D1 DB IS OVERLOADED') ||\n upper.includes('TOO MANY REQUESTS') ||\n upper.includes('MEMORY LIMIT WOULD BE EXCEEDED')\n )\n return new InsufficientResourcesError(message, innerError);\n\n if (upper.startsWith('D1_ERROR') || upper.startsWith('D1_EXEC_ERROR')) {\n const embeddedCode = extractEmbeddedSqliteCode(message);\n if (embeddedCode) {\n const mapped = mapEmbeddedSqliteCode(embeddedCode, message, innerError);\n if (mapped) return mapped;\n }\n\n return new InvalidOperationError(message, innerError);\n }\n\n const embeddedCode = extractEmbeddedSqliteCode(message);\n if (embeddedCode) {\n const mapped = mapEmbeddedSqliteCode(embeddedCode, message, innerError);\n if (mapped) return mapped;\n }\n\n return new DumboError({\n errorCode: 500,\n message,\n innerError,\n });\n};\n","import type {\n BatchSQLCommandOptions,\n DbSQLExecutor,\n QueryResult,\n QueryResultRow,\n SQL,\n SQLCommandOptions,\n SQLQueryOptions,\n} from '../../../../core';\nimport { tracer } from '../../../../core';\nimport { sqliteFormatter } from '../../core';\nimport type { D1Client, D1DriverType } from '../connections';\nimport { mapD1Error } from '../errors/errorMapper';\n\nexport const d1SQLExecutor = (): DbSQLExecutor<D1DriverType, D1Client> => ({\n driverType: 'SQLite:d1',\n formatter: sqliteFormatter,\n\n query: async <Result extends QueryResultRow>(\n client: D1Client,\n sql: SQL,\n options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>> => {\n try {\n return await client.query<Result>(sql, options);\n } catch (error) {\n tracer.error('db:sql:query:execute:error', { error });\n throw mapD1Error(error);\n }\n },\n\n batchQuery: async <Result extends QueryResultRow>(\n client: D1Client,\n sqls: SQL[],\n options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>[]> => {\n try {\n return await client.batchQuery<Result>(sqls, options);\n } catch (error) {\n tracer.error('db:sql:batch_query:execute:error', { error });\n throw mapD1Error(error);\n }\n },\n\n command: async <Result extends QueryResultRow>(\n client: D1Client,\n sql: SQL,\n options?: SQLCommandOptions,\n ): Promise<QueryResult<Result>> => {\n try {\n return await client.command<Result>(sql, options);\n } catch (error) {\n tracer.error('db:sql:command:execute:error', { error });\n throw mapD1Error(error);\n }\n },\n\n batchCommand: async <Result extends QueryResultRow>(\n client: D1Client,\n sqls: SQL[],\n options?: BatchSQLCommandOptions,\n ): Promise<QueryResult<Result>[]> => {\n try {\n return await client.batchCommand<Result>(sqls, options);\n } catch (error) {\n tracer.error('db:sql:batch_command:execute:error', { error });\n throw mapD1Error(error);\n }\n },\n});\n","import type { JSONSerializer } from '../../../../core';\nimport {\n sqlExecutor,\n type DatabaseTransaction,\n type DatabaseTransactionOptions,\n} from '../../../../core';\nimport { transactionNestingCounter } from '../../core';\nimport {\n D1DriverType,\n type D1Client,\n type D1Connection,\n type D1SessionOptions,\n} from '../connections';\nimport { d1SQLExecutor } from '../execute';\n\nexport type D1Transaction = DatabaseTransaction<\n D1Connection,\n D1TransactionOptions\n>;\n\nexport type D1TransactionOptions = DatabaseTransactionOptions & {\n d1Session?: D1SessionOptions;\n mode?: D1TransactionMode;\n};\n\nexport type D1TransactionMode = 'session_based' | 'strict';\n\nexport class D1TransactionNotSupportedError extends Error {\n constructor() {\n super(\n 'D1 does not support SQL transactions (BEGIN/COMMIT/ROLLBACK/SAVEPOINT). ' +\n 'Use { mode: \"session_based\" } to opt-in to session+batch semantics, or use ' +\n 'connection.execute.batchCommand() for atomic multi-statement execution.',\n );\n this.name = 'D1TransactionNotSupportedError';\n }\n}\n\nexport const d1Transaction =\n (\n connection: () => D1Connection,\n serializer: JSONSerializer,\n defaultOptions?: D1TransactionOptions,\n ) =>\n (\n getClient: Promise<D1Client>,\n options?: {\n close: (client: D1Client, error?: unknown) => Promise<void>;\n } & D1TransactionOptions,\n ): D1Transaction => {\n const transactionCounter = transactionNestingCounter();\n\n const allowNestedTransactions =\n options?.allowNestedTransactions ??\n defaultOptions?.allowNestedTransactions;\n\n const mode = options?.mode ?? defaultOptions?.mode;\n\n let client: D1Client | null = null;\n let sessionClient: D1Client | null = null;\n\n const getDatabaseClient = async () => {\n if (client) return Promise.resolve(client);\n\n client = await getClient;\n return client;\n };\n\n return {\n connection: connection(),\n driverType: D1DriverType,\n begin: async function () {\n if (mode !== 'session_based') {\n throw new D1TransactionNotSupportedError();\n }\n\n const client = await getDatabaseClient();\n\n if (allowNestedTransactions) {\n if (transactionCounter.level >= 1) {\n transactionCounter.increment();\n return;\n }\n\n transactionCounter.increment();\n }\n\n sessionClient = await client.withSession(options?.d1Session);\n },\n commit: async function () {\n const client = await getDatabaseClient();\n\n try {\n if (allowNestedTransactions) {\n if (transactionCounter.level > 1) {\n transactionCounter.decrement();\n\n return;\n }\n\n transactionCounter.reset();\n }\n sessionClient = null;\n } finally {\n if (options?.close) await options?.close(client);\n }\n },\n rollback: async function (error?: unknown) {\n const client = await getDatabaseClient();\n try {\n if (allowNestedTransactions) {\n if (transactionCounter.level > 1) {\n transactionCounter.decrement();\n return;\n }\n }\n\n sessionClient = null;\n } finally {\n if (options?.close) await options?.close(client, error);\n }\n },\n execute: sqlExecutor(d1SQLExecutor(), {\n connect: () => {\n if (!sessionClient) {\n throw new Error(\n 'Transaction has not been started. Call begin() first.',\n );\n }\n return Promise.resolve(sessionClient);\n },\n }),\n _transactionOptions: options ?? {},\n };\n };\n","import type { Connection } from '../../../../core';\nimport {\n sqliteAmbientClientConnection,\n type SQLiteConnectionOptions,\n type SQLiteDriverType,\n} from '../../core';\nimport { mapD1Error } from '../errors/errorMapper';\nimport { d1Transaction, type D1Transaction } from '../transactions';\nimport {\n d1Client,\n type D1Client,\n type D1ClientOptions,\n type D1SessionOptions,\n} from './d1Client';\n\nexport type D1DriverType = SQLiteDriverType<'d1'>;\nexport const D1DriverType: D1DriverType = 'SQLite:d1';\n\nexport type D1Connection = Connection<\n D1Connection,\n D1DriverType,\n D1Client,\n D1Transaction\n> & {\n d1Session: (constraintOrBookmark?: D1SessionOptions) => Promise<D1Connection>;\n withD1Session: <Result = never>(\n handle: (connection: D1Connection) => Promise<Result>,\n options?: D1SessionOptions,\n ) => Promise<Result>;\n};\n\nexport type D1ConnectionOptions = SQLiteConnectionOptions<D1Connection> & {\n client?: D1Client;\n connection?: D1Connection;\n transaction?: D1Transaction;\n} & D1ClientOptions;\n\nexport const d1Connection = (options: D1ConnectionOptions) => {\n const connection = options.connection ??\n options.transaction?.connection ?? {\n ...sqliteAmbientClientConnection<D1Connection>({\n driverType: D1DriverType,\n client: options.client ?? d1Client(options),\n initTransaction: (connection) =>\n d1Transaction(\n connection,\n options.serializer,\n options.transactionOptions,\n ),\n serializer: options.serializer,\n errorMapper: mapD1Error,\n }),\n };\n\n connection.d1Session = async (\n constraintOrBookmark?: D1SessionOptions,\n ): Promise<D1Connection> => {\n const client = await connection.open();\n\n const sessionClient = await client.withSession(constraintOrBookmark);\n\n return d1Connection({\n ...options,\n client: sessionClient,\n });\n };\n\n connection.withD1Session = async <Result = never>(\n handle: (connection: D1Connection) => Promise<Result>,\n options?: D1SessionOptions,\n ): Promise<Result> => {\n const sessionConnection = await connection.d1Session(options);\n\n try {\n return await handle(sessionConnection);\n } finally {\n await sessionConnection.close();\n }\n };\n\n return connection;\n};\n","import type { D1ConnectionOptions } from '..';\nimport {\n createSingletonConnectionPool,\n JSONSerializer,\n type ConnectionPool,\n type JSONSerializationOptions,\n} from '../../../../core';\nimport {\n d1Connection,\n D1DriverType,\n type D1Connection,\n} from '../connections/d1Connection';\n\nexport type D1PoolOptions = Omit<D1ConnectionOptions, 'serializer'> &\n JSONSerializationOptions;\n\nexport type D1ConnectionPool = ConnectionPool<D1Connection>;\n\nexport const d1Pool = (options: D1PoolOptions): D1ConnectionPool =>\n createSingletonConnectionPool<D1Connection>({\n driverType: D1DriverType,\n getConnection: () =>\n d1Connection({\n ...options,\n serializer: JSONSerializer.from(options),\n }),\n });\n","export * from './connections';\nimport type { D1Database } from '@cloudflare/workers-types';\nimport type { D1ConnectionPool } from '../../../cloudflare';\nimport {\n dumboDatabaseDriverRegistry,\n type DumboConnectionOptions,\n type DumboDatabaseDriver,\n} from '../../../core';\nimport {\n DefaultSQLiteMigratorOptions,\n sqliteFormatter,\n sqliteMetadata,\n} from '../core';\nimport { D1DriverType, type D1Connection } from './connections';\nimport { d1Pool, type D1PoolOptions } from './pool';\n\nexport type D1DumboOptions = D1PoolOptions;\n\nexport const d1DumboDriver: DumboDatabaseDriver<\n D1Connection,\n D1DumboOptions,\n D1ConnectionPool\n> = {\n driverType: D1DriverType,\n createPool: (options) => d1Pool(options),\n sqlFormatter: sqliteFormatter,\n defaultMigratorOptions: DefaultSQLiteMigratorOptions,\n canHandle: (options) => {\n return options.driverType === D1DriverType && 'database' in options;\n },\n databaseMetadata: sqliteMetadata,\n};\n\nexport const useD1DumboDriver = () => {\n dumboDatabaseDriverRegistry.register(D1DriverType, d1DumboDriver);\n};\n\nexport type D1DumboConnectionOptions = DumboConnectionOptions<\n typeof d1DumboDriver\n> & { database: D1Database };\n\nuseD1DumboDriver();\n\nexport * from './connections';\nexport * from './errors';\nexport * from './execute';\nexport * from './formatter';\nexport * from './pool';\nexport * from './transactions';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCO,IAAM,WAAW,CAAC,YAAuC;AAC9D,QAAM,EAAE,UAAU,SAAS,WAAW,IAAI;AAE1C,QAAM,UAAU,WAAW;AAE3B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,SAAS,MAAM,QAAQ,QAAQ;AAAA,IAC/B,OAAO,MAAM,QAAQ,QAAQ;AAAA,IAC7B,aAAa,OAAO,yBAA4C;AAC9D,YAAM,aAAa,uBACf,SAAS,YAAY,oBAA8B,IACnD,SAAS,YAAY;AAEzB,aAAO,Q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M,WAAW,UAAUA,QAAO;AAE5D,QAAI;AACF,aAAO,MAAM,OAAO,iBAAiB;AAAA,IACvC,UAAE;AACA,YAAM,kBAAkB,MAAM;AAAA,IAChC;AAAA,EACF;AAEA,SAAO;AACT;;;AC/DO,IAAM,SAAS,CAAC,YACrB,8BAA4C;AAAA,EAC1C,YAAY;AAAA,EACZ,eAAe,MACb,aAAa;AAAA,IACX,GAAG;AAAA,IACH,YAAY,eAAe,KAAK,OAAO;AAAA,EACzC,CAAC;AACL,CAAC;;;ACRI,IAAM,gBAIT;AAAA,EACF,YAAY;AAAA,EACZ,YAAY,CAAC,YAAY,OAAO,OAAO;AAAA,EACvC,cAAc;AAAA,EACd,wBAAwB;AAAA,EACxB,WAAW,CAAC,YAAY;AACtB,WAAO,QAAQ,eAAe,gBAAgB,cAAc;AAAA,EAC9D;AAAA,EACA,kBAAkB;AACpB;AAEO,IAAM,mBAAmB,MAAM;AACpC,8BAA4B,SAAS,cAAc,aAAa;AAClE;AAMA,iBAAiB;","names":["options","embeddedCode","client","connection","options"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SQLColumnTypeTokens, a as SQLProcessor, D as DefaultSQLColumnToken, b as SQLProcessorContext } from './connectionString-
|
|
1
|
+
import { S as SQLColumnTypeTokens, a as SQLProcessor, D as DefaultSQLColumnToken, b as SQLProcessorContext } from './connectionString-J4yRT71A.cjs';
|
|
2
2
|
|
|
3
3
|
type DefaultSQLColumnProcessors = {
|
|
4
4
|
[key in keyof SQLColumnTypeTokens]: SQLProcessor<SQLColumnTypeTokens[key]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SQLColumnTypeTokens, a as SQLProcessor, D as DefaultSQLColumnToken, b as SQLProcessorContext } from './connectionString-
|
|
1
|
+
import { S as SQLColumnTypeTokens, a as SQLProcessor, D as DefaultSQLColumnToken, b as SQLProcessorContext } from './connectionString-J4yRT71A.js';
|
|
2
2
|
|
|
3
3
|
type DefaultSQLColumnProcessors = {
|
|
4
4
|
[key in keyof SQLColumnTypeTokens]: SQLProcessor<SQLColumnTypeTokens[key]>;
|
|
@@ -1338,43 +1338,46 @@ declare function getDatabaseDriverName<T extends DatabaseType>(databaseDriverTyp
|
|
|
1338
1338
|
*/
|
|
1339
1339
|
declare function getDatabaseType<T extends DatabaseType>(databaseDriverType: DatabaseDriverType<T>): DatabaseType;
|
|
1340
1340
|
|
|
1341
|
-
interface DatabaseTransaction<ConnectionType extends AnyConnection = AnyConnection> extends WithSQLExecutor {
|
|
1341
|
+
interface DatabaseTransaction<ConnectionType extends AnyConnection = AnyConnection, TransactionOptionsType extends DatabaseTransactionOptions = DatabaseTransactionOptions> extends WithSQLExecutor {
|
|
1342
1342
|
driverType: ConnectionType['driverType'];
|
|
1343
1343
|
connection: ConnectionType;
|
|
1344
1344
|
begin: () => Promise<void>;
|
|
1345
1345
|
commit: () => Promise<void>;
|
|
1346
1346
|
rollback: (error?: unknown) => Promise<void>;
|
|
1347
|
+
_transactionOptions: TransactionOptionsType;
|
|
1347
1348
|
}
|
|
1348
|
-
type AnyDatabaseTransaction = DatabaseTransaction<any>;
|
|
1349
|
+
type AnyDatabaseTransaction = DatabaseTransaction<any, any>;
|
|
1349
1350
|
type DatabaseTransactionOptions = {
|
|
1350
1351
|
allowNestedTransactions?: boolean;
|
|
1351
1352
|
readonly?: boolean;
|
|
1352
1353
|
};
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1354
|
+
type InferTransactionOptionsFromTransaction<C extends AnyDatabaseTransaction> = C extends DatabaseTransaction<any, infer TO> ? TO : never;
|
|
1355
|
+
interface WithDatabaseTransactionFactory<ConnectionType extends AnyConnection = AnyConnection> {
|
|
1356
|
+
transaction: (options?: InferTransactionOptionsFromConnection<ConnectionType>) => InferTransactionFromConnection<ConnectionType>;
|
|
1357
|
+
withTransaction: <Result = never>(handle: (transaction: InferTransactionFromConnection<ConnectionType>) => Promise<TransactionResult<Result> | Result>, options?: InferTransactionOptionsFromConnection<ConnectionType>) => Promise<Result>;
|
|
1356
1358
|
}
|
|
1357
1359
|
type TransactionResult<Result> = {
|
|
1358
1360
|
success: boolean;
|
|
1359
1361
|
result: Result;
|
|
1360
1362
|
};
|
|
1361
1363
|
declare const executeInTransaction: <DatabaseTransactionType extends AnyDatabaseTransaction = AnyDatabaseTransaction, Result = void>(transaction: DatabaseTransactionType, handle: (transaction: DatabaseTransactionType) => Promise<TransactionResult<Result> | Result>) => Promise<Result>;
|
|
1362
|
-
declare const transactionFactoryWithDbClient: <ConnectionType extends AnyConnection = AnyConnection
|
|
1364
|
+
declare const transactionFactoryWithDbClient: <ConnectionType extends AnyConnection = AnyConnection>(connect: () => Promise<InferDbClientFromConnection<ConnectionType>>, initTransaction: (client: Promise<InferDbClientFromConnection<ConnectionType>>, options?: InferTransactionOptionsFromConnection<ConnectionType> & {
|
|
1363
1365
|
close: (client: InferDbClientFromConnection<ConnectionType>, error?: unknown) => Promise<void>;
|
|
1364
|
-
}) =>
|
|
1365
|
-
declare const transactionFactoryWithNewConnection: <ConnectionType extends AnyConnection = AnyConnection
|
|
1366
|
+
}) => InferTransactionFromConnection<ConnectionType>) => WithDatabaseTransactionFactory<ConnectionType>;
|
|
1367
|
+
declare const transactionFactoryWithNewConnection: <ConnectionType extends AnyConnection = AnyConnection>(connect: () => ConnectionType) => WithDatabaseTransactionFactory<ConnectionType>;
|
|
1366
1368
|
declare const transactionFactoryWithAmbientConnection: <ConnectionType extends AnyConnection = AnyConnection>(connect: () => ConnectionType) => WithDatabaseTransactionFactory<ConnectionType>;
|
|
1367
1369
|
|
|
1368
|
-
interface Connection<Self extends AnyConnection = AnyConnection, DriverType extends DatabaseDriverType = DatabaseDriverType, DbClient = unknown, TransactionType extends DatabaseTransaction<Self> = DatabaseTransaction<Self
|
|
1370
|
+
interface Connection<Self extends AnyConnection = AnyConnection, DriverType extends DatabaseDriverType = DatabaseDriverType, DbClient = unknown, TransactionType extends DatabaseTransaction<Self, any> = DatabaseTransaction<Self, any>> extends WithSQLExecutor, WithDatabaseTransactionFactory<Self> {
|
|
1369
1371
|
driverType: DriverType;
|
|
1370
1372
|
open: () => Promise<DbClient>;
|
|
1371
1373
|
close: () => Promise<void>;
|
|
1374
|
+
_transactionType: TransactionType;
|
|
1372
1375
|
}
|
|
1373
|
-
type AnyConnection = Connection<AnyConnection, DatabaseDriverType, unknown, AnyDatabaseTransaction
|
|
1374
|
-
type InferDriverTypeFromConnection<C extends AnyConnection> = C extends Connection<any, infer DT, any, any
|
|
1375
|
-
type InferDbClientFromConnection<C extends AnyConnection> = C extends Connection<any, any, infer DC, any
|
|
1376
|
-
type InferTransactionFromConnection<C extends AnyConnection> = C extends Connection<any, any, any, infer DT
|
|
1377
|
-
type InferTransactionOptionsFromConnection<C extends AnyConnection> = C
|
|
1376
|
+
type AnyConnection = Connection<AnyConnection, DatabaseDriverType, unknown, AnyDatabaseTransaction>;
|
|
1377
|
+
type InferDriverTypeFromConnection<C extends AnyConnection> = C extends Connection<any, infer DT, any, any> ? DT : never;
|
|
1378
|
+
type InferDbClientFromConnection<C extends AnyConnection> = C extends Connection<any, any, infer DC, any> ? DC : never;
|
|
1379
|
+
type InferTransactionFromConnection<C extends AnyConnection> = C extends Connection<any, any, any, infer DT> ? DT : never;
|
|
1380
|
+
type InferTransactionOptionsFromConnection<C extends AnyConnection> = InferTransactionOptionsFromTransaction<InferTransactionFromConnection<C>>;
|
|
1378
1381
|
type ConnectionOptions<ConnectionType extends AnyConnection = AnyConnection> = {
|
|
1379
1382
|
driverType?: ConnectionType['driverType'];
|
|
1380
1383
|
transactionOptions?: InferTransactionOptionsFromConnection<ConnectionType>;
|
|
@@ -1384,49 +1387,49 @@ type WithConnectionOptions = {
|
|
|
1384
1387
|
readonly?: boolean;
|
|
1385
1388
|
};
|
|
1386
1389
|
interface WithConnectionFactory<ConnectionType extends AnyConnection = AnyConnection> {
|
|
1387
|
-
connection: () => Promise<ConnectionType>;
|
|
1390
|
+
connection: (options?: WithConnectionOptions) => Promise<ConnectionType>;
|
|
1388
1391
|
withConnection: <Result = unknown>(handle: (connection: ConnectionType) => Promise<Result>, options?: WithConnectionOptions) => Promise<Result>;
|
|
1389
1392
|
}
|
|
1390
|
-
type InitTransaction<ConnectionType extends AnyConnection = AnyConnection
|
|
1393
|
+
type InitTransaction<ConnectionType extends AnyConnection = AnyConnection> = (connection: () => ConnectionType) => (client: Promise<InferDbClientFromConnection<ConnectionType>>, options?: InferTransactionOptionsFromConnection<ConnectionType> & {
|
|
1391
1394
|
close: (client: InferDbClientFromConnection<ConnectionType>, error?: unknown) => Promise<void>;
|
|
1392
|
-
}) =>
|
|
1393
|
-
type CreateConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor
|
|
1395
|
+
}) => InferTransactionFromConnection<ConnectionType>;
|
|
1396
|
+
type CreateConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor> = {
|
|
1394
1397
|
driverType: InferDriverTypeFromConnection<ConnectionType>;
|
|
1395
1398
|
connect: () => Promise<InferDbClientFromConnection<ConnectionType>>;
|
|
1396
1399
|
close: (client: InferDbClientFromConnection<ConnectionType>) => Promise<void>;
|
|
1397
|
-
initTransaction: InitTransaction<ConnectionType
|
|
1400
|
+
initTransaction: InitTransaction<ConnectionType>;
|
|
1398
1401
|
serializer: JSONSerializer;
|
|
1399
1402
|
executor: (options: DbSQLExecutorOptions) => Executor;
|
|
1400
1403
|
};
|
|
1401
|
-
type CreateAmbientConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor
|
|
1404
|
+
type CreateAmbientConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor> = {
|
|
1402
1405
|
driverType: InferDriverTypeFromConnection<ConnectionType>;
|
|
1403
1406
|
client: InferDbClientFromConnection<ConnectionType>;
|
|
1404
1407
|
serializer: JSONSerializer;
|
|
1405
|
-
initTransaction: InitTransaction<ConnectionType
|
|
1408
|
+
initTransaction: InitTransaction<ConnectionType>;
|
|
1406
1409
|
executor: (options: DbSQLExecutorOptions) => Executor;
|
|
1407
1410
|
};
|
|
1408
|
-
declare const createAmbientConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor
|
|
1409
|
-
type CreateSingletonConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor
|
|
1411
|
+
declare const createAmbientConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor>(options: CreateAmbientConnectionOptions<ConnectionType, Executor>) => ConnectionType;
|
|
1412
|
+
type CreateSingletonConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor> = {
|
|
1410
1413
|
driverType: InferDriverTypeFromConnection<ConnectionType>;
|
|
1411
1414
|
connect: () => Promise<InferDbClientFromConnection<ConnectionType>>;
|
|
1412
1415
|
close: (client: InferDbClientFromConnection<ConnectionType>) => Promise<void>;
|
|
1413
|
-
initTransaction: InitTransaction<ConnectionType
|
|
1416
|
+
initTransaction: InitTransaction<ConnectionType>;
|
|
1414
1417
|
serializer: JSONSerializer;
|
|
1415
1418
|
executor: (options: DbSQLExecutorOptions) => Executor;
|
|
1416
1419
|
};
|
|
1417
|
-
declare const createSingletonConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor
|
|
1418
|
-
type CreateTransientConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor
|
|
1420
|
+
declare const createSingletonConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor>(options: CreateSingletonConnectionOptions<ConnectionType, Executor>) => ConnectionType;
|
|
1421
|
+
type CreateTransientConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor> = {
|
|
1419
1422
|
driverType: InferDriverTypeFromConnection<ConnectionType>;
|
|
1420
1423
|
open: () => Promise<InferDbClientFromConnection<ConnectionType>>;
|
|
1421
1424
|
close: () => Promise<void>;
|
|
1422
|
-
initTransaction: InitTransaction<ConnectionType
|
|
1425
|
+
initTransaction: InitTransaction<ConnectionType>;
|
|
1423
1426
|
serializer: JSONSerializer;
|
|
1424
1427
|
executor: (options: DbSQLExecutorOptions) => Executor;
|
|
1425
1428
|
};
|
|
1426
|
-
declare const createTransientConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor
|
|
1427
|
-
declare const createConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor
|
|
1429
|
+
declare const createTransientConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor>(options: CreateTransientConnectionOptions<ConnectionType, Executor>) => ConnectionType;
|
|
1430
|
+
declare const createConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor>(options: CreateConnectionOptions<ConnectionType, Executor>) => ConnectionType;
|
|
1428
1431
|
|
|
1429
|
-
interface ConnectionPool<ConnectionType extends AnyConnection = AnyConnection
|
|
1432
|
+
interface ConnectionPool<ConnectionType extends AnyConnection = AnyConnection> extends WithSQLExecutor, WithConnectionFactory<ConnectionType>, WithDatabaseTransactionFactory<ConnectionType> {
|
|
1430
1433
|
driverType: ConnectionType['driverType'];
|
|
1431
1434
|
close: () => Promise<void>;
|
|
1432
1435
|
}
|
|
@@ -1442,6 +1445,12 @@ type SingletonConnectionPoolOptions<ConnectionType extends AnyConnection> = {
|
|
|
1442
1445
|
connectionOptions?: never;
|
|
1443
1446
|
};
|
|
1444
1447
|
declare const createSingletonConnectionPool: <ConnectionType extends AnyConnection>(options: SingletonConnectionPoolOptions<ConnectionType>) => ConnectionPool<ConnectionType>;
|
|
1448
|
+
type CreateBoundedConnectionPoolOptions<ConnectionType extends AnyConnection> = {
|
|
1449
|
+
driverType: ConnectionType['driverType'];
|
|
1450
|
+
getConnection: () => ConnectionType | Promise<ConnectionType>;
|
|
1451
|
+
maxConnections: number;
|
|
1452
|
+
};
|
|
1453
|
+
declare const createBoundedConnectionPool: <ConnectionType extends AnyConnection>(options: CreateBoundedConnectionPoolOptions<ConnectionType>) => ConnectionPool<ConnectionType>;
|
|
1445
1454
|
type SingletonClientConnectionPoolOptions<ConnectionType extends AnyConnection> = {
|
|
1446
1455
|
driverType: ConnectionType['driverType'];
|
|
1447
1456
|
dbClient: InferDbClientFromConnection<ConnectionType>;
|
|
@@ -1483,4 +1492,4 @@ type DatabaseConnectionString<DatabaseTypeName extends DatabaseType = DatabaseTy
|
|
|
1483
1492
|
};
|
|
1484
1493
|
declare const parseConnectionString: (connectionString: DatabaseConnectionString | string) => DatabaseDriverTypeParts;
|
|
1485
1494
|
|
|
1486
|
-
export { type CreateTransientConnectionOptions as $, type AnyConnection as A, type
|
|
1495
|
+
export { type CreateTransientConnectionOptions as $, type AnyConnection as A, type AnyTypeValidationError as B, type Connection as C, type DefaultSQLColumnToken as D, type TypeValidationSuccess as E, type AnyDumboDatabaseDriver as F, type ExtractDumboDatabaseDriverOptions as G, type ExtractDumboTypeFromDriver as H, IndexURN as I, JSONSerializer as J, type InferDriverTypeFromConnection as K, type InferDbClientFromConnection as L, type MigratorOptions as M, type InferTransactionFromConnection as N, type InferTransactionOptionsFromConnection as O, type ConnectionFactory as P, type QueryResultRow as Q, type WithConnectionFactory as R, SQLColumnTypeTokens as S, TableURN as T, type InitTransaction as U, type CreateConnectionOptions as V, type WithConnectionOptions as W, type CreateAmbientConnectionOptions as X, createAmbientConnection as Y, type CreateSingletonConnectionOptions as Z, createSingletonConnection as _, SQLProcessor as a, type WithSQLExecutor as a$, createTransientConnection as a0, createConnection as a1, type ConnectionPoolFactory as a2, type AmbientConnectionPoolOptions as a3, createAmbientConnectionPool as a4, type SingletonConnectionPoolOptions as a5, createSingletonConnectionPool as a6, type CreateBoundedConnectionPoolOptions as a7, createBoundedConnectionPool as a8, type SingletonClientConnectionPoolOptions as a9, ConnectionError as aA, SerializationError as aB, DeadlockError as aC, LockNotAvailableError as aD, InsufficientResourcesError as aE, SystemError as aF, AdminShutdownError as aG, QueryCanceledError as aH, IntegrityConstraintViolationError as aI, UniqueConstraintError as aJ, ForeignKeyViolationError as aK, NotNullViolationError as aL, CheckViolationError as aM, ExclusionViolationError as aN, DataError as aO, InvalidOperationError as aP, mapColumnToJSON as aQ, mapColumnToBigint as aR, mapColumnToDate as aS, mapSQLQueryResult as aT, type SQLQueryResultColumnMapping as aU, type SQLQueryOptions as aV, type SQLCommandOptions as aW, type BatchSQLCommandOptions as aX, BatchCommandNoChangesError as aY, type DbSQLExecutorOptions as aZ, type SQLExecutor as a_, createSingletonClientConnectionPool as aa, type CreateAlwaysNewConnectionPoolOptions as ab, createAlwaysNewConnectionPool as ac, type CreateConnectionPoolOptions as ad, createConnectionPool as ae, type AnyDatabaseTransaction as af, type InferTransactionOptionsFromTransaction as ag, type WithDatabaseTransactionFactory as ah, type TransactionResult as ai, executeInTransaction as aj, transactionFactoryWithDbClient as ak, transactionFactoryWithNewConnection as al, transactionFactoryWithAmbientConnection as am, type DatabaseType as an, type DatabaseDriverName as ao, type InferDriverDatabaseType as ap, type DatabaseDriverTypeParts as aq, toDatabaseDriverType as ar, fromDatabaseDriverType as as, getDatabaseDriverName as at, getDatabaseType as au, canHandleDriverWithConnectionString as av, DumboDatabaseDriverRegistry as aw, dumboDatabaseDriverRegistry as ax, ConcurrencyError as ay, TransientDatabaseError as az, type SQLProcessorContext as b, type ValidateRelationshipLength as b$, sqlExecutor as b0, sqlExecutorInNewConnection as b1, sqlExecutorInAmbientConnection as b2, executeInNewDbClient as b3, executeInNewConnection as b4, executeInAmbientConnection as b5, type DatabaseLockOptions as b6, type AcquireDatabaseLockMode as b7, type AcquireDatabaseLockOptions as b8, type ReleaseDatabaseLockOptions as b9, type AllColumnReferences as bA, type AllColumnTypesInSchema as bB, type AllColumnReferencesInSchema as bC, type NormalizeReference as bD, type NormalizeColumnPath as bE, type ColumnName as bF, type TableColumnName as bG, type SchemaColumnName as bH, type ColumnPath as bI, type ColumnReference as bJ, type ColumnPathToReference as bK, type ParseReferencePath as bL, type LookupColumnType as bM, type RelationshipType as bN, type RelationshipDefinition as bO, type AnyTableRelationshipDefinition as bP, type AnyTableRelationshipDefinitionWithColumns as bQ, type TableRelationships as bR, relationship as bS, type AnyRelationshipDefinition as bT, type RelationshipColumnsMismatchError as bU, type RelationshipReferencesLengthMismatchError as bV, type ColumnReferenceExistanceError as bW, type ColumnReferenceTypeMismatchError as bX, type NoError as bY, type ColumnReferenceError as bZ, type RelationshipValidationError as b_, defaultDatabaseLockOptions as ba, type DatabaseLock as bb, NoDatabaseLock as bc, ColumnURNType as bd, type ColumnSchemaComponent as be, type AnyColumnSchemaComponent as bf, type ColumnSchemaComponentOptions as bg, columnSchemaComponent as bh, DatabaseURNType as bi, type DatabaseSchemas as bj, type DatabaseSchemaComponent as bk, type AnyDatabaseSchemaComponent as bl, databaseSchemaComponent as bm, DatabaseSchemaURNType as bn, type DatabaseSchemaTables as bo, type DatabaseSchemaSchemaComponent as bp, type AnyDatabaseSchemaSchemaComponent as bq, databaseSchemaSchemaComponent as br, IndexURNType as bs, type IndexSchemaComponent as bt, indexSchemaComponent as bu, type ExtractSchemaNames as bv, type ExtractTableNames as bw, type ExtractColumnNames as bx, type ExtractColumnTypeName as by, type AllColumnTypes as bz, type DumboDatabaseDriver as c, mapSchemaComponentsOfType as c$, type ValidateRelationshipColumns as c0, type ValidateColumnReference as c1, type ValidateColumnTypeMatch as c2, type ValidateColumnsMatch as c3, type ValidateReference as c4, type ValidateReferences as c5, type CollectReferencesErrors as c6, type SchemaTablesWithSingle as c7, type DatabaseSchemasWithSingle as c8, type ValidateRelationship as c9, type InferTableRow as cA, type TableRowType as cB, type InferSchemaTables as cC, type InferDatabaseSchemas as cD, type DatabaseCapabilities as cE, DumboDatabaseMetadataRegistry as cF, dumboDatabaseMetadataRegistry as cG, getDatabaseMetadata as cH, resolveDatabaseMetadata as cI, getDefaultDatabase as cJ, getDefaultDatabaseAsync as cK, dumboSchema as cL, MIGRATIONS_LOCK_ID as cM, registerDefaultMigratorOptions as cN, getDefaultMigratorOptionsFromRegistry as cO, type RunSQLMigrationsResult as cP, runSQLMigrations as cQ, combineMigrations as cR, type ExtractAdditionalData as cS, type AnySchemaComponent as cT, type AnySchemaComponentOfType as cU, type SchemaComponentOptions as cV, type SchemaComponentType as cW, type DumboSchemaComponentType as cX, schemaComponent as cY, isSchemaComponentOfType as cZ, filterSchemaComponentsOfType as c_, type CollectRelationshipErrors as ca, type ValidateTableRelationships as cb, type ValidateTable as cc, type ValidateSchemaTables as cd, type ValidateDatabaseSchema as ce, type ValidateDatabaseSchemas as cf, type ValidateDatabaseSchemasWithMessages as cg, type Join as ch, type IndentErrors as ci, type FormatSingleError as cj, type FormatRelationshipBlock as ck, type FormatTableLevel as cl, type FormatSchemaLevel as cm, type FormatDatabaseValidationErrors as cn, type FormatValidationErrors as co, TableURNType as cp, type TableColumns as cq, type TableSchemaComponent as cr, type InferTableSchemaComponentTypes as cs, type InferTableSchemaComponentColumns as ct, type AnyTableSchemaComponent as cu, tableSchemaComponent as cv, type Writable as cw, type InferColumnType as cx, type TableColumnType as cy, type TableColumnNames as cz, type ConnectionOptions as d, SQLValueMapper as d$, findSchemaComponentsOfType as d0, type MigrationStyle as d1, sqlMigration as d2, type MigrationRecord as d3, type Serializer as d4, type SerializationCodec as d5, composeJSONReplacers as d6, composeJSONRevivers as d7, JSONCodec as d8, JSONReplacer as d9, isSQL as dA, type JSONValueType as dB, type JSONValueTypeName as dC, type JavaScriptValueType as dD, type JavaScriptValueTypeName as dE, type JavaScriptValueTypeToNameMap as dF, ColumnTypeToken as dG, type AnyColumnTypeToken as dH, SerialToken as dI, BigSerialToken as dJ, IntegerToken as dK, BigIntegerToken as dL, JSONBToken as dM, TimestampToken as dN, TimestamptzToken as dO, VarcharToken as dP, type NotNullableSQLColumnTokenProps as dQ, type NullableSQLColumnTokenProps as dR, SQLColumnToken as dS, AutoIncrementSQLColumnToken as dT, SQLColumnTypeTokensFactory as dU, SQLToken as dV, type ExtractSQLTokenType as dW, SQLPlain as dX, type SQLArrayMode as dY, type SQLDefaultTokens as dZ, type SQLDefaultTokensTypes as d_, JSONReplacers as da, JSONReviver as db, JSONRevivers as dc, jsonSerializer as dd, type JSONCodecOptions as de, type JSONDeserializeOptions as df, type JSONSerializeOptions as dg, type JSONSerializerOptions as dh, type JSONReviverContext as di, type FormatContext as dj, type FormatSQLOptions as dk, type SQLFormatterOptions as dl, registerFormatter as dm, getFormatter as dn, formatSQL as dp, describeSQL as dq, type ParametrizedSQL as dr, ParametrizedSQLBuilder as ds, defaultProcessorsRegistry as dt, type AnySQLProcessor as du, type SQLProcessorOptions as dv, type SQLProcessorsReadonlyRegistry as dw, SQLProcessorsRegistry as dx, SQL as dy, RawSQL as dz, SQLFormatter as e, type MapSQLParamValue as e0, type MapSQLParamValueOptions as e1, ANSISQLParamPlaceholder as e2, ANSISQLIdentifierQuote as e3, mapANSISQLParamPlaceholder as e4, mapSQLIdentifier as e5, DefaultMapSQLParamValueOptions as e6, mapSQLParamValue as e7, type DatabaseConnectionString as e8, parseConnectionString as e9, type DatabaseMetadata as f, type DumboConnectionOptions as g, type DatabaseTransactionOptions as h, type DatabaseTransaction as i, type ConnectionPool as j, type JSONSerializationOptions as k, type DbSQLExecutor as l, DumboError as m, SQLArray as n, SQLIn as o, SQLIdentifier as p, SQLLiteral as q, type AnySQLToken as r, DatabaseURN as s, DatabaseSchemaURN as t, ColumnURN as u, type QueryResult as v, type SchemaComponent as w, type SQLMigration as x, type DatabaseDriverType as y, type Dumbo as z };
|