Skip to main content

Data

Rendered from corpus/wiki/data.md · updated 2026-10-13

This page is generated from the project corpus and rewritten on every docs build. Edit the source in corpus/, not here.

SQLite — data/newspapper.db​

Schema version: 6. Auto-created and migrated on boot. The path is resolved from core/src/storage/db.ts via import.meta.url, never from the CWD. Foreign keys are enforced (PRAGMA foreign_keys = ON).

The .wzd markup is the source of truth. posts.markup is the document; every other column on posts — title, description, keywords — is derived from its <head> block on save and exists only so the library can be listed, filtered and searched without parsing every post. See the decision and markup.md for the <head> shape.

posts​

ColumnTypeNotes
idINTEGER PKautoincrement
titleTEXT NOT NULLderived from <head><title>
descriptionTEXT NOT NULL DEFAULT ''derived from <head><description>
markupTEXT NOT NULLthe .wzd document — the source of truth
themeTEXT NOT NULL DEFAULT warm-industrial-1one of the three themes
statusTEXT NOT NULL DEFAULT draftCHECK (status IN ('draft','published'))
created_at / updated_atTEXT ISO-8601updated_at bumped on every markup write
published_atTEXT ISO-8601 | NULLstamped on publish, cleared on unpublish

Index: idx_posts_status_updated_at on (status, updated_at).

v3 → v4 (2026-08-31) rewrote posts.theme, the defaultTheme setting and the column default to 'warm-industrial-1'. The default needs a table rebuild, so posts is copied and renamed with PRAGMA foreign_keys briefly off — DROP TABLE posts would cascade post_keywords and renders away. Skipped unless sqlite_master still holds the legacy default, so a re-run is a no-op.

published is a manual state, never automatic.

keywords / post_keywords​

keywordsTypeNotes
idINTEGER PK
nameTEXT NOT NULL UNIQUE COLLATE NOCASEBudget and budget are one keyword
post_keywordsTypeNotes
post_idINTEGER → posts(id) ON DELETE CASCADE
keyword_idINTEGER → keywords(id) ON DELETE CASCADE
PRIMARY KEY (post_id, keyword_id)

Index: idx_post_keywords_keyword_id on (keyword_id).

Normalized rather than a comma-joined column because keywords are shared across posts and used to filter the library — a text column would make that a scan. Derived from <head><keywords>; setPostKeywords upserts and replaces the join rows in one transaction.

renders​

ColumnTypeNotes
idINTEGER PK
post_idINTEGER → posts(id) ON DELETE CASCADE
output_dirTEXT NOT NULLabsolute path
slide_countINTEGER NOT NULL DEFAULT 0
optimizedINTEGER NOT NULL DEFAULT 0set by the publish-time pass
created_atTEXT ISO-8601

One row per render run; a post's export and thumbnail read the newest.

No app-owned users table since v5 (2026-09-06). Accounts came back on 2026-10-13 as the shared library's tables, in this same file but outside user_version: auth_users (id, username, scrypt hash, role), auth_sessions (hashed token, origin local or ward, the Ward session family), auth_ward_links (user ↔ Ward subject) and auth_migrations. The library creates and migrates them itself when the API boots (createSqliteStore), and no app table references them: no row of the app's is keyed by a user, so there was nothing to migrate when accounts arrived. See decisions-accounts.md.

sources, articles, feed_items​

The reading side's three tables (the Reader's columns on sources, the saved library with its note, and the Reader's stored items) are in data-reader.md.

uploads​

ColumnTypeNotes
idINTEGER PK
filenameTEXT NOT NULLoriginal name
stored_pathTEXT NOT NULLthe kept original
normalized_pathTEXTthe derived copy, NULL until made
mimeTEXT NOT NULL
width, heightINTEGER
bytesINTEGER NOT NULL DEFAULT 0
created_atTEXT ISO-8601

Rows only — the files live under uploads/. settings is a key-value table with exactly one key, defaultTheme.

Migration history​

How the schema got here, and how a migration step stays crash-safe: migrations.md.

TNode — the .wzd compile target​

Not an on-disk format: the JSON template files went with the template system (2026-08-27). TNode is in-memory only — core/src/wizard/compile.ts builds one per <Slide>, and renderTemplate walks it into HTML.

TNode types​

kindFieldsDescription
boxstyle?, children: TNode[]Flex container div
texttext: string, style?Text node; supports {{binding}}
repeatsource: string, style?, children: TNode[]Iterates data[source] array

TStyle​

CSS property map. Supports:

  • Numbers → appended with px (except unitless: fontWeight, lineHeight, opacity, flex, flexGrow, flexShrink, zIndex, order)
  • "$color.key", "$spacing.key", "$rounded.key" → resolved from theme tokens
  • "typography": "key" → expands full typography token set into CSS properties
  • Any other string → passed through verbatim

Bindings in text nodes: {{fieldName}}, {{item.label}}, {{_index}}, {{_total}}, {{_date}}. The compiler resolves <head> fields before the interpreter sees the tree; _index/_total come from renderTemplate's options — that is how <PageCounter/> gets its numbers.

Output directory​

output/
YYYY-MM-DD-1/
slide-01.jpg, slide-02.jpg, …slide-NN.jpg (1080×1080, one per slide)
slides.json
caption.txt (present only if a caption was set before render)
thumb.jpg (220×220 grid thumbnail of slide 1; not exported, not a slide)
YYYY-MM-DD-2/ (same-day re-render → increments N; reserved by mkdir when picked)

JPEG only, no .png (decisions.md) — draft quality ~92; writeRun deletes any stale .png it finds in the target dir. POST /api/posts/:id/publish (core/src/publish) re-encodes in place at ~85 and flags the render optimized, guarding a repeat publish from re-degrading the image.

Each directory is recorded as a row in renders.