/** * The 92 real-group profiles from product/real-group-profiles.md, read as setup answers, * and the one-member founders added to the test set on 27 Oct. * The real-group fixture is copied unchanged. Two readings are made here, both stated * in the README. The first kind listed is the main kind, as the review read its worked * examples. An alsoPlausible kind is read as another kind that fits. */ import type { GroupAnswers, Kind, Scale, SizeBand, Stage, TraitKey } from "./deckTypes"; export interface ReviewProfile { id: string; size: string | null; kinds: string[]; scale: string | null; stage: string | null; answers: Record; alsoPlausible?: { size?: string[]; kinds?: string[]; scale?: string[]; stage?: string[] }; } const KIND: Record = { "worker co-op": "workersCoop", "mutual aid": "mutualAid", nonprofit: "nonprofit", "for-profit": "forProfit", "open source": "openSource", dao: "dao", }; const SIZE: Record = { "1": "oneMember", "2-5": "twoToFive", "6-12": "sixToTwelve", "13-100": "thirteenToOneHundred", "100+": "oneHundredToOneHundredK", }; const STAGE: Record = { early: "earlyStage", growth: "growthStage", established: "established", enterprise: "enterprise", }; function kind(k: string): Kind { const v = KIND[k]; if (!v) throw new Error(`Unknown kind ${k}`); return v; } export function toAnswers(p: ReviewProfile): GroupAnswers { const kinds = p.kinds.map(kind); return { size: p.size ? SIZE[p.size] : null, mainKind: kinds[0] ?? null, otherKinds: kinds.slice(1), scale: p.scale ? [p.scale as Scale] : [], stage: p.stage ? STAGE[p.stage] : null, traits: { ...p.answers }, }; } export interface ProfileVariant { profile: string; variant: string; answers: GroupAnswers; } /** The profile as given, then once per alsoPlausible answer swapped in. */ export function variantsOf(p: ReviewProfile): ProfileVariant[] { const base = toAnswers(p); const out: ProfileVariant[] = [{ profile: p.id, variant: "base", answers: base }]; for (const s of p.alsoPlausible?.size ?? []) { out.push({ profile: p.id, variant: `size ${s}`, answers: { ...base, size: SIZE[s] } }); } for (const k of p.alsoPlausible?.kinds ?? []) { out.push({ profile: p.id, variant: `also ${k}`, answers: { ...base, otherKinds: [...(base.otherKinds ?? []), kind(k)] }, }); } for (const s of p.alsoPlausible?.scale ?? []) { out.push({ profile: p.id, variant: `scale ${s}`, answers: { ...base, scale: [s as Scale] } }); } for (const s of p.alsoPlausible?.stage ?? []) { out.push({ profile: p.id, variant: `stage ${s}`, answers: { ...base, stage: STAGE[s] } }); } return out; }