{"version":3,"file":"test-fixtures.mjs","sources":["../../../@hive/sdk/dist/test-fixtures.mjs"],"sourcesContent":["import { SQLITE_FIXTURE } from \"./_chunks/sqlite-CArRic-y.mjs\";\nimport { Database } from \"bun:sqlite\";\nimport { readFile, unlink } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\n\n//#region src/test-fixtures.ts\n/**\n* Cached compacted SQLite fixture.\n* Generated once per test run to match the current SQLite version.\n*/\nlet COMPACTED_FIXTURE_CACHE = null;\n/**\n* Generates a compacted (VACUUMed) SQLite database fixture at runtime.\n* This ensures the fixture matches the SQLite version being tested,\n* avoiding version-specific byte differences in test assertions.\n*\n* The result is cached in memory for the duration of the test run.\n*\n* **Note:** This function currently requires the Bun runtime.\n*\n* @returns A Promise resolving to the compacted database as a Uint8Array.\n*/\nconst getCompactedFixture = async () => {\n\tif (COMPACTED_FIXTURE_CACHE) return COMPACTED_FIXTURE_CACHE;\n\tconst db = Database.deserialize(SQLITE_FIXTURE);\n\tconst tmpPath = resolve(\".test\", `compacted-fixture-${crypto.randomUUID()}.db`);\n\ttry {\n\t\tdb.run(\"VACUUM INTO ?;\", [tmpPath]);\n\t\tdb.close();\n\t\tconst compacted = await readFile(tmpPath);\n\t\tCOMPACTED_FIXTURE_CACHE = new Uint8Array(compacted);\n\t\tawait unlink(tmpPath).catch(() => {});\n\t\treturn COMPACTED_FIXTURE_CACHE;\n\t} catch (error) {\n\t\tdb.close();\n\t\tawait unlink(tmpPath).catch(() => {});\n\t\tthrow error;\n\t}\n};\n\n//#endregion\nexport { getCompactedFixture };"],"names":[],"mappings":";;;;;AAUA,IAAI,uBAAA,GAA0B,IAAA;AAY9B,MAAM,sBAAsB,YAAY;AACvC,EAAA,IAAI,yBAAyB,OAAO,uBAAA;AACpC,EAAA,MAAM,EAAA,GAAK,QAAA,CAAS,WAAA,CAAY,cAAc,CAAA;AAC9C,EAAA,MAAM,UAAU,OAAA,CAAQ,OAAA,EAAS,qBAAqB,MAAA,CAAO,UAAA,EAAY,CAAA,GAAA,CAAK,CAAA;AAC9E,EAAA,IAAI;AACH,IAAA,EAAA,CAAG,GAAA,CAAI,gBAAA,EAAkB,CAAC,OAAO,CAAC,CAAA;AAClC,IAAA,EAAA,CAAG,KAAA,EAAM;AACT,IAAA,MAAM,SAAA,GAAY,MAAM,QAAA,CAAS,OAAO,CAAA;AACxC,IAAA,uBAAA,GAA0B,IAAI,WAAW,SAAS,CAAA;AAClD,IAAA,MAAM,MAAA,CAAO,OAAO,CAAA,CAAE,KAAA,CAAM,MAAM;AAAA,IAAC,CAAC,CAAA;AACpC,IAAA,OAAO,uBAAA;AAAA,EACR,SAAS,KAAA,EAAO;AACf,IAAA,EAAA,CAAG,KAAA,EAAM;AACT,IAAA,MAAM,MAAA,CAAO,OAAO,CAAA,CAAE,KAAA,CAAM,MAAM;AAAA,IAAC,CAAC,CAAA;AACpC,IAAA,MAAM,KAAA;AAAA,EACP;AACD;;;;"}