import type { CreateFlowState } from "../../app/(app)/create/types"; import { conflictManagementPresetFor, decisionApproachPresetFor, } from "./finalReviewChipPresets"; import { buildPublishPayload } from "./buildPublishPayload"; /** Staging still lists the September draft under this title. */ export const TEAM_RULE_DRAFT_TITLE = "The CommunityRule Project"; export const TEAM_RULE_TITLE = "CommunityRule Creative Team"; const TEAM_RULE_SUMMARY = "We build and maintain CommunityRule for the communities that use it. It is free for every community that wants to write down how it decides."; /** Core-value catalog ids, Home hero order. */ const TEAM_RULE_VALUE_IDS = [ "transparency", "forkability", "documentation", "maintenance", "voluntarism", ] as const; const TEAM_RULE_COMMUNICATION_IDS = [ "github-gitlab", "matrix-element", "email-distribution-list", "how-we-run-meetings", ] as const; const TEAM_RULE_MEMBERSHIP_IDS = [ "join-by-contributing", "companions", ] as const; const TEAM_RULE_DECISION_IDS = [ "consensus-decision-making", "lazy-consensus", "do-ocracy", "changing-this-rule", ] as const; const TEAM_RULE_CONFLICT_IDS = [ "conflict-ladder", "hearing-panel", "restorative-practices", ] as const; const VALUE_LABELS: Record<(typeof TEAM_RULE_VALUE_IDS)[number], string> = { transparency: "Transparency", forkability: "Forkability", documentation: "Documentation", maintenance: "Maintenance", voluntarism: "Voluntarism", }; function decisionDetailsFor( id: (typeof TEAM_RULE_DECISION_IDS)[number], ): NonNullable[string] { const preset = decisionApproachPresetFor(id); return { ...preset, selectedApplicableScope: [...preset.applicableScope], }; } function conflictDetailsFor( id: (typeof TEAM_RULE_CONFLICT_IDS)[number], ): NonNullable[string] { const preset = conflictManagementPresetFor(id); return { ...preset, selectedApplicableScope: [...preset.applicableScope], }; } /** Create-flow state that publishes as the team's adopted Rule. */ function teamRuleCreateFlowState(): CreateFlowState { return { title: TEAM_RULE_TITLE, summary: TEAM_RULE_SUMMARY, communityContext: TEAM_RULE_SUMMARY, selectedCoreValueIds: [...TEAM_RULE_VALUE_IDS], coreValuesChipsSnapshot: TEAM_RULE_VALUE_IDS.map((id) => ({ id, label: VALUE_LABELS[id], state: "selected", })), selectedCommunicationMethodIds: [...TEAM_RULE_COMMUNICATION_IDS], selectedMembershipMethodIds: [...TEAM_RULE_MEMBERSHIP_IDS], selectedDecisionApproachIds: [...TEAM_RULE_DECISION_IDS], selectedConflictManagementIds: [...TEAM_RULE_CONFLICT_IDS], decisionApproachDetailsById: Object.fromEntries( TEAM_RULE_DECISION_IDS.map((id) => [id, decisionDetailsFor(id)]), ), conflictManagementDetailsById: Object.fromEntries( TEAM_RULE_CONFLICT_IDS.map((id) => [id, conflictDetailsFor(id)]), ), }; } export type AdoptedTeamRule = { title: string; summary: string; document: Record; }; /** * Title, summary, and document for the Rule the team adopted on 30 Oct. * Card set matches the Home hero; method bodies are the remade-deck presets * those chips carry. */ export function buildAdoptedTeamRule(): AdoptedTeamRule { const result = buildPublishPayload(teamRuleCreateFlowState()); if (result.ok === false) { throw new Error(`Failed to build the adopted team Rule: ${result.error}`); } return { title: result.title, summary: result.summary ?? TEAM_RULE_SUMMARY, document: result.document, }; }