Files
Docwell/Database/pb_migrations/1762000000_collab.js
T
tajniak81andClaude Opus 5.5 ba394b8fac Finish Phase 0: lint, codegen, contributor docs and the two remaining spikes
Repository basics:
- CONTRIBUTING.md and CODE_OF_CONDUCT.md (Contributor Covenant 2.1)
- SPDX AGPL-3.0-or-later headers on all hand-written sources, checked in CI
- golangci-lint (shared .golangci.yml), ESLint and Prettier, all run in CI

API codegen from api/openapi.yaml (npm run generate, drift fails CI):
- Go types via oapi-codegen in Server/internal/api
- a contract test that the router and the spec list the same routes
- Dart models via Phone-App/tool/generate_api.dart; the app uses them

Spike: shared Tiptap editor in a Flutter WebView (ADR-4)
- @docwell/editor-bridge builds the editor into one HTML page with a
  versioned JSON protocol; Phone-App hosts it with webview_flutter and a
  native toolbar. Integration test passes on an Android API 35 emulator.
- flutter_inappwebview dropped: its Android plugin fails on AGP 9.

Spike: Wails v3 desktop (ADR-11)
- system tray, docwell:// deep links (page and space only) with
  single-instance hand-off, and the built-in updater with a required
  ed25519 signing key. Verified on Windows.
- regenerated build assets register the scheme and drop template
  placeholders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 16:11:07 +01:00

48 lines
1.9 KiB
JavaScript

// SPDX-License-Identifier: AGPL-3.0-or-later
/// <reference path="../pb_data/types.d.ts" />
// Collaboration storage. The server talks to PocketBase over JSON only, so the
// compacted Yjs snapshot moves from a file field to base64 text, like
// page_yupdates. page_versions keeps snapshots for the page history.
migrate(
(app) => {
const ydoc = app.findCollectionByNameOrId("page_ydoc");
ydoc.fields.removeByName("state");
app.save(ydoc);
// Base64-encoded Yjs update holding the whole document.
ydoc.fields.add(new TextField({ name: "state", max: 0 }));
app.save(ydoc);
const pages = app.findCollectionByNameOrId("pages");
const users = app.findCollectionByNameOrId("users");
const versions = new Collection({
type: "base",
name: "page_versions",
fields: [
{ name: "page", type: "relation", collectionId: pages.id, maxSelect: 1, required: true, cascadeDelete: true },
// Base64-encoded Yjs snapshot, as in page_ydoc.state.
{ name: "state", type: "text", required: true, max: 0 },
{ name: "content_json", type: "json", maxSize: 20971520 },
{ name: "author", type: "relation", collectionId: users.id, maxSelect: 1 },
{ name: "label", type: "text", max: 200 },
{ name: "created", type: "autodate", onCreate: true, onUpdate: false },
{ name: "updated", type: "autodate", onCreate: true, onUpdate: true },
],
indexes: ["CREATE INDEX idx_page_versions_page ON page_versions (page, created)"],
});
app.save(versions);
},
(app) => {
try {
app.delete(app.findCollectionByNameOrId("page_versions"));
} catch (_) {}
const ydoc = app.findCollectionByNameOrId("page_ydoc");
ydoc.fields.removeByName("state");
app.save(ydoc);
ydoc.fields.add(new FileField({ name: "state", maxSelect: 1, maxSize: 52428800, protected: true }));
app.save(ydoc);
},
);