/** * rDesign Automerge document schemas. * * Syncs linked Affine design projects per space. * Actual design data lives in the Affine instance. * * DocId format: {space}:design:projects */ import type { DocSchema } from '../../shared/local-first/document'; export interface LinkedProject { id: string; url: string; name: string; addedBy: string | null; addedAt: number; } export interface DesignDoc { meta: { module: string; collection: string; version: number; spaceSlug: string; createdAt: number }; linkedProjects: Record; } export const designSchema: DocSchema = { module: 'design', collection: 'projects', version: 1, init: (): DesignDoc => ({ meta: { module: 'design', collection: 'projects', version: 1, spaceSlug: '', createdAt: Date.now() }, linkedProjects: {}, }), migrate: (doc: any) => { if (!doc.linkedProjects) doc.linkedProjects = {}; doc.meta.version = 1; return doc; }, }; export function designDocId(space: string) { return `${space}:design:projects` as const; }