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/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export * from "./types/index.js";
|
|
2
2
|
export * from "./lib/index.js";
|
|
3
|
-
export { createBlogRepository, listScopesWithSetting, type BlogRepository, type RepositoryOptions, type ListQuery, } from "./repository/index.js";
|
|
4
|
-
export { createPostRepository, findDueScheduledPosts, purgeTrashedPosts, findImportedPosts, CategoryNotFoundError, PostConflictError, PostInvalidStatusTransitionError, PostNoDraftRevisionError, PostNoLiveRevisionError, PostNotFoundError, type PostRepository, } from "./repository/posts.js";
|
|
5
|
-
export { createPostService, resolvePostScope, ScopeUnresolvedError, CustomFieldValidationError, type PostService, } from "./service/posts.js";
|
|
3
|
+
export { createBlogRepository, listScopesWithSetting, BlogCategoryNotFoundError, type BlogRepository, type RepositoryOptions, type ListQuery, } from "./repository/index.js";
|
|
4
|
+
export { createPostRepository, findDueScheduledPosts, purgeTrashedPosts, findImportedPosts, findPostsForCalendar, CategoryNotFoundError, PostConflictError, PostInvalidStatusTransitionError, PostNoDraftRevisionError, PostNoLiveRevisionError, PostNotFoundError, RevisionNotFoundError, type PostRepository, } from "./repository/posts.js";
|
|
5
|
+
export { createPostService, resolvePostScope, ScopeUnresolvedError, CustomFieldValidationError, PostRescheduleRefusedError, type PostService, } from "./service/posts.js";
|
|
6
6
|
export { registerSeoHooks } from "./service/seo-hooks.js";
|
|
7
7
|
export { createBylineRepository, BylineNotFoundError, PostNotFoundForBylineError, type BylineRepository, } from "./repository/bylines.js";
|
|
8
8
|
export { createBylineService, type BylineService } from "./service/bylines.js";
|
|
@@ -12,10 +12,13 @@ export { createDomainRepository, deleteCompetingUnverifiedClaims, findDomainByHo
|
|
|
12
12
|
export { createDomainService, resolveScopeByDomain, type DomainService, type DomainVerificationInstructions, } from "./service/domains.js";
|
|
13
13
|
export { createMenuRepository, MenuNotFoundError, MenuItemNotFoundError, MenuHandleConflictError, MenuItemValidationError, type MenuRepository, } from "./repository/menus.js";
|
|
14
14
|
export { createMenuService, buildResolvedMenuTree, type MenuService } from "./service/menus.js";
|
|
15
|
+
export { createWidgetRepository, WidgetNotFoundError, type WidgetRepository, type ListWidgetsByAreaOptions, } from "./repository/widgets.js";
|
|
16
|
+
export { createWidgetService, type WidgetService } from "./service/widgets.js";
|
|
15
17
|
export { createThemeRepository, listVisibleThemes, ThemeNotFoundError, type ThemeRepository, } from "./repository/themes.js";
|
|
16
|
-
export {
|
|
18
|
+
export { createThemeVersionRepository, ThemeVersionNotFoundError, type ThemeVersionRepository, type ListThemeVersionsOptions, } from "./repository/theme-versions.js";
|
|
19
|
+
export { createThemeService, ThemeNotActiveError, ThemeSettingsValidationError, ThemeStorageNotConfiguredError, ThemeMaterializationUnsupportedError, ThemeImmutableError, type ThemeService, type CreateThemeServiceDeps, type InstallBuiltInThemesResult, type ThemeActorOpts, } from "./service/themes.js";
|
|
17
20
|
export { createSiteFileRepository, type SiteFileRepository, } from "./repository/site-files.js";
|
|
18
|
-
export { createSiteFileService, CustomCssTooLargeError, MAX_CUSTOM_CSS_BYTES, type SiteFileService, } from "./service/site-files.js";
|
|
21
|
+
export { createSiteFileService, CustomCssTooLargeError, MAX_CUSTOM_CSS_BYTES, AdsTxtTooLargeError, MAX_ADS_TXT_BYTES, type SiteFileService, } from "./service/site-files.js";
|
|
19
22
|
export { registerCdnHooks } from "./service/cdn-hooks.js";
|
|
20
23
|
export { domainVerificationToken, domainVerificationRecordName, DOMAIN_VERIFICATION_TXT_LABEL, INSECURE_DEV_FALLBACK_SECRET, } from "./lib/domain-token.js";
|
|
21
24
|
export { verifyDomainTxtRecord, type ResolveTxt } from "./lib/domain-dns.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,cAAc,kBAAkB,CAAC;AAGjC,cAAc,gBAAgB,CAAC;AAG/B,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,SAAS,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,gCAAgC,EAChC,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,EACjB,KAAK,cAAc,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,KAA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time, excerpt, toc).
|
|
7
7
|
export * from "./lib/index.js";
|
|
8
8
|
// Storage + business logic.
|
|
9
|
-
export { createBlogRepository, listScopesWithSetting, } from "./repository/index.js";
|
|
10
|
-
export { createPostRepository, findDueScheduledPosts, purgeTrashedPosts, findImportedPosts, CategoryNotFoundError, PostConflictError, PostInvalidStatusTransitionError, PostNoDraftRevisionError, PostNoLiveRevisionError, PostNotFoundError, } from "./repository/posts.js";
|
|
11
|
-
export { createPostService, resolvePostScope, ScopeUnresolvedError, CustomFieldValidationError, } from "./service/posts.js";
|
|
9
|
+
export { createBlogRepository, listScopesWithSetting, BlogCategoryNotFoundError, } from "./repository/index.js";
|
|
10
|
+
export { createPostRepository, findDueScheduledPosts, purgeTrashedPosts, findImportedPosts, findPostsForCalendar, CategoryNotFoundError, PostConflictError, PostInvalidStatusTransitionError, PostNoDraftRevisionError, PostNoLiveRevisionError, PostNotFoundError, RevisionNotFoundError, } from "./repository/posts.js";
|
|
11
|
+
export { createPostService, resolvePostScope, ScopeUnresolvedError, CustomFieldValidationError, PostRescheduleRefusedError, } from "./service/posts.js";
|
|
12
12
|
export { registerSeoHooks } from "./service/seo-hooks.js";
|
|
13
13
|
export { createBylineRepository, BylineNotFoundError, PostNotFoundForBylineError, } from "./repository/bylines.js";
|
|
14
14
|
export { createBylineService } from "./service/bylines.js";
|
|
@@ -18,10 +18,13 @@ export { createDomainRepository, deleteCompetingUnverifiedClaims, findDomainByHo
|
|
|
18
18
|
export { createDomainService, resolveScopeByDomain, } from "./service/domains.js";
|
|
19
19
|
export { createMenuRepository, MenuNotFoundError, MenuItemNotFoundError, MenuHandleConflictError, MenuItemValidationError, } from "./repository/menus.js";
|
|
20
20
|
export { createMenuService, buildResolvedMenuTree } from "./service/menus.js";
|
|
21
|
+
export { createWidgetRepository, WidgetNotFoundError, } from "./repository/widgets.js";
|
|
22
|
+
export { createWidgetService } from "./service/widgets.js";
|
|
21
23
|
export { createThemeRepository, listVisibleThemes, ThemeNotFoundError, } from "./repository/themes.js";
|
|
22
|
-
export {
|
|
24
|
+
export { createThemeVersionRepository, ThemeVersionNotFoundError, } from "./repository/theme-versions.js";
|
|
25
|
+
export { createThemeService, ThemeNotActiveError, ThemeSettingsValidationError, ThemeStorageNotConfiguredError, ThemeMaterializationUnsupportedError, ThemeImmutableError, } from "./service/themes.js";
|
|
23
26
|
export { createSiteFileRepository, } from "./repository/site-files.js";
|
|
24
|
-
export { createSiteFileService, CustomCssTooLargeError, MAX_CUSTOM_CSS_BYTES, } from "./service/site-files.js";
|
|
27
|
+
export { createSiteFileService, CustomCssTooLargeError, MAX_CUSTOM_CSS_BYTES, AdsTxtTooLargeError, MAX_ADS_TXT_BYTES, } from "./service/site-files.js";
|
|
25
28
|
export { registerCdnHooks } from "./service/cdn-hooks.js";
|
|
26
29
|
export { domainVerificationToken, domainVerificationRecordName, DOMAIN_VERIFICATION_TXT_LABEL, INSECURE_DEV_FALLBACK_SECRET, } from "./lib/domain-token.js";
|
|
27
30
|
export { verifyDomainTxtRecord } from "./lib/domain-dns.js";
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./status.js";
|
|
|
9
9
|
export * from "./hook-bus.js";
|
|
10
10
|
export * from "./safe-url.js";
|
|
11
11
|
export * from "./sections.js";
|
|
12
|
+
export * from "./widgets.js";
|
|
12
13
|
export * from "./theme-schema.js";
|
|
13
14
|
export * from "./theme-validate.js";
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AACA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AACA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
package/dist/lib/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export * from "./status.js";
|
|
|
10
10
|
export * from "./hook-bus.js";
|
|
11
11
|
export * from "./safe-url.js";
|
|
12
12
|
export * from "./sections.js";
|
|
13
|
+
export * from "./widgets.js";
|
|
13
14
|
export * from "./theme-schema.js";
|
|
14
15
|
export * from "./theme-validate.js";
|
|
15
16
|
// `mdx_mask.ts` and `mdx_segment.ts` are deliberately NOT re-exported here —
|
package/dist/lib/revisions.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Post } from "../types/index.js";
|
|
1
|
+
import type { Post, PostRevision } from "../types/index.js";
|
|
2
|
+
export type { ActorType } from "../types/index.js";
|
|
2
3
|
/**
|
|
3
4
|
* True when a post has unpromoted staged changes: both a live revision
|
|
4
5
|
* (it's been published at least once) and a draft revision (something's
|
|
@@ -7,4 +8,73 @@ import type { Post } from "../types/index.js";
|
|
|
7
8
|
* only, no live yet) and for a published post with nothing staged.
|
|
8
9
|
*/
|
|
9
10
|
export declare function hasPendingChanges(post: Pick<Post, "live_revision_id" | "draft_revision_id">): boolean;
|
|
11
|
+
/** One line of a body diff — `diffRevisionBody`'s line-level output. */
|
|
12
|
+
export interface RevisionLineDiffEntry {
|
|
13
|
+
type: "equal" | "added" | "removed";
|
|
14
|
+
value: string;
|
|
15
|
+
}
|
|
16
|
+
/** Result of `diffRevisionBody()` — line-level diff plus paragraph-level stats the deterministic summary is built from. */
|
|
17
|
+
export interface RevisionBodyDiff {
|
|
18
|
+
lines: RevisionLineDiffEntry[];
|
|
19
|
+
/** Whole new paragraphs with no corresponding paragraph in the old body. */
|
|
20
|
+
paragraphsAdded: number;
|
|
21
|
+
/** Whole paragraphs from the old body with no corresponding paragraph in the new body. */
|
|
22
|
+
paragraphsRemoved: number;
|
|
23
|
+
/** A removed paragraph immediately followed by an added one, at the same position — counted as one edited paragraph, not one removal + one addition. */
|
|
24
|
+
paragraphsChanged: number;
|
|
25
|
+
}
|
|
26
|
+
/** The subset of `PostRevision` metadata fields `diffRevisionMetadata()` compares. */
|
|
27
|
+
export type RevisionMetadataSnapshot = Pick<PostRevision, "title" | "slug" | "seo_title" | "seo_description" | "og_image" | "noindex" | "canonical_override" | "category_id" | "tags">;
|
|
28
|
+
export type RevisionMetadataField = "title" | "slug" | "seo_title" | "seo_description" | "og_image" | "noindex" | "canonical_override" | "category" | "tags";
|
|
29
|
+
/** One changed metadata field between two revisions — `diffRevisionMetadata()`'s output. */
|
|
30
|
+
export interface RevisionMetadataFieldChange {
|
|
31
|
+
field: RevisionMetadataField;
|
|
32
|
+
before: unknown;
|
|
33
|
+
after: unknown;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Body diff between two revisions (D29 — computed on read, never stored):
|
|
37
|
+
* a line-level diff for an inline diff view, plus paragraph-level add/
|
|
38
|
+
* remove/change counts the deterministic summary turns into "edited N
|
|
39
|
+
* paragraphs" (see `summarizeRevisionChange`).
|
|
40
|
+
*/
|
|
41
|
+
export declare function diffRevisionBody(oldBody: string, newBody: string): RevisionBodyDiff;
|
|
42
|
+
/**
|
|
43
|
+
* Word-level diff of two individual lines — used by an admin UI to
|
|
44
|
+
* highlight the exact changed words within a line the line-level diff
|
|
45
|
+
* already flagged as `added`/`removed` (e.g. a one-word title edit
|
|
46
|
+
* shouldn't highlight the whole line). Same LCS algorithm as
|
|
47
|
+
* `diffRevisionBody`, tokenized on whitespace runs (kept, so words rejoin
|
|
48
|
+
* with their original spacing).
|
|
49
|
+
*/
|
|
50
|
+
export declare function diffRevisionWords(oldLine: string, newLine: string): RevisionLineDiffEntry[];
|
|
51
|
+
/**
|
|
52
|
+
* Metadata diff between two revisions (D29): title, slug, SEO fields,
|
|
53
|
+
* category, tags — every field a save can change that `diffRevisionBody`
|
|
54
|
+
* doesn't already cover. Tags are compared by id set (order-independent);
|
|
55
|
+
* `before`/`after` on a `tags` change report the tag NAMES at each
|
|
56
|
+
* revision's own snapshot (see `PostRevision.tags`'s doc-comment), not ids.
|
|
57
|
+
*/
|
|
58
|
+
export declare function diffRevisionMetadata(before: RevisionMetadataSnapshot, after: RevisionMetadataSnapshot): RevisionMetadataFieldChange[];
|
|
59
|
+
/**
|
|
60
|
+
* Deterministic, rule-based one-line change summary (Phase 2 ticket 06 —
|
|
61
|
+
* explicitly NO LLM call). A pure function of the two diffs already
|
|
62
|
+
* computed above: fixed field order, fixed label table, fixed pluralization
|
|
63
|
+
* — the exact same `bodyDiff`/`metadataDiff` pair always produces the exact
|
|
64
|
+
* same string (see revisions.test.ts's determinism test, called twice on
|
|
65
|
+
* the same inputs).
|
|
66
|
+
*/
|
|
67
|
+
export declare function summarizeRevisionChange(bodyDiff: RevisionBodyDiff, metadataDiff: RevisionMetadataFieldChange[]): string;
|
|
68
|
+
/**
|
|
69
|
+
* Whether a revision is a losing side of a U6 concurrent-edit conflict: its
|
|
70
|
+
* `PostRepository.updatePost()` call inserted this snapshot, then lost the
|
|
71
|
+
* `_rev`-guarded conditional update to a concurrent writer (see
|
|
72
|
+
* `PostRepository`'s own `updatePost` doc-comment, and `is_conflict`'s
|
|
73
|
+
* column comment in db_setup_*.sql). The edit was never lost — this
|
|
74
|
+
* revision is the proof — but it never became the post's live or draft
|
|
75
|
+
* pointer. A trivial passthrough today, kept as a named predicate (same
|
|
76
|
+
* convention as `hasPendingChanges`) so admin UIs have one documented place
|
|
77
|
+
* to ask the question instead of reading `.is_conflict` ad hoc.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isConflictRevision(revision: Pick<PostRevision, "is_conflict">): boolean;
|
|
10
80
|
//# sourceMappingURL=revisions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revisions.d.ts","sourceRoot":"","sources":["../../src/lib/revisions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"revisions.d.ts","sourceRoot":"","sources":["../../src/lib/revisions.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAK5D,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,kBAAkB,GAAG,mBAAmB,CAAC,GAAG,OAAO,CAErG;AAED,wEAAwE;AACxE,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,2HAA2H;AAC3H,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,qBAAqB,EAAE,CAAC;IAC/B,4EAA4E;IAC5E,eAAe,EAAE,MAAM,CAAC;IACxB,0FAA0F;IAC1F,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wJAAwJ;IACxJ,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,sFAAsF;AACtF,MAAM,MAAM,wBAAwB,GAAG,IAAI,CACzC,YAAY,EACZ,OAAO,GAAG,MAAM,GAAG,WAAW,GAAG,iBAAiB,GAAG,UAAU,GAAG,SAAS,GAAG,oBAAoB,GAAG,aAAa,GAAG,MAAM,CAC5H,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAC7B,OAAO,GACP,MAAM,GACN,WAAW,GACX,iBAAiB,GACjB,UAAU,GACV,SAAS,GACT,oBAAoB,GACpB,UAAU,GACV,MAAM,CAAC;AAEX,4FAA4F;AAC5F,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,qBAAqB,CAAC;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;CAChB;AA0DD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,gBAAgB,CA2CnF;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,qBAAqB,EAAE,CAI3F;AA2BD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,wBAAwB,EAChC,KAAK,EAAE,wBAAwB,GAC9B,2BAA2B,EAAE,CAqC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,gBAAgB,EAC1B,YAAY,EAAE,2BAA2B,EAAE,GAC1C,MAAM,CAqBR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,OAAO,CAEvF"}
|
package/dist/lib/revisions.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
// hazo_blog/lib — pure helpers for the v2.0.0 live/draft revision model
|
|
2
|
-
// (Phase 1a issue 06)
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
2
|
+
// (Phase 1a issue 06) AND the revision-HISTORY diff/summary layer (Phase 2
|
|
3
|
+
// ticket 06). Pure + server/client-neutral (no DB, no React), so it belongs
|
|
4
|
+
// in the general-purpose `./lib` barrel rather than `src/ui`/`src/components`.
|
|
5
|
+
//
|
|
6
|
+
// D29 ("compute diffs on read, don't store them") lives here: every diff
|
|
7
|
+
// below is a pure function of two `PostRevision` snapshots, called by
|
|
8
|
+
// `PostService.compareRevisions()` at READ time — nothing is persisted.
|
|
9
|
+
// `summarizeRevisionChange()` is deliberately rule-based (counts + a fixed
|
|
10
|
+
// label table), NOT an LLM call — same diff in always produces the same
|
|
11
|
+
// summary string out (see this package's own revisions.test.ts for the
|
|
12
|
+
// determinism assertion the ticket explicitly asked for).
|
|
9
13
|
/**
|
|
10
14
|
* True when a post has unpromoted staged changes: both a live revision
|
|
11
15
|
* (it's been published at least once) and a draft revision (something's
|
|
@@ -16,3 +20,224 @@
|
|
|
16
20
|
export function hasPendingChanges(post) {
|
|
17
21
|
return post.live_revision_id !== null && post.draft_revision_id !== null;
|
|
18
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Classic LCS-table diff (same family of algorithm as Python's `difflib`) —
|
|
25
|
+
* O(n*m) DP, fine for blog-post-sized bodies (hundreds of lines/paragraphs),
|
|
26
|
+
* not tuned for huge inputs. Pure and deterministic: same `a`/`b` always
|
|
27
|
+
* produce the same op sequence, which is what makes
|
|
28
|
+
* `summarizeRevisionChange()`'s determinism guarantee possible one layer up.
|
|
29
|
+
*/
|
|
30
|
+
function lcsDiff(a, b, eq) {
|
|
31
|
+
const n = a.length;
|
|
32
|
+
const m = b.length;
|
|
33
|
+
const dp = Array.from({ length: n + 1 }, () => new Array(m + 1).fill(0));
|
|
34
|
+
for (let i = n - 1; i >= 0; i--) {
|
|
35
|
+
for (let j = m - 1; j >= 0; j--) {
|
|
36
|
+
dp[i][j] = eq(a[i], b[j]) ? dp[i + 1][j + 1] + 1 : Math.max(dp[i + 1][j], dp[i][j + 1]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const ops = [];
|
|
40
|
+
let i = 0;
|
|
41
|
+
let j = 0;
|
|
42
|
+
while (i < n && j < m) {
|
|
43
|
+
if (eq(a[i], b[j])) {
|
|
44
|
+
ops.push({ type: "equal", value: a[i] });
|
|
45
|
+
i++;
|
|
46
|
+
j++;
|
|
47
|
+
}
|
|
48
|
+
else if (dp[i + 1][j] >= dp[i][j + 1]) {
|
|
49
|
+
ops.push({ type: "removed", value: a[i] });
|
|
50
|
+
i++;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
ops.push({ type: "added", value: b[j] });
|
|
54
|
+
j++;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
while (i < n) {
|
|
58
|
+
ops.push({ type: "removed", value: a[i] });
|
|
59
|
+
i++;
|
|
60
|
+
}
|
|
61
|
+
while (j < m) {
|
|
62
|
+
ops.push({ type: "added", value: b[j] });
|
|
63
|
+
j++;
|
|
64
|
+
}
|
|
65
|
+
return ops;
|
|
66
|
+
}
|
|
67
|
+
/** MDX body split into paragraphs: blocks separated by one-or-more blank lines, trimmed, empty blocks dropped. */
|
|
68
|
+
function splitParagraphs(body) {
|
|
69
|
+
return body
|
|
70
|
+
.split(/\n\s*\n/)
|
|
71
|
+
.map((p) => p.trim())
|
|
72
|
+
.filter((p) => p.length > 0);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Body diff between two revisions (D29 — computed on read, never stored):
|
|
76
|
+
* a line-level diff for an inline diff view, plus paragraph-level add/
|
|
77
|
+
* remove/change counts the deterministic summary turns into "edited N
|
|
78
|
+
* paragraphs" (see `summarizeRevisionChange`).
|
|
79
|
+
*/
|
|
80
|
+
export function diffRevisionBody(oldBody, newBody) {
|
|
81
|
+
const lineOps = lcsDiff(oldBody.split("\n"), newBody.split("\n"), (x, y) => x === y);
|
|
82
|
+
const lines = lineOps.map((op) => ({ type: op.type, value: op.value }));
|
|
83
|
+
const paraOps = lcsDiff(splitParagraphs(oldBody), splitParagraphs(newBody), (x, y) => x === y);
|
|
84
|
+
// A standard LCS diff emits a contiguous run of `removed` ops immediately
|
|
85
|
+
// followed by a contiguous run of `added` ops for a "block replace" (e.g.
|
|
86
|
+
// 2 old paragraphs rewritten into 2 new ones never interleaves them) — a
|
|
87
|
+
// human reads a removed+added run of the SAME length as that many edited
|
|
88
|
+
// paragraphs, not N removals plus N additions. Pair each adjacent
|
|
89
|
+
// removed/added run up to `min(removedRun, addedRun)`; any length
|
|
90
|
+
// mismatch (a run genuinely adding or removing whole paragraphs) is left
|
|
91
|
+
// as plain added/removed.
|
|
92
|
+
let paragraphsAdded = 0;
|
|
93
|
+
let paragraphsRemoved = 0;
|
|
94
|
+
let paragraphsChanged = 0;
|
|
95
|
+
let i = 0;
|
|
96
|
+
while (i < paraOps.length) {
|
|
97
|
+
if (paraOps[i].type === "equal") {
|
|
98
|
+
i++;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
let j = i;
|
|
102
|
+
let removedCount = 0;
|
|
103
|
+
while (j < paraOps.length && paraOps[j].type === "removed") {
|
|
104
|
+
removedCount++;
|
|
105
|
+
j++;
|
|
106
|
+
}
|
|
107
|
+
let addedCount = 0;
|
|
108
|
+
let k = j;
|
|
109
|
+
while (k < paraOps.length && paraOps[k].type === "added") {
|
|
110
|
+
addedCount++;
|
|
111
|
+
k++;
|
|
112
|
+
}
|
|
113
|
+
const changed = Math.min(removedCount, addedCount);
|
|
114
|
+
paragraphsChanged += changed;
|
|
115
|
+
paragraphsRemoved += removedCount - changed;
|
|
116
|
+
paragraphsAdded += addedCount - changed;
|
|
117
|
+
i = k;
|
|
118
|
+
}
|
|
119
|
+
return { lines, paragraphsAdded, paragraphsRemoved, paragraphsChanged };
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Word-level diff of two individual lines — used by an admin UI to
|
|
123
|
+
* highlight the exact changed words within a line the line-level diff
|
|
124
|
+
* already flagged as `added`/`removed` (e.g. a one-word title edit
|
|
125
|
+
* shouldn't highlight the whole line). Same LCS algorithm as
|
|
126
|
+
* `diffRevisionBody`, tokenized on whitespace runs (kept, so words rejoin
|
|
127
|
+
* with their original spacing).
|
|
128
|
+
*/
|
|
129
|
+
export function diffRevisionWords(oldLine, newLine) {
|
|
130
|
+
const tokenize = (line) => line.split(/(\s+)/).filter((t) => t.length > 0);
|
|
131
|
+
const ops = lcsDiff(tokenize(oldLine), tokenize(newLine), (x, y) => x === y);
|
|
132
|
+
return ops.map((op) => ({ type: op.type, value: op.value }));
|
|
133
|
+
}
|
|
134
|
+
const METADATA_FIELD_ORDER = [
|
|
135
|
+
"title",
|
|
136
|
+
"slug",
|
|
137
|
+
"category",
|
|
138
|
+
"tags",
|
|
139
|
+
"seo_title",
|
|
140
|
+
"seo_description",
|
|
141
|
+
"og_image",
|
|
142
|
+
"canonical_override",
|
|
143
|
+
"noindex",
|
|
144
|
+
];
|
|
145
|
+
/** Human label for each `RevisionMetadataField`, used by `summarizeRevisionChange()`. Fixed/rule-based — never generated. */
|
|
146
|
+
const METADATA_FIELD_LABEL = {
|
|
147
|
+
title: "changed title",
|
|
148
|
+
slug: "changed slug",
|
|
149
|
+
category: "changed category",
|
|
150
|
+
tags: "updated tags",
|
|
151
|
+
seo_title: "updated SEO title",
|
|
152
|
+
seo_description: "updated SEO description",
|
|
153
|
+
og_image: "changed social image",
|
|
154
|
+
canonical_override: "changed canonical URL",
|
|
155
|
+
noindex: "changed search-indexing setting",
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Metadata diff between two revisions (D29): title, slug, SEO fields,
|
|
159
|
+
* category, tags — every field a save can change that `diffRevisionBody`
|
|
160
|
+
* doesn't already cover. Tags are compared by id set (order-independent);
|
|
161
|
+
* `before`/`after` on a `tags` change report the tag NAMES at each
|
|
162
|
+
* revision's own snapshot (see `PostRevision.tags`'s doc-comment), not ids.
|
|
163
|
+
*/
|
|
164
|
+
export function diffRevisionMetadata(before, after) {
|
|
165
|
+
const changes = [];
|
|
166
|
+
if (before.title !== after.title)
|
|
167
|
+
changes.push({ field: "title", before: before.title, after: after.title });
|
|
168
|
+
if (before.slug !== after.slug)
|
|
169
|
+
changes.push({ field: "slug", before: before.slug, after: after.slug });
|
|
170
|
+
if (before.category_id !== after.category_id) {
|
|
171
|
+
changes.push({ field: "category", before: before.category_id, after: after.category_id });
|
|
172
|
+
}
|
|
173
|
+
const tagIds = (list) => [...list]
|
|
174
|
+
.map((t) => t.id)
|
|
175
|
+
.sort()
|
|
176
|
+
.join(",");
|
|
177
|
+
if (tagIds(before.tags) !== tagIds(after.tags)) {
|
|
178
|
+
changes.push({
|
|
179
|
+
field: "tags",
|
|
180
|
+
before: before.tags.map((t) => t.name),
|
|
181
|
+
after: after.tags.map((t) => t.name),
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (before.seo_title !== after.seo_title) {
|
|
185
|
+
changes.push({ field: "seo_title", before: before.seo_title, after: after.seo_title });
|
|
186
|
+
}
|
|
187
|
+
if (before.seo_description !== after.seo_description) {
|
|
188
|
+
changes.push({ field: "seo_description", before: before.seo_description, after: after.seo_description });
|
|
189
|
+
}
|
|
190
|
+
if (before.og_image !== after.og_image) {
|
|
191
|
+
changes.push({ field: "og_image", before: before.og_image, after: after.og_image });
|
|
192
|
+
}
|
|
193
|
+
if (before.canonical_override !== after.canonical_override) {
|
|
194
|
+
changes.push({ field: "canonical_override", before: before.canonical_override, after: after.canonical_override });
|
|
195
|
+
}
|
|
196
|
+
if (before.noindex !== after.noindex) {
|
|
197
|
+
changes.push({ field: "noindex", before: before.noindex, after: after.noindex });
|
|
198
|
+
}
|
|
199
|
+
return changes;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Deterministic, rule-based one-line change summary (Phase 2 ticket 06 —
|
|
203
|
+
* explicitly NO LLM call). A pure function of the two diffs already
|
|
204
|
+
* computed above: fixed field order, fixed label table, fixed pluralization
|
|
205
|
+
* — the exact same `bodyDiff`/`metadataDiff` pair always produces the exact
|
|
206
|
+
* same string (see revisions.test.ts's determinism test, called twice on
|
|
207
|
+
* the same inputs).
|
|
208
|
+
*/
|
|
209
|
+
export function summarizeRevisionChange(bodyDiff, metadataDiff) {
|
|
210
|
+
const parts = [];
|
|
211
|
+
if (bodyDiff.paragraphsChanged > 0) {
|
|
212
|
+
parts.push(`edited ${bodyDiff.paragraphsChanged} paragraph${bodyDiff.paragraphsChanged === 1 ? "" : "s"}`);
|
|
213
|
+
}
|
|
214
|
+
if (bodyDiff.paragraphsAdded > 0) {
|
|
215
|
+
parts.push(`added ${bodyDiff.paragraphsAdded} paragraph${bodyDiff.paragraphsAdded === 1 ? "" : "s"}`);
|
|
216
|
+
}
|
|
217
|
+
if (bodyDiff.paragraphsRemoved > 0) {
|
|
218
|
+
parts.push(`removed ${bodyDiff.paragraphsRemoved} paragraph${bodyDiff.paragraphsRemoved === 1 ? "" : "s"}`);
|
|
219
|
+
}
|
|
220
|
+
const present = new Set(metadataDiff.map((c) => c.field));
|
|
221
|
+
for (const field of METADATA_FIELD_ORDER) {
|
|
222
|
+
if (present.has(field))
|
|
223
|
+
parts.push(METADATA_FIELD_LABEL[field]);
|
|
224
|
+
}
|
|
225
|
+
if (parts.length === 0)
|
|
226
|
+
return "No changes";
|
|
227
|
+
const sentence = parts.join(", ");
|
|
228
|
+
return sentence.charAt(0).toUpperCase() + sentence.slice(1);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Whether a revision is a losing side of a U6 concurrent-edit conflict: its
|
|
232
|
+
* `PostRepository.updatePost()` call inserted this snapshot, then lost the
|
|
233
|
+
* `_rev`-guarded conditional update to a concurrent writer (see
|
|
234
|
+
* `PostRepository`'s own `updatePost` doc-comment, and `is_conflict`'s
|
|
235
|
+
* column comment in db_setup_*.sql). The edit was never lost — this
|
|
236
|
+
* revision is the proof — but it never became the post's live or draft
|
|
237
|
+
* pointer. A trivial passthrough today, kept as a named predicate (same
|
|
238
|
+
* convention as `hasPendingChanges`) so admin UIs have one documented place
|
|
239
|
+
* to ask the question instead of reading `.is_conflict` ad hoc.
|
|
240
|
+
*/
|
|
241
|
+
export function isConflictRevision(revision) {
|
|
242
|
+
return revision.is_conflict;
|
|
243
|
+
}
|
|
@@ -34,6 +34,10 @@ export declare const themeJsonSchema: z.ZodObject<{
|
|
|
34
34
|
step: z.ZodOptional<z.ZodNumber>;
|
|
35
35
|
}, z.core.$strip>>>>;
|
|
36
36
|
allowedSections: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
37
|
+
widgetAreas: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
label: z.ZodString;
|
|
40
|
+
}, z.core.$strip>>>>;
|
|
37
41
|
}, z.core.$strip>;
|
|
38
42
|
/** Parses+validates a raw `theme.json` payload (already `JSON.parse`d). Throws `ThemeJsonValidationError` with every issue found, never just the first. */
|
|
39
43
|
export declare function parseThemeJson(raw: unknown): ThemeJson;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-schema.d.ts","sourceRoot":"","sources":["../../src/lib/theme-schema.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,CAAC,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAA0B,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"theme-schema.d.ts","sourceRoot":"","sources":["../../src/lib/theme-schema.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,CAAC,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAA0B,MAAM,mBAAmB,CAAC;AAY/F,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;gBACd,MAAM,EAAE,MAAM,EAAE;CAK7B;AAoCD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAU1B,CAAC;AAEH,2JAA2J;AAC3J,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,CAMtD;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAErG;AAED,sVAAsV;AACtV,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,EAAE,GAAG,UAAU,CAMjF"}
|
package/dist/lib/theme-schema.js
CHANGED
|
@@ -18,6 +18,15 @@
|
|
|
18
18
|
// so it's EXPLICITLY handed off to ticket 07/08 (per this ticket's own
|
|
19
19
|
// instructions) rather than half-wired here.
|
|
20
20
|
import { z } from "zod";
|
|
21
|
+
// Widget areas (Phase 2 ticket 05) — see `ThemeJson.widgetAreas`'s own
|
|
22
|
+
// doc-comment. Same shape/strictness as `settingsFieldSchema` above: two
|
|
23
|
+
// required, non-empty strings, no further constraint (a theme can call its
|
|
24
|
+
// area whatever it likes — `{% widget_area "name" %}` just looks it up by
|
|
25
|
+
// that exact string at render time).
|
|
26
|
+
const widgetAreaSchema = z.object({
|
|
27
|
+
name: z.string().min(1, "widget area name is required"),
|
|
28
|
+
label: z.string().min(1, "widget area label is required"),
|
|
29
|
+
});
|
|
21
30
|
export class ThemeJsonValidationError extends Error {
|
|
22
31
|
constructor(issues) {
|
|
23
32
|
super(`theme.json failed validation: ${issues.join("; ")}`);
|
|
@@ -64,6 +73,7 @@ export const themeJsonSchema = z.object({
|
|
|
64
73
|
screenshots: z.array(z.string()).optional().default([]),
|
|
65
74
|
settings: z.array(settingsFieldSchema).optional().default([]),
|
|
66
75
|
allowedSections: z.record(z.string(), z.array(z.string())).optional(),
|
|
76
|
+
widgetAreas: z.array(widgetAreaSchema).optional().default([]),
|
|
67
77
|
});
|
|
68
78
|
/** Parses+validates a raw `theme.json` payload (already `JSON.parse`d). Throws `ThemeJsonValidationError` with every issue found, never just the first. */
|
|
69
79
|
export function parseThemeJson(raw) {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ZodTypeAny } from "zod";
|
|
2
|
+
/** The fixed set of widget type ids. Adding a type means widening this union + `WIDGET_TYPE_REGISTRY` together — never by letting a theme declare its own. */
|
|
3
|
+
export type WidgetType = "recent_posts" | "text" | "category_list" | "tag_cloud" | "ad_slot" | "newsletter_placeholder" | "search";
|
|
4
|
+
/** One entry in `WIDGET_TYPE_REGISTRY` — see this module's header comment. */
|
|
5
|
+
export interface WidgetTypeDefinition {
|
|
6
|
+
type: WidgetType;
|
|
7
|
+
label: string;
|
|
8
|
+
schema: ZodTypeAny;
|
|
9
|
+
defaultSettings: () => Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
export declare const WIDGET_TYPE_REGISTRY: Record<WidgetType, WidgetTypeDefinition>;
|
|
12
|
+
/** Every registered widget type id, in the fixed display order above — the admin "add widget" picker's list. */
|
|
13
|
+
export declare const WIDGET_TYPES: WidgetType[];
|
|
14
|
+
export declare function isKnownWidgetType(type: string): type is WidgetType;
|
|
15
|
+
/**
|
|
16
|
+
* Thrown by `validateWidgetSettings` (and, in turn, `WidgetRepository.
|
|
17
|
+
* createWidget`/`updateWidget`) for an unknown `type` or a `settings` shape
|
|
18
|
+
* that fails that type's schema. `issues` carries every problem found, not
|
|
19
|
+
* just the first — same "input is one all-or-nothing unit" contract as
|
|
20
|
+
* `SectionValidationError`/`ThemeJsonValidationError`.
|
|
21
|
+
*/
|
|
22
|
+
export declare class WidgetValidationError extends Error {
|
|
23
|
+
readonly issues: string[];
|
|
24
|
+
constructor(issues: string[]);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Validates+coerces `settings` against `type`'s registered Zod schema.
|
|
28
|
+
* Returns the VALIDATED+COERCED object (Zod defaults applied) rather than
|
|
29
|
+
* the raw input, so callers persist the normalized shape — same contract
|
|
30
|
+
* as `../lib/sections.ts`'s `validateSections`. Throws `WidgetValidationError`
|
|
31
|
+
* for an unknown `type` too, so a caller never needs a separate
|
|
32
|
+
* `isKnownWidgetType` check before calling this.
|
|
33
|
+
*/
|
|
34
|
+
export declare function validateWidgetSettings(type: string, settings: unknown): Record<string, unknown>;
|
|
35
|
+
//# sourceMappingURL=widgets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widgets.d.ts","sourceRoot":"","sources":["../../src/lib/widgets.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAK,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AAEzC,8JAA8J;AAC9J,MAAM,MAAM,UAAU,GAClB,cAAc,GACd,MAAM,GACN,eAAe,GACf,WAAW,GACX,SAAS,GACT,wBAAwB,GACxB,QAAQ,CAAC;AA+Db,8EAA8E;AAC9E,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;IACnB,eAAe,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChD;AAED,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,UAAU,EAAE,oBAAoB,CAiDzE,CAAC;AAEF,gHAAgH;AAChH,eAAO,MAAM,YAAY,EAAE,UAAU,EAAsD,CAAC;AAE5F,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,UAAU,CAElE;AAED;;;;;;GAMG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;gBACd,MAAM,EAAE,MAAM,EAAE;CAK7B;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAS/F"}
|