{
  "description": "Historical source snapshot for recording.json. Text data only; use examples/sqlite for the maintained runnable fixture.",
  "files": [
    {
      "path": "examples/sqlite/batch.test.ts",
      "sha256": "bf2c55f63339cc4837532c067614adb81998741a3376ce9e8d62d43bf4db4f57",
      "text": "import assert from 'node:assert/strict'\nimport { test } from 'node:test'\nimport { createDatabase, importContacts } from './batch.ts'\n\ntest('commits the whole valid batch and binds a quote as data', async () => {\n  const db = await createDatabase()\n  try {\n    const contacts = [{ id: 1, name: \"O'Reilly\" }, { id: 2, name: \"Robert'); DROP TABLE contact;--\" }]\n    const compiled = db.insertInto('contact').values(contacts[0]!).compile()\n    assert.equal(compiled.sql, 'insert into \"contact\" (\"id\", \"name\") values (?, ?)')\n    assert.deepEqual(compiled.parameters, [1, \"O'Reilly\"])\n    await importContacts(db, contacts)\n    assert.deepEqual(await db.selectFrom('contact').selectAll().orderBy('id').execute(), contacts)\n    console.log(JSON.stringify({ assertion: 'parameter binding and exact round trip', sql: compiled.sql, parameters: compiled.parameters, rows: contacts }))\n  } finally {\n    await db.destroy()\n  }\n})\n\ntest('UNIQUE failure rolls back an earlier insert in the same batch', async () => {\n  const db = await createDatabase()\n  try {\n    await importContacts(db, [{ id: 1, name: 'existing' }])\n    await assert.rejects(importContacts(db, [{ id: 2, name: 'must roll back' }, { id: 3, name: 'existing' }]), { code: 'SQLITE_CONSTRAINT_UNIQUE' })\n    const rows = await db.selectFrom('contact').selectAll().execute()\n    assert.deepEqual(rows, [{ id: 1, name: 'existing' }])\n    console.log(JSON.stringify({ assertion: 'whole batch rollback', rejectedCode: 'SQLITE_CONSTRAINT_UNIQUE', rows }))\n  } finally {\n    await db.destroy()\n  }\n})\n"
    },
    {
      "path": "examples/sqlite/batch.ts",
      "sha256": "8bfb1ac28ce119657e830a7ff40a3ec2416febfde06641deebbccab2cb2d7ec6",
      "text": "import Database from 'better-sqlite3'\nimport { Kysely, SqliteDialect } from 'kysely'\n\nexport interface Contact {\n  id: number\n  name: string\n}\n\ninterface Tables {\n  contact: Contact\n}\n\nexport async function createDatabase() {\n  const db = new Kysely<Tables>({\n    dialect: new SqliteDialect({ database: new Database(':memory:') })\n  })\n  await db.schema.createTable('contact')\n    .addColumn('id', 'integer', column => column.primaryKey())\n    .addColumn('name', 'text', column => column.notNull().unique())\n    .execute()\n  return db\n}\n\nexport async function importContacts(db: Kysely<Tables>, contacts: Contact[]) {\n  // Let rejection escape the callback so Kysely rolls back the whole batch.\n  await db.transaction().execute(async transaction => {\n    for (const contact of contacts) {\n      await transaction.insertInto('contact').values(contact).execute()\n    }\n  })\n}\n"
    },
    {
      "path": "examples/sqlite/negative.test.ts",
      "sha256": "fcf79edb49e5a475f24c85bf22b1067bec2f668d995a8cecba0c36068136fcdd",
      "text": "import assert from 'node:assert/strict'\nimport { test } from 'node:test'\nimport { createDatabase } from './batch.ts'\n\ntest('negative control: omitting the transaction must fail the atomicity assertion', async () => {\n  const db = await createDatabase()\n  try {\n    await db.insertInto('contact').values({ id: 1, name: 'existing' }).execute()\n    await assert.rejects(async () => {\n      for (const row of [{ id: 2, name: 'must roll back' }, { id: 3, name: 'existing' }]) {\n        await db.insertInto('contact').values(row).execute()\n      }\n    }, { code: 'SQLITE_CONSTRAINT_UNIQUE' })\n    // This intentionally fails: without a transaction, id 2 remains committed.\n    assert.deepEqual(await db.selectFrom('contact').selectAll().orderBy('id').execute(), [{ id: 1, name: 'existing' }])\n  } finally {\n    await db.destroy()\n  }\n})\n"
    },
    {
      "path": "examples/sqlite/package-lock.json",
      "sha256": "fd72ebe91147cd1160207a2b5d887b0d5380a5bd21024defba61a1a4600020ca",
      "text": "{\n  \"name\": \"typelatch-sqlite-showcase\",\n  \"lockfileVersion\": 3,\n  \"requires\": true,\n  \"packages\": {\n    \"\": {\n      \"name\": \"typelatch-sqlite-showcase\",\n      \"dependencies\": {\n        \"better-sqlite3\": \"13.0.3\",\n        \"kysely\": \"0.28.8\"\n      },\n      \"devDependencies\": {\n        \"@types/better-sqlite3\": \"9.6.0\",\n        \"@types/node\": \"22.20.1\",\n        \"typescript\": \"6.0.3\"\n      },\n      \"engines\": {\n        \"node\": \">=22.12.0\"\n      }\n    },\n    \"node_modules/@types/better-sqlite3\": {\n      \"version\": \"9.6.0\",\n      \"resolved\": \"https://registry.npmjs.org/@types/better-sqlite3/-/better-sqlite3-9.6.0.tgz\",\n      \"integrity\": \"sha512-ZEEwBSgMu7GYJOynoagg5X9JbxfL6dTJDsgViJIqh67jV44kyOr9RXfmFjLK5rzC4MWssP06t9hu/JwGDnUbCg==\",\n      \"dev\": true,\n      \"license\": \"MIT\",\n      \"dependencies\": {\n        \"@types/node\": \"*\"\n      }\n    },\n    \"node_modules/@types/node\": {\n      \"version\": \"22.20.1\",\n      \"resolved\": \"https://registry.npmjs.org/@types/node/-/node-22.20.1.tgz\",\n      \"integrity\": \"sha512-EANqOCF9QFyra+4pfxUcX9STKJpCLjMbObVzljIJomAWSnuSIEAvyzEU53GaajbXJEgdh0iEcPL+DGvpUd4k1Q==\",\n      \"dev\": true,\n      \"license\": \"MIT\",\n      \"dependencies\": {\n        \"undici-types\": \"~6.21.0\"\n      }\n    },\n    \"node_modules/better-sqlite3\": {\n      \"version\": \"13.0.3\",\n      \"resolved\": \"https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-13.0.3.tgz\",\n      \"integrity\": \"sha512-RbOBxmLBG8uvFUc15X9+9SFemKcQ0WBuISBVkpuiaUB2qblC8UWlHEjdWVoZ8AdhSwmoEgsiXKfopX0CQxaACQ==\",\n      \"license\": \"MIT\",\n      \"dependencies\": {\n        \"node-addon-api\": \"^8.0.0\"\n      },\n      \"engines\": {\n        \"node\": \">=22\"\n      }\n    },\n    \"node_modules/kysely\": {\n      \"version\": \"0.28.8\",\n      \"resolved\": \"https://registry.npmjs.org/kysely/-/kysely-0.28.8.tgz\",\n      \"integrity\": \"sha512-QUOgl5ZrS9IRuhq5FvOKFSsD/3+IA6MLE81/bOOTRA/YQpKDza2sFdN5g6JCB9BOpqMJDGefLCQ9F12hRS13TA==\",\n      \"license\": \"MIT\",\n      \"engines\": {\n        \"node\": \">=20.0.0\"\n      }\n    },\n    \"node_modules/node-addon-api\": {\n      \"version\": \"8.9.2\",\n      \"resolved\": \"https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.9.2.tgz\",\n      \"integrity\": \"sha512-VijLXbi3UACN69I0JVXJsX4tjACjNoQDgv2gTF6sx2wWEi8tkSg2eX8p5gSIFi8z2+DL3oHmY6OyKce38SDolg==\",\n      \"license\": \"MIT\",\n      \"engines\": {\n        \"node\": \"^18 || ^20 || >= 21\"\n      }\n    },\n    \"node_modules/typescript\": {\n      \"version\": \"6.0.3\",\n      \"resolved\": \"https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz\",\n      \"integrity\": \"sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==\",\n      \"dev\": true,\n      \"license\": \"Apache-2.0\",\n      \"bin\": {\n        \"tsc\": \"bin/tsc\",\n        \"tsserver\": \"bin/tsserver\"\n      },\n      \"engines\": {\n        \"node\": \">=14.17\"\n      }\n    },\n    \"node_modules/undici-types\": {\n      \"version\": \"6.21.0\",\n      \"resolved\": \"https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz\",\n      \"integrity\": \"sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==\",\n      \"dev\": true,\n      \"license\": \"MIT\"\n    }\n  }\n}\n"
    },
    {
      "path": "examples/sqlite/package.json",
      "sha256": "71d6569283303c5c85e24fddaada80747b27b3d768c7239f36c2b3233c45ec0c",
      "text": "{\n  \"name\": \"typelatch-sqlite-showcase\",\n  \"private\": true,\n  \"type\": \"module\",\n  \"scripts\": {\n    \"check\": \"tsc --noEmit\",\n    \"test\": \"node --experimental-strip-types --test --test-reporter=tap batch.test.ts\",\n    \"test:negative\": \"node --experimental-strip-types --test --test-reporter=tap negative.test.ts\"\n  },\n  \"dependencies\": {\n    \"better-sqlite3\": \"13.0.3\",\n    \"kysely\": \"0.28.8\"\n  },\n  \"devDependencies\": {\n    \"@types/better-sqlite3\": \"9.6.0\",\n    \"@types/node\": \"22.20.1\",\n    \"typescript\": \"6.0.3\"\n  },\n  \"engines\": { \"node\": \">=22.12.0\" }\n}\n"
    },
    {
      "path": "examples/sqlite/tsconfig.json",
      "sha256": "6c7b4b9adf7dbcf5f27c46e049499c54f8e17093da117615cd7217be8b03f403",
      "text": "{\n  \"compilerOptions\": {\n    \"target\": \"ES2022\",\n    \"module\": \"NodeNext\",\n    \"moduleResolution\": \"NodeNext\",\n    \"strict\": true,\n    \"noEmit\": true,\n    \"allowImportingTsExtensions\": true,\n    \"types\": [\"node\"]\n  },\n  \"include\": [\"*.ts\"]\n}\n"
    }
  ]
}
