139 lines
2.7 KiB
TypeScript
139 lines
2.7 KiB
TypeScript
/**
|
||
* 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<Skill, string> = {
|
||
facilitation: '#8b5cf6',
|
||
design: '#ec4899',
|
||
tech: '#3b82f6',
|
||
outreach: '#10b981',
|
||
logistics: '#f59e0b',
|
||
};
|
||
|
||
export const SKILL_LABELS: Record<Skill, string> = {
|
||
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<string, number>; // 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<string, 'pending' | 'active' | 'done'>;
|
||
launchedAt?: number;
|
||
}
|
||
|
||
// ── Documents ──
|
||
|
||
export interface CommitmentsDoc {
|
||
meta: {
|
||
module: string;
|
||
collection: string;
|
||
version: number;
|
||
spaceSlug: string;
|
||
createdAt: number;
|
||
seeded?: boolean;
|
||
};
|
||
items: Record<string, Commitment>;
|
||
}
|
||
|
||
export interface TasksDoc {
|
||
meta: {
|
||
module: string;
|
||
collection: string;
|
||
version: number;
|
||
spaceSlug: string;
|
||
createdAt: number;
|
||
};
|
||
tasks: Record<string, Task>;
|
||
connections: Record<string, Connection>;
|
||
execStates: Record<string, ExecState>;
|
||
}
|
||
|
||
// ── 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<CommitmentsDoc> = {
|
||
module: 'rtime',
|
||
collection: 'commitments',
|
||
version: 1,
|
||
init: (): CommitmentsDoc => ({
|
||
meta: {
|
||
module: 'rtime',
|
||
collection: 'commitments',
|
||
version: 1,
|
||
spaceSlug: '',
|
||
createdAt: Date.now(),
|
||
},
|
||
items: {},
|
||
}),
|
||
};
|
||
|
||
export const tasksSchema: DocSchema<TasksDoc> = {
|
||
module: 'rtime',
|
||
collection: 'tasks',
|
||
version: 1,
|
||
init: (): TasksDoc => ({
|
||
meta: {
|
||
module: 'rtime',
|
||
collection: 'tasks',
|
||
version: 1,
|
||
spaceSlug: '',
|
||
createdAt: Date.now(),
|
||
},
|
||
tasks: {},
|
||
connections: {},
|
||
execStates: {},
|
||
}),
|
||
};
|