hazo_blog 2.18.0 → 2.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGE_LOG.md +152 -0
- package/db_setup_postgres.sql +131 -1
- package/db_setup_sqlite.sql +104 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -0
- package/dist/lib/revisions.d.ts +71 -1
- package/dist/lib/revisions.d.ts.map +1 -1
- package/dist/lib/revisions.js +232 -7
- package/dist/lib/theme-schema.d.ts +4 -0
- package/dist/lib/theme-schema.d.ts.map +1 -1
- package/dist/lib/theme-schema.js +10 -0
- package/dist/lib/widgets.d.ts +35 -0
- package/dist/lib/widgets.d.ts.map +1 -0
- package/dist/lib/widgets.js +166 -0
- package/dist/next/blog-content-client.d.ts +6 -0
- package/dist/next/blog-content-client.d.ts.map +1 -0
- package/dist/next/blog-content-client.js +33 -0
- package/dist/next/blog-content.d.ts +2 -2
- package/dist/next/blog-content.d.ts.map +1 -1
- package/dist/next/blog-content.js +15 -18
- package/dist/next/pages.d.ts +4 -2
- package/dist/next/pages.d.ts.map +1 -1
- package/dist/next/pages.js +22 -4
- package/dist/render/tags/index.d.ts.map +1 -1
- package/dist/render/tags/index.js +2 -0
- package/dist/render/tags/widget-area.d.ts +8 -0
- package/dist/render/tags/widget-area.d.ts.map +1 -0
- package/dist/render/tags/widget-area.js +87 -0
- package/dist/render/types.d.ts +61 -0
- package/dist/render/types.d.ts.map +1 -1
- package/dist/repository/bylines.d.ts.map +1 -1
- package/dist/repository/bylines.js +1 -0
- package/dist/repository/index.d.ts +15 -1
- package/dist/repository/index.d.ts.map +1 -1
- package/dist/repository/index.js +25 -0
- package/dist/repository/posts.d.ts +62 -1
- package/dist/repository/posts.d.ts.map +1 -1
- package/dist/repository/posts.js +264 -0
- package/dist/repository/tags.d.ts +9 -1
- package/dist/repository/tags.d.ts.map +1 -1
- package/dist/repository/tags.js +11 -0
- package/dist/repository/theme-versions.d.ts +27 -0
- package/dist/repository/theme-versions.d.ts.map +1 -0
- package/dist/repository/theme-versions.js +105 -0
- package/dist/repository/widgets.d.ts +51 -0
- package/dist/repository/widgets.d.ts.map +1 -0
- package/dist/repository/widgets.js +169 -0
- package/dist/service/posts.d.ts +65 -3
- package/dist/service/posts.d.ts.map +1 -1
- package/dist/service/posts.js +77 -2
- package/dist/service/site-files.d.ts +9 -0
- package/dist/service/site-files.d.ts.map +1 -1
- package/dist/service/site-files.js +29 -0
- package/dist/service/themes.d.ts +65 -7
- package/dist/service/themes.d.ts.map +1 -1
- package/dist/service/themes.js +235 -8
- package/dist/service/widgets.d.ts +28 -0
- package/dist/service/widgets.d.ts.map +1 -0
- package/dist/service/widgets.js +153 -0
- package/dist/types/index.d.ts +338 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/ui/blog-admin-panel.js +2 -2
- package/package.json +1 -1
- package/seeds/editorial-homepage-seed.json +72 -0
- package/seeds/magazine-homepage-seed.json +94 -0
- package/themes/editorial/assets/screenshot.svg +32 -0
- package/themes/editorial/assets/style.css +1057 -0
- package/themes/editorial/partials/contact-form.liquid +100 -0
- package/themes/editorial/partials/footer.liquid +34 -0
- package/themes/editorial/partials/header.liquid +22 -0
- package/themes/editorial/partials/pagination.liquid +28 -0
- package/themes/editorial/partials/post-card.liquid +15 -0
- package/themes/editorial/partials/scripts.liquid +205 -0
- package/themes/editorial/partials/styles.liquid +1103 -0
- package/themes/editorial/sections/contact.liquid +16 -0
- package/themes/editorial/sections/cta.liquid +8 -0
- package/themes/editorial/sections/faq.liquid +11 -0
- package/themes/editorial/sections/features.liquid +22 -0
- package/themes/editorial/sections/hero.liquid +10 -0
- package/themes/editorial/sections/image_text.liquid +9 -0
- package/themes/editorial/sections/logos.liquid +14 -0
- package/themes/editorial/sections/posts_grid.liquid +22 -0
- package/themes/editorial/sections/quote_form.liquid +15 -0
- package/themes/editorial/sections/stats.liquid +13 -0
- package/themes/editorial/sections/testimonials.liquid +14 -0
- package/themes/editorial/sections/text.liquid +6 -0
- package/themes/editorial/templates/404.liquid +11 -0
- package/themes/editorial/templates/archive.liquid +20 -0
- package/themes/editorial/templates/category.liquid +17 -0
- package/themes/editorial/templates/home.liquid +14 -0
- package/themes/editorial/templates/page.liquid +14 -0
- package/themes/editorial/templates/post.liquid +42 -0
- package/themes/editorial/templates/search.liquid +28 -0
- package/themes/editorial/templates/tag.liquid +13 -0
- package/themes/editorial/theme.json +33 -0
- package/themes/editorial/widgets/ad_slot.liquid +16 -0
- package/themes/editorial/widgets/category_list.liquid +18 -0
- package/themes/editorial/widgets/newsletter_placeholder.liquid +14 -0
- package/themes/editorial/widgets/recent_posts.liquid +20 -0
- package/themes/editorial/widgets/search.liquid +14 -0
- package/themes/editorial/widgets/tag_cloud.liquid +20 -0
- package/themes/editorial/widgets/text.liquid +10 -0
- package/themes/magazine/assets/screenshot.svg +48 -0
- package/themes/magazine/assets/style.css +527 -0
- package/themes/magazine/partials/contact-form.liquid +100 -0
- package/themes/magazine/partials/footer.liquid +34 -0
- package/themes/magazine/partials/header.liquid +23 -0
- package/themes/magazine/partials/pagination.liquid +28 -0
- package/themes/magazine/partials/post-card.liquid +19 -0
- package/themes/magazine/partials/styles.liquid +580 -0
- package/themes/magazine/sections/contact.liquid +16 -0
- package/themes/magazine/sections/cta.liquid +8 -0
- package/themes/magazine/sections/faq.liquid +11 -0
- package/themes/magazine/sections/features.liquid +22 -0
- package/themes/magazine/sections/hero.liquid +19 -0
- package/themes/magazine/sections/image_text.liquid +9 -0
- package/themes/magazine/sections/logos.liquid +14 -0
- package/themes/magazine/sections/posts_grid.liquid +38 -0
- package/themes/magazine/sections/quote_form.liquid +15 -0
- package/themes/magazine/sections/stats.liquid +13 -0
- package/themes/magazine/sections/testimonials.liquid +14 -0
- package/themes/magazine/sections/text.liquid +6 -0
- package/themes/magazine/templates/404.liquid +11 -0
- package/themes/magazine/templates/archive.liquid +21 -0
- package/themes/magazine/templates/category.liquid +18 -0
- package/themes/magazine/templates/home.liquid +16 -0
- package/themes/magazine/templates/page.liquid +14 -0
- package/themes/magazine/templates/post.liquid +56 -0
- package/themes/magazine/templates/search.liquid +28 -0
- package/themes/magazine/templates/tag.liquid +14 -0
- package/themes/magazine/theme.json +32 -0
- package/themes/magazine/widgets/ad_slot.liquid +16 -0
- package/themes/magazine/widgets/category_list.liquid +20 -0
- package/themes/magazine/widgets/newsletter_placeholder.liquid +14 -0
- package/themes/magazine/widgets/recent_posts.liquid +21 -0
- package/themes/magazine/widgets/search.liquid +14 -0
- package/themes/magazine/widgets/tag_cloud.liquid +19 -0
- package/themes/magazine/widgets/text.liquid +10 -0
- package/themes/starter-light/sections/faq.liquid +2 -2
- package/themes/trades/partials/footer.liquid +2 -0
- package/themes/trades/partials/styles.liquid +115 -0
- package/themes/trades/sections/faq.liquid +2 -2
- package/themes/trades/templates/post.liquid +18 -12
- package/themes/trades/theme.json +5 -1
- package/themes/trades/widgets/ad_slot.liquid +19 -0
- package/themes/trades/widgets/category_list.liquid +22 -0
- package/themes/trades/widgets/newsletter_placeholder.liquid +17 -0
- package/themes/trades/widgets/recent_posts.liquid +26 -0
- package/themes/trades/widgets/search.liquid +16 -0
- package/themes/trades/widgets/tag_cloud.liquid +22 -0
- package/themes/trades/widgets/text.liquid +12 -0
package/CHANGE_LOG.md
CHANGED
|
@@ -3,6 +3,158 @@
|
|
|
3
3
|
All notable changes are documented here. This project follows
|
|
4
4
|
[Semantic Versioning](https://semver.org/).
|
|
5
5
|
|
|
6
|
+
## 2.27.1 — 2026-11-23
|
|
7
|
+
|
|
8
|
+
**Bug fix: blog post pages crash with RSC serialization error on production builds.** `BlogContent` (the server component that renders MDX post bodies) used `MDXRemote` from `next-mdx-remote/rsc`, which compiled MDX and returned live React elements that had to pass through RSC serialization. On some production builds — where the bundled MDX compiler and its unified/remark ecosystem are resolved differently — these elements couldn't be serialized, producing `E{"digest":"…"}` in the RSC payload. The initial SSR HTML rendered fine (server saw the elements directly), but the client error boundary fired as soon as hydration read the broken RSC stream, replacing the content with "Something went wrong."
|
|
9
|
+
|
|
10
|
+
- **Fix**: `BlogContent` now compiles MDX to a `function-body` string via `@mdx-js/mdx`'s `compile()` (server side), passes that plain string to a new `BlogContentClient` ("use client") component, which evaluates it at hydration time using the `react/jsx-runtime` and renders with the standard `mdxComponents` map (`BlogImage`, `YouTube`, `Callout`, `CodeBlock`, `InlineCode`). The compiled MDX is a plain string — trivially RSC-serializable.
|
|
11
|
+
- **New file**: `src/next/blog-content-client.tsx` — minimal "use client" MDX renderer. No dependency on `next-mdx-remote`'s client bundle (avoids a dual-React SSR issue) — evaluates the compiled function-body directly with `Reflect.construct(Function, ...)` + `react/jsx-runtime`.
|
|
12
|
+
- **Admin preview for draft posts**: `PostPreview` button now shows for any post with a slug (was gated on `status === "published"`). Preview URL appends `?preview=true` for non-published posts. `createBlogPostPage`'s `Page` and `generateMetadata` functions accept `searchParams` and pass `includeUnpublished: true` when `preview=true`.
|
|
13
|
+
|
|
14
|
+
Bumps 2.27.0 -> 2.27.1 (patch — bug fix + preview UX improvement, no DDL, no breaking API change).
|
|
15
|
+
|
|
16
|
+
## 2.27.0 — 2026-11-21
|
|
17
|
+
|
|
18
|
+
**Theme duplicate + export (Phase 2 ticket 23, D59).** No DDL — both features are built entirely on top of ticket 06's existing theme storage/validation pipeline and ticket 22's export surface; no new table or column. Two new `ThemeService` methods plus one new guard on an existing one:
|
|
19
|
+
|
|
20
|
+
- **`ThemeService.exportTheme(themeId, req?)`** (new) — returns every file needed to recreate a theme (built-in or upload) as a `ThemeFile[]`, the SAME shape a zip extraction or `installThemeFromFiles` already use, so `installThemeFromFiles(await exportTheme(id, req), req)` is a legitimate re-install. `theme.json` is one of those files, and it already carries the settings SCHEMA (the ticket's own "files AND its settings schema" wording) — no separate settings export was needed. A built-in theme's files come from a local directory walk (reusing `installBuiltInThemes`' own `readDirAsThemeFiles`); an upload's come from a new `readUploadedThemeFiles` helper that downloads every file under its storage prefix via the configured `BlogFileStorageProvider` (same `provider.list`/`provider.get` iteration `materializeUploadedTheme` already does for render, just returned in memory instead of written to a local cache). Throws `ThemeNotFoundError` across a tenant boundary, same convention as `getTheme`/`activateTheme`.
|
|
21
|
+
- **`ThemeService.duplicateTheme(sourceThemeId, newName, req?)`** (new) — copies a theme's files (built-in or upload, either works) into a BRAND NEW upload-sourced theme record owned by the caller's scope, named `newName`. If `sourceThemeId` is this scope's CURRENTLY ACTIVE theme, the duplicate's `theme.json` gets each setting field's `default` overwritten with that field's CURRENT site value before being stored — so activating the duplicate looks identical to the customised original, not back to the stock defaults — the ticket's own "copies files and settings" requirement. If the source isn't currently active for this scope, the duplicate just keeps the source's own schema defaults (nothing to carry forward). The new record's handle is derived from `newName` with a `uniqueDuplicateHandle` helper that ALWAYS finds a free handle (appending `-2`, `-3`, … on a collision) — deliberately NOT `installThemeFromFiles`'s own "same handle = new version" rule, which would silently land a duplicate on an unrelated existing theme instead of creating the new record the ticket asks for. Throws `ThemeNotFoundError` if `sourceThemeId` isn't visible to this scope.
|
|
22
|
+
- **Built-in themes refuse in-place edits (ticket's own first checkbox, D59's "built-in themes are read-only; editing requires duplicating first")**: `installThemeFromFiles` now throws a new `ThemeImmutableError` if the uploaded `theme.json`'s name slugifies to the SAME handle as an existing BUILT-IN theme, instead of its previous behaviour of silently creating a same-handle upload shadowing the built-in. This is the one concrete "edit a theme" entry point this package exposes today (there's no theme-file editor UI) — the error message points the caller at `duplicateTheme` by name. Mapping this to a clear HTTP response is the platform's job (ticket 23's platform half).
|
|
23
|
+
- Tests: 10 new cases in `src/__tests__/themes.service.integration.test.ts` — the immutable-edit guard, duplicate from a built-in, settings carried forward only when the source is the scope's active theme, duplicate always creates a new record (collision gets a suffixed handle), duplicate/export tenant isolation (`ThemeNotFoundError` across a scope boundary), and two round-trip tests: export an uploaded theme → reinstall on a DIFFERENT scope → `getThemeJson` and every file byte-identical; export a BUILT-IN theme → reinstall under a new name (dodging the immutable guard) → same non-name fields and files identical. 939/999 passing (929/989 before this ticket — the same 52 pre-existing, unrelated failures every release since 2.10.0 has carried, unchanged — zero regressions).
|
|
24
|
+
- **Not done in this release (flagged, not silently deferred)**: no `test-app/` change — same precedent tickets 20–22 already set (themes aren't exercised in the demo app beyond `render-demo`, and this ticket adds no new render-affecting behaviour). `duplicateTheme` doesn't write a `BlogSiteThemeVersion` row — it creates a new, not-yet-active theme record, so there's nothing to version yet (versioning starts, as before, at `activateTheme`). The new theme's `version` string is carried over UNCHANGED from the source (a duplicate is a copy, not a new release) — an operator who wants a bumped version can re-upload a new one afterwards via the ordinary install path.
|
|
25
|
+
|
|
26
|
+
Bumps 2.26.1 -> 2.27.0 (minor, additive — two new service methods plus a new error type, no DDL, fully backward compatible).
|
|
27
|
+
|
|
28
|
+
## 2.26.1 — 2026-11-21
|
|
29
|
+
|
|
30
|
+
**Bug fix: the composable `faq` section's theme partials rendered `question`/`answer` with no HTML escaping.** Found while implementing the platform's Phase 2 ticket 14 (SEO meta + FAQ carry-over) — that ticket's own injection-safety review checked every FAQ-rendering path this package ships and confirmed, empirically (`new Liquid().parseAndRender("{{ x }}", { x: "<script>..." })` compiles the script tag straight through), that liquidjs does NOT auto-escape output by default. The pre-existing `{% faq %}` platform tag (`src/render/tags/faq.ts`) already ran both fields through `escapeHtml` before this release; the four built-in themes' OWN `sections/faq.liquid` partials (a different rendering path — the composable `faq` SECTION type, reached via `{% section_list %}`, not `{% faq %}`) did not, so a `faq` section's `question`/`answer` — built-in-theme page content, no custom theme involved — compiled any HTML in either field live into the page.
|
|
31
|
+
|
|
32
|
+
- **Fix**: `{{ item.question }}` / `{{ item.answer }}` → `{{ item.question | escape }}` / `{{ item.answer | escape }}` in all four `themes/{editorial,magazine,starter-light,trades}/sections/faq.liquid`. No schema/behaviour change — `faqSettingsSchema` is unchanged, every non-HTML question/answer renders identically to before.
|
|
33
|
+
- Tests: 1 new case, `src/__tests__/builtin-themes.editorial.render.test.ts` ("faq — question/answer are HTML-escaped, not injected raw") — asserts a `<script>`/`onerror` payload in either field never survives unescaped in the rendered page. The same partial is shared byte-for-byte across all four themes (confirmed identical before this fix), so one theme's test coverage stands in for all four, consistent with how this file's other section tests already cover editorial only. 929/989 passing (928/988 before — the same 52 pre-existing, unrelated failures every release since 2.10.0 has carried, unchanged — zero regressions).
|
|
34
|
+
- **Not done in this release**: no `test-app/` change — this is a rendering-safety fix with no new export, config key, or visible behaviour change for ordinary (non-HTML) FAQ content, so there's nothing new for the demo app to exercise.
|
|
35
|
+
|
|
36
|
+
Bumps 2.26.0 -> 2.26.1 (patch, bug fix — no DDL, no API surface change).
|
|
37
|
+
|
|
38
|
+
## 2.26.0 — 2026-11-21
|
|
39
|
+
|
|
40
|
+
**⚠️ DDL required — theme versions + rollback (Phase 2 ticket 22, D59).** New table `hazo_blog_site_theme_versions`: an append-only history of a site's theme state (which theme + its full settings), with one row written on every theme activation, every settings save, AND every rollback — never updated or deleted after insert, same append-only philosophy as the platform's own `app_ops_log_entries` (ticket 03). Not to be confused with the PRE-EXISTING `hazo_blog_theme_versions` table, which tracks a theme PACKAGE's upload history (`ThemeRepository.addThemeVersion`/`listThemeVersions`) and is unrelated/untouched — the new table is deliberately named differently (`hazo_blog_site_theme_versions`, mirroring `hazo_blog_site_theme`) to avoid any confusion with that existing concept.
|
|
41
|
+
|
|
42
|
+
- **Write sites (two, not one, per the ticket's own checkbox):** `ThemeService.activateTheme` writes a version (`source: "activation"`) AFTER the switch and ticket 19's widget-area reconciliation complete, so the row reflects the post-reconciliation state. `ThemeService.updateThemeSettings` writes a version (`source: "settings_save"`) with the full MERGED settings object (not just the patch), so a later rollback can restore the whole state from one row.
|
|
43
|
+
- **Rollback (`ThemeService.rollbackThemeVersion(versionId, req?, actor?)`, new):** reads the chosen past version's `theme_id`+`settings`, re-activates that theme (a no-op switch if it's already active — `setSiteTheme`'s own upsert semantics), FORCES settings to exactly the snapshot's settings (`setSiteTheme` alone would keep the CURRENT settings when re-activating an already-active theme, which is wrong for a rollback undoing a settings-only change), re-runs the same widget-area reconciliation activation performs, then writes a THIRD kind of version row (`source: "rollback"`) — it never mutates or deletes the version it rolled back to, or any other row. History only ever grows (D59's own "rollback creates a new version, history never rewritten" / "rollback is itself reversible" requirement). Throws the new `ThemeVersionNotFoundError` if `versionId` doesn't resolve to a version belonging to the caller's scope (tenant-isolation boundary, same "scoped lookup returns null/throws across a tenant boundary" convention as `ThemeNotFoundError`).
|
|
44
|
+
- **`ThemeService.listThemeVersions(req?)`** (new) — every version ever written for the caller's scope, newest first; the version-list UI's data source.
|
|
45
|
+
- **Actor attribution:** `activateTheme`/`updateThemeSettings`/`rollbackThemeVersion` all gained a new optional third parameter, `actor?: ThemeActorOpts` (`{ actorType?: ActorType; createdBy?: string | null }`) — purely additive, so every existing two-argument call site keeps compiling unchanged. Omitted = `"human"`/`null`, same default `ActorType`'s own doc-comment documents for every other actor-carrying write in this package (`PostRevision`'s `actor_type`/`created_by` is the direct precedent — see `restoreRevision`'s own `opts` shape, which this mirrors). The HOST (this ticket's platform-side route) is expected to pass the authenticated user's id through.
|
|
46
|
+
- **`is_current`** flags the single most-recent version per scope — APPLICATION-enforced (select-current, flip, insert-new in the new `ThemeVersionRepository.createVersion`), same convention as `hazo_blog_site_files.is_current`, not a DB constraint. It answers "has a later version superseded this one?", not "was this theme active when the row was written" (every row, by construction, snapshots a state that WAS active at write time).
|
|
47
|
+
- **New repository**, `src/repository/theme-versions.ts`: `createThemeVersionRepository(adapter)` → `ThemeVersionRepository` (`createVersion`/`listVersions`/`getVersionById`/`getCurrentVersion`), `ThemeVersionNotFoundError`. New types in `src/types/index.ts`: `BlogSiteThemeVersion`, `ThemeVersionSource` (`"activation" | "settings_save" | "rollback"`), `CreateThemeVersionInput`. All re-exported from the package root (`src/index.ts`) alongside `ThemeActorOpts` (`src/service/themes.ts`) — this is the stable export surface tickets 23 (theme duplicate + export) and 24 (site export as seed, `themeVersions[]`) are expected to build on.
|
|
48
|
+
- **Postgres RLS**: `hazo_blog_site_theme_versions` gets the same strict `scope_id`-equality tenant-isolation policy as `hazo_blog_site_theme`/`hazo_blog_site_files` (scope_id is `NOT NULL` — tenant-owned, same reasoning as those tables).
|
|
49
|
+
- Tests: 6 new cases in `src/__tests__/themes.service.integration.test.ts` against a real SQLite DB — write-on-activate (with actor fields recorded), write-on-settings-save (flips the prior row's `is_current` off), rollback-creates-a-new-version-and-never-mutates-the-old-rows (byte-identical before/after comparison on every pre-existing row), rollback across a tenant boundary throws `ThemeVersionNotFoundError`, `listThemeVersions` is scoped per tenant, and omitted actor opts default to `"human"`/`null`. 928/988 passing (922/982 before this ticket — the same 52 pre-existing, unrelated failures every release since 2.10.0 has carried, unchanged — zero regressions).
|
|
50
|
+
- **Not done in this release (flagged, not silently deferred):** `deactivateTheme` does NOT write a version (deactivating clears the active-theme row entirely rather than snapshotting a "no theme" state — the ticket's own checklist only asked for a version on activation/settings-save/rollback, not deactivation; flagged here as a deliberate scope boundary, not an oversight, since ticket 23/24 may want it later). This package's OWN internal `migrations/db_setup_*.sql` mirror was already stale before this ticket (missing `hazo_blog_widgets` from ticket 19 onward, confirmed pre-existing) — the new table was NOT added there either, to avoid compounding a pre-existing drift this ticket didn't create and wasn't asked to fix; the root `db_setup_sqlite.sql`/`db_setup_postgres.sql` (what every test and the platform's own copied migration actually load) are fully up to date.
|
|
51
|
+
|
|
52
|
+
Bumps 2.25.0 -> 2.26.0 (minor, DDL required — new table, additive, fully backward compatible).
|
|
53
|
+
|
|
54
|
+
## 2.25.0 — 2026-11-21
|
|
55
|
+
|
|
56
|
+
**New built-in theme: "Magazine" — an image-led, tabloid-glossy theme for celebrity/entertainment sites (Phase 2 ticket 21).** No DDL — a new theme folder is additive, picked up by `installBuiltInThemes()`'s own directory scan with no code change (see `src/service/themes.ts`'s header comment), same mechanism Trades/Editorial/starter-light already use. Ships at `themes/magazine/`, installs via the existing built-in installer, and declares the same `sidebar`/`footer` widget areas ticket 05/19 already shipped the fixed widget-type registry for.
|
|
57
|
+
|
|
58
|
+
- **Design brief, and why**, in full in `themes/magazine/partials/styles.liquid`'s own header comment (not repeated here) — summary: a white/near-black canvas (`#FFFFFF`/`#121212`) with a two-accent coral-red/gold pair (`#FF2D55`/`#FFC53D`, genuinely different hue families from Trades' earthy terracotta `#C2714F` and Editorial's cool signal-blue `#2954e0`), "Archivo Black" (uppercase, tightly tracked) over "Karla" body copy — no serif anywhere, deliberately, since a gossip-magazine body reads as sans in every real-world comparable. The one real aesthetic bet: a recurring "cover line" signature (full-bleed image, gradient scrim, oversized heading sitting ON the photo, a coloured category sticker) at three scales — the homepage hero, every post-card, and the article's own cover image — instead of Trades/Editorial's convention of a heading block always sitting BESIDE or ABOVE an image.
|
|
59
|
+
- **Templates**: all 12 D54 section types (`sections/*.liquid`) plus `home`/`post`/`page`/`category`/`tag`/`archive`/`search`/`404` (`templates/*.liquid`), same opt-in `archive`/`search`/`category`/`tag` convention Editorial's own entry documents.
|
|
60
|
+
- **"Category rails" need no new section type or schema field** (D54 fixes the 12 types; themes supply renderers only) — `posts_grid`'s existing `categoryFilter` setting does double duty: blank renders this theme's dense "main image grid" (the homepage's front-page block), set renders the SAME list markup as a horizontally-scrolling rail via a CSS selector keyed off the real `data-category-filter` attribute the section already emits, with the rail's eyebrow label read straight off that same field (an operator-set category slug/name, never a fabricated heading). Same pre-existing engine gap Trades/Editorial's own `posts_grid.liquid` already flags, not newly introduced here: `RenderContext` carries no real "posts in this category/tag/archive" list yet (confirmed again against `render/types.ts` for this ticket — only `post.related`/`post.faq` are pre-resolved host data, nothing category/tag/archive-scoped exists) — `section.settings.items` is never part of `postsGridSettingsSchema`, so every grid/rail renders real structure plus an honest empty state ("Stories will appear here."), never fake sample posts.
|
|
61
|
+
- **Related-posts rail**: the article template places the engine's own `{% related_posts %}` tag (`post.related`, unchanged — ticket 03) inside a `.related-reads` wrapper. That tag only ever emits plain `<a>title</a>` links (`src/render/tags/related-posts.ts`) — it has no image markup even though `RenderRelatedPost` carries an optional `image` field; fixing the shared tag was out of this ticket's scope (engine code every theme uses), so this theme turns the constraint into its own device instead of a broken half-image card: solid colour-block tiles (ink/accent alternating) with the headline in Archivo Black.
|
|
62
|
+
- **Article "hero" image**: `RenderPost` has no dedicated featured-image field (confirmed against `render/types.ts`), so the post template uses `post.seo.ogImage` to stand in for one — the SAME precedent `WidgetService.resolveWidgetAreasForRender`'s own `recent_posts` resolution already set for exactly this gap (`og_image` standing in for a summary image, CHANGE_LOG 2.23.0), not a new workaround invented here. An image-less post falls back to a plain ink header band rather than a broken/empty background.
|
|
63
|
+
- **No table of contents / no code-block styling** — deliberate, not an oversight: unlike Editorial, this theme ships neither. A celebrity-site post is short enough that a sticky TOC would be theatre, not utility, and this theme's brief has nothing to do with code blocks.
|
|
64
|
+
- **Widget areas**: declares `sidebar`+`footer` (`theme.json`) with this theme's own styled renderer partials for all 7 widget types in `WIDGET_TYPE_REGISTRY` (`recent_posts`, `text`, `category_list`, `tag_cloud`, `ad_slot`, `newsletter_placeholder`, `search` — `themes/magazine/widgets/*.liquid`), structurally mirroring Trades/Editorial's partials (same data contract per type) with this theme's own visual design (solid ink chips instead of Editorial's monospace chips or Trades' pill chips).
|
|
65
|
+
- **Starter homepage seed**: `seeds/magazine-homepage-seed.json` (package root, outside the validated theme tree — same `theme-validate.ts` asset-allowlist reasoning Trades/Editorial's own seed comment documents): a cover-story hero, one "main grid" `posts_grid` instance (no `categoryFilter`), two "category rail" `posts_grid` instances (`categoryFilter` set to `celebrity-news`/`royals`), features, stats, cta.
|
|
66
|
+
- **Gallery screenshot**: `themes/magazine/assets/screenshot.svg`, referenced via `theme.json`'s `screenshots` array (the same static-file mechanism Trades/Editorial use). This one is a clearly-labelled PLACEHOLDER mockup (its own `<title>`/`<desc>` say so) — a hand-drawn SVG depicting the cover-line hero/grid/rail layout, not a real render of the theme, same reasoning Editorial's own screenshot entry documents: producing an actual pixel screenshot needs a running render + browser capture this ticket's own tooling doesn't have. The manifest wiring itself (the field, the file, the gallery's ability to serve it) is real and complete; only the image content needs a human to swap in a genuine screenshot before this theme is customer-facing.
|
|
67
|
+
- Tests: 1 updated case in `src/__tests__/builtin-themes.self-reference.test.ts` (`installBuiltInThemes()` now finds `magazine` too, alongside `editorial`/`starter-light`/`trades`), 31 new cases in the new `src/__tests__/builtin-themes.magazine.render.test.ts` — one render test per D54 section type (12, including a dedicated pair distinguishing the "main grid" vs "category rail" readings of `posts_grid`), one per top-level template plus an ogImage/no-ogImage hero pair and an unresolved-type 404-fallback case (11), and one per widget type plus a footer-area case (8). All other existing theme-structural tests (`builtin-themes.validate.test.ts`, `theme-schema.test.ts`, `theme-validate.test.ts`) already iterate every `themes/<handle>/` directory generically and pass against `magazine` with no changes needed. 31 new tests, all passing; full suite unaffected (same pre-existing, unrelated v1.6/v2.0.0 schema-split failures every release since 2.10.0 has carried — 52 failures, unchanged — zero regressions: 891 -> 922 passing, 951 -> 982 total).
|
|
68
|
+
- **Not done in this release (flagged, not silently deferred)**: the gallery screenshot is a placeholder mockup, not a real render (see above); no real "posts in this category/tag/archive" list anywhere in `RenderContext` yet (same pre-existing engine gap Trades/Editorial already flag — confirmed still present, not newly discovered); no search-results resolution (`templates/search.liquid`/`widgets/search.liquid` both emit a form only, same as Editorial); the related-posts rail cannot show images because the shared `{% related_posts %}` tag doesn't render the `image` field it already carries in its own type — flagged as engine-tag scope, not fixed here (fixing it would change shared output every theme uses, out of this ticket's scope); `ogImage`-as-hero-image is a stand-in, not a real featured-image field — the same gap `recent_posts`' own resolution already flagged, not newly introduced.
|
|
69
|
+
|
|
70
|
+
Bumps 2.24.0 -> 2.25.0 (minor, additive — new built-in theme, no DDL).
|
|
71
|
+
|
|
72
|
+
## 2.24.0 — 2026-11-21
|
|
73
|
+
|
|
74
|
+
**New built-in theme: "Editorial" — a long-form, code-friendly reading theme (Phase 2 ticket 20).** No DDL — a new theme folder is additive, picked up by `installBuiltInThemes()`'s own directory scan with no code change (see `src/service/themes.ts`'s header comment), same mechanism Trades/starter-light already use. Ships at `themes/editorial/`, installs via the existing built-in installer, and declares the same `sidebar`/`footer` widget areas ticket 05/19 already shipped the fixed widget-type registry for.
|
|
75
|
+
|
|
76
|
+
- **Design brief, and why**, in full in `themes/editorial/partials/styles.liquid`'s own header comment (not repeated here) — summary: ink-on-paper palette (near-black `#1b1b1f` on warm-white `#fbfaf6`, one signal-blue `#2954e0` accent), a three-font pairing where Trades uses two ("Source Serif 4" for body — a screen-optimised reading serif, not a display serif — "Work Sans" for headings/UI, "IBM Plex Mono" for code), a 40rem content measure at 1.7 line-height (vs Trades' 44rem/1.6 — serif body text benefits from a touch more vertical air at a slightly tighter measure), and a dark code-block surface that deliberately breaks the light page's palette (a common, legible "this is code" convention). Chosen to read unmistakably as a technical-writing/essay blog, not a re-skinned Trades.
|
|
77
|
+
- **Templates**: all 12 D54 section types (`sections/*.liquid`) plus `home`/`post`/`page`/`category`/`tag`/`archive`/`search`/`404` (`templates/*.liquid`) — `archive`/`search` are new opt-in templates (via a page's own `template` override, same mechanism Trades' `about`/`contact`/`privacy`/`terms` already use) since neither is a `resolve.ts` content `type` on its own. `search.liquid`/`widgets/search.liquid` both emit a plain `GET /search?q=` form; no search-results resolution exists anywhere in this engine yet (flagged, not faked) — wiring a real results page is later work.
|
|
78
|
+
- **Code blocks**: syntax highlighting + a copy-to-clipboard button, both **new, small, vanilla-JS** (`partials/scripts.liquid`, included once from `partials/footer.liquid`) — confirmed first that neither this package's render engine nor Trades has ANY code-highlighting mechanism to reuse (checked `src/render/*`, `package.json`'s deps — no shiki/prism/highlight.js anywhere). Deliberately a small regex-based tokenizer (comments/strings/numbers/keywords/function-calls, keyed off the `language-xxx` class a markdown/MDX code-fence pipeline already emits), not a real grammar/parser — pulling in a real highlighter would itself be the "new framework dependency" this ticket's brief rules out. Copies via `navigator.clipboard` with a `document.execCommand` fallback. Runs once on `DOMContentLoaded` over every `pre code` in a post/page body or a text section.
|
|
79
|
+
- **Table of contents**: reuses the engine's own `{% toc %}` tag (`src/render/tags/toc.ts`, unchanged — ticket 03) verbatim in `templates/post.liquid`, styled as a sticky rail on wide viewports. Already only renders for a post with 2+ real `<h2>`/`<h3>` headings, which is exactly this ticket's "long post" condition — no new TOC-generation code was needed, only placement + CSS.
|
|
80
|
+
- **Widget areas**: declares `sidebar`+`footer` (`theme.json`) with this theme's own styled renderer partials for all 7 widget types in `WIDGET_TYPE_REGISTRY` (`recent_posts`, `text`, `category_list`, `tag_cloud`, `ad_slot`, `newsletter_placeholder`, `search` — `themes/editorial/widgets/*.liquid`), structurally mirroring Trades' partials (same data contract per type) with this theme's own visual design (monospace tag chips instead of Trades' pill chips, etc.).
|
|
81
|
+
- **Starter homepage seed**: `seeds/editorial-homepage-seed.json` (package root, outside the validated theme tree — same `theme-validate.ts` asset-allowlist reasoning Trades' own seed comment documents), content-pillar copy for a technical blog: hero, features, posts_grid, stats, cta.
|
|
82
|
+
- **Gallery screenshot**: `themes/editorial/assets/screenshot.svg`, referenced via `theme.json`'s `screenshots` array (the same static-file mechanism Trades uses — confirmed via the platform's own `GET /api/themes/[id]/screenshot` route and `theme-gallery-panel.tsx`: a theme's screenshot is a shipped file path, never rendered live). This one is a clearly-labelled PLACEHOLDER mockup (its own `<title>`/`<desc>` say so) — a hand-drawn SVG, not a real render of the theme, because producing an actual pixel screenshot needs a running render + browser capture this ticket's own tooling doesn't have. The manifest wiring itself (the field, the file, the gallery's ability to serve it) is real and complete; only the image content needs a human to swap in a genuine screenshot before this theme is customer-facing.
|
|
83
|
+
- Tests: 6 new cases in `src/__tests__/builtin-themes.validate.test.ts` (ticket-20 templates present, all 12 section renderers present, required partials present, all 7 widget renderers present, `sidebar`+`footer` widget areas declared, homepage seed valid/outside the theme tree/schema-checks), 1 updated case in `src/__tests__/builtin-themes.self-reference.test.ts` (`installBuiltInThemes()` now finds `editorial` too), 30 new cases in the new `src/__tests__/builtin-themes.editorial.render.test.ts` — one render test per D54 section type (12), one per top-level template plus a short-post no-TOC case and an unresolved-type 404-fallback case (10), and one per widget type plus a footer-area case (8) — exactly the ticket's own "render tests for every section type and every template" requirement. 36 new tests, all passing; full suite unaffected (same pre-existing, unrelated v1.6/v2.0.0 schema-split failures every release since 2.10.0 has carried — 52 failures, unchanged — zero regressions: 855 -> 891 passing, 915 -> 951 total).
|
|
84
|
+
- **Not done in this release (flagged, not silently deferred)**: the gallery screenshot is a placeholder mockup, not a real render (see above — needs a human with a browser to replace it); no real "posts in this category/tag/archive" list anywhere in `RenderContext` yet (same pre-existing engine gap Trades' own category/tag templates already flag — `posts_grid`'s `section.settings.items` loop is real structure over no data until that's wired); no search-results resolution (`templates/search.liquid`/`widgets/search.liquid` both emit a form only); the regex-based syntax highlighter is "good enough to visibly distinguish token classes", not a correct per-language grammar — a nested template literal or an unusual string-escaping edge case can mis-tokenize, acceptable for a visual aid, not acceptable to rely on for anything semantic.
|
|
85
|
+
|
|
86
|
+
Bumps 2.23.0 -> 2.24.0 (minor, additive — new built-in theme, no DDL).
|
|
87
|
+
|
|
88
|
+
## 2.23.0 — 2026-11-21
|
|
89
|
+
|
|
90
|
+
**The five remaining widget types + theme-switch widget-area reconciliation (Phase 2 ticket 19).** No DDL — reuses `hazo_blog_widgets.active` from ticket 05 (2.20.0) rather than adding a new column, per that column's own "an inactive widget is skipped... same soft-disable shape as other on/off flags" doc-comment. This is the BACKEND/RENDER layer — the platform's own commit for this ticket extends `components/widgets-panel.tsx`'s hardcoded per-type settings UI (not schema-driven) and adds its "Inactive widgets" reassignment section; no new API routes were needed there (`GET /api/widgets` already returns every widget regardless of area when `?area=` is omitted, and `PATCH /api/widgets/[id]` already accepts `area`+`active` together).
|
|
91
|
+
|
|
92
|
+
- **Five new `WIDGET_TYPE_REGISTRY` entries** (`src/lib/widgets.ts`): `category_list` (`title`, `limit` 1-50, default 20), `tag_cloud` (`title`, `limit` 1-100, default 30), `ad_slot` (`title`, `code` — a trusted, operator-authored ad-network embed snippet, rendered UNESCAPED by the theme partial, same "service stores, render boundary trusts it" convention `SiteFileService`'s `custom_css` already uses), `newsletter_placeholder` (`title`, `description`, `buttonLabel`; ships as a non-functional visual placeholder only — no subscription backend/provider integration in this release, flagged plainly in the Trades partial's own header comment), `search` (`title`, `placeholder`, `action` — emits a plain GET form only; no search-results page/section exists anywhere in this package yet, resolving `action` to something real is the host's job). `WIDGET_TYPES` now lists all seven.
|
|
93
|
+
- **`WidgetService.resolveWidgetAreasForRender`** (`src/service/widgets.ts`) resolves `category_list`/`tag_cloud` from the content DB the same way `recent_posts` already does — `ResolvedWidgetInstance.categories`/`.tags` (new fields, `src/types/index.ts`; mirrored, deliberately duplicated per this file's own isolation-boundary convention, onto `RenderWidgetInstance.categories`/`.tags` in `src/render/types.ts`), each entry `{ id, name, slug, url }`. Category URLs go through `config.menus?.resolveReferenceUrl` (type `"category"`, same as menus) falling back to `/category/{slug}`; tag URLs are a plain local `/tag/{slug}` convention — tags have no `MenuItemRefType` of their own yet, so there's no override hook for a host wanting a different tag URL shape (flagged, not silently worked around). `ad_slot`/`newsletter_placeholder`/`search` need no DB resolution at all — their `settings` pass through unchanged, same as `text`.
|
|
94
|
+
- **`WidgetRepository.deactivateWidgetsOutsideAreas(areaNames)`** (`src/repository/widgets.ts`) — the theme-switch reconciliation primitive: flips every currently-active widget in scope whose `area` isn't in `areaNames` to `active: false`; a widget whose area IS in `areaNames` is never touched (so a widget that was already manually deactivated inside a still-existing area is never silently reactivated by a switch), and an already-inactive widget outside `areaNames` is left alone (idempotent). Returns the widgets it just flipped.
|
|
95
|
+
- **`ThemeService.activateTheme`** (`src/service/themes.ts`) now calls `deactivateWidgetsOutsideAreas` with the newly-activated theme's `themeJson.widgetAreas` names right after persisting the site-theme row — implements the ticket's own rule exactly as specified: "instances whose area exists in the newly-activated theme's manifest stay active (same area, same position); instances in an area that doesn't exist in the new theme become inactive." This is deliberately ONE-DIRECTIONAL: switching back to a theme that re-declares a now-existing area does NOT auto-reactivate a widget that was deactivated by an earlier switch — recovery is manual, via the existing `updateWidget(id, { area, active: true })` admin path (reassigning an inactive widget to a different, now-existing area reactivates it; no bespoke "reactivate" API was needed).
|
|
96
|
+
- **Trades theme** ships default renderer partials for all five new types (`themes/trades/widgets/{category_list,tag_cloud,ad_slot,newsletter_placeholder,search}.liquid`) plus matching CSS in `partials/styles.liquid` (`.widget-category-list__list`, `.tag-chip`/`.widget-tag-cloud__list`, `.widget-ad-slot__placeholder`, `.widget-newsletter__*`, `.widget-search__*`). No `theme.json` change — these are new widget TYPES droppable into Trades' existing `sidebar`/`footer` areas, not new areas.
|
|
97
|
+
- Tests: 15 new cases in `src/__tests__/widgets.test.ts` (registry count, all 7 types' `isKnownWidgetType`, `validateWidgetSettings` valid/default/range-boundary for each of the 5 new types), 4 new cases in `src/__tests__/widgets.repository.integration.test.ts` (`deactivateWidgetsOutsideAreas` — non-matching active widget deactivated, matching-area widget untouched, idempotent against an already-inactive widget, a manually-deactivated-but-still-matching-area widget is never reactivated, tenant isolation), 7 new cases in `src/__tests__/widgets.service.integration.test.ts` (real SQLite — `category_list`/`tag_cloud` resolve real scoped DB rows including the `limit` setting and URL shape, `ad_slot`/`newsletter_placeholder`/`search` settings pass through unchanged with no extra DB query), 2 new cases in `src/__tests__/themes.service.integration.test.ts` (full theme-switch round trip: matching area survives, non-matching area goes inactive, switching back doesn't auto-reactivate, reassignment via `updateWidget` reactivates and the widget then resolves in its new area; a theme declaring zero widget areas deactivates everything), 5 new cases in `src/__tests__/render.widget-area.test.ts` (one per new type, through `renderTemplate`, including the `ad_slot` unescaped-code case). 33 new tests, all passing; full suite unaffected (same pre-existing, unrelated v1.6/v2.0.0 schema-split failures every release since 2.10.0 has carried — 52 failures, unchanged — zero regressions, +33 passing… actual net package total shows +23 due to the same jest path-pattern-overlap effect 2.21.0's entry already flagged for `revisions.test.ts`; the full, unfiltered suite run is the number that matters: 832 -> 855 passing, 892 -> 915 total, same 52 failures/8 skipped before and after).
|
|
98
|
+
- **Not done in this release (flagged, not silently deferred)**: no admin "Inactive widgets" UI, no per-type settings form beyond `recent_posts`/`text` in the admin editor — BlogSketch platform repo's own commit for this ticket (`components/widgets-panel.tsx` is NOT schema-driven, it hardcodes a settings form per type, so the platform repo's commit extends it directly rather than this package growing a generic settings-form renderer); `ad_slot`'s `code` has no sanitization/CSP guardrail of any kind — it is rendered exactly as an operator typed it, same trust model as `custom_css`, not revisited here; `search` ships no results page anywhere; `newsletter_placeholder` has no provider integration (Mailchimp/ConvertKit/etc.) — genuinely a placeholder, as named; `tag_cloud` does no per-tag post-count weighting (every chip is the same size) since the resolver doesn't compute post counts per tag.
|
|
99
|
+
|
|
100
|
+
Bumps 2.22.0 -> 2.23.0 (minor, additive — new widget types + theme-switch logic, no DDL).
|
|
101
|
+
|
|
102
|
+
## 2.22.0 — 2026-11-21
|
|
103
|
+
|
|
104
|
+
**⚠️ DDL required (additive column, nullable, no backfill needed) — publishing calendar data layer (Phase 2 ticket 07): `target_date` on `hazo_blog_posts`, a multi-scope-capable calendar query, and a dedicated reschedule entry point.** This is the DATA/QUERY layer — the admin Calendar page (month/week/list views, drag-to-reschedule UI, filters) ships in the BlogSketch platform repo's own commit for this ticket, same "backend here, UI there" split as every prior Phase 1b/2 ticket's entry.
|
|
105
|
+
|
|
106
|
+
- **`target_date` column on `hazo_blog_posts`** (both dialect files) — an editor's own "aiming to publish by" date for a draft, distinct from `publish_at` (the actual scheduled/auto-publish time this package's auto-publish worker acts on). Nullable, no backfill needed. Purely informational: nothing in this package reads it to drive auto-publish or any status transition, and it is never cleared automatically by a later schedule/publish — see the column's own doc-comment in `db_setup_*.sql`/`Post.target_date` (`src/types/index.ts`) for the full reasoning. `CreatePostInput.target_date`/`UpdatePostInput.target_date` (optional, same "omitted = unchanged, `null` clears it" convention as `publish_at`).
|
|
107
|
+
- **`findPostsForCalendar(adapter, scopeIds: string[], range: CalendarDateRange, filter?: CalendarQueryFilter): Promise<CalendarEntry[]>`** (`src/repository/posts.ts`, exported from the main entry) — the calendar's one query, deliberately `scopeIds: string[]` from day one: Phase 2 ticket 07 (single-site) calls it with exactly one scope; the cross-site calendar (ticket 26, per the platform's own spec — "the platform always passes an explicit scope list built from membership, no new cross-scope query exists inside the packages") calls this SAME function with the caller's full membership list, never a separate/parallel query. A post matches the range if ANY of its three calendar dates (`publish_at`/`published_at`/`target_date`) falls inside it (inclusive both ends) — which date is the meaningful one for a given row depends on `status`; this function reports all three and lets the caller render accordingly, it doesn't pick. Excludes trashed posts. Optional `filter.status`/`filter.bylineId`/`filter.categoryId` narrow the result, same filter shape the ticket's own "filters for status, author, category" story asks for. Each `CalendarEntry` carries the resolved `category`/`bylines`, batch-resolved the same way `listPostsForAdmin` already does (one extra query each, not one per row), generalized to a list of scopes.
|
|
108
|
+
- **`PostService.reschedulePost(id, { publish_at, expectedRev }, req?)`** (`src/service/posts.ts`) — the drag-to-reschedule calendar action's ONE entry point, so the platform's UI never needs (and must never use) a raw DB update to move a post's date: internally it goes through the exact same `_rev`-guarded `updatePost` write path as every other save (same `before:save`/`after:save` hooks, same revision snapshot, same `PostConflictError` on a stale `expectedRev`), after one extra check this ticket specifically asked for — **refuses with the new `PostRescheduleRefusedError` when the post is already `'published'` or `'trashed'`**. That refusal lives on this entry point specifically, not as a blanket rule inside `updatePost` itself — a legitimate edit to a published post's OTHER fields (title, body, SEO, …) must never be blocked by it. Does not itself change `status`; moving a draft into the scheduled lane for the first time is still `setStatus(id, 'scheduled')`, a separate call, same as before this ticket.
|
|
109
|
+
- New types exported from the main entry: `CalendarDateRange`, `CalendarQueryFilter`, `CalendarEntry`, `ReschedulePostInput`, `PostRescheduleRefusedError`.
|
|
110
|
+
- Tests: 11 new cases in `src/__tests__/posts.repository.integration.test.ts` (`findPostsForCalendar` — real SQLite: range-boundary inclusivity at both ends, publish_at/published_at/target_date each independently matching, outside-range exclusion, trashed-post exclusion, multi-scope cross-tenant correctness (each entry keeps its OWN `scope_id`), empty-scope-list short-circuit, and the status/categoryId/bylineId filters including category/byline resolution on the result), `src/__tests__/posts.service.reschedule.test.ts` (7 cases, real SQLite — reschedule goes through the same before:save/after:save hooks as updatePost, reschedules a `scheduled` post without touching `status`, refuses a `published` post, refuses a `trashed` post, `PostNotFoundError`/`PostConflictError` parity with `updatePost`, `publish_at: null` clears). 18 new tests, all passing; full suite unaffected (same pre-existing, unrelated v1.6/v2.0.0 schema-split failures every release since 2.10.0 has carried — 52 failures, unchanged — zero regressions, +18 passing).
|
|
111
|
+
- **Not done in this release (flagged, not silently deferred)**: no admin Calendar page (month/week/list views, drag-and-drop UI, filter controls) — BlogSketch platform repo's own commit for this ticket; no timezone conversion anywhere in this package — `CalendarDateRange.from`/`.to` are plain UTC ISO instants, and resolving "the month in the site's timezone" to that range is entirely the platform's job (the platform already stores a per-site IANA timezone in `SiteIdentity.timezone`, see `src/lib/site-identity.ts` — unchanged by this release); `target_date` has no UI yet in the post editor (platform's own commit); no DB-level constraint ties `target_date` to `status === 'draft'` — it is settable/readable regardless of status, deliberately (see the column's own doc-comment) rather than enforced, since nothing downstream needs it enforced at the DB layer.
|
|
112
|
+
|
|
113
|
+
Bumps 2.21.0 -> 2.22.0 (minor, additive DDL with safe default — see ⚠️ heading above).
|
|
114
|
+
|
|
115
|
+
## 2.21.0 — 2026-11-21
|
|
116
|
+
|
|
117
|
+
**⚠️ DDL required (additive columns, safe defaults, no backfill needed) — revision-history diff/summary/restore layer (Phase 2 ticket 06).** This is the SERVICE/DATA layer — the admin "History" drawer (timeline, pick-two-and-diff, restore button) ships in the BlogSketch platform repo's own commit for this ticket, same "backend here, UI there" split as every prior Phase 1b/2 ticket's entry.
|
|
118
|
+
|
|
119
|
+
- **Four new columns on `hazo_blog_revisions`** (both dialect files): `actor_type TEXT NOT NULL DEFAULT 'human'` (who/what made the save — `human`/`agent`/`job`; the DEFAULT alone backfills every pre-existing revision, no migration script needed), `is_conflict` (SQLite `INTEGER`/Postgres `BOOLEAN`, `DEFAULT 0`/`FALSE`), `category_id TEXT` and `tags` (SQLite `TEXT`/Postgres `JSONB`, `DEFAULT '[]'`) — see each column's own comment in `db_setup_*.sql` for the reasoning. `category_id`/`tags` close a real gap in D29's "full snapshot" promise: the revisions table never captured a post's category/tags at all before this release, so a revision-history metadata diff had nothing to compare them against.
|
|
120
|
+
- **`diffRevisionBody`/`diffRevisionWords`/`diffRevisionMetadata`/`summarizeRevisionChange`/`isConflictRevision`** (`src/lib/revisions.ts`, exported via `./lib` and the main `.` entry, alongside the pre-existing `hasPendingChanges`) — pure, server/client-neutral. `diffRevisionBody` is a classic LCS line-diff plus paragraph-level add/remove/change counts; `diffRevisionMetadata` compares title/slug/SEO fields/category/tags (tags by id-set, order-independent); `summarizeRevisionChange` turns both into one deterministic, RULE-BASED sentence (e.g. "Edited 3 paragraphs, changed title") — **no LLM call**, same diff in always produces the same string out (asserted directly in `revisions.test.ts`).
|
|
121
|
+
- **`PostRepository.restoreRevision(id, revisionId, opts?)`** (`src/repository/posts.ts`) — restoring an old revision is modelled as "stage this old content as my new current edit": creates a brand-new revision row (old content, carried-over `category_id`/`tags` snapshot), bumps `_rev`, and points `draft_revision_id` at it — `live_revision_id` is **never** touched, and the chosen old revision row is never mutated. Throws `PostNotFoundError`/the new `RevisionNotFoundError` (cross-post and cross-tenant revision ids both rejected, never distinguished). Does **not** re-link `hazo_blog_post_tags` to match the restored snapshot — tags shown in a restored revision are historical record, not a live re-assignment; flagged as a known limitation, not silently worked around.
|
|
122
|
+
- **`PostService.listRevisionsWithSummaries`/`compareRevisions`/`restoreRevision`** (`src/service/posts.ts`) — `listRevisionsWithSummaries` pairs each revision with a one-line summary diffed against its own predecessor (oldest revision always reads `"Initial version"`); `compareRevisions` runs the full body+metadata diff between any two of a post's revisions (distinct from the older, shallow `compareDraftAndLive`, which only ever compares the current live/draft pair); `restoreRevision` goes through the same `before:save`/`after:save` hooks as `createPost`/`updatePost` (a restore reverting a slug still fires the auto-redirect SEO hook). All three are exported via the main `.` entry.
|
|
123
|
+
- **U6 conflict flagging**: `PostRepository.updatePost`'s `_rev`-guarded conditional update already inserted a revision row BEFORE checking the guard (existing behaviour, by design — U6: "both versions saved as revisions"), but the losing save's orphaned revision had no way to be IDENTIFIED as a conflict afterwards. `updatePost` now flags that exact row `is_conflict: true` right before throwing `PostConflictError`, so `isConflictRevision()`/the new `is_conflict` field let an admin UI label it in a timeline. **Flagged plainly**: this is the ONLY conflict-detection mechanism that exists anywhere in this package or the BlogSketch platform — there is no separate merge/reconciliation UI, no diff-against-the-conflicting-version helper beyond the generic `compareRevisions`, and no change to the existing reject-and-reload behaviour (`PostConflictError` → 409 → the platform's own reload prompt). This release only makes the already-existing orphan revision visible/labellable; it does not add new conflict-detection logic beyond that.
|
|
124
|
+
- `ActorType` (`"human" | "agent" | "job"`) and `PostRevision.actor_type`/`.is_conflict`/`.category_id`/`.tags` (`src/types/index.ts`), plus `CreatePostInput.actor_type`/`UpdatePostInput.actor_type` (optional, default `"human"`). New result types `PostRevisionWithSummary`, `RevisionCompareResult`.
|
|
125
|
+
- Tests: `src/__tests__/revisions.test.ts` (25 cases, pure — body/word/metadata diffs, determinism of `summarizeRevisionChange` asserted by calling it twice on the same input, pluralization, `hasPendingChanges`/`isConflictRevision`), 14 new cases in `src/__tests__/posts.repository.integration.test.ts` (real SQLite — `actor_type` default/override/DB-default-backfill, `is_conflict` flagging on a real stale-`expectedRev` conflict with a same-scope positive control, `category_id`/`tags` snapshotting across saves including immutability of earlier snapshots, `restoreRevision` end-to-end incl. not-found/cross-post/cross-tenant rejections). 39 new tests, all passing; full suite unaffected (same pre-existing, unrelated v1.6/v2.0.0 schema-split failures every release since 2.10.0 has carried — 52 failures, unchanged — zero regressions, +39 passing… net package total shows +33 due to an unrelated jest path-pattern overlap between `revisions.test.ts` and the pre-existing `routes.post-revisions.test.ts` encountered while spot-checking a subset run; the full, unfiltered suite run is the number that matters and is what's reported here).
|
|
126
|
+
- **Not done in this release (flagged, not silently deferred)**: no admin "History" drawer UI, no new platform API routes — BlogSketch platform repo's own commit for this ticket; no `next/post-routes.ts` route-factory parity for add-on mode (GoTimer/kinstripe) — the platform's own routes call `PostService` directly, same pattern `compare`/`publish`/`discard` already established, and add-on-mode route factories for this specific capability are a follow-up, not asked for by this ticket; restoring a revision does not re-link `hazo_blog_post_tags` (see `restoreRevision`'s entry above); no UI/mechanism to turn a flagged conflict revision into an actual three-way merge — U6 explicitly defers that ("upgrade to auto-merge later if conflicts become common").
|
|
127
|
+
|
|
128
|
+
Bumps 2.20.0 -> 2.21.0 (minor, additive DDL with safe defaults — see ⚠️ heading above).
|
|
129
|
+
|
|
130
|
+
## 2.20.0 — 2026-11-21
|
|
131
|
+
|
|
132
|
+
**⚠️ DDL required (new table) — widget areas (Phase 2 ticket 05): theme-declared named widget areas, a fixed widget-TYPE registry (`recent_posts`/`text`), a new `hazo_blog_widgets` instance table, and the `{% widget_area %}` Liquid tag.** This is the BACKEND/RENDER layer — the admin "Appearance → Widgets" editor (add/edit/reorder/remove) ships in the BlogSketch platform repo's own commit for this ticket, same "backend here, UI there" split as 2.15.0/2.16.0's theme-management/site-identity entries.
|
|
133
|
+
|
|
134
|
+
- **`ThemeJson.widgetAreas: WidgetAreaDefinition[]`** (`src/types/index.ts`, `src/lib/theme-schema.ts`) — a theme's `theme.json` declares its own named areas (`{ name, label }`), e.g. the Trades theme now declares `sidebar`/`footer`. Optional, defaults to `[]` — a theme that declares none simply has no "Widgets" areas to manage, same "optional, degrades to nothing" shape as `allowedSections`. Drives the admin editor's area picker; the Liquid tag itself doesn't consult this field at all (it just looks up whatever area name it's given — see below).
|
|
135
|
+
- **New table** `hazo_blog_widgets` (both dialect files, strict Postgres RLS policy — `scope_id` NOT NULL, same shape as `hazo_blog_menus`/`hazo_blog_site_theme`/`hazo_blog_site_files`): `id`, `scope_id`, `area`, `type`, `position`, `settings` (JSON/JSONB), `active`, `created_at`, `updated_at`. One widget INSTANCE per row, ordered within its own `(scope_id, area)` by `position` — not globally, same scoped-ordering convention as `hazo_blog_menu_items.position`.
|
|
136
|
+
- **`WIDGET_TYPE_REGISTRY`** (`src/lib/widgets.ts`, exported via `./lib` and the main `.` entry) — a FIXED, engine-defined registry, deliberately NOT theme-extensible (a theme only ever supplies a RENDERER for a type this registry already knows, never a new type). Ships exactly the two types this ticket specifies: `recent_posts` (`title`, `count` 1-20) and `text` (`title`, `content`). `validateWidgetSettings(type, settings)` validates+coerces against a type's Zod schema (or throws the new `WidgetValidationError` for an unknown type), same "validated+coerced, every issue collected" contract as `../lib/sections.ts`'s `validateSections`.
|
|
137
|
+
- **`createWidgetRepository`/`createWidgetService`** (`src/repository/widgets.ts`/`src/service/widgets.ts`, exported via the main entry) — CRUD + per-area ordering (`listWidgetsByArea`, `reorderWidgets`), mirroring `./menus.ts`'s shape exactly (same tenant-scoping, same "ignore ids that don't belong to this area" reorder convention, same not-found error style via the new `WidgetNotFoundError`). `createWidget`/`updateWidget` validate `settings` against the widget's `type` schema before the row is ever written; omitted `settings` on create falls back to the type's own `defaultSettings()` (richer, immediately-previewable placeholder content — e.g. recent_posts' `{ title: "Recent posts", count: 5 }` — not the schema's bare per-field defaults, which only apply to a PARTIAL explicitly-supplied settings object). A widget's `type` is fixed at creation and never re-assignable via `updateWidget` — swapping types is "remove one, add the other."
|
|
138
|
+
- **`WidgetService.resolveWidgetAreasForRender(req?)`** — the render-integration bridge, same shape as `MenuService.resolveAllMenusForRender`: resolves every ACTIVE widget in scope, grouped by area, render-ready. A `recent_posts` instance gets its actual post list resolved from the content DB here (query, not inside the Liquid tag — `./render`'s own "no db/fs/network from inside a template" contract), mapped onto `{ title, slug, url, excerpt: null, image: post.og_image }` (the v2 `Post` row carries no `excerpt`/dedicated featured-image column — `excerpt` lives on `PostRevision`, fetching it per-post for a widget wasn't worth an extra DB round-trip per post, so `og_image` stands in for the summary image and `excerpt` is left `null`; flagged, not silently worked around). Returns `ResolvedWidgetInstance`/`ResolvedWidgetPost` (`src/types/index.ts`) — structurally identical to, but deliberately NOT imported from, `hazo_blog/render`'s own `RenderWidgetInstance`/`RenderWidgetPost`, same "the two type sets stay duplicated across the `./render` isolation boundary" convention `ResolvedMenuItem`/`RenderMenuItem` already established for menus.
|
|
139
|
+
- **`{% widget_area "name" %}`** (`src/render/tags/widget-area.ts`, registered in `registerPlatformTags`) — iterates `widgets[name]` (already resolved, position-ordered) and renders each instance through the active theme's `widgets/{type}.liquid` partial via `this.liquid.renderFile()`, same "also renders a nested template file" shape as `{% section_list %}`. **An unknown widget type or a theme with no renderer for a known type renders NOTHING for that one widget and logs a warning (`hazo_logs`, `"hazo_blog:widget-area"`) — never throws, never breaks the surrounding page** (this ticket's own explicit contract; unlike `{% section_list %}`'s visible fallback card, a misconfigured/stale widget degrades silently-but-loudly-logged). `RenderContext.widgets?: Record<string, RenderWidgetInstance[]> | null` (`src/render/types.ts`) is the new context field; an area used by a template but absent/`[]` here simply renders nothing, same convention as `menus`.
|
|
140
|
+
- **Trades theme** now declares `sidebar`/`footer` in `theme.json` and ships real `widgets/recent_posts.liquid`/`widgets/text.liquid` partials (looping the resolved `widget.posts` through the existing `partials/post-card.liquid`, same post-summary shape `sections/posts_grid.liquid` already expects). `templates/post.liquid` wires `{% widget_area "sidebar" %}` into a new two-column `post-layout` (CSS added to `partials/styles.liquid`); `partials/footer.liquid` wires `{% widget_area "footer" %}` into the existing footer chrome.
|
|
141
|
+
- Tests: `src/__tests__/widgets.test.ts` (11 cases — registry + `validateWidgetSettings`, pure), `src/__tests__/widgets.repository.integration.test.ts` (20 cases, real SQLite — CRUD, type/settings validation, per-area ordering + reorder, tenant isolation), `src/__tests__/widgets.service.integration.test.ts` (7 cases, real SQLite — `resolveWidgetAreasForRender`'s real `recent_posts` DB query against published-only posts, `count` setting, inactive exclusion, grouping, tenant isolation), `src/__tests__/render.widget-area.test.ts` (9 cases — 0/1/multiple widgets, area isolation, real theme partial, and BOTH the unknown-type and missing-renderer "renders nothing, logs once, never throws" cases, `hazo_logs` mocked per `posts.service.media-usage.test.ts`'s convention), plus 2 new cases in `src/__tests__/theme-schema.test.ts` for `widgetAreas` validation (invalid shapes rejected; the existing "accepts"/"fills in defaults" cases were extended with `widgetAreas` assertions rather than duplicated). 49 new tests, all passing; full suite unaffected (same pre-existing, unrelated v1.6/v2.0.0 schema-split failures every release since 2.10.0 has carried — 52 failures, unchanged — zero regressions, +49 passing).
|
|
142
|
+
- **Not done in this release (flagged, not silently deferred)**: no admin "Appearance → Widgets" UI (platform repo's own commit for this ticket, per the usual split); only `recent_posts`/`text` ship — later tickets (19/20/21) add more types to `WIDGET_TYPE_REGISTRY`, never by letting a theme declare its own; no rollback/versioning for widget settings (unlike `hazo_blog_site_files`, a widget's `settings` is a plain in-place update — no history kept, not asked for here); `recent_posts`' resolved post list has no category/tag filter setting (the ticket's own two-type settings list doesn't ask for one — ticket 19 can add it without any DDL change, just a new settings field + registry schema update).
|
|
143
|
+
|
|
144
|
+
## 2.19.0 — 2026-11-21
|
|
145
|
+
|
|
146
|
+
**⚠️ DDL required (optional column) — closes the "no update path" gap the seed loader's own docs have flagged since Phase 1b ticket 10: categories and tags now have a real update API, categories gain a parent for WordPress-style hierarchy, and site files gain an `ads_txt` kind.** Prefactor for Phase 2 ticket 01 (the platform repo's own seed-loader/seed-format ticket) and, downstream, the WordPress importer — both this package's and the platform's commits for this ticket ship together.
|
|
147
|
+
|
|
148
|
+
- **`BlogRepository.updateCategory(id, input)`** (`src/repository/index.ts`) — genuinely updates `name`/`description`/`colour`/`parent_id` on an existing category (only supplied fields change). Throws the new `BlogCategoryNotFoundError` for an unknown/out-of-scope id. Previously there was no update primitive at all here — `getOrCreateCategory` is find-or-create only — which is exactly why the platform's seed loader's `onConflict: "update"` degraded to `"skip"` + a warning for categories (documented in the platform repo's `design/specs/seed-format.md` since ticket 10).
|
|
149
|
+
- **`BlogCategory.parent_id?: string | null`** (`src/types/index.ts`) and matching DDL — `hazo_blog_categories.parent_id TEXT DEFAULT NULL` (both dialect files, `ALTER TABLE ... ADD COLUMN IF NOT EXISTS` for Postgres, inline in the `CREATE TABLE` for SQLite, same convention as the `locale` column), plus a non-unique index on `parent_id`. No FK (same convention as every other optional/legacy cross-table reference in this package). `null`/omitted = top-level category, fully back-compat with every existing row and caller. This is the one piece of genuinely NEW DDL in this release — everything else below reuses existing free-text/JSON columns.
|
|
150
|
+
- **`TagRepository.updateTag(id, input)`** (`src/repository/tags.ts`) — genuinely updates a tag's `name`. Throws the existing `TagNotFoundError` for an unknown/out-of-scope id. Same gap as categories, fixed the same way; tags have no `description`/parent concept (WordPress tags, unlike categories, are never hierarchical), so this is `name`-only.
|
|
151
|
+
- **`SiteFileKind` widened to `"custom_css" | "ads_txt"`** (`src/types/index.ts`), plus `SiteFileService.getAdsTxt`/`updateAdsTxt` (`src/service/site-files.ts`, mirroring `getCustomCss`/`updateCustomCss` byte-for-byte, including a `MAX_ADS_TXT_BYTES` (64 KiB) cap and a new `AdsTxtTooLargeError`). No DDL — `hazo_blog_site_files.kind` was already free-text specifically so a future per-site file like this could reuse the mechanism (see that column's own doc-comment from ticket 09). Lets the platform's seed loader persist an imported site's ads.txt body and, later (ticket 16), serve it at `/ads.txt`.
|
|
152
|
+
- New types exported from the main entry: `UpdateCategoryInput`, `UpdateTagInput`, `BlogCategoryNotFoundError`, `AdsTxtTooLargeError`, `MAX_ADS_TXT_BYTES`. (`BlogCategoryNotFoundError` is deliberately NOT named `CategoryNotFoundError` — that name is already taken by `./repository/posts.ts`'s own, unrelated v2 "post's `category_id` doesn't resolve" error; the two are easy to confuse by name alone but guard different tables/call sites.)
|
|
153
|
+
- Tests: 2 new cases in `src/__tests__/repository.integration.test.ts` (`updateCategory` — genuine update of all four fields including clearing `parent_id` back to `null`, public read-after-write via `listCategories()`; not-found throws `BlogCategoryNotFoundError`), 2 new cases in `src/__tests__/tags.repository.integration.test.ts` (`updateTag` — genuine update, public read-after-write via `getTagById()`; not-found throws `TagNotFoundError`), 4 new cases in `src/__tests__/site-files.service.integration.test.ts` (`getAdsTxt`/`updateAdsTxt` — round-trip, independent of `customCss`'s own kind, size cap, tenant isolation). 8 new tests, all passing; full suite unaffected (same pre-existing, unrelated v1.6/v2.0.0 schema-split failures every release since 2.10.0 has carried — verified unchanged via a scoped `git stash push -- <this release's files>` before/after comparison — zero regressions, +8 passing).
|
|
154
|
+
- **Not done in this release**: no category-hierarchy UI (admin category picker, nested rendering) — this release is the DATA primitive only, same "backend layer now, UI later" split as 2.16.0's site-identity/custom-CSS entry; no admin UI or `/ads.txt` route for the new `ads_txt` site file kind (platform repo's own ticket 16); FAQ-per-post and imported-redirect-source-marker needed NO change here at all — FAQ already round-trips through the existing `faq` section type + `sections_json` (D54), and redirect provenance already had a `source` field from ticket 10 — both are handled entirely in the platform repo's seed-format/seed-loader commit for this ticket.
|
|
155
|
+
|
|
156
|
+
Bumps 2.18.0 -> 2.19.0 (minor, new optional DDL — see ⚠️ heading above).
|
|
157
|
+
|
|
6
158
|
## 2.18.0 — 2026-11-09
|
|
7
159
|
|
|
8
160
|
**Additive — folded the standalone `hazo_blog_themes` package (ticket 07's "Trades" + "Starter Light" built-in themes) directly into this package, to keep the `hazo_*` package count minimal.** No DDL, no breaking change to any documented export.
|
package/db_setup_postgres.sql
CHANGED
|
@@ -17,10 +17,18 @@ CREATE TABLE IF NOT EXISTS hazo_blog_categories (
|
|
|
17
17
|
description TEXT NOT NULL DEFAULT '',
|
|
18
18
|
colour TEXT NOT NULL DEFAULT '#3B82F6',
|
|
19
19
|
locale TEXT DEFAULT NULL, -- BCP-47 locale; NULL = default locale
|
|
20
|
+
-- Parent category id (Phase 2 ticket 01) — WordPress-style category
|
|
21
|
+
-- hierarchy, needed by the WP/Divi importer. No FK (same convention as
|
|
22
|
+
-- every other optional/legacy cross-table reference in this package).
|
|
23
|
+
-- NULL = top-level category.
|
|
24
|
+
parent_id TEXT DEFAULT NULL,
|
|
20
25
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
21
26
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
22
27
|
);
|
|
23
28
|
ALTER TABLE hazo_blog_categories ADD COLUMN IF NOT EXISTS locale TEXT DEFAULT NULL;
|
|
29
|
+
ALTER TABLE hazo_blog_categories ADD COLUMN IF NOT EXISTS parent_id TEXT DEFAULT NULL;
|
|
30
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_blog_categories_parent_id
|
|
31
|
+
ON hazo_blog_categories (parent_id);
|
|
24
32
|
-- FR-034: locale-aware uniqueness. DROP+CREATE is idempotent and safe to
|
|
25
33
|
-- always include. COALESCE(locale, '') folds NULL (default locale) into one
|
|
26
34
|
-- bucket so two default-locale rows can't collide with Postgres's
|
|
@@ -105,7 +113,11 @@ CREATE TABLE IF NOT EXISTS hazo_blog_posts (
|
|
|
105
113
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
106
114
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
107
115
|
published_at TIMESTAMPTZ,
|
|
108
|
-
publish_at TIMESTAMPTZ
|
|
116
|
+
publish_at TIMESTAMPTZ,
|
|
117
|
+
-- Target date (Phase 2 ticket 07) — see the matching column comment in
|
|
118
|
+
-- db_setup_sqlite.sql for the full reasoning (purely informational,
|
|
119
|
+
-- never drives auto-publish/status, not DB-coupled to `publish_at`).
|
|
120
|
+
target_date TIMESTAMPTZ
|
|
109
121
|
);
|
|
110
122
|
-- Phase 1a issue 07: add `status` to a pre-2.2.0 hazo_blog_posts table.
|
|
111
123
|
-- NOT NULL + DEFAULT backfills existing rows to 'draft' in the same
|
|
@@ -122,6 +134,11 @@ ALTER TABLE hazo_blog_posts ADD COLUMN IF NOT EXISTS category_id TEXT;
|
|
|
122
134
|
-- `[]` in the same statement — idempotent, same pattern as `status`/
|
|
123
135
|
-- `category_id` above.
|
|
124
136
|
ALTER TABLE hazo_blog_posts ADD COLUMN IF NOT EXISTS sections_json JSONB NOT NULL DEFAULT '[]'::jsonb;
|
|
137
|
+
-- ⚠️ DDL required (v2.22.0) — add `target_date` to a pre-2.22.0
|
|
138
|
+
-- hazo_blog_posts table. Nullable, no backfill needed (NULL = no target
|
|
139
|
+
-- date set, correct default for every pre-existing row) — idempotent, same
|
|
140
|
+
-- pattern as `category_id`/`sections_json` above.
|
|
141
|
+
ALTER TABLE hazo_blog_posts ADD COLUMN IF NOT EXISTS target_date TIMESTAMPTZ;
|
|
125
142
|
|
|
126
143
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_hazo_blog_posts_scope_slug_locale
|
|
127
144
|
ON hazo_blog_posts (scope_id, slug, COALESCE(locale, ''));
|
|
@@ -133,6 +150,8 @@ CREATE INDEX IF NOT EXISTS idx_hazo_blog_posts_deleted_at
|
|
|
133
150
|
ON hazo_blog_posts (deleted_at);
|
|
134
151
|
CREATE INDEX IF NOT EXISTS idx_hazo_blog_posts_publish_at
|
|
135
152
|
ON hazo_blog_posts (publish_at);
|
|
153
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_blog_posts_target_date
|
|
154
|
+
ON hazo_blog_posts (target_date);
|
|
136
155
|
CREATE INDEX IF NOT EXISTS idx_hazo_blog_posts_category_id
|
|
137
156
|
ON hazo_blog_posts (category_id);
|
|
138
157
|
CREATE INDEX IF NOT EXISTS idx_hazo_blog_posts_search
|
|
@@ -154,11 +173,40 @@ CREATE TABLE IF NOT EXISTS hazo_blog_revisions (
|
|
|
154
173
|
og_image TEXT,
|
|
155
174
|
noindex BOOLEAN NOT NULL DEFAULT FALSE,
|
|
156
175
|
canonical_override TEXT,
|
|
176
|
+
-- Post's category_id/assigned tags AT SAVE TIME (Phase 2 ticket 06) —
|
|
177
|
+
-- D29's "full snapshot" promise previously left these out entirely, so a
|
|
178
|
+
-- revision-history metadata diff had nothing to compare them against.
|
|
179
|
+
-- `tags` is a JSON array of {id, name} (not just ids) so the snapshot
|
|
180
|
+
-- stays readable even if a tag is later renamed/deleted. Neither column
|
|
181
|
+
-- is written back to hazo_blog_categories/hazo_blog_post_tags on restore
|
|
182
|
+
-- — see PostRepository.restoreRevision's doc-comment.
|
|
183
|
+
category_id TEXT,
|
|
184
|
+
tags JSONB NOT NULL DEFAULT '[]'::jsonb,
|
|
185
|
+
-- Who/what created this revision (Phase 2 ticket 06) — human editor, AI
|
|
186
|
+
-- agent, or background job (e.g. the auto-publish worker). DEFAULT
|
|
187
|
+
-- 'human' backfills every pre-existing revision with no migration
|
|
188
|
+
-- needed — see ActorType in src/types/index.ts.
|
|
189
|
+
actor_type TEXT NOT NULL DEFAULT 'human',
|
|
190
|
+
-- True iff this revision is the losing side of a U6 concurrent-edit
|
|
191
|
+
-- conflict: PostRepository.updatePost() inserted it, then lost the
|
|
192
|
+
-- _rev-guarded conditional update to a concurrent writer, so it never
|
|
193
|
+
-- became live_revision_id/draft_revision_id (U6: "both versions saved as
|
|
194
|
+
-- revisions" — this is the rejected one). See isConflictRevision() in
|
|
195
|
+
-- src/lib/revisions.ts.
|
|
196
|
+
is_conflict BOOLEAN NOT NULL DEFAULT FALSE,
|
|
157
197
|
created_by TEXT,
|
|
158
198
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
159
199
|
);
|
|
160
200
|
CREATE INDEX IF NOT EXISTS idx_hazo_blog_revisions_post_created
|
|
161
201
|
ON hazo_blog_revisions (post_id, created_at);
|
|
202
|
+
-- ⚠️ DDL required (Phase 2 ticket 06) — add category_id/tags/actor_type/
|
|
203
|
+
-- is_conflict to a pre-existing hazo_blog_revisions table. All four are
|
|
204
|
+
-- additive with safe defaults, same idempotent pattern as sections_json's
|
|
205
|
+
-- own ALTER above.
|
|
206
|
+
ALTER TABLE hazo_blog_revisions ADD COLUMN IF NOT EXISTS category_id TEXT;
|
|
207
|
+
ALTER TABLE hazo_blog_revisions ADD COLUMN IF NOT EXISTS tags JSONB NOT NULL DEFAULT '[]'::jsonb;
|
|
208
|
+
ALTER TABLE hazo_blog_revisions ADD COLUMN IF NOT EXISTS actor_type TEXT NOT NULL DEFAULT 'human';
|
|
209
|
+
ALTER TABLE hazo_blog_revisions ADD COLUMN IF NOT EXISTS is_conflict BOOLEAN NOT NULL DEFAULT FALSE;
|
|
162
210
|
|
|
163
211
|
CREATE TABLE IF NOT EXISTS hazo_blog_post_tags (
|
|
164
212
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
@@ -457,6 +505,38 @@ CREATE TABLE IF NOT EXISTS hazo_blog_site_theme (
|
|
|
457
505
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_hazo_blog_site_theme_scope
|
|
458
506
|
ON hazo_blog_site_theme (scope_id);
|
|
459
507
|
|
|
508
|
+
-- hazo_blog_site_theme_versions (Phase 2 ticket 22, D59) — append-only
|
|
509
|
+
-- history of a site's theme state: one row per activation, per settings
|
|
510
|
+
-- save, and per rollback. NEVER updated or deleted after insert — same
|
|
511
|
+
-- append-only philosophy as the platform's own `app_ops_log_entries`
|
|
512
|
+
-- (ticket 03): a rollback creates a NEW row copying an OLD snapshot's
|
|
513
|
+
-- `theme_id`/`settings`, it never rewrites or removes the old rows.
|
|
514
|
+
-- `scope_id` is NOT NULL (tenant-owned, same reasoning as
|
|
515
|
+
-- hazo_blog_site_theme above). `is_current` flags the single most-recent
|
|
516
|
+
-- row per scope — APPLICATION-enforced (select-current, flip, insert-new
|
|
517
|
+
-- in `ThemeVersionRepository.createVersion`), same convention as
|
|
518
|
+
-- hazo_blog_site_files.is_current above, not a DB constraint. `source`
|
|
519
|
+
-- records which of the three write sites created the row: 'activation' |
|
|
520
|
+
-- 'settings_save' | 'rollback'. `actor_type`/`created_by` mirror
|
|
521
|
+
-- hazo_blog_revisions' actor columns (see ActorType in src/types/index.ts).
|
|
522
|
+
CREATE TABLE IF NOT EXISTS hazo_blog_site_theme_versions (
|
|
523
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
524
|
+
scope_id TEXT NOT NULL,
|
|
525
|
+
theme_id UUID NOT NULL REFERENCES hazo_blog_themes(id) ON DELETE CASCADE,
|
|
526
|
+
settings JSONB NOT NULL DEFAULT '{}',
|
|
527
|
+
is_current BOOLEAN NOT NULL DEFAULT TRUE,
|
|
528
|
+
source TEXT NOT NULL DEFAULT 'activation', -- 'activation' | 'settings_save' | 'rollback'
|
|
529
|
+
actor_type TEXT NOT NULL DEFAULT 'human',
|
|
530
|
+
created_by TEXT,
|
|
531
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
532
|
+
);
|
|
533
|
+
-- Drives the version-list UI's ordered read for a site.
|
|
534
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_blog_site_theme_versions_scope_created
|
|
535
|
+
ON hazo_blog_site_theme_versions (scope_id, created_at);
|
|
536
|
+
-- The common lookup: "give me the current version for this site".
|
|
537
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_blog_site_theme_versions_current
|
|
538
|
+
ON hazo_blog_site_theme_versions (scope_id, is_current);
|
|
539
|
+
|
|
460
540
|
-- hazo_blog_site_files (Phase 1b issue 09) — versioned per-site files, e.g.
|
|
461
541
|
-- the Settings -> Appearance custom CSS textarea. `scope_id` NOT NULL, same
|
|
462
542
|
-- "platform-multi-tenant-first" reasoning as hazo_blog_menus/
|
|
@@ -487,6 +567,36 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_hazo_blog_site_files_scope_kind_version
|
|
|
487
567
|
CREATE INDEX IF NOT EXISTS idx_hazo_blog_site_files_current
|
|
488
568
|
ON hazo_blog_site_files (scope_id, kind, is_current);
|
|
489
569
|
|
|
570
|
+
-- hazo_blog_widgets (Phase 2 ticket 05) — one widget INSTANCE placed in a
|
|
571
|
+
-- theme-declared area (e.g. Trades' "sidebar"/"footer", see theme.json's
|
|
572
|
+
-- widgetAreas). `scope_id` is NOT NULL — same "platform-multi-tenant-first,
|
|
573
|
+
-- no useful global widget" reasoning as hazo_blog_menus/hazo_blog_site_theme/
|
|
574
|
+
-- hazo_blog_site_files above. `type` is a FIXED, engine-defined value (see
|
|
575
|
+
-- `WIDGET_TYPE_REGISTRY` in src/lib/widgets.ts) — this table never stores a
|
|
576
|
+
-- theme-invented type; themes only ever supply a RENDERER
|
|
577
|
+
-- (`widgets/{type}.liquid`) for a type this registry already knows.
|
|
578
|
+
-- `position` orders instances within their own `(scope_id, area)` — not
|
|
579
|
+
-- globally — same scoped-ordering convention as hazo_blog_menu_items'
|
|
580
|
+
-- `position` (scoped to `(menu_id, parent_id)`). `settings` is validated
|
|
581
|
+
-- against the type's own Zod schema at WRITE time
|
|
582
|
+
-- (`WidgetRepository.createWidget`/`updateWidget`), same "invariant
|
|
583
|
+
-- enforced in application code before the row is ever written" discipline
|
|
584
|
+
-- as hazo_blog_menu_items.item_type.
|
|
585
|
+
CREATE TABLE IF NOT EXISTS hazo_blog_widgets (
|
|
586
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
587
|
+
scope_id TEXT NOT NULL,
|
|
588
|
+
area TEXT NOT NULL,
|
|
589
|
+
type TEXT NOT NULL,
|
|
590
|
+
position INTEGER NOT NULL DEFAULT 0,
|
|
591
|
+
settings JSONB NOT NULL DEFAULT '{}', -- validated against WIDGET_TYPE_REGISTRY[type]'s schema
|
|
592
|
+
active BOOLEAN NOT NULL DEFAULT TRUE,
|
|
593
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
594
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
595
|
+
);
|
|
596
|
+
-- Drives `listWidgetsByArea`'s ordered read and `reorderWidgets`' batch update.
|
|
597
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_blog_widgets_scope_area_position
|
|
598
|
+
ON hazo_blog_widgets (scope_id, area, position);
|
|
599
|
+
|
|
490
600
|
-- ============================================================================
|
|
491
601
|
-- Row-Level Security (Phase 1a issue 17, platform's tenant-isolation suite).
|
|
492
602
|
-- Postgres-only — there is no SQLite equivalent of RLS, so this section has
|
|
@@ -783,6 +893,16 @@ CREATE POLICY tenant_isolation ON hazo_blog_site_theme
|
|
|
783
893
|
USING (scope_id = hazo_blog_current_scope_id())
|
|
784
894
|
WITH CHECK (scope_id = hazo_blog_current_scope_id());
|
|
785
895
|
|
|
896
|
+
-- hazo_blog_site_theme_versions (Phase 2 ticket 22) — scope_id is NOT NULL
|
|
897
|
+
-- (see its own table comment above), same strict policy as
|
|
898
|
+
-- hazo_blog_menus/hazo_blog_site_theme.
|
|
899
|
+
ALTER TABLE hazo_blog_site_theme_versions ENABLE ROW LEVEL SECURITY;
|
|
900
|
+
ALTER TABLE hazo_blog_site_theme_versions FORCE ROW LEVEL SECURITY;
|
|
901
|
+
DROP POLICY IF EXISTS tenant_isolation ON hazo_blog_site_theme_versions;
|
|
902
|
+
CREATE POLICY tenant_isolation ON hazo_blog_site_theme_versions
|
|
903
|
+
USING (scope_id = hazo_blog_current_scope_id())
|
|
904
|
+
WITH CHECK (scope_id = hazo_blog_current_scope_id());
|
|
905
|
+
|
|
786
906
|
-- hazo_blog_site_files (Phase 1b issue 09) — scope_id is NOT NULL (see its
|
|
787
907
|
-- own table comment above), so this gets the same strict policy as
|
|
788
908
|
-- hazo_blog_menus/hazo_blog_site_theme, not the nullable-scope_id dual-mode
|
|
@@ -793,3 +913,13 @@ DROP POLICY IF EXISTS tenant_isolation ON hazo_blog_site_files;
|
|
|
793
913
|
CREATE POLICY tenant_isolation ON hazo_blog_site_files
|
|
794
914
|
USING (scope_id = hazo_blog_current_scope_id())
|
|
795
915
|
WITH CHECK (scope_id = hazo_blog_current_scope_id());
|
|
916
|
+
|
|
917
|
+
-- hazo_blog_widgets (Phase 2 ticket 05) — scope_id is NOT NULL (see its own
|
|
918
|
+
-- table comment above), same strict policy as hazo_blog_menus/
|
|
919
|
+
-- hazo_blog_site_theme/hazo_blog_site_files.
|
|
920
|
+
ALTER TABLE hazo_blog_widgets ENABLE ROW LEVEL SECURITY;
|
|
921
|
+
ALTER TABLE hazo_blog_widgets FORCE ROW LEVEL SECURITY;
|
|
922
|
+
DROP POLICY IF EXISTS tenant_isolation ON hazo_blog_widgets;
|
|
923
|
+
CREATE POLICY tenant_isolation ON hazo_blog_widgets
|
|
924
|
+
USING (scope_id = hazo_blog_current_scope_id())
|
|
925
|
+
WITH CHECK (scope_id = hazo_blog_current_scope_id());
|
package/db_setup_sqlite.sql
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
-- hazo_blog_theme_versions — version history for a theme
|
|
22
22
|
-- hazo_blog_site_theme — the theme currently active for a site (one row per scope_id)
|
|
23
23
|
-- hazo_blog_site_files — versioned per-site files, e.g. custom CSS (Phase 1b issue 09)
|
|
24
|
+
-- hazo_blog_widgets — widget instances placed in a theme's named areas (Phase 2 ticket 05)
|
|
24
25
|
--
|
|
25
26
|
-- Multi-tenancy: hazo_blog_posts/hazo_blog_revisions require a `scope_id`
|
|
26
27
|
-- (NOT NULL, as of v2.0.0) — add-on/single-site mode stamps hazo_auth's
|
|
@@ -37,9 +38,16 @@ CREATE TABLE IF NOT EXISTS hazo_blog_categories (
|
|
|
37
38
|
description TEXT NOT NULL DEFAULT '',
|
|
38
39
|
colour TEXT NOT NULL DEFAULT '#3B82F6',
|
|
39
40
|
locale TEXT DEFAULT NULL, -- BCP-47 locale; NULL = default locale
|
|
41
|
+
-- Parent category id (Phase 2 ticket 01) — WordPress-style category
|
|
42
|
+
-- hierarchy, needed by the WP/Divi importer. No FK (same convention as
|
|
43
|
+
-- every other optional/legacy cross-table reference in this package).
|
|
44
|
+
-- NULL = top-level category.
|
|
45
|
+
parent_id TEXT DEFAULT NULL,
|
|
40
46
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
41
47
|
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
42
48
|
);
|
|
49
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_blog_categories_parent_id
|
|
50
|
+
ON hazo_blog_categories (parent_id);
|
|
43
51
|
-- FR-034: locale-aware uniqueness. DROP+CREATE is idempotent and safe to
|
|
44
52
|
-- re-run every process start (no table rebuild needed — this is an index
|
|
45
53
|
-- swap, not a column change). COALESCE(locale, '') folds NULL (default
|
|
@@ -118,7 +126,17 @@ CREATE TABLE IF NOT EXISTS hazo_blog_posts (
|
|
|
118
126
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
119
127
|
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
120
128
|
published_at TEXT,
|
|
121
|
-
publish_at TEXT
|
|
129
|
+
publish_at TEXT, -- scheduled publish time
|
|
130
|
+
-- Target date (Phase 2 ticket 07) — an editor's own "aiming to publish
|
|
131
|
+
-- by" date for a draft, distinct from `publish_at` (the actual
|
|
132
|
+
-- scheduled/auto-publish time). Purely informational: nothing reads this
|
|
133
|
+
-- to drive auto-publish or any status transition — it exists only so the
|
|
134
|
+
-- publishing calendar can show target-dated drafts distinctly from
|
|
135
|
+
-- scheduled/published posts. Settable/clearable on any post regardless
|
|
136
|
+
-- of status (same "no DB-level lifecycle coupling" convention as
|
|
137
|
+
-- `publish_at`); not cleared automatically when a post is later
|
|
138
|
+
-- scheduled or published.
|
|
139
|
+
target_date TEXT
|
|
122
140
|
);
|
|
123
141
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_hazo_blog_posts_scope_slug_locale
|
|
124
142
|
ON hazo_blog_posts (scope_id, slug, COALESCE(locale, ''));
|
|
@@ -130,6 +148,8 @@ CREATE INDEX IF NOT EXISTS idx_hazo_blog_posts_deleted_at
|
|
|
130
148
|
ON hazo_blog_posts (deleted_at);
|
|
131
149
|
CREATE INDEX IF NOT EXISTS idx_hazo_blog_posts_publish_at
|
|
132
150
|
ON hazo_blog_posts (publish_at);
|
|
151
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_blog_posts_target_date
|
|
152
|
+
ON hazo_blog_posts (target_date);
|
|
133
153
|
CREATE INDEX IF NOT EXISTS idx_hazo_blog_posts_category_id
|
|
134
154
|
ON hazo_blog_posts (category_id);
|
|
135
155
|
|
|
@@ -159,6 +179,27 @@ CREATE TABLE IF NOT EXISTS hazo_blog_revisions (
|
|
|
159
179
|
og_image TEXT,
|
|
160
180
|
noindex INTEGER NOT NULL DEFAULT 0,
|
|
161
181
|
canonical_override TEXT,
|
|
182
|
+
-- Post's category_id/assigned tags AT SAVE TIME (Phase 2 ticket 06) —
|
|
183
|
+
-- D29's "full snapshot" promise previously left these out entirely, so a
|
|
184
|
+
-- revision-history metadata diff had nothing to compare them against.
|
|
185
|
+
-- `tags` is a JSON array of {id, name} (not just ids) so the snapshot
|
|
186
|
+
-- stays readable even if a tag is later renamed/deleted. Neither column
|
|
187
|
+
-- is written back to hazo_blog_categories/hazo_blog_post_tags on restore
|
|
188
|
+
-- — see PostRepository.restoreRevision's doc-comment.
|
|
189
|
+
category_id TEXT,
|
|
190
|
+
tags TEXT NOT NULL DEFAULT '[]',
|
|
191
|
+
-- Who/what created this revision (Phase 2 ticket 06) — human editor, AI
|
|
192
|
+
-- agent, or background job (e.g. the auto-publish worker). DEFAULT
|
|
193
|
+
-- 'human' backfills every pre-existing revision with no migration
|
|
194
|
+
-- needed — see ActorType in src/types/index.ts.
|
|
195
|
+
actor_type TEXT NOT NULL DEFAULT 'human',
|
|
196
|
+
-- True iff this revision is the losing side of a U6 concurrent-edit
|
|
197
|
+
-- conflict: PostRepository.updatePost() inserted it, then lost the
|
|
198
|
+
-- _rev-guarded conditional update to a concurrent writer, so it never
|
|
199
|
+
-- became live_revision_id/draft_revision_id (U6: "both versions saved as
|
|
200
|
+
-- revisions" — this is the rejected one). See isConflictRevision() in
|
|
201
|
+
-- src/lib/revisions.ts.
|
|
202
|
+
is_conflict INTEGER NOT NULL DEFAULT 0,
|
|
162
203
|
created_by TEXT,
|
|
163
204
|
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
164
205
|
);
|
|
@@ -465,6 +506,38 @@ CREATE TABLE IF NOT EXISTS hazo_blog_site_theme (
|
|
|
465
506
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_hazo_blog_site_theme_scope
|
|
466
507
|
ON hazo_blog_site_theme (scope_id);
|
|
467
508
|
|
|
509
|
+
-- hazo_blog_site_theme_versions (Phase 2 ticket 22, D59) — append-only
|
|
510
|
+
-- history of a site's theme state: one row per activation, per settings
|
|
511
|
+
-- save, and per rollback. NEVER updated or deleted after insert — same
|
|
512
|
+
-- append-only philosophy as the platform's own `app_ops_log_entries`
|
|
513
|
+
-- (ticket 03): a rollback creates a NEW row copying an OLD snapshot's
|
|
514
|
+
-- `theme_id`/`settings`, it never rewrites or removes the old rows.
|
|
515
|
+
-- `scope_id` is NOT NULL (tenant-owned, same reasoning as
|
|
516
|
+
-- hazo_blog_site_theme above). `is_current` flags the single most-recent
|
|
517
|
+
-- row per scope — APPLICATION-enforced (select-current, flip, insert-new
|
|
518
|
+
-- in `ThemeVersionRepository.createVersion`), same convention as
|
|
519
|
+
-- hazo_blog_site_files.is_current above, not a DB constraint. `source`
|
|
520
|
+
-- records which of the three write sites created the row: 'activation' |
|
|
521
|
+
-- 'settings_save' | 'rollback'. `actor_type`/`created_by` mirror
|
|
522
|
+
-- hazo_blog_revisions' actor columns (see ActorType in src/types/index.ts).
|
|
523
|
+
CREATE TABLE IF NOT EXISTS hazo_blog_site_theme_versions (
|
|
524
|
+
id TEXT PRIMARY KEY,
|
|
525
|
+
scope_id TEXT NOT NULL,
|
|
526
|
+
theme_id TEXT NOT NULL REFERENCES hazo_blog_themes(id) ON DELETE CASCADE,
|
|
527
|
+
settings TEXT NOT NULL DEFAULT '{}',
|
|
528
|
+
is_current INTEGER NOT NULL DEFAULT 1, -- 0/1 (SQLite has no native boolean)
|
|
529
|
+
source TEXT NOT NULL DEFAULT 'activation', -- 'activation' | 'settings_save' | 'rollback'
|
|
530
|
+
actor_type TEXT NOT NULL DEFAULT 'human',
|
|
531
|
+
created_by TEXT,
|
|
532
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
533
|
+
);
|
|
534
|
+
-- Drives the version-list UI's ordered read for a site.
|
|
535
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_blog_site_theme_versions_scope_created
|
|
536
|
+
ON hazo_blog_site_theme_versions (scope_id, created_at);
|
|
537
|
+
-- The common lookup: "give me the current version for this site".
|
|
538
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_blog_site_theme_versions_current
|
|
539
|
+
ON hazo_blog_site_theme_versions (scope_id, is_current);
|
|
540
|
+
|
|
468
541
|
-- hazo_blog_site_files (Phase 1b issue 09) — versioned per-site files, e.g.
|
|
469
542
|
-- the Settings -> Appearance custom CSS textarea. `scope_id` NOT NULL, same
|
|
470
543
|
-- "platform-multi-tenant-first" reasoning as hazo_blog_menus/
|
|
@@ -494,3 +567,33 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_hazo_blog_site_files_scope_kind_version
|
|
|
494
567
|
-- The common lookup: "give me the current row for this site+kind".
|
|
495
568
|
CREATE INDEX IF NOT EXISTS idx_hazo_blog_site_files_current
|
|
496
569
|
ON hazo_blog_site_files (scope_id, kind, is_current);
|
|
570
|
+
|
|
571
|
+
-- hazo_blog_widgets (Phase 2 ticket 05) — one widget INSTANCE placed in a
|
|
572
|
+
-- theme-declared area (e.g. Trades' "sidebar"/"footer", see theme.json's
|
|
573
|
+
-- widgetAreas). `scope_id` is NOT NULL — same "platform-multi-tenant-first,
|
|
574
|
+
-- no useful global widget" reasoning as hazo_blog_menus/hazo_blog_site_theme/
|
|
575
|
+
-- hazo_blog_site_files above. `type` is a FIXED, engine-defined value (see
|
|
576
|
+
-- `WIDGET_TYPE_REGISTRY` in src/lib/widgets.ts) — this table never stores a
|
|
577
|
+
-- theme-invented type; themes only ever supply a RENDERER
|
|
578
|
+
-- (`widgets/{type}.liquid`) for a type this registry already knows.
|
|
579
|
+
-- `position` orders instances within their own `(scope_id, area)` — not
|
|
580
|
+
-- globally — same scoped-ordering convention as hazo_blog_menu_items'
|
|
581
|
+
-- `position` (scoped to `(menu_id, parent_id)`). `settings` is validated
|
|
582
|
+
-- against the type's own Zod schema at WRITE time
|
|
583
|
+
-- (`WidgetRepository.createWidget`/`updateWidget`), same "invariant
|
|
584
|
+
-- enforced in application code before the row is ever written" discipline
|
|
585
|
+
-- as hazo_blog_menu_items.item_type.
|
|
586
|
+
CREATE TABLE IF NOT EXISTS hazo_blog_widgets (
|
|
587
|
+
id TEXT PRIMARY KEY,
|
|
588
|
+
scope_id TEXT NOT NULL,
|
|
589
|
+
area TEXT NOT NULL,
|
|
590
|
+
type TEXT NOT NULL,
|
|
591
|
+
position INTEGER NOT NULL DEFAULT 0,
|
|
592
|
+
settings TEXT NOT NULL DEFAULT '{}', -- JSON, validated against WIDGET_TYPE_REGISTRY[type]'s schema
|
|
593
|
+
active INTEGER NOT NULL DEFAULT 1, -- 0/1 (SQLite has no native boolean)
|
|
594
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
595
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
596
|
+
);
|
|
597
|
+
-- Drives `listWidgetsByArea`'s ordered read and `reorderWidgets`' batch update.
|
|
598
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_blog_widgets_scope_area_position
|
|
599
|
+
ON hazo_blog_widgets (scope_id, area, position);
|