feat(deps): @faker-js/faker wide-synthetic seed for load testing

New seed harness for stress-testing list pages, search, analytics
under realistic volumes. Faker-driven, deterministic via fixed
seed, idempotent via `clients.source_details = 'wide-synthetic'`
marker.

- `src/lib/db/seed-wide-synthetic-data.ts` — generator (1000 clients
  default, override via `WIDE_SEED_COUNT`)
- `src/lib/db/seed-wide-synthetic.ts` — entrypoint
- `pnpm db:seed:wide-synthetic` script

Distribution:
- 70% of clients get an interest (spread across pipeline stages)
- ~50% of those interests link to a real berth
- Acquisition source weighted: 55% website / 25% referral /
  15% broker / 5% manual
- Locale-aware names/emails/phones/addresses via faker

Curated synthetic seed (`seed-synthetic-data.ts`) and realistic
seed (`seed-data.ts`) are untouched — this is a third axis for
volume testing, not a replacement.

Verified: tsc clean, build green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-12 22:43:59 +02:00
parent 92975e6bf5
commit dda554df84
4 changed files with 289 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
/**
* Wide synthetic seed entrypoint.
*
* Bootstraps ports + roles + super-admin profile (idempotent), then
* generates faker-driven bulk client + interest rows per port. Default
* 1000 clients/port; override via `WIDE_SEED_COUNT`.
*
* Run with: pnpm db:seed:wide-synthetic
*/
import 'dotenv/config';
import { seedBootstrap } from './seed-bootstrap';
import { seedWideSyntheticPortData, type WideSeedSummary } from './seed-wide-synthetic-data';
const DEFAULT_COUNT = 1000;
async function seed() {
const target = Number(process.env.WIDE_SEED_COUNT ?? DEFAULT_COUNT);
if (!Number.isFinite(target) || target < 1) {
console.error(`Invalid WIDE_SEED_COUNT: ${process.env.WIDE_SEED_COUNT}`);
process.exit(1);
}
console.log(`Seeding Port Nimara CRM (wide synthetic — ${target} clients/port)...`);
const portIds = await seedBootstrap();
console.log('');
console.log('Seeding per-port wide synthetic data...');
const summaries: Array<{ name: string; summary: WideSeedSummary | null }> = [];
for (const p of portIds) {
console.log(` [${p.slug}] seeding ${target} synthetic clients...`);
const summary = await seedWideSyntheticPortData(p.id, p.slug, target);
summaries.push({ name: p.name, summary });
}
console.log('');
console.log('─── Summary ───────────────────────────────────────────────');
for (const s of summaries) {
if (s.summary === null) {
console.log(` ✓ Port "${s.name}" - already at target count (skipped)`);
} else {
const x = s.summary;
console.log(` ✓ Port "${s.name}" - +${x.clients} clients, +${x.interests} interests`);
}
}
console.log('');
console.log('Wide synthetic seed complete!');
process.exit(0);
}
seed().catch((err) => {
console.error('Wide synthetic seed failed:', err);
process.exit(1);
});