1c9b531996
Complete the server-backed storage layer for PubScript so the app can run against a real Fastify + SQLite backend instead of only local IndexedDB. Server (@pubscript/server): - db.ts: better-sqlite3 schema + migrations (users, shares, projects, books, chapters, entities, boards, ai_sessions, audit); WAL mode; idempotent admin bootstrap via PUBSCRIPT_ADMIN_EMAIL/PASSWORD. - auth.ts: argon2 hashing, JWT-ish session tokens, guards, auth routes. - routes.ts: REST CRUD for projects/books/chapters/entities/boards/ai_sessions with multi-tenant isolation and optimistic concurrency (baseRev). - ws.ts: Fastify websocket hub for autosave + presence events. - mapping.ts: row <-> core type conversion. Core (@pubscript/core): - Zod domain schemas (projects, books, chapters, entities, boards, ai_sessions) exported from index. - storage-local.ts (IndexedDB/Dexie) and storage-server.ts (REST) adapters implementing the StorageAdapter contract. Tests & tooling: - storage.contract.test.ts: parameterized over both adapters; wired as `pnpm contract` and added to CI. - seed.ts (`pnpm --filter server seed`): creates demo project "The Glass Harbor" — 3 chapters of prose, 4 linked characters, 1 world location, 6-node board. - Dockerfile + compose wiring for the server runtime. Acceptance: seed project opens with 3 chapters, 4 linked characters, 1 board.
24 lines
906 B
TypeScript
24 lines
906 B
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { ENTITY_FIELDS, ENTITY_KINDS } from "./schema.js";
|
|
|
|
describe("schema ENTITY_FIELDS", () => {
|
|
it("covers every entity kind from PLAN.md §3.3", () => {
|
|
for (const kind of ["character", "location", "faction", "item", "glossary", "system", "note"]) {
|
|
expect(ENTITY_FIELDS[kind]).toBeDefined();
|
|
expect(ENTITY_FIELDS[kind]!.fields.length).toBeGreaterThan(0);
|
|
}
|
|
});
|
|
|
|
it("includes a list field and a select field", () => {
|
|
const character = ENTITY_FIELDS.character;
|
|
expect(character).toBeDefined();
|
|
expect(character!.fields.some((f) => f.type === "list")).toBe(true);
|
|
expect(character!.fields.some((f) => f.type === "select")).toBe(true);
|
|
});
|
|
|
|
it("exposes a stable, ordered kind list", () => {
|
|
expect(ENTITY_KINDS).toContain("character");
|
|
expect(ENTITY_KINDS.length).toBeGreaterThanOrEqual(7);
|
|
});
|
|
});
|