@event-driven-io/dumbo 0.13.0-beta.30 → 0.13.0-beta.32

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.
@@ -475,6 +475,10 @@ var parsePragmasFromConnectionString = (connectionString) => {
475
475
  if (busyTimeout !== null) {
476
476
  pragmas.busy_timeout = parseInt(busyTimeout, 10);
477
477
  }
478
+ const mmapSize = params.get("mmap_size");
479
+ if (mmapSize !== null) {
480
+ pragmas.mmap_size = parseInt(mmapSize, 10);
481
+ }
478
482
  return pragmas;
479
483
  };
480
484
 
@@ -602,7 +606,8 @@ var DEFAULT_SQLITE_PRAGMA_OPTIONS = {
602
606
  cache_size: -1e6,
603
607
  foreign_keys: true,
604
608
  temp_store: "MEMORY",
605
- busy_timeout: 5e3
609
+ busy_timeout: 5e3,
610
+ mmap_size: 268435456
606
611
  };
607
612
 
608
613
  // src/storage/sqlite/core/transactions/index.ts
@@ -703,4 +708,4 @@ export {
703
708
  DefaultSQLiteMigratorOptions,
704
709
  SQLiteDatabaseName
705
710
  };
706
- //# sourceMappingURL=chunk-XFEGS3YT.js.map
711
+ //# sourceMappingURL=chunk-CMHMR5VO.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/storage/sqlite/core/errors/errorMapper.ts","../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/dualPool.ts","../src/storage/sqlite/core/pool/pool.ts","../src/storage/sqlite/core/schema/migrations.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"],"sourcesContent":["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\n/**\n * Extracts the SQLite error code string from a `sqlite3` driver error.\n *\n * The `sqlite3` (node-sqlite3) driver sets `error.code` to a string like\n * `'SQLITE_CONSTRAINT'` and `error.errno` to the numeric result code.\n * See: https://github.com/TryGhost/node-sqlite3\n */\nconst getSqliteErrorCode = (error: unknown): string | undefined => {\n if (\n error instanceof Error &&\n 'code' in error &&\n typeof (error as Record<string, unknown>).code === 'string'\n ) {\n return (error as Record<string, unknown>).code as string;\n }\n return undefined;\n};\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 * Maps a constraint error to a specific DumboError subtype by inspecting the\n * error message. The `sqlite3` driver only exposes the primary result code\n * `SQLITE_CONSTRAINT` — the constraint subtype (UNIQUE, FOREIGN KEY, etc.)\n * is embedded in the message string by SQLite, e.g.:\n * \"SQLITE_CONSTRAINT: UNIQUE constraint failed: users.email\"\n *\n * Reference: https://www.sqlite.org/rescode.html (extended result codes 275–3091)\n */\nconst mapConstraintError = (\n message: string | undefined,\n innerError: Error | undefined,\n): DumboError => {\n const upperMessage = message?.toUpperCase() ?? '';\n\n // SQLITE_CONSTRAINT_UNIQUE (2067) / SQLITE_CONSTRAINT_PRIMARYKEY (1555)\n if (upperMessage.includes('UNIQUE') || upperMessage.includes('PRIMARY KEY'))\n return new UniqueConstraintError(message, innerError);\n\n // SQLITE_CONSTRAINT_FOREIGNKEY (787)\n if (upperMessage.includes('FOREIGN KEY'))\n return new ForeignKeyViolationError(message, innerError);\n\n // SQLITE_CONSTRAINT_NOTNULL (1299)\n if (upperMessage.includes('NOT NULL'))\n return new NotNullViolationError(message, innerError);\n\n // SQLITE_CONSTRAINT_CHECK (275)\n if (upperMessage.includes('CHECK'))\n return new CheckViolationError(message, innerError);\n\n // SQLITE_CONSTRAINT_ROWID (2579), SQLITE_CONSTRAINT_TRIGGER (1811),\n // SQLITE_CONSTRAINT_COMMITHOOK (531), SQLITE_CONSTRAINT_PINNED (2835),\n // SQLITE_CONSTRAINT_DATATYPE (3091), etc.\n return new IntegrityConstraintViolationError(message, innerError);\n};\n\n/**\n * Maps a SQLite error (from the `sqlite3` / node-sqlite3 driver) to a typed\n * DumboError based on the SQLite result code.\n *\n * Result code reference: https://www.sqlite.org/rescode.html\n *\n * Falls back to a generic DumboError (500) if the error is not a recognized SQLite error.\n */\nexport const mapSqliteError = (error: unknown): DumboError => {\n if (DumboError.isInstanceOf<DumboError>(error)) return error;\n\n const code = getSqliteErrorCode(error);\n if (!code)\n return new DumboError({\n errorCode: 500,\n message: getErrorMessage(error),\n innerError: asError(error),\n });\n\n const message = getErrorMessage(error);\n const innerError = asError(error);\n\n switch (code) {\n // ── Constraint violations (19) ──\n // node-sqlite3 only exposes the primary code; subtype is in the message.\n case 'SQLITE_CONSTRAINT':\n return mapConstraintError(message, innerError);\n\n // ── Busy / lock contention ──\n // SQLITE_BUSY (5): conflict with a separate database connection\n case 'SQLITE_BUSY':\n return new LockNotAvailableError(message, innerError);\n\n // SQLITE_LOCKED (6): conflict within the same connection or shared cache\n case 'SQLITE_LOCKED':\n return new DeadlockError(message, innerError);\n\n // SQLITE_PROTOCOL (15): WAL locking race condition\n case 'SQLITE_PROTOCOL':\n return new LockNotAvailableError(message, innerError);\n\n // ── Connection / open errors ──\n // SQLITE_CANTOPEN (14): unable to open database file\n case 'SQLITE_CANTOPEN':\n return new ConnectionError(message, innerError);\n\n // SQLITE_NOTADB (26): file is not a database\n case 'SQLITE_NOTADB':\n return new ConnectionError(message, innerError);\n\n // ── Resource exhaustion ──\n // SQLITE_NOMEM (7): out of memory\n case 'SQLITE_NOMEM':\n return new InsufficientResourcesError(message, innerError);\n\n // SQLITE_FULL (13): disk full\n case 'SQLITE_FULL':\n return new InsufficientResourcesError(message, innerError);\n\n // ── System / I/O errors ──\n // SQLITE_IOERR (10): operating system I/O error\n case 'SQLITE_IOERR':\n return new SystemError(message, innerError);\n\n // SQLITE_CORRUPT (11): database file is corrupted\n case 'SQLITE_CORRUPT':\n return new SystemError(message, innerError);\n\n // SQLITE_INTERNAL (2): internal SQLite malfunction\n case 'SQLITE_INTERNAL':\n return new SystemError(message, innerError);\n\n // SQLITE_NOLFS (22): large file support unavailable\n case 'SQLITE_NOLFS':\n return new SystemError(message, innerError);\n\n // ── Data errors ──\n // SQLITE_TOOBIG (18): string or BLOB too large\n case 'SQLITE_TOOBIG':\n return new DataError(message, innerError);\n\n // SQLITE_MISMATCH (20): datatype mismatch\n case 'SQLITE_MISMATCH':\n return new DataError(message, innerError);\n\n // SQLITE_RANGE (25): bind parameter index out of range\n case 'SQLITE_RANGE':\n return new DataError(message, innerError);\n\n // ── Invalid operations ──\n // SQLITE_ERROR (1): generic SQL error (syntax errors, missing tables, etc.)\n case 'SQLITE_ERROR':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_READONLY (8): attempt to write to a read-only database\n case 'SQLITE_READONLY':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_MISUSE (21): API misuse\n case 'SQLITE_MISUSE':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_AUTH (23): authorization denied\n case 'SQLITE_AUTH':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_PERM (3): access permission denied\n case 'SQLITE_PERM':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_SCHEMA (17): schema changed, statement needs re-preparation\n case 'SQLITE_SCHEMA':\n return new InvalidOperationError(message, innerError);\n\n // ── Transaction / abort ──\n // SQLITE_ABORT (4): operation aborted (e.g. by rollback)\n case 'SQLITE_ABORT':\n return new SerializationError(message, innerError);\n\n // SQLITE_INTERRUPT (9): operation interrupted\n case 'SQLITE_INTERRUPT':\n return new SerializationError(message, innerError);\n }\n\n return new DumboError({\n errorCode: 500,\n message,\n innerError,\n });\n};\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 = `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 type { JSONSerializer, SQLFormatter, SQL } from '../../../../core';\nimport {\n mapSQLQueryResult,\n tracer,\n type BatchSQLCommandOptions,\n type DbSQLExecutor,\n type QueryResult,\n type QueryResultRow,\n type SQLCommandOptions,\n type SQLQueryOptions,\n} from '../../../../core';\nimport type { DumboError } from '../../../../core/errors';\nimport type { SQLiteClient } from '../connections';\nimport { mapSqliteError } from '../errors/errorMapper';\nimport { sqliteFormatter } from '../sql/formatter';\n\nexport type SQLiteErrorMapper = (error: unknown) => DumboError;\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 serializer: JSONSerializer,\n formatter?: SQLFormatter,\n errorMapper?: SQLiteErrorMapper,\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 tracer.info('db:sql:query', {\n query: (formatter ?? sqliteFormatter).format(sql, { serializer }).query,\n params: (formatter ?? sqliteFormatter).format(sql, { serializer }).params,\n debugSQL: (formatter ?? sqliteFormatter).describe(sql, { serializer }),\n });\n\n try {\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 } catch (error) {\n tracer.error('db:sql:query:execute:error', { error });\n throw (errorMapper ?? mapSqliteError)(error);\n }\n },\n batchQuery: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sqls: SQL[],\n options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>[]> => {\n try {\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 } catch (error) {\n tracer.error('db:sql:batch_query:execute:error', { error });\n throw (errorMapper ?? mapSqliteError)(error);\n }\n },\n command: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sql: SQL,\n options?: SQLCommandOptions,\n ): Promise<QueryResult<Result>> => {\n tracer.info('db:sql:command', {\n query: (formatter ?? sqliteFormatter).format(sql, { serializer }).query,\n params: (formatter ?? sqliteFormatter).format(sql, { serializer }).params,\n debugSQL: (formatter ?? sqliteFormatter).describe(sql, { serializer }),\n });\n\n try {\n return await client.command<Result>(sql, options);\n } catch (error) {\n tracer.error('db:sql:command:execute:error', { error });\n throw (errorMapper ?? mapSqliteError)(error);\n }\n },\n batchCommand: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\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 (errorMapper ?? mapSqliteError)(error);\n }\n },\n formatter: formatter ?? sqliteFormatter,\n});\n","import { cpus } from 'os';\nimport {\n createBoundedConnectionPool,\n createSingletonConnectionPool,\n} from '../../../../core';\nimport { TaskProcessor } from '../../../../core/taskProcessing';\nimport type {\n AnySQLiteConnection,\n SQLiteConnectionFactory,\n SQLiteConnectionOptions,\n} from '../connections';\nimport { mapSqliteError } from '../errors';\nimport type { SQLitePool } from './pool';\n\nexport type SQLiteDualPoolOptions<\n SQLiteConnectionType extends AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions,\n> = {\n driverType: SQLiteConnectionType['driverType'];\n dual?: true;\n singleton?: false;\n pooled?: true;\n connection?: never;\n readerPoolSize?: number;\n sqliteConnectionFactory: SQLiteConnectionFactory<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n connectionOptions?: ConnectionOptions;\n};\n\nexport const sqliteDualConnectionPool = <\n SQLiteConnectionType extends AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions,\n>(\n options: SQLiteDualPoolOptions<SQLiteConnectionType, ConnectionOptions>,\n): SQLitePool<SQLiteConnectionType> => {\n const { sqliteConnectionFactory, connectionOptions } = options;\n const readerPoolSize = options.readerPoolSize ?? Math.max(4, cpus().length);\n\n let databaseInitPromise: Promise<void> | null = null;\n\n const initTaskProcessor = new TaskProcessor({\n maxActiveTasks: 1,\n maxQueueSize: 1000,\n });\n\n const ensureDatabaseInitialized = async (\n connectionOptions: ConnectionOptions | undefined,\n retryCount = 0,\n ): Promise<void> => {\n if (databaseInitPromise !== null) {\n return databaseInitPromise;\n }\n\n return initTaskProcessor.enqueue(\n async ({ ack }) => {\n if (databaseInitPromise !== null) {\n ack();\n return databaseInitPromise;\n }\n\n const initConnection = sqliteConnectionFactory({\n ...connectionOptions,\n skipDatabasePragmas: false,\n readonly: false,\n } as ConnectionOptions);\n\n const initPromise = initConnection.open();\n databaseInitPromise = initPromise;\n\n try {\n await initPromise;\n await initConnection.close();\n ack();\n } catch (error) {\n databaseInitPromise = null;\n await initConnection.close();\n ack();\n if (retryCount < 3) {\n return ensureDatabaseInitialized(connectionOptions, retryCount + 1);\n }\n throw mapSqliteError(error);\n }\n },\n { taskGroupId: 'db-init' },\n );\n };\n\n const wrappedConnectionFactory = async (\n readonly: boolean,\n connectionOptions: ConnectionOptions | undefined,\n ): Promise<SQLiteConnectionType> => {\n await ensureDatabaseInitialized(connectionOptions);\n\n const connection = sqliteConnectionFactory({\n ...connectionOptions,\n skipDatabasePragmas: true,\n readonly,\n } as ConnectionOptions);\n\n await connection.open();\n\n return connection;\n };\n\n const writerPool = createSingletonConnectionPool({\n driverType: options.driverType,\n getConnection: () => wrappedConnectionFactory(false, connectionOptions),\n });\n\n const readerPool = createBoundedConnectionPool({\n driverType: options.driverType,\n getConnection: () => wrappedConnectionFactory(true, connectionOptions),\n maxConnections: readerPoolSize,\n });\n\n return {\n driverType: options.driverType,\n connection: (connectionOptions) =>\n connectionOptions?.readonly\n ? readerPool.connection(connectionOptions)\n : writerPool.connection(connectionOptions),\n execute: {\n query: (...args) => readerPool.execute.query(...args),\n batchQuery: (...args) => readerPool.execute.batchQuery(...args),\n command: (...args) => writerPool.execute.command(...args),\n batchCommand: (...args) => writerPool.execute.batchCommand(...args),\n },\n withConnection: (handle, connectionOptions) =>\n connectionOptions?.readonly\n ? readerPool.withConnection(handle, connectionOptions)\n : writerPool.withConnection(handle, connectionOptions),\n transaction: writerPool.transaction,\n withTransaction: writerPool.withTransaction,\n close: () =>\n Promise.all([writerPool.close(), readerPool.close()]).then(() => {}),\n };\n};\n","import type { SQLiteConnectionString } from '..';\nimport {\n InMemorySQLiteDatabase,\n type AnySQLiteConnection,\n type SQLiteConnectionFactory,\n type SQLiteConnectionOptions,\n} from '..';\nimport type { JSONSerializer } from '../../../../core';\nimport {\n createAlwaysNewConnectionPool,\n createAmbientConnectionPool,\n createSingletonConnectionPool,\n type ConnectionPool,\n} from '../../../../core';\nimport {\n sqliteDualConnectionPool,\n type SQLiteDualPoolOptions,\n} from './dualPool';\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 }) as unknown as SQLiteAmbientConnectionPool<\n SQLiteConnectionType['driverType']\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 & Record<string, unknown> =\n 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 }) as unknown as SQLiteSingletonConnectionPool<SQLiteConnectionType>;\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 & Record<string, unknown> =\n 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 }) as unknown as SQLiteAlwaysNewConnectionPool<SQLiteConnectionType>;\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 | SQLiteDualPoolOptions<SQLiteConnectionType, ConnectionOptions>\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 isInMemory = isInMemoryDatabase(options);\n\n if ('client' in options && options.client) {\n return { ...rest, singleton: true } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n }\n\n if (isInMemory) {\n return { ...rest, singleton: true } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n }\n\n if (singleton === true) {\n return { ...rest, singleton: true } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n }\n\n return { ...rest, dual: true } 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 if (\n (\n options as SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType> & {\n driverType: SQLiteConnectionType['driverType'];\n }\n ).connection\n )\n return createAmbientConnectionPool<SQLiteConnectionType>({\n driverType,\n connection: (\n options as SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType> & {\n driverType: SQLiteConnectionType['driverType'];\n }\n ).connection,\n });\n\n if ('dual' in options && options.dual) {\n return sqliteDualConnectionPool(\n options as SQLiteDualPoolOptions<SQLiteConnectionType, ConnectionOptions>,\n );\n }\n\n if (\n options.singleton === true &&\n (\n options as SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).sqliteConnectionFactory\n ) {\n return createSingletonConnectionPool({\n driverType,\n getConnection: () =>\n (\n options as SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).sqliteConnectionFactory(\n (\n options as SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).connectionOptions,\n ),\n });\n }\n\n return createAlwaysNewConnectionPool({\n driverType,\n getConnection: () =>\n (\n options as SQLiteAlwaysNewPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).sqliteConnectionFactory(\n (\n options as SQLiteAlwaysNewPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).connectionOptions,\n ),\n });\n}\n","import {\n registerDefaultMigratorOptions,\n type MigratorOptions,\n} from '../../../../core';\n\nexport const DefaultSQLiteMigratorOptions: MigratorOptions = {};\n\nregisterDefaultMigratorOptions('SQLite', DefaultSQLiteMigratorOptions);\n","import type { DatabaseDriverType } from '../../..';\n\nexport * from './connections';\nexport * from './errors';\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';\nimport type { SQLitePragmaOptions } from './index';\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\nexport const parsePragmasFromConnectionString = (\n connectionString: string | SQLiteConnectionString,\n): Partial<SQLitePragmaOptions> => {\n const str = String(connectionString);\n\n if (!str.startsWith('file:')) {\n return {};\n }\n\n const url = new URL(str);\n const params = url.searchParams;\n const pragmas: Partial<SQLitePragmaOptions> = {};\n\n const journalMode = params.get('journal_mode');\n if (journalMode !== null) {\n pragmas.journal_mode = journalMode as\n | 'DELETE'\n | 'TRUNCATE'\n | 'PERSIST'\n | 'MEMORY'\n | 'WAL'\n | 'OFF';\n }\n\n const synchronous = params.get('synchronous');\n if (synchronous !== null) {\n pragmas.synchronous = synchronous as 'OFF' | 'NORMAL' | 'FULL' | 'EXTRA';\n }\n\n const cacheSize = params.get('cache_size');\n if (cacheSize !== null) {\n pragmas.cache_size = parseInt(cacheSize, 10);\n }\n\n const foreignKeys = params.get('foreign_keys');\n if (foreignKeys !== null) {\n const val = foreignKeys.toLowerCase();\n pragmas.foreign_keys = val === 'true' || val === 'on' || val === '1';\n }\n\n const tempStore = params.get('temp_store');\n if (tempStore !== null) {\n pragmas.temp_store = tempStore.toUpperCase() as\n | 'DEFAULT'\n | 'FILE'\n | 'MEMORY';\n }\n\n const busyTimeout = params.get('busy_timeout');\n if (busyTimeout !== null) {\n pragmas.busy_timeout = parseInt(busyTimeout, 10);\n }\n\n return pragmas;\n};\n","import {\n mapSqliteError,\n SQLiteConnectionString,\n sqliteSQLExecutor,\n type SQLiteDriverType,\n type SQLiteErrorMapper,\n} from '..';\nimport type { JSONSerializer } from '../../../../core';\nimport {\n createAmbientConnection,\n createConnection,\n type AnyConnection,\n type BatchSQLCommandOptions,\n type Connection,\n type ConnectionOptions,\n type DatabaseTransaction,\n type InferDbClientFromConnection,\n type InferDriverTypeFromConnection,\n type InitTransaction,\n type SQLCommandOptions,\n type SQLExecutor,\n} from '../../../../core';\nimport { sqliteTransaction, type SQLiteTransactionMode } from '../transactions';\n\nexport type SQLiteCommandOptions = SQLCommandOptions & {\n ignoreChangesCount?: boolean;\n};\n\nexport type BatchSQLiteCommandOptions = SQLiteCommandOptions &\n BatchSQLCommandOptions;\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> = Connection<Self, DriverType, SQLiteClientType, TransactionType>;\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> = Connection<Self, DriverType, SQLitePoolClientType, TransactionType>;\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> =\n | (SQLiteClientType extends SQLiteClient\n ? SQLiteClientConnection<\n Self,\n DriverType,\n SQLiteClientType,\n TransactionType\n >\n : never)\n | (SQLiteClientType extends SQLitePoolClient\n ? SQLitePoolClientConnection<\n Self,\n DriverType,\n SQLiteClientType,\n TransactionType\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>;\n\nexport type AnySQLiteConnection =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n SQLiteConnection<any, any, any, any>;\n\nexport type SQLiteConnectionOptions<\n ConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = ConnectionOptions<ConnectionType> & SQLiteClientOptions;\n\nexport type SQLiteClientConnectionDefinitionOptions<\n SQLiteConnectionType extends AnySQLiteClientConnection =\n 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 serializer: JSONSerializer;\n};\n\nexport type SQLitePoolConnectionDefinitionOptions<\n SQLiteConnectionType extends AnySQLitePoolClientConnection =\n 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 serializer: JSONSerializer;\n};\n\nexport type SQLiteConnectionDefinitionOptions<\n SQLiteConnectionType extends AnySQLitePoolClientConnection =\n 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 AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n> = {\n driverType: SQLiteConnectionType['driverType'];\n client: InferDbClientFromConnection<SQLiteConnectionType>;\n initTransaction?: InitTransaction<SQLiteConnectionType>;\n allowNestedTransactions?: boolean;\n defaultTransactionMode?: SQLiteTransactionMode;\n serializer: JSONSerializer;\n errorMapper?: SQLiteErrorMapper;\n};\n\nexport const sqliteAmbientClientConnection = <\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n>(\n options: SqliteAmbientClientConnectionOptions<SQLiteConnectionType>,\n) => {\n const {\n client,\n driverType,\n initTransaction,\n allowNestedTransactions,\n defaultTransactionMode,\n serializer,\n errorMapper,\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 serializer,\n defaultTransactionMode,\n )),\n executor: ({ serializer }) =>\n sqliteSQLExecutor(driverType, serializer, undefined, errorMapper),\n serializer,\n });\n};\n\nexport const sqliteClientConnection = <\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n ClientOptions = SQLiteClientOptions,\n>(\n options: SQLiteClientConnectionDefinitionOptions<\n SQLiteConnectionType,\n ClientOptions\n >,\n): SQLiteConnectionType => {\n const { connectionOptions, sqliteClientFactory, serializer } = 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 try {\n await client.connect();\n } catch (error) {\n throw mapSqliteError(error);\n }\n }\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 serializer,\n connectionOptions.defaultTransactionMode,\n ),\n executor: ({ serializer }) =>\n sqliteSQLExecutor(options.driverType, serializer),\n serializer,\n });\n};\n\nexport const sqlitePoolClientConnection = <\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n ClientOptions = SQLiteClientOptions,\n>(\n options: SQLitePoolConnectionDefinitionOptions<\n SQLiteConnectionType,\n ClientOptions\n >,\n): SQLiteConnectionType => {\n const { connectionOptions, sqliteClientFactory, serializer } = 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 try {\n await client.connect();\n } catch (error) {\n throw mapSqliteError(error);\n }\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 serializer,\n connectionOptions.defaultTransactionMode,\n ),\n executor: ({ serializer }) =>\n sqliteSQLExecutor(options.driverType, serializer),\n serializer,\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\nexport type SQLitePragmaOptions = {\n journal_mode?: 'DELETE' | 'TRUNCATE' | 'PERSIST' | 'MEMORY' | 'WAL' | 'OFF';\n synchronous?: 'OFF' | 'NORMAL' | 'FULL' | 'EXTRA';\n cache_size?: number;\n foreign_keys?: boolean;\n temp_store?: 'DEFAULT' | 'FILE' | 'MEMORY';\n busy_timeout?: number;\n};\n\nexport const DEFAULT_SQLITE_PRAGMA_OPTIONS: SQLitePragmaOptions = {\n journal_mode: 'WAL',\n synchronous: 'NORMAL',\n cache_size: -1000000,\n foreign_keys: true,\n temp_store: 'MEMORY',\n busy_timeout: 5000,\n};\n\nexport type SQLiteClientOptions = {\n pragmaOptions?: Partial<SQLitePragmaOptions>;\n defaultTransactionMode?: SQLiteTransactionMode;\n skipDatabasePragmas?: boolean;\n readonly?: boolean;\n};\n\nexport * from './connectionString';\n","import type {\n InferTransactionFromConnection,\n JSONSerializer,\n} from '../../../../core';\nimport {\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 TransactionOptions extends SQLiteTransactionOptions =\n SQLiteTransactionOptions,\n> = DatabaseTransaction<ConnectionType, TransactionOptions>;\n\nexport type SQLiteTransactionMode = 'DEFERRED' | 'IMMEDIATE' | 'EXCLUSIVE';\n\nexport type SQLiteTransactionOptions = DatabaseTransactionOptions & {\n mode?: SQLiteTransactionMode;\n useSavepoints?: boolean;\n};\n\nexport const sqliteTransaction =\n <ConnectionType extends AnySQLiteConnection = AnySQLiteConnection>(\n driverType: ConnectionType['driverType'],\n connection: () => ConnectionType,\n allowNestedTransactions: boolean,\n serializer: JSONSerializer,\n defaultTransactionMode?: 'IMMEDIATE' | 'DEFERRED' | 'EXCLUSIVE',\n ) =>\n (\n getClient: Promise<InferDbClientFromConnection<ConnectionType>>,\n options?: {\n close: (\n client: InferDbClientFromConnection<ConnectionType>,\n error?: unknown,\n ) => Promise<void>;\n } & SQLiteTransactionOptions,\n ): InferTransactionFromConnection<ConnectionType> => {\n const transactionCounter = transactionNestingCounter();\n allowNestedTransactions =\n options?.allowNestedTransactions ?? allowNestedTransactions;\n\n const transaction: DatabaseTransaction<ConnectionType> = {\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 if (options?.useSavepoints) {\n await client.query(\n SQL`SAVEPOINT transaction${SQL.plain(transactionCounter.level.toString())}`,\n );\n }\n return;\n }\n\n transactionCounter.increment();\n }\n\n const mode = options?.mode ?? defaultTransactionMode ?? 'IMMEDIATE';\n await client.query(SQL`BEGIN ${SQL.plain(mode)} 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 if (options?.useSavepoints) {\n await client.query(\n SQL`RELEASE transaction${SQL.plain(transactionCounter.level.toString())}`,\n );\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, serializer), {\n connect: () => getClient,\n }),\n _transactionOptions: options ?? {},\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return transaction as InferTransactionFromConnection<ConnectionType>;\n };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAM,qBAAqB,CAAC,UAAuC;AACjE,MACE,iBAAiB,SACjB,UAAU,SACV,OAAQ,MAAkC,SAAS,UACnD;AACA,WAAQ,MAAkC;AAAA,EAC5C;AACA,SAAO;AACT;AAEA,IAAM,kBAAkB,CAAC,UACvB,iBAAiB,QAAQ,MAAM,UAAU;AAE3C,IAAM,UAAU,CAAC,UACf,iBAAiB,QAAQ,QAA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AAyB;AAC3B,cAAI,mBAAmB,QAAQ,GAAG;AAChC,gBAAI,SAAS,eAAe;AAC1B,oBAAM,OAAO;AAAA,gBACX,yBAAyB,IAAI,MAAM,mBAAmB,MAAM,SAAS,CAAC,CAAC;AAAA,cACzE;AAAA,YACF;AACA,+BAAmB,UAAU;AAE7B;AAAA,UACF;AAEA,6BAAmB,MAAM;AAAA,QAC3B;AACA,cAAM,OAAO,MAAM,WAAW;AAAA,MAChC,UAAE;AACA,YAAI,SAAS;AACX,gBAAM,SAAS;AAAA,YACb;AAAA,UACF;AAAA,MACJ;AAAA,IACF;AAAA,IACA,UAAU,eAAgB,OAAiB;AACzC,YAAM,SAAU,MAAM;AACtB,UAAI;AACF,YAAI,yBAAyB;AAC3B,cAAI,mBAAmB,QAAQ,GAAG;AAChC,+BAAmB,UAAU;AAC7B;AAAA,UACF;AAAA,QACF;AAEA,cAAM,OAAO,MAAM,aAAa;AAAA,MAClC,UAAE;AACA,YAAI,SAAS;AACX,gBAAM,SAAS;AAAA,YACb;AAAA,YACA;AAAA,UACF;AAAA,MACJ;AAAA,IACF;AAAA,IACA,SAAS,YAAY,kBAAkB,YAAY,UAAU,GAAG;AAAA,MAC9D,SAAS,MAAM;AAAA,IACjB,CAAC;AAAA,IACD,qBAAqB,WAAW,CAAC;AAAA,EACnC;AAGA,SAAO;AACT;","names":["connectionOptions","serializer"]}
1
+ {"version":3,"sources":["../src/storage/sqlite/core/errors/errorMapper.ts","../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/dualPool.ts","../src/storage/sqlite/core/pool/pool.ts","../src/storage/sqlite/core/schema/migrations.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"],"sourcesContent":["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\n/**\n * Extracts the SQLite error code string from a `sqlite3` driver error.\n *\n * The `sqlite3` (node-sqlite3) driver sets `error.code` to a string like\n * `'SQLITE_CONSTRAINT'` and `error.errno` to the numeric result code.\n * See: https://github.com/TryGhost/node-sqlite3\n */\nconst getSqliteErrorCode = (error: unknown): string | undefined => {\n if (\n error instanceof Error &&\n 'code' in error &&\n typeof (error as Record<string, unknown>).code === 'string'\n ) {\n return (error as Record<string, unknown>).code as string;\n }\n return undefined;\n};\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 * Maps a constraint error to a specific DumboError subtype by inspecting the\n * error message. The `sqlite3` driver only exposes the primary result code\n * `SQLITE_CONSTRAINT` — the constraint subtype (UNIQUE, FOREIGN KEY, etc.)\n * is embedded in the message string by SQLite, e.g.:\n * \"SQLITE_CONSTRAINT: UNIQUE constraint failed: users.email\"\n *\n * Reference: https://www.sqlite.org/rescode.html (extended result codes 275–3091)\n */\nconst mapConstraintError = (\n message: string | undefined,\n innerError: Error | undefined,\n): DumboError => {\n const upperMessage = message?.toUpperCase() ?? '';\n\n // SQLITE_CONSTRAINT_UNIQUE (2067) / SQLITE_CONSTRAINT_PRIMARYKEY (1555)\n if (upperMessage.includes('UNIQUE') || upperMessage.includes('PRIMARY KEY'))\n return new UniqueConstraintError(message, innerError);\n\n // SQLITE_CONSTRAINT_FOREIGNKEY (787)\n if (upperMessage.includes('FOREIGN KEY'))\n return new ForeignKeyViolationError(message, innerError);\n\n // SQLITE_CONSTRAINT_NOTNULL (1299)\n if (upperMessage.includes('NOT NULL'))\n return new NotNullViolationError(message, innerError);\n\n // SQLITE_CONSTRAINT_CHECK (275)\n if (upperMessage.includes('CHECK'))\n return new CheckViolationError(message, innerError);\n\n // SQLITE_CONSTRAINT_ROWID (2579), SQLITE_CONSTRAINT_TRIGGER (1811),\n // SQLITE_CONSTRAINT_COMMITHOOK (531), SQLITE_CONSTRAINT_PINNED (2835),\n // SQLITE_CONSTRAINT_DATATYPE (3091), etc.\n return new IntegrityConstraintViolationError(message, innerError);\n};\n\n/**\n * Maps a SQLite error (from the `sqlite3` / node-sqlite3 driver) to a typed\n * DumboError based on the SQLite result code.\n *\n * Result code reference: https://www.sqlite.org/rescode.html\n *\n * Falls back to a generic DumboError (500) if the error is not a recognized SQLite error.\n */\nexport const mapSqliteError = (error: unknown): DumboError => {\n if (DumboError.isInstanceOf<DumboError>(error)) return error;\n\n const code = getSqliteErrorCode(error);\n if (!code)\n return new DumboError({\n errorCode: 500,\n message: getErrorMessage(error),\n innerError: asError(error),\n });\n\n const message = getErrorMessage(error);\n const innerError = asError(error);\n\n switch (code) {\n // ── Constraint violations (19) ──\n // node-sqlite3 only exposes the primary code; subtype is in the message.\n case 'SQLITE_CONSTRAINT':\n return mapConstraintError(message, innerError);\n\n // ── Busy / lock contention ──\n // SQLITE_BUSY (5): conflict with a separate database connection\n case 'SQLITE_BUSY':\n return new LockNotAvailableError(message, innerError);\n\n // SQLITE_LOCKED (6): conflict within the same connection or shared cache\n case 'SQLITE_LOCKED':\n return new DeadlockError(message, innerError);\n\n // SQLITE_PROTOCOL (15): WAL locking race condition\n case 'SQLITE_PROTOCOL':\n return new LockNotAvailableError(message, innerError);\n\n // ── Connection / open errors ──\n // SQLITE_CANTOPEN (14): unable to open database file\n case 'SQLITE_CANTOPEN':\n return new ConnectionError(message, innerError);\n\n // SQLITE_NOTADB (26): file is not a database\n case 'SQLITE_NOTADB':\n return new ConnectionError(message, innerError);\n\n // ── Resource exhaustion ──\n // SQLITE_NOMEM (7): out of memory\n case 'SQLITE_NOMEM':\n return new InsufficientResourcesError(message, innerError);\n\n // SQLITE_FULL (13): disk full\n case 'SQLITE_FULL':\n return new InsufficientResourcesError(message, innerError);\n\n // ── System / I/O errors ──\n // SQLITE_IOERR (10): operating system I/O error\n case 'SQLITE_IOERR':\n return new SystemError(message, innerError);\n\n // SQLITE_CORRUPT (11): database file is corrupted\n case 'SQLITE_CORRUPT':\n return new SystemError(message, innerError);\n\n // SQLITE_INTERNAL (2): internal SQLite malfunction\n case 'SQLITE_INTERNAL':\n return new SystemError(message, innerError);\n\n // SQLITE_NOLFS (22): large file support unavailable\n case 'SQLITE_NOLFS':\n return new SystemError(message, innerError);\n\n // ── Data errors ──\n // SQLITE_TOOBIG (18): string or BLOB too large\n case 'SQLITE_TOOBIG':\n return new DataError(message, innerError);\n\n // SQLITE_MISMATCH (20): datatype mismatch\n case 'SQLITE_MISMATCH':\n return new DataError(message, innerError);\n\n // SQLITE_RANGE (25): bind parameter index out of range\n case 'SQLITE_RANGE':\n return new DataError(message, innerError);\n\n // ── Invalid operations ──\n // SQLITE_ERROR (1): generic SQL error (syntax errors, missing tables, etc.)\n case 'SQLITE_ERROR':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_READONLY (8): attempt to write to a read-only database\n case 'SQLITE_READONLY':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_MISUSE (21): API misuse\n case 'SQLITE_MISUSE':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_AUTH (23): authorization denied\n case 'SQLITE_AUTH':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_PERM (3): access permission denied\n case 'SQLITE_PERM':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_SCHEMA (17): schema changed, statement needs re-preparation\n case 'SQLITE_SCHEMA':\n return new InvalidOperationError(message, innerError);\n\n // ── Transaction / abort ──\n // SQLITE_ABORT (4): operation aborted (e.g. by rollback)\n case 'SQLITE_ABORT':\n return new SerializationError(message, innerError);\n\n // SQLITE_INTERRUPT (9): operation interrupted\n case 'SQLITE_INTERRUPT':\n return new SerializationError(message, innerError);\n }\n\n return new DumboError({\n errorCode: 500,\n message,\n innerError,\n });\n};\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 = `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 type { JSONSerializer, SQLFormatter, SQL } from '../../../../core';\nimport {\n mapSQLQueryResult,\n tracer,\n type BatchSQLCommandOptions,\n type DbSQLExecutor,\n type QueryResult,\n type QueryResultRow,\n type SQLCommandOptions,\n type SQLQueryOptions,\n} from '../../../../core';\nimport type { DumboError } from '../../../../core/errors';\nimport type { SQLiteClient } from '../connections';\nimport { mapSqliteError } from '../errors/errorMapper';\nimport { sqliteFormatter } from '../sql/formatter';\n\nexport type SQLiteErrorMapper = (error: unknown) => DumboError;\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 serializer: JSONSerializer,\n formatter?: SQLFormatter,\n errorMapper?: SQLiteErrorMapper,\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 tracer.info('db:sql:query', {\n query: (formatter ?? sqliteFormatter).format(sql, { serializer }).query,\n params: (formatter ?? sqliteFormatter).format(sql, { serializer }).params,\n debugSQL: (formatter ?? sqliteFormatter).describe(sql, { serializer }),\n });\n\n try {\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 } catch (error) {\n tracer.error('db:sql:query:execute:error', { error });\n throw (errorMapper ?? mapSqliteError)(error);\n }\n },\n batchQuery: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sqls: SQL[],\n options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>[]> => {\n try {\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 } catch (error) {\n tracer.error('db:sql:batch_query:execute:error', { error });\n throw (errorMapper ?? mapSqliteError)(error);\n }\n },\n command: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sql: SQL,\n options?: SQLCommandOptions,\n ): Promise<QueryResult<Result>> => {\n tracer.info('db:sql:command', {\n query: (formatter ?? sqliteFormatter).format(sql, { serializer }).query,\n params: (formatter ?? sqliteFormatter).format(sql, { serializer }).params,\n debugSQL: (formatter ?? sqliteFormatter).describe(sql, { serializer }),\n });\n\n try {\n return await client.command<Result>(sql, options);\n } catch (error) {\n tracer.error('db:sql:command:execute:error', { error });\n throw (errorMapper ?? mapSqliteError)(error);\n }\n },\n batchCommand: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\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 (errorMapper ?? mapSqliteError)(error);\n }\n },\n formatter: formatter ?? sqliteFormatter,\n});\n","import { cpus } from 'os';\nimport {\n createBoundedConnectionPool,\n createSingletonConnectionPool,\n} from '../../../../core';\nimport { TaskProcessor } from '../../../../core/taskProcessing';\nimport type {\n AnySQLiteConnection,\n SQLiteConnectionFactory,\n SQLiteConnectionOptions,\n} from '../connections';\nimport { mapSqliteError } from '../errors';\nimport type { SQLitePool } from './pool';\n\nexport type SQLiteDualPoolOptions<\n SQLiteConnectionType extends AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions,\n> = {\n driverType: SQLiteConnectionType['driverType'];\n dual?: true;\n singleton?: false;\n pooled?: true;\n connection?: never;\n readerPoolSize?: number;\n sqliteConnectionFactory: SQLiteConnectionFactory<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n connectionOptions?: ConnectionOptions;\n};\n\nexport const sqliteDualConnectionPool = <\n SQLiteConnectionType extends AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions,\n>(\n options: SQLiteDualPoolOptions<SQLiteConnectionType, ConnectionOptions>,\n): SQLitePool<SQLiteConnectionType> => {\n const { sqliteConnectionFactory, connectionOptions } = options;\n const readerPoolSize = options.readerPoolSize ?? Math.max(4, cpus().length);\n\n let databaseInitPromise: Promise<void> | null = null;\n\n const initTaskProcessor = new TaskProcessor({\n maxActiveTasks: 1,\n maxQueueSize: 1000,\n });\n\n const ensureDatabaseInitialized = async (\n connectionOptions: ConnectionOptions | undefined,\n retryCount = 0,\n ): Promise<void> => {\n if (databaseInitPromise !== null) {\n return databaseInitPromise;\n }\n\n return initTaskProcessor.enqueue(\n async ({ ack }) => {\n if (databaseInitPromise !== null) {\n ack();\n return databaseInitPromise;\n }\n\n const initConnection = sqliteConnectionFactory({\n ...connectionOptions,\n skipDatabasePragmas: false,\n readonly: false,\n } as ConnectionOptions);\n\n const initPromise = initConnection.open();\n databaseInitPromise = initPromise;\n\n try {\n await initPromise;\n await initConnection.close();\n ack();\n } catch (error) {\n databaseInitPromise = null;\n await initConnection.close();\n ack();\n if (retryCount < 3) {\n return ensureDatabaseInitialized(connectionOptions, retryCount + 1);\n }\n throw mapSqliteError(error);\n }\n },\n { taskGroupId: 'db-init' },\n );\n };\n\n const wrappedConnectionFactory = async (\n readonly: boolean,\n connectionOptions: ConnectionOptions | undefined,\n ): Promise<SQLiteConnectionType> => {\n await ensureDatabaseInitialized(connectionOptions);\n\n const connection = sqliteConnectionFactory({\n ...connectionOptions,\n skipDatabasePragmas: true,\n readonly,\n } as ConnectionOptions);\n\n await connection.open();\n\n return connection;\n };\n\n const writerPool = createSingletonConnectionPool({\n driverType: options.driverType,\n getConnection: () => wrappedConnectionFactory(false, connectionOptions),\n });\n\n const readerPool = createBoundedConnectionPool({\n driverType: options.driverType,\n getConnection: () => wrappedConnectionFactory(true, connectionOptions),\n maxConnections: readerPoolSize,\n });\n\n return {\n driverType: options.driverType,\n connection: (connectionOptions) =>\n connectionOptions?.readonly\n ? readerPool.connection(connectionOptions)\n : writerPool.connection(connectionOptions),\n execute: {\n query: (...args) => readerPool.execute.query(...args),\n batchQuery: (...args) => readerPool.execute.batchQuery(...args),\n command: (...args) => writerPool.execute.command(...args),\n batchCommand: (...args) => writerPool.execute.batchCommand(...args),\n },\n withConnection: (handle, connectionOptions) =>\n connectionOptions?.readonly\n ? readerPool.withConnection(handle, connectionOptions)\n : writerPool.withConnection(handle, connectionOptions),\n transaction: writerPool.transaction,\n withTransaction: writerPool.withTransaction,\n close: () =>\n Promise.all([writerPool.close(), readerPool.close()]).then(() => {}),\n };\n};\n","import type { SQLiteConnectionString } from '..';\nimport {\n InMemorySQLiteDatabase,\n type AnySQLiteConnection,\n type SQLiteConnectionFactory,\n type SQLiteConnectionOptions,\n} from '..';\nimport type { JSONSerializer } from '../../../../core';\nimport {\n createAlwaysNewConnectionPool,\n createAmbientConnectionPool,\n createSingletonConnectionPool,\n type ConnectionPool,\n} from '../../../../core';\nimport {\n sqliteDualConnectionPool,\n type SQLiteDualPoolOptions,\n} from './dualPool';\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 }) as unknown as SQLiteAmbientConnectionPool<\n SQLiteConnectionType['driverType']\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 & Record<string, unknown> =\n 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 }) as unknown as SQLiteSingletonConnectionPool<SQLiteConnectionType>;\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 & Record<string, unknown> =\n 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 }) as unknown as SQLiteAlwaysNewConnectionPool<SQLiteConnectionType>;\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 | SQLiteDualPoolOptions<SQLiteConnectionType, ConnectionOptions>\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 isInMemory = isInMemoryDatabase(options);\n\n if ('client' in options && options.client) {\n return { ...rest, singleton: true } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n }\n\n if (isInMemory) {\n return { ...rest, singleton: true } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n }\n\n if (singleton === true) {\n return { ...rest, singleton: true } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n }\n\n return { ...rest, dual: true } 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 if (\n (\n options as SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType> & {\n driverType: SQLiteConnectionType['driverType'];\n }\n ).connection\n )\n return createAmbientConnectionPool<SQLiteConnectionType>({\n driverType,\n connection: (\n options as SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType> & {\n driverType: SQLiteConnectionType['driverType'];\n }\n ).connection,\n });\n\n if ('dual' in options && options.dual) {\n return sqliteDualConnectionPool(\n options as SQLiteDualPoolOptions<SQLiteConnectionType, ConnectionOptions>,\n );\n }\n\n if (\n options.singleton === true &&\n (\n options as SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).sqliteConnectionFactory\n ) {\n return createSingletonConnectionPool({\n driverType,\n getConnection: () =>\n (\n options as SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).sqliteConnectionFactory(\n (\n options as SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).connectionOptions,\n ),\n });\n }\n\n return createAlwaysNewConnectionPool({\n driverType,\n getConnection: () =>\n (\n options as SQLiteAlwaysNewPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).sqliteConnectionFactory(\n (\n options as SQLiteAlwaysNewPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).connectionOptions,\n ),\n });\n}\n","import {\n registerDefaultMigratorOptions,\n type MigratorOptions,\n} from '../../../../core';\n\nexport const DefaultSQLiteMigratorOptions: MigratorOptions = {};\n\nregisterDefaultMigratorOptions('SQLite', DefaultSQLiteMigratorOptions);\n","import type { DatabaseDriverType } from '../../..';\n\nexport * from './connections';\nexport * from './errors';\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';\nimport type { SQLitePragmaOptions } from './index';\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\nexport const parsePragmasFromConnectionString = (\n connectionString: string | SQLiteConnectionString,\n): Partial<SQLitePragmaOptions> => {\n const str = String(connectionString);\n\n if (!str.startsWith('file:')) {\n return {};\n }\n\n const url = new URL(str);\n const params = url.searchParams;\n const pragmas: Partial<SQLitePragmaOptions> = {};\n\n const journalMode = params.get('journal_mode');\n if (journalMode !== null) {\n pragmas.journal_mode = journalMode as\n | 'DELETE'\n | 'TRUNCATE'\n | 'PERSIST'\n | 'MEMORY'\n | 'WAL'\n | 'OFF';\n }\n\n const synchronous = params.get('synchronous');\n if (synchronous !== null) {\n pragmas.synchronous = synchronous as 'OFF' | 'NORMAL' | 'FULL' | 'EXTRA';\n }\n\n const cacheSize = params.get('cache_size');\n if (cacheSize !== null) {\n pragmas.cache_size = parseInt(cacheSize, 10);\n }\n\n const foreignKeys = params.get('foreign_keys');\n if (foreignKeys !== null) {\n const val = foreignKeys.toLowerCase();\n pragmas.foreign_keys = val === 'true' || val === 'on' || val === '1';\n }\n\n const tempStore = params.get('temp_store');\n if (tempStore !== null) {\n pragmas.temp_store = tempStore.toUpperCase() as\n | 'DEFAULT'\n | 'FILE'\n | 'MEMORY';\n }\n\n const busyTimeout = params.get('busy_timeout');\n if (busyTimeout !== null) {\n pragmas.busy_timeout = parseInt(busyTimeout, 10);\n }\n\n const mmapSize = params.get('mmap_size');\n if (mmapSize !== null) {\n pragmas.mmap_size = parseInt(mmapSize, 10);\n }\n\n return pragmas;\n};\n","import {\n mapSqliteError,\n SQLiteConnectionString,\n sqliteSQLExecutor,\n type SQLiteDriverType,\n type SQLiteErrorMapper,\n} from '..';\nimport type { JSONSerializer } from '../../../../core';\nimport {\n createAmbientConnection,\n createConnection,\n type AnyConnection,\n type BatchSQLCommandOptions,\n type Connection,\n type ConnectionOptions,\n type DatabaseTransaction,\n type InferDbClientFromConnection,\n type InferDriverTypeFromConnection,\n type InitTransaction,\n type SQLCommandOptions,\n type SQLExecutor,\n} from '../../../../core';\nimport { sqliteTransaction, type SQLiteTransactionMode } from '../transactions';\n\nexport type SQLiteCommandOptions = SQLCommandOptions & {\n ignoreChangesCount?: boolean;\n};\n\nexport type BatchSQLiteCommandOptions = SQLiteCommandOptions &\n BatchSQLCommandOptions;\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> = Connection<Self, DriverType, SQLiteClientType, TransactionType>;\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> = Connection<Self, DriverType, SQLitePoolClientType, TransactionType>;\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> =\n | (SQLiteClientType extends SQLiteClient\n ? SQLiteClientConnection<\n Self,\n DriverType,\n SQLiteClientType,\n TransactionType\n >\n : never)\n | (SQLiteClientType extends SQLitePoolClient\n ? SQLitePoolClientConnection<\n Self,\n DriverType,\n SQLiteClientType,\n TransactionType\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>;\n\nexport type AnySQLiteConnection =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n SQLiteConnection<any, any, any, any>;\n\nexport type SQLiteConnectionOptions<\n ConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = ConnectionOptions<ConnectionType> & SQLiteClientOptions;\n\nexport type SQLiteClientConnectionDefinitionOptions<\n SQLiteConnectionType extends AnySQLiteClientConnection =\n 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 serializer: JSONSerializer;\n};\n\nexport type SQLitePoolConnectionDefinitionOptions<\n SQLiteConnectionType extends AnySQLitePoolClientConnection =\n 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 serializer: JSONSerializer;\n};\n\nexport type SQLiteConnectionDefinitionOptions<\n SQLiteConnectionType extends AnySQLitePoolClientConnection =\n 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 AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n> = {\n driverType: SQLiteConnectionType['driverType'];\n client: InferDbClientFromConnection<SQLiteConnectionType>;\n initTransaction?: InitTransaction<SQLiteConnectionType>;\n allowNestedTransactions?: boolean;\n defaultTransactionMode?: SQLiteTransactionMode;\n serializer: JSONSerializer;\n errorMapper?: SQLiteErrorMapper;\n};\n\nexport const sqliteAmbientClientConnection = <\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n>(\n options: SqliteAmbientClientConnectionOptions<SQLiteConnectionType>,\n) => {\n const {\n client,\n driverType,\n initTransaction,\n allowNestedTransactions,\n defaultTransactionMode,\n serializer,\n errorMapper,\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 serializer,\n defaultTransactionMode,\n )),\n executor: ({ serializer }) =>\n sqliteSQLExecutor(driverType, serializer, undefined, errorMapper),\n serializer,\n });\n};\n\nexport const sqliteClientConnection = <\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n ClientOptions = SQLiteClientOptions,\n>(\n options: SQLiteClientConnectionDefinitionOptions<\n SQLiteConnectionType,\n ClientOptions\n >,\n): SQLiteConnectionType => {\n const { connectionOptions, sqliteClientFactory, serializer } = 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 try {\n await client.connect();\n } catch (error) {\n throw mapSqliteError(error);\n }\n }\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 serializer,\n connectionOptions.defaultTransactionMode,\n ),\n executor: ({ serializer }) =>\n sqliteSQLExecutor(options.driverType, serializer),\n serializer,\n });\n};\n\nexport const sqlitePoolClientConnection = <\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n ClientOptions = SQLiteClientOptions,\n>(\n options: SQLitePoolConnectionDefinitionOptions<\n SQLiteConnectionType,\n ClientOptions\n >,\n): SQLiteConnectionType => {\n const { connectionOptions, sqliteClientFactory, serializer } = 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 try {\n await client.connect();\n } catch (error) {\n throw mapSqliteError(error);\n }\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 serializer,\n connectionOptions.defaultTransactionMode,\n ),\n executor: ({ serializer }) =>\n sqliteSQLExecutor(options.driverType, serializer),\n serializer,\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\nexport type SQLitePragmaOptions = {\n journal_mode?: 'DELETE' | 'TRUNCATE' | 'PERSIST' | 'MEMORY' | 'WAL' | 'OFF';\n synchronous?: 'OFF' | 'NORMAL' | 'FULL' | 'EXTRA';\n cache_size?: number;\n foreign_keys?: boolean;\n temp_store?: 'DEFAULT' | 'FILE' | 'MEMORY';\n busy_timeout?: number;\n mmap_size?: number;\n};\n\nexport const DEFAULT_SQLITE_PRAGMA_OPTIONS: SQLitePragmaOptions = {\n journal_mode: 'WAL',\n synchronous: 'NORMAL',\n cache_size: -1000000,\n foreign_keys: true,\n temp_store: 'MEMORY',\n busy_timeout: 5000,\n mmap_size: 268435456,\n};\n\nexport type SQLiteClientOptions = {\n pragmaOptions?: Partial<SQLitePragmaOptions>;\n defaultTransactionMode?: SQLiteTransactionMode;\n skipDatabasePragmas?: boolean;\n readonly?: boolean;\n};\n\nexport * from './connectionString';\n","import type {\n InferTransactionFromConnection,\n JSONSerializer,\n} from '../../../../core';\nimport {\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 TransactionOptions extends SQLiteTransactionOptions =\n SQLiteTransactionOptions,\n> = DatabaseTransaction<ConnectionType, TransactionOptions>;\n\nexport type SQLiteTransactionMode = 'DEFERRED' | 'IMMEDIATE' | 'EXCLUSIVE';\n\nexport type SQLiteTransactionOptions = DatabaseTransactionOptions & {\n mode?: SQLiteTransactionMode;\n useSavepoints?: boolean;\n};\n\nexport const sqliteTransaction =\n <ConnectionType extends AnySQLiteConnection = AnySQLiteConnection>(\n driverType: ConnectionType['driverType'],\n connection: () => ConnectionType,\n allowNestedTransactions: boolean,\n serializer: JSONSerializer,\n defaultTransactionMode?: 'IMMEDIATE' | 'DEFERRED' | 'EXCLUSIVE',\n ) =>\n (\n getClient: Promise<InferDbClientFromConnection<ConnectionType>>,\n options?: {\n close: (\n client: InferDbClientFromConnection<ConnectionType>,\n error?: unknown,\n ) => Promise<void>;\n } & SQLiteTransactionOptions,\n ): InferTransactionFromConnection<ConnectionType> => {\n const transactionCounter = transactionNestingCounter();\n allowNestedTransactions =\n options?.allowNestedTransactions ?? allowNestedTransactions;\n\n const transaction: DatabaseTransaction<ConnectionType> = {\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 if (options?.useSavepoints) {\n await client.query(\n SQL`SAVEPOINT transaction${SQL.plain(transactionCounter.level.toString())}`,\n );\n }\n return;\n }\n\n transactionCounter.increment();\n }\n\n const mode = options?.mode ?? defaultTransactionMode ?? 'IMMEDIATE';\n await client.query(SQL`BEGIN ${SQL.plain(mode)} 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 if (options?.useSavepoints) {\n await client.query(\n SQL`RELEASE transaction${SQL.plain(transactionCounter.level.toString())}`,\n );\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, serializer), {\n connect: () => getClient,\n }),\n _transactionOptions: options ?? {},\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return transaction as InferTransactionFromConnection<ConnectionType>;\n };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAM,qBAAqB,CAAC,UAAuC;AACjE,MACE,i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String) => {
475
475
  if (busyTimeout !== null) {
476
476
  pragmas.busy_timeout = parseInt(busyTimeout, 10);
477
477
  }
478
+ const mmapSize = params.get("mmap_size");
479
+ if (mmapSize !== null) {
480
+ pragmas.mmap_size = parseInt(mmapSize, 10);
481
+ }
478
482
  return pragmas;
479
483
  };
480
484
 
@@ -602,7 +606,8 @@ var DEFAULT_SQLITE_PRAGMA_OPTIONS = {
602
606
  cache_size: -1e6,
603
607
  foreign_keys: true,
604
608
  temp_store: "MEMORY",
605
- busy_timeout: 5e3
609
+ busy_timeout: 5e3,
610
+ mmap_size: 268435456
606
611
  };
607
612
 
608
613
  // src/storage/sqlite/core/transactions/index.ts
@@ -703,4 +708,4 @@ var sqliteTransaction = (driverType, connection, allowNestedTransactions, serial
703
708
 
704
709
 
705
710
  exports.mapSqliteError = mapSqliteError; exports.sqliteFormatter = sqliteFormatter; exports.sqliteExecute = sqliteExecute; exports.sqliteSQLExecutor = sqliteSQLExecutor; exports.sqliteTransaction = sqliteTransaction; exports.SQLiteConnectionString = SQLiteConnectionString; exports.parsePragmasFromConnectionString = parsePragmasFromConnectionString; exports.isSQLiteError = isSQLiteError; exports.transactionNestingCounter = transactionNestingCounter; exports.sqliteAmbientClientConnection = sqliteAmbientClientConnection; exports.sqliteClientConnection = sqliteClientConnection; exports.sqlitePoolClientConnection = sqlitePoolClientConnection; exports.sqliteConnection = sqliteConnection; exports.InMemorySQLiteDatabase = InMemorySQLiteDatabase; exports.DEFAULT_SQLITE_PRAGMA_OPTIONS = DEFAULT_SQLITE_PRAGMA_OPTIONS; exports.isInMemoryDatabase = isInMemoryDatabase; exports.sqliteAmbientConnectionPool = sqliteAmbientConnectionPool; exports.sqliteSingletonConnectionPool = sqliteSingletonConnectionPool; exports.sqliteAlwaysNewConnectionPool = sqliteAlwaysNewConnectionPool; exports.toSqlitePoolOptions = toSqlitePoolOptions; exports.sqlitePool = sqlitePool; exports.DefaultSQLiteMigratorOptions = DefaultSQLiteMigratorOptions; exports.SQLiteDatabaseName = SQLiteDatabaseName;
706
- //# sourceMappingURL=chunk-EEKBLOCH.cjs.map
711
+ //# sourceMappingURL=chunk-J2S3DPDR.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/chunk-J2S3DPDR.cjs","../src/storage/sqlite/core/errors/errorMapper.ts","../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/dualPool.ts","../src/storage/sqlite/core/pool/pool.ts","../src/storage/sqlite/core/schema/migrations.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":["connectionOptions","serializer"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACVA,IAAM,mBAAA,EAAqB,CAAC,KAAA,EAAA,GAAuC;AACjE,EAAA,GAAA,CACE,MAAA,WAAiB,MAAA,GACjB,OAAA,GAAU,MAAA,GACV,OAAQ,KAAA,CAAkC,KAAA,IAAS,QAAA,EACnD;AACA,IAAA,OAAQ,KAAA,CAAkC,IAAA;AAAA,EAC5C;AACA,EAAA,OAAO,KAAA,CAAA;AACT,CAAA;AAEA,IAAM,gBAAA,EAAkB,CAAC,KAAA,EAAA,GACvB,MAAA,WAAiB,MAAA,EAAQ,KAAA,CAAM,QAAA,EAAU,KAAA,CAAA;AAE3C,IAAM,QAAA,EAAU,CAAC,KAAA,EAAA,GACf,MAAA,WAAiB,MAAA,EAAQ,MAAA,EAAQ,KAAA,CAAA;AAWnC,IAAM,mBAAA,EAAqB,CACzB,OAAA,EACA,UAAA,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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;AACgE,IAAA;AAC/C,MAAA;AAChB,IAAA;AACgC,IAAA;AACnC,EAAA;AAGO,EAAA;AACT;AX4iBiF;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-J2S3DPDR.cjs","sourcesContent":[null,"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\n/**\n * Extracts the SQLite error code string from a `sqlite3` driver error.\n *\n * The `sqlite3` (node-sqlite3) driver sets `error.code` to a string like\n * `'SQLITE_CONSTRAINT'` and `error.errno` to the numeric result code.\n * See: https://github.com/TryGhost/node-sqlite3\n */\nconst getSqliteErrorCode = (error: unknown): string | undefined => {\n if (\n error instanceof Error &&\n 'code' in error &&\n typeof (error as Record<string, unknown>).code === 'string'\n ) {\n return (error as Record<string, unknown>).code as string;\n }\n return undefined;\n};\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 * Maps a constraint error to a specific DumboError subtype by inspecting the\n * error message. The `sqlite3` driver only exposes the primary result code\n * `SQLITE_CONSTRAINT` — the constraint subtype (UNIQUE, FOREIGN KEY, etc.)\n * is embedded in the message string by SQLite, e.g.:\n * \"SQLITE_CONSTRAINT: UNIQUE constraint failed: users.email\"\n *\n * Reference: https://www.sqlite.org/rescode.html (extended result codes 275–3091)\n */\nconst mapConstraintError = (\n message: string | undefined,\n innerError: Error | undefined,\n): DumboError => {\n const upperMessage = message?.toUpperCase() ?? '';\n\n // SQLITE_CONSTRAINT_UNIQUE (2067) / SQLITE_CONSTRAINT_PRIMARYKEY (1555)\n if (upperMessage.includes('UNIQUE') || upperMessage.includes('PRIMARY KEY'))\n return new UniqueConstraintError(message, innerError);\n\n // SQLITE_CONSTRAINT_FOREIGNKEY (787)\n if (upperMessage.includes('FOREIGN KEY'))\n return new ForeignKeyViolationError(message, innerError);\n\n // SQLITE_CONSTRAINT_NOTNULL (1299)\n if (upperMessage.includes('NOT NULL'))\n return new NotNullViolationError(message, innerError);\n\n // SQLITE_CONSTRAINT_CHECK (275)\n if (upperMessage.includes('CHECK'))\n return new CheckViolationError(message, innerError);\n\n // SQLITE_CONSTRAINT_ROWID (2579), SQLITE_CONSTRAINT_TRIGGER (1811),\n // SQLITE_CONSTRAINT_COMMITHOOK (531), SQLITE_CONSTRAINT_PINNED (2835),\n // SQLITE_CONSTRAINT_DATATYPE (3091), etc.\n return new IntegrityConstraintViolationError(message, innerError);\n};\n\n/**\n * Maps a SQLite error (from the `sqlite3` / node-sqlite3 driver) to a typed\n * DumboError based on the SQLite result code.\n *\n * Result code reference: https://www.sqlite.org/rescode.html\n *\n * Falls back to a generic DumboError (500) if the error is not a recognized SQLite error.\n */\nexport const mapSqliteError = (error: unknown): DumboError => {\n if (DumboError.isInstanceOf<DumboError>(error)) return error;\n\n const code = getSqliteErrorCode(error);\n if (!code)\n return new DumboError({\n errorCode: 500,\n message: getErrorMessage(error),\n innerError: asError(error),\n });\n\n const message = getErrorMessage(error);\n const innerError = asError(error);\n\n switch (code) {\n // ── Constraint violations (19) ──\n // node-sqlite3 only exposes the primary code; subtype is in the message.\n case 'SQLITE_CONSTRAINT':\n return mapConstraintError(message, innerError);\n\n // ── Busy / lock contention ──\n // SQLITE_BUSY (5): conflict with a separate database connection\n case 'SQLITE_BUSY':\n return new LockNotAvailableError(message, innerError);\n\n // SQLITE_LOCKED (6): conflict within the same connection or shared cache\n case 'SQLITE_LOCKED':\n return new DeadlockError(message, innerError);\n\n // SQLITE_PROTOCOL (15): WAL locking race condition\n case 'SQLITE_PROTOCOL':\n return new LockNotAvailableError(message, innerError);\n\n // ── Connection / open errors ──\n // SQLITE_CANTOPEN (14): unable to open database file\n case 'SQLITE_CANTOPEN':\n return new ConnectionError(message, innerError);\n\n // SQLITE_NOTADB (26): file is not a database\n case 'SQLITE_NOTADB':\n return new ConnectionError(message, innerError);\n\n // ── Resource exhaustion ──\n // SQLITE_NOMEM (7): out of memory\n case 'SQLITE_NOMEM':\n return new InsufficientResourcesError(message, innerError);\n\n // SQLITE_FULL (13): disk full\n case 'SQLITE_FULL':\n return new InsufficientResourcesError(message, innerError);\n\n // ── System / I/O errors ──\n // SQLITE_IOERR (10): operating system I/O error\n case 'SQLITE_IOERR':\n return new SystemError(message, innerError);\n\n // SQLITE_CORRUPT (11): database file is corrupted\n case 'SQLITE_CORRUPT':\n return new SystemError(message, innerError);\n\n // SQLITE_INTERNAL (2): internal SQLite malfunction\n case 'SQLITE_INTERNAL':\n return new SystemError(message, innerError);\n\n // SQLITE_NOLFS (22): large file support unavailable\n case 'SQLITE_NOLFS':\n return new SystemError(message, innerError);\n\n // ── Data errors ──\n // SQLITE_TOOBIG (18): string or BLOB too large\n case 'SQLITE_TOOBIG':\n return new DataError(message, innerError);\n\n // SQLITE_MISMATCH (20): datatype mismatch\n case 'SQLITE_MISMATCH':\n return new DataError(message, innerError);\n\n // SQLITE_RANGE (25): bind parameter index out of range\n case 'SQLITE_RANGE':\n return new DataError(message, innerError);\n\n // ── Invalid operations ──\n // SQLITE_ERROR (1): generic SQL error (syntax errors, missing tables, etc.)\n case 'SQLITE_ERROR':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_READONLY (8): attempt to write to a read-only database\n case 'SQLITE_READONLY':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_MISUSE (21): API misuse\n case 'SQLITE_MISUSE':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_AUTH (23): authorization denied\n case 'SQLITE_AUTH':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_PERM (3): access permission denied\n case 'SQLITE_PERM':\n return new InvalidOperationError(message, innerError);\n\n // SQLITE_SCHEMA (17): schema changed, statement needs re-preparation\n case 'SQLITE_SCHEMA':\n return new InvalidOperationError(message, innerError);\n\n // ── Transaction / abort ──\n // SQLITE_ABORT (4): operation aborted (e.g. by rollback)\n case 'SQLITE_ABORT':\n return new SerializationError(message, innerError);\n\n // SQLITE_INTERRUPT (9): operation interrupted\n case 'SQLITE_INTERRUPT':\n return new SerializationError(message, innerError);\n }\n\n return new DumboError({\n errorCode: 500,\n message,\n innerError,\n });\n};\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 = `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 type { JSONSerializer, SQLFormatter, SQL } from '../../../../core';\nimport {\n mapSQLQueryResult,\n tracer,\n type BatchSQLCommandOptions,\n type DbSQLExecutor,\n type QueryResult,\n type QueryResultRow,\n type SQLCommandOptions,\n type SQLQueryOptions,\n} from '../../../../core';\nimport type { DumboError } from '../../../../core/errors';\nimport type { SQLiteClient } from '../connections';\nimport { mapSqliteError } from '../errors/errorMapper';\nimport { sqliteFormatter } from '../sql/formatter';\n\nexport type SQLiteErrorMapper = (error: unknown) => DumboError;\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 serializer: JSONSerializer,\n formatter?: SQLFormatter,\n errorMapper?: SQLiteErrorMapper,\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 tracer.info('db:sql:query', {\n query: (formatter ?? sqliteFormatter).format(sql, { serializer }).query,\n params: (formatter ?? sqliteFormatter).format(sql, { serializer }).params,\n debugSQL: (formatter ?? sqliteFormatter).describe(sql, { serializer }),\n });\n\n try {\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 } catch (error) {\n tracer.error('db:sql:query:execute:error', { error });\n throw (errorMapper ?? mapSqliteError)(error);\n }\n },\n batchQuery: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sqls: SQL[],\n options?: SQLQueryOptions,\n ): Promise<QueryResult<Result>[]> => {\n try {\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 } catch (error) {\n tracer.error('db:sql:batch_query:execute:error', { error });\n throw (errorMapper ?? mapSqliteError)(error);\n }\n },\n command: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\n sql: SQL,\n options?: SQLCommandOptions,\n ): Promise<QueryResult<Result>> => {\n tracer.info('db:sql:command', {\n query: (formatter ?? sqliteFormatter).format(sql, { serializer }).query,\n params: (formatter ?? sqliteFormatter).format(sql, { serializer }).params,\n debugSQL: (formatter ?? sqliteFormatter).describe(sql, { serializer }),\n });\n\n try {\n return await client.command<Result>(sql, options);\n } catch (error) {\n tracer.error('db:sql:command:execute:error', { error });\n throw (errorMapper ?? mapSqliteError)(error);\n }\n },\n batchCommand: async <Result extends QueryResultRow = QueryResultRow>(\n client: SQLiteClient,\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 (errorMapper ?? mapSqliteError)(error);\n }\n },\n formatter: formatter ?? sqliteFormatter,\n});\n","import { cpus } from 'os';\nimport {\n createBoundedConnectionPool,\n createSingletonConnectionPool,\n} from '../../../../core';\nimport { TaskProcessor } from '../../../../core/taskProcessing';\nimport type {\n AnySQLiteConnection,\n SQLiteConnectionFactory,\n SQLiteConnectionOptions,\n} from '../connections';\nimport { mapSqliteError } from '../errors';\nimport type { SQLitePool } from './pool';\n\nexport type SQLiteDualPoolOptions<\n SQLiteConnectionType extends AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions,\n> = {\n driverType: SQLiteConnectionType['driverType'];\n dual?: true;\n singleton?: false;\n pooled?: true;\n connection?: never;\n readerPoolSize?: number;\n sqliteConnectionFactory: SQLiteConnectionFactory<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n connectionOptions?: ConnectionOptions;\n};\n\nexport const sqliteDualConnectionPool = <\n SQLiteConnectionType extends AnySQLiteConnection,\n ConnectionOptions extends SQLiteConnectionOptions,\n>(\n options: SQLiteDualPoolOptions<SQLiteConnectionType, ConnectionOptions>,\n): SQLitePool<SQLiteConnectionType> => {\n const { sqliteConnectionFactory, connectionOptions } = options;\n const readerPoolSize = options.readerPoolSize ?? Math.max(4, cpus().length);\n\n let databaseInitPromise: Promise<void> | null = null;\n\n const initTaskProcessor = new TaskProcessor({\n maxActiveTasks: 1,\n maxQueueSize: 1000,\n });\n\n const ensureDatabaseInitialized = async (\n connectionOptions: ConnectionOptions | undefined,\n retryCount = 0,\n ): Promise<void> => {\n if (databaseInitPromise !== null) {\n return databaseInitPromise;\n }\n\n return initTaskProcessor.enqueue(\n async ({ ack }) => {\n if (databaseInitPromise !== null) {\n ack();\n return databaseInitPromise;\n }\n\n const initConnection = sqliteConnectionFactory({\n ...connectionOptions,\n skipDatabasePragmas: false,\n readonly: false,\n } as ConnectionOptions);\n\n const initPromise = initConnection.open();\n databaseInitPromise = initPromise;\n\n try {\n await initPromise;\n await initConnection.close();\n ack();\n } catch (error) {\n databaseInitPromise = null;\n await initConnection.close();\n ack();\n if (retryCount < 3) {\n return ensureDatabaseInitialized(connectionOptions, retryCount + 1);\n }\n throw mapSqliteError(error);\n }\n },\n { taskGroupId: 'db-init' },\n );\n };\n\n const wrappedConnectionFactory = async (\n readonly: boolean,\n connectionOptions: ConnectionOptions | undefined,\n ): Promise<SQLiteConnectionType> => {\n await ensureDatabaseInitialized(connectionOptions);\n\n const connection = sqliteConnectionFactory({\n ...connectionOptions,\n skipDatabasePragmas: true,\n readonly,\n } as ConnectionOptions);\n\n await connection.open();\n\n return connection;\n };\n\n const writerPool = createSingletonConnectionPool({\n driverType: options.driverType,\n getConnection: () => wrappedConnectionFactory(false, connectionOptions),\n });\n\n const readerPool = createBoundedConnectionPool({\n driverType: options.driverType,\n getConnection: () => wrappedConnectionFactory(true, connectionOptions),\n maxConnections: readerPoolSize,\n });\n\n return {\n driverType: options.driverType,\n connection: (connectionOptions) =>\n connectionOptions?.readonly\n ? readerPool.connection(connectionOptions)\n : writerPool.connection(connectionOptions),\n execute: {\n query: (...args) => readerPool.execute.query(...args),\n batchQuery: (...args) => readerPool.execute.batchQuery(...args),\n command: (...args) => writerPool.execute.command(...args),\n batchCommand: (...args) => writerPool.execute.batchCommand(...args),\n },\n withConnection: (handle, connectionOptions) =>\n connectionOptions?.readonly\n ? readerPool.withConnection(handle, connectionOptions)\n : writerPool.withConnection(handle, connectionOptions),\n transaction: writerPool.transaction,\n withTransaction: writerPool.withTransaction,\n close: () =>\n Promise.all([writerPool.close(), readerPool.close()]).then(() => {}),\n };\n};\n","import type { SQLiteConnectionString } from '..';\nimport {\n InMemorySQLiteDatabase,\n type AnySQLiteConnection,\n type SQLiteConnectionFactory,\n type SQLiteConnectionOptions,\n} from '..';\nimport type { JSONSerializer } from '../../../../core';\nimport {\n createAlwaysNewConnectionPool,\n createAmbientConnectionPool,\n createSingletonConnectionPool,\n type ConnectionPool,\n} from '../../../../core';\nimport {\n sqliteDualConnectionPool,\n type SQLiteDualPoolOptions,\n} from './dualPool';\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 }) as unknown as SQLiteAmbientConnectionPool<\n SQLiteConnectionType['driverType']\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 & Record<string, unknown> =\n 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 }) as unknown as SQLiteSingletonConnectionPool<SQLiteConnectionType>;\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 & Record<string, unknown> =\n 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 }) as unknown as SQLiteAlwaysNewConnectionPool<SQLiteConnectionType>;\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 | SQLiteDualPoolOptions<SQLiteConnectionType, ConnectionOptions>\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 isInMemory = isInMemoryDatabase(options);\n\n if ('client' in options && options.client) {\n return { ...rest, singleton: true } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n }\n\n if (isInMemory) {\n return { ...rest, singleton: true } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n }\n\n if (singleton === true) {\n return { ...rest, singleton: true } as SQLitePoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n >;\n }\n\n return { ...rest, dual: true } 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 if (\n (\n options as SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType> & {\n driverType: SQLiteConnectionType['driverType'];\n }\n ).connection\n )\n return createAmbientConnectionPool<SQLiteConnectionType>({\n driverType,\n connection: (\n options as SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType> & {\n driverType: SQLiteConnectionType['driverType'];\n }\n ).connection,\n });\n\n if ('dual' in options && options.dual) {\n return sqliteDualConnectionPool(\n options as SQLiteDualPoolOptions<SQLiteConnectionType, ConnectionOptions>,\n );\n }\n\n if (\n options.singleton === true &&\n (\n options as SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).sqliteConnectionFactory\n ) {\n return createSingletonConnectionPool({\n driverType,\n getConnection: () =>\n (\n options as SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).sqliteConnectionFactory(\n (\n options as SQLiteSingletonConnectionPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).connectionOptions,\n ),\n });\n }\n\n return createAlwaysNewConnectionPool({\n driverType,\n getConnection: () =>\n (\n options as SQLiteAlwaysNewPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).sqliteConnectionFactory(\n (\n options as SQLiteAlwaysNewPoolOptions<\n SQLiteConnectionType,\n ConnectionOptions\n > & { driverType: SQLiteConnectionType['driverType'] }\n ).connectionOptions,\n ),\n });\n}\n","import {\n registerDefaultMigratorOptions,\n type MigratorOptions,\n} from '../../../../core';\n\nexport const DefaultSQLiteMigratorOptions: MigratorOptions = {};\n\nregisterDefaultMigratorOptions('SQLite', DefaultSQLiteMigratorOptions);\n","import type { DatabaseDriverType } from '../../..';\n\nexport * from './connections';\nexport * from './errors';\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';\nimport type { SQLitePragmaOptions } from './index';\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\nexport const parsePragmasFromConnectionString = (\n connectionString: string | SQLiteConnectionString,\n): Partial<SQLitePragmaOptions> => {\n const str = String(connectionString);\n\n if (!str.startsWith('file:')) {\n return {};\n }\n\n const url = new URL(str);\n const params = url.searchParams;\n const pragmas: Partial<SQLitePragmaOptions> = {};\n\n const journalMode = params.get('journal_mode');\n if (journalMode !== null) {\n pragmas.journal_mode = journalMode as\n | 'DELETE'\n | 'TRUNCATE'\n | 'PERSIST'\n | 'MEMORY'\n | 'WAL'\n | 'OFF';\n }\n\n const synchronous = params.get('synchronous');\n if (synchronous !== null) {\n pragmas.synchronous = synchronous as 'OFF' | 'NORMAL' | 'FULL' | 'EXTRA';\n }\n\n const cacheSize = params.get('cache_size');\n if (cacheSize !== null) {\n pragmas.cache_size = parseInt(cacheSize, 10);\n }\n\n const foreignKeys = params.get('foreign_keys');\n if (foreignKeys !== null) {\n const val = foreignKeys.toLowerCase();\n pragmas.foreign_keys = val === 'true' || val === 'on' || val === '1';\n }\n\n const tempStore = params.get('temp_store');\n if (tempStore !== null) {\n pragmas.temp_store = tempStore.toUpperCase() as\n | 'DEFAULT'\n | 'FILE'\n | 'MEMORY';\n }\n\n const busyTimeout = params.get('busy_timeout');\n if (busyTimeout !== null) {\n pragmas.busy_timeout = parseInt(busyTimeout, 10);\n }\n\n const mmapSize = params.get('mmap_size');\n if (mmapSize !== null) {\n pragmas.mmap_size = parseInt(mmapSize, 10);\n }\n\n return pragmas;\n};\n","import {\n mapSqliteError,\n SQLiteConnectionString,\n sqliteSQLExecutor,\n type SQLiteDriverType,\n type SQLiteErrorMapper,\n} from '..';\nimport type { JSONSerializer } from '../../../../core';\nimport {\n createAmbientConnection,\n createConnection,\n type AnyConnection,\n type BatchSQLCommandOptions,\n type Connection,\n type ConnectionOptions,\n type DatabaseTransaction,\n type InferDbClientFromConnection,\n type InferDriverTypeFromConnection,\n type InitTransaction,\n type SQLCommandOptions,\n type SQLExecutor,\n} from '../../../../core';\nimport { sqliteTransaction, type SQLiteTransactionMode } from '../transactions';\n\nexport type SQLiteCommandOptions = SQLCommandOptions & {\n ignoreChangesCount?: boolean;\n};\n\nexport type BatchSQLiteCommandOptions = SQLiteCommandOptions &\n BatchSQLCommandOptions;\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> = Connection<Self, DriverType, SQLiteClientType, TransactionType>;\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> = Connection<Self, DriverType, SQLitePoolClientType, TransactionType>;\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> =\n | (SQLiteClientType extends SQLiteClient\n ? SQLiteClientConnection<\n Self,\n DriverType,\n SQLiteClientType,\n TransactionType\n >\n : never)\n | (SQLiteClientType extends SQLitePoolClient\n ? SQLitePoolClientConnection<\n Self,\n DriverType,\n SQLiteClientType,\n TransactionType\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>;\n\nexport type AnySQLiteConnection =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n SQLiteConnection<any, any, any, any>;\n\nexport type SQLiteConnectionOptions<\n ConnectionType extends AnySQLiteConnection = AnySQLiteConnection,\n> = ConnectionOptions<ConnectionType> & SQLiteClientOptions;\n\nexport type SQLiteClientConnectionDefinitionOptions<\n SQLiteConnectionType extends AnySQLiteClientConnection =\n 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 serializer: JSONSerializer;\n};\n\nexport type SQLitePoolConnectionDefinitionOptions<\n SQLiteConnectionType extends AnySQLitePoolClientConnection =\n 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 serializer: JSONSerializer;\n};\n\nexport type SQLiteConnectionDefinitionOptions<\n SQLiteConnectionType extends AnySQLitePoolClientConnection =\n 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 AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n> = {\n driverType: SQLiteConnectionType['driverType'];\n client: InferDbClientFromConnection<SQLiteConnectionType>;\n initTransaction?: InitTransaction<SQLiteConnectionType>;\n allowNestedTransactions?: boolean;\n defaultTransactionMode?: SQLiteTransactionMode;\n serializer: JSONSerializer;\n errorMapper?: SQLiteErrorMapper;\n};\n\nexport const sqliteAmbientClientConnection = <\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n>(\n options: SqliteAmbientClientConnectionOptions<SQLiteConnectionType>,\n) => {\n const {\n client,\n driverType,\n initTransaction,\n allowNestedTransactions,\n defaultTransactionMode,\n serializer,\n errorMapper,\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 serializer,\n defaultTransactionMode,\n )),\n executor: ({ serializer }) =>\n sqliteSQLExecutor(driverType, serializer, undefined, errorMapper),\n serializer,\n });\n};\n\nexport const sqliteClientConnection = <\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n ClientOptions = SQLiteClientOptions,\n>(\n options: SQLiteClientConnectionDefinitionOptions<\n SQLiteConnectionType,\n ClientOptions\n >,\n): SQLiteConnectionType => {\n const { connectionOptions, sqliteClientFactory, serializer } = 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 try {\n await client.connect();\n } catch (error) {\n throw mapSqliteError(error);\n }\n }\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 serializer,\n connectionOptions.defaultTransactionMode,\n ),\n executor: ({ serializer }) =>\n sqliteSQLExecutor(options.driverType, serializer),\n serializer,\n });\n};\n\nexport const sqlitePoolClientConnection = <\n SQLiteConnectionType extends AnySQLiteClientConnection =\n AnySQLiteClientConnection,\n ClientOptions = SQLiteClientOptions,\n>(\n options: SQLitePoolConnectionDefinitionOptions<\n SQLiteConnectionType,\n ClientOptions\n >,\n): SQLiteConnectionType => {\n const { connectionOptions, sqliteClientFactory, serializer } = 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 try {\n await client.connect();\n } catch (error) {\n throw mapSqliteError(error);\n }\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 serializer,\n connectionOptions.defaultTransactionMode,\n ),\n executor: ({ serializer }) =>\n sqliteSQLExecutor(options.driverType, serializer),\n serializer,\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\nexport type SQLitePragmaOptions = {\n journal_mode?: 'DELETE' | 'TRUNCATE' | 'PERSIST' | 'MEMORY' | 'WAL' | 'OFF';\n synchronous?: 'OFF' | 'NORMAL' | 'FULL' | 'EXTRA';\n cache_size?: number;\n foreign_keys?: boolean;\n temp_store?: 'DEFAULT' | 'FILE' | 'MEMORY';\n busy_timeout?: number;\n mmap_size?: number;\n};\n\nexport const DEFAULT_SQLITE_PRAGMA_OPTIONS: SQLitePragmaOptions = {\n journal_mode: 'WAL',\n synchronous: 'NORMAL',\n cache_size: -1000000,\n foreign_keys: true,\n temp_store: 'MEMORY',\n busy_timeout: 5000,\n mmap_size: 268435456,\n};\n\nexport type SQLiteClientOptions = {\n pragmaOptions?: Partial<SQLitePragmaOptions>;\n defaultTransactionMode?: SQLiteTransactionMode;\n skipDatabasePragmas?: boolean;\n readonly?: boolean;\n};\n\nexport * from './connectionString';\n","import type {\n InferTransactionFromConnection,\n JSONSerializer,\n} from '../../../../core';\nimport {\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 TransactionOptions extends SQLiteTransactionOptions =\n SQLiteTransactionOptions,\n> = DatabaseTransaction<ConnectionType, TransactionOptions>;\n\nexport type SQLiteTransactionMode = 'DEFERRED' | 'IMMEDIATE' | 'EXCLUSIVE';\n\nexport type SQLiteTransactionOptions = DatabaseTransactionOptions & {\n mode?: SQLiteTransactionMode;\n useSavepoints?: boolean;\n};\n\nexport const sqliteTransaction =\n <ConnectionType extends AnySQLiteConnection = AnySQLiteConnection>(\n driverType: ConnectionType['driverType'],\n connection: () => ConnectionType,\n allowNestedTransactions: boolean,\n serializer: JSONSerializer,\n defaultTransactionMode?: 'IMMEDIATE' | 'DEFERRED' | 'EXCLUSIVE',\n ) =>\n (\n getClient: Promise<InferDbClientFromConnection<ConnectionType>>,\n options?: {\n close: (\n client: InferDbClientFromConnection<ConnectionType>,\n error?: unknown,\n ) => Promise<void>;\n } & SQLiteTransactionOptions,\n ): InferTransactionFromConnection<ConnectionType> => {\n const transactionCounter = transactionNestingCounter();\n allowNestedTransactions =\n options?.allowNestedTransactions ?? allowNestedTransactions;\n\n const transaction: DatabaseTransaction<ConnectionType> = {\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 if (options?.useSavepoints) {\n await client.query(\n SQL`SAVEPOINT transaction${SQL.plain(transactionCounter.level.toString())}`,\n );\n }\n return;\n }\n\n transactionCounter.increment();\n }\n\n const mode = options?.mode ?? defaultTransactionMode ?? 'IMMEDIATE';\n await client.query(SQL`BEGIN ${SQL.plain(mode)} 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 if (options?.useSavepoints) {\n await client.query(\n SQL`RELEASE transaction${SQL.plain(transactionCounter.level.toString())}`,\n );\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, serializer), {\n connect: () => getClient,\n }),\n _transactionOptions: options ?? {},\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return transaction as InferTransactionFromConnection<ConnectionType>;\n };\n"]}
@@ -22,7 +22,7 @@
22
22
 
23
23
 
24
24
 
25
- var _chunkEEKBLOCHcjs = require('./chunk-EEKBLOCH.cjs');
25
+ var _chunkJ2S3DPDRcjs = require('./chunk-J2S3DPDR.cjs');
26
26
 
27
27
 
28
28
 
@@ -71,7 +71,7 @@ var d1Client = (options) => {
71
71
  );
72
72
  },
73
73
  query: async (sql, _options) => {
74
- const { query, params } = _chunkEEKBLOCHcjs.sqliteFormatter.format(sql, { serializer });
74
+ const { query, params } = _chunkJ2S3DPDRcjs.sqliteFormatter.format(sql, { serializer });
75
75
  const stmt = execute.prepare(query);
76
76
  const bound = _optionalChain([params, 'optionalAccess', _ => _.length]) ? stmt.bind(...params) : stmt;
77
77
  const { results } = await bound.all();
@@ -79,7 +79,7 @@ var d1Client = (options) => {
79
79
  },
80
80
  batchQuery: async (sqls, _options) => {
81
81
  const statements = sqls.map((sql) => {
82
- const { query, params } = _chunkEEKBLOCHcjs.sqliteFormatter.format(sql, { serializer });
82
+ const { query, params } = _chunkJ2S3DPDRcjs.sqliteFormatter.format(sql, { serializer });
83
83
  const stmt = execute.prepare(query);
84
84
  return _optionalChain([params, 'optionalAccess', _3 => _3.length]) ? stmt.bind(...params) : stmt;
85
85
  });
@@ -90,7 +90,7 @@ var d1Client = (options) => {
90
90
  }));
91
91
  },
92
92
  command: async (sql, _options) => {
93
- const { query, params } = _chunkEEKBLOCHcjs.sqliteFormatter.format(sql, { serializer });
93
+ const { query, params } = _chunkJ2S3DPDRcjs.sqliteFormatter.format(sql, { serializer });
94
94
  const stmt = execute.prepare(query);
95
95
  const bound = _optionalChain([params, 'optionalAccess', _6 => _6.length]) ? stmt.bind(...params) : stmt;
96
96
  const result = await bound.run();
@@ -101,7 +101,7 @@ var d1Client = (options) => {
101
101
  },
102
102
  batchCommand: async (sqls, options2) => {
103
103
  const statements = sqls.map((sql) => {
104
- const { query, params } = _chunkEEKBLOCHcjs.sqliteFormatter.format(sql, { serializer });
104
+ const { query, params } = _chunkJ2S3DPDRcjs.sqliteFormatter.format(sql, { serializer });
105
105
  const stmt = execute.prepare(query);
106
106
  return _optionalChain([params, 'optionalAccess', _9 => _9.length]) ? stmt.bind(...params) : stmt;
107
107
  });
@@ -241,7 +241,7 @@ var mapD1Error = (error) => {
241
241
  // src/storage/sqlite/d1/execute/d1SqlExecutor.ts
242
242
  var d1SQLExecutor = () => ({
243
243
  driverType: "SQLite:d1",
244
- formatter: _chunkEEKBLOCHcjs.sqliteFormatter,
244
+ formatter: _chunkJ2S3DPDRcjs.sqliteFormatter,
245
245
  query: async (client, sql, options) => {
246
246
  try {
247
247
  return await client.query(sql, options);
@@ -286,7 +286,7 @@ var D1TransactionNotSupportedError = class extends Error {
286
286
  }
287
287
  };
288
288
  var d1Transaction = (connection, serializer, defaultOptions) => (getClient, options) => {
289
- const transactionCounter = _chunkEEKBLOCHcjs.transactionNestingCounter.call(void 0, );
289
+ const transactionCounter = _chunkJ2S3DPDRcjs.transactionNestingCounter.call(void 0, );
290
290
  const allowNestedTransactions = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _15 => _15.allowNestedTransactions]), () => ( _optionalChain([defaultOptions, 'optionalAccess', _16 => _16.allowNestedTransactions])));
291
291
  const mode = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _17 => _17.mode]), () => ( _optionalChain([defaultOptions, 'optionalAccess', _18 => _18.mode])));
292
292
  let client = null;
@@ -360,7 +360,7 @@ var d1Transaction = (connection, serializer, defaultOptions) => (getClient, opti
360
360
  var D1DriverType = "SQLite:d1";
361
361
  var d1Connection = (options) => {
362
362
  const connection = _nullishCoalesce(_nullishCoalesce(options.connection, () => ( _optionalChain([options, 'access', _26 => _26.transaction, 'optionalAccess', _27 => _27.connection]))), () => ( {
363
- ..._chunkEEKBLOCHcjs.sqliteAmbientClientConnection.call(void 0, {
363
+ ..._chunkJ2S3DPDRcjs.sqliteAmbientClientConnection.call(void 0, {
364
364
  driverType: D1DriverType,
365
365
  client: _nullishCoalesce(options.client, () => ( d1Client(options))),
366
366
  initTransaction: (connection2) => d1Transaction(
@@ -404,8 +404,8 @@ var d1Pool = (options) => _chunkGVR3PSDLcjs.createSingletonConnectionPool.call(v
404
404
  var d1DumboDriver = {
405
405
  driverType: D1DriverType,
406
406
  createPool: (options) => d1Pool(options),
407
- sqlFormatter: _chunkEEKBLOCHcjs.sqliteFormatter,
408
- defaultMigratorOptions: _chunkEEKBLOCHcjs.DefaultSQLiteMigratorOptions,
407
+ sqlFormatter: _chunkJ2S3DPDRcjs.sqliteFormatter,
408
+ defaultMigratorOptions: _chunkJ2S3DPDRcjs.DefaultSQLiteMigratorOptions,
409
409
  canHandle: (options) => {
410
410
  return options.driverType === D1DriverType && "database" in options;
411
411
  },
@@ -452,5 +452,5 @@ useD1DumboDriver();
452
452
 
453
453
 
454
454
 
455
- exports.D1DriverType = D1DriverType; exports.D1TransactionNotSupportedError = D1TransactionNotSupportedError; exports.DEFAULT_SQLITE_PRAGMA_OPTIONS = _chunkEEKBLOCHcjs.DEFAULT_SQLITE_PRAGMA_OPTIONS; exports.DefaultSQLiteMigratorOptions = _chunkEEKBLOCHcjs.DefaultSQLiteMigratorOptions; exports.InMemorySQLiteDatabase = _chunkEEKBLOCHcjs.InMemorySQLiteDatabase; exports.SQLiteConnectionString = _chunkEEKBLOCHcjs.SQLiteConnectionString; exports.SQLiteDatabaseName = _chunkEEKBLOCHcjs.SQLiteDatabaseName; exports.d1Client = d1Client; exports.d1Connection = d1Connection; exports.d1DumboDriver = d1DumboDriver; exports.d1Pool = d1Pool; exports.d1SQLExecutor = d1SQLExecutor; exports.d1Transaction = d1Transaction; exports.defaultSQLiteDatabase = _chunkHZM7GDOTcjs.defaultSQLiteDatabase; exports.isInMemoryDatabase = _chunkEEKBLOCHcjs.isInMemoryDatabase; exports.isSQLiteError = _chunkEEKBLOCHcjs.isSQLiteError; exports.mapD1Error = mapD1Error; exports.mapSqliteError = _chunkEEKBLOCHcjs.mapSqliteError; exports.parsePragmasFromConnectionString = _chunkEEKBLOCHcjs.parsePragmasFromConnectionString; exports.sqliteAlwaysNewConnectionPool = _chunkEEKBLOCHcjs.sqliteAlwaysNewConnectionPool; exports.sqliteAmbientClientConnection = _chunkEEKBLOCHcjs.sqliteAmbientClientConnection; exports.sqliteAmbientConnectionPool = _chunkEEKBLOCHcjs.sqliteAmbientConnectionPool; exports.sqliteClientConnection = _chunkEEKBLOCHcjs.sqliteClientConnection; exports.sqliteConnection = _chunkEEKBLOCHcjs.sqliteConnection; exports.sqliteExecute = _chunkEEKBLOCHcjs.sqliteExecute; exports.sqliteFormatter = _chunkEEKBLOCHcjs.sqliteFormatter; exports.sqliteMetadata = _chunkHZM7GDOTcjs.sqliteMetadata; exports.sqlitePool = _chunkEEKBLOCHcjs.sqlitePool; exports.sqlitePoolClientConnection = _chunkEEKBLOCHcjs.sqlitePoolClientConnection; exports.sqliteSQLExecutor = _chunkEEKBLOCHcjs.sqliteSQLExecutor; exports.sqliteSingletonConnectionPool = _chunkEEKBLOCHcjs.sqliteSingletonConnectionPool; exports.sqliteTransaction = _chunkEEKBLOCHcjs.sqliteTransaction; exports.tableExists = _chunkHZM7GDOTcjs.tableExists; exports.toSqlitePoolOptions = _chunkEEKBLOCHcjs.toSqlitePoolOptions; exports.transactionNestingCounter = _chunkEEKBLOCHcjs.transactionNestingCounter; exports.useD1DumboDriver = useD1DumboDriver;
455
+ exports.D1DriverType = D1DriverType; exports.D1TransactionNotSupportedError = D1TransactionNotSupportedError; exports.DEFAULT_SQLITE_PRAGMA_OPTIONS = _chunkJ2S3DPDRcjs.DEFAULT_SQLITE_PRAGMA_OPTIONS; exports.DefaultSQLiteMigratorOptions = _chunkJ2S3DPDRcjs.DefaultSQLiteMigratorOptions; exports.InMemorySQLiteDatabase = _chunkJ2S3DPDRcjs.InMemorySQLiteDatabase; exports.SQLiteConnectionString = _chunkJ2S3DPDRcjs.SQLiteConnectionString; exports.SQLiteDatabaseName = _chunkJ2S3DPDRcjs.SQLiteDatabaseName; exports.d1Client = d1Client; exports.d1Connection = d1Connection; exports.d1DumboDriver = d1DumboDriver; exports.d1Pool = d1Pool; exports.d1SQLExecutor = d1SQLExecutor; exports.d1Transaction = d1Transaction; exports.defaultSQLiteDatabase = _chunkHZM7GDOTcjs.defaultSQLiteDatabase; exports.isInMemoryDatabase = _chunkJ2S3DPDRcjs.isInMemoryDatabase; exports.isSQLiteError = _chunkJ2S3DPDRcjs.isSQLiteError; exports.mapD1Error = mapD1Error; exports.mapSqliteError = _chunkJ2S3DPDRcjs.mapSqliteError; exports.parsePragmasFromConnectionString = _chunkJ2S3DPDRcjs.parsePragmasFromConnectionString; exports.sqliteAlwaysNewConnectionPool = _chunkJ2S3DPDRcjs.sqliteAlwaysNewConnectionPool; exports.sqliteAmbientClientConnection = _chunkJ2S3DPDRcjs.sqliteAmbientClientConnection; exports.sqliteAmbientConnectionPool = _chunkJ2S3DPDRcjs.sqliteAmbientConnectionPool; exports.sqliteClientConnection = _chunkJ2S3DPDRcjs.sqliteClientConnection; exports.sqliteConnection = _chunkJ2S3DPDRcjs.sqliteConnection; exports.sqliteExecute = _chunkJ2S3DPDRcjs.sqliteExecute; exports.sqliteFormatter = _chunkJ2S3DPDRcjs.sqliteFormatter; exports.sqliteMetadata = _chunkHZM7GDOTcjs.sqliteMetadata; exports.sqlitePool = _chunkJ2S3DPDRcjs.sqlitePool; exports.sqlitePoolClientConnection = _chunkJ2S3DPDRcjs.sqlitePoolClientConnection; exports.sqliteSQLExecutor = _chunkJ2S3DPDRcjs.sqliteSQLExecutor; exports.sqliteSingletonConnectionPool = _chunkJ2S3DPDRcjs.sqliteSingletonConnectionPool; exports.sqliteTransaction = _chunkJ2S3DPDRcjs.sqliteTransaction; exports.tableExists = _chunkHZM7GDOTcjs.tableExists; exports.toSqlitePoolOptions = _chunkJ2S3DPDRcjs.toSqlitePoolOptions; exports.transactionNestingCounter = _chunkJ2S3DPDRcjs.transactionNestingCounter; exports.useD1DumboDriver = useD1DumboDriver;
456
456
  //# sourceMappingURL=cloudflare.cjs.map
@@ -22,7 +22,7 @@ import {
22
22
  sqliteTransaction,
23
23
  toSqlitePoolOptions,
24
24
  transactionNestingCounter
25
- } from "./chunk-XFEGS3YT.js";
25
+ } from "./chunk-CMHMR5VO.js";
26
26
  import {
27
27
  defaultSQLiteDatabase,
28
28
  sqliteMetadata,