/** * rFlows Automerge document schemas. * * Granularity: one Automerge document per space (flow associations). * DocId format: {space}:flows:data * * Actual flow logic stays in the external payment-flow service. * This doc tracks which flows are associated with which spaces. */ import type { DocSchema } from '../../shared/local-first/document'; // ── Document types ── export interface SpaceFlow { id: string; spaceSlug: string; flowId: string; addedBy: string | null; createdAt: number; } export interface FlowsDoc { meta: { module: string; collection: string; version: number; spaceSlug: string; createdAt: number; }; spaceFlows: Record; } // ── Schema registration ── export const flowsSchema: DocSchema = { module: 'flows', collection: 'data', version: 1, init: (): FlowsDoc => ({ meta: { module: 'flows', collection: 'data', version: 1, spaceSlug: '', createdAt: Date.now(), }, spaceFlows: {}, }), }; // ── Helpers ── export function flowsDocId(space: string) { return `${space}:flows:data` as const; }