1/** 2 * AI Software Factory — read the `seed-100k-v1` marker (written by 3 * seed-100k.mjs into the `test_seeds` table) and print shell-exportable env 4 * lines for the TASK-0135 k6 suites: 5 * 6 * K6_WORKSPACE_ID the seeded workspace (api-load / database-load / realtime) 7 * K6_DB_ID the primary database id (database-load target) 8 * K6_DATABASE_IDS all database ids (api-load record-list scenario) 9 * K6_BIG_PAGE_ID the big-block page (api-load open scenario) 10 * K6_PAGE_IDS comma-joined hub page ids (api-load tree/list scenarios) 11 * 12 * Usage (CI): source <(node tests/performance/extract-100k-env.mjs) 13 * Usage (test): node tests/performance/extract-100k-env.mjs # prints the lines 14 * 15 * Exits 1 with a clear error if the marker is absent (run seed-100k.mjs first). 16 * Needs DATABASE_URL (the repo's Prisma client is generated by `pnpm db:generate`). 17 */ 18import { PrismaClient } from "@prisma/client"; 19 20const MARKER = "seed-100k-v1"; 21const prisma = new PrismaClient(); 22 23try { 24 const rows = await prisma.$queryRaw`SELECT value FROM test_seeds WHERE key = ${MARKER}`; 25 if (rows.length === 0) { 26 console.error(`extract-100k-env: marker ${MARKER} not found in test_seeds — run seed-100k.mjs first.`); 27 process.exit(1); 28 } 29 const m = rows[0].value; 30 // `export K6_...=` so a `source <(...)` picks each up; values are single- 31 // quoted (the ids are cuids / db_* / pg_* — no embedded quotes, but be safe). 32 const q = (s) => `'${String(s).replace(/'/g, `'\''`)}'`; 33 console.log(`export K6_WORKSPACE_ID=${q(m.workspaceId)}`); 34 console.log(`export K6_DB_ID=${q(m.databaseId)}`); 35 console.log(`export K6_DATABASE_IDS=${q((m.databaseIds || []).join(","))}`); 36 console.log(`export K6_BIG_PAGE_ID=${q(m.bigPageId)}`); 37 console.log(`export K6_PAGE_IDS=${q((m.pageIds || []).join(","))}`); 38 console.error(`extract-100k-env: workspace=${m.workspaceId} db=${m.databaseId} pages=${(m.pageIds || []).length} records=${m.records}`); 39} finally { 40 await prisma.$disconnect(); 41} 42