a-type / verdant

🌿 Storage, sync & realtime for local-first web apps. Build an app in minutes, deploy as a static page, and add sync with a few lines.
https://verdant.dev
MIT License
193 stars 4 forks source link

Custom operations #340

Open a-type opened 9 months ago

a-type commented 9 months ago

Theoretically... if all code for app logic is on the client, then custom operations are as simple as defining

However, not all use of operations is on the client today. There's tools to get a snapshot on the server.

So to support custom operations, which would be nice, either:

I lean toward 3 if I can find the right way to do it. There may be caveats.

a-type commented 8 months ago

Ok, one idea...

Rather than having Verdant Server generate your documents from operations for you, treat document snapshotting like a lower-level feature. The server returns the operations/baselines needed to create the snapshot. The calling server is responsible for interpreting them (using tools Verdant provides)

import { computeSnapshot } from '@verdant-web/server';

const docInfo = verdantServer.getDocumentInfo(id);
const snapshot = computeSnapshot(docInfo, schema, etc);

That way Verdant Server doesn't have to know any schemas, so it can remain multi-app-tenant capable without much effort.