emdash 0.33.0 → 0.34.0
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/dist/{adapters-BMyNSSZi.d.mts → adapters-34EN2eXO.d.mts} +26 -2
- package/dist/adapters-34EN2eXO.d.mts.map +1 -0
- package/dist/{allowed-origins-CG1pACtS.mjs → allowed-origins-DW7sYyqg.mjs} +2 -2
- package/dist/{allowed-origins-CG1pACtS.mjs.map → allowed-origins-DW7sYyqg.mjs.map} +1 -1
- package/dist/api/route-utils.d.mts +3 -3
- package/dist/api/route-utils.mjs +22 -21
- package/dist/api/route-utils.mjs.map +1 -1
- package/dist/api/schemas/index.d.mts +2 -2
- package/dist/api/schemas/index.mjs +6 -5
- package/dist/{api-D2hunekQ.mjs → api-DdAsirBe.mjs} +98 -407
- package/dist/api-DdAsirBe.mjs.map +1 -0
- package/dist/{api-tokens-CSND0i1z.mjs → api-tokens-CFXu8F_2.mjs} +2 -2
- package/dist/{api-tokens-CSND0i1z.mjs.map → api-tokens-CFXu8F_2.mjs.map} +1 -1
- package/dist/{apply-kwNEJW2l.mjs → apply-D5zfeD09.mjs} +131 -107
- package/dist/apply-D5zfeD09.mjs.map +1 -0
- package/dist/astro/index.d.mts +12 -12
- package/dist/astro/index.d.mts.map +1 -1
- package/dist/astro/index.mjs +93 -35
- package/dist/astro/index.mjs.map +1 -1
- package/dist/astro/middleware/auth.d.mts +10 -10
- package/dist/astro/middleware/auth.mjs +8 -8
- package/dist/astro/middleware/media-usage-write-fence.d.mts +7 -0
- package/dist/astro/middleware/media-usage-write-fence.d.mts.map +1 -0
- package/dist/astro/middleware/media-usage-write-fence.mjs +35 -0
- package/dist/astro/middleware/media-usage-write-fence.mjs.map +1 -0
- package/dist/astro/middleware/redirect.d.mts.map +1 -1
- package/dist/astro/middleware/redirect.mjs +10 -7
- package/dist/astro/middleware/redirect.mjs.map +1 -1
- package/dist/astro/middleware/request-context.mjs +3 -3
- package/dist/astro/middleware/setup.mjs +1 -1
- package/dist/astro/middleware.d.mts +12 -11
- package/dist/astro/middleware.d.mts.map +1 -1
- package/dist/astro/middleware.mjs +1677 -156
- package/dist/astro/middleware.mjs.map +1 -1
- package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +9 -8
- package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs.map +1 -1
- package/dist/astro/routes/api/admin/allowed-domains/index.mjs +9 -8
- package/dist/astro/routes/api/admin/allowed-domains/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +5 -5
- package/dist/astro/routes/api/admin/api-tokens/index.mjs +6 -6
- package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +6 -6
- package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +12 -11
- package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs.map +1 -1
- package/dist/astro/routes/api/admin/byline-fields/index.mjs +12 -11
- package/dist/astro/routes/api/admin/byline-fields/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +12 -11
- package/dist/astro/routes/api/admin/byline-fields/reorder.mjs.map +1 -1
- package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +17 -17
- package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +17 -17
- package/dist/astro/routes/api/admin/bylines/index.mjs +17 -17
- package/dist/astro/routes/api/admin/comments/_id_/status.mjs +14 -13
- package/dist/astro/routes/api/admin/comments/_id_/status.mjs.map +1 -1
- package/dist/astro/routes/api/admin/comments/_id_.mjs +6 -6
- package/dist/astro/routes/api/admin/comments/bulk.mjs +12 -11
- package/dist/astro/routes/api/admin/comments/bulk.mjs.map +1 -1
- package/dist/astro/routes/api/admin/comments/counts.mjs +6 -6
- package/dist/astro/routes/api/admin/comments/index.mjs +12 -11
- package/dist/astro/routes/api/admin/comments/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +5 -5
- package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +4 -4
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.d.mts +8 -0
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.d.mts.map +1 -0
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs +36 -0
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs.map +1 -0
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.d.mts +8 -0
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.d.mts.map +1 -0
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs +36 -0
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs.map +1 -0
- package/dist/astro/routes/api/admin/media-usage/repair.mjs +15 -14
- package/dist/astro/routes/api/admin/media-usage/repair.mjs.map +1 -1
- package/dist/astro/routes/api/admin/media-usage/work/index.d.mts +8 -0
- package/dist/astro/routes/api/admin/media-usage/work/index.d.mts.map +1 -0
- package/dist/astro/routes/api/admin/media-usage/work/index.mjs +37 -0
- package/dist/astro/routes/api/admin/media-usage/work/index.mjs.map +1 -0
- package/dist/astro/routes/api/admin/media-usage/work/retry.d.mts +8 -0
- package/dist/astro/routes/api/admin/media-usage/work/retry.d.mts.map +1 -0
- package/dist/astro/routes/api/admin/media-usage/work/retry.mjs +37 -0
- package/dist/astro/routes/api/admin/media-usage/work/retry.mjs.map +1 -0
- package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +5 -5
- package/dist/astro/routes/api/admin/oauth-clients/index.mjs +5 -5
- package/dist/astro/routes/api/admin/plugins/_id_/disable.d.mts.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +51 -43
- package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/enable.d.mts.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +51 -43
- package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +47 -42
- package/dist/astro/routes/api/admin/plugins/_id_/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/mcp.mjs +6 -6
- package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs +47 -42
- package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/uninstall.d.mts.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +50 -42
- package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/update.d.mts.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +50 -42
- package/dist/astro/routes/api/admin/plugins/_id_/update.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/index.mjs +47 -42
- package/dist/astro/routes/api/admin/plugins/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +4 -4
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +47 -42
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.d.mts.map +1 -1
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +50 -42
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +47 -42
- package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.d.mts.map +1 -1
- package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs +50 -42
- package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/registry/_id_/update.d.mts.map +1 -1
- package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs +51 -43
- package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs +47 -42
- package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/registry/install.d.mts.map +1 -1
- package/dist/astro/routes/api/admin/plugins/registry/install.mjs +51 -43
- package/dist/astro/routes/api/admin/plugins/registry/install.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/updates.mjs +47 -42
- package/dist/astro/routes/api/admin/plugins/updates.mjs.map +1 -1
- package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +47 -42
- package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +4 -4
- package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +47 -42
- package/dist/astro/routes/api/admin/themes/marketplace/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/users/_id_/disable.mjs +3 -3
- package/dist/astro/routes/api/admin/users/_id_/enable.mjs +3 -3
- package/dist/astro/routes/api/admin/users/_id_/index.mjs +9 -8
- package/dist/astro/routes/api/admin/users/_id_/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +4 -4
- package/dist/astro/routes/api/admin/users/index.mjs +9 -8
- package/dist/astro/routes/api/admin/users/index.mjs.map +1 -1
- package/dist/astro/routes/api/auth/dev-bypass.mjs +7 -7
- package/dist/astro/routes/api/auth/invite/accept.mjs +3 -3
- package/dist/astro/routes/api/auth/invite/complete.mjs +13 -12
- package/dist/astro/routes/api/auth/invite/complete.mjs.map +1 -1
- package/dist/astro/routes/api/auth/invite/index.mjs +10 -9
- package/dist/astro/routes/api/auth/invite/index.mjs.map +1 -1
- package/dist/astro/routes/api/auth/invite/register-options.mjs +12 -11
- package/dist/astro/routes/api/auth/invite/register-options.mjs.map +1 -1
- package/dist/astro/routes/api/auth/logout.mjs +4 -4
- package/dist/astro/routes/api/auth/magic-link/send.mjs +12 -11
- package/dist/astro/routes/api/auth/magic-link/send.mjs.map +1 -1
- package/dist/astro/routes/api/auth/magic-link/verify.mjs +4 -4
- package/dist/astro/routes/api/auth/me.mjs +10 -9
- package/dist/astro/routes/api/auth/me.mjs.map +1 -1
- package/dist/astro/routes/api/auth/mode.mjs +4 -4
- package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +3 -3
- package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
- package/dist/astro/routes/api/auth/passkey/_id_.mjs +9 -8
- package/dist/astro/routes/api/auth/passkey/_id_.mjs.map +1 -1
- package/dist/astro/routes/api/auth/passkey/index.mjs +3 -3
- package/dist/astro/routes/api/auth/passkey/options.mjs +14 -13
- package/dist/astro/routes/api/auth/passkey/options.mjs.map +1 -1
- package/dist/astro/routes/api/auth/passkey/register/options.mjs +12 -11
- package/dist/astro/routes/api/auth/passkey/register/options.mjs.map +1 -1
- package/dist/astro/routes/api/auth/passkey/register/verify.mjs +13 -12
- package/dist/astro/routes/api/auth/passkey/register/verify.mjs.map +1 -1
- package/dist/astro/routes/api/auth/passkey/verify.mjs +13 -12
- package/dist/astro/routes/api/auth/passkey/verify.mjs.map +1 -1
- package/dist/astro/routes/api/auth/signup/complete.mjs +13 -12
- package/dist/astro/routes/api/auth/signup/complete.mjs.map +1 -1
- package/dist/astro/routes/api/auth/signup/request.mjs +12 -11
- package/dist/astro/routes/api/auth/signup/request.mjs.map +1 -1
- package/dist/astro/routes/api/auth/signup/verify.mjs +3 -3
- package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +15 -14
- package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs.map +1 -1
- package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +14 -13
- package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +5 -5
- package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +5 -5
- package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +13 -13
- package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +11 -10
- package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs +18 -17
- package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs +18 -17
- package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +5 -5
- package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +11 -10
- package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.d.mts.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +44 -31
- package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +5 -5
- package/dist/astro/routes/api/content/_collection_/_id_.mjs +11 -10
- package/dist/astro/routes/api/content/_collection_/_id_.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/authors.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/index.mjs +11 -10
- package/dist/astro/routes/api/content/_collection_/index.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/trash.mjs +10 -9
- package/dist/astro/routes/api/content/_collection_/trash.mjs.map +1 -1
- package/dist/astro/routes/api/dashboard.mjs +10 -8
- package/dist/astro/routes/api/dashboard.mjs.map +1 -1
- package/dist/astro/routes/api/dev/emails.mjs +4 -4
- package/dist/astro/routes/api/import/probe.d.mts +3 -3
- package/dist/astro/routes/api/import/probe.mjs +18 -16
- package/dist/astro/routes/api/import/probe.mjs.map +1 -1
- package/dist/astro/routes/api/import/wordpress/analyze.mjs +5 -5
- package/dist/astro/routes/api/import/wordpress/execute.d.mts +11 -11
- package/dist/astro/routes/api/import/wordpress/execute.mjs +15 -15
- package/dist/astro/routes/api/import/wordpress/execute.mjs.map +1 -1
- package/dist/astro/routes/api/import/wordpress/media.d.mts +10 -10
- package/dist/astro/routes/api/import/wordpress/media.mjs +14 -12
- package/dist/astro/routes/api/import/wordpress/media.mjs.map +1 -1
- package/dist/astro/routes/api/import/wordpress/prepare.mjs +13 -12
- package/dist/astro/routes/api/import/wordpress/prepare.mjs.map +1 -1
- package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +11 -11
- package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +14 -14
- package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
- package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +18 -16
- package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs.map +1 -1
- package/dist/astro/routes/api/import/wordpress-plugin/callback.mjs +1 -1
- package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +11 -11
- package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +28 -27
- package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs.map +1 -1
- package/dist/astro/routes/api/manifest.mjs +5 -5
- package/dist/astro/routes/api/mcp.d.mts.map +1 -1
- package/dist/astro/routes/api/mcp.mjs +174 -72
- package/dist/astro/routes/api/mcp.mjs.map +1 -1
- package/dist/astro/routes/api/media/_id_/confirm.mjs +13 -11
- package/dist/astro/routes/api/media/_id_/confirm.mjs.map +1 -1
- package/dist/astro/routes/api/media/_id_/upload.mjs +6 -6
- package/dist/astro/routes/api/media/_id_/usage.mjs +17 -16
- package/dist/astro/routes/api/media/_id_/usage.mjs.map +1 -1
- package/dist/astro/routes/api/media/_id_.mjs +16 -15
- package/dist/astro/routes/api/media/_id_.mjs.map +1 -1
- package/dist/astro/routes/api/media/file/_...key_.mjs +3 -3
- package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +4 -4
- package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +4 -4
- package/dist/astro/routes/api/media/providers/index.mjs +4 -4
- package/dist/astro/routes/api/media/upload-url.mjs +11 -10
- package/dist/astro/routes/api/media/upload-url.mjs.map +1 -1
- package/dist/astro/routes/api/media.mjs +18 -15
- package/dist/astro/routes/api/media.mjs.map +1 -1
- package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +11 -11
- package/dist/astro/routes/api/menus/_name_/items.mjs +11 -11
- package/dist/astro/routes/api/menus/_name_/reorder.mjs +11 -11
- package/dist/astro/routes/api/menus/_name_/translations.mjs +11 -11
- package/dist/astro/routes/api/menus/_name_.mjs +11 -11
- package/dist/astro/routes/api/menus/index.mjs +11 -11
- package/dist/astro/routes/api/oauth/authorize.mjs +6 -6
- package/dist/astro/routes/api/oauth/device/authorize.mjs +7 -7
- package/dist/astro/routes/api/oauth/device/code.mjs +10 -10
- package/dist/astro/routes/api/oauth/device/token.mjs +9 -9
- package/dist/astro/routes/api/oauth/register.mjs +4 -4
- package/dist/astro/routes/api/oauth/token/refresh.mjs +7 -7
- package/dist/astro/routes/api/oauth/token/revoke.mjs +7 -7
- package/dist/astro/routes/api/oauth/token.mjs +7 -7
- package/dist/astro/routes/api/openapi.json.mjs +152 -6
- package/dist/astro/routes/api/openapi.json.mjs.map +1 -1
- package/dist/astro/routes/api/plugins/_pluginId_/_...path_.d.mts.map +1 -1
- package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +8 -7
- package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs.map +1 -1
- package/dist/astro/routes/api/redirects/404s/index.mjs +12 -11
- package/dist/astro/routes/api/redirects/404s/index.mjs.map +1 -1
- package/dist/astro/routes/api/redirects/404s/summary.mjs +12 -11
- package/dist/astro/routes/api/redirects/404s/summary.mjs.map +1 -1
- package/dist/astro/routes/api/redirects/_id_.mjs +13 -12
- package/dist/astro/routes/api/redirects/_id_.mjs.map +1 -1
- package/dist/astro/routes/api/redirects/index.mjs +13 -12
- package/dist/astro/routes/api/redirects/index.mjs.map +1 -1
- package/dist/astro/routes/api/relations/_id_/index.mjs +18 -17
- package/dist/astro/routes/api/relations/_id_/index.mjs.map +1 -1
- package/dist/astro/routes/api/relations/_id_/translations.mjs +13 -12
- package/dist/astro/routes/api/relations/_id_/translations.mjs.map +1 -1
- package/dist/astro/routes/api/relations/index.mjs +18 -17
- package/dist/astro/routes/api/relations/index.mjs.map +1 -1
- package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +4 -4
- package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +5 -5
- package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +47 -42
- package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs.map +1 -1
- package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +47 -42
- package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs.map +1 -1
- package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +47 -42
- package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs.map +1 -1
- package/dist/astro/routes/api/schema/collections/_slug_/index.d.mts.map +1 -1
- package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +47 -42
- package/dist/astro/routes/api/schema/collections/_slug_/index.mjs.map +1 -1
- package/dist/astro/routes/api/schema/collections/index.mjs +47 -42
- package/dist/astro/routes/api/schema/collections/index.mjs.map +1 -1
- package/dist/astro/routes/api/schema/collections/reorder.mjs +47 -42
- package/dist/astro/routes/api/schema/collections/reorder.mjs.map +1 -1
- package/dist/astro/routes/api/schema/index.mjs +10 -9
- package/dist/astro/routes/api/schema/index.mjs.map +1 -1
- package/dist/astro/routes/api/schema/orphans/_slug_.mjs +47 -42
- package/dist/astro/routes/api/schema/orphans/_slug_.mjs.map +1 -1
- package/dist/astro/routes/api/schema/orphans/index.mjs +47 -42
- package/dist/astro/routes/api/schema/orphans/index.mjs.map +1 -1
- package/dist/astro/routes/api/search/enable.mjs +13 -13
- package/dist/astro/routes/api/search/index.mjs +12 -12
- package/dist/astro/routes/api/search/rebuild.mjs +13 -13
- package/dist/astro/routes/api/search/stats.mjs +8 -8
- package/dist/astro/routes/api/search/suggest.mjs +12 -12
- package/dist/astro/routes/api/sections/_slug_.mjs +12 -11
- package/dist/astro/routes/api/sections/_slug_.mjs.map +1 -1
- package/dist/astro/routes/api/sections/index.mjs +12 -11
- package/dist/astro/routes/api/sections/index.mjs.map +1 -1
- package/dist/astro/routes/api/settings/backups/archives/_name_.mjs +7 -7
- package/dist/astro/routes/api/settings/backups/archives/index.mjs +6 -6
- package/dist/astro/routes/api/settings/backups/export.mjs +7 -7
- package/dist/astro/routes/api/settings/backups/index.mjs +8 -8
- package/dist/astro/routes/api/settings/email.mjs +5 -5
- package/dist/astro/routes/api/settings.mjs +14 -13
- package/dist/astro/routes/api/settings.mjs.map +1 -1
- package/dist/astro/routes/api/setup/admin-verify.mjs +14 -13
- package/dist/astro/routes/api/setup/admin-verify.mjs.map +1 -1
- package/dist/astro/routes/api/setup/admin.mjs +13 -12
- package/dist/astro/routes/api/setup/admin.mjs.map +1 -1
- package/dist/astro/routes/api/setup/dev-bypass.mjs +30 -28
- package/dist/astro/routes/api/setup/dev-bypass.mjs.map +1 -1
- package/dist/astro/routes/api/setup/dev-reset.mjs +3 -3
- package/dist/astro/routes/api/setup/index.mjs +32 -30
- package/dist/astro/routes/api/setup/index.mjs.map +1 -1
- package/dist/astro/routes/api/setup/status.mjs +5 -5
- package/dist/astro/routes/api/snapshot.mjs +8 -8
- package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs +16 -15
- package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs.map +1 -1
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +16 -15
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs.map +1 -1
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +16 -15
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs.map +1 -1
- package/dist/astro/routes/api/taxonomies/_name_/terms/index.d.mts.map +1 -1
- package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +18 -16
- package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs.map +1 -1
- package/dist/astro/routes/api/taxonomies/_name_/translations.d.mts +8 -0
- package/dist/astro/routes/api/taxonomies/_name_/translations.d.mts.map +1 -0
- package/dist/astro/routes/api/taxonomies/_name_/translations.mjs +46 -0
- package/dist/astro/routes/api/taxonomies/_name_/translations.mjs.map +1 -0
- package/dist/astro/routes/api/taxonomies/_name_.d.mts +19 -0
- package/dist/astro/routes/api/taxonomies/_name_.d.mts.map +1 -0
- package/dist/astro/routes/api/taxonomies/_name_.mjs +88 -0
- package/dist/astro/routes/api/taxonomies/_name_.mjs.map +1 -0
- package/dist/astro/routes/api/taxonomies/index.mjs +16 -15
- package/dist/astro/routes/api/taxonomies/index.mjs.map +1 -1
- package/dist/astro/routes/api/themes/preview.mjs +6 -6
- package/dist/astro/routes/api/typegen.mjs +6 -6
- package/dist/astro/routes/api/well-known/auth.mjs +1 -1
- package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +2 -2
- package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +2 -2
- package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +10 -9
- package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs.map +1 -1
- package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +12 -11
- package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs.map +1 -1
- package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +12 -11
- package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs.map +1 -1
- package/dist/astro/routes/api/widget-areas/_name_.mjs +7 -6
- package/dist/astro/routes/api/widget-areas/_name_.mjs.map +1 -1
- package/dist/astro/routes/api/widget-areas/index.mjs +12 -11
- package/dist/astro/routes/api/widget-areas/index.mjs.map +1 -1
- package/dist/astro/routes/api/widget-components.mjs +4 -4
- package/dist/astro/routes/robots.txt.mjs +7 -6
- package/dist/astro/routes/robots.txt.mjs.map +1 -1
- package/dist/astro/routes/sitemap-_collection_.xml.mjs +10 -10
- package/dist/astro/routes/sitemap.xml.mjs +8 -7
- package/dist/astro/routes/sitemap.xml.mjs.map +1 -1
- package/dist/astro/types.d.mts +35 -17
- package/dist/astro/types.d.mts.map +1 -1
- package/dist/auth/providers/github.d.mts +1 -1
- package/dist/auth/providers/google.d.mts +1 -1
- package/dist/{authorize-qRhWQnel.mjs → authorize-1iFJzPaZ.mjs} +2 -2
- package/dist/{authorize-qRhWQnel.mjs.map → authorize-1iFJzPaZ.mjs.map} +1 -1
- package/dist/{backup-CtA6LDNw.mjs → backup-LHjIAVNP.mjs} +4 -4
- package/dist/{backup-CtA6LDNw.mjs.map → backup-LHjIAVNP.mjs.map} +1 -1
- package/dist/{base64-B-PsqheR.mjs → base64-CvLhUKQv.mjs} +1 -1
- package/dist/{base64-B-PsqheR.mjs.map → base64-CvLhUKQv.mjs.map} +1 -1
- package/dist/bundle-CBEXrBnb.mjs +663 -0
- package/dist/bundle-CBEXrBnb.mjs.map +1 -0
- package/dist/{byline-fields-CNc0Yq5i.mjs → byline-fields-C5S8wygO.mjs} +2 -2
- package/dist/{byline-fields-CNc0Yq5i.mjs.map → byline-fields-C5S8wygO.mjs.map} +1 -1
- package/dist/{byline-Cp6csL84.mjs → byline-pEcoDps8.mjs} +5 -5
- package/dist/{byline-Cp6csL84.mjs.map → byline-pEcoDps8.mjs.map} +1 -1
- package/dist/{byline-registry-ZkPKqEwC.mjs → byline-registry-DDun8sxh.mjs} +2 -2
- package/dist/{byline-registry-ZkPKqEwC.mjs.map → byline-registry-DDun8sxh.mjs.map} +1 -1
- package/dist/{bylines-CEj5CdT4.mjs → bylines-BWemdX2k.mjs} +7 -7
- package/dist/{bylines-CEj5CdT4.mjs.map → bylines-BWemdX2k.mjs.map} +1 -1
- package/dist/{bylines-cf-C9lmF.mjs → bylines-DJfSfXCL.mjs} +5 -5
- package/dist/{bylines-cf-C9lmF.mjs.map → bylines-DJfSfXCL.mjs.map} +1 -1
- package/dist/{cache-C9FptTFR.mjs → cache-CBJaDy_E.mjs} +3 -3
- package/dist/{cache-C9FptTFR.mjs.map → cache-CBJaDy_E.mjs.map} +1 -1
- package/dist/{challenge-store-D9VNKELo.mjs → challenge-store-CZyFVaad.mjs} +1 -1
- package/dist/{challenge-store-D9VNKELo.mjs.map → challenge-store-CZyFVaad.mjs.map} +1 -1
- package/dist/{chunks-DbYzib_k.mjs → chunks-DfPax1I0.mjs} +2 -2
- package/dist/{chunks-DbYzib_k.mjs.map → chunks-DfPax1I0.mjs.map} +1 -1
- package/dist/cli/index.mjs +176 -698
- package/dist/cli/index.mjs.map +1 -1
- package/dist/client/cf-access.d.mts +1 -1
- package/dist/client/index.d.mts +74 -4
- package/dist/client/index.d.mts.map +1 -1
- package/dist/client/index.mjs +25 -2
- package/dist/client/index.mjs.map +1 -1
- package/dist/collection-deletion-C8BugSGz.mjs +779 -0
- package/dist/collection-deletion-C8BugSGz.mjs.map +1 -0
- package/dist/{comment-BIkJ6Fil.mjs → comment-Dxlep6cE.mjs} +2 -2
- package/dist/{comment-BIkJ6Fil.mjs.map → comment-Dxlep6cE.mjs.map} +1 -1
- package/dist/{comment-reaction-D-laEceb.mjs → comment-reaction-D6qfHKBc.mjs} +2 -2
- package/dist/{comment-reaction-D-laEceb.mjs.map → comment-reaction-D6qfHKBc.mjs.map} +1 -1
- package/dist/{comments-0_w6KChA.mjs → comments-CTOuhTSX.mjs} +3 -3
- package/dist/{comments-0_w6KChA.mjs.map → comments-CTOuhTSX.mjs.map} +1 -1
- package/dist/{components-BPxrRjpE.mjs → components-CQy3lh9x.mjs} +1 -1
- package/dist/{components-BPxrRjpE.mjs.map → components-CQy3lh9x.mjs.map} +1 -1
- package/dist/{config-DyF3OKg_.mjs → config-C3EBstHi.mjs} +18 -2
- package/dist/config-C3EBstHi.mjs.map +1 -0
- package/dist/{content-CJ94NEx5.mjs → content-BNfwh7xX.mjs} +509 -78
- package/dist/content-BNfwh7xX.mjs.map +1 -0
- package/dist/content-list-query-DhQ84eVV.d.mts +26 -0
- package/dist/content-list-query-DhQ84eVV.d.mts.map +1 -0
- package/dist/content-refresh-DNERP4-f.mjs +2560 -0
- package/dist/content-refresh-DNERP4-f.mjs.map +1 -0
- package/dist/{context-C_1nrqnW.mjs → context-DRgOvSnW.mjs} +25 -17
- package/dist/context-DRgOvSnW.mjs.map +1 -0
- package/dist/{cron-DRV-UC4K.mjs → cron-Y9aLtgrA.mjs} +1 -1
- package/dist/{cron-DRV-UC4K.mjs.map → cron-Y9aLtgrA.mjs.map} +1 -1
- package/dist/{dashboard-DINnNVVU.mjs → dashboard-CB8J89rJ.mjs} +44 -10
- package/dist/dashboard-CB8J89rJ.mjs.map +1 -0
- package/dist/db/index.d.mts +4 -4
- package/dist/db/index.mjs +2 -2
- package/dist/db/index.mjs.map +1 -1
- package/dist/db/libsql.d.mts +1 -1
- package/dist/db/postgres.d.mts +1 -1
- package/dist/db/sqlite.d.mts +1 -1
- package/dist/{db-errors-CcWLaRiR.mjs → db-errors-Cl-sKYTm.mjs} +1 -1
- package/dist/{db-errors-CcWLaRiR.mjs.map → db-errors-Cl-sKYTm.mjs.map} +1 -1
- package/dist/{default-BD2FG0xV.mjs → default-DdDl3fxv.mjs} +1 -1
- package/dist/{default-BD2FG0xV.mjs.map → default-DdDl3fxv.mjs.map} +1 -1
- package/dist/{deferred-tasks-C-WRCcKo.d.mts → deferred-tasks-BMsa9F64.d.mts} +1 -1
- package/dist/{deferred-tasks-C-WRCcKo.d.mts.map → deferred-tasks-BMsa9F64.d.mts.map} +1 -1
- package/dist/{device-flow-CTqd8mud.mjs → device-flow-CaioYGK3.mjs} +4 -4
- package/dist/{device-flow-CTqd8mud.mjs.map → device-flow-CaioYGK3.mjs.map} +1 -1
- package/dist/dist-D_6CKR8z.mjs +810 -0
- package/dist/dist-D_6CKR8z.mjs.map +1 -0
- package/dist/{email-console-C6WdcWbL.mjs → email-console-BHNjIwiB.mjs} +1 -1
- package/dist/{email-console-C6WdcWbL.mjs.map → email-console-BHNjIwiB.mjs.map} +1 -1
- package/dist/{enrich-CFJJgxs_.mjs → enrich-_ySMEvEE.mjs} +2 -2
- package/dist/{enrich-CFJJgxs_.mjs.map → enrich-_ySMEvEE.mjs.map} +1 -1
- package/dist/{error-oh_9i6bR.mjs → error-DupyJZE2.mjs} +3 -3
- package/dist/{error-oh_9i6bR.mjs.map → error-DupyJZE2.mjs.map} +1 -1
- package/dist/{errors-BucQ8VYz.mjs → errors-CLUPm7aD.mjs} +14 -2
- package/dist/errors-CLUPm7aD.mjs.map +1 -0
- package/dist/{escape-CXps5F_v.mjs → escape-C_aLKP3H.mjs} +1 -1
- package/dist/{escape-CXps5F_v.mjs.map → escape-C_aLKP3H.mjs.map} +1 -1
- package/dist/{field-defs-cache-WD82dMQq.mjs → field-defs-cache-hg6QkjV9.mjs} +4 -4
- package/dist/{field-defs-cache-WD82dMQq.mjs.map → field-defs-cache-hg6QkjV9.mjs.map} +1 -1
- package/dist/{fts-manager-BITakW_R.mjs → fts-manager-CZ-5dVwJ.mjs} +76 -50
- package/dist/fts-manager-CZ-5dVwJ.mjs.map +1 -0
- package/dist/{hreflang-BaLCNcDx.d.mts → hreflang-D3Uehfv2.d.mts} +2 -2
- package/dist/{hreflang-BaLCNcDx.d.mts.map → hreflang-D3Uehfv2.d.mts.map} +1 -1
- package/dist/{hreflang-BdZuVBhL.mjs → hreflang-DNswoYsi.mjs} +7 -7
- package/dist/{hreflang-BdZuVBhL.mjs.map → hreflang-DNswoYsi.mjs.map} +1 -1
- package/dist/{import-C-9uqyT3.mjs → import-B41u8Rot.mjs} +5 -5
- package/dist/{import-C-9uqyT3.mjs.map → import-B41u8Rot.mjs.map} +1 -1
- package/dist/{index-M37iz29I.d.mts → index-C3Y-rsyN.d.mts} +226 -73
- package/dist/index-C3Y-rsyN.d.mts.map +1 -0
- package/dist/{index-MGw47uWq.d.mts → index-Cof4-Fab.d.mts} +5 -10
- package/dist/index-Cof4-Fab.d.mts.map +1 -0
- package/dist/index.d.mts +20 -19
- package/dist/index.mjs +73 -67
- package/dist/{init-lock-DJkX6Hto.mjs → init-lock-6b309ZrF.mjs} +1 -1
- package/dist/{init-lock-DJkX6Hto.mjs.map → init-lock-6b309ZrF.mjs.map} +1 -1
- package/dist/{load-DV1DZuUJ.mjs → load-DmvJrtxS.mjs} +2 -2
- package/dist/{load-DV1DZuUJ.mjs.map → load-DmvJrtxS.mjs.map} +1 -1
- package/dist/{loader-CGugY7Zl.mjs → loader-DLBqRiGP.mjs} +95 -53
- package/dist/loader-DLBqRiGP.mjs.map +1 -0
- package/dist/{manifest-schema-Da7kj23y.mjs → manifest-schema-BXbUAHod.mjs} +1 -1
- package/dist/{manifest-schema-Da7kj23y.mjs.map → manifest-schema-BXbUAHod.mjs.map} +1 -1
- package/dist/media/image-endpoint.mjs +1 -1
- package/dist/media/index.d.mts +1 -1
- package/dist/media/index.mjs +3 -2
- package/dist/media/index.mjs.map +1 -1
- package/dist/media/local-runtime.d.mts +12 -12
- package/dist/media/local-runtime.mjs +6 -5
- package/dist/media/local-runtime.mjs.map +1 -1
- package/dist/{media-OhYL-7Io.mjs → media-BWWWb8kg.mjs} +92 -3
- package/dist/media-BWWWb8kg.mjs.map +1 -0
- package/dist/{media-BP7S-nHT.mjs → media-CzhAn2--.mjs} +2 -2
- package/dist/{media-BP7S-nHT.mjs.map → media-CzhAn2--.mjs.map} +1 -1
- package/dist/{media-allowlist-D-peH1H5.mjs → media-allowlist-BD6HhgXA.mjs} +14 -3
- package/dist/media-allowlist-BD6HhgXA.mjs.map +1 -0
- package/dist/{media-upload-DtrwU2B0.mjs → media-upload-9yas9zGH.mjs} +10 -8
- package/dist/{media-upload-DtrwU2B0.mjs.map → media-upload-9yas9zGH.mjs.map} +1 -1
- package/dist/{media-url-DYs_YLOx.mjs → media-url-BvoX88FA.mjs} +1 -1
- package/dist/{media-url-DYs_YLOx.mjs.map → media-url-BvoX88FA.mjs.map} +1 -1
- package/dist/{media-usage-BlxfTkN0.mjs → media-usage-De3qvwjc.mjs} +137 -60
- package/dist/media-usage-De3qvwjc.mjs.map +1 -0
- package/dist/media-usage-work-B9Bksh_b.mjs +152 -0
- package/dist/media-usage-work-B9Bksh_b.mjs.map +1 -0
- package/dist/media-usage-work-DrCbqBcl.mjs +424 -0
- package/dist/media-usage-work-DrCbqBcl.mjs.map +1 -0
- package/dist/media-usage-write-fence-aHEgN1zB.mjs +42 -0
- package/dist/media-usage-write-fence-aHEgN1zB.mjs.map +1 -0
- package/dist/{menus-Y54RDPIN.mjs → menus-CC-yn1F9.mjs} +351 -95
- package/dist/menus-CC-yn1F9.mjs.map +1 -0
- package/dist/{menus-BcQWxeXu.mjs → menus-fxvEDYE6.mjs} +3 -3
- package/dist/{menus-BcQWxeXu.mjs.map → menus-fxvEDYE6.mjs.map} +1 -1
- package/dist/{mode-BWyTBe3I.mjs → mode-Bpe-tNNy.mjs} +1 -1
- package/dist/{mode-BWyTBe3I.mjs.map → mode-Bpe-tNNy.mjs.map} +1 -1
- package/dist/{normalize-C-SHXmra.mjs → normalize-Bc-s_r-a.mjs} +1 -1
- package/dist/{normalize-C-SHXmra.mjs.map → normalize-Bc-s_r-a.mjs.map} +1 -1
- package/dist/{oauth-authorization-ClvktmrL.mjs → oauth-authorization-BXO1MKej.mjs} +4 -4
- package/dist/{oauth-authorization-ClvktmrL.mjs.map → oauth-authorization-BXO1MKej.mjs.map} +1 -1
- package/dist/{oauth-clients-8ao-U66l.mjs → oauth-clients-C_DNqtRu.mjs} +1 -1
- package/dist/{oauth-clients-8ao-U66l.mjs.map → oauth-clients-C_DNqtRu.mjs.map} +1 -1
- package/dist/{oauth-state-store-B1ofdTiQ.mjs → oauth-state-store-DwAxMtk4.mjs} +1 -1
- package/dist/{oauth-state-store-B1ofdTiQ.mjs.map → oauth-state-store-DwAxMtk4.mjs.map} +1 -1
- package/dist/{oauth-user-lookup-CscEuIiR.mjs → oauth-user-lookup-BxfZizdk.mjs} +1 -1
- package/dist/{oauth-user-lookup-CscEuIiR.mjs.map → oauth-user-lookup-BxfZizdk.mjs.map} +1 -1
- package/dist/object-cache/memory.d.mts +1 -1
- package/dist/{options-CA4eVX6P.d.mts → options-DRe1pIBL.d.mts} +4 -3
- package/dist/options-DRe1pIBL.d.mts.map +1 -0
- package/dist/page/index.d.mts +2 -2
- package/dist/{parse-CJKNuewM.mjs → parse-DFbuc-Fh.mjs} +2 -2
- package/dist/{parse-CJKNuewM.mjs.map → parse-DFbuc-Fh.mjs.map} +1 -1
- package/dist/{passkey-config-D-zrzMJI.mjs → passkey-config-_2GOwwK8.mjs} +1 -1
- package/dist/{passkey-config-D-zrzMJI.mjs.map → passkey-config-_2GOwwK8.mjs.map} +1 -1
- package/dist/{placeholder-DaeNS-VG.d.mts → placeholder-CzW7Lshs.d.mts} +1 -1
- package/dist/{placeholder-DaeNS-VG.d.mts.map → placeholder-CzW7Lshs.d.mts.map} +1 -1
- package/dist/plugin-types.d.mts +8 -1
- package/dist/plugin-types.d.mts.map +1 -1
- package/dist/plugin-utils.d.mts +10 -10
- package/dist/plugins/adapt-sandbox-entry.d.mts +10 -10
- package/dist/plugins/adapt-sandbox-entry.mjs +7 -4
- package/dist/plugins/adapt-sandbox-entry.mjs.map +1 -1
- package/dist/{portable-text-B_kqBmXB.mjs → portable-text-DhKbDAGr.mjs} +1 -1
- package/dist/{portable-text-B_kqBmXB.mjs.map → portable-text-DhKbDAGr.mjs.map} +1 -1
- package/dist/{preview-BU6PaLpM.mjs → preview-PW-nOnq4.mjs} +2 -2
- package/dist/{preview-BU6PaLpM.mjs.map → preview-PW-nOnq4.mjs.map} +1 -1
- package/dist/{public-url-Ox9oOlgp.mjs → public-url-CWoFhQT8.mjs} +1 -1
- package/dist/{public-url-Ox9oOlgp.mjs.map → public-url-CWoFhQT8.mjs.map} +1 -1
- package/dist/{query-C5w7PsRQ.mjs → query-BgjfiLUQ.mjs} +31 -49
- package/dist/query-BgjfiLUQ.mjs.map +1 -0
- package/dist/{query-rC9HKv1N.mjs → query-vgZNwIhh.mjs} +3 -3
- package/dist/{query-rC9HKv1N.mjs.map → query-vgZNwIhh.mjs.map} +1 -1
- package/dist/{rate-limit-kug6q99V.mjs → rate-limit-L5anykgo.mjs} +2 -2
- package/dist/{rate-limit-kug6q99V.mjs.map → rate-limit-L5anykgo.mjs.map} +1 -1
- package/dist/{redirect-DIJxXKOG.mjs → redirect-COsS6SWJ.mjs} +2 -2
- package/dist/{redirect-DIJxXKOG.mjs.map → redirect-COsS6SWJ.mjs.map} +1 -1
- package/dist/{redirect-Egf2R9yP.mjs → redirect-KBNE3UEs.mjs} +1 -1
- package/dist/{redirect-Egf2R9yP.mjs.map → redirect-KBNE3UEs.mjs.map} +1 -1
- package/dist/{redirects-Bzm812bY.mjs → redirects-CufRQt0Q.mjs} +4 -4
- package/dist/{redirects-Bzm812bY.mjs.map → redirects-CufRQt0Q.mjs.map} +1 -1
- package/dist/{redirects-G8wAhWAf.mjs → redirects-cV9g7V-0.mjs} +133 -14
- package/dist/redirects-cV9g7V-0.mjs.map +1 -0
- package/dist/registry-C581V4TP.mjs +1275 -0
- package/dist/registry-C581V4TP.mjs.map +1 -0
- package/dist/{relation-Cbe3Sd3m.mjs → relation-DtmAQH7s.mjs} +3 -3
- package/dist/{relation-Cbe3Sd3m.mjs.map → relation-DtmAQH7s.mjs.map} +1 -1
- package/dist/{relations-Bw_E1TXo.mjs → relations-BBApI4e2.mjs} +3 -3
- package/dist/{relations-Bw_E1TXo.mjs.map → relations-BBApI4e2.mjs.map} +1 -1
- package/dist/{relations-qHwpUe66.mjs → relations-DICSyfsh.mjs} +6 -6
- package/dist/{relations-qHwpUe66.mjs.map → relations-DICSyfsh.mjs.map} +1 -1
- package/dist/{relations-G2ta7GIl.d.mts → relations-DItI3MN9.d.mts} +369 -35
- package/dist/relations-DItI3MN9.d.mts.map +1 -0
- package/dist/request-context.d.mts +1 -1
- package/dist/{request-meta-Df-jFbAd.mjs → request-meta-DgZJh3zG.mjs} +2 -2
- package/dist/{request-meta-Df-jFbAd.mjs.map → request-meta-DgZJh3zG.mjs.map} +1 -1
- package/dist/{resolve-DZzG4HqM.mjs → resolve-DOhVEvty.mjs} +2 -2
- package/dist/{resolve-DZzG4HqM.mjs.map → resolve-DOhVEvty.mjs.map} +1 -1
- package/dist/{runner-BFTrkYhu.mjs → runner-BiDvq5dv.mjs} +1157 -254
- package/dist/runner-BiDvq5dv.mjs.map +1 -0
- package/dist/{runner-BaADli8l.d.mts → runner-CgQbELYC.d.mts} +2 -2
- package/dist/{runner-BaADli8l.d.mts.map → runner-CgQbELYC.d.mts.map} +1 -1
- package/dist/runtime.d.mts +11 -11
- package/dist/runtime.mjs +4 -3
- package/dist/runtime.mjs.map +1 -1
- package/dist/{schema-CiQXr6_F.mjs → schema-BFyTg38T.mjs} +3 -3
- package/dist/{schema-CiQXr6_F.mjs.map → schema-BFyTg38T.mjs.map} +1 -1
- package/dist/schema-CeQSNwB3.mjs +390 -0
- package/dist/schema-CeQSNwB3.mjs.map +1 -0
- package/dist/{scopes-CNJVT5i5.mjs → scopes-BVeuhGBE.mjs} +3 -3
- package/dist/{scopes-CNJVT5i5.mjs.map → scopes-BVeuhGBE.mjs.map} +1 -1
- package/dist/{search-FZhx5dDU.mjs → search-BpuPKZb0.mjs} +25 -15
- package/dist/search-BpuPKZb0.mjs.map +1 -0
- package/dist/{secrets-DLd8RXee.mjs → secrets-dtYs2hDo.mjs} +3 -3
- package/dist/{secrets-DLd8RXee.mjs.map → secrets-dtYs2hDo.mjs.map} +1 -1
- package/dist/{sections-BrIrMUCn.mjs → sections-COctk6hf.mjs} +3 -3
- package/dist/{sections-BrIrMUCn.mjs.map → sections-COctk6hf.mjs.map} +1 -1
- package/dist/seed/index.d.mts +2 -2
- package/dist/seed/index.mjs +24 -22
- package/dist/seo/index.d.mts +3 -3
- package/dist/seo/index.mjs +16 -15
- package/dist/seo/index.mjs.map +1 -1
- package/dist/{seo-CobNfOvb.mjs → seo-AFpVvTqr.mjs} +5 -3
- package/dist/seo-AFpVvTqr.mjs.map +1 -0
- package/dist/{seo-DTHRntNC.mjs → seo-CvDxfvFb.mjs} +2 -2
- package/dist/{seo-DTHRntNC.mjs.map → seo-CvDxfvFb.mjs.map} +1 -1
- package/dist/{service-B-pYGPgR.mjs → service-xMiMSTsR.mjs} +3 -3
- package/dist/{service-B-pYGPgR.mjs.map → service-xMiMSTsR.mjs.map} +1 -1
- package/dist/{session-user-BvM9-zNl.mjs → session-user-BzVemLkw.mjs} +1 -1
- package/dist/{session-user-BvM9-zNl.mjs.map → session-user-BzVemLkw.mjs.map} +1 -1
- package/dist/{settings-kJhGiQ4z.mjs → settings-B372MV0p.mjs} +4 -4
- package/dist/{settings-kJhGiQ4z.mjs.map → settings-B372MV0p.mjs.map} +1 -1
- package/dist/{settings-DPHau-WH.mjs → settings-BE9aqn_9.mjs} +3 -3
- package/dist/{settings-DPHau-WH.mjs.map → settings-BE9aqn_9.mjs.map} +1 -1
- package/dist/{setup-complete-u50Qm8rY.mjs → setup-complete-DF7TAfD5.mjs} +1 -1
- package/dist/{setup-complete-u50Qm8rY.mjs.map → setup-complete-DF7TAfD5.mjs.map} +1 -1
- package/dist/{setup-nonce-DCjiiOD2.mjs → setup-nonce-Do-U_cg9.mjs} +1 -1
- package/dist/{setup-nonce-DCjiiOD2.mjs.map → setup-nonce-Do-U_cg9.mjs.map} +1 -1
- package/dist/{single-flight-cache-DW3w11Pu.mjs → single-flight-cache-B0eLKS6K.mjs} +2 -2
- package/dist/{single-flight-cache-DW3w11Pu.mjs.map → single-flight-cache-B0eLKS6K.mjs.map} +1 -1
- package/dist/{site-url-I-lJ5kma.mjs → site-url-Bowsi9T-.mjs} +2 -2
- package/dist/{site-url-I-lJ5kma.mjs.map → site-url-Bowsi9T-.mjs.map} +1 -1
- package/dist/slugify-B994zkXC.mjs +17 -0
- package/dist/slugify-B994zkXC.mjs.map +1 -0
- package/dist/{snapshot-I_fjLDaD.mjs → snapshot-B5h6aPMh.mjs} +1 -1
- package/dist/{snapshot-I_fjLDaD.mjs.map → snapshot-B5h6aPMh.mjs.map} +1 -1
- package/dist/{ssrf-CTa6v21i.mjs → ssrf-Cpvg_n3A.mjs} +1 -1
- package/dist/{ssrf-CTa6v21i.mjs.map → ssrf-Cpvg_n3A.mjs.map} +1 -1
- package/dist/{state-CQvoefYP.mjs → state-DYwPue40.mjs} +1 -1
- package/dist/{state-CQvoefYP.mjs.map → state-DYwPue40.mjs.map} +1 -1
- package/dist/{status-CIsmlC1E.mjs → status-CWVYpbD8.mjs} +1 -1
- package/dist/{status-CIsmlC1E.mjs.map → status-CWVYpbD8.mjs.map} +1 -1
- package/dist/storage/local.d.mts +1 -1
- package/dist/storage/local.mjs +1 -1
- package/dist/storage/s3.d.mts +1 -1
- package/dist/storage/s3.mjs +1 -1
- package/dist/{taxonomies-CLN1N92E.mjs → taxonomies-B0o9ExNV.mjs} +75 -64
- package/dist/taxonomies-B0o9ExNV.mjs.map +1 -0
- package/dist/{taxonomies-CKuaZER5.mjs → taxonomies-Dk3MAklL.mjs} +280 -56
- package/dist/taxonomies-Dk3MAklL.mjs.map +1 -0
- package/dist/{taxonomy-pOrB2kZe.mjs → taxonomy-CPeM8d2o.mjs} +131 -78
- package/dist/taxonomy-CPeM8d2o.mjs.map +1 -0
- package/dist/{tokens-DagaJGK8.mjs → tokens-C39klX8R.mjs} +2 -2
- package/dist/{tokens-DagaJGK8.mjs.map → tokens-C39klX8R.mjs.map} +1 -1
- package/dist/{transport-DVsa5YYo.mjs → transport--CfOflrp.mjs} +1 -1
- package/dist/{transport-DVsa5YYo.mjs.map → transport--CfOflrp.mjs.map} +1 -1
- package/dist/{transport-CAwTaTp_.d.mts → transport-B_rfeU-a.d.mts} +1 -1
- package/dist/{transport-CAwTaTp_.d.mts.map → transport-B_rfeU-a.d.mts.map} +1 -1
- package/dist/{trusted-proxy-D20_7fyX.mjs → trusted-proxy-CEVekpby.mjs} +1 -1
- package/dist/{trusted-proxy-D20_7fyX.mjs.map → trusted-proxy-CEVekpby.mjs.map} +1 -1
- package/dist/{types-NBI3rF-_.mjs → types-75KIqzL9.mjs} +18 -2
- package/dist/types-75KIqzL9.mjs.map +1 -0
- package/dist/{types-CbUcuxxc.d.mts → types-BPuloofb.d.mts} +1 -1
- package/dist/{types-CbUcuxxc.d.mts.map → types-BPuloofb.d.mts.map} +1 -1
- package/dist/{types-BjxTKxrZ.mjs → types-BW1syrlw.mjs} +1 -1
- package/dist/{types-BjxTKxrZ.mjs.map → types-BW1syrlw.mjs.map} +1 -1
- package/dist/{types-BnFP1M3J.d.mts → types-C3_AbkDP.d.mts} +32 -10
- package/dist/types-C3_AbkDP.d.mts.map +1 -0
- package/dist/{types-Dc4ntQjQ.d.mts → types-CAGdePf3.d.mts} +124 -1
- package/dist/types-CAGdePf3.d.mts.map +1 -0
- package/dist/{types-DLG4IFEQ.d.mts → types-CFUfyt1s.d.mts} +1 -1
- package/dist/{types-DLG4IFEQ.d.mts.map → types-CFUfyt1s.d.mts.map} +1 -1
- package/dist/{types-LoagAGzH.d.mts → types-CPx2lIGo.d.mts} +1 -1
- package/dist/{types-LoagAGzH.d.mts.map → types-CPx2lIGo.d.mts.map} +1 -1
- package/dist/{types-Cd8iuS1J.mjs → types-CQPWhPxE.mjs} +9 -12
- package/dist/types-CQPWhPxE.mjs.map +1 -0
- package/dist/{types-Cz8hNch2.d.mts → types-Cs-TFLNf.d.mts} +25 -5
- package/dist/types-Cs-TFLNf.d.mts.map +1 -0
- package/dist/types-CtzytVXn.mjs.map +1 -1
- package/dist/{types-BGWPMiBO.d.mts → types-D4_1Ga4L.d.mts} +44 -5
- package/dist/types-D4_1Ga4L.d.mts.map +1 -0
- package/dist/{types-C8oz_ayJ.d.mts → types-DefV3OiO.d.mts} +1 -1
- package/dist/{types-C8oz_ayJ.d.mts.map → types-DefV3OiO.d.mts.map} +1 -1
- package/dist/{types-BK6U01Ro.d.mts → types-X0MThr7x.d.mts} +1 -1
- package/dist/{types-BK6U01Ro.d.mts.map → types-X0MThr7x.d.mts.map} +1 -1
- package/dist/{upload-attempts-D8QAFLUJ.mjs → upload-attempts-hlne3iA1.mjs} +1 -1
- package/dist/{upload-attempts-D8QAFLUJ.mjs.map → upload-attempts-hlne3iA1.mjs.map} +1 -1
- package/dist/url-pattern-BHS0V5Ng.mjs +33 -0
- package/dist/url-pattern-BHS0V5Ng.mjs.map +1 -0
- package/dist/{user-DBrq4UVq.mjs → user-sHgJ62SP.mjs} +3 -3
- package/dist/{user-DBrq4UVq.mjs.map → user-sHgJ62SP.mjs.map} +1 -1
- package/dist/{utils-hLzi_2Fn.mjs → utils-D4vD_Y98.mjs} +3 -3
- package/dist/{utils-hLzi_2Fn.mjs.map → utils-D4vD_Y98.mjs.map} +1 -1
- package/dist/{validate-mKo3RxBM.mjs → validate-BkqIG_Uj.mjs} +24 -5
- package/dist/validate-BkqIG_Uj.mjs.map +1 -0
- package/dist/{validate-C3oSmA7F.d.mts → validate-DeGtBN84.d.mts} +15 -7
- package/dist/validate-DeGtBN84.d.mts.map +1 -0
- package/dist/{validation-BgpucsvF.mjs → validation-CiJb_X5o.mjs} +11 -10
- package/dist/{validation-BgpucsvF.mjs.map → validation-CiJb_X5o.mjs.map} +1 -1
- package/dist/version-x0NjTScG.mjs +7 -0
- package/dist/{version-C4PnpmoV.mjs.map → version-x0NjTScG.mjs.map} +1 -1
- package/dist/{widgets-CJJtkiKh.mjs → widgets-Cwzvww0W.mjs} +3 -3
- package/dist/{widgets-CJJtkiKh.mjs.map → widgets-Cwzvww0W.mjs.map} +1 -1
- package/dist/{wxr-taxonomies-Bkpp_2tK.d.mts → wxr-taxonomies-CmC0ZsDr.d.mts} +1 -1
- package/dist/{wxr-taxonomies-Bkpp_2tK.d.mts.map → wxr-taxonomies-CmC0ZsDr.d.mts.map} +1 -1
- package/dist/{wxr-taxonomies-9PPSy8X6.mjs → wxr-taxonomies-QZjWxjyk.mjs} +13 -32
- package/dist/{wxr-taxonomies-9PPSy8X6.mjs.map → wxr-taxonomies-QZjWxjyk.mjs.map} +1 -1
- package/dist/{zod-generator-CG64Hnbh.mjs → zod-generator-D11MhxG4.mjs} +52 -5
- package/dist/zod-generator-D11MhxG4.mjs.map +1 -0
- package/package.json +16 -8
- package/src/api/errors.ts +12 -0
- package/src/api/handlers/content.ts +127 -29
- package/src/api/handlers/dashboard.ts +12 -2
- package/src/api/handlers/index.ts +16 -0
- package/src/api/handlers/manifest.ts +2 -0
- package/src/api/handlers/media-allowlist.ts +13 -2
- package/src/api/handlers/media-usage-work.ts +188 -0
- package/src/api/handlers/media-usage.ts +5 -3
- package/src/api/handlers/schema.ts +9 -3
- package/src/api/handlers/seo.ts +5 -2
- package/src/api/handlers/taxonomies.ts +345 -82
- package/src/api/media-usage-write-fence.ts +64 -0
- package/src/api/openapi/document.ts +199 -0
- package/src/api/schemas/common.ts +3 -1
- package/src/api/schemas/content.ts +122 -1
- package/src/api/schemas/media-usage.ts +133 -0
- package/src/api/schemas/schema.ts +78 -3
- package/src/api/schemas/taxonomies.ts +40 -8
- package/src/api/types.ts +1 -0
- package/src/astro/integration/index.ts +55 -42
- package/src/astro/integration/routes.ts +34 -4
- package/src/astro/integration/runtime.ts +15 -0
- package/src/astro/integration/virtual-modules.ts +25 -1
- package/src/astro/integration/vite-config.ts +16 -1
- package/src/astro/middleware/media-usage-write-fence.ts +30 -0
- package/src/astro/middleware/redirect.ts +12 -2
- package/src/astro/middleware.ts +75 -8
- package/src/astro/routes/api/admin/media-usage/collection-deletions/index.ts +22 -0
- package/src/astro/routes/api/admin/media-usage/collection-deletions/retry.ts +22 -0
- package/src/astro/routes/api/admin/media-usage/work/index.ts +26 -0
- package/src/astro/routes/api/admin/media-usage/work/retry.ts +26 -0
- package/src/astro/routes/api/admin/plugins/[id]/disable.ts +4 -0
- package/src/astro/routes/api/admin/plugins/[id]/enable.ts +4 -0
- package/src/astro/routes/api/admin/plugins/[id]/uninstall.ts +4 -0
- package/src/astro/routes/api/admin/plugins/[id]/update.ts +4 -0
- package/src/astro/routes/api/admin/plugins/marketplace/[id]/install.ts +4 -0
- package/src/astro/routes/api/admin/plugins/registry/[id]/uninstall.ts +4 -0
- package/src/astro/routes/api/admin/plugins/registry/[id]/update.ts +4 -0
- package/src/astro/routes/api/admin/plugins/registry/install.ts +4 -0
- package/src/astro/routes/api/content/[collection]/[id]/terms/[taxonomy].ts +67 -31
- package/src/astro/routes/api/import/wordpress/execute.ts +3 -10
- package/src/astro/routes/api/mcp.ts +1 -0
- package/src/astro/routes/api/plugins/[pluginId]/[...path].ts +7 -1
- package/src/astro/routes/api/schema/collections/[slug]/index.ts +1 -7
- package/src/astro/routes/api/taxonomies/[name]/terms/index.ts +1 -0
- package/src/astro/routes/api/taxonomies/[name]/translations.ts +48 -0
- package/src/astro/routes/api/taxonomies/[name].ts +102 -0
- package/src/astro/types.ts +25 -4
- package/src/cleanup.ts +6 -12
- package/src/cli/commands/doctor.ts +193 -6
- package/src/cli/commands/export-seed.ts +4 -1
- package/src/client/index.ts +119 -0
- package/src/components/Block.astro +12 -0
- package/src/components/InlinePortableTextEditor.tsx +89 -1
- package/src/content/converters/mark-safety.ts +120 -0
- package/src/content/converters/portable-text-to-prosemirror.ts +25 -16
- package/src/content/converters/prosemirror-to-portable-text.ts +12 -2
- package/src/content-list-query.ts +29 -0
- package/src/database/migrations/060_collection_admin_config.ts +16 -0
- package/src/database/migrations/061_media_usage_cleanup.ts +77 -0
- package/src/database/migrations/062_media_usage_cleanup_fence.ts +295 -0
- package/src/database/migrations/063_media_usage_incremental_work.ts +397 -0
- package/src/database/migrations/064_fts_plain_text.ts +253 -0
- package/src/database/migrations/065_media_usage_collection_deletion.ts +85 -0
- package/src/database/migrations/066_media_usage_reconciliation.ts +115 -0
- package/src/database/migrations/067_indexed_content_fields.ts +39 -0
- package/src/database/migrations/068_content_taxonomy_entry_groups.ts +61 -0
- package/src/database/migrations/069_collection_title_date_fields.ts +45 -0
- package/src/database/migrations/070_collection_routable.ts +18 -0
- package/src/database/migrations/runner.ts +22 -0
- package/src/database/repositories/content.ts +861 -96
- package/src/database/repositories/media-usage-work.ts +848 -0
- package/src/database/repositories/media-usage.ts +1502 -138
- package/src/database/repositories/revision.ts +17 -6
- package/src/database/repositories/taxonomy.ts +234 -103
- package/src/database/repositories/types.ts +51 -2
- package/src/database/types.ts +134 -16
- package/src/db/adapters.ts +28 -0
- package/src/db/index.ts +3 -0
- package/src/emdash-runtime.ts +227 -20
- package/src/fields/file.ts +7 -4
- package/src/fields/image.ts +8 -1
- package/src/fields/types.ts +18 -5
- package/src/i18n/config.ts +32 -0
- package/src/i18n/repair-locale-casing.ts +0 -14
- package/src/i18n/taxonomy-locale-diagnostic.ts +47 -0
- package/src/import/wxr-taxonomies.ts +7 -47
- package/src/index.ts +25 -2
- package/src/loader.ts +119 -65
- package/src/mcp/server.ts +242 -34
- package/src/media/usage/activation.ts +626 -0
- package/src/media/usage/capture-triggers.ts +543 -0
- package/src/media/usage/cleanup.ts +305 -0
- package/src/media/usage/collection-deletion-processor.ts +356 -0
- package/src/media/usage/collection-deletion.ts +836 -0
- package/src/media/usage/content-fields.ts +40 -3
- package/src/media/usage/content-refresh.ts +356 -47
- package/src/media/usage/content-repair.ts +180 -61
- package/src/media/usage/content-snapshots.ts +85 -105
- package/src/media/usage/projection-fingerprint.ts +129 -0
- package/src/media/usage/reconciliation-processor.ts +372 -0
- package/src/media/usage/reconciliation.ts +1117 -0
- package/src/media/usage/source-key.ts +4 -0
- package/src/media/usage/types.ts +2 -0
- package/src/media/usage/work-processor.ts +248 -0
- package/src/menus/index.ts +246 -141
- package/src/plugin-types.ts +8 -0
- package/src/plugins/adapt-sandbox-entry.ts +24 -5
- package/src/plugins/context.ts +24 -7
- package/src/plugins/index.ts +9 -0
- package/src/plugins/routes.ts +43 -1
- package/src/plugins/sandbox/index.ts +10 -1
- package/src/plugins/sandbox/types.ts +78 -1
- package/src/plugins/scheduler/node.ts +13 -1
- package/src/plugins/scheduler/types.ts +2 -0
- package/src/plugins/types.ts +39 -2
- package/src/query.ts +29 -37
- package/src/scheduler-health.ts +46 -0
- package/src/schema/registry.ts +777 -255
- package/src/schema/types.ts +50 -8
- package/src/schema/url-pattern.ts +33 -0
- package/src/schema/zod-generator.ts +77 -5
- package/src/search/fts-manager.ts +117 -76
- package/src/search/query.ts +32 -11
- package/src/search/types.ts +2 -0
- package/src/seed/apply.ts +68 -15
- package/src/seed/types.ts +11 -3
- package/src/seed/validate.ts +52 -2
- package/src/taxonomies/index.ts +77 -75
- package/src/taxonomies/term-counts.ts +21 -8
- package/src/utils/slugify.ts +1 -29
- package/src/virtual-modules.d.ts +16 -0
- package/dist/adapters-BMyNSSZi.d.mts.map +0 -1
- package/dist/api-D2hunekQ.mjs.map +0 -1
- package/dist/apply-kwNEJW2l.mjs.map +0 -1
- package/dist/config-DyF3OKg_.mjs.map +0 -1
- package/dist/content-CJ94NEx5.mjs.map +0 -1
- package/dist/content-refresh-Xw7aKmou.mjs +0 -1629
- package/dist/content-refresh-Xw7aKmou.mjs.map +0 -1
- package/dist/context-C_1nrqnW.mjs.map +0 -1
- package/dist/dashboard-DINnNVVU.mjs.map +0 -1
- package/dist/errors-BucQ8VYz.mjs.map +0 -1
- package/dist/fts-manager-BITakW_R.mjs.map +0 -1
- package/dist/index-M37iz29I.d.mts.map +0 -1
- package/dist/index-MGw47uWq.d.mts.map +0 -1
- package/dist/loader-CGugY7Zl.mjs.map +0 -1
- package/dist/media-OhYL-7Io.mjs.map +0 -1
- package/dist/media-allowlist-D-peH1H5.mjs.map +0 -1
- package/dist/media-usage-BlxfTkN0.mjs.map +0 -1
- package/dist/menus-Y54RDPIN.mjs.map +0 -1
- package/dist/options-CA4eVX6P.d.mts.map +0 -1
- package/dist/query-C5w7PsRQ.mjs.map +0 -1
- package/dist/redirects-G8wAhWAf.mjs.map +0 -1
- package/dist/registry-Dbodb4Uo.mjs +0 -840
- package/dist/registry-Dbodb4Uo.mjs.map +0 -1
- package/dist/relations-G2ta7GIl.d.mts.map +0 -1
- package/dist/runner-BFTrkYhu.mjs.map +0 -1
- package/dist/search-FZhx5dDU.mjs.map +0 -1
- package/dist/seo-CobNfOvb.mjs.map +0 -1
- package/dist/slugify-C_tqlU4G.mjs +0 -30
- package/dist/slugify-C_tqlU4G.mjs.map +0 -1
- package/dist/taxonomies-CKuaZER5.mjs.map +0 -1
- package/dist/taxonomies-CLN1N92E.mjs.map +0 -1
- package/dist/taxonomy-pOrB2kZe.mjs.map +0 -1
- package/dist/types-BGWPMiBO.d.mts.map +0 -1
- package/dist/types-BnFP1M3J.d.mts.map +0 -1
- package/dist/types-Cd8iuS1J.mjs.map +0 -1
- package/dist/types-Cz8hNch2.d.mts.map +0 -1
- package/dist/types-Dc4ntQjQ.d.mts.map +0 -1
- package/dist/types-NBI3rF-_.mjs.map +0 -1
- package/dist/validate-C3oSmA7F.d.mts.map +0 -1
- package/dist/validate-mKo3RxBM.mjs.map +0 -1
- package/dist/version-C4PnpmoV.mjs +0 -7
- package/dist/zod-generator-CG64Hnbh.mjs.map +0 -1
- /package/dist/{api-tokens-Dai9dND0.mjs → api-tokens-CyTsLszZ.mjs} +0 -0
- /package/dist/{ssrf-Cj568Dgs.mjs → ssrf-DpXgKsna.mjs} +0 -0
- /package/dist/{types-DKuWPYV5.mjs → types-CP1CflWf.mjs} +0 -0
|
@@ -0,0 +1,1275 @@
|
|
|
1
|
+
import { o as __exportAll } from "./runner-BiDvq5dv.mjs";
|
|
2
|
+
import { t as validateIdentifier } from "./validate-BpwoDOgt.mjs";
|
|
3
|
+
import { a as currentTimestamp, p as tableExists, s as isPostgres, u as listTablesLike } from "./dialect-helpers-BSbfaO3F.mjs";
|
|
4
|
+
import { c as isIndexableFieldType, o as RESERVED_COLLECTION_SLUGS, r as FIELD_TYPE_TO_COLUMN, s as RESERVED_FIELD_SLUGS } from "./types-75KIqzL9.mjs";
|
|
5
|
+
import { n as chunks, t as SQL_BATCH_SIZE } from "./chunks-DfPax1I0.mjs";
|
|
6
|
+
import { t as withTransaction } from "./transaction-NQj4VJ7Z.mjs";
|
|
7
|
+
import { t as FTSManager } from "./fts-manager-CZ-5dVwJ.mjs";
|
|
8
|
+
import { c as markContentMediaUsageCollectionStaleSafely, i as deleteContentMediaUsageCollection, o as invalidateContentMediaUsageSchemaChange } from "./content-refresh-DNERP4-f.mjs";
|
|
9
|
+
import { a as installMediaUsageCaptureTriggers, i as isMediaUsageCollectionSlugDeleting, o as verifyMediaUsageCaptureTriggers, r as deleteActivatedMediaUsageCollection } from "./collection-deletion-C8BugSGz.mjs";
|
|
10
|
+
import { sql } from "kysely";
|
|
11
|
+
import { ulid } from "ulidx";
|
|
12
|
+
|
|
13
|
+
//#region src/media/usage/activation.ts
|
|
14
|
+
const ACTIVATION_KEY = "incremental_capture";
|
|
15
|
+
const MEDIA_USAGE_ACTIVATION_RUNTIME_GENERATION = 1;
|
|
16
|
+
const MEDIA_USAGE_ACTIVATION_LIMITS = Object.freeze({
|
|
17
|
+
collectionsPerCall: 1,
|
|
18
|
+
leaseDurationSeconds: 300
|
|
19
|
+
});
|
|
20
|
+
async function canResumeMediaUsageCollectionCapture(db, identity) {
|
|
21
|
+
const activation = await findActivationIfAvailable(db);
|
|
22
|
+
if (!activation) return false;
|
|
23
|
+
assertRuntimeGeneration(activation);
|
|
24
|
+
if (activation.state !== "active") return false;
|
|
25
|
+
const lifecycle = await db.selectFrom("_emdash_media_usage_index_status").select(["collection_id", "cursor"]).where("adapter_id", "=", "content-media").where("scope_type", "=", "collection").where("scope_key", "=", identity.collectionSlug).where("collection_id", "=", identity.collectionId).where("capture_state", "in", ["installing", "ready"]).executeTakeFirst();
|
|
26
|
+
return lifecycle?.collection_id === identity.collectionId && (identity.creationFingerprint ? lifecycle.cursor === identity.creationFingerprint : lifecycle.cursor === null);
|
|
27
|
+
}
|
|
28
|
+
async function prepareMediaUsageCollectionCapture(db, input) {
|
|
29
|
+
const activation = await findActivationIfAvailable(db);
|
|
30
|
+
if (!activation) return {
|
|
31
|
+
captureRequired: false,
|
|
32
|
+
collectionId: input.collectionId,
|
|
33
|
+
registrationExists: input.registeredCollectionId !== void 0,
|
|
34
|
+
resuming: false
|
|
35
|
+
};
|
|
36
|
+
assertRuntimeGeneration(activation);
|
|
37
|
+
if (activation.state !== "active") return {
|
|
38
|
+
captureRequired: false,
|
|
39
|
+
collectionId: input.collectionId,
|
|
40
|
+
registrationExists: input.registeredCollectionId !== void 0,
|
|
41
|
+
resuming: false
|
|
42
|
+
};
|
|
43
|
+
const existing = await db.selectFrom("_emdash_media_usage_index_status").select([
|
|
44
|
+
"collection_id",
|
|
45
|
+
"capture_state",
|
|
46
|
+
"cursor"
|
|
47
|
+
]).where("adapter_id", "=", "content-media").where("scope_type", "=", "collection").where("scope_key", "=", input.collectionSlug).executeTakeFirst();
|
|
48
|
+
if (existing) {
|
|
49
|
+
if (existing.collection_id && (existing.capture_state === "installing" || existing.capture_state === "ready") && (input.creationFingerprint ? existing.cursor === input.creationFingerprint : existing.cursor === null) && (input.registeredCollectionId === void 0 || input.registeredCollectionId === existing.collection_id)) return {
|
|
50
|
+
captureRequired: true,
|
|
51
|
+
collectionId: existing.collection_id,
|
|
52
|
+
registrationExists: input.registeredCollectionId !== void 0,
|
|
53
|
+
resuming: true
|
|
54
|
+
};
|
|
55
|
+
throw new Error("Media usage collection lifecycle identity conflict");
|
|
56
|
+
}
|
|
57
|
+
if (input.registeredCollectionId !== void 0) throw new Error("Media usage collection lifecycle is missing");
|
|
58
|
+
await db.insertInto("_emdash_media_usage_index_status").values({
|
|
59
|
+
adapter_id: "content-media",
|
|
60
|
+
scope_type: "collection",
|
|
61
|
+
scope_key: input.collectionSlug,
|
|
62
|
+
status: "never",
|
|
63
|
+
collection_id: input.collectionId,
|
|
64
|
+
reconciliation_required: 1,
|
|
65
|
+
capture_state: "installing",
|
|
66
|
+
cursor: input.creationFingerprint ?? null,
|
|
67
|
+
updated_at: timestampOffset(db, 0)
|
|
68
|
+
}).execute();
|
|
69
|
+
return {
|
|
70
|
+
captureRequired: true,
|
|
71
|
+
collectionId: input.collectionId,
|
|
72
|
+
registrationExists: false,
|
|
73
|
+
resuming: false
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
async function installPreparedMediaUsageCollectionCapture(db, identity) {
|
|
77
|
+
await installMediaUsageCaptureTriggers(db, identity, { replaceExisting: false });
|
|
78
|
+
if (!await verifyMediaUsageCaptureTriggers(db, identity)) throw new Error("Media usage capture trigger verification failed");
|
|
79
|
+
}
|
|
80
|
+
async function markMediaUsageCollectionCaptureReady(db, identity) {
|
|
81
|
+
const result = await db.updateTable("_emdash_media_usage_index_status").set({
|
|
82
|
+
capture_state: "ready",
|
|
83
|
+
updated_at: timestampOffset(db, 0)
|
|
84
|
+
}).where("adapter_id", "=", "content-media").where("scope_type", "=", "collection").where("scope_key", "=", identity.collectionSlug).where("collection_id", "=", identity.collectionId).where("capture_state", "in", ["installing", "ready"]).where(sql`EXISTS (
|
|
85
|
+
SELECT 1 FROM _emdash_media_usage_activation AS activation
|
|
86
|
+
WHERE activation.task_key = ${ACTIVATION_KEY}
|
|
87
|
+
AND activation.state = 'active'
|
|
88
|
+
AND activation.runtime_generation = ${MEDIA_USAGE_ACTIVATION_RUNTIME_GENERATION}
|
|
89
|
+
)`).executeTakeFirst();
|
|
90
|
+
if (Number(result.numUpdatedRows ?? 0) === 0) throw new Error("Media usage collection readiness lost its fence");
|
|
91
|
+
}
|
|
92
|
+
async function finalizeMediaUsageCollectionCapture(db, identity) {
|
|
93
|
+
const result = await db.updateTable("_emdash_media_usage_index_status").set({
|
|
94
|
+
capture_state: "active",
|
|
95
|
+
cursor: null,
|
|
96
|
+
updated_at: timestampOffset(db, 0)
|
|
97
|
+
}).where("adapter_id", "=", "content-media").where("scope_type", "=", "collection").where("scope_key", "=", identity.collectionSlug).where("collection_id", "=", identity.collectionId).where("capture_state", "=", "ready").where(sql`EXISTS (
|
|
98
|
+
SELECT 1 FROM _emdash_collections AS collection
|
|
99
|
+
WHERE collection.id = ${identity.collectionId}
|
|
100
|
+
AND collection.slug = ${identity.collectionSlug}
|
|
101
|
+
)`).where(sql`EXISTS (
|
|
102
|
+
SELECT 1 FROM _emdash_media_usage_activation AS activation
|
|
103
|
+
WHERE activation.task_key = ${ACTIVATION_KEY}
|
|
104
|
+
AND activation.state = 'active'
|
|
105
|
+
AND activation.runtime_generation = ${MEDIA_USAGE_ACTIVATION_RUNTIME_GENERATION}
|
|
106
|
+
)`).executeTakeFirst();
|
|
107
|
+
if (Number(result.numUpdatedRows ?? 0) === 0) throw new Error("Media usage collection activation lost its fence");
|
|
108
|
+
}
|
|
109
|
+
async function findActivation(db) {
|
|
110
|
+
return db.selectFrom("_emdash_media_usage_activation").selectAll().where("task_key", "=", ACTIVATION_KEY).executeTakeFirstOrThrow();
|
|
111
|
+
}
|
|
112
|
+
async function findActivationIfAvailable(db) {
|
|
113
|
+
if (!await tableExists(db, "_emdash_media_usage_activation")) return null;
|
|
114
|
+
return findActivation(db);
|
|
115
|
+
}
|
|
116
|
+
function assertRuntimeGeneration(activation) {
|
|
117
|
+
if (activation.runtime_generation !== MEDIA_USAGE_ACTIVATION_RUNTIME_GENERATION) throw new Error("Media usage activation runtime generation mismatch");
|
|
118
|
+
}
|
|
119
|
+
function timestampOffset(db, seconds) {
|
|
120
|
+
if (isPostgres(db)) return sql`to_char(
|
|
121
|
+
clock_timestamp() AT TIME ZONE 'UTC' + (${seconds} * interval '1 second'),
|
|
122
|
+
'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'
|
|
123
|
+
)`;
|
|
124
|
+
return sql`strftime('%Y-%m-%dT%H:%M:%fZ', 'now', ${`+${seconds} seconds`})`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/schema/registry.ts
|
|
129
|
+
var registry_exports = /* @__PURE__ */ __exportAll({
|
|
130
|
+
SchemaError: () => SchemaError,
|
|
131
|
+
SchemaRegistry: () => SchemaRegistry,
|
|
132
|
+
buildSeedCollectionCaptureFingerprint: () => buildSeedCollectionCaptureFingerprint
|
|
133
|
+
});
|
|
134
|
+
const SLUG_VALIDATION_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
135
|
+
const EC_PREFIX_PATTERN = /^ec_/;
|
|
136
|
+
const SINGLE_QUOTE_PATTERN = /'/g;
|
|
137
|
+
const UNDERSCORE_PATTERN = /_/g;
|
|
138
|
+
const WORD_BOUNDARY_PATTERN = /\b\w/g;
|
|
139
|
+
const FIELD_ID_PATTERN = /^[0-9A-Z]{26}$/;
|
|
140
|
+
/** Valid column types for runtime validation */
|
|
141
|
+
const COLUMN_TYPES = new Set([
|
|
142
|
+
"TEXT",
|
|
143
|
+
"REAL",
|
|
144
|
+
"INTEGER",
|
|
145
|
+
"JSON"
|
|
146
|
+
]);
|
|
147
|
+
const COLUMN_TYPE_TO_DATA_TYPE = {
|
|
148
|
+
TEXT: "text",
|
|
149
|
+
REAL: "real",
|
|
150
|
+
INTEGER: "integer",
|
|
151
|
+
JSON: "json"
|
|
152
|
+
};
|
|
153
|
+
const TEXT_ALIAS_FIELD_TYPES = new Set([
|
|
154
|
+
"string",
|
|
155
|
+
"text",
|
|
156
|
+
"slug"
|
|
157
|
+
]);
|
|
158
|
+
/** Field types usable as a `titleField` — plain text that reads well as a title. */
|
|
159
|
+
const TITLE_FIELD_TYPES = new Set([
|
|
160
|
+
"string",
|
|
161
|
+
"text",
|
|
162
|
+
"slug"
|
|
163
|
+
]);
|
|
164
|
+
/** Valid collection source prefixes/values */
|
|
165
|
+
const VALID_SOURCES = new Set([
|
|
166
|
+
"manual",
|
|
167
|
+
"discovered",
|
|
168
|
+
"seed"
|
|
169
|
+
]);
|
|
170
|
+
function isCollectionSource(value) {
|
|
171
|
+
return VALID_SOURCES.has(value) || value.startsWith("template:") || value.startsWith("import:");
|
|
172
|
+
}
|
|
173
|
+
function isFieldType(value) {
|
|
174
|
+
return value in FIELD_TYPE_TO_COLUMN;
|
|
175
|
+
}
|
|
176
|
+
function isColumnType(value) {
|
|
177
|
+
return COLUMN_TYPES.has(value);
|
|
178
|
+
}
|
|
179
|
+
const VALID_COLLECTION_SUPPORTS = new Set([
|
|
180
|
+
"drafts",
|
|
181
|
+
"revisions",
|
|
182
|
+
"preview",
|
|
183
|
+
"scheduling",
|
|
184
|
+
"search",
|
|
185
|
+
"seo"
|
|
186
|
+
]);
|
|
187
|
+
const SEED_FIELD_INSERT_BATCH_SIZE = 6;
|
|
188
|
+
/**
|
|
189
|
+
* Collection ordering shared by every list read: explicit `sort_order`
|
|
190
|
+
* first (ascending), then alphabetically by slug.
|
|
191
|
+
*/
|
|
192
|
+
const collectionOrder = sql`coalesce(sort_order, ${sql.lit(2147483647)})`;
|
|
193
|
+
function assertIndexableField(type, indexed, slug) {
|
|
194
|
+
if (indexed && !isIndexableFieldType(type)) throw new SchemaError(`Field "${slug}" cannot be indexed because type "${type}" is not a scalar query type`, "FIELD_NOT_INDEXABLE");
|
|
195
|
+
}
|
|
196
|
+
function isCollectionSupport(value) {
|
|
197
|
+
return typeof value === "string" && VALID_COLLECTION_SUPPORTS.has(value);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Parse a collection's `supports` column (stored as a JSON array of
|
|
201
|
+
* CollectionSupport keys). Unknown/invalid entries are filtered out so the
|
|
202
|
+
* runtime value matches the declared `CollectionSupport[]` type.
|
|
203
|
+
*
|
|
204
|
+
* Throws on malformed JSON so corruption surfaces loudly; returns an empty
|
|
205
|
+
* array only for explicitly null/empty values or non-array JSON.
|
|
206
|
+
*/
|
|
207
|
+
function parseSupports(raw) {
|
|
208
|
+
if (!raw) return [];
|
|
209
|
+
const parsed = JSON.parse(raw);
|
|
210
|
+
if (!Array.isArray(parsed)) return [];
|
|
211
|
+
return parsed.filter(isCollectionSupport);
|
|
212
|
+
}
|
|
213
|
+
function isRecord(value) {
|
|
214
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
215
|
+
}
|
|
216
|
+
function parseCollectionAdmin(raw) {
|
|
217
|
+
if (!raw) return void 0;
|
|
218
|
+
const parsed = JSON.parse(raw);
|
|
219
|
+
if (!isRecord(parsed)) return void 0;
|
|
220
|
+
const listColumns = parsed.listColumns;
|
|
221
|
+
return { listColumns: Array.isArray(listColumns) ? listColumns.filter((value) => typeof value === "string") : void 0 };
|
|
222
|
+
}
|
|
223
|
+
async function buildSeedCollectionCaptureFingerprint(input, fields) {
|
|
224
|
+
const supports = input.supports ?? ["drafts", "revisions"];
|
|
225
|
+
const hasSeo = input.hasSeo ?? supports.includes("seo") ?? false;
|
|
226
|
+
let maxSortOrder = -1;
|
|
227
|
+
const definitions = fields.map((field) => {
|
|
228
|
+
const sortOrder = field.sortOrder ?? maxSortOrder + 1;
|
|
229
|
+
maxSortOrder = Math.max(maxSortOrder, sortOrder);
|
|
230
|
+
return {
|
|
231
|
+
slug: field.slug,
|
|
232
|
+
label: field.label,
|
|
233
|
+
type: field.type,
|
|
234
|
+
required: field.required ?? false,
|
|
235
|
+
unique: field.unique ?? false,
|
|
236
|
+
defaultValue: field.defaultValue === void 0 ? null : JSON.stringify(field.defaultValue),
|
|
237
|
+
validation: field.validation ? JSON.stringify(field.validation) : null,
|
|
238
|
+
widget: field.widget ?? null,
|
|
239
|
+
options: field.options ? JSON.stringify(field.options) : null,
|
|
240
|
+
sortOrder,
|
|
241
|
+
searchable: field.searchable ?? false,
|
|
242
|
+
translatable: field.translatable ?? true
|
|
243
|
+
};
|
|
244
|
+
});
|
|
245
|
+
const payload = JSON.stringify(canonicalizeFingerprintValue({
|
|
246
|
+
version: 1,
|
|
247
|
+
collection: {
|
|
248
|
+
slug: input.slug,
|
|
249
|
+
label: input.label,
|
|
250
|
+
labelSingular: input.labelSingular ?? null,
|
|
251
|
+
description: input.description ?? null,
|
|
252
|
+
icon: input.icon ?? null,
|
|
253
|
+
admin: input.admin ?? null,
|
|
254
|
+
supports,
|
|
255
|
+
hasSeo,
|
|
256
|
+
hidden: input.hidden ?? false,
|
|
257
|
+
sortOrder: input.sortOrder ?? null,
|
|
258
|
+
commentsEnabled: input.commentsEnabled ?? false,
|
|
259
|
+
urlPattern: input.urlPattern ?? null,
|
|
260
|
+
routable: input.routable ?? true
|
|
261
|
+
},
|
|
262
|
+
fields: definitions
|
|
263
|
+
}));
|
|
264
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(payload));
|
|
265
|
+
return `media-usage-seed:v1:sha256:${Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
266
|
+
}
|
|
267
|
+
function canonicalizeFingerprintValue(value) {
|
|
268
|
+
if (value === void 0) return { __emdashUndefined: true };
|
|
269
|
+
if (Array.isArray(value)) return value.map(canonicalizeFingerprintValue);
|
|
270
|
+
if (typeof value !== "object" || value === null) return value;
|
|
271
|
+
const canonical = {};
|
|
272
|
+
for (const [key, entry] of Object.entries(value).toSorted(([a], [b]) => a.localeCompare(b))) canonical[key] = canonicalizeFingerprintValue(entry);
|
|
273
|
+
return canonical;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Error thrown when a schema operation fails
|
|
277
|
+
*/
|
|
278
|
+
var SchemaError = class extends Error {
|
|
279
|
+
constructor(message, code, details) {
|
|
280
|
+
super(message);
|
|
281
|
+
this.code = code;
|
|
282
|
+
this.details = details;
|
|
283
|
+
this.name = "SchemaError";
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Schema Registry
|
|
288
|
+
*
|
|
289
|
+
* Manages collection and field definitions stored in D1.
|
|
290
|
+
* Handles runtime DDL operations (CREATE TABLE, ALTER TABLE).
|
|
291
|
+
*/
|
|
292
|
+
var SchemaRegistry = class {
|
|
293
|
+
constructor(db) {
|
|
294
|
+
this.db = db;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* List all collections
|
|
298
|
+
*/
|
|
299
|
+
async listCollections() {
|
|
300
|
+
return (await this.db.selectFrom("_emdash_collections").selectAll().orderBy(collectionOrder, "asc").orderBy("slug", "asc").execute()).map(this.mapCollectionRow);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Get a collection by slug
|
|
304
|
+
*/
|
|
305
|
+
async getCollection(slug) {
|
|
306
|
+
const row = await this.db.selectFrom("_emdash_collections").where("slug", "=", slug).selectAll().executeTakeFirst();
|
|
307
|
+
return row ? this.mapCollectionRow(row) : null;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Get a collection with all its fields
|
|
311
|
+
*/
|
|
312
|
+
async getCollectionWithFields(slug) {
|
|
313
|
+
const collection = await this.getCollection(slug);
|
|
314
|
+
if (!collection) return null;
|
|
315
|
+
const fields = await this.listFields(collection.id);
|
|
316
|
+
return {
|
|
317
|
+
...collection,
|
|
318
|
+
fields
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* List every collection together with its fields in O(1) query shapes
|
|
323
|
+
* — one for collections, then one batched query for the fields of every
|
|
324
|
+
* returned collection — instead of the N+1 pattern of `listCollections`
|
|
325
|
+
* + per-collection `listFields`. The fields query is chunked at
|
|
326
|
+
* `SQL_BATCH_SIZE` to stay under D1's bound-parameter limit, so on
|
|
327
|
+
* sites with more than `SQL_BATCH_SIZE` collections the field fetch
|
|
328
|
+
* becomes `ceil(collectionCount / SQL_BATCH_SIZE)` queries — still
|
|
329
|
+
* a constant factor, not N+1. Typical sites have well under
|
|
330
|
+
* `SQL_BATCH_SIZE` collections, so this is two queries in practice.
|
|
331
|
+
*
|
|
332
|
+
* Used by the manifest build, which previously paid N+1 round-trips on
|
|
333
|
+
* every admin request. Each round-trip costs ~80–150ms against the D1
|
|
334
|
+
* primary on a busy link, so a 10-collection site spent ~1 s rebuilding
|
|
335
|
+
* a manifest that is now built fresh per admin request (no cache).
|
|
336
|
+
*/
|
|
337
|
+
async listCollectionsWithFields() {
|
|
338
|
+
const collectionRows = await this.db.selectFrom("_emdash_collections").selectAll().orderBy(collectionOrder, "asc").orderBy("slug", "asc").execute();
|
|
339
|
+
if (collectionRows.length === 0) return [];
|
|
340
|
+
const fieldsByCollection = /* @__PURE__ */ new Map();
|
|
341
|
+
for (const idChunk of chunks(collectionRows.map((c) => c.id), SQL_BATCH_SIZE)) {
|
|
342
|
+
const fieldRows = await this.db.selectFrom("_emdash_fields").where("collection_id", "in", idChunk).selectAll().orderBy("collection_id", "asc").orderBy("sort_order", "asc").orderBy("created_at", "asc").execute();
|
|
343
|
+
for (const row of fieldRows) {
|
|
344
|
+
const list = fieldsByCollection.get(row.collection_id) ?? [];
|
|
345
|
+
list.push(this.mapFieldRow(row));
|
|
346
|
+
fieldsByCollection.set(row.collection_id, list);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return collectionRows.map((c) => ({
|
|
350
|
+
...this.mapCollectionRow(c),
|
|
351
|
+
fields: fieldsByCollection.get(c.id) ?? []
|
|
352
|
+
}));
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Validate `titleField`/`dateField` against the collection's fields:
|
|
356
|
+
* `titleField` must be a text-like field; `dateField` must be a `datetime` field.
|
|
357
|
+
* Only truthy values are checked (undefined = unchanged, null/"" = cleared).
|
|
358
|
+
*/
|
|
359
|
+
async validateTitleDateFields(collectionId, collectionSlug, input, db = this.db) {
|
|
360
|
+
const slugs = [input.titleField, input.dateField].filter((slug) => !!slug);
|
|
361
|
+
if (slugs.length === 0) return;
|
|
362
|
+
const rows = await db.selectFrom("_emdash_fields").where("collection_id", "=", collectionId).where("slug", "in", slugs).select(["slug", "type"]).execute();
|
|
363
|
+
const typeBySlug = new Map(rows.map((row) => [row.slug, row.type]));
|
|
364
|
+
if (input.titleField) {
|
|
365
|
+
const type = typeBySlug.get(input.titleField);
|
|
366
|
+
if (type === void 0) throw new SchemaError(`titleField "${input.titleField}" is not a field on "${collectionSlug}"`, "INVALID_TITLE_FIELD");
|
|
367
|
+
if (!TITLE_FIELD_TYPES.has(type)) throw new SchemaError(`titleField "${input.titleField}" must be a text field (got "${type}")`, "INVALID_TITLE_FIELD");
|
|
368
|
+
}
|
|
369
|
+
if (input.dateField) {
|
|
370
|
+
const type = typeBySlug.get(input.dateField);
|
|
371
|
+
if (type === void 0) throw new SchemaError(`dateField "${input.dateField}" is not a field on "${collectionSlug}"`, "INVALID_DATE_FIELD");
|
|
372
|
+
if (type !== "datetime") throw new SchemaError(`dateField "${input.dateField}" must be a datetime field (got "${type}")`, "INVALID_DATE_FIELD");
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Create a new collection
|
|
377
|
+
*/
|
|
378
|
+
async createCollection(input) {
|
|
379
|
+
this.validateSlug(input.slug, "collection");
|
|
380
|
+
if (RESERVED_COLLECTION_SLUGS.includes(input.slug)) throw new SchemaError(`Collection slug "${input.slug}" is reserved`, "RESERVED_SLUG");
|
|
381
|
+
if (await isMediaUsageCollectionSlugDeleting(this.db, input.slug)) throw new SchemaError(`Collection "${input.slug}" already exists`, "COLLECTION_EXISTS");
|
|
382
|
+
const existing = await this.getCollection(input.slug);
|
|
383
|
+
if (await isMediaUsageCollectionSlugDeleting(this.db, input.slug)) throw new SchemaError(`Collection "${input.slug}" already exists`, "COLLECTION_EXISTS");
|
|
384
|
+
if (existing && !await canResumeMediaUsageCollectionCapture(this.db, {
|
|
385
|
+
collectionId: existing.id,
|
|
386
|
+
collectionSlug: existing.slug
|
|
387
|
+
})) throw new SchemaError(`Collection "${input.slug}" already exists`, "COLLECTION_EXISTS");
|
|
388
|
+
const proposedId = existing?.id ?? ulid();
|
|
389
|
+
const supports = input.supports ?? ["drafts", "revisions"];
|
|
390
|
+
const hasSeo = input.hasSeo ?? supports.includes("seo") ?? false;
|
|
391
|
+
await withTransaction(this.db, async (trx) => {
|
|
392
|
+
const capture = await prepareMediaUsageCollectionCapture(trx, {
|
|
393
|
+
collectionId: proposedId,
|
|
394
|
+
collectionSlug: input.slug,
|
|
395
|
+
registeredCollectionId: existing?.id
|
|
396
|
+
});
|
|
397
|
+
const values = {
|
|
398
|
+
id: capture.collectionId,
|
|
399
|
+
slug: input.slug,
|
|
400
|
+
label: input.label,
|
|
401
|
+
label_singular: input.labelSingular ?? null,
|
|
402
|
+
description: input.description ?? null,
|
|
403
|
+
icon: input.icon ?? null,
|
|
404
|
+
admin_config: input.admin ? JSON.stringify(input.admin) : null,
|
|
405
|
+
supports: JSON.stringify(supports),
|
|
406
|
+
source: input.source ?? "manual",
|
|
407
|
+
has_seo: hasSeo ? 1 : 0,
|
|
408
|
+
routable: input.routable === false ? 0 : 1,
|
|
409
|
+
hidden: input.hidden ? 1 : 0,
|
|
410
|
+
sort_order: input.sortOrder ?? null,
|
|
411
|
+
comments_enabled: input.commentsEnabled ? 1 : 0,
|
|
412
|
+
url_pattern: input.urlPattern ?? null
|
|
413
|
+
};
|
|
414
|
+
if (capture.captureRequired) {
|
|
415
|
+
await this.createContentTable(input.slug, trx, [], { ifNotExists: capture.resuming });
|
|
416
|
+
await installPreparedMediaUsageCollectionCapture(trx, {
|
|
417
|
+
collectionId: capture.collectionId,
|
|
418
|
+
collectionSlug: input.slug
|
|
419
|
+
});
|
|
420
|
+
await markMediaUsageCollectionCaptureReady(trx, {
|
|
421
|
+
collectionId: capture.collectionId,
|
|
422
|
+
collectionSlug: input.slug
|
|
423
|
+
});
|
|
424
|
+
if (!capture.registrationExists) await trx.insertInto("_emdash_collections").values(values).execute();
|
|
425
|
+
await finalizeMediaUsageCollectionCapture(trx, {
|
|
426
|
+
collectionId: capture.collectionId,
|
|
427
|
+
collectionSlug: input.slug
|
|
428
|
+
});
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
await trx.insertInto("_emdash_collections").values(values).execute();
|
|
432
|
+
await this.createContentTable(input.slug, trx);
|
|
433
|
+
});
|
|
434
|
+
const collection = await this.getCollection(input.slug);
|
|
435
|
+
if (!collection) throw new SchemaError("Failed to create collection", "CREATE_FAILED");
|
|
436
|
+
return collection;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Create a seed-owned collection and all of its fields in bulk.
|
|
440
|
+
*
|
|
441
|
+
* Fresh seeds can define dozens of fields. Creating them through
|
|
442
|
+
* `createField` performs multiple reads, one ALTER TABLE, and one media
|
|
443
|
+
* usage invalidation per field, which can exhaust D1's per-request query
|
|
444
|
+
* budget. This path validates the full schema before mutating it, creates
|
|
445
|
+
* the complete content table in one statement, and inserts field metadata
|
|
446
|
+
* in parameter-safe batches.
|
|
447
|
+
*/
|
|
448
|
+
async createSeedCollection(input, fields) {
|
|
449
|
+
this.validateSlug(input.slug, "collection");
|
|
450
|
+
if (RESERVED_COLLECTION_SLUGS.includes(input.slug)) throw new SchemaError(`Collection slug "${input.slug}" is reserved`, "RESERVED_SLUG");
|
|
451
|
+
if (await isMediaUsageCollectionSlugDeleting(this.db, input.slug)) throw new SchemaError(`Collection "${input.slug}" already exists`, "COLLECTION_EXISTS");
|
|
452
|
+
const fieldSlugs = /* @__PURE__ */ new Set();
|
|
453
|
+
for (const field of fields) {
|
|
454
|
+
this.validateSlug(field.slug, "field");
|
|
455
|
+
assertIndexableField(field.type, field.indexed, field.slug);
|
|
456
|
+
if (RESERVED_FIELD_SLUGS.includes(field.slug)) throw new SchemaError(`Field slug "${field.slug}" is reserved`, "RESERVED_SLUG");
|
|
457
|
+
if (fieldSlugs.has(field.slug)) throw new SchemaError(`Field "${field.slug}" already exists in collection "${input.slug}"`, "FIELD_EXISTS");
|
|
458
|
+
fieldSlugs.add(field.slug);
|
|
459
|
+
}
|
|
460
|
+
const supports = input.supports ?? ["drafts", "revisions"];
|
|
461
|
+
const hasSeo = input.hasSeo ?? supports.includes("seo") ?? false;
|
|
462
|
+
const creationFingerprint = await buildSeedCollectionCaptureFingerprint(input, fields);
|
|
463
|
+
const existing = await this.getCollection(input.slug);
|
|
464
|
+
if (await isMediaUsageCollectionSlugDeleting(this.db, input.slug)) throw new SchemaError(`Collection "${input.slug}" already exists`, "COLLECTION_EXISTS");
|
|
465
|
+
if (existing && !await canResumeMediaUsageCollectionCapture(this.db, {
|
|
466
|
+
collectionId: existing.id,
|
|
467
|
+
collectionSlug: existing.slug,
|
|
468
|
+
creationFingerprint
|
|
469
|
+
})) throw new SchemaError(`Collection "${input.slug}" already exists`, "COLLECTION_EXISTS");
|
|
470
|
+
const proposedCollectionId = existing?.id ?? ulid();
|
|
471
|
+
let maxSortOrder = -1;
|
|
472
|
+
const fieldRows = fields.map((field) => {
|
|
473
|
+
const sortOrder = field.sortOrder ?? maxSortOrder + 1;
|
|
474
|
+
maxSortOrder = Math.max(maxSortOrder, sortOrder);
|
|
475
|
+
return {
|
|
476
|
+
id: ulid(),
|
|
477
|
+
collection_id: proposedCollectionId,
|
|
478
|
+
slug: field.slug,
|
|
479
|
+
label: field.label,
|
|
480
|
+
type: field.type,
|
|
481
|
+
column_type: FIELD_TYPE_TO_COLUMN[field.type],
|
|
482
|
+
required: field.required ? 1 : 0,
|
|
483
|
+
unique: field.unique ? 1 : 0,
|
|
484
|
+
default_value: field.defaultValue !== void 0 ? JSON.stringify(field.defaultValue) : null,
|
|
485
|
+
validation: field.validation ? JSON.stringify(field.validation) : null,
|
|
486
|
+
widget: field.widget ?? null,
|
|
487
|
+
options: field.options ? JSON.stringify(field.options) : null,
|
|
488
|
+
sort_order: sortOrder,
|
|
489
|
+
searchable: field.searchable ? 1 : 0,
|
|
490
|
+
indexed: field.indexed ? 1 : 0,
|
|
491
|
+
translatable: field.translatable === false ? 0 : 1
|
|
492
|
+
};
|
|
493
|
+
});
|
|
494
|
+
let schemaMutated = false;
|
|
495
|
+
try {
|
|
496
|
+
await withTransaction(this.db, async (trx) => {
|
|
497
|
+
const capture = await prepareMediaUsageCollectionCapture(trx, {
|
|
498
|
+
collectionId: proposedCollectionId,
|
|
499
|
+
collectionSlug: input.slug,
|
|
500
|
+
creationFingerprint,
|
|
501
|
+
registeredCollectionId: existing?.id
|
|
502
|
+
});
|
|
503
|
+
const collectionValues = {
|
|
504
|
+
id: capture.collectionId,
|
|
505
|
+
slug: input.slug,
|
|
506
|
+
label: input.label,
|
|
507
|
+
label_singular: input.labelSingular ?? null,
|
|
508
|
+
description: input.description ?? null,
|
|
509
|
+
icon: input.icon ?? null,
|
|
510
|
+
admin_config: input.admin ? JSON.stringify(input.admin) : null,
|
|
511
|
+
supports: JSON.stringify(supports),
|
|
512
|
+
source: "seed",
|
|
513
|
+
has_seo: hasSeo ? 1 : 0,
|
|
514
|
+
routable: input.routable === false ? 0 : 1,
|
|
515
|
+
hidden: input.hidden ? 1 : 0,
|
|
516
|
+
sort_order: input.sortOrder ?? null,
|
|
517
|
+
comments_enabled: input.commentsEnabled ? 1 : 0,
|
|
518
|
+
url_pattern: input.urlPattern ?? null
|
|
519
|
+
};
|
|
520
|
+
const rows = fieldRows.map((row) => ({
|
|
521
|
+
...row,
|
|
522
|
+
collection_id: capture.collectionId
|
|
523
|
+
}));
|
|
524
|
+
if (capture.captureRequired) {
|
|
525
|
+
await this.createContentTable(input.slug, trx, fields, { ifNotExists: capture.resuming });
|
|
526
|
+
await installPreparedMediaUsageCollectionCapture(trx, {
|
|
527
|
+
collectionId: capture.collectionId,
|
|
528
|
+
collectionSlug: input.slug
|
|
529
|
+
});
|
|
530
|
+
await markMediaUsageCollectionCaptureReady(trx, {
|
|
531
|
+
collectionId: capture.collectionId,
|
|
532
|
+
collectionSlug: input.slug
|
|
533
|
+
});
|
|
534
|
+
if (!capture.registrationExists) {
|
|
535
|
+
await trx.insertInto("_emdash_collections").values(collectionValues).execute();
|
|
536
|
+
schemaMutated = true;
|
|
537
|
+
}
|
|
538
|
+
} else {
|
|
539
|
+
await trx.insertInto("_emdash_collections").values(collectionValues).execute();
|
|
540
|
+
schemaMutated = true;
|
|
541
|
+
await this.createContentTable(input.slug, trx, fields);
|
|
542
|
+
}
|
|
543
|
+
for (const fieldBatch of chunks(rows, SEED_FIELD_INSERT_BATCH_SIZE)) {
|
|
544
|
+
let insert = trx.insertInto("_emdash_fields").values(fieldBatch);
|
|
545
|
+
if (capture.resuming) insert = insert.onConflict((conflict) => conflict.columns(["collection_id", "slug"]).doNothing());
|
|
546
|
+
await insert.execute();
|
|
547
|
+
}
|
|
548
|
+
let indexedRows = rows;
|
|
549
|
+
if (capture.resuming) indexedRows = await this.assertSeedFieldDefinitions(capture.collectionId, fields, trx);
|
|
550
|
+
for (const field of indexedRows) if (field.indexed === 1) await this.createFieldIndex(input.slug, field.id, field.slug, trx);
|
|
551
|
+
if (capture.captureRequired) await finalizeMediaUsageCollectionCapture(trx, {
|
|
552
|
+
collectionId: capture.collectionId,
|
|
553
|
+
collectionSlug: input.slug
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
await markContentMediaUsageCollectionStaleSafely(this.db, input.slug, "CONTENT_USAGE_STALE");
|
|
557
|
+
} catch (error) {
|
|
558
|
+
if (schemaMutated) await markContentMediaUsageCollectionStaleSafely(this.db, input.slug, "CONTENT_USAGE_STALE");
|
|
559
|
+
throw error;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
async assertSeedFieldDefinitions(collectionId, fields, db) {
|
|
563
|
+
const stored = await db.selectFrom("_emdash_fields").selectAll().where("collection_id", "=", collectionId).execute();
|
|
564
|
+
if (stored.length !== fields.length) throw new SchemaError("Interrupted seed collection fields do not match", "CREATE_FAILED");
|
|
565
|
+
let maxSortOrder = -1;
|
|
566
|
+
for (const field of fields) {
|
|
567
|
+
const sortOrder = field.sortOrder ?? maxSortOrder + 1;
|
|
568
|
+
maxSortOrder = Math.max(maxSortOrder, sortOrder);
|
|
569
|
+
const row = stored.find((candidate) => candidate.slug === field.slug);
|
|
570
|
+
if (!row || row.label !== field.label || row.type !== field.type || row.column_type !== FIELD_TYPE_TO_COLUMN[field.type] || row.required !== (field.required ? 1 : 0) || row.unique !== (field.unique ? 1 : 0) || row.default_value !== (field.defaultValue !== void 0 ? JSON.stringify(field.defaultValue) : null) || row.validation !== (field.validation ? JSON.stringify(field.validation) : null) || row.widget !== (field.widget ?? null) || row.options !== (field.options ? JSON.stringify(field.options) : null) || row.sort_order !== sortOrder || row.searchable !== (field.searchable ? 1 : 0) || row.indexed !== (field.indexed ? 1 : 0) || row.translatable !== (field.translatable === false ? 0 : 1)) throw new SchemaError("Interrupted seed collection fields do not match", "CREATE_FAILED");
|
|
571
|
+
}
|
|
572
|
+
return stored;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Update a collection
|
|
576
|
+
*/
|
|
577
|
+
async updateCollection(slug, input) {
|
|
578
|
+
return withTransaction(this.db, async (trx) => {
|
|
579
|
+
const existingRow = await trx.selectFrom("_emdash_collections").where("slug", "=", slug).selectAll().executeTakeFirst();
|
|
580
|
+
if (!existingRow) throw new SchemaError(`Collection "${slug}" not found`, "COLLECTION_NOT_FOUND");
|
|
581
|
+
const existing = this.mapCollectionRow(existingRow);
|
|
582
|
+
await this.validateTitleDateFields(existing.id, slug, {
|
|
583
|
+
titleField: input.titleField,
|
|
584
|
+
dateField: input.dateField
|
|
585
|
+
}, trx);
|
|
586
|
+
const updates = {};
|
|
587
|
+
if (input.label !== void 0) updates.label = input.label;
|
|
588
|
+
if (input.labelSingular !== void 0) updates.label_singular = input.labelSingular;
|
|
589
|
+
if (input.description !== void 0) updates.description = input.description;
|
|
590
|
+
if (input.icon !== void 0) updates.icon = input.icon;
|
|
591
|
+
if (input.admin !== void 0) updates.admin_config = JSON.stringify(input.admin);
|
|
592
|
+
if (input.supports !== void 0) updates.supports = JSON.stringify(input.supports);
|
|
593
|
+
if (input.urlPattern !== void 0) updates.url_pattern = input.urlPattern;
|
|
594
|
+
if (input.routable !== void 0) updates.routable = input.routable ? 1 : 0;
|
|
595
|
+
if (input.hasSeo !== void 0) updates.has_seo = input.hasSeo ? 1 : 0;
|
|
596
|
+
else if (input.supports !== void 0) updates.has_seo = input.supports.includes("seo") ? 1 : 0;
|
|
597
|
+
if (input.hidden !== void 0) updates.hidden = input.hidden ? 1 : 0;
|
|
598
|
+
if (input.sortOrder !== void 0) updates.sort_order = input.sortOrder;
|
|
599
|
+
if (input.titleField !== void 0) updates.title_field = input.titleField || null;
|
|
600
|
+
if (input.dateField !== void 0) updates.date_field = input.dateField || null;
|
|
601
|
+
if (input.commentsEnabled !== void 0) updates.comments_enabled = input.commentsEnabled ? 1 : 0;
|
|
602
|
+
if (input.commentsModeration !== void 0) updates.comments_moderation = input.commentsModeration;
|
|
603
|
+
if (input.commentsClosedAfterDays !== void 0) updates.comments_closed_after_days = input.commentsClosedAfterDays;
|
|
604
|
+
if (input.commentsAutoApproveUsers !== void 0) updates.comments_auto_approve_users = input.commentsAutoApproveUsers ? 1 : 0;
|
|
605
|
+
updates.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
606
|
+
await trx.updateTable("_emdash_collections").set(updates).where("id", "=", existing.id).execute();
|
|
607
|
+
const row = await trx.selectFrom("_emdash_collections").where("slug", "=", slug).selectAll().executeTakeFirst();
|
|
608
|
+
if (!row) throw new SchemaError("Failed to update collection", "UPDATE_FAILED");
|
|
609
|
+
if (input.supports !== void 0) {
|
|
610
|
+
if (existing.supports.includes("search") !== parseSupports(row.supports).includes("search")) await this.syncSearchState(slug, trx);
|
|
611
|
+
}
|
|
612
|
+
return this.mapCollectionRow(row);
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Delete a collection
|
|
617
|
+
*/
|
|
618
|
+
async deleteCollection(slug, options) {
|
|
619
|
+
const existing = await this.getCollection(slug);
|
|
620
|
+
if (existing && !options?.force && await this.collectionHasContent(slug)) throw new SchemaError(`Collection "${slug}" has content. Use force: true to delete.`, "COLLECTION_HAS_CONTENT");
|
|
621
|
+
const activated = await deleteActivatedMediaUsageCollection(this.db, {
|
|
622
|
+
collectionId: existing?.id,
|
|
623
|
+
collectionSlug: slug,
|
|
624
|
+
forceDelete: options?.force === true
|
|
625
|
+
});
|
|
626
|
+
if (activated === "has_content") throw new SchemaError(`Collection "${slug}" has content. Use force: true to delete.`, "COLLECTION_HAS_CONTENT");
|
|
627
|
+
if (activated === "in_progress") throw new SchemaError(`Collection "${slug}" deletion is already in progress`, "CONFLICT");
|
|
628
|
+
if (activated === "deleted") return;
|
|
629
|
+
if (!existing) throw new SchemaError(`Collection "${slug}" not found`, "COLLECTION_NOT_FOUND");
|
|
630
|
+
let contentTableDropped = false;
|
|
631
|
+
try {
|
|
632
|
+
await withTransaction(this.db, async (trx) => {
|
|
633
|
+
await new FTSManager(trx).dropFtsTable(slug);
|
|
634
|
+
const tableName = this.getTableName(slug);
|
|
635
|
+
await sql`DROP TABLE IF EXISTS ${sql.ref(tableName)}`.execute(trx);
|
|
636
|
+
contentTableDropped = true;
|
|
637
|
+
await trx.deleteFrom("_emdash_collections").where("id", "=", existing.id).execute();
|
|
638
|
+
});
|
|
639
|
+
await deleteContentMediaUsageCollection(this.db, slug);
|
|
640
|
+
} catch (error) {
|
|
641
|
+
if (contentTableDropped && !await tableExists(this.db, this.getTableName(slug))) await deleteContentMediaUsageCollection(this.db, slug);
|
|
642
|
+
throw error;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* List fields for a collection
|
|
647
|
+
*/
|
|
648
|
+
async listFields(collectionId) {
|
|
649
|
+
return (await this.db.selectFrom("_emdash_fields").where("collection_id", "=", collectionId).selectAll().orderBy("sort_order", "asc").orderBy("created_at", "asc").execute()).map(this.mapFieldRow);
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Get a field by slug within a collection
|
|
653
|
+
*/
|
|
654
|
+
async getField(collectionSlug, fieldSlug) {
|
|
655
|
+
const collection = await this.getCollection(collectionSlug);
|
|
656
|
+
if (!collection) return null;
|
|
657
|
+
const row = await this.db.selectFrom("_emdash_fields").where("collection_id", "=", collection.id).where("slug", "=", fieldSlug).selectAll().executeTakeFirst();
|
|
658
|
+
return row ? this.mapFieldRow(row) : null;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Create a new field
|
|
662
|
+
*/
|
|
663
|
+
async createField(collectionSlug, input) {
|
|
664
|
+
const collection = await this.getCollection(collectionSlug);
|
|
665
|
+
if (!collection) throw new SchemaError(`Collection "${collectionSlug}" not found`, "COLLECTION_NOT_FOUND");
|
|
666
|
+
this.validateSlug(input.slug, "field");
|
|
667
|
+
if (RESERVED_FIELD_SLUGS.includes(input.slug)) throw new SchemaError(`Field slug "${input.slug}" is reserved`, "RESERVED_SLUG");
|
|
668
|
+
if (await this.getField(collectionSlug, input.slug)) throw new SchemaError(`Field "${input.slug}" already exists in collection "${collectionSlug}"`, "FIELD_EXISTS");
|
|
669
|
+
const id = ulid();
|
|
670
|
+
const columnType = FIELD_TYPE_TO_COLUMN[input.type];
|
|
671
|
+
assertIndexableField(input.type, input.indexed, input.slug);
|
|
672
|
+
const maxSort = await this.db.selectFrom("_emdash_fields").where("collection_id", "=", collection.id).select((eb) => eb.fn.max("sort_order").as("max")).executeTakeFirst();
|
|
673
|
+
const sortOrder = input.sortOrder ?? (maxSort?.max ?? -1) + 1;
|
|
674
|
+
const activeCoverageInvalidated = await invalidateContentMediaUsageSchemaChange(this.db, collectionSlug);
|
|
675
|
+
let schemaMutated = false;
|
|
676
|
+
try {
|
|
677
|
+
const created = await withTransaction(this.db, async (trx) => {
|
|
678
|
+
await trx.insertInto("_emdash_fields").values({
|
|
679
|
+
id,
|
|
680
|
+
collection_id: collection.id,
|
|
681
|
+
slug: input.slug,
|
|
682
|
+
label: input.label,
|
|
683
|
+
type: input.type,
|
|
684
|
+
column_type: columnType,
|
|
685
|
+
required: input.required ? 1 : 0,
|
|
686
|
+
unique: input.unique ? 1 : 0,
|
|
687
|
+
default_value: input.defaultValue !== void 0 ? JSON.stringify(input.defaultValue) : null,
|
|
688
|
+
validation: input.validation ? JSON.stringify(input.validation) : null,
|
|
689
|
+
widget: input.widget ?? null,
|
|
690
|
+
options: input.options ? JSON.stringify(input.options) : null,
|
|
691
|
+
sort_order: sortOrder,
|
|
692
|
+
searchable: input.searchable ? 1 : 0,
|
|
693
|
+
indexed: input.indexed ? 1 : 0,
|
|
694
|
+
translatable: input.translatable === false ? 0 : 1
|
|
695
|
+
}).execute();
|
|
696
|
+
schemaMutated = true;
|
|
697
|
+
await this.addColumn(collectionSlug, input.slug, input.type, {
|
|
698
|
+
required: input.required,
|
|
699
|
+
defaultValue: input.defaultValue
|
|
700
|
+
}, trx);
|
|
701
|
+
if (input.indexed) await this.createFieldIndex(collectionSlug, id, input.slug, trx);
|
|
702
|
+
const fieldRow = await trx.selectFrom("_emdash_fields").where("collection_id", "=", collection.id).where("slug", "=", input.slug).selectAll().executeTakeFirst();
|
|
703
|
+
if (!fieldRow) throw new SchemaError("Failed to create field", "CREATE_FAILED");
|
|
704
|
+
const field = this.mapFieldRow(fieldRow);
|
|
705
|
+
if (input.searchable) await this.syncSearchState(collectionSlug, trx);
|
|
706
|
+
return field;
|
|
707
|
+
});
|
|
708
|
+
if (activeCoverageInvalidated) await invalidateContentMediaUsageSchemaChange(this.db, collectionSlug);
|
|
709
|
+
else await markContentMediaUsageCollectionStaleSafely(this.db, collectionSlug, "CONTENT_USAGE_STALE");
|
|
710
|
+
return created;
|
|
711
|
+
} catch (error) {
|
|
712
|
+
if (schemaMutated) if (activeCoverageInvalidated) await invalidateContentMediaUsageSchemaChange(this.db, collectionSlug);
|
|
713
|
+
else await markContentMediaUsageCollectionStaleSafely(this.db, collectionSlug, "CONTENT_USAGE_STALE");
|
|
714
|
+
throw error;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* Update a field
|
|
719
|
+
*/
|
|
720
|
+
async updateField(collectionSlug, fieldSlug, input) {
|
|
721
|
+
let activeCoverageInvalidated = false;
|
|
722
|
+
let schemaMutated = false;
|
|
723
|
+
try {
|
|
724
|
+
const updatedField = await withTransaction(this.db, async (trx) => {
|
|
725
|
+
const collectionRow = await trx.selectFrom("_emdash_collections").where("slug", "=", collectionSlug).select([
|
|
726
|
+
"id",
|
|
727
|
+
"title_field",
|
|
728
|
+
"date_field"
|
|
729
|
+
]).executeTakeFirst();
|
|
730
|
+
const fieldRow = collectionRow ? await trx.selectFrom("_emdash_fields").where("collection_id", "=", collectionRow.id).where("slug", "=", fieldSlug).selectAll().executeTakeFirst() : void 0;
|
|
731
|
+
if (!fieldRow) throw new SchemaError(`Field "${fieldSlug}" not found in collection "${collectionSlug}"`, "FIELD_NOT_FOUND");
|
|
732
|
+
const field = this.mapFieldRow(fieldRow);
|
|
733
|
+
const updates = {};
|
|
734
|
+
let nextType = field.type;
|
|
735
|
+
if (input.type !== void 0 && input.type !== field.type) {
|
|
736
|
+
const newColumnType = FIELD_TYPE_TO_COLUMN[input.type];
|
|
737
|
+
if (newColumnType !== field.columnType) throw new SchemaError(`Cannot change field "${fieldSlug}" in collection "${collectionSlug}" from type "${field.type}" to "${input.type}": the underlying column type would change from ${field.columnType} to ${newColumnType}, which requires a manual content migration.`, "FIELD_TYPE_COLUMN_CHANGE");
|
|
738
|
+
if (!TEXT_ALIAS_FIELD_TYPES.has(field.type) || !TEXT_ALIAS_FIELD_TYPES.has(input.type)) throw new SchemaError(`Cannot change field "${fieldSlug}" in collection "${collectionSlug}" from type "${field.type}" to "${input.type}" without a manual content migration.`, "FIELD_TYPE_CHANGE_REQUIRES_MIGRATION");
|
|
739
|
+
if (collectionRow?.title_field === fieldSlug && !TITLE_FIELD_TYPES.has(input.type)) throw new SchemaError(`titleField "${fieldSlug}" must stay a text field, not "${input.type}"`, "INVALID_TITLE_FIELD");
|
|
740
|
+
if (collectionRow?.date_field === fieldSlug && input.type !== "datetime") throw new SchemaError(`dateField "${fieldSlug}" must stay a datetime field, not "${input.type}"`, "INVALID_DATE_FIELD");
|
|
741
|
+
nextType = input.type;
|
|
742
|
+
updates.type = input.type;
|
|
743
|
+
updates.column_type = newColumnType;
|
|
744
|
+
}
|
|
745
|
+
if (input.required !== void 0 && input.required !== field.required) throw new SchemaError(`Changing required for field "${fieldSlug}" requires a manual content migration.`, "FIELD_UPDATE_REQUIRES_MIGRATION");
|
|
746
|
+
if (input.unique !== void 0 && input.unique !== field.unique) throw new SchemaError(`Changing unique for field "${fieldSlug}" requires a manual content migration.`, "FIELD_UPDATE_REQUIRES_MIGRATION");
|
|
747
|
+
if (input.translatable === false && field.translatable) throw new SchemaError(`Changing field "${fieldSlug}" to non-translatable requires a manual content migration.`, "FIELD_UPDATE_REQUIRES_MIGRATION");
|
|
748
|
+
if (input.label !== void 0) updates.label = input.label;
|
|
749
|
+
if (input.required !== void 0) updates.required = input.required ? 1 : 0;
|
|
750
|
+
if (input.unique !== void 0) updates.unique = input.unique ? 1 : 0;
|
|
751
|
+
if (input.searchable !== void 0) updates.searchable = input.searchable ? 1 : 0;
|
|
752
|
+
const indexedChanged = input.indexed !== void 0 && input.indexed !== field.indexed;
|
|
753
|
+
if (indexedChanged) updates.indexed = input.indexed ? 1 : 0;
|
|
754
|
+
if (input.translatable !== void 0) updates.translatable = input.translatable ? 1 : 0;
|
|
755
|
+
if (input.defaultValue !== void 0) updates.default_value = JSON.stringify(input.defaultValue);
|
|
756
|
+
if (input.validation !== void 0) updates.validation = input.validation ? JSON.stringify(input.validation) : null;
|
|
757
|
+
if (input.widget !== void 0) updates.widget = input.widget;
|
|
758
|
+
if (input.options !== void 0) updates.options = JSON.stringify(input.options);
|
|
759
|
+
if (input.sortOrder !== void 0) updates.sort_order = input.sortOrder;
|
|
760
|
+
assertIndexableField(nextType, input.indexed ?? field.indexed, fieldSlug);
|
|
761
|
+
if (Object.keys(updates).length === 0) return field;
|
|
762
|
+
activeCoverageInvalidated = await invalidateContentMediaUsageSchemaChange(trx, collectionSlug);
|
|
763
|
+
if (Object.keys(updates).length > 0) {
|
|
764
|
+
await trx.updateTable("_emdash_fields").set(updates).where("id", "=", field.id).execute();
|
|
765
|
+
schemaMutated = true;
|
|
766
|
+
}
|
|
767
|
+
if (indexedChanged) {
|
|
768
|
+
if (input.indexed) await this.createFieldIndex(collectionSlug, field.id, fieldSlug, trx);
|
|
769
|
+
else await this.dropFieldIndex(field.id, trx);
|
|
770
|
+
schemaMutated = true;
|
|
771
|
+
}
|
|
772
|
+
const updatedRow = await trx.selectFrom("_emdash_fields").where("collection_id", "=", field.collectionId).where("slug", "=", fieldSlug).selectAll().executeTakeFirst();
|
|
773
|
+
if (!updatedRow) throw new SchemaError("Failed to update field", "UPDATE_FAILED");
|
|
774
|
+
const updated = this.mapFieldRow(updatedRow);
|
|
775
|
+
if (schemaMutated && input.searchable !== void 0 && input.searchable !== field.searchable) await this.syncSearchState(collectionSlug, trx);
|
|
776
|
+
return updated;
|
|
777
|
+
});
|
|
778
|
+
if (schemaMutated) if (activeCoverageInvalidated) await invalidateContentMediaUsageSchemaChange(this.db, collectionSlug);
|
|
779
|
+
else await markContentMediaUsageCollectionStaleSafely(this.db, collectionSlug, "CONTENT_USAGE_STALE");
|
|
780
|
+
return updatedField;
|
|
781
|
+
} catch (error) {
|
|
782
|
+
if (schemaMutated) if (activeCoverageInvalidated) await invalidateContentMediaUsageSchemaChange(this.db, collectionSlug);
|
|
783
|
+
else await markContentMediaUsageCollectionStaleSafely(this.db, collectionSlug, "CONTENT_USAGE_STALE");
|
|
784
|
+
throw error;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Synchronize an existing FTS index with the collection's current state.
|
|
789
|
+
*
|
|
790
|
+
* Only rebuilds or disables — never first-time enables. First-time FTS
|
|
791
|
+
* enablement is handled by the seed's explicit enableSearch call (which
|
|
792
|
+
* is try-caught) or the admin UI toggle.
|
|
793
|
+
*
|
|
794
|
+
* - FTS active + still has search support and searchable fields → rebuild
|
|
795
|
+
* - FTS active + lost search support or no searchable fields → disable
|
|
796
|
+
* - FTS not active → no-op
|
|
797
|
+
*
|
|
798
|
+
* Pass `db` when calling from within a transaction so FTS operations
|
|
799
|
+
* participate in the same transaction and are rolled back on failure.
|
|
800
|
+
*/
|
|
801
|
+
async syncSearchState(collectionSlug, db) {
|
|
802
|
+
const conn = db ?? this.db;
|
|
803
|
+
const ftsManager = new FTSManager(conn);
|
|
804
|
+
const row = await conn.selectFrom("_emdash_collections").where("slug", "=", collectionSlug).select("supports").executeTakeFirst();
|
|
805
|
+
if (!row) return;
|
|
806
|
+
const wantsSearch = parseSupports(row.supports).includes("search");
|
|
807
|
+
const searchableFields = await ftsManager.getSearchableFields(collectionSlug);
|
|
808
|
+
const config = await ftsManager.getSearchConfig(collectionSlug);
|
|
809
|
+
const ftsActive = config?.enabled === true;
|
|
810
|
+
if (wantsSearch && searchableFields.length > 0 && ftsActive) await ftsManager.rebuildIndex(collectionSlug, searchableFields, config?.weights, config?.tokenize);
|
|
811
|
+
else if (ftsActive && (!wantsSearch || searchableFields.length === 0)) await ftsManager.disableSearch(collectionSlug);
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Delete a field
|
|
815
|
+
*/
|
|
816
|
+
async deleteField(collectionSlug, fieldSlug) {
|
|
817
|
+
const field = await this.getField(collectionSlug, fieldSlug);
|
|
818
|
+
if (!field) throw new SchemaError(`Field "${fieldSlug}" not found in collection "${collectionSlug}"`, "FIELD_NOT_FOUND");
|
|
819
|
+
const activeCoverageInvalidated = await invalidateContentMediaUsageSchemaChange(this.db, collectionSlug);
|
|
820
|
+
const collection = await this.getCollection(collectionSlug);
|
|
821
|
+
const clearTitle = collection?.titleField === fieldSlug;
|
|
822
|
+
const clearDate = collection?.dateField === fieldSlug;
|
|
823
|
+
let schemaMutated = false;
|
|
824
|
+
try {
|
|
825
|
+
await withTransaction(this.db, async (trx) => {
|
|
826
|
+
await trx.deleteFrom("_emdash_fields").where("id", "=", field.id).execute();
|
|
827
|
+
schemaMutated = true;
|
|
828
|
+
if (clearTitle || clearDate) await trx.updateTable("_emdash_collections").set({
|
|
829
|
+
...clearTitle ? { title_field: null } : {},
|
|
830
|
+
...clearDate ? { date_field: null } : {},
|
|
831
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
832
|
+
}).where("slug", "=", collectionSlug).execute();
|
|
833
|
+
if (field.searchable) await this.syncSearchState(collectionSlug, trx);
|
|
834
|
+
if (field.indexed) await this.dropFieldIndex(field.id, trx);
|
|
835
|
+
await this.dropColumn(collectionSlug, fieldSlug, trx);
|
|
836
|
+
});
|
|
837
|
+
if (activeCoverageInvalidated) await invalidateContentMediaUsageSchemaChange(this.db, collectionSlug);
|
|
838
|
+
else await markContentMediaUsageCollectionStaleSafely(this.db, collectionSlug, "CONTENT_USAGE_STALE");
|
|
839
|
+
} catch (error) {
|
|
840
|
+
if (schemaMutated) if (activeCoverageInvalidated) await invalidateContentMediaUsageSchemaChange(this.db, collectionSlug);
|
|
841
|
+
else await markContentMediaUsageCollectionStaleSafely(this.db, collectionSlug, "CONTENT_USAGE_STALE");
|
|
842
|
+
throw error;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Reorder collections in the admin sidebar.
|
|
847
|
+
*
|
|
848
|
+
* `slugs` is the full desired order: every listed collection gets its
|
|
849
|
+
* index as `sort_order`, and any collection left out has its explicit
|
|
850
|
+
* position cleared, dropping it back to the alphabetical tail. Unknown or
|
|
851
|
+
* duplicate slugs throw before anything is written.
|
|
852
|
+
*/
|
|
853
|
+
async reorderCollections(slugs) {
|
|
854
|
+
const known = new Set((await this.listCollections()).map((collection) => collection.slug));
|
|
855
|
+
const unknown = slugs.filter((slug) => !known.has(slug));
|
|
856
|
+
if (unknown.length > 0) throw new SchemaError(`Unknown collection${unknown.length > 1 ? "s" : ""}: ${unknown.join(", ")}`, "COLLECTION_NOT_FOUND", { slugs: unknown });
|
|
857
|
+
const duplicates = slugs.filter((slug, index) => slugs.indexOf(slug) !== index);
|
|
858
|
+
if (duplicates.length > 0) throw new SchemaError(`Duplicate collection${duplicates.length > 1 ? "s" : ""}: ${[...new Set(duplicates)].join(", ")}`, "DUPLICATE_SLUG", { slugs: [...new Set(duplicates)] });
|
|
859
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
860
|
+
const ordered = new Set(slugs);
|
|
861
|
+
await withTransaction(this.db, async (trx) => {
|
|
862
|
+
for (const [index, slug] of slugs.entries()) await trx.updateTable("_emdash_collections").set({
|
|
863
|
+
sort_order: index,
|
|
864
|
+
updated_at: now
|
|
865
|
+
}).where("slug", "=", slug).execute();
|
|
866
|
+
const cleared = [...known].filter((slug) => !ordered.has(slug));
|
|
867
|
+
for (const slugChunk of chunks(cleared, SQL_BATCH_SIZE)) await trx.updateTable("_emdash_collections").set({
|
|
868
|
+
sort_order: null,
|
|
869
|
+
updated_at: now
|
|
870
|
+
}).where("slug", "in", slugChunk).execute();
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Reorder fields
|
|
875
|
+
*/
|
|
876
|
+
async reorderFields(collectionSlug, fieldSlugs) {
|
|
877
|
+
const collection = await this.getCollection(collectionSlug);
|
|
878
|
+
if (!collection) throw new SchemaError(`Collection "${collectionSlug}" not found`, "COLLECTION_NOT_FOUND");
|
|
879
|
+
for (let i = 0; i < fieldSlugs.length; i++) await this.db.updateTable("_emdash_fields").set({ sort_order: i }).where("collection_id", "=", collection.id).where("slug", "=", fieldSlugs[i]).execute();
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Create a content table for a collection
|
|
883
|
+
*/
|
|
884
|
+
async createContentTable(slug, db, fields = [], options = {}) {
|
|
885
|
+
const conn = db ?? this.db;
|
|
886
|
+
const tableName = this.getTableName(slug);
|
|
887
|
+
let table = conn.schema.createTable(tableName).addColumn("id", "text", (col) => col.primaryKey()).addColumn("slug", "text").addColumn("status", "text", (col) => col.defaultTo("draft")).addColumn("author_id", "text").addColumn("primary_byline_id", "text").addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp(conn))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp(conn))).addColumn("published_at", "text").addColumn("scheduled_at", "text").addColumn("deleted_at", "text").addColumn("version", "integer", (col) => col.defaultTo(1)).addColumn("live_revision_id", "text", (col) => col.references("revisions.id")).addColumn("draft_revision_id", "text", (col) => col.references("revisions.id")).addColumn("locale", "text", (col) => col.notNull().defaultTo("en")).addColumn("translation_group", "text");
|
|
888
|
+
if (options.ifNotExists) table = table.ifNotExists();
|
|
889
|
+
for (const field of fields) {
|
|
890
|
+
const columnName = this.getColumnName(field.slug);
|
|
891
|
+
const columnType = COLUMN_TYPE_TO_DATA_TYPE[FIELD_TYPE_TO_COLUMN[field.type]];
|
|
892
|
+
table = table.addColumn(columnName, columnType, (column) => {
|
|
893
|
+
if (!field.required) return column;
|
|
894
|
+
const defaultValue = field.defaultValue !== void 0 ? this.formatDefaultValue(field.defaultValue, field.type) : this.getEmptyDefault(field.type);
|
|
895
|
+
return column.notNull().defaultTo(sql.raw(defaultValue));
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
await table.addUniqueConstraint(`${tableName}_slug_locale_unique`, ["slug", "locale"]).execute();
|
|
899
|
+
const createIndex = options.ifNotExists ? sql`CREATE INDEX IF NOT EXISTS` : sql`CREATE INDEX`;
|
|
900
|
+
await sql`
|
|
901
|
+
${createIndex} ${sql.ref(`idx_${tableName}_slug`)}
|
|
902
|
+
ON ${sql.ref(tableName)} (slug)
|
|
903
|
+
`.execute(conn);
|
|
904
|
+
await sql`
|
|
905
|
+
${createIndex} ${sql.ref(`idx_${tableName}_scheduled`)}
|
|
906
|
+
ON ${sql.ref(tableName)} (scheduled_at)
|
|
907
|
+
WHERE scheduled_at IS NOT NULL
|
|
908
|
+
`.execute(conn);
|
|
909
|
+
await sql`
|
|
910
|
+
${createIndex} ${sql.ref(`idx_${tableName}_live_revision`)}
|
|
911
|
+
ON ${sql.ref(tableName)} (live_revision_id)
|
|
912
|
+
`.execute(conn);
|
|
913
|
+
await sql`
|
|
914
|
+
${createIndex} ${sql.ref(`idx_${tableName}_draft_revision`)}
|
|
915
|
+
ON ${sql.ref(tableName)} (draft_revision_id)
|
|
916
|
+
`.execute(conn);
|
|
917
|
+
await sql`
|
|
918
|
+
${createIndex} ${sql.ref(`idx_${tableName}_author`)}
|
|
919
|
+
ON ${sql.ref(tableName)} (author_id)
|
|
920
|
+
`.execute(conn);
|
|
921
|
+
await sql`
|
|
922
|
+
${createIndex} ${sql.ref(`idx_${tableName}_primary_byline`)}
|
|
923
|
+
ON ${sql.ref(tableName)} (primary_byline_id)
|
|
924
|
+
`.execute(conn);
|
|
925
|
+
await sql`
|
|
926
|
+
${createIndex} ${sql.ref(`idx_${tableName}_locale`)}
|
|
927
|
+
ON ${sql.ref(tableName)} (locale)
|
|
928
|
+
`.execute(conn);
|
|
929
|
+
await sql`
|
|
930
|
+
${createIndex} ${sql.ref(`idx_${tableName}_tg_locale`)}
|
|
931
|
+
ON ${sql.ref(tableName)} (translation_group, locale)
|
|
932
|
+
`.execute(conn);
|
|
933
|
+
await sql`
|
|
934
|
+
${createIndex} ${sql.ref(`idx_${tableName}_del_tg_locale`)}
|
|
935
|
+
ON ${sql.ref(tableName)} (deleted_at, translation_group, locale)
|
|
936
|
+
`.execute(conn);
|
|
937
|
+
await sql`
|
|
938
|
+
${createIndex} ${sql.ref(`idx_${tableName}_deleted_updated_id`)}
|
|
939
|
+
ON ${sql.ref(tableName)} (deleted_at, updated_at DESC, id DESC)
|
|
940
|
+
`.execute(conn);
|
|
941
|
+
await sql`
|
|
942
|
+
${createIndex} ${sql.ref(`idx_${tableName}_deleted_status`)}
|
|
943
|
+
ON ${sql.ref(tableName)} (deleted_at, status)
|
|
944
|
+
`.execute(conn);
|
|
945
|
+
await sql`
|
|
946
|
+
${createIndex} ${sql.ref(`idx_${tableName}_deleted_created_id`)}
|
|
947
|
+
ON ${sql.ref(tableName)} (deleted_at, created_at DESC, id DESC)
|
|
948
|
+
`.execute(conn);
|
|
949
|
+
await sql`
|
|
950
|
+
${createIndex} ${sql.ref(`idx_${tableName}_deleted_published_id`)}
|
|
951
|
+
ON ${sql.ref(tableName)} (deleted_at, published_at DESC, id DESC)
|
|
952
|
+
`.execute(conn);
|
|
953
|
+
await sql`
|
|
954
|
+
${createIndex} ${sql.ref(`idx_${tableName}_loc_upd`)}
|
|
955
|
+
ON ${sql.ref(tableName)} (deleted_at, locale, updated_at DESC, id DESC)
|
|
956
|
+
`.execute(conn);
|
|
957
|
+
await sql`
|
|
958
|
+
${createIndex} ${sql.ref(`idx_${tableName}_loc_crt`)}
|
|
959
|
+
ON ${sql.ref(tableName)} (deleted_at, locale, created_at DESC, id DESC)
|
|
960
|
+
`.execute(conn);
|
|
961
|
+
}
|
|
962
|
+
getFieldIndexName(fieldId) {
|
|
963
|
+
if (!FIELD_ID_PATTERN.test(fieldId)) throw new SchemaError(`Invalid field id "${fieldId}"`, "INVALID_FIELD_ID");
|
|
964
|
+
return `idx_cf_${fieldId.toLowerCase()}`;
|
|
965
|
+
}
|
|
966
|
+
getLocaleFieldIndexName(fieldId) {
|
|
967
|
+
return `${this.getFieldIndexName(fieldId)}_loc`;
|
|
968
|
+
}
|
|
969
|
+
async createFieldIndex(collectionSlug, fieldId, fieldSlug, db) {
|
|
970
|
+
const conn = db ?? this.db;
|
|
971
|
+
const tableName = this.getTableName(collectionSlug);
|
|
972
|
+
const columnName = this.getColumnName(fieldSlug);
|
|
973
|
+
const indexName = this.getFieldIndexName(fieldId);
|
|
974
|
+
const localeIndexName = this.getLocaleFieldIndexName(fieldId);
|
|
975
|
+
await sql`
|
|
976
|
+
CREATE INDEX IF NOT EXISTS ${sql.ref(indexName)}
|
|
977
|
+
ON ${sql.ref(tableName)} (
|
|
978
|
+
(${sql.ref(columnName)} IS NOT NULL),
|
|
979
|
+
${sql.ref(columnName)},
|
|
980
|
+
id
|
|
981
|
+
)
|
|
982
|
+
WHERE deleted_at IS NULL
|
|
983
|
+
`.execute(conn);
|
|
984
|
+
await sql`
|
|
985
|
+
CREATE INDEX IF NOT EXISTS ${sql.ref(localeIndexName)}
|
|
986
|
+
ON ${sql.ref(tableName)} (
|
|
987
|
+
locale,
|
|
988
|
+
(${sql.ref(columnName)} IS NOT NULL),
|
|
989
|
+
${sql.ref(columnName)},
|
|
990
|
+
id
|
|
991
|
+
)
|
|
992
|
+
WHERE deleted_at IS NULL
|
|
993
|
+
`.execute(conn);
|
|
994
|
+
}
|
|
995
|
+
async dropFieldIndex(fieldId, db) {
|
|
996
|
+
const conn = db ?? this.db;
|
|
997
|
+
await sql`DROP INDEX IF EXISTS ${sql.ref(this.getFieldIndexName(fieldId))}`.execute(conn);
|
|
998
|
+
await sql`DROP INDEX IF EXISTS ${sql.ref(this.getLocaleFieldIndexName(fieldId))}`.execute(conn);
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Add a column to a content table
|
|
1002
|
+
*/
|
|
1003
|
+
async addColumn(collectionSlug, fieldSlug, fieldType, options, db) {
|
|
1004
|
+
const conn = db ?? this.db;
|
|
1005
|
+
const tableName = this.getTableName(collectionSlug);
|
|
1006
|
+
const columnType = FIELD_TYPE_TO_COLUMN[fieldType];
|
|
1007
|
+
const columnName = this.getColumnName(fieldSlug);
|
|
1008
|
+
if (options?.required && options?.defaultValue !== void 0) {
|
|
1009
|
+
const defaultVal = this.formatDefaultValue(options.defaultValue, fieldType);
|
|
1010
|
+
await sql`
|
|
1011
|
+
ALTER TABLE ${sql.ref(tableName)}
|
|
1012
|
+
ADD COLUMN ${sql.ref(columnName)} ${sql.raw(columnType)} NOT NULL DEFAULT ${sql.raw(defaultVal)}
|
|
1013
|
+
`.execute(conn);
|
|
1014
|
+
} else if (options?.required) {
|
|
1015
|
+
const defaultVal = this.getEmptyDefault(fieldType);
|
|
1016
|
+
await sql`
|
|
1017
|
+
ALTER TABLE ${sql.ref(tableName)}
|
|
1018
|
+
ADD COLUMN ${sql.ref(columnName)} ${sql.raw(columnType)} NOT NULL DEFAULT ${sql.raw(defaultVal)}
|
|
1019
|
+
`.execute(conn);
|
|
1020
|
+
} else await sql`
|
|
1021
|
+
ALTER TABLE ${sql.ref(tableName)}
|
|
1022
|
+
ADD COLUMN ${sql.ref(columnName)} ${sql.raw(columnType)}
|
|
1023
|
+
`.execute(conn);
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Drop a column from a content table
|
|
1027
|
+
*/
|
|
1028
|
+
async dropColumn(collectionSlug, fieldSlug, db) {
|
|
1029
|
+
const tableName = this.getTableName(collectionSlug);
|
|
1030
|
+
const columnName = this.getColumnName(fieldSlug);
|
|
1031
|
+
await sql`
|
|
1032
|
+
ALTER TABLE ${sql.ref(tableName)}
|
|
1033
|
+
DROP COLUMN ${sql.ref(columnName)}
|
|
1034
|
+
`.execute(db ?? this.db);
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
* Check if a collection has any content
|
|
1038
|
+
*/
|
|
1039
|
+
async collectionHasContent(slug) {
|
|
1040
|
+
const tableName = this.getTableName(slug);
|
|
1041
|
+
try {
|
|
1042
|
+
return ((await sql`
|
|
1043
|
+
SELECT COUNT(*) as count FROM ${sql.ref(tableName)}
|
|
1044
|
+
WHERE deleted_at IS NULL
|
|
1045
|
+
`.execute(this.db)).rows[0]?.count ?? 0) > 0;
|
|
1046
|
+
} catch {
|
|
1047
|
+
return false;
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Get table name for a collection
|
|
1052
|
+
*/
|
|
1053
|
+
getTableName(slug) {
|
|
1054
|
+
validateIdentifier(slug, "collection slug");
|
|
1055
|
+
return `ec_${slug}`;
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Get column name for a field
|
|
1059
|
+
*/
|
|
1060
|
+
getColumnName(slug) {
|
|
1061
|
+
validateIdentifier(slug, "field slug");
|
|
1062
|
+
return slug;
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Validate a slug
|
|
1066
|
+
*/
|
|
1067
|
+
validateSlug(slug, type) {
|
|
1068
|
+
if (!slug || typeof slug !== "string") throw new SchemaError(`${type} slug is required`, "INVALID_SLUG");
|
|
1069
|
+
if (!SLUG_VALIDATION_PATTERN.test(slug)) throw new SchemaError(`${type} slug must start with a letter and contain only lowercase letters, numbers, and underscores`, "INVALID_SLUG");
|
|
1070
|
+
if (slug.length > 63) throw new SchemaError(`${type} slug must be 63 characters or less`, "INVALID_SLUG");
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Format a default value for SQL.
|
|
1074
|
+
*
|
|
1075
|
+
* SQLite `ALTER TABLE ADD COLUMN ... DEFAULT` requires a literal constant
|
|
1076
|
+
* expression — parameterized values cannot be used here. We manually escape
|
|
1077
|
+
* single quotes and coerce types to ensure the output is safe.
|
|
1078
|
+
*
|
|
1079
|
+
* INTEGER/REAL values are coerced through `Number()` which can only produce
|
|
1080
|
+
* digits, `.`, `-`, `e`, `Infinity`, or `NaN` — all safe in SQL.
|
|
1081
|
+
* TEXT/JSON values have single quotes escaped via SQL standard doubling (`''`).
|
|
1082
|
+
*/
|
|
1083
|
+
formatDefaultValue(value, fieldType) {
|
|
1084
|
+
if (value === null || value === void 0) return "NULL";
|
|
1085
|
+
const columnType = FIELD_TYPE_TO_COLUMN[fieldType];
|
|
1086
|
+
if (columnType === "JSON") return `'${JSON.stringify(value).replace(SINGLE_QUOTE_PATTERN, "''")}'`;
|
|
1087
|
+
if (columnType === "INTEGER") {
|
|
1088
|
+
if (typeof value === "boolean") return value ? "1" : "0";
|
|
1089
|
+
const num = Number(value);
|
|
1090
|
+
if (!Number.isFinite(num)) return "0";
|
|
1091
|
+
return String(Math.trunc(num));
|
|
1092
|
+
}
|
|
1093
|
+
if (columnType === "REAL") {
|
|
1094
|
+
const num = Number(value);
|
|
1095
|
+
if (!Number.isFinite(num)) return "0";
|
|
1096
|
+
return String(num);
|
|
1097
|
+
}
|
|
1098
|
+
let text;
|
|
1099
|
+
if (typeof value === "string") text = value;
|
|
1100
|
+
else if (typeof value === "number" || typeof value === "boolean") text = String(value);
|
|
1101
|
+
else if (typeof value === "object" && value !== null) text = JSON.stringify(value);
|
|
1102
|
+
else text = "";
|
|
1103
|
+
return `'${text.replace(SINGLE_QUOTE_PATTERN, "''")}'`;
|
|
1104
|
+
}
|
|
1105
|
+
/**
|
|
1106
|
+
* Get empty default for a field type
|
|
1107
|
+
*/
|
|
1108
|
+
getEmptyDefault(fieldType) {
|
|
1109
|
+
switch (FIELD_TYPE_TO_COLUMN[fieldType]) {
|
|
1110
|
+
case "INTEGER": return "0";
|
|
1111
|
+
case "REAL": return "0.0";
|
|
1112
|
+
case "JSON": return "'null'";
|
|
1113
|
+
default: return "''";
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Map a collection row to a Collection object
|
|
1118
|
+
*/
|
|
1119
|
+
mapCollectionRow = (row) => {
|
|
1120
|
+
const moderation = row.comments_moderation;
|
|
1121
|
+
return {
|
|
1122
|
+
id: row.id,
|
|
1123
|
+
slug: row.slug,
|
|
1124
|
+
label: row.label,
|
|
1125
|
+
labelSingular: row.label_singular ?? void 0,
|
|
1126
|
+
description: row.description ?? void 0,
|
|
1127
|
+
icon: row.icon ?? void 0,
|
|
1128
|
+
admin: parseCollectionAdmin(row.admin_config),
|
|
1129
|
+
supports: parseSupports(row.supports),
|
|
1130
|
+
source: row.source && isCollectionSource(row.source) ? row.source : void 0,
|
|
1131
|
+
hasSeo: row.has_seo === 1,
|
|
1132
|
+
titleField: row.title_field ?? void 0,
|
|
1133
|
+
dateField: row.date_field ?? void 0,
|
|
1134
|
+
urlPattern: row.url_pattern ?? void 0,
|
|
1135
|
+
routable: row.routable !== 0,
|
|
1136
|
+
hidden: row.hidden === 1,
|
|
1137
|
+
sortOrder: row.sort_order ?? void 0,
|
|
1138
|
+
commentsEnabled: row.comments_enabled === 1,
|
|
1139
|
+
commentsModeration: moderation === "all" || moderation === "first_time" || moderation === "none" ? moderation : "first_time",
|
|
1140
|
+
commentsClosedAfterDays: row.comments_closed_after_days ?? 90,
|
|
1141
|
+
commentsAutoApproveUsers: row.comments_auto_approve_users === 1,
|
|
1142
|
+
createdAt: row.created_at,
|
|
1143
|
+
updatedAt: row.updated_at
|
|
1144
|
+
};
|
|
1145
|
+
};
|
|
1146
|
+
/**
|
|
1147
|
+
* Map a field row to a Field object
|
|
1148
|
+
*/
|
|
1149
|
+
mapFieldRow = (row) => {
|
|
1150
|
+
return {
|
|
1151
|
+
id: row.id,
|
|
1152
|
+
collectionId: row.collection_id,
|
|
1153
|
+
slug: row.slug,
|
|
1154
|
+
label: row.label,
|
|
1155
|
+
type: isFieldType(row.type) ? row.type : "string",
|
|
1156
|
+
columnType: isColumnType(row.column_type) ? row.column_type : "TEXT",
|
|
1157
|
+
required: row.required === 1,
|
|
1158
|
+
unique: row.unique === 1,
|
|
1159
|
+
defaultValue: row.default_value ? JSON.parse(row.default_value) : void 0,
|
|
1160
|
+
validation: row.validation ? JSON.parse(row.validation) : void 0,
|
|
1161
|
+
widget: row.widget ?? void 0,
|
|
1162
|
+
options: row.options ? JSON.parse(row.options) : void 0,
|
|
1163
|
+
sortOrder: row.sort_order,
|
|
1164
|
+
searchable: row.searchable === 1,
|
|
1165
|
+
indexed: row.indexed === 1,
|
|
1166
|
+
translatable: row.translatable !== 0,
|
|
1167
|
+
createdAt: row.created_at
|
|
1168
|
+
};
|
|
1169
|
+
};
|
|
1170
|
+
/**
|
|
1171
|
+
* Discover orphaned content tables
|
|
1172
|
+
*
|
|
1173
|
+
* Finds ec_* tables that exist in the database but don't have a
|
|
1174
|
+
* corresponding entry in _emdash_collections.
|
|
1175
|
+
*/
|
|
1176
|
+
async discoverOrphanedTables() {
|
|
1177
|
+
const allTables = await listTablesLike(this.db, "ec_%");
|
|
1178
|
+
const registered = await this.listCollections();
|
|
1179
|
+
const registeredSlugs = new Set(registered.map((c) => c.slug));
|
|
1180
|
+
const orphans = [];
|
|
1181
|
+
for (const tableName of allTables) {
|
|
1182
|
+
const slug = tableName.replace(EC_PREFIX_PATTERN, "");
|
|
1183
|
+
if (!registeredSlugs.has(slug)) try {
|
|
1184
|
+
const countResult = await sql`
|
|
1185
|
+
SELECT COUNT(*) as count FROM ${sql.ref(tableName)}
|
|
1186
|
+
WHERE deleted_at IS NULL
|
|
1187
|
+
`.execute(this.db);
|
|
1188
|
+
orphans.push({
|
|
1189
|
+
slug,
|
|
1190
|
+
tableName,
|
|
1191
|
+
rowCount: countResult.rows[0]?.count ?? 0
|
|
1192
|
+
});
|
|
1193
|
+
} catch {
|
|
1194
|
+
orphans.push({
|
|
1195
|
+
slug,
|
|
1196
|
+
tableName,
|
|
1197
|
+
rowCount: 0
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
return orphans;
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Register an orphaned table as a collection
|
|
1205
|
+
*
|
|
1206
|
+
* Creates a _emdash_collections entry for an existing ec_* table.
|
|
1207
|
+
*/
|
|
1208
|
+
async registerOrphanedTable(slug, options) {
|
|
1209
|
+
const tableName = this.getTableName(slug);
|
|
1210
|
+
if (await isMediaUsageCollectionSlugDeleting(this.db, slug)) throw new SchemaError(`Collection "${slug}" is already registered`, "COLLECTION_EXISTS");
|
|
1211
|
+
if (!await tableExists(this.db, tableName)) throw new SchemaError(`Table "${tableName}" does not exist`, "TABLE_NOT_FOUND");
|
|
1212
|
+
const existing = await this.getCollection(slug);
|
|
1213
|
+
if (await isMediaUsageCollectionSlugDeleting(this.db, slug)) throw new SchemaError(`Collection "${slug}" is already registered`, "COLLECTION_EXISTS");
|
|
1214
|
+
if (existing && !await canResumeMediaUsageCollectionCapture(this.db, {
|
|
1215
|
+
collectionId: existing.id,
|
|
1216
|
+
collectionSlug: existing.slug
|
|
1217
|
+
})) throw new SchemaError(`Collection "${slug}" is already registered`, "COLLECTION_EXISTS");
|
|
1218
|
+
const proposedId = existing?.id ?? ulid();
|
|
1219
|
+
const label = options?.label || this.slugToLabel(slug);
|
|
1220
|
+
let collectionRegistered = false;
|
|
1221
|
+
try {
|
|
1222
|
+
const capture = await prepareMediaUsageCollectionCapture(this.db, {
|
|
1223
|
+
collectionId: proposedId,
|
|
1224
|
+
collectionSlug: slug,
|
|
1225
|
+
registeredCollectionId: existing?.id
|
|
1226
|
+
});
|
|
1227
|
+
if (capture.captureRequired) {
|
|
1228
|
+
await installPreparedMediaUsageCollectionCapture(this.db, {
|
|
1229
|
+
collectionId: capture.collectionId,
|
|
1230
|
+
collectionSlug: slug
|
|
1231
|
+
});
|
|
1232
|
+
await markMediaUsageCollectionCaptureReady(this.db, {
|
|
1233
|
+
collectionId: capture.collectionId,
|
|
1234
|
+
collectionSlug: slug
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
if (!capture.registrationExists) {
|
|
1238
|
+
await this.db.insertInto("_emdash_collections").values({
|
|
1239
|
+
id: capture.collectionId,
|
|
1240
|
+
slug,
|
|
1241
|
+
label,
|
|
1242
|
+
label_singular: options?.labelSingular ?? null,
|
|
1243
|
+
description: options?.description ?? null,
|
|
1244
|
+
icon: null,
|
|
1245
|
+
supports: JSON.stringify([]),
|
|
1246
|
+
source: "discovered",
|
|
1247
|
+
has_seo: 0,
|
|
1248
|
+
url_pattern: null
|
|
1249
|
+
}).execute();
|
|
1250
|
+
collectionRegistered = true;
|
|
1251
|
+
}
|
|
1252
|
+
if (capture.captureRequired) await finalizeMediaUsageCollectionCapture(this.db, {
|
|
1253
|
+
collectionId: capture.collectionId,
|
|
1254
|
+
collectionSlug: slug
|
|
1255
|
+
});
|
|
1256
|
+
const collection = await this.getCollection(slug);
|
|
1257
|
+
if (!collection) throw new SchemaError("Failed to register orphaned table", "REGISTER_FAILED");
|
|
1258
|
+
await markContentMediaUsageCollectionStaleSafely(this.db, slug, "CONTENT_USAGE_STALE");
|
|
1259
|
+
return collection;
|
|
1260
|
+
} catch (error) {
|
|
1261
|
+
if (collectionRegistered) await markContentMediaUsageCollectionStaleSafely(this.db, slug, "CONTENT_USAGE_STALE");
|
|
1262
|
+
throw error;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Convert slug to human-readable label
|
|
1267
|
+
*/
|
|
1268
|
+
slugToLabel(slug) {
|
|
1269
|
+
return slug.replace(UNDERSCORE_PATTERN, " ").replace(WORD_BOUNDARY_PATTERN, (c) => c.toUpperCase());
|
|
1270
|
+
}
|
|
1271
|
+
};
|
|
1272
|
+
|
|
1273
|
+
//#endregion
|
|
1274
|
+
export { SchemaRegistry as n, registry_exports as r, SchemaError as t };
|
|
1275
|
+
//# sourceMappingURL=registry-C581V4TP.mjs.map
|