/** * rTime Automerge document schemas. * * DocId formats: * {space}:rtime:commitments → CommitmentsDoc (commitment pool) * {space}:rtime:tasks → TasksDoc (weaving: tasks, connections, exec states) */ import type { DocSchema } from '../../shared/local-first/document'; // ── Skill type ── export type Skill = 'facilitation' | 'design' | 'tech' | 'outreach' | 'logistics'; export const SKILL_COLORS: Record = { facilitation: '#8b5cf6', design: '#ec4899', tech: '#3b82f6', outreach: '#10b981', logistics: '#f59e0b', }; export const SKILL_LABELS: Record = { facilitation: 'Facilitation', design: 'Design', tech: 'Tech', outreach: 'Outreach', logistics: 'Logistics', }; // ── Commitment ── export interface Commitment { id: string; memberName: string; hours: number; // 1–10 skill: Skill; desc: string; cyclosMemberId?: string; createdAt: number; } // ── Task / Connection / ExecState ── export interface Task { id: string; name: string; description: string; needs: Record; // skill → hours needed links: { label: string; url: string }[]; notes: string; } export interface Connection { id: string; fromCommitmentId: string; toTaskId: string; skill: string; } export interface ExecState { taskId: string; steps: Record; launchedAt?: number; } // ── Documents ── export interface CommitmentsDoc { meta: { module: string; collection: string; version: number; spaceSlug: string; createdAt: number; seeded?: boolean; }; items: Record; } export interface TasksDoc { meta: { module: string; collection: string; version: number; spaceSlug: string; createdAt: number; }; tasks: Record; connections: Record; execStates: Record; } // ── DocId helpers ── export function commitmentsDocId(space: string) { return `${space}:rtime:commitments` as const; } export function tasksDocId(space: string) { return `${space}:rtime:tasks` as const; } // ── Schema registrations ── export const commitmentsSchema: DocSchema = { module: 'rtime', collection: 'commitments', version: 1, init: (): CommitmentsDoc => ({ meta: { module: 'rtime', collection: 'commitments', version: 1, spaceSlug: '', createdAt: Date.now(), }, items: {}, }), }; export const tasksSchema: DocSchema = { module: 'rtime', collection: 'tasks', version: 1, init: (): TasksDoc => ({ meta: { module: 'rtime', collection: 'tasks', version: 1, spaceSlug: '', createdAt: Date.now(), }, tasks: {}, connections: {}, execStates: {}, }), };