@jterrazz/test 6.0.0 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mock-of.cjs CHANGED
@@ -1,27 +1,6 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
- //#endregion
1
+ const require_chunk = require("./chunk.cjs");
23
2
  let mockdate = require("mockdate");
24
- mockdate = __toESM(mockdate, 1);
3
+ mockdate = require_chunk.__toESM(mockdate, 1);
25
4
  let vitest_mock_extended = require("vitest-mock-extended");
26
5
  //#region src/mocking/mock-of-date.ts
27
6
  /**
@@ -37,12 +16,6 @@ const mockOfDate = mockdate.default;
37
16
  */
38
17
  const mockOf = vitest_mock_extended.mockDeep;
39
18
  //#endregion
40
- Object.defineProperty(exports, "__toESM", {
41
- enumerable: true,
42
- get: function() {
43
- return __toESM;
44
- }
45
- });
46
19
  Object.defineProperty(exports, "mockOf", {
47
20
  enumerable: true,
48
21
  get: function() {
@@ -1 +1 @@
1
- {"version":3,"file":"mock-of.cjs","names":["MockDatePackage","mockDeep"],"sources":["../src/mocking/mock-of-date.ts","../src/mocking/mock-of.ts"],"sourcesContent":["import MockDatePackage from 'mockdate';\n\n/** Interface for freezing and resetting the global Date in tests. */\nexport interface MockDatePort {\n /** Restore the real Date object. */\n reset: () => void;\n /** Freeze `Date.now()` and `new Date()` to the given value. */\n set: (date: Date | number | string) => void;\n}\n\n/**\n * Freeze or reset the global Date for deterministic time-dependent tests.\n * Wraps the `mockdate` package.\n */\nexport const mockOfDate: MockDatePort = MockDatePackage;\n","import { type DeepMockProxy, mockDeep } from 'vitest-mock-extended';\n\n/** Factory signature that creates a deep mock proxy for any interface. */\nexport type MockPort = <T>() => DeepMockProxy<T>;\n\n/**\n * Create a deep mock proxy for a given type.\n * Wraps `vitest-mock-extended`'s `mockDeep` for convenient port mocking.\n */\nexport const mockOf: MockPort = mockDeep;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAa,aAA2BA,SAAAA;;;;;;;ACLxC,MAAa,SAAmBC,qBAAAA"}
1
+ {"version":3,"file":"mock-of.cjs","names":["MockDatePackage","mockDeep"],"sources":["../src/mocking/mock-of-date.ts","../src/mocking/mock-of.ts"],"sourcesContent":["import MockDatePackage from 'mockdate';\n\n/** Interface for freezing and resetting the global Date in tests. */\nexport interface MockDatePort {\n /** Restore the real Date object. */\n reset: () => void;\n /** Freeze `Date.now()` and `new Date()` to the given value. */\n set: (date: Date | number | string) => void;\n}\n\n/**\n * Freeze or reset the global Date for deterministic time-dependent tests.\n * Wraps the `mockdate` package.\n */\nexport const mockOfDate: MockDatePort = MockDatePackage;\n","import { type DeepMockProxy, mockDeep } from 'vitest-mock-extended';\n\n/** Factory signature that creates a deep mock proxy for any interface. */\nexport type MockPort = <T>() => DeepMockProxy<T>;\n\n/**\n * Create a deep mock proxy for a given type.\n * Wraps `vitest-mock-extended`'s `mockDeep` for convenient port mocking.\n */\nexport const mockOf: MockPort = mockDeep;\n"],"mappings":";;;;;;;;;AAcA,MAAa,aAA2BA,SAAAA;;;;;;;ACLxC,MAAa,SAAmBC,qBAAAA"}
package/dist/services.cjs CHANGED
@@ -1,4 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_redis_adapter = require("./redis.adapter.cjs");
3
- exports.postgres = require_redis_adapter.postgres;
4
- exports.redis = require_redis_adapter.redis;
2
+ const require_sqlite_adapter = require("./sqlite.adapter.cjs");
3
+ exports.postgres = require_sqlite_adapter.postgres;
4
+ exports.redis = require_sqlite_adapter.redis;
5
+ exports.sqlite = require_sqlite_adapter.sqlite;
@@ -1,2 +1,2 @@
1
- import { i as postgres, n as redis, r as PostgresOptions, t as RedisOptions } from "./redis.adapter.cjs";
2
- export { type PostgresOptions, type RedisOptions, postgres, redis };
1
+ import { a as PostgresOptions, i as redis, n as sqlite, o as postgres, r as RedisOptions, t as SqliteOptions } from "./sqlite.adapter.cjs";
2
+ export { type PostgresOptions, type RedisOptions, type SqliteOptions, postgres, redis, sqlite };
@@ -1,2 +1,2 @@
1
- import { i as postgres, n as redis, r as PostgresOptions, t as RedisOptions } from "./redis.adapter.js";
2
- export { type PostgresOptions, type RedisOptions, postgres, redis };
1
+ import { a as PostgresOptions, i as redis, n as sqlite, o as postgres, r as RedisOptions, t as SqliteOptions } from "./sqlite.adapter.js";
2
+ export { type PostgresOptions, type RedisOptions, type SqliteOptions, postgres, redis, sqlite };
package/dist/services.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as postgres, t as redis } from "./redis.adapter.js";
2
- export { postgres, redis };
1
+ import { n as redis, r as postgres, t as sqlite } from "./sqlite.adapter.js";
2
+ export { postgres, redis, sqlite };
@@ -1,7 +1,10 @@
1
- require("./mock-of.cjs");
1
+ const require_chunk = require("./chunk.cjs");
2
2
  let node_fs = require("node:fs");
3
+ let node_os = require("node:os");
3
4
  let node_path = require("node:path");
4
5
  let pg = require("pg");
6
+ let better_sqlite3 = require("better-sqlite3");
7
+ better_sqlite3 = require_chunk.__toESM(better_sqlite3, 1);
5
8
  //#region src/adapters/postgres.adapter.ts
6
9
  var PostgresHandle = class {
7
10
  type = "postgres";
@@ -198,6 +201,133 @@ function redis(options = {}) {
198
201
  return new RedisHandle(options);
199
202
  }
200
203
  //#endregion
204
+ //#region src/adapters/sqlite.adapter.ts
205
+ var SqliteHandle = class {
206
+ type = "sqlite";
207
+ composeName = null;
208
+ defaultPort = 0;
209
+ defaultImage = "";
210
+ environment = {};
211
+ connectionString = "";
212
+ started = false;
213
+ db = null;
214
+ templatePath = "";
215
+ workerDbPath = "";
216
+ initSql;
217
+ prismaSchema;
218
+ constructor(options = {}) {
219
+ this.initSql = options.init ?? null;
220
+ this.prismaSchema = options.prismaSchema ?? null;
221
+ }
222
+ buildConnectionString() {
223
+ return `file:${this.workerDbPath || this.templatePath}`;
224
+ }
225
+ createDatabaseAdapter() {
226
+ return this;
227
+ }
228
+ async healthcheck() {}
229
+ async initialize() {
230
+ this.templatePath = (0, node_path.resolve)((0, node_os.tmpdir)(), "jterrazz-test-sqlite-template.sqlite");
231
+ const lockPath = `${this.templatePath}.lock`;
232
+ if ((0, node_fs.existsSync)(lockPath)) {
233
+ const start = Date.now();
234
+ while ((0, node_fs.existsSync)(lockPath) && Date.now() - start < 3e4) await new Promise((r) => setTimeout(r, 100));
235
+ }
236
+ if ((0, node_fs.existsSync)(this.templatePath)) {
237
+ this.connectionString = `file:${this.templatePath}`;
238
+ this.started = true;
239
+ return;
240
+ }
241
+ const { writeFileSync } = await import("node:fs");
242
+ writeFileSync(lockPath, process.pid.toString());
243
+ if (this.prismaSchema) {
244
+ const { execSync } = await import("node:child_process");
245
+ execSync("npx prisma db push --force-reset", {
246
+ env: {
247
+ ...process.env,
248
+ DATABASE_URL: `file:${this.templatePath}`,
249
+ PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION: "yes"
250
+ },
251
+ stdio: "pipe"
252
+ });
253
+ const tmpDb = new better_sqlite3.default(this.templatePath);
254
+ tmpDb.pragma("wal_checkpoint(TRUNCATE)");
255
+ tmpDb.close();
256
+ } else if (this.initSql) {
257
+ const sql = (0, node_fs.readFileSync)(this.initSql, "utf8");
258
+ const templateDb = new better_sqlite3.default(this.templatePath);
259
+ templateDb.exec(sql);
260
+ templateDb.close();
261
+ } else new better_sqlite3.default(this.templatePath).close();
262
+ try {
263
+ (0, node_fs.unlinkSync)(lockPath);
264
+ } catch {}
265
+ this.connectionString = `file:${this.templatePath}`;
266
+ this.started = true;
267
+ }
268
+ getDb() {
269
+ const dbPath = this.workerDbPath || this.templatePath;
270
+ if (!this.db) {
271
+ this.db = new better_sqlite3.default(dbPath);
272
+ this.db.pragma("journal_mode = WAL");
273
+ }
274
+ return this.db;
275
+ }
276
+ closeDb() {
277
+ if (this.db) {
278
+ this.db.close();
279
+ this.db = null;
280
+ }
281
+ }
282
+ async seed(sql) {
283
+ this.getDb().exec(sql);
284
+ }
285
+ async query(table, columns) {
286
+ const columnList = columns.join(", ");
287
+ return this.getDb().prepare(`SELECT ${columnList} FROM "${table}" ORDER BY 1`).all().map((row) => columns.map((col) => row[col]));
288
+ }
289
+ async reset() {
290
+ const db = this.getDb();
291
+ const tables = db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE '_prisma%' AND name != 'sqlite_sequence'`).all();
292
+ for (const { name } of tables) db.exec(`DELETE FROM "${name}"`);
293
+ }
294
+ isolation() {
295
+ return {
296
+ acquire: async (workerId) => {
297
+ this.closeDb();
298
+ this.workerDbPath = (0, node_path.resolve)((0, node_os.tmpdir)(), `test-worker-${workerId}-${Date.now()}.sqlite`);
299
+ (0, node_fs.copyFileSync)(this.templatePath, this.workerDbPath);
300
+ this.connectionString = `file:${this.workerDbPath}`;
301
+ },
302
+ reset: async () => {
303
+ await this.reset();
304
+ },
305
+ release: async () => {
306
+ this.closeDb();
307
+ if (this.workerDbPath && (0, node_fs.existsSync)(this.workerDbPath)) (0, node_fs.unlinkSync)(this.workerDbPath);
308
+ this.workerDbPath = "";
309
+ this.connectionString = `file:${this.templatePath}`;
310
+ }
311
+ };
312
+ }
313
+ };
314
+ /**
315
+ * Create a SQLite service handle. Uses file-copy isolation for parallel tests.
316
+ *
317
+ * @example
318
+ * // With Prisma schema
319
+ * const db = sqlite({ prismaSchema: './prisma/schema' });
320
+ *
321
+ * // With raw SQL init
322
+ * const db = sqlite({ init: './schema.sql' });
323
+ *
324
+ * // Empty database
325
+ * const db = sqlite();
326
+ */
327
+ function sqlite(options = {}) {
328
+ return new SqliteHandle(options);
329
+ }
330
+ //#endregion
201
331
  Object.defineProperty(exports, "postgres", {
202
332
  enumerable: true,
203
333
  get: function() {
@@ -210,5 +340,11 @@ Object.defineProperty(exports, "redis", {
210
340
  return redis;
211
341
  }
212
342
  });
343
+ Object.defineProperty(exports, "sqlite", {
344
+ enumerable: true,
345
+ get: function() {
346
+ return sqlite;
347
+ }
348
+ });
213
349
 
214
- //# sourceMappingURL=redis.adapter.cjs.map
350
+ //# sourceMappingURL=sqlite.adapter.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite.adapter.cjs","names":["Client","Database"],"sources":["../src/adapters/postgres.adapter.ts","../src/adapters/redis.adapter.ts","../src/adapters/sqlite.adapter.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { Client } from 'pg';\n\nimport type { DatabasePort } from '../ports/database.port.js';\nimport type { IsolationStrategy } from '../ports/isolation.port.js';\nimport type { ServiceHandle } from '../ports/service.port.js';\n\nexport interface PostgresOptions {\n /** Map to a service in docker-compose.test.yaml. */\n compose?: string;\n /** Override image. */\n image?: string;\n /** Override environment variables. */\n env?: Record<string, string>;\n}\n\nexport class PostgresHandle implements DatabasePort, ServiceHandle {\n readonly type = 'postgres';\n readonly composeName: null | string;\n readonly defaultPort = 5432;\n readonly defaultImage: string;\n readonly environment: Record<string, string>;\n\n connectionString = '';\n started = false;\n\n private client: Client | null = null;\n private originalConnectionString = '';\n private schema = 'public';\n\n constructor(options: PostgresOptions = {}) {\n this.composeName = options.compose ?? null;\n this.defaultImage = options.image ?? 'postgres:17';\n this.environment = {\n POSTGRES_DB: 'test',\n POSTGRES_PASSWORD: 'test',\n POSTGRES_USER: 'test',\n ...options.env,\n };\n }\n\n buildConnectionString(host: string, port: number): string {\n const user = this.environment.POSTGRES_USER ?? 'test';\n const password = this.environment.POSTGRES_PASSWORD ?? 'test';\n const db = this.environment.POSTGRES_DB ?? 'test';\n return `postgresql://${user}:${password}@${host}:${port}/${db}`;\n }\n\n createDatabaseAdapter(): DatabasePort {\n return this;\n }\n\n async healthcheck(): Promise<void> {\n if (!this.connectionString) {\n throw new Error('postgres: cannot healthcheck — no connection string');\n }\n\n // Healthcheck uses a throwaway client (connection might not be established yet)\n try {\n const client = new Client({ connectionString: this.connectionString });\n await client.connect();\n await client.query('SELECT 1');\n await client.end();\n } catch (error: any) {\n throw new Error(\n `postgres healthcheck failed: ${error.message || error.code || String(error)}`,\n { cause: error },\n );\n }\n }\n\n async initialize(composeDir: string): Promise<void> {\n if (!this.composeName) {\n return;\n }\n\n const initPaths = [\n resolve(composeDir, `${this.composeName}/init.sql`),\n resolve(composeDir, 'postgres/init.sql'),\n ];\n\n for (const initPath of initPaths) {\n if (existsSync(initPath)) {\n const sql = readFileSync(initPath, 'utf8');\n try {\n await this.seed(sql);\n } catch (error: any) {\n throw new Error(\n `postgres init script failed (${initPath}):\\n${error.message}`,\n {\n cause: error,\n },\n );\n }\n return;\n }\n }\n }\n\n private async getClient(): Promise<Client> {\n if (this.client) {\n return this.client;\n }\n const client = new Client({ connectionString: this.connectionString });\n client.on('error', () => {\n // Connection dropped (container stopped) — reset so next call reconnects\n this.client = null;\n });\n await client.connect();\n this.client = client;\n return client;\n }\n\n async seed(sql: string): Promise<void> {\n const client = await this.getClient();\n await client.query(sql);\n }\n\n async reset(): Promise<void> {\n const client = await this.getClient();\n const result = await client.query(`\n SELECT tablename FROM pg_tables\n WHERE schemaname = '${this.schema}'\n AND tablename NOT LIKE '_prisma%'\n `);\n for (const row of result.rows) {\n await client.query(`TRUNCATE \"${this.schema}\".\"${row.tablename}\" CASCADE`);\n }\n }\n\n async query(table: string, columns: string[]): Promise<unknown[][]> {\n const client = await this.getClient();\n const columnList = columns.join(', ');\n const result = await client.query(\n `SELECT ${columnList} FROM \"${this.schema}\".\"${table}\" ORDER BY 1`,\n );\n return result.rows.map((row: Record<string, unknown>) => columns.map((col) => row[col]));\n }\n\n isolation(): IsolationStrategy {\n return {\n acquire: async (workerId: string) => {\n const workerSchema = `worker_${workerId}`;\n this.originalConnectionString = this.connectionString;\n const client = await this.getClient();\n\n // Create schema by cloning all tables from public\n await client.query(`DROP SCHEMA IF EXISTS \"${workerSchema}\" CASCADE`);\n await client.query(`CREATE SCHEMA \"${workerSchema}\"`);\n\n // Copy table structures (no data) from public\n const tables = await client.query(`\n SELECT tablename FROM pg_tables\n WHERE schemaname = 'public'\n AND tablename NOT LIKE '_prisma%'\n `);\n for (const row of tables.rows) {\n await client.query(\n `CREATE TABLE \"${workerSchema}\".\"${row.tablename}\" (LIKE \"public\".\"${row.tablename}\" INCLUDING ALL)`,\n );\n }\n\n // Switch this handle to use the worker schema\n this.schema = workerSchema;\n await client.query(`SET search_path TO \"${workerSchema}\", public`);\n\n // Update connectionString so app connections also use the worker schema\n const url = new URL(this.connectionString);\n url.searchParams.set('options', `-c search_path=${workerSchema},public`);\n this.connectionString = url.toString();\n },\n\n reset: async () => {\n await this.reset();\n },\n\n release: async () => {\n const client = await this.getClient();\n const workerSchema = this.schema;\n this.schema = 'public';\n this.connectionString = this.originalConnectionString;\n await client.query(`SET search_path TO public`);\n await client.query(`DROP SCHEMA IF EXISTS \"${workerSchema}\" CASCADE`);\n },\n };\n }\n}\n\n/**\n * Create a PostgreSQL service handle.\n *\n * @example\n * const db = postgres({ compose: \"db\" });\n * // After start: db.connectionString is populated\n */\nexport function postgres(options: PostgresOptions = {}): PostgresHandle {\n return new PostgresHandle(options);\n}\n","import type { DatabasePort } from '../ports/database.port.js';\nimport type { IsolationStrategy } from '../ports/isolation.port.js';\nimport type { ServiceHandle } from '../ports/service.port.js';\n\nexport interface RedisOptions {\n /** Map to a service in docker-compose.test.yaml. */\n compose?: string;\n /** Override image. */\n image?: string;\n}\n\nexport class RedisHandle implements ServiceHandle {\n readonly type = 'redis';\n readonly composeName: null | string;\n readonly defaultPort = 6379;\n readonly defaultImage: string;\n readonly environment: Record<string, string> = {};\n\n connectionString = '';\n started = false;\n\n private dbIndex = 0;\n\n constructor(options: RedisOptions = {}) {\n this.composeName = options.compose ?? null;\n this.defaultImage = options.image ?? 'redis:7';\n }\n\n buildConnectionString(host: string, port: number): string {\n return `redis://${host}:${port}`;\n }\n\n createDatabaseAdapter(): DatabasePort | null {\n return null;\n }\n\n async healthcheck(): Promise<void> {\n if (!this.connectionString) {\n throw new Error('redis: cannot healthcheck — no connection string');\n }\n\n try {\n const { createClient } = await import('redis');\n const client = createClient({ url: this.connectionString });\n await client.connect();\n await client.ping();\n await client.disconnect();\n } catch (error: any) {\n throw new Error(\n `redis healthcheck failed: ${error.message || error.code || String(error)}`,\n {\n cause: error,\n },\n );\n }\n }\n\n async initialize(): Promise<void> {\n // Redis doesn't need initialization scripts\n }\n\n async reset(): Promise<void> {\n const { createClient } = await import('redis');\n const client = createClient({ url: this.connectionString, database: this.dbIndex });\n await client.connect();\n try {\n await client.flushDb();\n } finally {\n await client.disconnect();\n }\n }\n\n isolation(): IsolationStrategy {\n return {\n acquire: async (workerId: string) => {\n // Use Redis database index 1-15 for workers (0 is default/shared)\n const numericId = Number.parseInt(workerId, 10) || 0;\n this.dbIndex = (numericId % 15) + 1;\n },\n\n reset: async () => {\n await this.reset();\n },\n\n release: async () => {\n await this.reset();\n this.dbIndex = 0;\n },\n };\n }\n}\n\n/**\n * Create a Redis service handle.\n *\n * @example\n * const cache = redis({ compose: \"cache\" });\n * // After start: cache.connectionString is populated\n */\nexport function redis(options: RedisOptions = {}): RedisHandle {\n return new RedisHandle(options);\n}\n","import Database from 'better-sqlite3';\nimport { copyFileSync, existsSync, readFileSync, unlinkSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { resolve } from 'node:path';\n\nimport type { DatabasePort } from '../ports/database.port.js';\nimport type { IsolationStrategy } from '../ports/isolation.port.js';\nimport type { ServiceHandle } from '../ports/service.port.js';\n\nexport interface SqliteOptions {\n /**\n * Path to a SQL file used to initialize the database schema.\n * Mutually exclusive with `prismaSchema`.\n */\n init?: string;\n /**\n * Path to a Prisma schema directory or file.\n * The adapter runs `prisma db push` to create the template.\n * Mutually exclusive with `init`.\n */\n prismaSchema?: string;\n}\n\nexport class SqliteHandle implements DatabasePort, ServiceHandle {\n readonly type = 'sqlite';\n readonly composeName = null;\n readonly defaultPort = 0;\n readonly defaultImage = '';\n readonly environment: Record<string, string> = {};\n\n connectionString = '';\n started = false;\n\n private db: Database.Database | null = null;\n private templatePath = '';\n private workerDbPath = '';\n private initSql: null | string;\n private prismaSchema: null | string;\n\n constructor(options: SqliteOptions = {}) {\n this.initSql = options.init ?? null;\n this.prismaSchema = options.prismaSchema ?? null;\n }\n\n buildConnectionString(): string {\n return `file:${this.workerDbPath || this.templatePath}`;\n }\n\n createDatabaseAdapter(): DatabasePort {\n return this;\n }\n\n async healthcheck(): Promise<void> {\n // SQLite is always ready — it's a file\n }\n\n async initialize(): Promise<void> {\n // Each test run gets a fresh template; workers share it via lock\n this.templatePath = resolve(tmpdir(), 'jterrazz-test-sqlite-template.sqlite');\n const lockPath = `${this.templatePath}.lock`;\n\n if (existsSync(lockPath)) {\n // Another worker is creating it — wait for it\n const start = Date.now();\n while (existsSync(lockPath) && Date.now() - start < 30_000) {\n await new Promise((r) => setTimeout(r, 100));\n }\n }\n\n if (existsSync(this.templatePath)) {\n this.connectionString = `file:${this.templatePath}`;\n this.started = true;\n return;\n }\n\n // Acquire lock\n const { writeFileSync } = await import('node:fs');\n writeFileSync(lockPath, process.pid.toString());\n\n if (this.prismaSchema) {\n // Use Prisma to create schema\n const { execSync } = await import('node:child_process');\n execSync('npx prisma db push --force-reset', {\n env: {\n ...process.env,\n DATABASE_URL: `file:${this.templatePath}`,\n PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION: 'yes',\n },\n stdio: 'pipe',\n });\n\n // Checkpoint WAL so the template is a single file (safe to copy)\n const tmpDb = new Database(this.templatePath);\n tmpDb.pragma('wal_checkpoint(TRUNCATE)');\n tmpDb.close();\n } else if (this.initSql) {\n // Use raw SQL to create schema\n const sql = readFileSync(this.initSql, 'utf8');\n const templateDb = new Database(this.templatePath);\n templateDb.exec(sql);\n templateDb.close();\n } else {\n // Empty database — consumer will seed\n const templateDb = new Database(this.templatePath);\n templateDb.close();\n }\n\n // Release lock\n try {\n unlinkSync(lockPath);\n } catch {\n /* Ignore */\n }\n\n this.connectionString = `file:${this.templatePath}`;\n this.started = true;\n }\n\n private getDb(): Database.Database {\n const dbPath = this.workerDbPath || this.templatePath;\n if (!this.db) {\n this.db = new Database(dbPath);\n this.db.pragma('journal_mode = WAL');\n }\n return this.db;\n }\n\n private closeDb(): void {\n if (this.db) {\n this.db.close();\n this.db = null;\n }\n }\n\n async seed(sql: string): Promise<void> {\n this.getDb().exec(sql);\n }\n\n async query(table: string, columns: string[]): Promise<unknown[][]> {\n const columnList = columns.join(', ');\n const rows = this.getDb()\n .prepare(`SELECT ${columnList} FROM \"${table}\" ORDER BY 1`)\n .all() as Record<string, unknown>[];\n return rows.map((row) => columns.map((col) => row[col]));\n }\n\n async reset(): Promise<void> {\n const db = this.getDb();\n const tables = db\n .prepare(\n `SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE '_prisma%' AND name != 'sqlite_sequence'`,\n )\n .all() as { name: string }[];\n for (const { name } of tables) {\n db.exec(`DELETE FROM \"${name}\"`);\n }\n }\n\n isolation(): IsolationStrategy {\n return {\n acquire: async (workerId: string) => {\n this.closeDb();\n this.workerDbPath = resolve(\n tmpdir(),\n `test-worker-${workerId}-${Date.now()}.sqlite`,\n );\n copyFileSync(this.templatePath, this.workerDbPath);\n this.connectionString = `file:${this.workerDbPath}`;\n },\n\n reset: async () => {\n await this.reset();\n },\n\n release: async () => {\n this.closeDb();\n if (this.workerDbPath && existsSync(this.workerDbPath)) {\n unlinkSync(this.workerDbPath);\n }\n this.workerDbPath = '';\n this.connectionString = `file:${this.templatePath}`;\n },\n };\n }\n}\n\n/**\n * Create a SQLite service handle. Uses file-copy isolation for parallel tests.\n *\n * @example\n * // With Prisma schema\n * const db = sqlite({ prismaSchema: './prisma/schema' });\n *\n * // With raw SQL init\n * const db = sqlite({ init: './schema.sql' });\n *\n * // Empty database\n * const db = sqlite();\n */\nexport function sqlite(options: SqliteOptions = {}): SqliteHandle {\n return new SqliteHandle(options);\n}\n"],"mappings":";;;;;;;;AAiBA,IAAa,iBAAb,MAAmE;CAC/D,OAAgB;CAChB;CACA,cAAuB;CACvB;CACA;CAEA,mBAAmB;CACnB,UAAU;CAEV,SAAgC;CAChC,2BAAmC;CACnC,SAAiB;CAEjB,YAAY,UAA2B,EAAE,EAAE;AACvC,OAAK,cAAc,QAAQ,WAAW;AACtC,OAAK,eAAe,QAAQ,SAAS;AACrC,OAAK,cAAc;GACf,aAAa;GACb,mBAAmB;GACnB,eAAe;GACf,GAAG,QAAQ;GACd;;CAGL,sBAAsB,MAAc,MAAsB;AAItD,SAAO,gBAHM,KAAK,YAAY,iBAAiB,OAGnB,GAFX,KAAK,YAAY,qBAAqB,OAEf,GAAG,KAAK,GAAG,KAAK,GAD7C,KAAK,YAAY,eAAe;;CAI/C,wBAAsC;AAClC,SAAO;;CAGX,MAAM,cAA6B;AAC/B,MAAI,CAAC,KAAK,iBACN,OAAM,IAAI,MAAM,sDAAsD;AAI1E,MAAI;GACA,MAAM,SAAS,IAAIA,GAAAA,OAAO,EAAE,kBAAkB,KAAK,kBAAkB,CAAC;AACtE,SAAM,OAAO,SAAS;AACtB,SAAM,OAAO,MAAM,WAAW;AAC9B,SAAM,OAAO,KAAK;WACb,OAAY;AACjB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;;;;;;;;;AAiBT,SAAgB,OAAO,UAAyB,EAAE,EAAgB;AAC9D,QAAO,IAAI,aAAa,QAAQ"}
@@ -151,5 +151,59 @@ declare class RedisHandle implements ServiceHandle {
151
151
  */
152
152
  declare function redis(options?: RedisOptions): RedisHandle;
153
153
  //#endregion
154
- export { ServiceHandle as a, postgres as i, redis as n, IsolationStrategy as o, PostgresOptions as r, DatabasePort as s, RedisOptions as t };
155
- //# sourceMappingURL=redis.adapter.d.ts.map
154
+ //#region src/adapters/sqlite.adapter.d.ts
155
+ interface SqliteOptions {
156
+ /**
157
+ * Path to a SQL file used to initialize the database schema.
158
+ * Mutually exclusive with `prismaSchema`.
159
+ */
160
+ init?: string;
161
+ /**
162
+ * Path to a Prisma schema directory or file.
163
+ * The adapter runs `prisma db push` to create the template.
164
+ * Mutually exclusive with `init`.
165
+ */
166
+ prismaSchema?: string;
167
+ }
168
+ declare class SqliteHandle implements DatabasePort, ServiceHandle {
169
+ readonly type = "sqlite";
170
+ readonly composeName: null;
171
+ readonly defaultPort = 0;
172
+ readonly defaultImage = "";
173
+ readonly environment: Record<string, string>;
174
+ connectionString: string;
175
+ started: boolean;
176
+ private db;
177
+ private templatePath;
178
+ private workerDbPath;
179
+ private initSql;
180
+ private prismaSchema;
181
+ constructor(options?: SqliteOptions);
182
+ buildConnectionString(): string;
183
+ createDatabaseAdapter(): DatabasePort;
184
+ healthcheck(): Promise<void>;
185
+ initialize(): Promise<void>;
186
+ private getDb;
187
+ private closeDb;
188
+ seed(sql: string): Promise<void>;
189
+ query(table: string, columns: string[]): Promise<unknown[][]>;
190
+ reset(): Promise<void>;
191
+ isolation(): IsolationStrategy;
192
+ }
193
+ /**
194
+ * Create a SQLite service handle. Uses file-copy isolation for parallel tests.
195
+ *
196
+ * @example
197
+ * // With Prisma schema
198
+ * const db = sqlite({ prismaSchema: './prisma/schema' });
199
+ *
200
+ * // With raw SQL init
201
+ * const db = sqlite({ init: './schema.sql' });
202
+ *
203
+ * // Empty database
204
+ * const db = sqlite();
205
+ */
206
+ declare function sqlite(options?: SqliteOptions): SqliteHandle;
207
+ //#endregion
208
+ export { PostgresOptions as a, IsolationStrategy as c, redis as i, DatabasePort as l, sqlite as n, postgres as o, RedisOptions as r, ServiceHandle as s, SqliteOptions as t };
209
+ //# sourceMappingURL=sqlite.adapter.d.cts.map
@@ -151,5 +151,59 @@ declare class RedisHandle implements ServiceHandle {
151
151
  */
152
152
  declare function redis(options?: RedisOptions): RedisHandle;
153
153
  //#endregion
154
- export { ServiceHandle as a, postgres as i, redis as n, IsolationStrategy as o, PostgresOptions as r, DatabasePort as s, RedisOptions as t };
155
- //# sourceMappingURL=redis.adapter.d.cts.map
154
+ //#region src/adapters/sqlite.adapter.d.ts
155
+ interface SqliteOptions {
156
+ /**
157
+ * Path to a SQL file used to initialize the database schema.
158
+ * Mutually exclusive with `prismaSchema`.
159
+ */
160
+ init?: string;
161
+ /**
162
+ * Path to a Prisma schema directory or file.
163
+ * The adapter runs `prisma db push` to create the template.
164
+ * Mutually exclusive with `init`.
165
+ */
166
+ prismaSchema?: string;
167
+ }
168
+ declare class SqliteHandle implements DatabasePort, ServiceHandle {
169
+ readonly type = "sqlite";
170
+ readonly composeName: null;
171
+ readonly defaultPort = 0;
172
+ readonly defaultImage = "";
173
+ readonly environment: Record<string, string>;
174
+ connectionString: string;
175
+ started: boolean;
176
+ private db;
177
+ private templatePath;
178
+ private workerDbPath;
179
+ private initSql;
180
+ private prismaSchema;
181
+ constructor(options?: SqliteOptions);
182
+ buildConnectionString(): string;
183
+ createDatabaseAdapter(): DatabasePort;
184
+ healthcheck(): Promise<void>;
185
+ initialize(): Promise<void>;
186
+ private getDb;
187
+ private closeDb;
188
+ seed(sql: string): Promise<void>;
189
+ query(table: string, columns: string[]): Promise<unknown[][]>;
190
+ reset(): Promise<void>;
191
+ isolation(): IsolationStrategy;
192
+ }
193
+ /**
194
+ * Create a SQLite service handle. Uses file-copy isolation for parallel tests.
195
+ *
196
+ * @example
197
+ * // With Prisma schema
198
+ * const db = sqlite({ prismaSchema: './prisma/schema' });
199
+ *
200
+ * // With raw SQL init
201
+ * const db = sqlite({ init: './schema.sql' });
202
+ *
203
+ * // Empty database
204
+ * const db = sqlite();
205
+ */
206
+ declare function sqlite(options?: SqliteOptions): SqliteHandle;
207
+ //#endregion
208
+ export { PostgresOptions as a, IsolationStrategy as c, redis as i, DatabasePort as l, sqlite as n, postgres as o, RedisOptions as r, ServiceHandle as s, SqliteOptions as t };
209
+ //# sourceMappingURL=sqlite.adapter.d.ts.map
@@ -1,6 +1,8 @@
1
- import { existsSync, readFileSync } from "node:fs";
1
+ import { copyFileSync, existsSync, readFileSync, unlinkSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
2
3
  import { resolve } from "node:path";
3
4
  import { Client } from "pg";
5
+ import Database from "better-sqlite3";
4
6
  //#region src/adapters/postgres.adapter.ts
5
7
  var PostgresHandle = class {
6
8
  type = "postgres";
@@ -197,6 +199,133 @@ function redis(options = {}) {
197
199
  return new RedisHandle(options);
198
200
  }
199
201
  //#endregion
200
- export { postgres as n, redis as t };
202
+ //#region src/adapters/sqlite.adapter.ts
203
+ var SqliteHandle = class {
204
+ type = "sqlite";
205
+ composeName = null;
206
+ defaultPort = 0;
207
+ defaultImage = "";
208
+ environment = {};
209
+ connectionString = "";
210
+ started = false;
211
+ db = null;
212
+ templatePath = "";
213
+ workerDbPath = "";
214
+ initSql;
215
+ prismaSchema;
216
+ constructor(options = {}) {
217
+ this.initSql = options.init ?? null;
218
+ this.prismaSchema = options.prismaSchema ?? null;
219
+ }
220
+ buildConnectionString() {
221
+ return `file:${this.workerDbPath || this.templatePath}`;
222
+ }
223
+ createDatabaseAdapter() {
224
+ return this;
225
+ }
226
+ async healthcheck() {}
227
+ async initialize() {
228
+ this.templatePath = resolve(tmpdir(), "jterrazz-test-sqlite-template.sqlite");
229
+ const lockPath = `${this.templatePath}.lock`;
230
+ if (existsSync(lockPath)) {
231
+ const start = Date.now();
232
+ while (existsSync(lockPath) && Date.now() - start < 3e4) await new Promise((r) => setTimeout(r, 100));
233
+ }
234
+ if (existsSync(this.templatePath)) {
235
+ this.connectionString = `file:${this.templatePath}`;
236
+ this.started = true;
237
+ return;
238
+ }
239
+ const { writeFileSync } = await import("node:fs");
240
+ writeFileSync(lockPath, process.pid.toString());
241
+ if (this.prismaSchema) {
242
+ const { execSync } = await import("node:child_process");
243
+ execSync("npx prisma db push --force-reset", {
244
+ env: {
245
+ ...process.env,
246
+ DATABASE_URL: `file:${this.templatePath}`,
247
+ PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION: "yes"
248
+ },
249
+ stdio: "pipe"
250
+ });
251
+ const tmpDb = new Database(this.templatePath);
252
+ tmpDb.pragma("wal_checkpoint(TRUNCATE)");
253
+ tmpDb.close();
254
+ } else if (this.initSql) {
255
+ const sql = readFileSync(this.initSql, "utf8");
256
+ const templateDb = new Database(this.templatePath);
257
+ templateDb.exec(sql);
258
+ templateDb.close();
259
+ } else new Database(this.templatePath).close();
260
+ try {
261
+ unlinkSync(lockPath);
262
+ } catch {}
263
+ this.connectionString = `file:${this.templatePath}`;
264
+ this.started = true;
265
+ }
266
+ getDb() {
267
+ const dbPath = this.workerDbPath || this.templatePath;
268
+ if (!this.db) {
269
+ this.db = new Database(dbPath);
270
+ this.db.pragma("journal_mode = WAL");
271
+ }
272
+ return this.db;
273
+ }
274
+ closeDb() {
275
+ if (this.db) {
276
+ this.db.close();
277
+ this.db = null;
278
+ }
279
+ }
280
+ async seed(sql) {
281
+ this.getDb().exec(sql);
282
+ }
283
+ async query(table, columns) {
284
+ const columnList = columns.join(", ");
285
+ return this.getDb().prepare(`SELECT ${columnList} FROM "${table}" ORDER BY 1`).all().map((row) => columns.map((col) => row[col]));
286
+ }
287
+ async reset() {
288
+ const db = this.getDb();
289
+ const tables = db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE '_prisma%' AND name != 'sqlite_sequence'`).all();
290
+ for (const { name } of tables) db.exec(`DELETE FROM "${name}"`);
291
+ }
292
+ isolation() {
293
+ return {
294
+ acquire: async (workerId) => {
295
+ this.closeDb();
296
+ this.workerDbPath = resolve(tmpdir(), `test-worker-${workerId}-${Date.now()}.sqlite`);
297
+ copyFileSync(this.templatePath, this.workerDbPath);
298
+ this.connectionString = `file:${this.workerDbPath}`;
299
+ },
300
+ reset: async () => {
301
+ await this.reset();
302
+ },
303
+ release: async () => {
304
+ this.closeDb();
305
+ if (this.workerDbPath && existsSync(this.workerDbPath)) unlinkSync(this.workerDbPath);
306
+ this.workerDbPath = "";
307
+ this.connectionString = `file:${this.templatePath}`;
308
+ }
309
+ };
310
+ }
311
+ };
312
+ /**
313
+ * Create a SQLite service handle. Uses file-copy isolation for parallel tests.
314
+ *
315
+ * @example
316
+ * // With Prisma schema
317
+ * const db = sqlite({ prismaSchema: './prisma/schema' });
318
+ *
319
+ * // With raw SQL init
320
+ * const db = sqlite({ init: './schema.sql' });
321
+ *
322
+ * // Empty database
323
+ * const db = sqlite();
324
+ */
325
+ function sqlite(options = {}) {
326
+ return new SqliteHandle(options);
327
+ }
328
+ //#endregion
329
+ export { redis as n, postgres as r, sqlite as t };
201
330
 
202
- //# sourceMappingURL=redis.adapter.js.map
331
+ //# sourceMappingURL=sqlite.adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite.adapter.js","names":[],"sources":["../src/adapters/postgres.adapter.ts","../src/adapters/redis.adapter.ts","../src/adapters/sqlite.adapter.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { Client } from 'pg';\n\nimport type { DatabasePort } from '../ports/database.port.js';\nimport type { IsolationStrategy } from '../ports/isolation.port.js';\nimport type { ServiceHandle } from '../ports/service.port.js';\n\nexport interface PostgresOptions {\n /** Map to a service in docker-compose.test.yaml. */\n compose?: string;\n /** Override image. */\n image?: string;\n /** Override environment variables. */\n env?: Record<string, string>;\n}\n\nexport class PostgresHandle implements DatabasePort, ServiceHandle {\n readonly type = 'postgres';\n readonly composeName: null | string;\n readonly defaultPort = 5432;\n readonly defaultImage: string;\n readonly environment: Record<string, string>;\n\n connectionString = '';\n started = false;\n\n private client: Client | null = null;\n private originalConnectionString = '';\n private schema = 'public';\n\n constructor(options: PostgresOptions = {}) {\n this.composeName = options.compose ?? null;\n this.defaultImage = options.image ?? 'postgres:17';\n this.environment = {\n POSTGRES_DB: 'test',\n POSTGRES_PASSWORD: 'test',\n POSTGRES_USER: 'test',\n ...options.env,\n };\n }\n\n buildConnectionString(host: string, port: number): string {\n const user = this.environment.POSTGRES_USER ?? 'test';\n const password = this.environment.POSTGRES_PASSWORD ?? 'test';\n const db = this.environment.POSTGRES_DB ?? 'test';\n return `postgresql://${user}:${password}@${host}:${port}/${db}`;\n }\n\n createDatabaseAdapter(): DatabasePort {\n return this;\n }\n\n async healthcheck(): Promise<void> {\n if (!this.connectionString) {\n throw new Error('postgres: cannot healthcheck — no connection string');\n }\n\n // Healthcheck uses a throwaway client (connection might not be established yet)\n try {\n const client = new Client({ connectionString: this.connectionString });\n await client.connect();\n await client.query('SELECT 1');\n await client.end();\n } catch (error: any) {\n throw new Error(\n `postgres healthcheck failed: ${error.message || error.code || String(error)}`,\n { cause: error },\n );\n }\n }\n\n async initialize(composeDir: string): Promise<void> {\n if (!this.composeName) {\n return;\n }\n\n const initPaths = [\n resolve(composeDir, `${this.composeName}/init.sql`),\n resolve(composeDir, 'postgres/init.sql'),\n ];\n\n for (const initPath of initPaths) {\n if (existsSync(initPath)) {\n const sql = readFileSync(initPath, 'utf8');\n try {\n await this.seed(sql);\n } catch (error: any) {\n throw new Error(\n `postgres init script failed (${initPath}):\\n${error.message}`,\n {\n cause: error,\n },\n );\n }\n return;\n }\n }\n }\n\n private async getClient(): Promise<Client> {\n if (this.client) {\n return this.client;\n }\n const client = new Client({ connectionString: this.connectionString });\n client.on('error', () => {\n // Connection dropped (container stopped) — reset so next call reconnects\n this.client = null;\n });\n await client.connect();\n this.client = client;\n return client;\n }\n\n async seed(sql: string): Promise<void> {\n const client = await this.getClient();\n await client.query(sql);\n }\n\n async reset(): Promise<void> {\n const client = await this.getClient();\n const result = await client.query(`\n SELECT tablename FROM pg_tables\n WHERE schemaname = '${this.schema}'\n AND tablename NOT LIKE '_prisma%'\n `);\n for (const row of result.rows) {\n await client.query(`TRUNCATE \"${this.schema}\".\"${row.tablename}\" CASCADE`);\n }\n }\n\n async query(table: string, columns: string[]): Promise<unknown[][]> {\n const client = await this.getClient();\n const columnList = columns.join(', ');\n const result = await client.query(\n `SELECT ${columnList} FROM \"${this.schema}\".\"${table}\" ORDER BY 1`,\n );\n return result.rows.map((row: Record<string, unknown>) => columns.map((col) => row[col]));\n }\n\n isolation(): IsolationStrategy {\n return {\n acquire: async (workerId: string) => {\n const workerSchema = `worker_${workerId}`;\n this.originalConnectionString = this.connectionString;\n const client = await this.getClient();\n\n // Create schema by cloning all tables from public\n await client.query(`DROP SCHEMA IF EXISTS \"${workerSchema}\" CASCADE`);\n await client.query(`CREATE SCHEMA \"${workerSchema}\"`);\n\n // Copy table structures (no data) from public\n const tables = await client.query(`\n SELECT tablename FROM pg_tables\n WHERE schemaname = 'public'\n AND tablename NOT LIKE '_prisma%'\n `);\n for (const row of tables.rows) {\n await client.query(\n `CREATE TABLE \"${workerSchema}\".\"${row.tablename}\" (LIKE \"public\".\"${row.tablename}\" INCLUDING ALL)`,\n );\n }\n\n // Switch this handle to use the worker schema\n this.schema = workerSchema;\n await client.query(`SET search_path TO \"${workerSchema}\", public`);\n\n // Update connectionString so app connections also use the worker schema\n const url = new URL(this.connectionString);\n url.searchParams.set('options', `-c search_path=${workerSchema},public`);\n this.connectionString = url.toString();\n },\n\n reset: async () => {\n await this.reset();\n },\n\n release: async () => {\n const client = await this.getClient();\n const workerSchema = this.schema;\n this.schema = 'public';\n this.connectionString = this.originalConnectionString;\n await client.query(`SET search_path TO public`);\n await client.query(`DROP SCHEMA IF EXISTS \"${workerSchema}\" CASCADE`);\n },\n };\n }\n}\n\n/**\n * Create a PostgreSQL service handle.\n *\n * @example\n * const db = postgres({ compose: \"db\" });\n * // After start: db.connectionString is populated\n */\nexport function postgres(options: PostgresOptions = {}): PostgresHandle {\n return new PostgresHandle(options);\n}\n","import type { DatabasePort } from '../ports/database.port.js';\nimport type { IsolationStrategy } from '../ports/isolation.port.js';\nimport type { ServiceHandle } from '../ports/service.port.js';\n\nexport interface RedisOptions {\n /** Map to a service in docker-compose.test.yaml. */\n compose?: string;\n /** Override image. */\n image?: string;\n}\n\nexport class RedisHandle implements ServiceHandle {\n readonly type = 'redis';\n readonly composeName: null | string;\n readonly defaultPort = 6379;\n readonly defaultImage: string;\n readonly environment: Record<string, string> = {};\n\n connectionString = '';\n started = false;\n\n private dbIndex = 0;\n\n constructor(options: RedisOptions = {}) {\n this.composeName = options.compose ?? null;\n this.defaultImage = options.image ?? 'redis:7';\n }\n\n buildConnectionString(host: string, port: number): string {\n return `redis://${host}:${port}`;\n }\n\n createDatabaseAdapter(): DatabasePort | null {\n return null;\n }\n\n async healthcheck(): Promise<void> {\n if (!this.connectionString) {\n throw new Error('redis: cannot healthcheck — no connection string');\n }\n\n try {\n const { createClient } = await import('redis');\n const client = createClient({ url: this.connectionString });\n await client.connect();\n await client.ping();\n await client.disconnect();\n } catch (error: any) {\n throw new Error(\n `redis healthcheck failed: ${error.message || error.code || String(error)}`,\n {\n cause: error,\n },\n );\n }\n }\n\n async initialize(): Promise<void> {\n // Redis doesn't need initialization scripts\n }\n\n async reset(): Promise<void> {\n const { createClient } = await import('redis');\n const client = createClient({ url: this.connectionString, database: this.dbIndex });\n await client.connect();\n try {\n await client.flushDb();\n } finally {\n await client.disconnect();\n }\n }\n\n isolation(): IsolationStrategy {\n return {\n acquire: async (workerId: string) => {\n // Use Redis database index 1-15 for workers (0 is default/shared)\n const numericId = Number.parseInt(workerId, 10) || 0;\n this.dbIndex = (numericId % 15) + 1;\n },\n\n reset: async () => {\n await this.reset();\n },\n\n release: async () => {\n await this.reset();\n this.dbIndex = 0;\n },\n };\n }\n}\n\n/**\n * Create a Redis service handle.\n *\n * @example\n * const cache = redis({ compose: \"cache\" });\n * // After start: cache.connectionString is populated\n */\nexport function redis(options: RedisOptions = {}): RedisHandle {\n return new RedisHandle(options);\n}\n","import Database from 'better-sqlite3';\nimport { copyFileSync, existsSync, readFileSync, unlinkSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { resolve } from 'node:path';\n\nimport type { DatabasePort } from '../ports/database.port.js';\nimport type { IsolationStrategy } from '../ports/isolation.port.js';\nimport type { ServiceHandle } from '../ports/service.port.js';\n\nexport interface SqliteOptions {\n /**\n * Path to a SQL file used to initialize the database schema.\n * Mutually exclusive with `prismaSchema`.\n */\n init?: string;\n /**\n * Path to a Prisma schema directory or file.\n * The adapter runs `prisma db push` to create the template.\n * Mutually exclusive with `init`.\n */\n prismaSchema?: string;\n}\n\nexport class SqliteHandle implements DatabasePort, ServiceHandle {\n readonly type = 'sqlite';\n readonly composeName = null;\n readonly defaultPort = 0;\n readonly defaultImage = '';\n readonly environment: Record<string, string> = {};\n\n connectionString = '';\n started = false;\n\n private db: Database.Database | null = null;\n private templatePath = '';\n private workerDbPath = '';\n private initSql: null | string;\n private prismaSchema: null | string;\n\n constructor(options: SqliteOptions = {}) {\n this.initSql = options.init ?? null;\n this.prismaSchema = options.prismaSchema ?? null;\n }\n\n buildConnectionString(): string {\n return `file:${this.workerDbPath || this.templatePath}`;\n }\n\n createDatabaseAdapter(): DatabasePort {\n return this;\n }\n\n async healthcheck(): Promise<void> {\n // SQLite is always ready — it's a file\n }\n\n async initialize(): Promise<void> {\n // Each test run gets a fresh template; workers share it via lock\n this.templatePath = resolve(tmpdir(), 'jterrazz-test-sqlite-template.sqlite');\n const lockPath = `${this.templatePath}.lock`;\n\n if (existsSync(lockPath)) {\n // Another worker is creating it — wait for it\n const start = Date.now();\n while (existsSync(lockPath) && Date.now() - start < 30_000) {\n await new Promise((r) => setTimeout(r, 100));\n }\n }\n\n if (existsSync(this.templatePath)) {\n this.connectionString = `file:${this.templatePath}`;\n this.started = true;\n return;\n }\n\n // Acquire lock\n const { writeFileSync } = await import('node:fs');\n writeFileSync(lockPath, process.pid.toString());\n\n if (this.prismaSchema) {\n // Use Prisma to create schema\n const { execSync } = await import('node:child_process');\n execSync('npx prisma db push --force-reset', {\n env: {\n ...process.env,\n DATABASE_URL: `file:${this.templatePath}`,\n PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION: 'yes',\n },\n stdio: 'pipe',\n });\n\n // Checkpoint WAL so the template is a single file (safe to copy)\n const tmpDb = new Database(this.templatePath);\n tmpDb.pragma('wal_checkpoint(TRUNCATE)');\n tmpDb.close();\n } else if (this.initSql) {\n // Use raw SQL to create schema\n const sql = readFileSync(this.initSql, 'utf8');\n const templateDb = new Database(this.templatePath);\n templateDb.exec(sql);\n templateDb.close();\n } else {\n // Empty database — consumer will seed\n const templateDb = new Database(this.templatePath);\n templateDb.close();\n }\n\n // Release lock\n try {\n unlinkSync(lockPath);\n } catch {\n /* Ignore */\n }\n\n this.connectionString = `file:${this.templatePath}`;\n this.started = true;\n }\n\n private getDb(): Database.Database {\n const dbPath = this.workerDbPath || this.templatePath;\n if (!this.db) {\n this.db = new Database(dbPath);\n this.db.pragma('journal_mode = WAL');\n }\n return this.db;\n }\n\n private closeDb(): void {\n if (this.db) {\n this.db.close();\n this.db = null;\n }\n }\n\n async seed(sql: string): Promise<void> {\n this.getDb().exec(sql);\n }\n\n async query(table: string, columns: string[]): Promise<unknown[][]> {\n const columnList = columns.join(', ');\n const rows = this.getDb()\n .prepare(`SELECT ${columnList} FROM \"${table}\" ORDER BY 1`)\n .all() as Record<string, unknown>[];\n return rows.map((row) => columns.map((col) => row[col]));\n }\n\n async reset(): Promise<void> {\n const db = this.getDb();\n const tables = db\n .prepare(\n `SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE '_prisma%' AND name != 'sqlite_sequence'`,\n )\n .all() as { name: string }[];\n for (const { name } of tables) {\n db.exec(`DELETE FROM \"${name}\"`);\n }\n }\n\n isolation(): IsolationStrategy {\n return {\n acquire: async (workerId: string) => {\n this.closeDb();\n this.workerDbPath = resolve(\n tmpdir(),\n `test-worker-${workerId}-${Date.now()}.sqlite`,\n );\n copyFileSync(this.templatePath, this.workerDbPath);\n this.connectionString = `file:${this.workerDbPath}`;\n },\n\n reset: async () => {\n await this.reset();\n },\n\n release: async () => {\n this.closeDb();\n if (this.workerDbPath && existsSync(this.workerDbPath)) {\n unlinkSync(this.workerDbPath);\n }\n this.workerDbPath = '';\n this.connectionString = `file:${this.templatePath}`;\n },\n };\n }\n}\n\n/**\n * Create a SQLite service handle. Uses file-copy isolation for parallel tests.\n *\n * @example\n * // With Prisma schema\n * const db = sqlite({ prismaSchema: './prisma/schema' });\n *\n * // With raw SQL init\n * const db = sqlite({ init: './schema.sql' });\n *\n * // Empty database\n * const db = sqlite();\n */\nexport function sqlite(options: SqliteOptions = {}): SqliteHandle {\n return new SqliteHandle(options);\n}\n"],"mappings":";;;;;;AAiBA,IAAa,iBAAb,MAAmE;CAC/D,OAAgB;CAChB;CACA,cAAuB;CACvB;CACA;CAEA,mBAAmB;CACnB,UAAU;CAEV,SAAgC;CAChC,2BAAmC;CACnC,SAAiB;CAEjB,YAAY,UAA2B,EAAE,EAAE;AACvC,OAAK,cAAc,QAAQ,WAAW;AACtC,OAAK,eAAe,QAAQ,SAAS;AACrC,OAAK,cAAc;GACf,aAAa;GACb,mBAAmB;GACnB,eAAe;GACf,GAAG,QAAQ;GACd;;CAGL,sBAAsB,MAAc,MAAsB;AAItD,SAAO,gBAHM,KAAK,YAAY,iBAAiB,OAGnB,GAFX,KAAK,YAAY,qBAAqB,OAEf,GAAG,KAAK,GAAG,KAAK,GAD7C,KAAK,YAAY,eAAe;;CAI/C,wBAAsC;AAClC,SAAO;;CAGX,MAAM,cAA6B;AAC/B,MAAI,CAAC,KAAK,iBACN,OAAM,IAAI,MAAM,sDAAsD;AAI1E,MAAI;GACA,M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@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jterrazz/test",
3
- "version": "6.0.0",
3
+ "version": "6.2.0",
4
4
  "author": "Jean-Baptiste Terrazzoni <contact@jterrazz.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,6 +35,7 @@
35
35
  "test": "vitest --run"
36
36
  },
37
37
  "dependencies": {
38
+ "better-sqlite3": "^12.9.0",
38
39
  "mockdate": "^3.0.5",
39
40
  "pg": "^8.20.0",
40
41
  "redis": "^5.11.0",
@@ -46,6 +47,7 @@
46
47
  "@hono/node-server": "^1.19.11",
47
48
  "@jterrazz/codestyle": "^3.3.0",
48
49
  "@jterrazz/typescript": "^5.3.0",
50
+ "@types/better-sqlite3": "^7.6.13",
49
51
  "@types/node": "^25.5.0",
50
52
  "@types/pg": "^8.20.0",
51
53
  "hono": "^4.12.9",