/** * rFunds Automerge document schemas. * * Granularity: one Automerge document per space (flow associations). * DocId format: {space}:funds:flows * * 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 FundsDoc { meta: { module: string; collection: string; version: number; spaceSlug: string; createdAt: number; }; spaceFlows: Record; } // ── Schema registration ── export const fundsSchema: DocSchema = { module: 'funds', collection: 'flows', version: 1, init: (): FundsDoc => ({ meta: { module: 'funds', collection: 'flows', version: 1, spaceSlug: '', createdAt: Date.now(), }, spaceFlows: {}, }), }; // ── Helpers ── export function fundsDocId(space: string) { return `${space}:funds:flows` as const; }