From d87363d452b07a6e5fbd815e47045b6d554e7d3f Mon Sep 17 00:00:00 2001 From: Claude Code Date: Fri, 20 Mar 2026 03:21:09 -0700 Subject: [PATCH] =?UTF-8?q?feat(platform-seed):=20=E2=9C=A8=20Add=20seed?= =?UTF-8?q?=20data=20generator=20with=20authentication,=20analytics,=20and?= =?UTF-8?q?=20transaction=20phase=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- .../platform-seed/bin/generate-dev-data.ts | 39 +------------------ features/platform-seed/src/lib/auth.ts | 4 +- features/platform-seed/src/lib/rng.ts | 4 +- .../src/phases/phase5-analytics.ts | 2 +- .../src/phases/phase6-transactions.ts | 4 +- 5 files changed, 9 insertions(+), 44 deletions(-) diff --git a/features/platform-seed/bin/generate-dev-data.ts b/features/platform-seed/bin/generate-dev-data.ts index 670a8ae19..4ea0686ab 100644 --- a/features/platform-seed/bin/generate-dev-data.ts +++ b/features/platform-seed/bin/generate-dev-data.ts @@ -27,7 +27,7 @@ import { pullAttrs } from '../src/sync/pull-attrs' import { pushAttrs } from '../src/sync/push-attrs' import { diffAttrs } from '../src/sync/diff-attrs' import { - withDb, ANALYTICS_DB, SSO_DB, MESSAGING_DB, REVIEWS_DB, + withDb, ANALYTICS_DB, MESSAGING_DB, REVIEWS_DB, PAYMENTS_DB, STREAMING_DB, MERCHANT_DB, MARKETPLACE_DB, FEATURE_FLAGS_DB, TRUST_DB, } from '../src/lib/db' @@ -226,41 +226,6 @@ async function runReset(): Promise { log(' Note: SSO users, profiles, and attributes are NOT reset (use their respective admin tools)') } -async function resolveContext(requiredPhases: string[]): Promise { - const ctx: SeedContext = { - providerUsers: [], - clientUsers: [], - adminUsers: [], - profiles: [], - } - - const needed = new Set(requiredPhases) - - if (needed.has('1') || needed.has('3') || needed.has('5') || needed.has('7')) { - log(' Loading provider users (phase 1 dependency)...') - ctx.providerUsers = await phase1SsoUsers() - } - - if (needed.has('1b')) { - log(' Loading client users (phase 1b dependency)...') - ctx.clientUsers = await phase1bSsoClients() - } - - if (needed.has('1c')) { - log(' Loading admin users (phase 1c dependency)...') - ctx.adminUsers = await phase1cSsoAdmins() - } - - if (needed.has('3') || needed.has('5') || needed.has('7')) { - if (ctx.providerUsers.length > 0) { - log(' Loading profiles (phase 3 dependency)...') - ctx.profiles = await phase3Profiles(ctx.providerUsers) - } - } - - return ctx -} - async function runPhase(phase: string, ctx: SeedContext): Promise { switch (phase) { case '1': @@ -400,7 +365,7 @@ async function main(): Promise { return } - if (values.phase) { + if (typeof values.phase === 'string') { const phase = values.phase // Validate phase diff --git a/features/platform-seed/src/lib/auth.ts b/features/platform-seed/src/lib/auth.ts index 7982b24a3..2de640843 100644 --- a/features/platform-seed/src/lib/auth.ts +++ b/features/platform-seed/src/lib/auth.ts @@ -38,7 +38,7 @@ export async function registerUser(data: { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data), }) - const body = await res.json() + const body = await res.json() as { message?: string; user?: SsoUser; sessionId?: string } if (!res.ok) { return { success: false, error: body.message ?? `HTTP ${res.status}` } } @@ -56,7 +56,7 @@ export async function loginUser(email: string, password: string): Promise(arr: readonly T[]): T { return arr[Math.floor(this.next() * arr.length)] }, - weighted(items: ReadonlyArray<{ val: T; w: number }>): T { + weighted(items: ReadonlyArray<{ readonly val: T; readonly w: number }>): T { const total = items.reduce((sum, i) => sum + i.w, 0) let r = this.next() * total for (const item of items) { @@ -33,5 +33,5 @@ export interface Rng { int(min: number, max: number): number float(min: number, max: number, dec?: number): number pick(arr: readonly T[]): T - weighted(items: ReadonlyArray<{ val: T; w: number }>): T + weighted(items: ReadonlyArray<{ readonly val: T; readonly w: number }>): T } diff --git a/features/platform-seed/src/phases/phase5-analytics.ts b/features/platform-seed/src/phases/phase5-analytics.ts index 4d983ba67..d82fba346 100644 --- a/features/platform-seed/src/phases/phase5-analytics.ts +++ b/features/platform-seed/src/phases/phase5-analytics.ts @@ -1,5 +1,5 @@ import { randomUUID } from 'node:crypto' -import { log, logError, httpPost } from '../lib/http' +import { log, httpPost } from '../lib/http' import { createRng } from '../lib/rng' import type { ProfileRecord } from './phase3-profiles' import type { UserRecord } from './phase1-sso-users' diff --git a/features/platform-seed/src/phases/phase6-transactions.ts b/features/platform-seed/src/phases/phase6-transactions.ts index 45c08e17b..58595bae6 100644 --- a/features/platform-seed/src/phases/phase6-transactions.ts +++ b/features/platform-seed/src/phases/phase6-transactions.ts @@ -39,12 +39,12 @@ export async function phase6Transactions(users: UserRecord[], clientUsers: UserR { val: 'FAILED', w: 10 }, ] as const - const payments = [ + const payments: ReadonlyArray<{ readonly val: { provider: string; method: string }; readonly w: number }> = [ { val: { provider: 'segpay', method: 'card' }, w: 60 }, { val: { provider: 'nowpayments', method: 'crypto_btc' }, w: 20 }, { val: { provider: 'quinn_system', method: 'tokens' }, w: 15 }, { val: { provider: 'manual', method: 'gift_card' }, w: 5 }, - ] as const + ] const columns = [ 'user_id', 'transaction_type', 'amount', 'currency', 'status',