37 lines
1020 B
TypeScript
37 lines
1020 B
TypeScript
/**
|
|
* rDocs Automerge document schemas.
|
|
*
|
|
* Syncs linked Docmost documents per space.
|
|
* Actual document content lives in the Docmost instance.
|
|
*
|
|
* DocId format: {space}:docs:links
|
|
*/
|
|
|
|
import type { DocSchema } from '../../shared/local-first/document';
|
|
|
|
export interface LinkedDocument {
|
|
id: string;
|
|
url: string;
|
|
title: string;
|
|
addedBy: string | null;
|
|
addedAt: number;
|
|
}
|
|
|
|
export interface DocsDoc {
|
|
meta: { module: string; collection: string; version: number; spaceSlug: string; createdAt: number };
|
|
linkedDocuments: Record<string, LinkedDocument>;
|
|
}
|
|
|
|
export const docsSchema: DocSchema<DocsDoc> = {
|
|
module: 'docs',
|
|
collection: 'links',
|
|
version: 1,
|
|
init: (): DocsDoc => ({
|
|
meta: { module: 'docs', collection: 'links', version: 1, spaceSlug: '', createdAt: Date.now() },
|
|
linkedDocuments: {},
|
|
}),
|
|
migrate: (doc: any) => { if (!doc.linkedDocuments) doc.linkedDocuments = {}; doc.meta.version = 1; return doc; },
|
|
};
|
|
|
|
export function docsDocId(space: string) { return `${space}:docs:links` as const; }
|