emdash 0.36.0 → 0.38.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/{activation-K0kGBWuJ.mjs → activation-DyNTe_Tl.mjs} +3 -3
- package/dist/{activation-K0kGBWuJ.mjs.map → activation-DyNTe_Tl.mjs.map} +1 -1
- package/dist/{adapters-CzL3H752.d.mts → adapters-DCEgOBXi.d.mts} +4 -2
- package/dist/{adapters-CzL3H752.d.mts.map → adapters-DCEgOBXi.d.mts.map} +1 -1
- package/dist/{allowed-origins-maylGaHv.mjs → allowed-origins-GFUVavRj.mjs} +2 -2
- package/dist/{allowed-origins-maylGaHv.mjs.map → allowed-origins-GFUVavRj.mjs.map} +1 -1
- package/dist/api/route-utils.d.mts +3 -3
- package/dist/api/route-utils.mjs +25 -24
- package/dist/api/route-utils.mjs.map +1 -1
- package/dist/api/schemas/index.d.mts +2 -2
- package/dist/api/schemas/index.mjs +5 -5
- package/dist/api-BvxJmnFY.mjs +10094 -0
- package/dist/api-BvxJmnFY.mjs.map +1 -0
- package/dist/{api-tokens-9YrrCoE6.mjs → api-tokens-xpGqMHrC.mjs} +2 -2
- package/dist/{api-tokens-9YrrCoE6.mjs.map → api-tokens-xpGqMHrC.mjs.map} +1 -1
- package/dist/{apply-B_VMpJ2P.mjs → apply-DLmM3R7f.mjs} +26 -22
- package/dist/apply-DLmM3R7f.mjs.map +1 -0
- package/dist/artifact-fetch-P2JXVwOq.mjs +972 -0
- package/dist/artifact-fetch-P2JXVwOq.mjs.map +1 -0
- package/dist/astro/image-endpoint.mjs +2 -2
- package/dist/astro/image-endpoint.mjs.map +1 -1
- package/dist/astro/index.d.mts +12 -12
- package/dist/astro/index.d.mts.map +1 -1
- package/dist/astro/index.mjs +138 -39
- package/dist/astro/index.mjs.map +1 -1
- package/dist/astro/middleware/auth.d.mts +10 -10
- package/dist/astro/middleware/auth.mjs +6 -6
- package/dist/astro/middleware/media-usage-write-fence.mjs +3 -3
- package/dist/astro/middleware/redirect.mjs +7 -5
- 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 +10 -10
- package/dist/astro/middleware.d.mts.map +1 -1
- package/dist/astro/middleware.mjs +223 -232
- package/dist/astro/middleware.mjs.map +1 -1
- package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +6 -6
- package/dist/astro/routes/api/admin/allowed-domains/index.mjs +6 -6
- package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +3 -3
- package/dist/astro/routes/api/admin/api-tokens/index.d.mts.map +1 -1
- package/dist/astro/routes/api/admin/api-tokens/index.mjs +5 -5
- package/dist/astro/routes/api/admin/api-tokens/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +4 -4
- package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +9 -9
- package/dist/astro/routes/api/admin/byline-fields/index.mjs +9 -9
- package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +9 -9
- 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 +13 -13
- package/dist/astro/routes/api/admin/comments/_id_.mjs +5 -5
- package/dist/astro/routes/api/admin/comments/bulk.mjs +10 -10
- package/dist/astro/routes/api/admin/comments/counts.mjs +5 -5
- package/dist/astro/routes/api/admin/comments/index.mjs +10 -10
- package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +4 -4
- package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +3 -3
- package/dist/astro/routes/api/admin/media-usage/activation.mjs +13 -13
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs +15 -15
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs +15 -15
- package/dist/astro/routes/api/admin/media-usage/progress.mjs +14 -14
- package/dist/astro/routes/api/admin/media-usage/repair.mjs +17 -17
- package/dist/astro/routes/api/admin/media-usage/work/index.mjs +15 -15
- package/dist/astro/routes/api/admin/media-usage/work/retry.mjs +15 -15
- package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +4 -4
- package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs.map +1 -1
- package/dist/astro/routes/api/admin/oauth-clients/index.mjs +4 -4
- package/dist/astro/routes/api/admin/oauth-clients/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +59 -56
- package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +59 -56
- package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +57 -54
- package/dist/astro/routes/api/admin/plugins/_id_/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/mcp.mjs +4 -4
- package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs +57 -54
- package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +58 -55
- package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +58 -55
- package/dist/astro/routes/api/admin/plugins/_id_/update.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/index.mjs +57 -54
- package/dist/astro/routes/api/admin/plugins/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +2 -2
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +57 -54
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +58 -55
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +57 -54
- package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs +58 -55
- 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 +64 -57
- package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs +18 -16
- 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 +65 -58
- package/dist/astro/routes/api/admin/plugins/registry/install.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/registry/verify.d.mts +8 -0
- package/dist/astro/routes/api/admin/plugins/registry/verify.d.mts.map +1 -0
- package/dist/astro/routes/api/admin/plugins/registry/verify.mjs +96 -0
- package/dist/astro/routes/api/admin/plugins/registry/verify.mjs.map +1 -0
- package/dist/astro/routes/api/admin/plugins/updates.mjs +57 -54
- package/dist/astro/routes/api/admin/plugins/updates.mjs.map +1 -1
- package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +57 -54
- 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 +2 -2
- package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +57 -54
- package/dist/astro/routes/api/admin/themes/marketplace/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/users/_id_/disable.mjs +1 -1
- package/dist/astro/routes/api/admin/users/_id_/enable.mjs +1 -1
- package/dist/astro/routes/api/admin/users/_id_/index.mjs +6 -6
- package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +3 -3
- package/dist/astro/routes/api/admin/users/index.mjs +6 -6
- package/dist/astro/routes/api/auth/dev-bypass.mjs +3 -3
- package/dist/astro/routes/api/auth/invite/accept.mjs +1 -1
- package/dist/astro/routes/api/auth/invite/complete.mjs +11 -11
- package/dist/astro/routes/api/auth/invite/index.mjs +8 -8
- package/dist/astro/routes/api/auth/invite/register-options.mjs +10 -10
- package/dist/astro/routes/api/auth/logout.mjs +2 -2
- package/dist/astro/routes/api/auth/magic-link/send.mjs +10 -10
- package/dist/astro/routes/api/auth/magic-link/verify.mjs +2 -2
- package/dist/astro/routes/api/auth/me.mjs +7 -7
- package/dist/astro/routes/api/auth/mode.mjs +2 -2
- package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +4 -4
- package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
- package/dist/astro/routes/api/auth/passkey/_id_.mjs +6 -6
- package/dist/astro/routes/api/auth/passkey/index.mjs +1 -1
- package/dist/astro/routes/api/auth/passkey/options.mjs +12 -12
- package/dist/astro/routes/api/auth/passkey/register/options.mjs +10 -10
- package/dist/astro/routes/api/auth/passkey/register/verify.mjs +11 -11
- package/dist/astro/routes/api/auth/passkey/verify.mjs +11 -11
- package/dist/astro/routes/api/auth/signup/complete.mjs +11 -11
- package/dist/astro/routes/api/auth/signup/request.mjs +10 -10
- package/dist/astro/routes/api/auth/signup/verify.mjs +1 -1
- package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +14 -14
- package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +13 -13
- package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +2 -2
- package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.d.mts.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +19 -5
- package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +3 -3
- package/dist/astro/routes/api/content/_collection_/_id_/lock.d.mts +10 -0
- package/dist/astro/routes/api/content/_collection_/_id_/lock.d.mts.map +1 -0
- package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs +66 -0
- package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs.map +1 -0
- package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +2 -2
- package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +11 -11
- package/dist/astro/routes/api/content/_collection_/_id_/publish.d.mts.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +18 -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 +20 -18
- 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 +20 -18
- 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 +3 -3
- package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +2 -2
- package/dist/astro/routes/api/content/_collection_/_id_/schedule.d.mts.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +15 -8
- package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +16 -15
- package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +2 -2
- package/dist/astro/routes/api/content/_collection_/_id_/unpublish.d.mts.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +19 -5
- package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_.d.mts.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_.mjs +23 -11
- package/dist/astro/routes/api/content/_collection_/_id_.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/authors.mjs +2 -2
- package/dist/astro/routes/api/content/_collection_/index.mjs +14 -9
- package/dist/astro/routes/api/content/_collection_/index.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/trash.mjs +7 -7
- package/dist/astro/routes/api/dashboard.mjs +8 -8
- package/dist/astro/routes/api/dev/emails.mjs +2 -2
- package/dist/astro/routes/api/import/probe.d.mts +3 -3
- package/dist/astro/routes/api/import/probe.mjs +18 -18
- package/dist/astro/routes/api/import/wordpress/analyze.mjs +3 -3
- package/dist/astro/routes/api/import/wordpress/execute.d.mts +11 -11
- package/dist/astro/routes/api/import/wordpress/execute.mjs +15 -14
- 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 +11 -11
- package/dist/astro/routes/api/import/wordpress/prepare.mjs +10 -10
- package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +11 -11
- package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +13 -13
- package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
- package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +18 -18
- package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +11 -11
- package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +29 -28
- package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs.map +1 -1
- package/dist/astro/routes/api/manifest.mjs +4 -4
- package/dist/astro/routes/api/manifest.mjs.map +1 -1
- package/dist/astro/routes/api/mcp.mjs +213 -74
- package/dist/astro/routes/api/mcp.mjs.map +1 -1
- package/dist/astro/routes/api/media/_id_/confirm.mjs +11 -11
- package/dist/astro/routes/api/media/_id_/replace.d.mts +8 -0
- package/dist/astro/routes/api/media/_id_/replace.d.mts.map +1 -0
- package/dist/astro/routes/api/media/_id_/replace.mjs +91 -0
- package/dist/astro/routes/api/media/_id_/replace.mjs.map +1 -0
- package/dist/astro/routes/api/media/_id_/upload.mjs +6 -6
- package/dist/astro/routes/api/media/_id_/usage.mjs +19 -19
- package/dist/astro/routes/api/media/_id_.mjs +18 -18
- package/dist/astro/routes/api/media/file/_...key_.d.mts.map +1 -1
- package/dist/astro/routes/api/media/file/_...key_.mjs +3 -2
- package/dist/astro/routes/api/media/file/_...key_.mjs.map +1 -1
- package/dist/astro/routes/api/media/folders/_id_.mjs +8 -8
- package/dist/astro/routes/api/media/folders/index.mjs +8 -8
- package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +2 -2
- package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +2 -2
- package/dist/astro/routes/api/media/providers/index.mjs +2 -2
- package/dist/astro/routes/api/media/upload-url.mjs +16 -14
- package/dist/astro/routes/api/media/upload-url.mjs.map +1 -1
- package/dist/astro/routes/api/media.d.mts.map +1 -1
- package/dist/astro/routes/api/media.mjs +53 -30
- package/dist/astro/routes/api/media.mjs.map +1 -1
- package/dist/astro/routes/api/menus/_name_/items/_id_.d.mts.map +1 -1
- package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +20 -13
- package/dist/astro/routes/api/menus/_name_/items/_id_.mjs.map +1 -1
- package/dist/astro/routes/api/menus/_name_/items.d.mts.map +1 -1
- package/dist/astro/routes/api/menus/_name_/items.mjs +15 -11
- package/dist/astro/routes/api/menus/_name_/items.mjs.map +1 -1
- package/dist/astro/routes/api/menus/_name_/reorder.d.mts.map +1 -1
- package/dist/astro/routes/api/menus/_name_/reorder.mjs +15 -11
- package/dist/astro/routes/api/menus/_name_/reorder.mjs.map +1 -1
- package/dist/astro/routes/api/menus/_name_/translations.d.mts.map +1 -1
- package/dist/astro/routes/api/menus/_name_/translations.mjs +16 -12
- package/dist/astro/routes/api/menus/_name_/translations.mjs.map +1 -1
- package/dist/astro/routes/api/menus/_name_.d.mts.map +1 -1
- package/dist/astro/routes/api/menus/_name_.mjs +21 -14
- package/dist/astro/routes/api/menus/_name_.mjs.map +1 -1
- package/dist/astro/routes/api/menus/index.d.mts.map +1 -1
- package/dist/astro/routes/api/menus/index.mjs +15 -11
- package/dist/astro/routes/api/menus/index.mjs.map +1 -1
- package/dist/astro/routes/api/oauth/authorize.mjs +6 -6
- package/dist/astro/routes/api/oauth/device/authorize.mjs +5 -5
- package/dist/astro/routes/api/oauth/device/code.mjs +8 -8
- package/dist/astro/routes/api/oauth/device/token.mjs +7 -7
- package/dist/astro/routes/api/oauth/register.mjs +2 -2
- package/dist/astro/routes/api/oauth/token/refresh.mjs +5 -5
- package/dist/astro/routes/api/oauth/token/revoke.mjs +5 -5
- package/dist/astro/routes/api/oauth/token.mjs +5 -5
- package/dist/astro/routes/api/openapi.json.mjs +184 -52
- package/dist/astro/routes/api/openapi.json.mjs.map +1 -1
- package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +4 -4
- 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 +20 -18
- package/dist/astro/routes/api/relations/_id_/index.mjs.map +1 -1
- package/dist/astro/routes/api/relations/_id_/translations.mjs +15 -13
- package/dist/astro/routes/api/relations/_id_/translations.mjs.map +1 -1
- package/dist/astro/routes/api/relations/index.mjs +20 -18
- package/dist/astro/routes/api/relations/index.mjs.map +1 -1
- package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +2 -2
- package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +3 -3
- package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +57 -54
- 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 +57 -54
- 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 +57 -54
- package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs.map +1 -1
- package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +57 -54
- package/dist/astro/routes/api/schema/collections/_slug_/index.mjs.map +1 -1
- package/dist/astro/routes/api/schema/collections/index.mjs +57 -54
- package/dist/astro/routes/api/schema/collections/index.mjs.map +1 -1
- package/dist/astro/routes/api/schema/collections/reorder.mjs +57 -54
- package/dist/astro/routes/api/schema/collections/reorder.mjs.map +1 -1
- package/dist/astro/routes/api/schema/index.mjs +13 -11
- package/dist/astro/routes/api/schema/index.mjs.map +1 -1
- package/dist/astro/routes/api/schema/orphans/_slug_.mjs +57 -54
- package/dist/astro/routes/api/schema/orphans/_slug_.mjs.map +1 -1
- package/dist/astro/routes/api/schema/orphans/index.mjs +57 -54
- package/dist/astro/routes/api/schema/orphans/index.mjs.map +1 -1
- package/dist/astro/routes/api/search/enable.mjs +12 -11
- package/dist/astro/routes/api/search/enable.mjs.map +1 -1
- package/dist/astro/routes/api/search/index.mjs +11 -10
- package/dist/astro/routes/api/search/index.mjs.map +1 -1
- package/dist/astro/routes/api/search/rebuild.mjs +12 -11
- package/dist/astro/routes/api/search/rebuild.mjs.map +1 -1
- package/dist/astro/routes/api/search/stats.mjs +7 -6
- package/dist/astro/routes/api/search/stats.mjs.map +1 -1
- package/dist/astro/routes/api/search/suggest.mjs +11 -10
- package/dist/astro/routes/api/search/suggest.mjs.map +1 -1
- package/dist/astro/routes/api/sections/_slug_.mjs +11 -10
- package/dist/astro/routes/api/sections/_slug_.mjs.map +1 -1
- package/dist/astro/routes/api/sections/index.mjs +11 -10
- package/dist/astro/routes/api/sections/index.mjs.map +1 -1
- package/dist/astro/routes/api/settings/backups/archives/_name_.mjs +7 -6
- package/dist/astro/routes/api/settings/backups/archives/_name_.mjs.map +1 -1
- package/dist/astro/routes/api/settings/backups/archives/index.mjs +6 -5
- package/dist/astro/routes/api/settings/backups/archives/index.mjs.map +1 -1
- package/dist/astro/routes/api/settings/backups/export.mjs +7 -6
- package/dist/astro/routes/api/settings/backups/export.mjs.map +1 -1
- package/dist/astro/routes/api/settings/backups/index.mjs +8 -7
- package/dist/astro/routes/api/settings/backups/index.mjs.map +1 -1
- package/dist/astro/routes/api/settings/email.mjs +5 -5
- package/dist/astro/routes/api/settings/email.mjs.map +1 -1
- package/dist/astro/routes/api/settings.d.mts.map +1 -1
- package/dist/astro/routes/api/settings.mjs +21 -17
- package/dist/astro/routes/api/settings.mjs.map +1 -1
- package/dist/astro/routes/api/setup/admin-verify.mjs +12 -12
- package/dist/astro/routes/api/setup/admin.mjs +11 -11
- package/dist/astro/routes/api/setup/dev-bypass.mjs +35 -33
- package/dist/astro/routes/api/setup/dev-bypass.mjs.map +1 -1
- package/dist/astro/routes/api/setup/dev-reset.mjs +2 -2
- package/dist/astro/routes/api/setup/index.mjs +35 -33
- package/dist/astro/routes/api/setup/index.mjs.map +1 -1
- package/dist/astro/routes/api/setup/status.mjs +3 -3
- package/dist/astro/routes/api/snapshot.mjs +8 -7
- package/dist/astro/routes/api/snapshot.mjs.map +1 -1
- package/dist/astro/routes/api/taxonomies/_name_/reorder.d.mts.map +1 -1
- package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs +22 -17
- package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs.map +1 -1
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.d.mts.map +1 -1
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +23 -18
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs.map +1 -1
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.d.mts.map +1 -1
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +27 -19
- 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 +22 -17
- package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs.map +1 -1
- package/dist/astro/routes/api/taxonomies/_name_/translations.mjs +16 -15
- package/dist/astro/routes/api/taxonomies/_name_/translations.mjs.map +1 -1
- package/dist/astro/routes/api/taxonomies/_name_.d.mts.map +1 -1
- package/dist/astro/routes/api/taxonomies/_name_.mjs +28 -20
- package/dist/astro/routes/api/taxonomies/_name_.mjs.map +1 -1
- package/dist/astro/routes/api/taxonomies/index.d.mts.map +1 -1
- package/dist/astro/routes/api/taxonomies/index.mjs +22 -17
- package/dist/astro/routes/api/taxonomies/index.mjs.map +1 -1
- package/dist/astro/routes/api/themes/preview.mjs +5 -5
- package/dist/astro/routes/api/typegen.mjs +4 -4
- package/dist/astro/routes/api/well-known/auth.mjs +2 -2
- 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.d.mts.map +1 -1
- package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +10 -8
- package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs.map +1 -1
- package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.d.mts.map +1 -1
- package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +18 -14
- package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs.map +1 -1
- package/dist/astro/routes/api/widget-areas/_name_/widgets.d.mts.map +1 -1
- package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +16 -13
- package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs.map +1 -1
- package/dist/astro/routes/api/widget-areas/_name_.d.mts.map +1 -1
- package/dist/astro/routes/api/widget-areas/_name_.mjs +9 -7
- package/dist/astro/routes/api/widget-areas/_name_.mjs.map +1 -1
- package/dist/astro/routes/api/widget-areas/index.d.mts.map +1 -1
- package/dist/astro/routes/api/widget-areas/index.mjs +16 -13
- package/dist/astro/routes/api/widget-areas/index.mjs.map +1 -1
- package/dist/astro/routes/api/widget-components.mjs +2 -2
- package/dist/astro/routes/robots.txt.mjs +8 -8
- package/dist/astro/routes/sitemap-_collection_.xml.mjs +13 -12
- package/dist/astro/routes/sitemap-_collection_.xml.mjs.map +1 -1
- package/dist/astro/routes/sitemap.xml.mjs +9 -9
- package/dist/astro/types.d.mts +50 -20
- 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-ByYs-Uxs.mjs → authorize-C2QHlWSS.mjs} +2 -2
- package/dist/{authorize-ByYs-Uxs.mjs.map → authorize-C2QHlWSS.mjs.map} +1 -1
- package/dist/{backup-ChyHfIoX.mjs → backup-oS8ft5Cm.mjs} +5 -5
- package/dist/{backup-ChyHfIoX.mjs.map → backup-oS8ft5Cm.mjs.map} +1 -1
- package/dist/{bundle-DZFhFurR.mjs → bundle-CL0JjIPx.mjs} +4 -4
- package/dist/{bundle-DZFhFurR.mjs.map → bundle-CL0JjIPx.mjs.map} +1 -1
- package/dist/{byline-Cpnwrje1.mjs → byline-Vdi85CsZ.mjs} +27 -14
- package/dist/byline-Vdi85CsZ.mjs.map +1 -0
- package/dist/{byline-fields-CAyA_Umd.mjs → byline-fields-DPVRFMz2.mjs} +2 -2
- package/dist/{byline-fields-CAyA_Umd.mjs.map → byline-fields-DPVRFMz2.mjs.map} +1 -1
- package/dist/{byline-registry-Bpu9-MVs.mjs → byline-registry-BxDGIO0I.mjs} +2 -2
- package/dist/{byline-registry-Bpu9-MVs.mjs.map → byline-registry-BxDGIO0I.mjs.map} +1 -1
- package/dist/{bylines-BSo9B9RX.mjs → bylines-BX8QhcTk.mjs} +7 -7
- package/dist/{bylines-BSo9B9RX.mjs.map → bylines-BX8QhcTk.mjs.map} +1 -1
- package/dist/{bylines-CHjvehVX.mjs → bylines-w-E1IEQd.mjs} +3 -3
- package/dist/{bylines-CHjvehVX.mjs.map → bylines-w-E1IEQd.mjs.map} +1 -1
- package/dist/{cache-5VirJ2Cn.mjs → cache--7HKu5Xm.mjs} +4 -4
- package/dist/{cache-5VirJ2Cn.mjs.map → cache--7HKu5Xm.mjs.map} +1 -1
- package/dist/{capture-triggers-CNW1q3HK.mjs → capture-triggers-CeAsC76Z.mjs} +2 -2
- package/dist/{capture-triggers-CNW1q3HK.mjs.map → capture-triggers-CeAsC76Z.mjs.map} +1 -1
- package/dist/{challenge-store-D5pSY2S1.mjs → challenge-store-BIOak-tp.mjs} +5 -3
- package/dist/challenge-store-BIOak-tp.mjs.map +1 -0
- package/dist/chrome-tags-DzDQBCjX.mjs +24 -0
- package/dist/chrome-tags-DzDQBCjX.mjs.map +1 -0
- package/dist/{chunks-bNiX6_DR.mjs → chunks-VG_tyqnP.mjs} +2 -2
- package/dist/{chunks-bNiX6_DR.mjs.map → chunks-VG_tyqnP.mjs.map} +1 -1
- package/dist/cli/index.mjs +68 -40
- package/dist/cli/index.mjs.map +1 -1
- package/dist/client/cf-access.d.mts +1 -1
- package/dist/client/index.d.mts +17 -7
- package/dist/client/index.d.mts.map +1 -1
- package/dist/client/index.mjs +17 -12
- package/dist/client/index.mjs.map +1 -1
- package/dist/{collection-deletion-m_oi2c0N.mjs → collection-deletion-BCwaWTDw.mjs} +4 -4
- package/dist/{collection-deletion-m_oi2c0N.mjs.map → collection-deletion-BCwaWTDw.mjs.map} +1 -1
- package/dist/collection-slugs-cache-7lTmNzeA.mjs +85 -0
- package/dist/collection-slugs-cache-7lTmNzeA.mjs.map +1 -0
- package/dist/{comment-reaction-CRuItEjt.mjs → comment-reaction-CDyvPQRj.mjs} +2 -2
- package/dist/{comment-reaction-CRuItEjt.mjs.map → comment-reaction-CDyvPQRj.mjs.map} +1 -1
- package/dist/{comment-DhvLEdhQ.mjs → comment-vxOzWbZN.mjs} +2 -2
- package/dist/{comment-DhvLEdhQ.mjs.map → comment-vxOzWbZN.mjs.map} +1 -1
- package/dist/{comments-CLj4bi8I.mjs → comments-VzmVLyaC.mjs} +2 -2
- package/dist/{comments-CLj4bi8I.mjs.map → comments-VzmVLyaC.mjs.map} +1 -1
- package/dist/{components-v4U4DT2y.mjs → components-CL6Wkdk-.mjs} +1 -1
- package/dist/{components-v4U4DT2y.mjs.map → components-CL6Wkdk-.mjs.map} +1 -1
- package/dist/config--eWjQJE5.mjs +217 -0
- package/dist/config--eWjQJE5.mjs.map +1 -0
- package/dist/{index-DWbJrsAg.d.mts → config-CGAhyOjP.d.mts} +276 -76
- package/dist/config-CGAhyOjP.d.mts.map +1 -0
- package/dist/{config-DrfghTPe.d.mts → config-ChFzshGd.d.mts} +1 -1
- package/dist/{config-DrfghTPe.d.mts.map → config-ChFzshGd.d.mts.map} +1 -1
- package/dist/{content-CP-SeXNa.mjs → content-CNfMWuhY.mjs} +202 -46
- package/dist/content-CNfMWuhY.mjs.map +1 -0
- package/dist/{content-list-query-BhejKVqb.d.mts → content-list-query-B8d4UQp9.d.mts} +1 -1
- package/dist/{content-list-query-BhejKVqb.d.mts.map → content-list-query-B8d4UQp9.d.mts.map} +1 -1
- package/dist/{content-refresh-DLOfIhYc.mjs → content-refresh-GTMyi2Xy.mjs} +53 -26
- package/dist/content-refresh-GTMyi2Xy.mjs.map +1 -0
- package/dist/{content-repair-BCxzy0r4.mjs → content-repair-CIMt5C0U.mjs} +4 -4
- package/dist/{content-repair-BCxzy0r4.mjs.map → content-repair-CIMt5C0U.mjs.map} +1 -1
- package/dist/{context-BR5hRWiK.mjs → context-C9PB8vGd.mjs} +308 -33
- package/dist/context-C9PB8vGd.mjs.map +1 -0
- package/dist/{cron-CWfWrWKG.mjs → cron-DHAy9oyq.mjs} +1 -1
- package/dist/{cron-CWfWrWKG.mjs.map → cron-DHAy9oyq.mjs.map} +1 -1
- package/dist/{dashboard-CkIV2rnQ.mjs → dashboard-BNSvAN8A.mjs} +5 -5
- package/dist/{dashboard-CkIV2rnQ.mjs.map → dashboard-BNSvAN8A.mjs.map} +1 -1
- package/dist/db/index.d.mts +3 -3
- package/dist/db/index.mjs +2 -2
- package/dist/db/index.mjs.map +1 -1
- package/dist/db/libsql-migrations.d.mts +1 -1
- package/dist/db/libsql-migrations.mjs +5 -5
- package/dist/db/libsql.d.mts +1 -1
- package/dist/db/postgres-migrations.d.mts +1 -1
- package/dist/db/postgres-migrations.mjs +5 -5
- package/dist/db/postgres.d.mts +1 -1
- package/dist/db/postgres.d.mts.map +1 -1
- package/dist/db/postgres.mjs +19 -3
- package/dist/db/postgres.mjs.map +1 -1
- package/dist/db/sqlite-migrations.d.mts +1 -1
- package/dist/db/sqlite-migrations.mjs +5 -5
- package/dist/db/sqlite.d.mts +1 -1
- package/dist/db/sqlite.mjs +1 -1
- package/dist/{default-YMEfcQUx.mjs → default-ByZ0JqZo.mjs} +1 -1
- package/dist/{default-YMEfcQUx.mjs.map → default-ByZ0JqZo.mjs.map} +1 -1
- package/dist/{deferred-tasks-DfqxH5Xf.d.mts → deferred-tasks-Cu4NSJpa.d.mts} +1 -1
- package/dist/{deferred-tasks-DfqxH5Xf.d.mts.map → deferred-tasks-Cu4NSJpa.d.mts.map} +1 -1
- package/dist/dev-typegen-DHT7lcMU.mjs +29 -0
- package/dist/dev-typegen-DHT7lcMU.mjs.map +1 -0
- package/dist/{device-flow-CojjSBwb.mjs → device-flow-Cf6bhCCT.mjs} +4 -4
- package/dist/{device-flow-CojjSBwb.mjs.map → device-flow-Cf6bhCCT.mjs.map} +1 -1
- package/dist/{dialect-helpers-BSbfaO3F.mjs → dialect-helpers-BcQvkHgn.mjs} +83 -2
- package/dist/dialect-helpers-BcQvkHgn.mjs.map +1 -0
- package/dist/{direct-executor-BWeWiRYB.mjs → direct-executor-yAyUGSqB.mjs} +3 -3
- package/dist/{direct-executor-BWeWiRYB.mjs.map → direct-executor-yAyUGSqB.mjs.map} +1 -1
- package/dist/{dist-89xCrGqi.mjs → dist-BAsh8dbf.mjs} +1 -1
- package/dist/{dist-89xCrGqi.mjs.map → dist-BAsh8dbf.mjs.map} +1 -1
- package/dist/{email-console-CEJgR_LB.mjs → email-console-DNup1Fku.mjs} +1 -1
- package/dist/{email-console-CEJgR_LB.mjs.map → email-console-DNup1Fku.mjs.map} +1 -1
- package/dist/{enrich-BX0IDp4z.mjs → enrich-t2Xvjdqa.mjs} +3 -3
- package/dist/{enrich-BX0IDp4z.mjs.map → enrich-t2Xvjdqa.mjs.map} +1 -1
- package/dist/entry-lock-BEr8gDkG.mjs +163 -0
- package/dist/entry-lock-BEr8gDkG.mjs.map +1 -0
- package/dist/{relations-C7B46bcU.d.mts → entry-lock-CGAtrwAR.d.mts} +265 -76
- package/dist/entry-lock-CGAtrwAR.d.mts.map +1 -0
- package/dist/{redirects-CRIM55KH.mjs → entry-lock-DIYHAaSw.mjs} +112 -34
- package/dist/entry-lock-DIYHAaSw.mjs.map +1 -0
- package/dist/entry-locks-BEcX7ET0.mjs +167 -0
- package/dist/entry-locks-BEcX7ET0.mjs.map +1 -0
- package/dist/{error-D9w94fjV.mjs → error-BDcFyoRt.mjs} +2 -2
- package/dist/{error-D9w94fjV.mjs.map → error-BDcFyoRt.mjs.map} +1 -1
- package/dist/{errors-n2j49uNf.mjs → errors-DvMdNrgf.mjs} +10 -1
- package/dist/errors-DvMdNrgf.mjs.map +1 -0
- package/dist/{escape-DN4Qmjsl.mjs → escape-B3asJC6W.mjs} +1 -1
- package/dist/{escape-DN4Qmjsl.mjs.map → escape-B3asJC6W.mjs.map} +1 -1
- package/dist/{field-defs-cache-Bh4q6oar.mjs → field-defs-cache-Cf5FHK0M.mjs} +5 -5
- package/dist/{field-defs-cache-Bh4q6oar.mjs.map → field-defs-cache-Cf5FHK0M.mjs.map} +1 -1
- package/dist/{fts-manager-BhOdW0bi.mjs → fts-manager-iddym8cd.mjs} +4 -4
- package/dist/{fts-manager-BhOdW0bi.mjs.map → fts-manager-iddym8cd.mjs.map} +1 -1
- package/dist/{hash-CTcngWvj.mjs → hash-BRweX6jz.mjs} +1 -1
- package/dist/{hash-CTcngWvj.mjs.map → hash-BRweX6jz.mjs.map} +1 -1
- package/dist/hook-result-BrshYHLx.d.mts +31 -0
- package/dist/hook-result-BrshYHLx.d.mts.map +1 -0
- package/dist/{hreflang-7pTHsLZJ.d.mts → hreflang-CQpu5bMy.d.mts} +2 -2
- package/dist/{hreflang-7pTHsLZJ.d.mts.map → hreflang-CQpu5bMy.d.mts.map} +1 -1
- package/dist/{hreflang-Huc6O5wa.mjs → hreflang-DshnweTC.mjs} +9 -8
- package/dist/{hreflang-Huc6O5wa.mjs.map → hreflang-DshnweTC.mjs.map} +1 -1
- package/dist/{identity-DXmb4aVp.mjs → identity-CjGKDq8J.mjs} +3 -3
- package/dist/{identity-DXmb4aVp.mjs.map → identity-CjGKDq8J.mjs.map} +1 -1
- package/dist/{import-C4_O3KXU.mjs → import-D96g2otw.mjs} +6 -6
- package/dist/{import-C4_O3KXU.mjs.map → import-D96g2otw.mjs.map} +1 -1
- package/dist/{index-6bRee8zb.d.mts → index-1ECYpfiF.d.mts} +3 -3
- package/dist/{index-6bRee8zb.d.mts.map → index-1ECYpfiF.d.mts.map} +1 -1
- package/dist/index.d.mts +22 -21
- package/dist/index.mjs +84 -81
- package/dist/{init-lock-DJkX6Hto.mjs → init-lock-CFNBe_iH.mjs} +1 -1
- package/dist/{init-lock-DJkX6Hto.mjs.map → init-lock-CFNBe_iH.mjs.map} +1 -1
- package/dist/{load-Bo7fZAbg.mjs → load-DPtY9cZo.mjs} +2 -2
- package/dist/{load-Bo7fZAbg.mjs.map → load-DPtY9cZo.mjs.map} +1 -1
- package/dist/{loader-ZsjE4paL.mjs → loader-WJi6GFRn.mjs} +90 -17
- package/dist/loader-WJi6GFRn.mjs.map +1 -0
- package/dist/{manifest-builder-QXuqvVMP.mjs → manifest-builder-BfNlGQIA.mjs} +2 -2
- package/dist/{manifest-builder-QXuqvVMP.mjs.map → manifest-builder-BfNlGQIA.mjs.map} +1 -1
- package/dist/{manifest-schema-CUYPfCEH.mjs → manifest-schema-CILooI5J.mjs} +5 -5
- package/dist/manifest-schema-CILooI5J.mjs.map +1 -0
- package/dist/media/image-endpoint.d.mts +4 -2
- package/dist/media/image-endpoint.d.mts.map +1 -1
- package/dist/media/image-endpoint.mjs +6 -4
- package/dist/media/image-endpoint.mjs.map +1 -1
- package/dist/media/index.d.mts +1 -1
- package/dist/media/index.mjs +3 -3
- package/dist/media/local-runtime.d.mts +12 -12
- package/dist/media/local-runtime.mjs +7 -7
- package/dist/{media-D6SeAfBl.mjs → media-BBm8Wg3f.mjs} +30 -2
- package/dist/media-BBm8Wg3f.mjs.map +1 -0
- package/dist/{media-BjwNuLEu.mjs → media-C1EIZKh1.mjs} +35 -5
- package/dist/media-C1EIZKh1.mjs.map +1 -0
- package/dist/{media-allowlist-D35v7bmL.mjs → media-allowlist-elXJgb_K.mjs} +2 -2
- package/dist/{media-allowlist-D35v7bmL.mjs.map → media-allowlist-elXJgb_K.mjs.map} +1 -1
- package/dist/{media-folders-D-0CmRZj.mjs → media-folders-DASfX_DH.mjs} +1 -1
- package/dist/{media-folders-D-0CmRZj.mjs.map → media-folders-DASfX_DH.mjs.map} +1 -1
- package/dist/{media-upload-C7bLXGcI.mjs → media-upload-C7_AQJ5v.mjs} +9 -9
- package/dist/{media-upload-C7bLXGcI.mjs.map → media-upload-C7_AQJ5v.mjs.map} +1 -1
- package/dist/{media-url-DH7giMx_.mjs → media-url-8dVl1loq.mjs} +19 -2
- package/dist/media-url-8dVl1loq.mjs.map +1 -0
- package/dist/{media-usage-BTRJvS6V.mjs → media-usage-C1EswMTq.mjs} +10 -10
- package/dist/{media-usage-BTRJvS6V.mjs.map → media-usage-C1EswMTq.mjs.map} +1 -1
- package/dist/{media-usage-activation-Dx0kPV6b.mjs → media-usage-activation-CrHNltlL.mjs} +3 -3
- package/dist/{media-usage-activation-Dx0kPV6b.mjs.map → media-usage-activation-CrHNltlL.mjs.map} +1 -1
- package/dist/{media-usage-work-C-fhM30c.mjs → media-usage-work-C5B1zT1c.mjs} +2 -2
- package/dist/{media-usage-work-C-fhM30c.mjs.map → media-usage-work-C5B1zT1c.mjs.map} +1 -1
- package/dist/{media-usage-work-DWb2XPMI.mjs → media-usage-work-IkQx_Yz6.mjs} +4 -4
- package/dist/{media-usage-work-DWb2XPMI.mjs.map → media-usage-work-IkQx_Yz6.mjs.map} +1 -1
- package/dist/{media-usage-write-fence-BwoJVRDC.mjs → media-usage-write-fence-B9anjOSg.mjs} +3 -3
- package/dist/{media-usage-write-fence-BwoJVRDC.mjs.map → media-usage-write-fence-B9anjOSg.mjs.map} +1 -1
- package/dist/{menus-CNg0QlDt.mjs → menus-D8mC4eaN.mjs} +406 -175
- package/dist/menus-D8mC4eaN.mjs.map +1 -0
- package/dist/{menus-CD7EFLwz.mjs → menus-UdwjHZJC.mjs} +12 -4
- package/dist/{menus-CD7EFLwz.mjs.map → menus-UdwjHZJC.mjs.map} +1 -1
- package/dist/migrations/index.d.mts +1 -1
- package/dist/migrations/index.mjs +4 -4
- package/dist/{mime-CUIG6x84.mjs → mime-DYpsOAny.mjs} +1 -1
- package/dist/{mime-CUIG6x84.mjs.map → mime-DYpsOAny.mjs.map} +1 -1
- package/dist/{mode-DaUM_MB2.mjs → mode-Dm4BHhRH.mjs} +1 -1
- package/dist/{mode-DaUM_MB2.mjs.map → mode-Dm4BHhRH.mjs.map} +1 -1
- package/dist/{node-sqlite-compat-Udb4Y-rs.mjs → node-sqlite-compat-2sezm-Zd.mjs} +1 -1
- package/dist/{node-sqlite-compat-Udb4Y-rs.mjs.map → node-sqlite-compat-2sezm-Zd.mjs.map} +1 -1
- package/dist/{normalize-CSxdKBVa.mjs → normalize-4nkKGsuW.mjs} +15 -5
- package/dist/normalize-4nkKGsuW.mjs.map +1 -0
- package/dist/{oauth-authorization-Dpsb-fMJ.mjs → oauth-authorization-BxE_lURD.mjs} +4 -4
- package/dist/{oauth-authorization-Dpsb-fMJ.mjs.map → oauth-authorization-BxE_lURD.mjs.map} +1 -1
- package/dist/{oauth-clients-Bxnoe_67.mjs → oauth-clients-DJIdOdq0.mjs} +1 -1
- package/dist/{oauth-clients-Bxnoe_67.mjs.map → oauth-clients-DJIdOdq0.mjs.map} +1 -1
- package/dist/{oauth-state-store-0C4s0K6w.mjs → oauth-state-store-CsdxP57n.mjs} +1 -1
- package/dist/{oauth-state-store-0C4s0K6w.mjs.map → oauth-state-store-CsdxP57n.mjs.map} +1 -1
- package/dist/{oauth-user-lookup-wlGYSeqX.mjs → oauth-user-lookup-HzzW-dkF.mjs} +1 -1
- package/dist/{oauth-user-lookup-wlGYSeqX.mjs.map → oauth-user-lookup-HzzW-dkF.mjs.map} +1 -1
- package/dist/object-cache/memory.d.mts +1 -1
- package/dist/{object-cache-71tPfV4A.mjs → object-cache-DVKnyOfy.mjs} +19 -3
- package/dist/object-cache-DVKnyOfy.mjs.map +1 -0
- package/dist/{options-BHPeIbBd.mjs → options-D1FBiAv1.mjs} +60 -5
- package/dist/options-D1FBiAv1.mjs.map +1 -0
- package/dist/{options-BhZIeFY1.d.mts → options-D8Y0VHc7.d.mts} +30 -11
- package/dist/options-D8Y0VHc7.d.mts.map +1 -0
- package/dist/page/index.d.mts +2 -2
- package/dist/page/index.d.mts.map +1 -1
- package/dist/page/index.mjs +12 -0
- package/dist/page/index.mjs.map +1 -1
- package/dist/{parse-BRJg1kz8.mjs → parse-WRg5C3NX.mjs} +2 -2
- package/dist/{parse-BRJg1kz8.mjs.map → parse-WRg5C3NX.mjs.map} +1 -1
- package/dist/{passkey-config-B3P0nHRR.mjs → passkey-config-qIdO-wF6.mjs} +1 -1
- package/dist/{passkey-config-B3P0nHRR.mjs.map → passkey-config-qIdO-wF6.mjs.map} +1 -1
- package/dist/{patterns-D9iDO3j8.mjs → patterns-DC8CLptu.mjs} +1 -1
- package/dist/{patterns-D9iDO3j8.mjs.map → patterns-DC8CLptu.mjs.map} +1 -1
- package/dist/{placeholder-BR4ZhVJl.d.mts → placeholder-COrvARyD.d.mts} +1 -1
- package/dist/{placeholder-BR4ZhVJl.d.mts.map → placeholder-COrvARyD.d.mts.map} +1 -1
- package/dist/plugin-types.d.mts +8 -3
- 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 +2 -2
- package/dist/{policy-BVRganJQ.mjs → policy-XCfb-IE9.mjs} +2 -2
- package/dist/{policy-BVRganJQ.mjs.map → policy-XCfb-IE9.mjs.map} +1 -1
- package/dist/{portable-text-C8Tvp4_g.mjs → portable-text-BS3d5n-0.mjs} +1 -1
- package/dist/{portable-text-C8Tvp4_g.mjs.map → portable-text-BS3d5n-0.mjs.map} +1 -1
- package/dist/{preview-dn2dUyM0.mjs → preview-BxwsGgGp.mjs} +2 -2
- package/dist/{preview-dn2dUyM0.mjs.map → preview-BxwsGgGp.mjs.map} +1 -1
- package/dist/{protocol-CuBEsqgE.d.mts → protocol-CLn58-nw.d.mts} +2 -2
- package/dist/{protocol-CuBEsqgE.d.mts.map → protocol-CLn58-nw.d.mts.map} +1 -1
- package/dist/{public-url-DRz_AinV.mjs → public-url-FWWAvnre.mjs} +1 -1
- package/dist/{public-url-DRz_AinV.mjs.map → public-url-FWWAvnre.mjs.map} +1 -1
- package/dist/{query-D18vTdha.mjs → query-DygOte9M.mjs} +26 -17
- package/dist/query-DygOte9M.mjs.map +1 -0
- package/dist/{query-tZDEdtCN.mjs → query-gtXT03Wc.mjs} +5 -5
- package/dist/{query-tZDEdtCN.mjs.map → query-gtXT03Wc.mjs.map} +1 -1
- package/dist/{rate-limit-on7KPo-v.mjs → rate-limit-CQUPm0dh.mjs} +2 -2
- package/dist/{rate-limit-on7KPo-v.mjs.map → rate-limit-CQUPm0dh.mjs.map} +1 -1
- package/dist/{redirect-DrbEmU9a.mjs → redirect-D1cWafi6.mjs} +1 -1
- package/dist/{redirect-DrbEmU9a.mjs.map → redirect-D1cWafi6.mjs.map} +1 -1
- package/dist/{redirect-CZkbozu9.mjs → redirect-DId44BS1.mjs} +19 -6
- package/dist/redirect-DId44BS1.mjs.map +1 -0
- package/dist/{redirects-BahWiu8Z.mjs → redirects-DN-ZE33W.mjs} +5 -5
- package/dist/{redirects-BahWiu8Z.mjs.map → redirects-DN-ZE33W.mjs.map} +1 -1
- package/dist/{registry-Cx-jEJOS.mjs → registry-DTqaqxed.mjs} +46 -12
- package/dist/registry-DTqaqxed.mjs.map +1 -0
- package/dist/{relation-A6wLF_DS.mjs → relation-DxgCHOBw.mjs} +2 -2
- package/dist/{relation-A6wLF_DS.mjs.map → relation-DxgCHOBw.mjs.map} +1 -1
- package/dist/{relations-Cj5hZ6Zg.mjs → relations-KKDSLUwS.mjs} +4 -4
- package/dist/{relations-Cj5hZ6Zg.mjs.map → relations-KKDSLUwS.mjs.map} +1 -1
- package/dist/{relations-BTPM2saV.mjs → relations-rOmbndUJ.mjs} +8 -8
- package/dist/relations-rOmbndUJ.mjs.map +1 -0
- package/dist/{request-cache-DH9zdCOD.mjs → request-cache-DAZZmesc.mjs} +1 -1
- package/dist/{request-cache-DH9zdCOD.mjs.map → request-cache-DAZZmesc.mjs.map} +1 -1
- package/dist/request-context.d.mts +1 -1
- package/dist/{request-meta-DRp5ENd_.mjs → request-meta-BgjUQLQ-.mjs} +2 -2
- package/dist/{request-meta-DRp5ENd_.mjs.map → request-meta-BgjUQLQ-.mjs.map} +1 -1
- package/dist/{resolve-DxUpTMmE.mjs → resolve-Cy0aWSRj.mjs} +37 -4
- package/dist/resolve-Cy0aWSRj.mjs.map +1 -0
- package/dist/{runner-zgqA_CqP.d.mts → runner-CfwysRM0.d.mts} +3 -2
- package/dist/runner-CfwysRM0.d.mts.map +1 -0
- package/dist/{runner-77GOZCnH.mjs → runner-nEzvnogG.mjs} +476 -295
- package/dist/runner-nEzvnogG.mjs.map +1 -0
- package/dist/runtime.d.mts +11 -11
- package/dist/runtime.mjs +3 -2
- package/dist/runtime.mjs.map +1 -1
- package/dist/{schema-BY-oVntF.mjs → schema-CRu38Pr5.mjs} +3 -3
- package/dist/{schema-BY-oVntF.mjs.map → schema-CRu38Pr5.mjs.map} +1 -1
- package/dist/{schema-Cw9kVK0I.mjs → schema-DifxndJx.mjs} +5 -5
- package/dist/{schema-Cw9kVK0I.mjs.map → schema-DifxndJx.mjs.map} +1 -1
- package/dist/{scopes-vMR1uIbt.mjs → scopes-D5A1OZbq.mjs} +3 -3
- package/dist/{scopes-vMR1uIbt.mjs.map → scopes-D5A1OZbq.mjs.map} +1 -1
- package/dist/{search-CfT3KxO5.mjs → search-DEPFSBFq.mjs} +4 -4
- package/dist/{search-CfT3KxO5.mjs.map → search-DEPFSBFq.mjs.map} +1 -1
- package/dist/{secrets-BH2Qow1-.mjs → secrets-CdfzLdoO.mjs} +3 -3
- package/dist/{secrets-BH2Qow1-.mjs.map → secrets-CdfzLdoO.mjs.map} +1 -1
- package/dist/{sections-DTfjyf1z.mjs → sections-3X52kmIR.mjs} +2 -2
- package/dist/{sections-DTfjyf1z.mjs.map → sections-3X52kmIR.mjs.map} +1 -1
- package/dist/seed/index.d.mts +2 -2
- package/dist/seed/index.mjs +28 -26
- package/dist/seo/index.d.mts +3 -3
- package/dist/seo/index.d.mts.map +1 -1
- package/dist/seo/index.mjs +20 -21
- package/dist/seo/index.mjs.map +1 -1
- package/dist/{seo-Cm-dtvgk.mjs → seo-Bw68KxRc.mjs} +3 -3
- package/dist/{seo-Cm-dtvgk.mjs.map → seo-Bw68KxRc.mjs.map} +1 -1
- package/dist/{seo-BSiTIXzd.mjs → seo-C4AmbsMU.mjs} +3 -2
- package/dist/seo-C4AmbsMU.mjs.map +1 -0
- package/dist/{service-DYsDHEKe.mjs → service-J_-Vgo7R.mjs} +3 -3
- package/dist/{service-DYsDHEKe.mjs.map → service-J_-Vgo7R.mjs.map} +1 -1
- package/dist/{session-user-CNAfvsdw.mjs → session-user-CbnMMwk6.mjs} +1 -1
- package/dist/{session-user-CNAfvsdw.mjs.map → session-user-CbnMMwk6.mjs.map} +1 -1
- package/dist/{settings-DjtkUo__.mjs → settings-AnEFYICn.mjs} +3 -3
- package/dist/{settings-DjtkUo__.mjs.map → settings-AnEFYICn.mjs.map} +1 -1
- package/dist/{settings-BgN-0DT-.mjs → settings-DcMjREe5.mjs} +21 -8
- package/dist/settings-DcMjREe5.mjs.map +1 -0
- package/dist/{setup-complete-CcpXaPU7.mjs → setup-complete-BClXXTvr.mjs} +2 -2
- package/dist/{setup-complete-CcpXaPU7.mjs.map → setup-complete-BClXXTvr.mjs.map} +1 -1
- package/dist/{setup-nonce-Reyw30jg.mjs → setup-nonce-BheRa4RG.mjs} +1 -1
- package/dist/{setup-nonce-Reyw30jg.mjs.map → setup-nonce-BheRa4RG.mjs.map} +1 -1
- package/dist/{single-flight-cache-BPuGPdcN.mjs → single-flight-cache-jaswDzmQ.mjs} +2 -2
- package/dist/{single-flight-cache-BPuGPdcN.mjs.map → single-flight-cache-jaswDzmQ.mjs.map} +1 -1
- package/dist/{site-url-Cs_V9n3V.mjs → site-url-Bqf-ea3N.mjs} +3 -3
- package/dist/{site-url-Cs_V9n3V.mjs.map → site-url-Bqf-ea3N.mjs.map} +1 -1
- package/dist/{snapshot-DSB8P7Lm.mjs → snapshot-C4CtXntb.mjs} +51 -35
- package/dist/snapshot-C4CtXntb.mjs.map +1 -0
- package/dist/{ssrf-DqebVE34.mjs → ssrf-gl4gFNhw.mjs} +151 -93
- package/dist/ssrf-gl4gFNhw.mjs.map +1 -0
- package/dist/{state-BJfU9Uzw.mjs → state-1F6IOhdQ.mjs} +1 -1
- package/dist/{state-BJfU9Uzw.mjs.map → state-1F6IOhdQ.mjs.map} +1 -1
- package/dist/{status-DDu8HIQl.mjs → status-Cenfk_r5.mjs} +1 -1
- package/dist/{status-DDu8HIQl.mjs.map → status-Cenfk_r5.mjs.map} +1 -1
- package/dist/storage/local.d.mts +2 -1
- package/dist/storage/local.d.mts.map +1 -1
- package/dist/storage/local.mjs +1 -1
- package/dist/storage/local.mjs.map +1 -1
- package/dist/storage/s3.d.mts +2 -1
- package/dist/storage/s3.d.mts.map +1 -1
- package/dist/storage/s3.mjs +3 -2
- package/dist/storage/s3.mjs.map +1 -1
- package/dist/{target-D0o26Azo.mjs → target-CRzeTs8G.mjs} +1 -1
- package/dist/{target-D0o26Azo.mjs.map → target-CRzeTs8G.mjs.map} +1 -1
- package/dist/{taxonomies-CPGxo-bn.mjs → taxonomies-BOdxuZpV.mjs} +23 -13
- package/dist/taxonomies-BOdxuZpV.mjs.map +1 -0
- package/dist/{taxonomies-kmyudNGP.mjs → taxonomies-NcFDq5Gg.mjs} +58 -23
- package/dist/taxonomies-NcFDq5Gg.mjs.map +1 -0
- package/dist/{taxonomy-8X09dLN5.mjs → taxonomy-DP1vny4K.mjs} +12 -4
- package/dist/{taxonomy-8X09dLN5.mjs.map → taxonomy-DP1vny4K.mjs.map} +1 -1
- package/dist/{tokens-gTS-IVUp.mjs → tokens-CDk8ox9p.mjs} +1 -1
- package/dist/{tokens-gTS-IVUp.mjs.map → tokens-CDk8ox9p.mjs.map} +1 -1
- package/dist/{transport-_6R1ub7t.d.mts → transport-BVn4tVb9.d.mts} +1 -1
- package/dist/{transport-_6R1ub7t.d.mts.map → transport-BVn4tVb9.d.mts.map} +1 -1
- package/dist/{transport-fX59xaJz.mjs → transport-DP0JI-8i.mjs} +1 -1
- package/dist/{transport-fX59xaJz.mjs.map → transport-DP0JI-8i.mjs.map} +1 -1
- package/dist/{trusted-proxy-fe6nEgR4.mjs → trusted-proxy-BTM6UxqD.mjs} +1 -1
- package/dist/{trusted-proxy-fe6nEgR4.mjs.map → trusted-proxy-BTM6UxqD.mjs.map} +1 -1
- package/dist/{types-D_DWe7k9.d.mts → types-2n848aVW.d.mts} +3 -2
- package/dist/types-2n848aVW.d.mts.map +1 -0
- package/dist/types-A2cN6a4a.mjs +3 -0
- package/dist/{types-75KIqzL9.mjs → types-BMXnRIrX.mjs} +4 -2
- package/dist/types-BMXnRIrX.mjs.map +1 -0
- package/dist/{types-Vg6f5i3s.d.mts → types-BouXpOsa.d.mts} +121 -4
- package/dist/types-BouXpOsa.d.mts.map +1 -0
- package/dist/{types-BXUmsINL.mjs → types-ByG2coLw.mjs} +1 -1
- package/dist/{types-BXUmsINL.mjs.map → types-ByG2coLw.mjs.map} +1 -1
- package/dist/types-CQPWhPxE.mjs.map +1 -1
- package/dist/{types-Blb-MRC3.d.mts → types-DEfNJ__A.d.mts} +1 -1
- package/dist/{types-Blb-MRC3.d.mts.map → types-DEfNJ__A.d.mts.map} +1 -1
- package/dist/{types-Br-ERaxh.d.mts → types-DKcKSbtB.d.mts} +23 -7
- package/dist/types-DKcKSbtB.d.mts.map +1 -0
- package/dist/{types-BzBd3PeX.d.mts → types-DRYs7uTL.d.mts} +1 -1
- package/dist/{types-BzBd3PeX.d.mts.map → types-DRYs7uTL.d.mts.map} +1 -1
- package/dist/{types-CLqvnd05.d.mts → types-DaEg7KX2.d.mts} +1 -1
- package/dist/{types-CLqvnd05.d.mts.map → types-DaEg7KX2.d.mts.map} +1 -1
- package/dist/{types-DJQxln7q.d.mts → types-LU8utpP_.d.mts} +14 -10
- package/dist/types-LU8utpP_.d.mts.map +1 -0
- package/dist/{types-D5VVLr7J.d.mts → types-VpYfPUxN.d.mts} +1 -1
- package/dist/{types-D5VVLr7J.d.mts.map → types-VpYfPUxN.d.mts.map} +1 -1
- package/dist/{types-DM3vioBY.mjs → types-c9GP7Dj5.mjs} +1 -1
- package/dist/{types-DM3vioBY.mjs.map → types-c9GP7Dj5.mjs.map} +1 -1
- package/dist/{types-DHxzBjbD.d.mts → types-tJWDK__M.d.mts} +14 -1
- package/dist/types-tJWDK__M.d.mts.map +1 -0
- package/dist/{upload-attempts-CNyGSepg.mjs → upload-attempts-C6S2y-lp.mjs} +1 -1
- package/dist/{upload-attempts-CNyGSepg.mjs.map → upload-attempts-C6S2y-lp.mjs.map} +1 -1
- package/dist/{url-pattern-K-KdXcSe.mjs → url-pattern-UYtxVTuj.mjs} +1 -1
- package/dist/{url-pattern-K-KdXcSe.mjs.map → url-pattern-UYtxVTuj.mjs.map} +1 -1
- package/dist/{user-CtYY0tp2.mjs → user-DIsIXogT.mjs} +2 -2
- package/dist/{user-CtYY0tp2.mjs.map → user-DIsIXogT.mjs.map} +1 -1
- package/dist/{utils-HztC73hq.mjs → utils-BicP5Qbg.mjs} +2 -2
- package/dist/{utils-HztC73hq.mjs.map → utils-BicP5Qbg.mjs.map} +1 -1
- package/dist/{validate-Dd-IUjnZ.mjs → validate-D8VPn4Hv.mjs} +8 -3
- package/dist/validate-D8VPn4Hv.mjs.map +1 -0
- package/dist/{validate-DlqdOZXB.d.mts → validate-Df6Dvwbw.d.mts} +12 -7
- package/dist/validate-Df6Dvwbw.d.mts.map +1 -0
- package/dist/{validation-D83n7Npi.mjs → validation-CzMJn9Ku.mjs} +13 -11
- package/dist/{validation-D83n7Npi.mjs.map → validation-CzMJn9Ku.mjs.map} +1 -1
- package/dist/version-CK67_SXX.mjs +7 -0
- package/dist/{version-ri-sCyAp.mjs.map → version-CK67_SXX.mjs.map} +1 -1
- package/dist/{widgets-CpmZd9Q-.mjs → widgets-RFVAxQl3.mjs} +18 -5
- package/dist/widgets-RFVAxQl3.mjs.map +1 -0
- package/dist/{wxr-taxonomies-BFd0y72_.d.mts → wxr-taxonomies-BX4yQL9s.d.mts} +1 -1
- package/dist/{wxr-taxonomies-BFd0y72_.d.mts.map → wxr-taxonomies-BX4yQL9s.d.mts.map} +1 -1
- package/dist/{wxr-taxonomies-Df4vxWcU.mjs → wxr-taxonomies-Csdp7yde.mjs} +4 -4
- package/dist/{wxr-taxonomies-Df4vxWcU.mjs.map → wxr-taxonomies-Csdp7yde.mjs.map} +1 -1
- package/dist/{zod-generator-DylzusHh.mjs → zod-generator-CNRGdnBY.mjs} +11 -7
- package/dist/zod-generator-CNRGdnBY.mjs.map +1 -0
- package/package.json +16 -11
- package/src/api/errors.ts +9 -0
- package/src/api/handlers/content.ts +115 -90
- package/src/api/handlers/entry-lock.ts +206 -0
- package/src/api/handlers/index.ts +1 -0
- package/src/api/handlers/manifest.ts +162 -12
- package/src/api/handlers/marketplace.ts +28 -20
- package/src/api/handlers/media.ts +30 -0
- package/src/api/handlers/menus.ts +9 -0
- package/src/api/handlers/registry.ts +406 -297
- package/src/api/handlers/revision.ts +2 -1
- package/src/api/handlers/seo.ts +10 -1
- package/src/api/handlers/snapshot.ts +84 -72
- package/src/api/handlers/taxonomies.ts +25 -9
- package/src/api/openapi/document.ts +196 -11
- package/src/api/parse.ts +1 -1
- package/src/api/schemas/auth.ts +4 -4
- package/src/api/schemas/bylines.ts +3 -3
- package/src/api/schemas/comments.ts +1 -1
- package/src/api/schemas/common.ts +3 -2
- package/src/api/schemas/content.ts +86 -22
- package/src/api/schemas/entry-lock.ts +48 -0
- package/src/api/schemas/index.ts +1 -0
- package/src/api/schemas/media.ts +52 -0
- package/src/api/schemas/redirects.ts +6 -1
- package/src/api/schemas/schema.ts +14 -1
- package/src/api/schemas/setup.ts +1 -1
- package/src/api/schemas/taxonomies.ts +2 -2
- package/src/api/schemas/users.ts +1 -1
- package/src/api/types.ts +25 -10
- package/src/astro/dev-typegen.ts +35 -0
- package/src/astro/image-endpoint.ts +2 -2
- package/src/astro/integration/dev-typegen.ts +91 -0
- package/src/astro/integration/index.ts +18 -50
- package/src/astro/integration/routes.ts +10 -0
- package/src/astro/integration/runtime.ts +13 -5
- package/src/astro/integration/vite-config.ts +51 -2
- package/src/astro/middleware.ts +21 -0
- package/src/astro/routes/api/admin/api-tokens/index.ts +4 -1
- package/src/astro/routes/api/admin/oauth-clients/[id].ts +1 -1
- package/src/astro/routes/api/admin/oauth-clients/index.ts +1 -1
- package/src/astro/routes/api/admin/plugins/registry/[id]/update.ts +4 -0
- package/src/astro/routes/api/admin/plugins/registry/artifact.ts +3 -7
- package/src/astro/routes/api/admin/plugins/registry/install.ts +4 -0
- package/src/astro/routes/api/admin/plugins/registry/verify.ts +60 -0
- package/src/astro/routes/api/content/[collection]/[id]/discard-draft.ts +18 -2
- package/src/astro/routes/api/content/[collection]/[id]/lock.ts +133 -0
- package/src/astro/routes/api/content/[collection]/[id]/publish.ts +12 -1
- package/src/astro/routes/api/content/[collection]/[id]/schedule.ts +20 -0
- package/src/astro/routes/api/content/[collection]/[id]/unpublish.ts +16 -2
- package/src/astro/routes/api/content/[collection]/[id].ts +27 -2
- package/src/astro/routes/api/content/[collection]/index.ts +3 -0
- package/src/astro/routes/api/manifest.ts +1 -1
- package/src/astro/routes/api/media/[id]/replace.ts +114 -0
- package/src/astro/routes/api/media/file/[...key].ts +4 -1
- package/src/astro/routes/api/media/upload-url.ts +8 -4
- package/src/astro/routes/api/media.ts +54 -8
- package/src/astro/routes/api/menus/[name]/items/[id].ts +7 -2
- package/src/astro/routes/api/menus/[name]/items.ts +4 -1
- package/src/astro/routes/api/menus/[name]/reorder.ts +4 -1
- package/src/astro/routes/api/menus/[name]/translations.ts +4 -1
- package/src/astro/routes/api/menus/[name].ts +7 -2
- package/src/astro/routes/api/menus/index.ts +4 -1
- package/src/astro/routes/api/settings/email.ts +1 -1
- package/src/astro/routes/api/settings.ts +4 -1
- package/src/astro/routes/api/taxonomies/[name]/reorder.ts +4 -1
- package/src/astro/routes/api/taxonomies/[name]/terms/[slug]/translations.ts +4 -1
- package/src/astro/routes/api/taxonomies/[name]/terms/[slug].ts +7 -2
- package/src/astro/routes/api/taxonomies/[name]/terms/index.ts +4 -1
- package/src/astro/routes/api/taxonomies/[name].ts +7 -2
- package/src/astro/routes/api/taxonomies/index.ts +4 -1
- package/src/astro/routes/api/widget-areas/[name]/reorder.ts +3 -1
- package/src/astro/routes/api/widget-areas/[name]/widgets/[id].ts +5 -2
- package/src/astro/routes/api/widget-areas/[name]/widgets.ts +3 -1
- package/src/astro/routes/api/widget-areas/[name].ts +3 -1
- package/src/astro/routes/api/widget-areas/index.ts +3 -1
- package/src/astro/routes/sitemap-[collection].xml.ts +4 -0
- package/src/astro/types.ts +36 -8
- package/src/auth/challenge-store.ts +3 -1
- package/src/aws-sdk.d.ts +1 -0
- package/src/cache/chrome-tags.ts +24 -0
- package/src/cli/commands/content.ts +31 -5
- package/src/cli/commands/export-seed.ts +2 -0
- package/src/client/index.ts +34 -7
- package/src/components/EmDashBodyEnd.astro +4 -1
- package/src/components/EmDashBodyStart.astro +4 -1
- package/src/components/EmDashHead.astro +35 -16
- package/src/components/EmDashImage.astro +2 -1
- package/src/components/EmDashMedia.astro +2 -1
- package/src/components/Gallery.astro +18 -4
- package/src/components/InlineEditor.astro +3 -1
- package/src/components/InlinePortableTextEditor.tsx +112 -12
- package/src/components/PortableText.astro +4 -0
- package/src/components/Table.astro +147 -62
- package/src/components/widgets/Archives.astro +2 -37
- package/src/config/errors.ts +13 -0
- package/src/content/converters/index.ts +2 -0
- package/src/content/converters/mark-safety.ts +1 -0
- package/src/content/converters/portable-text-identity.ts +139 -0
- package/src/content/converters/portable-text-to-prosemirror.ts +226 -69
- package/src/content/converters/prosemirror-to-portable-text.ts +128 -28
- package/src/content/converters/types.ts +11 -0
- package/src/database/dialect-helpers.ts +125 -0
- package/src/database/migrations/017_authorization_codes.ts +14 -4
- package/src/database/migrations/074_content_deleted_scheduled_index.ts +55 -0
- package/src/database/migrations/075_entry_edit_locks.ts +44 -0
- package/src/database/migrations/076_collection_nav_group.ts +22 -0
- package/src/database/migrations/077_plugin_storage_revisions.ts +89 -0
- package/src/database/migrations/runner.ts +9 -1
- package/src/database/repositories/byline.ts +32 -16
- package/src/database/repositories/content.ts +284 -48
- package/src/database/repositories/entry-locks.ts +257 -0
- package/src/database/repositories/media-usage.ts +66 -37
- package/src/database/repositories/media.ts +60 -1
- package/src/database/repositories/options.ts +69 -5
- package/src/database/repositories/plugin-storage.ts +233 -9
- package/src/database/repositories/redirect.ts +17 -6
- package/src/database/repositories/taxonomy.ts +8 -0
- package/src/database/repositories/types.ts +11 -7
- package/src/database/types.ts +15 -1
- package/src/db/adapters.ts +8 -1
- package/src/db/postgres.ts +23 -0
- package/src/emdash-runtime.ts +196 -199
- package/src/fields/boolean.ts +1 -1
- package/src/fields/datetime.ts +1 -1
- package/src/fields/file.ts +1 -1
- package/src/fields/integer.ts +1 -1
- package/src/fields/json.ts +1 -1
- package/src/fields/multiselect.ts +1 -1
- package/src/fields/number.ts +1 -1
- package/src/fields/portable-text.ts +1 -1
- package/src/fields/richtext.ts +1 -1
- package/src/fields/select.ts +1 -1
- package/src/fields/slug.ts +1 -1
- package/src/fields/text.ts +1 -1
- package/src/fields/textarea.ts +1 -1
- package/src/fields/types.ts +2 -2
- package/src/i18n/resolve.ts +44 -4
- package/src/index.ts +39 -3
- package/src/loader.ts +96 -12
- package/src/mcp/server.ts +251 -29
- package/src/media/image-endpoint.ts +5 -2
- package/src/media/normalize.ts +15 -4
- package/src/media/responsive.ts +23 -0
- package/src/media/usage/cleanup.ts +9 -8
- package/src/media/usage/content-refresh.ts +2 -1
- package/src/menus/index.ts +33 -21
- package/src/object-cache/index.ts +44 -2
- package/src/page/seo-contributions.ts +78 -1
- package/src/page/seo-panel.ts +47 -0
- package/src/plugin-types.ts +27 -1
- package/src/plugins/conditional-storage.ts +30 -0
- package/src/plugins/context.ts +49 -17
- package/src/plugins/hooks.ts +10 -1
- package/src/plugins/index.ts +15 -0
- package/src/plugins/manager.ts +6 -2
- package/src/plugins/manifest-schema.ts +1 -1
- package/src/plugins/routes.ts +3 -1
- package/src/plugins/sandbox/hook-result.ts +52 -0
- package/src/plugins/sandbox/index.ts +10 -0
- package/src/plugins/sandbox/types.ts +16 -2
- package/src/plugins/storage-query.ts +45 -0
- package/src/plugins/storage-update.ts +96 -0
- package/src/plugins/types.ts +120 -0
- package/src/query.ts +29 -3
- package/src/registry/artifact-checksum.ts +15 -0
- package/src/registry/artifact-verification.ts +85 -0
- package/src/registry/authoritative-records.ts +180 -0
- package/src/registry/config.ts +130 -27
- package/src/registry/record-labels.ts +28 -0
- package/src/registry/types.ts +5 -6
- package/src/schema/collection-slugs-cache.ts +157 -0
- package/src/schema/registry.ts +45 -3
- package/src/schema/types.ts +25 -6
- package/src/schema/zod-generator.ts +16 -13
- package/src/security/ssrf.ts +172 -143
- package/src/seed/apply.ts +4 -0
- package/src/seed/types.ts +7 -2
- package/src/seed/validate.ts +18 -1
- package/src/seo/hreflang.ts +1 -0
- package/src/seo/index.ts +5 -10
- package/src/seo/media-url.ts +26 -0
- package/src/settings/index.ts +16 -0
- package/src/storage/local.ts +1 -0
- package/src/storage/s3.ts +2 -0
- package/src/storage/types.ts +2 -0
- package/src/taxonomies/index.ts +40 -20
- package/src/taxonomies/term-counts.ts +22 -5
- package/src/widgets/archives.ts +67 -0
- package/src/widgets/index.ts +16 -0
- package/dist/api-B0w3uBiG.mjs +0 -2269
- package/dist/api-B0w3uBiG.mjs.map +0 -1
- package/dist/apply-B_VMpJ2P.mjs.map +0 -1
- package/dist/byline-Cpnwrje1.mjs.map +0 -1
- package/dist/challenge-store-D5pSY2S1.mjs.map +0 -1
- package/dist/content-CP-SeXNa.mjs.map +0 -1
- package/dist/content-refresh-DLOfIhYc.mjs.map +0 -1
- package/dist/context-BR5hRWiK.mjs.map +0 -1
- package/dist/dialect-helpers-BSbfaO3F.mjs.map +0 -1
- package/dist/errors-n2j49uNf.mjs.map +0 -1
- package/dist/index-DWbJrsAg.d.mts.map +0 -1
- package/dist/loader-ZsjE4paL.mjs.map +0 -1
- package/dist/manifest-schema-CUYPfCEH.mjs.map +0 -1
- package/dist/media-BjwNuLEu.mjs.map +0 -1
- package/dist/media-D6SeAfBl.mjs.map +0 -1
- package/dist/media-url-DH7giMx_.mjs.map +0 -1
- package/dist/menus-CNg0QlDt.mjs.map +0 -1
- package/dist/normalize-CSxdKBVa.mjs.map +0 -1
- package/dist/object-cache-71tPfV4A.mjs.map +0 -1
- package/dist/options-BHPeIbBd.mjs.map +0 -1
- package/dist/options-BhZIeFY1.d.mts.map +0 -1
- package/dist/query-D18vTdha.mjs.map +0 -1
- package/dist/redirect-CZkbozu9.mjs.map +0 -1
- package/dist/redirects-CRIM55KH.mjs.map +0 -1
- package/dist/registry-BiO5WwPq.mjs +0 -2716
- package/dist/registry-BiO5WwPq.mjs.map +0 -1
- package/dist/registry-Cx-jEJOS.mjs.map +0 -1
- package/dist/relations-BTPM2saV.mjs.map +0 -1
- package/dist/relations-C7B46bcU.d.mts.map +0 -1
- package/dist/resolve-DxUpTMmE.mjs.map +0 -1
- package/dist/runner-77GOZCnH.mjs.map +0 -1
- package/dist/runner-zgqA_CqP.d.mts.map +0 -1
- package/dist/seo-BSiTIXzd.mjs.map +0 -1
- package/dist/settings-BgN-0DT-.mjs.map +0 -1
- package/dist/snapshot-DSB8P7Lm.mjs.map +0 -1
- package/dist/ssrf-DqebVE34.mjs.map +0 -1
- package/dist/taxonomies-CPGxo-bn.mjs.map +0 -1
- package/dist/taxonomies-kmyudNGP.mjs.map +0 -1
- package/dist/types-75KIqzL9.mjs.map +0 -1
- package/dist/types-Br-ERaxh.d.mts.map +0 -1
- package/dist/types-D6OcIp2P.mjs +0 -3
- package/dist/types-DHxzBjbD.d.mts.map +0 -1
- package/dist/types-DJQxln7q.d.mts.map +0 -1
- package/dist/types-D_DWe7k9.d.mts.map +0 -1
- package/dist/types-Vg6f5i3s.d.mts.map +0 -1
- package/dist/validate-Dd-IUjnZ.mjs.map +0 -1
- package/dist/validate-DlqdOZXB.d.mts.map +0 -1
- package/dist/version-ri-sCyAp.mjs +0 -7
- package/dist/widgets-CpmZd9Q-.mjs.map +0 -1
- package/dist/zod-generator-DylzusHh.mjs.map +0 -1
- /package/dist/{api-tokens-B5NHLNUN.mjs → api-tokens-B_lfpmH3.mjs} +0 -0
- /package/dist/{ssrf-BPKzkm6O.mjs → ssrf-TQhaljuI.mjs} +0 -0
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import "../../../../../dialect-helpers-BcQvkHgn.mjs";
|
|
1
2
|
import "../../../../../config-C3EBstHi.mjs";
|
|
2
3
|
import "../../../../../base64-CvLhUKQv.mjs";
|
|
3
4
|
import "../../../../../types-CQPWhPxE.mjs";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import "../../../../../
|
|
8
|
-
import
|
|
9
|
-
import "../../../../../
|
|
10
|
-
import "../../../../../
|
|
5
|
+
import "../../../../../entry-locks-BEcX7ET0.mjs";
|
|
6
|
+
import { n as mapErrorStatus } from "../../../../../errors-DvMdNrgf.mjs";
|
|
7
|
+
import { a as unwrapResult, t as apiError } from "../../../../../error-BDcFyoRt.mjs";
|
|
8
|
+
import { n as parseBody, t as isParseError } from "../../../../../parse-WRg5C3NX.mjs";
|
|
9
|
+
import "../../../../../media-C1EIZKh1.mjs";
|
|
10
|
+
import { _n as contentUpdateBody } from "../../../../../entry-lock-DIYHAaSw.mjs";
|
|
11
|
+
import "../../../../../relations-rOmbndUJ.mjs";
|
|
12
|
+
import "../../../../../status-Cenfk_r5.mjs";
|
|
11
13
|
import "../../../../../api/schemas/index.mjs";
|
|
12
|
-
import { n as requireOwnerPerm, r as requirePerm } from "../../../../../authorize-
|
|
14
|
+
import { n as requireOwnerPerm, r as requirePerm } from "../../../../../authorize-C2QHlWSS.mjs";
|
|
15
|
+
import { t as claimEntryLockForWrite } from "../../../../../entry-lock-BEr8gDkG.mjs";
|
|
13
16
|
import { hasPermission } from "@emdash-cms/auth";
|
|
14
17
|
|
|
15
18
|
//#region src/astro/routes/api/content/[collection]/[id].ts
|
|
@@ -58,14 +61,21 @@ const PUT = async ({ params, request, locals, cache }) => {
|
|
|
58
61
|
if (editDenied) return editDenied;
|
|
59
62
|
if (body.publishedAt !== void 0 && !hasPermission(user, "content:publish_any")) return apiError("FORBIDDEN", "Writing publishedAt requires content:publish_any permission", 403);
|
|
60
63
|
const resolvedId = typeof existingItem?.id === "string" ? existingItem.id : id;
|
|
61
|
-
const
|
|
64
|
+
const refusal = await claimEntryLockForWrite(emdash.db, collection, resolvedId, user.id, { override: body.overrideLock });
|
|
65
|
+
if (refusal) return apiError(refusal.code, refusal.message, mapErrorStatus(refusal.code), { ...refusal.details });
|
|
66
|
+
const { overrideLock: _overrideLock, ...writeBody } = body.authorId !== void 0 && user && hasPermission(user, "content:edit_any") ? body : {
|
|
62
67
|
...body,
|
|
63
68
|
authorId: void 0
|
|
64
69
|
};
|
|
70
|
+
const actor = user ? {
|
|
71
|
+
id: user.id,
|
|
72
|
+
role: user.role
|
|
73
|
+
} : void 0;
|
|
65
74
|
const result = await emdash.handleContentUpdate(collection, resolvedId, {
|
|
66
|
-
...
|
|
75
|
+
...writeBody,
|
|
67
76
|
locale,
|
|
68
|
-
_rev: body._rev
|
|
77
|
+
_rev: body._rev,
|
|
78
|
+
actor
|
|
69
79
|
});
|
|
70
80
|
if (!result.success) return unwrapResult(result);
|
|
71
81
|
if (cache?.enabled && result.liveContentChanged !== false) await cache.invalidate({ tags: [collection, resolvedId] });
|
|
@@ -84,6 +94,8 @@ const DELETE = async ({ params, locals, url, cache }) => {
|
|
|
84
94
|
const deleteDenied = requireOwnerPerm(user, typeof deleteItem?.authorId === "string" ? deleteItem.authorId : "", "content:delete_own", "content:delete_any");
|
|
85
95
|
if (deleteDenied) return deleteDenied;
|
|
86
96
|
const resolvedId = typeof deleteItem?.id === "string" ? deleteItem.id : id;
|
|
97
|
+
const refusal = await claimEntryLockForWrite(emdash.db, collection, resolvedId, user.id, { override: url.searchParams.get("overrideLock") === "true" });
|
|
98
|
+
if (refusal) return apiError(refusal.code, refusal.message, mapErrorStatus(refusal.code), { ...refusal.details });
|
|
87
99
|
const result = await emdash.handleContentDelete(collection, resolvedId);
|
|
88
100
|
if (!result.success) return unwrapResult(result);
|
|
89
101
|
if (cache?.enabled) await cache.invalidate({ tags: [collection, resolvedId] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_id_.mjs","names":[],"sources":["../../../../../../src/astro/routes/api/content/[collection]/[id].ts"],"sourcesContent":["/**\n * Single content item endpoints - injected by EmDash integration\n *\n * GET /_emdash/api/content/{collection}/{id} - Get content\n * PUT /_emdash/api/content/{collection}/{id} - Update content\n * DELETE /_emdash/api/content/{collection}/{id} - Delete content\n */\n\nimport { hasPermission } from \"@emdash-cms/auth\";\nimport type { APIRoute } from \"astro\";\n\nimport { requirePerm, requireOwnerPerm } from \"#api/authorize.js\";\nimport { apiError, mapErrorStatus, unwrapResult } from \"#api/error.js\";\nimport { parseBody, isParseError } from \"#api/parse.js\";\nimport { contentUpdateBody } from \"#api/schemas.js\";\n\nexport const prerender = false;\n\nexport const GET: APIRoute = async ({ params, url, locals }) => {\n\tconst { emdash, user } = locals;\n\tif (!emdash?.handleContentGet) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\tconst denied = requirePerm(user, \"content:read\");\n\tif (denied) return denied;\n\tconst collection = params.collection!;\n\tconst id = params.id!;\n\tconst locale = url.searchParams.get(\"locale\") || undefined;\n\n\tconst result = await emdash.handleContentGet(collection, id, locale);\n\n\t// Hide non-published items from users without content:read_drafts. Return\n\t// 404 (not 403) so subscribers can't enumerate draft IDs by status code.\n\tif (result.success && !hasPermission(user, \"content:read_drafts\")) {\n\t\tconst data =\n\t\t\tresult.data && typeof result.data === \"object\"\n\t\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler returns unknown data; narrowed by typeof check\n\t\t\t\t\t(result.data as Record<string, unknown>)\n\t\t\t\t: undefined;\n\t\tconst item =\n\t\t\tdata?.item && typeof data.item === \"object\"\n\t\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed by typeof check\n\t\t\t\t\t(data.item as Record<string, unknown>)\n\t\t\t\t: undefined;\n\t\tconst status = typeof item?.status === \"string\" ? item.status : null;\n\t\tif (status !== \"published\") {\n\t\t\treturn apiError(\"NOT_FOUND\", `Content item not found: ${id}`, 404);\n\t\t}\n\n\t\t// Strip draft hydration data from response for users without read_drafts.\n\t\t// handleContentGet overlays draft revision data onto item.data and exposes\n\t\t// the published values in item.liveData. Without this, subscribers see\n\t\t// unpublished edits in the data field.\n\t\tif (item) {\n\t\t\tif (item.liveData && typeof item.liveData === \"object\") {\n\t\t\t\titem.data = item.liveData;\n\t\t\t}\n\t\t\tdelete item.liveData;\n\t\t\tdelete item.draftRevisionId;\n\t\t}\n\t}\n\n\treturn unwrapResult(result);\n};\n\nexport const PUT: APIRoute = async ({ params, request, locals, cache }) => {\n\tconst { emdash, user } = locals;\n\tconst collection = params.collection!;\n\tconst id = params.id!;\n\tconst locale = new URL(request.url).searchParams.get(\"locale\") || undefined;\n\tconst body = await parseBody(request, contentUpdateBody);\n\tif (isParseError(body)) return body;\n\n\tif (!emdash?.handleContentUpdate || !emdash?.handleContentGet) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\n\t// Fetch item to check ownership\n\tconst existing = await emdash.handleContentGet(collection, id, locale);\n\tif (!existing.success) {\n\t\treturn apiError(\n\t\t\texisting.error?.code ?? \"UNKNOWN_ERROR\",\n\t\t\texisting.error?.message ?? \"Unknown error\",\n\t\t\tmapErrorStatus(existing.error?.code),\n\t\t);\n\t}\n\n\tconst existingData =\n\t\texisting.data && typeof existing.data === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler returns unknown data; narrowed by typeof check above\n\t\t\t\t(existing.data as Record<string, unknown>)\n\t\t\t: undefined;\n\t// Handler returns { item, _rev } — extract the item for ownership and ID resolution\n\tconst existingItem =\n\t\texistingData?.item && typeof existingData.item === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed by typeof check above\n\t\t\t\t(existingData.item as Record<string, unknown>)\n\t\t\t: existingData;\n\tconst authorId = typeof existingItem?.authorId === \"string\" ? existingItem.authorId : \"\";\n\tconst editDenied = requireOwnerPerm(user, authorId, \"content:edit_own\", \"content:edit_any\");\n\tif (editDenied) return editDenied;\n\n\t// Only EDITOR+ can write publishedAt directly — incl. clearing to null.\n\tif (body.publishedAt !== undefined && !hasPermission(user, \"content:publish_any\")) {\n\t\treturn apiError(\n\t\t\t\"FORBIDDEN\",\n\t\t\t\"Writing publishedAt requires content:publish_any permission\",\n\t\t\t403,\n\t\t);\n\t}\n\n\t// Use the resolved ID (handles slug → ID resolution)\n\tconst resolvedId = typeof existingItem?.id === \"string\" ? existingItem.id : id;\n\n\t// Only allow authorId changes if user has content:edit_any permission (editor+)\n\tconst canChangeAuthor =\n\t\tbody.authorId !== undefined && user && hasPermission(user, \"content:edit_any\");\n\tconst updateBody = canChangeAuthor ? body : { ...body, authorId: undefined };\n\n\t// Pass _rev through for optimistic concurrency validation\n\tconst result = await emdash.handleContentUpdate(collection, resolvedId, {\n\t\t...updateBody,\n\t\tlocale,\n\t\t_rev: body._rev,\n\t});\n\n\tif (!result.success) return unwrapResult(result);\n\n\tif (cache?.enabled && result.liveContentChanged !== false) {\n\t\tawait cache.invalidate({ tags: [collection, resolvedId] });\n\t}\n\n\treturn unwrapResult(result);\n};\n\nexport const DELETE: APIRoute = async ({ params, locals, url, cache }) => {\n\tconst { emdash, user } = locals;\n\tconst collection = params.collection!;\n\tconst id = params.id!;\n\n\tif (!emdash?.handleContentDelete || !emdash?.handleContentGet) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\n\tconst locale = url.searchParams.get(\"locale\") || undefined;\n\n\t// Fetch item to check ownership\n\tconst existing = await emdash.handleContentGet(collection, id, locale);\n\tif (!existing.success) {\n\t\treturn apiError(\n\t\t\texisting.error?.code ?? \"UNKNOWN_ERROR\",\n\t\t\texisting.error?.message ?? \"Unknown error\",\n\t\t\tmapErrorStatus(existing.error?.code),\n\t\t);\n\t}\n\n\tconst deleteData =\n\t\texisting.data && typeof existing.data === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler returns unknown data; narrowed by typeof check above\n\t\t\t\t(existing.data as Record<string, unknown>)\n\t\t\t: undefined;\n\t// Handler returns { item, _rev } — extract the item for ownership and ID resolution\n\tconst deleteItem =\n\t\tdeleteData?.item && typeof deleteData.item === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed by typeof check above\n\t\t\t\t(deleteData.item as Record<string, unknown>)\n\t\t\t: deleteData;\n\tconst authorId = typeof deleteItem?.authorId === \"string\" ? deleteItem.authorId : \"\";\n\tconst deleteDenied = requireOwnerPerm(user, authorId, \"content:delete_own\", \"content:delete_any\");\n\tif (deleteDenied) return deleteDenied;\n\n\t// Use the resolved ID (handles slug → ID resolution)\n\tconst resolvedId = typeof deleteItem?.id === \"string\" ? deleteItem.id : id;\n\n\tconst result = await emdash.handleContentDelete(collection, resolvedId);\n\n\tif (!result.success) return unwrapResult(result);\n\n\tif (cache?.enabled) await cache.invalidate({ tags: [collection, resolvedId] });\n\n\treturn unwrapResult(result);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAa,YAAY;AAEzB,MAAa,MAAgB,OAAO,EAAE,QAAQ,KAAK,aAAa;CAC/D,MAAM,EAAE,QAAQ,SAAS;AACzB,KAAI,CAAC,QAAQ,iBACZ,QAAO,SAAS,kBAAkB,6BAA6B,IAAI;CAEpE,MAAM,SAAS,YAAY,MAAM,eAAe;AAChD,KAAI,OAAQ,QAAO;CACnB,MAAM,aAAa,OAAO;CAC1B,MAAM,KAAK,OAAO;CAClB,MAAM,SAAS,IAAI,aAAa,IAAI,SAAS,IAAI;CAEjD,MAAM,SAAS,MAAM,OAAO,iBAAiB,YAAY,IAAI,OAAO;AAIpE,KAAI,OAAO,WAAW,CAAC,cAAc,MAAM,sBAAsB,EAAE;EAClE,MAAM,OACL,OAAO,QAAQ,OAAO,OAAO,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AAS,MAAM,OAAO,oBAAoB,YAAY,WAAW;AAEvE,KAAI,CAAC,OAAO,QAAS,QAAO,aAAa,OAAO;AAEhD,KAAI,OAAO,QAAS,OAAM,MAAM,WAAW,EAAE,MAAM,CAAC,YAAY,WAAW,EAAE,CAAC;AAE9E,QAAO,aAAa,OAAO"}
|
|
1
|
+
{"version":3,"file":"_id_.mjs","names":[],"sources":["../../../../../../src/astro/routes/api/content/[collection]/[id].ts"],"sourcesContent":["/**\n * Single content item endpoints - injected by EmDash integration\n *\n * GET /_emdash/api/content/{collection}/{id} - Get content\n * PUT /_emdash/api/content/{collection}/{id} - Update content\n * DELETE /_emdash/api/content/{collection}/{id} - Delete content\n */\n\nimport { hasPermission } from \"@emdash-cms/auth\";\nimport type { APIRoute } from \"astro\";\n\nimport { requirePerm, requireOwnerPerm } from \"#api/authorize.js\";\nimport { apiError, mapErrorStatus, unwrapResult } from \"#api/error.js\";\nimport { claimEntryLockForWrite } from \"#api/handlers/entry-lock.js\";\nimport { parseBody, isParseError } from \"#api/parse.js\";\nimport { contentUpdateBody } from \"#api/schemas.js\";\n\nexport const prerender = false;\n\nexport const GET: APIRoute = async ({ params, url, locals }) => {\n\tconst { emdash, user } = locals;\n\tif (!emdash?.handleContentGet) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\tconst denied = requirePerm(user, \"content:read\");\n\tif (denied) return denied;\n\tconst collection = params.collection!;\n\tconst id = params.id!;\n\tconst locale = url.searchParams.get(\"locale\") || undefined;\n\n\tconst result = await emdash.handleContentGet(collection, id, locale);\n\n\t// Hide non-published items from users without content:read_drafts. Return\n\t// 404 (not 403) so subscribers can't enumerate draft IDs by status code.\n\tif (result.success && !hasPermission(user, \"content:read_drafts\")) {\n\t\tconst data =\n\t\t\tresult.data && typeof result.data === \"object\"\n\t\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler returns unknown data; narrowed by typeof check\n\t\t\t\t\t(result.data as Record<string, unknown>)\n\t\t\t\t: undefined;\n\t\tconst item =\n\t\t\tdata?.item && typeof data.item === \"object\"\n\t\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed by typeof check\n\t\t\t\t\t(data.item as Record<string, unknown>)\n\t\t\t\t: undefined;\n\t\tconst status = typeof item?.status === \"string\" ? item.status : null;\n\t\tif (status !== \"published\") {\n\t\t\treturn apiError(\"NOT_FOUND\", `Content item not found: ${id}`, 404);\n\t\t}\n\n\t\t// Strip draft hydration data from response for users without read_drafts.\n\t\t// handleContentGet overlays draft revision data onto item.data and exposes\n\t\t// the published values in item.liveData. Without this, subscribers see\n\t\t// unpublished edits in the data field.\n\t\tif (item) {\n\t\t\tif (item.liveData && typeof item.liveData === \"object\") {\n\t\t\t\titem.data = item.liveData;\n\t\t\t}\n\t\t\tdelete item.liveData;\n\t\t\tdelete item.draftRevisionId;\n\t\t}\n\t}\n\n\treturn unwrapResult(result);\n};\n\nexport const PUT: APIRoute = async ({ params, request, locals, cache }) => {\n\tconst { emdash, user } = locals;\n\tconst collection = params.collection!;\n\tconst id = params.id!;\n\tconst locale = new URL(request.url).searchParams.get(\"locale\") || undefined;\n\tconst body = await parseBody(request, contentUpdateBody);\n\tif (isParseError(body)) return body;\n\n\tif (!emdash?.handleContentUpdate || !emdash?.handleContentGet) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\n\t// Fetch item to check ownership\n\tconst existing = await emdash.handleContentGet(collection, id, locale);\n\tif (!existing.success) {\n\t\treturn apiError(\n\t\t\texisting.error?.code ?? \"UNKNOWN_ERROR\",\n\t\t\texisting.error?.message ?? \"Unknown error\",\n\t\t\tmapErrorStatus(existing.error?.code),\n\t\t);\n\t}\n\n\tconst existingData =\n\t\texisting.data && typeof existing.data === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler returns unknown data; narrowed by typeof check above\n\t\t\t\t(existing.data as Record<string, unknown>)\n\t\t\t: undefined;\n\t// Handler returns { item, _rev } — extract the item for ownership and ID resolution\n\tconst existingItem =\n\t\texistingData?.item && typeof existingData.item === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed by typeof check above\n\t\t\t\t(existingData.item as Record<string, unknown>)\n\t\t\t: existingData;\n\tconst authorId = typeof existingItem?.authorId === \"string\" ? existingItem.authorId : \"\";\n\tconst editDenied = requireOwnerPerm(user, authorId, \"content:edit_own\", \"content:edit_any\");\n\tif (editDenied) return editDenied;\n\n\t// Only EDITOR+ can write publishedAt directly — incl. clearing to null.\n\tif (body.publishedAt !== undefined && !hasPermission(user, \"content:publish_any\")) {\n\t\treturn apiError(\n\t\t\t\"FORBIDDEN\",\n\t\t\t\"Writing publishedAt requires content:publish_any permission\",\n\t\t\t403,\n\t\t);\n\t}\n\n\t// Use the resolved ID (handles slug → ID resolution)\n\tconst resolvedId = typeof existingItem?.id === \"string\" ? existingItem.id : id;\n\n\tconst refusal = await claimEntryLockForWrite(emdash.db, collection, resolvedId, user!.id, {\n\t\toverride: body.overrideLock,\n\t});\n\tif (refusal) {\n\t\treturn apiError(refusal.code, refusal.message, mapErrorStatus(refusal.code), {\n\t\t\t...refusal.details,\n\t\t});\n\t}\n\n\t// Only allow authorId changes if user has content:edit_any permission (editor+)\n\tconst canChangeAuthor =\n\t\tbody.authorId !== undefined && user && hasPermission(user, \"content:edit_any\");\n\tconst { overrideLock: _overrideLock, ...writeBody } = canChangeAuthor\n\t\t? body\n\t\t: { ...body, authorId: undefined };\n\n\tconst actor = user ? { id: user.id, role: user.role } : undefined;\n\n\t// Pass _rev through for optimistic concurrency validation\n\tconst result = await emdash.handleContentUpdate(collection, resolvedId, {\n\t\t...writeBody,\n\t\tlocale,\n\t\t_rev: body._rev,\n\t\tactor,\n\t});\n\n\tif (!result.success) return unwrapResult(result);\n\n\tif (cache?.enabled && result.liveContentChanged !== false) {\n\t\tawait cache.invalidate({ tags: [collection, resolvedId] });\n\t}\n\n\treturn unwrapResult(result);\n};\n\nexport const DELETE: APIRoute = async ({ params, locals, url, cache }) => {\n\tconst { emdash, user } = locals;\n\tconst collection = params.collection!;\n\tconst id = params.id!;\n\n\tif (!emdash?.handleContentDelete || !emdash?.handleContentGet) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\n\tconst locale = url.searchParams.get(\"locale\") || undefined;\n\n\t// Fetch item to check ownership\n\tconst existing = await emdash.handleContentGet(collection, id, locale);\n\tif (!existing.success) {\n\t\treturn apiError(\n\t\t\texisting.error?.code ?? \"UNKNOWN_ERROR\",\n\t\t\texisting.error?.message ?? \"Unknown error\",\n\t\t\tmapErrorStatus(existing.error?.code),\n\t\t);\n\t}\n\n\tconst deleteData =\n\t\texisting.data && typeof existing.data === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler returns unknown data; narrowed by typeof check above\n\t\t\t\t(existing.data as Record<string, unknown>)\n\t\t\t: undefined;\n\t// Handler returns { item, _rev } — extract the item for ownership and ID resolution\n\tconst deleteItem =\n\t\tdeleteData?.item && typeof deleteData.item === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed by typeof check above\n\t\t\t\t(deleteData.item as Record<string, unknown>)\n\t\t\t: deleteData;\n\tconst authorId = typeof deleteItem?.authorId === \"string\" ? deleteItem.authorId : \"\";\n\tconst deleteDenied = requireOwnerPerm(user, authorId, \"content:delete_own\", \"content:delete_any\");\n\tif (deleteDenied) return deleteDenied;\n\n\t// Use the resolved ID (handles slug → ID resolution)\n\tconst resolvedId = typeof deleteItem?.id === \"string\" ? deleteItem.id : id;\n\n\t// DELETE carries no body, so the lock opt-out rides on the query string.\n\tconst refusal = await claimEntryLockForWrite(emdash.db, collection, resolvedId, user!.id, {\n\t\toverride: url.searchParams.get(\"overrideLock\") === \"true\",\n\t});\n\tif (refusal) {\n\t\treturn apiError(refusal.code, refusal.message, mapErrorStatus(refusal.code), {\n\t\t\t...refusal.details,\n\t\t});\n\t}\n\n\tconst result = await emdash.handleContentDelete(collection, resolvedId);\n\n\tif (!result.success) return unwrapResult(result);\n\n\tif (cache?.enabled) await cache.invalidate({ tags: [collection, resolvedId] });\n\n\treturn unwrapResult(result);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAa,YAAY;AAEzB,MAAa,MAAgB,OAAO,EAAE,QAAQ,KAAK,aAAa;CAC/D,MAAM,EAAE,QAAQ,SAAS;AACzB,KAAI,CAAC,QAAQ,iBACZ,QAAO,SAAS,kBAAkB,6BAA6B,IAAI;CAEpE,MAAM,SAAS,YAAY,MAAM,eAAe;AAChD,KAAI,OAAQ,QAAO;CACnB,MAAM,aAAa,OAAO;CAC1B,MAAM,KAAK,OAAO;CAClB,MAAM,SAAS,IAAI,aAAa,IAAI,SAAS,IAAI;CAEjD,MAAM,SAAS,MAAM,OAAO,iBAAiB,YAAY,IAAI,OAAO;AAIpE,KAAI,OAAO,WAAW,CAAC,cAAc,MAAM,sBAAsB,EAAE;EAClE,MAAM,OACL,OAAO,QAAQ,OAAO,OAAO,SAAS,WAEnC,OAAO,OACP;EACJ,MAAM,OACL,MAAM,QAAQ,OAAO,KAAK,SAAS,WAEhC,KAAK,OACL;AAEJ,OADe,OAAO,MAAM,WAAW,WAAW,KAAK,SAAS,UACjD,YACd,QAAO,SAAS,aAAa,2BAA2B,MAAM,IAAI;AAOnE,MAAI,MAAM;AACT,OAAI,KAAK,YAAY,OAAO,KAAK,aAAa,SAC7C,MAAK,OAAO,KAAK;AAElB,UAAO,KAAK;AACZ,UAAO,KAAK;;;AAId,QAAO,aAAa,OAAO;;AAG5B,MAAa,MAAgB,OAAO,EAAE,QAAQ,SAAS,QAAQ,YAAY;CAC1E,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,aAAa,OAAO;CAC1B,MAAM,KAAK,OAAO;CAClB,MAAM,SAAS,IAAI,IAAI,QAAQ,IAAI,CAAC,aAAa,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;CAGH,MAAM,SAAS,MAAM,OAAO,oBAAoB,YAAY,WAAW;AAEvE,KAAI,CAAC,OAAO,QAAS,QAAO,aAAa,OAAO;AAEhD,KAAI,OAAO,QAAS,OAAM,MAAM,WAAW,EAAE,MAAM,CAAC,YAAY,WAAW,EAAE,CAAC;AAE9E,QAAO,aAAa,OAAO"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../../../../../base64-CvLhUKQv.mjs";
|
|
2
2
|
import "../../../../../types-CQPWhPxE.mjs";
|
|
3
|
-
import { a as unwrapResult, t as apiError } from "../../../../../error-
|
|
4
|
-
import { r as requirePerm } from "../../../../../authorize-
|
|
3
|
+
import { a as unwrapResult, t as apiError } from "../../../../../error-BDcFyoRt.mjs";
|
|
4
|
+
import { r as requirePerm } from "../../../../../authorize-C2QHlWSS.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/astro/routes/api/content/[collection]/authors.ts
|
|
7
7
|
const prerender = false;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import "../../../../../config-C3EBstHi.mjs";
|
|
2
2
|
import "../../../../../base64-CvLhUKQv.mjs";
|
|
3
3
|
import "../../../../../types-CQPWhPxE.mjs";
|
|
4
|
-
import { n as mapErrorStatus } from "../../../../../errors-
|
|
5
|
-
import { a as unwrapResult, t as apiError } from "../../../../../error-
|
|
6
|
-
import { i as parseQuery, n as parseBody, t as isParseError } from "../../../../../parse-
|
|
7
|
-
import "../../../../../media-
|
|
8
|
-
import {
|
|
9
|
-
import "../../../../../relations-
|
|
10
|
-
import "../../../../../status-
|
|
4
|
+
import { n as mapErrorStatus } from "../../../../../errors-DvMdNrgf.mjs";
|
|
5
|
+
import { a as unwrapResult, t as apiError } from "../../../../../error-BDcFyoRt.mjs";
|
|
6
|
+
import { i as parseQuery, n as parseBody, t as isParseError } from "../../../../../parse-WRg5C3NX.mjs";
|
|
7
|
+
import "../../../../../media-C1EIZKh1.mjs";
|
|
8
|
+
import { en as contentCreateBody, rn as contentListQuery } from "../../../../../entry-lock-DIYHAaSw.mjs";
|
|
9
|
+
import "../../../../../relations-rOmbndUJ.mjs";
|
|
10
|
+
import "../../../../../status-Cenfk_r5.mjs";
|
|
11
11
|
import "../../../../../api/schemas/index.mjs";
|
|
12
|
-
import { n as requireOwnerPerm, r as requirePerm } from "../../../../../authorize-
|
|
12
|
+
import { n as requireOwnerPerm, r as requirePerm } from "../../../../../authorize-C2QHlWSS.mjs";
|
|
13
13
|
import { hasPermission } from "@emdash-cms/auth";
|
|
14
14
|
|
|
15
15
|
//#region src/astro/routes/api/content/[collection]/index.ts
|
|
@@ -49,11 +49,16 @@ const POST = async ({ params, request, locals, cache }) => {
|
|
|
49
49
|
if (translationDenied) return translationDenied;
|
|
50
50
|
}
|
|
51
51
|
if ((body.publishedAt !== void 0 || body.createdAt !== void 0) && !hasPermission(user, "content:publish_any")) return apiError("FORBIDDEN", "Writing publishedAt or createdAt requires content:publish_any permission", 403);
|
|
52
|
+
const actor = user ? {
|
|
53
|
+
id: user.id,
|
|
54
|
+
role: user.role
|
|
55
|
+
} : void 0;
|
|
52
56
|
const result = await emdash.handleContentCreate(collection, {
|
|
53
57
|
...body,
|
|
54
58
|
authorId: user?.id,
|
|
55
59
|
locale: body.locale,
|
|
56
|
-
translationOf: body.translationOf
|
|
60
|
+
translationOf: body.translationOf,
|
|
61
|
+
actor
|
|
57
62
|
});
|
|
58
63
|
if (!result.success) return unwrapResult(result);
|
|
59
64
|
if (cache?.enabled) await cache.invalidate({ tags: [collection] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../src/astro/routes/api/content/[collection]/index.ts"],"sourcesContent":["/**\n * Content list and create endpoints - injected by EmDash integration\n *\n * GET /_emdash/api/content/{collection} - List content\n * POST /_emdash/api/content/{collection} - Create content\n */\n\nimport { hasPermission } from \"@emdash-cms/auth\";\nimport type { APIRoute } from \"astro\";\n\nimport { requirePerm, requireOwnerPerm } from \"#api/authorize.js\";\nimport { apiError, mapErrorStatus, unwrapResult } from \"#api/error.js\";\nimport { parseBody, parseQuery, isParseError } from \"#api/parse.js\";\nimport { contentListQuery, contentCreateBody } from \"#api/schemas.js\";\n\nexport const prerender = false;\n\nexport const GET: APIRoute = async ({ params, url, locals }) => {\n\tconst { emdash, user } = locals;\n\tif (!emdash?.handleContentList) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\tconst denied = requirePerm(user, \"content:read\");\n\tif (denied) return denied;\n\tconst collection = params.collection!;\n\tconst query = parseQuery(url, contentListQuery);\n\tif (isParseError(query)) return query;\n\n\t// Subscribers must only see published content; force the status filter\n\t// regardless of caller-supplied value. Any user with content:read_drafts\n\t// (CONTRIBUTOR+) keeps the requested filter.\n\tconst params_ = hasPermission(user, \"content:read_drafts\")\n\t\t? query\n\t\t: { ...query, status: \"published\" };\n\n\tconst result = await emdash.handleContentList(collection, params_);\n\n\treturn unwrapResult(result);\n};\n\nexport const POST: APIRoute = async ({ params, request, locals, cache }) => {\n\tconst { emdash, user } = locals;\n\tif (!emdash?.handleContentCreate || !emdash?.handleContentGet) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\tconst denied = requirePerm(user, \"content:create\");\n\tif (denied) return denied;\n\tconst collection = params.collection!;\n\tconst body = await parseBody(request, contentCreateBody);\n\tif (isParseError(body)) return body;\n\n\t// Creating a translation requires edit permission on the source item\n\tif (body.translationOf) {\n\t\tconst source = await emdash.handleContentGet(collection, body.translationOf);\n\t\tif (!source.success) {\n\t\t\treturn apiError(\n\t\t\t\tsource.error?.code ?? \"NOT_FOUND\",\n\t\t\t\tsource.error?.message ?? \"Translation source not found\",\n\t\t\t\tmapErrorStatus(source.error?.code),\n\t\t\t);\n\t\t}\n\t\tconst sourceAuthor = source.data.item.authorId ?? \"\";\n\t\tconst translationDenied = requireOwnerPerm(\n\t\t\tuser,\n\t\t\tsourceAuthor,\n\t\t\t\"content:edit_own\",\n\t\t\t\"content:edit_any\",\n\t\t);\n\t\tif (translationDenied) return translationDenied;\n\t}\n\n\t// Only EDITOR+ can write publishedAt / createdAt directly — incl. clearing to null.\n\tconst hasDateOverride = body.publishedAt !== undefined || body.createdAt !== undefined;\n\tif (hasDateOverride && !hasPermission(user, \"content:publish_any\")) {\n\t\treturn apiError(\n\t\t\t\"FORBIDDEN\",\n\t\t\t\"Writing publishedAt or createdAt requires content:publish_any permission\",\n\t\t\t403,\n\t\t);\n\t}\n\n\t// Auto-set authorId to current user when creating content\n\tconst result = await emdash.handleContentCreate(collection, {\n\t\t...body,\n\t\tauthorId: user?.id,\n\t\tlocale: body.locale,\n\t\ttranslationOf: body.translationOf,\n\t});\n\n\tif (!result.success) return unwrapResult(result);\n\n\tif (cache?.enabled) await cache.invalidate({ tags: [collection] });\n\n\treturn unwrapResult(result, 201);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAeA,MAAa,YAAY;AAEzB,MAAa,MAAgB,OAAO,EAAE,QAAQ,KAAK,aAAa;CAC/D,MAAM,EAAE,QAAQ,SAAS;AACzB,KAAI,CAAC,QAAQ,kBACZ,QAAO,SAAS,kBAAkB,6BAA6B,IAAI;CAEpE,MAAM,SAAS,YAAY,MAAM,eAAe;AAChD,KAAI,OAAQ,QAAO;CACnB,MAAM,aAAa,OAAO;CAC1B,MAAM,QAAQ,WAAW,KAAK,iBAAiB;AAC/C,KAAI,aAAa,MAAM,CAAE,QAAO;CAKhC,MAAM,UAAU,cAAc,MAAM,sBAAsB,GACvD,QACA;EAAE,GAAG;EAAO,QAAQ;EAAa;AAIpC,QAAO,aAFQ,MAAM,OAAO,kBAAkB,YAAY,QAAQ,CAEvC;;AAG5B,MAAa,OAAiB,OAAO,EAAE,QAAQ,SAAS,QAAQ,YAAY;CAC3E,MAAM,EAAE,QAAQ,SAAS;AACzB,KAAI,CAAC,QAAQ,uBAAuB,CAAC,QAAQ,iBAC5C,QAAO,SAAS,kBAAkB,6BAA6B,IAAI;CAEpE,MAAM,SAAS,YAAY,MAAM,iBAAiB;AAClD,KAAI,OAAQ,QAAO;CACnB,MAAM,aAAa,OAAO;CAC1B,MAAM,OAAO,MAAM,UAAU,SAAS,kBAAkB;AACxD,KAAI,aAAa,KAAK,CAAE,QAAO;AAG/B,KAAI,KAAK,eAAe;EACvB,MAAM,SAAS,MAAM,OAAO,iBAAiB,YAAY,KAAK,cAAc;AAC5E,MAAI,CAAC,OAAO,QACX,QAAO,SACN,OAAO,OAAO,QAAQ,aACtB,OAAO,OAAO,WAAW,gCACzB,eAAe,OAAO,OAAO,KAAK,CAClC;EAGF,MAAM,oBAAoB,iBACzB,MAFoB,OAAO,KAAK,KAAK,YAAY,IAIjD,oBACA,mBACA;AACD,MAAI,kBAAmB,QAAO;;AAK/B,MADwB,KAAK,gBAAgB,UAAa,KAAK,cAAc,WACtD,CAAC,cAAc,MAAM,sBAAsB,CACjE,QAAO,SACN,aACA,4EACA,IACA;
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../src/astro/routes/api/content/[collection]/index.ts"],"sourcesContent":["/**\n * Content list and create endpoints - injected by EmDash integration\n *\n * GET /_emdash/api/content/{collection} - List content\n * POST /_emdash/api/content/{collection} - Create content\n */\n\nimport { hasPermission } from \"@emdash-cms/auth\";\nimport type { APIRoute } from \"astro\";\n\nimport { requirePerm, requireOwnerPerm } from \"#api/authorize.js\";\nimport { apiError, mapErrorStatus, unwrapResult } from \"#api/error.js\";\nimport { parseBody, parseQuery, isParseError } from \"#api/parse.js\";\nimport { contentListQuery, contentCreateBody } from \"#api/schemas.js\";\n\nexport const prerender = false;\n\nexport const GET: APIRoute = async ({ params, url, locals }) => {\n\tconst { emdash, user } = locals;\n\tif (!emdash?.handleContentList) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\tconst denied = requirePerm(user, \"content:read\");\n\tif (denied) return denied;\n\tconst collection = params.collection!;\n\tconst query = parseQuery(url, contentListQuery);\n\tif (isParseError(query)) return query;\n\n\t// Subscribers must only see published content; force the status filter\n\t// regardless of caller-supplied value. Any user with content:read_drafts\n\t// (CONTRIBUTOR+) keeps the requested filter.\n\tconst params_ = hasPermission(user, \"content:read_drafts\")\n\t\t? query\n\t\t: { ...query, status: \"published\" };\n\n\tconst result = await emdash.handleContentList(collection, params_);\n\n\treturn unwrapResult(result);\n};\n\nexport const POST: APIRoute = async ({ params, request, locals, cache }) => {\n\tconst { emdash, user } = locals;\n\tif (!emdash?.handleContentCreate || !emdash?.handleContentGet) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\tconst denied = requirePerm(user, \"content:create\");\n\tif (denied) return denied;\n\tconst collection = params.collection!;\n\tconst body = await parseBody(request, contentCreateBody);\n\tif (isParseError(body)) return body;\n\n\t// Creating a translation requires edit permission on the source item\n\tif (body.translationOf) {\n\t\tconst source = await emdash.handleContentGet(collection, body.translationOf);\n\t\tif (!source.success) {\n\t\t\treturn apiError(\n\t\t\t\tsource.error?.code ?? \"NOT_FOUND\",\n\t\t\t\tsource.error?.message ?? \"Translation source not found\",\n\t\t\t\tmapErrorStatus(source.error?.code),\n\t\t\t);\n\t\t}\n\t\tconst sourceAuthor = source.data.item.authorId ?? \"\";\n\t\tconst translationDenied = requireOwnerPerm(\n\t\t\tuser,\n\t\t\tsourceAuthor,\n\t\t\t\"content:edit_own\",\n\t\t\t\"content:edit_any\",\n\t\t);\n\t\tif (translationDenied) return translationDenied;\n\t}\n\n\t// Only EDITOR+ can write publishedAt / createdAt directly — incl. clearing to null.\n\tconst hasDateOverride = body.publishedAt !== undefined || body.createdAt !== undefined;\n\tif (hasDateOverride && !hasPermission(user, \"content:publish_any\")) {\n\t\treturn apiError(\n\t\t\t\"FORBIDDEN\",\n\t\t\t\"Writing publishedAt or createdAt requires content:publish_any permission\",\n\t\t\t403,\n\t\t);\n\t}\n\n\tconst actor = user ? { id: user.id, role: user.role } : undefined;\n\n\t// Auto-set authorId to current user when creating content\n\tconst result = await emdash.handleContentCreate(collection, {\n\t\t...body,\n\t\tauthorId: user?.id,\n\t\tlocale: body.locale,\n\t\ttranslationOf: body.translationOf,\n\t\tactor,\n\t});\n\n\tif (!result.success) return unwrapResult(result);\n\n\tif (cache?.enabled) await cache.invalidate({ tags: [collection] });\n\n\treturn unwrapResult(result, 201);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAeA,MAAa,YAAY;AAEzB,MAAa,MAAgB,OAAO,EAAE,QAAQ,KAAK,aAAa;CAC/D,MAAM,EAAE,QAAQ,SAAS;AACzB,KAAI,CAAC,QAAQ,kBACZ,QAAO,SAAS,kBAAkB,6BAA6B,IAAI;CAEpE,MAAM,SAAS,YAAY,MAAM,eAAe;AAChD,KAAI,OAAQ,QAAO;CACnB,MAAM,aAAa,OAAO;CAC1B,MAAM,QAAQ,WAAW,KAAK,iBAAiB;AAC/C,KAAI,aAAa,MAAM,CAAE,QAAO;CAKhC,MAAM,UAAU,cAAc,MAAM,sBAAsB,GACvD,QACA;EAAE,GAAG;EAAO,QAAQ;EAAa;AAIpC,QAAO,aAFQ,MAAM,OAAO,kBAAkB,YAAY,QAAQ,CAEvC;;AAG5B,MAAa,OAAiB,OAAO,EAAE,QAAQ,SAAS,QAAQ,YAAY;CAC3E,MAAM,EAAE,QAAQ,SAAS;AACzB,KAAI,CAAC,QAAQ,uBAAuB,CAAC,QAAQ,iBAC5C,QAAO,SAAS,kBAAkB,6BAA6B,IAAI;CAEpE,MAAM,SAAS,YAAY,MAAM,iBAAiB;AAClD,KAAI,OAAQ,QAAO;CACnB,MAAM,aAAa,OAAO;CAC1B,MAAM,OAAO,MAAM,UAAU,SAAS,kBAAkB;AACxD,KAAI,aAAa,KAAK,CAAE,QAAO;AAG/B,KAAI,KAAK,eAAe;EACvB,MAAM,SAAS,MAAM,OAAO,iBAAiB,YAAY,KAAK,cAAc;AAC5E,MAAI,CAAC,OAAO,QACX,QAAO,SACN,OAAO,OAAO,QAAQ,aACtB,OAAO,OAAO,WAAW,gCACzB,eAAe,OAAO,OAAO,KAAK,CAClC;EAGF,MAAM,oBAAoB,iBACzB,MAFoB,OAAO,KAAK,KAAK,YAAY,IAIjD,oBACA,mBACA;AACD,MAAI,kBAAmB,QAAO;;AAK/B,MADwB,KAAK,gBAAgB,UAAa,KAAK,cAAc,WACtD,CAAC,cAAc,MAAM,sBAAsB,CACjE,QAAO,SACN,aACA,4EACA,IACA;CAGF,MAAM,QAAQ,OAAO;EAAE,IAAI,KAAK;EAAI,MAAM,KAAK;EAAM,GAAG;CAGxD,MAAM,SAAS,MAAM,OAAO,oBAAoB,YAAY;EAC3D,GAAG;EACH,UAAU,MAAM;EAChB,QAAQ,KAAK;EACb,eAAe,KAAK;EACpB;EACA,CAAC;AAEF,KAAI,CAAC,OAAO,QAAS,QAAO,aAAa,OAAO;AAEhD,KAAI,OAAO,QAAS,OAAM,MAAM,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;AAElE,QAAO,aAAa,QAAQ,IAAI"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import "../../../../../config-C3EBstHi.mjs";
|
|
2
2
|
import "../../../../../base64-CvLhUKQv.mjs";
|
|
3
3
|
import "../../../../../types-CQPWhPxE.mjs";
|
|
4
|
-
import { a as unwrapResult, t as apiError } from "../../../../../error-
|
|
5
|
-
import { i as parseQuery, t as isParseError } from "../../../../../parse-
|
|
6
|
-
import "../../../../../media-
|
|
7
|
-
import {
|
|
8
|
-
import "../../../../../relations-
|
|
9
|
-
import "../../../../../status-
|
|
4
|
+
import { a as unwrapResult, t as apiError } from "../../../../../error-BDcFyoRt.mjs";
|
|
5
|
+
import { i as parseQuery, t as isParseError } from "../../../../../parse-WRg5C3NX.mjs";
|
|
6
|
+
import "../../../../../media-C1EIZKh1.mjs";
|
|
7
|
+
import { gn as contentTrashQuery } from "../../../../../entry-lock-DIYHAaSw.mjs";
|
|
8
|
+
import "../../../../../relations-rOmbndUJ.mjs";
|
|
9
|
+
import "../../../../../status-Cenfk_r5.mjs";
|
|
10
10
|
import "../../../../../api/schemas/index.mjs";
|
|
11
|
-
import { r as requirePerm } from "../../../../../authorize-
|
|
11
|
+
import { r as requirePerm } from "../../../../../authorize-C2QHlWSS.mjs";
|
|
12
12
|
|
|
13
13
|
//#region src/astro/routes/api/content/[collection]/trash.ts
|
|
14
14
|
const prerender = false;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import "../../../after-CBU2vkoO.mjs";
|
|
2
|
-
import "../../../object-cache-
|
|
3
|
-
import "../../../content-
|
|
2
|
+
import "../../../object-cache-DVKnyOfy.mjs";
|
|
3
|
+
import "../../../content-CNfMWuhY.mjs";
|
|
4
4
|
import "../../../slugify-B994zkXC.mjs";
|
|
5
5
|
import "../../../base64-CvLhUKQv.mjs";
|
|
6
6
|
import "../../../types-CQPWhPxE.mjs";
|
|
7
|
-
import "../../../media-
|
|
8
|
-
import "../../../user-
|
|
9
|
-
import "../../../options-
|
|
10
|
-
import { t as handleDashboardStats } from "../../../dashboard-
|
|
11
|
-
import { a as unwrapResult, r as handleError, t as apiError } from "../../../error-
|
|
12
|
-
import { r as requirePerm } from "../../../authorize-
|
|
7
|
+
import "../../../media-BBm8Wg3f.mjs";
|
|
8
|
+
import "../../../user-DIsIXogT.mjs";
|
|
9
|
+
import "../../../options-D1FBiAv1.mjs";
|
|
10
|
+
import { t as handleDashboardStats } from "../../../dashboard-BNSvAN8A.mjs";
|
|
11
|
+
import { a as unwrapResult, r as handleError, t as apiError } from "../../../error-BDcFyoRt.mjs";
|
|
12
|
+
import { r as requirePerm } from "../../../authorize-C2QHlWSS.mjs";
|
|
13
13
|
|
|
14
14
|
//#region src/astro/routes/api/dashboard.ts
|
|
15
15
|
const prerender = false;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../../../../base64-CvLhUKQv.mjs";
|
|
2
2
|
import "../../../../types-CQPWhPxE.mjs";
|
|
3
|
-
import { n as apiSuccess, t as apiError } from "../../../../error-
|
|
4
|
-
import { i as getDevEmails, n as clearDevEmails } from "../../../../email-console-
|
|
3
|
+
import { n as apiSuccess, t as apiError } from "../../../../error-BDcFyoRt.mjs";
|
|
4
|
+
import { i as getDevEmails, n as clearDevEmails } from "../../../../email-console-DNup1Fku.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/astro/routes/api/dev/emails.ts
|
|
7
7
|
const prerender = false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../../../../types-
|
|
2
|
-
import "../../../../index-
|
|
3
|
-
import { g as ProbeResult } from "../../../../types-
|
|
1
|
+
import "../../../../types-tJWDK__M.mjs";
|
|
2
|
+
import "../../../../index-1ECYpfiF.mjs";
|
|
3
|
+
import { g as ProbeResult } from "../../../../types-DaEg7KX2.mjs";
|
|
4
4
|
import { APIRoute } from "astro";
|
|
5
5
|
|
|
6
6
|
//#region src/astro/routes/api/import/probe.d.ts
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import "../../../../dialect-helpers-
|
|
1
|
+
import "../../../../dialect-helpers-BcQvkHgn.mjs";
|
|
2
2
|
import "../../../../config-C3EBstHi.mjs";
|
|
3
3
|
import "../../../../after-CBU2vkoO.mjs";
|
|
4
|
-
import "../../../../object-cache-
|
|
4
|
+
import "../../../../object-cache-DVKnyOfy.mjs";
|
|
5
5
|
import "../../../../slugify-B994zkXC.mjs";
|
|
6
6
|
import "../../../../base64-CvLhUKQv.mjs";
|
|
7
7
|
import "../../../../types-CQPWhPxE.mjs";
|
|
8
|
-
import "../../../../media-
|
|
9
|
-
import "../../../../options-
|
|
10
|
-
import "../../../../request-cache-
|
|
11
|
-
import "../../../../loader-
|
|
12
|
-
import "../../../../settings-
|
|
13
|
-
import { t as SsrfError } from "../../../../ssrf-
|
|
14
|
-
import { n as apiSuccess, r as handleError, t as apiError } from "../../../../error-
|
|
15
|
-
import { n as parseBody, t as isParseError } from "../../../../parse-
|
|
16
|
-
import "../../../../media-
|
|
17
|
-
import "../../../../
|
|
18
|
-
import { S as importProbeBody } from "../../../../relations-
|
|
19
|
-
import "../../../../status-
|
|
8
|
+
import "../../../../media-BBm8Wg3f.mjs";
|
|
9
|
+
import "../../../../options-D1FBiAv1.mjs";
|
|
10
|
+
import "../../../../request-cache-DAZZmesc.mjs";
|
|
11
|
+
import "../../../../loader-WJi6GFRn.mjs";
|
|
12
|
+
import "../../../../settings-DcMjREe5.mjs";
|
|
13
|
+
import { t as SsrfError } from "../../../../ssrf-gl4gFNhw.mjs";
|
|
14
|
+
import { n as apiSuccess, r as handleError, t as apiError } from "../../../../error-BDcFyoRt.mjs";
|
|
15
|
+
import { n as parseBody, t as isParseError } from "../../../../parse-WRg5C3NX.mjs";
|
|
16
|
+
import "../../../../media-C1EIZKh1.mjs";
|
|
17
|
+
import "../../../../entry-lock-DIYHAaSw.mjs";
|
|
18
|
+
import { S as importProbeBody } from "../../../../relations-rOmbndUJ.mjs";
|
|
19
|
+
import "../../../../status-Cenfk_r5.mjs";
|
|
20
20
|
import "../../../../api/schemas/index.mjs";
|
|
21
|
-
import { h as probeUrl } from "../../../../import-
|
|
22
|
-
import "../../../../ssrf-
|
|
23
|
-
import "../../../../utils-
|
|
24
|
-
import { r as requirePerm } from "../../../../authorize-
|
|
21
|
+
import { h as probeUrl } from "../../../../import-D96g2otw.mjs";
|
|
22
|
+
import "../../../../ssrf-TQhaljuI.mjs";
|
|
23
|
+
import "../../../../utils-BicP5Qbg.mjs";
|
|
24
|
+
import { r as requirePerm } from "../../../../authorize-C2QHlWSS.mjs";
|
|
25
25
|
|
|
26
26
|
//#region src/astro/routes/api/import/probe.ts
|
|
27
27
|
const prerender = false;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s as RESERVED_COLLECTION_SLUGS } from "../../../../../types-BMXnRIrX.mjs";
|
|
2
2
|
import "../../../../../base64-CvLhUKQv.mjs";
|
|
3
3
|
import "../../../../../types-CQPWhPxE.mjs";
|
|
4
|
-
import { n as apiSuccess, r as handleError, t as apiError } from "../../../../../error-
|
|
5
|
-
import { r as requirePerm } from "../../../../../authorize-
|
|
4
|
+
import { n as apiSuccess, r as handleError, t as apiError } from "../../../../../error-BDcFyoRt.mjs";
|
|
5
|
+
import { r as requirePerm } from "../../../../../authorize-C2QHlWSS.mjs";
|
|
6
6
|
import mime from "mime/lite";
|
|
7
7
|
import { SchemaRegistry, parseWxrString } from "emdash";
|
|
8
8
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import "../../../../../options-
|
|
2
|
-
import "../../../../../types-
|
|
3
|
-
import "../../../../../types-
|
|
4
|
-
import "../../../../../
|
|
5
|
-
import "../../../../../
|
|
6
|
-
import "../../../../../runner-
|
|
7
|
-
import "../../../../../index-
|
|
8
|
-
import "../../../../../types-
|
|
9
|
-
import "../../../../../hreflang-
|
|
10
|
-
import "../../../../../validate-
|
|
1
|
+
import "../../../../../options-D8Y0VHc7.mjs";
|
|
2
|
+
import "../../../../../types-tJWDK__M.mjs";
|
|
3
|
+
import "../../../../../types-BouXpOsa.mjs";
|
|
4
|
+
import "../../../../../entry-lock-CGAtrwAR.mjs";
|
|
5
|
+
import "../../../../../config-CGAhyOjP.mjs";
|
|
6
|
+
import "../../../../../runner-CfwysRM0.mjs";
|
|
7
|
+
import "../../../../../index-1ECYpfiF.mjs";
|
|
8
|
+
import "../../../../../types-DaEg7KX2.mjs";
|
|
9
|
+
import "../../../../../hreflang-CQpu5bMy.mjs";
|
|
10
|
+
import "../../../../../validate-Df6Dvwbw.mjs";
|
|
11
11
|
import { EmDashHandlers, EmDashManifest } from "../../../../types.mjs";
|
|
12
|
-
import { t as TaxonomyImportPlan } from "../../../../../wxr-taxonomies-
|
|
12
|
+
import { t as TaxonomyImportPlan } from "../../../../../wxr-taxonomies-BX4yQL9s.mjs";
|
|
13
13
|
import { WxrPost } from "emdash";
|
|
14
14
|
import { APIRoute } from "astro";
|
|
15
15
|
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import "../../../../../dialect-helpers-
|
|
1
|
+
import "../../../../../dialect-helpers-BcQvkHgn.mjs";
|
|
2
2
|
import "../../../../../config-C3EBstHi.mjs";
|
|
3
3
|
import "../../../../../after-CBU2vkoO.mjs";
|
|
4
|
-
import "../../../../../object-cache-
|
|
4
|
+
import "../../../../../object-cache-DVKnyOfy.mjs";
|
|
5
5
|
import { n as slugify } from "../../../../../slugify-B994zkXC.mjs";
|
|
6
6
|
import "../../../../../base64-CvLhUKQv.mjs";
|
|
7
7
|
import "../../../../../types-CQPWhPxE.mjs";
|
|
8
|
-
import "../../../../../taxonomy-
|
|
9
|
-
import "../../../../../
|
|
10
|
-
import "../../../../../
|
|
11
|
-
import "../../../../../
|
|
12
|
-
import
|
|
13
|
-
import "../../../../../
|
|
14
|
-
import "../../../../../loader-
|
|
15
|
-
import "../../../../../
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
8
|
+
import "../../../../../taxonomy-DP1vny4K.mjs";
|
|
9
|
+
import "../../../../../resolve-Cy0aWSRj.mjs";
|
|
10
|
+
import "../../../../../request-cache-DAZZmesc.mjs";
|
|
11
|
+
import "../../../../../byline-registry-BxDGIO0I.mjs";
|
|
12
|
+
import "../../../../../field-defs-cache-Cf5FHK0M.mjs";
|
|
13
|
+
import { t as BylineRepository } from "../../../../../byline-Vdi85CsZ.mjs";
|
|
14
|
+
import "../../../../../loader-WJi6GFRn.mjs";
|
|
15
|
+
import "../../../../../collection-slugs-cache-7lTmNzeA.mjs";
|
|
16
|
+
import "../../../../../taxonomies-NcFDq5Gg.mjs";
|
|
17
|
+
import { n as apiSuccess, r as handleError, t as apiError } from "../../../../../error-BDcFyoRt.mjs";
|
|
18
|
+
import { g as resolveImportByline } from "../../../../../utils-BicP5Qbg.mjs";
|
|
19
|
+
import { r as requirePerm } from "../../../../../authorize-C2QHlWSS.mjs";
|
|
19
20
|
import { sanitizeSlug } from "./analyze.mjs";
|
|
20
|
-
import { a as preImportWxrTaxonomies, i as mirrorTermsToLocales, n as isWxrTaxonomyConflictError, o as setPostTermAssignmentsReplacing, t as attachPostTaxonomies } from "../../../../../wxr-taxonomies-
|
|
21
|
+
import { a as preImportWxrTaxonomies, i as mirrorTermsToLocales, n as isWxrTaxonomyConflictError, o as setPostTermAssignmentsReplacing, t as attachPostTaxonomies } from "../../../../../wxr-taxonomies-Csdp7yde.mjs";
|
|
21
22
|
import { gutenbergToPortableText } from "@emdash-cms/gutenberg-to-portable-text";
|
|
22
23
|
import { ContentRepository, importReusableBlocksAsSections, parseWxrDate, parseWxrString } from "emdash";
|
|
23
24
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.mjs","names":[],"sources":["../../../../../../src/astro/routes/api/import/wordpress/execute.ts"],"sourcesContent":["/**\n * WordPress WXR execute import endpoint\n *\n * POST /_emdash/api/import/wordpress/execute\n *\n * Accepts WXR file and import configuration, imports content into the database.\n */\n\nimport { gutenbergToPortableText } from \"@emdash-cms/gutenberg-to-portable-text\";\nimport type { APIRoute } from \"astro\";\nimport {\n\tparseWxrString,\n\tContentRepository,\n\timportReusableBlocksAsSections,\n\ttype WxrPost,\n\tparseWxrDate,\n} from \"emdash\";\n\nimport { requirePerm } from \"#api/authorize.js\";\nimport { apiError, apiSuccess, handleError } from \"#api/error.js\";\nimport { BylineRepository } from \"#db/repositories/byline.js\";\nimport { resolveImportByline } from \"#import/utils.js\";\nimport {\n\tattachPostTaxonomies,\n\tisWxrTaxonomyConflictError,\n\tmirrorTermsToLocales,\n\tpreImportWxrTaxonomies,\n\tsetPostTermAssignmentsReplacing,\n\ttype TaxonomyImportPlan,\n} from \"#import/wxr-taxonomies.js\";\nimport type { EmDashHandlers, EmDashManifest } from \"#types\";\nimport { slugify } from \"#utils/slugify.js\";\n\nimport { sanitizeSlug } from \"./analyze.js\";\n\nexport const prerender = false;\n\nexport interface ImportConfig {\n\t/** Map WordPress post types to EmDash collections */\n\tpostTypeMappings: Record<\n\t\tstring,\n\t\t{\n\t\t\tcollection: string;\n\t\t\tenabled: boolean;\n\t\t}\n\t>;\n\t/** Whether to skip items that already exist (by slug) */\n\tskipExisting: boolean;\n\t/** Whether to import reusable blocks (wp_block) as sections */\n\timportSections?: boolean;\n\t/** Author mappings (WP author login -> EmDash user ID) */\n\tauthorMappings?: Record<string, string | null>;\n\t/** BCP 47 locale for all imported items. When omitted, defaults to defaultLocale. */\n\tlocale?: string;\n}\n\nexport interface ImportResult {\n\tsuccess: boolean;\n\timported: number;\n\tskipped: number;\n\terrors: Array<{ title: string; error: string }>;\n\tbyCollection: Record<string, number>;\n\t/** Sections import results (if enabled) */\n\tsections?: {\n\t\tcreated: number;\n\t\tskipped: number;\n\t};\n\t/** Taxonomy import results (categories, tags, custom taxonomies). */\n\ttaxonomies?: {\n\t\t/** Terms newly created during this import, keyed by taxonomy name. */\n\t\ttermsCreated: Record<string, number>;\n\t\t/** Existing terms that were re-used, keyed by taxonomy name. */\n\t\ttermsReused: Record<string, number>;\n\t\t/** Total pivot rows (post <-> term) written to `content_taxonomies`. */\n\t\tassignments: number;\n\t\t/**\n\t\t * Custom taxonomy names from the WXR file that had no matching EmDash\n\t\t * definition and were therefore skipped. Lets the admin UI surface a\n\t\t * \"create taxonomy X first\" hint without re-running the import.\n\t\t */\n\t\tmissingTaxonomies: string[];\n\t};\n}\n\nexport const POST: APIRoute = async ({ request, locals }) => {\n\tconst { emdash, user } = locals;\n\n\tconst denied = requirePerm(user, \"import:execute\");\n\tif (denied) return denied;\n\n\tif (!emdash?.handleContentCreate) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash not configured\", 500);\n\t}\n\n\ttry {\n\t\tconst emdashManifest = await emdash.getManifest();\n\n\t\tconst formData = await request.formData();\n\t\tconst fileEntry = formData.get(\"file\");\n\t\tconst file = fileEntry instanceof File ? fileEntry : null;\n\t\tconst configEntry = formData.get(\"config\");\n\t\tconst configJson = typeof configEntry === \"string\" ? configEntry : null;\n\n\t\tif (!file) {\n\t\t\treturn apiError(\"VALIDATION_ERROR\", \"No file provided\", 400);\n\t\t}\n\n\t\tif (!configJson) {\n\t\t\treturn apiError(\"VALIDATION_ERROR\", \"No config provided\", 400);\n\t\t}\n\n\t\tconst config: ImportConfig = JSON.parse(configJson);\n\n\t\t// Parse WXR\n\t\tconst text = await file.text();\n\t\tconst wxr = await parseWxrString(text);\n\n\t\t// Build attachment ID -> URL map for featured images\n\t\tconst attachmentMap = new Map<string, string>();\n\t\tfor (const att of wxr.attachments) {\n\t\t\tif (att.id && att.url) {\n\t\t\t\tattachmentMap.set(String(att.id), att.url);\n\t\t\t}\n\t\t}\n\n\t\t// Build author login -> display name map\n\t\tconst authorDisplayNames = new Map<string, string>();\n\t\tfor (const author of wxr.authors) {\n\t\t\tif (!author.login) continue;\n\t\t\tauthorDisplayNames.set(author.login, author.displayName || author.login);\n\t\t}\n\n\t\t// Pre-create taxonomy terms (categories, tags, custom taxonomies) so\n\t\t// per-post assignments can resolve to existing rows. Done before any\n\t\t// content insert because WXR exports list terms at the top of the\n\t\t// file but per-item assignments only reference them by slug.\n\t\tconst taxonomyPlan = await preImportWxrTaxonomies(\n\t\t\temdash.db,\n\t\t\twxr.posts,\n\t\t\twxr.categories,\n\t\t\twxr.tags,\n\t\t\twxr.terms,\n\t\t\tconfig.locale,\n\t\t);\n\n\t\t// Multilingual imports (WPML / Polylang -- see #1080) need a term\n\t\t// row at each per-post locale, all sharing the canonical term's\n\t\t// `translation_group`. Without this, `getTermsForEntry(..., locale)`\n\t\t// on non-canonical translations comes back empty.\n\t\t//\n\t\t// The mirror raises `WxrTaxonomyConflictError` with an operator-\n\t\t// actionable message when an existing locale row has an\n\t\t// incompatible group. Surface its `publicMessage` directly so the\n\t\t// admin UI can tell the user which (taxonomy, slug, locale) needs\n\t\t// reconciliation. Other errors (DB connectivity, unexpected\n\t\t// repository failures) re-throw to the outer catch where\n\t\t// `handleError` masks them with the generic \"Failed to import\n\t\t// content\" -- exposing raw DB errors to clients would leak schema\n\t\t// names and bypass the AGENTS.md \"never expose error.message\" rule.\n\t\tconst postLocales = new Set<string>();\n\t\tfor (const post of wxr.posts) {\n\t\t\tif (post.locale) postLocales.add(post.locale);\n\t\t}\n\t\tif (postLocales.size > 0) {\n\t\t\ttry {\n\t\t\t\tawait mirrorTermsToLocales(emdash.db, taxonomyPlan, postLocales, config.locale);\n\t\t\t} catch (mirrorError) {\n\t\t\t\tif (isWxrTaxonomyConflictError(mirrorError)) {\n\t\t\t\t\tconsole.error(\"[WXR_IMPORT_TAXONOMY_CONFLICT]\", mirrorError);\n\t\t\t\t\treturn apiError(\"WXR_IMPORT_TAXONOMY_CONFLICT\", mirrorError.publicMessage, 409);\n\t\t\t\t}\n\t\t\t\tthrow mirrorError;\n\t\t\t}\n\t\t}\n\n\t\t// Import content (locale from config scopes all items)\n\t\tconst result = await importContent(\n\t\t\twxr.posts,\n\t\t\tconfig,\n\t\t\temdash,\n\t\t\temdashManifest,\n\t\t\tattachmentMap,\n\t\t\tconfig.locale,\n\t\t\tauthorDisplayNames,\n\t\t\ttaxonomyPlan,\n\t\t);\n\n\t\t// Import reusable blocks as sections (if enabled)\n\t\tif (config.importSections !== false) {\n\t\t\tconst sectionsResult = await importReusableBlocksAsSections(wxr.posts, emdash.db);\n\t\t\tresult.sections = {\n\t\t\t\tcreated: sectionsResult.sectionsCreated,\n\t\t\t\tskipped: sectionsResult.sectionsSkipped,\n\t\t\t};\n\t\t\t// Add section errors to main errors array\n\t\t\tresult.errors.push(...sectionsResult.errors);\n\t\t\tif (sectionsResult.errors.length > 0) {\n\t\t\t\tresult.success = false;\n\t\t\t}\n\t\t}\n\n\t\treturn apiSuccess(result);\n\t} catch (error) {\n\t\treturn handleError(error, \"Failed to import content\", \"WXR_IMPORT_ERROR\");\n\t}\n};\n\nexport async function importContent(\n\tposts: WxrPost[],\n\tconfig: ImportConfig,\n\temdash: EmDashHandlers,\n\tmanifest: EmDashManifest,\n\tattachmentMap: Map<string, string>,\n\tlocale: string | undefined,\n\tauthorDisplayNames: Map<string, string> | undefined,\n\ttaxonomyPlan: TaxonomyImportPlan,\n): Promise<ImportResult> {\n\tconst result: ImportResult = {\n\t\tsuccess: true,\n\t\timported: 0,\n\t\tskipped: 0,\n\t\terrors: [],\n\t\tbyCollection: {},\n\t\ttaxonomies: {\n\t\t\ttermsCreated: taxonomyPlan.termsCreated,\n\t\t\ttermsReused: taxonomyPlan.termsReused,\n\t\t\tassignments: 0,\n\t\t\tmissingTaxonomies: taxonomyPlan.missingTaxonomies,\n\t\t},\n\t};\n\n\t// Create content repository for checking existing items\n\tconst contentRepo = new ContentRepository(emdash.db);\n\tconst bylineRepo = new BylineRepository(emdash.db);\n\tconst bylineCache = new Map<string, string>();\n\n\t// Source-side translation group ID -> the EmDash ID of the first post we\n\t// imported for that group. Subsequent translations are linked via\n\t// `translationOf` so they share a `translation_group` on the EmDash side.\n\tconst translationGroupMap = new Map<string, string>();\n\n\tfor (const post of posts) {\n\t\tconst postType = post.postType || \"post\";\n\t\tconst mapping = config.postTypeMappings[postType];\n\n\t\t// Skip if not mapped or disabled\n\t\tif (!mapping || !mapping.enabled) {\n\t\t\tresult.skipped++;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Defensive: mapping.collection is already sanitized by prepare, but the user\n\t\t// could manually edit the import config between prepare and execute.\n\t\tconst collection = sanitizeSlug(mapping.collection);\n\n\t\t// Check if collection exists in manifest\n\t\tif (!manifest?.collections[collection]) {\n\t\t\tresult.errors.push({\n\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\terror: `Collection \"${collection}\" does not exist`,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\ttry {\n\t\t\t// Convert content to Portable Text\n\t\t\tconst content = post.content ? gutenbergToPortableText(post.content) : [];\n\n\t\t\t// Generate slug from post name or title\n\t\t\tconst slug = post.postName || slugify(post.title || `post-${post.id || Date.now()}`);\n\n\t\t\t// Per-post locale: prefer the value extracted from WPML/Polylang\n\t\t\t// metadata; fall back to the upload-wide locale. Two translations\n\t\t\t// sharing `post_name` (e.g. /en/hello + /ar/hello) collide on the\n\t\t\t// `UNIQUE(slug, locale)` constraint when they share a locale, so\n\t\t\t// honouring the per-post value is what makes multilingual imports\n\t\t\t// land correctly. See issue #1080.\n\t\t\tconst postLocale = post.locale ?? locale;\n\n\t\t\t// Check if already exists (idempotency). Match against the\n\t\t\t// per-post locale so the same slug in different locales doesn't\n\t\t\t// false-positive as duplicate.\n\t\t\tif (config.skipExisting) {\n\t\t\t\tconst existing = await contentRepo.findBySlug(collection, slug, postLocale);\n\t\t\t\tif (existing) {\n\t\t\t\t\t// Record the translation group mapping so later\n\t\t\t\t\t// translations in this WXR can link to the existing\n\t\t\t\t\t// item. We deliberately trust the WXR's grouping over\n\t\t\t\t\t// the existing row's `translation_group`: a singleton\n\t\t\t\t\t// existing row gets folded into the WXR's group when\n\t\t\t\t\t// `handleContentCreate` resolves the new translation's\n\t\t\t\t\t// `translationOf`. Pre-existing translations that\n\t\t\t\t\t// already belong to a different group are left alone --\n\t\t\t\t\t// the user is responsible for reconciling those through\n\t\t\t\t\t// the admin if they don't match the WXR.\n\t\t\t\t\tif (post.translationGroup) {\n\t\t\t\t\t\ttranslationGroupMap.set(post.translationGroup, existing.id);\n\t\t\t\t\t}\n\t\t\t\t\tresult.skipped++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Resolve translation group: if this post belongs to a group and\n\t\t\t// we've already imported one of its translations, link to it.\n\t\t\tlet translationOf: string | undefined;\n\t\t\tif (post.translationGroup) {\n\t\t\t\ttranslationOf = translationGroupMap.get(post.translationGroup);\n\t\t\t}\n\n\t\t\t// Map WordPress status to EmDash status\n\t\t\tconst status = mapStatus(post.status);\n\n\t\t\t// Build data object with required fields\n\t\t\tconst data: Record<string, unknown> = {\n\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\tcontent,\n\t\t\t\texcerpt: post.excerpt || undefined,\n\t\t\t};\n\n\t\t\t// Only add featured_image if the collection has this field and we have a value\n\t\t\tconst collectionSchema = manifest.collections[collection];\n\t\t\tconst hasFeaturedImageField = collectionSchema?.fields\n\t\t\t\t? \"featured_image\" in collectionSchema.fields\n\t\t\t\t: false;\n\t\t\tif (hasFeaturedImageField) {\n\t\t\t\tconst thumbnailId = post.meta.get(\"_thumbnail_id\");\n\t\t\t\tconst featuredImage = thumbnailId ? attachmentMap.get(String(thumbnailId)) : undefined;\n\t\t\t\tif (featuredImage) {\n\t\t\t\t\tdata.featured_image = featuredImage;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Resolve author ID from mappings\n\t\t\tlet authorId: string | undefined;\n\t\t\tif (config.authorMappings && post.creator) {\n\t\t\t\tconst mappedUserId = config.authorMappings[post.creator];\n\t\t\t\tif (mappedUserId !== undefined && mappedUserId !== null) {\n\t\t\t\t\tauthorId = mappedUserId;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst bylineId = await resolveImportByline(\n\t\t\t\tpost.creator,\n\t\t\t\tauthorDisplayNames?.get(post.creator ?? \"\") ?? post.creator,\n\t\t\t\tauthorId,\n\t\t\t\tbylineRepo,\n\t\t\t\tbylineCache,\n\t\t\t);\n\n\t\t\t// Preserve original WordPress dates using the shared WXR date parser.\n\t\t\t// Fallback chain: postDateGmt (UTC) → pubDate (RFC 2822) → postDate (site-local).\n\t\t\tconst parsedDate = parseWxrDate(post.postDateGmt, post.pubDate, post.postDate);\n\t\t\tconst createdAt = parsedDate ? parsedDate.toISOString() : undefined;\n\t\t\tconst publishedAt = status === \"published\" && createdAt ? createdAt : undefined;\n\n\t\t\t// Create the content item\n\t\t\tconst createResult = await emdash.handleContentCreate(collection, {\n\t\t\t\tdata,\n\t\t\t\tslug,\n\t\t\t\tstatus,\n\t\t\t\tauthorId,\n\t\t\t\tbylines: bylineId ? [{ bylineId }] : undefined,\n\t\t\t\tlocale: postLocale,\n\t\t\t\ttranslationOf,\n\t\t\t\tcreatedAt,\n\t\t\t\tpublishedAt,\n\t\t\t});\n\n\t\t\tif (createResult.success) {\n\t\t\t\tresult.imported++;\n\t\t\t\tresult.byCollection[collection] = (result.byCollection[collection] || 0) + 1;\n\n\t\t\t\t// `handleContentCreate` returns `data: { item, _rev? }` on\n\t\t\t\t// success (see `ApiResult<ContentResponse>` in\n\t\t\t\t// `api/handlers/content.ts`). `HandlerResponse.data` is\n\t\t\t\t// typed as `unknown` to avoid coupling the route surface to\n\t\t\t\t// internal handler types, so we narrow here.\n\t\t\t\t// eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler contract documented at handleContentCreate\n\t\t\t\tconst createdItem = (createResult.data as { item: { id: string } } | undefined)?.item;\n\n\t\t\t\t// Track translation group: the first imported post in a group\n\t\t\t\t// becomes the anchor that later translations link to.\n\t\t\t\tif (\n\t\t\t\t\tcreatedItem &&\n\t\t\t\t\tpost.translationGroup &&\n\t\t\t\t\t!translationGroupMap.has(post.translationGroup)\n\t\t\t\t) {\n\t\t\t\t\ttranslationGroupMap.set(post.translationGroup, createdItem.id);\n\t\t\t\t}\n\n\t\t\t\t// Attach taxonomy assignments parsed from the WXR's per-item\n\t\t\t\t// <category> elements.\n\t\t\t\t//\n\t\t\t\t// Anchors (no `translationOf`) get an additive attach -- the\n\t\t\t\t// row is fresh, no inherited pivots to consider.\n\t\t\t\t//\n\t\t\t\t// Translations replace only taxonomies they explicitly carry.\n\t\t\t\t// Since assignments belong to the content translation_group,\n\t\t\t\t// that replacement is reflected in every sibling locale.\n\t\t\t\tif (createdItem) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst written = translationOf\n\t\t\t\t\t\t\t? await setPostTermAssignmentsReplacing(\n\t\t\t\t\t\t\t\t\temdash.db,\n\t\t\t\t\t\t\t\t\tcollection,\n\t\t\t\t\t\t\t\t\tcreatedItem.id,\n\t\t\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t\t\ttaxonomyPlan,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: await attachPostTaxonomies(\n\t\t\t\t\t\t\t\t\temdash.db,\n\t\t\t\t\t\t\t\t\tcollection,\n\t\t\t\t\t\t\t\t\tcreatedItem.id,\n\t\t\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t\t\ttaxonomyPlan,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\tif (result.taxonomies) {\n\t\t\t\t\t\t\tresult.taxonomies.assignments += written;\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (taxError) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`Failed to attach taxonomies for \"${post.title || \"Untitled\"}\":`,\n\t\t\t\t\t\t\ttaxError,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tresult.errors.push({\n\t\t\t\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\t\t\t\terror:\n\t\t\t\t\t\t\t\ttaxError instanceof Error && taxError.message\n\t\t\t\t\t\t\t\t\t? `Imported but failed to attach taxonomies: ${taxError.message}`\n\t\t\t\t\t\t\t\t\t: \"Imported but failed to attach taxonomies\",\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tresult.errors.push({\n\t\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\t\terror:\n\t\t\t\t\t\ttypeof createResult.error === \"object\" && createResult.error !== null\n\t\t\t\t\t\t\t? (createResult.error as { message?: string }).message || \"Unknown error\"\n\t\t\t\t\t\t\t: String(createResult.error),\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(`Import error for \"${post.title || \"Untitled\"}\":`, error);\n\t\t\tresult.errors.push({\n\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\terror: error instanceof Error && error.message ? error.message : \"Failed to import item\",\n\t\t\t});\n\t\t}\n\t}\n\n\tresult.success = result.errors.length === 0;\n\treturn result;\n}\n\nfunction mapStatus(wpStatus: string | undefined): string {\n\tswitch (wpStatus) {\n\t\tcase \"publish\":\n\t\t\tre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AAK,SAAS,WAAW,KAAK,MAAM;AACvE,UAAO,OAAO,KAAK;IAClB,OAAO,KAAK,SAAS;IACrB,OAAO,iBAAiB,SAAS,MAAM,UAAU,MAAM,UAAU;IACjE,CAAC;;;AAIJ,QAAO,UAAU,OAAO,OAAO,WAAW;AAC1C,QAAO;;AAGR,SAAS,UAAU,UAAsC;AACxD,SAAQ,UAAR;EACC,KAAK,UACJ,QAAO;EACR,KAAK,QACJ,QAAO;EACR,KAAK,UACJ,QAAO;EACR,KAAK,UACJ,QAAO;EACR,QACC,QAAO"}
|
|
1
|
+
{"version":3,"file":"execute.mjs","names":[],"sources":["../../../../../../src/astro/routes/api/import/wordpress/execute.ts"],"sourcesContent":["/**\n * WordPress WXR execute import endpoint\n *\n * POST /_emdash/api/import/wordpress/execute\n *\n * Accepts WXR file and import configuration, imports content into the database.\n */\n\nimport { gutenbergToPortableText } from \"@emdash-cms/gutenberg-to-portable-text\";\nimport type { APIRoute } from \"astro\";\nimport {\n\tparseWxrString,\n\tContentRepository,\n\timportReusableBlocksAsSections,\n\ttype WxrPost,\n\tparseWxrDate,\n} from \"emdash\";\n\nimport { requirePerm } from \"#api/authorize.js\";\nimport { apiError, apiSuccess, handleError } from \"#api/error.js\";\nimport { BylineRepository } from \"#db/repositories/byline.js\";\nimport { resolveImportByline } from \"#import/utils.js\";\nimport {\n\tattachPostTaxonomies,\n\tisWxrTaxonomyConflictError,\n\tmirrorTermsToLocales,\n\tpreImportWxrTaxonomies,\n\tsetPostTermAssignmentsReplacing,\n\ttype TaxonomyImportPlan,\n} from \"#import/wxr-taxonomies.js\";\nimport type { EmDashHandlers, EmDashManifest } from \"#types\";\nimport { slugify } from \"#utils/slugify.js\";\n\nimport { sanitizeSlug } from \"./analyze.js\";\n\nexport const prerender = false;\n\nexport interface ImportConfig {\n\t/** Map WordPress post types to EmDash collections */\n\tpostTypeMappings: Record<\n\t\tstring,\n\t\t{\n\t\t\tcollection: string;\n\t\t\tenabled: boolean;\n\t\t}\n\t>;\n\t/** Whether to skip items that already exist (by slug) */\n\tskipExisting: boolean;\n\t/** Whether to import reusable blocks (wp_block) as sections */\n\timportSections?: boolean;\n\t/** Author mappings (WP author login -> EmDash user ID) */\n\tauthorMappings?: Record<string, string | null>;\n\t/** BCP 47 locale for all imported items. When omitted, defaults to defaultLocale. */\n\tlocale?: string;\n}\n\nexport interface ImportResult {\n\tsuccess: boolean;\n\timported: number;\n\tskipped: number;\n\terrors: Array<{ title: string; error: string }>;\n\tbyCollection: Record<string, number>;\n\t/** Sections import results (if enabled) */\n\tsections?: {\n\t\tcreated: number;\n\t\tskipped: number;\n\t};\n\t/** Taxonomy import results (categories, tags, custom taxonomies). */\n\ttaxonomies?: {\n\t\t/** Terms newly created during this import, keyed by taxonomy name. */\n\t\ttermsCreated: Record<string, number>;\n\t\t/** Existing terms that were re-used, keyed by taxonomy name. */\n\t\ttermsReused: Record<string, number>;\n\t\t/** Total pivot rows (post <-> term) written to `content_taxonomies`. */\n\t\tassignments: number;\n\t\t/**\n\t\t * Custom taxonomy names from the WXR file that had no matching EmDash\n\t\t * definition and were therefore skipped. Lets the admin UI surface a\n\t\t * \"create taxonomy X first\" hint without re-running the import.\n\t\t */\n\t\tmissingTaxonomies: string[];\n\t};\n}\n\nexport const POST: APIRoute = async ({ request, locals }) => {\n\tconst { emdash, user } = locals;\n\n\tconst denied = requirePerm(user, \"import:execute\");\n\tif (denied) return denied;\n\n\tif (!emdash?.handleContentCreate) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash not configured\", 500);\n\t}\n\n\ttry {\n\t\tconst emdashManifest = await emdash.getManifest();\n\n\t\tconst formData = await request.formData();\n\t\tconst fileEntry = formData.get(\"file\");\n\t\tconst file = fileEntry instanceof File ? fileEntry : null;\n\t\tconst configEntry = formData.get(\"config\");\n\t\tconst configJson = typeof configEntry === \"string\" ? configEntry : null;\n\n\t\tif (!file) {\n\t\t\treturn apiError(\"VALIDATION_ERROR\", \"No file provided\", 400);\n\t\t}\n\n\t\tif (!configJson) {\n\t\t\treturn apiError(\"VALIDATION_ERROR\", \"No config provided\", 400);\n\t\t}\n\n\t\tconst config: ImportConfig = JSON.parse(configJson);\n\n\t\t// Parse WXR\n\t\tconst text = await file.text();\n\t\tconst wxr = await parseWxrString(text);\n\n\t\t// Build attachment ID -> URL map for featured images\n\t\tconst attachmentMap = new Map<string, string>();\n\t\tfor (const att of wxr.attachments) {\n\t\t\tif (att.id && att.url) {\n\t\t\t\tattachmentMap.set(String(att.id), att.url);\n\t\t\t}\n\t\t}\n\n\t\t// Build author login -> display name map\n\t\tconst authorDisplayNames = new Map<string, string>();\n\t\tfor (const author of wxr.authors) {\n\t\t\tif (!author.login) continue;\n\t\t\tauthorDisplayNames.set(author.login, author.displayName || author.login);\n\t\t}\n\n\t\t// Pre-create taxonomy terms (categories, tags, custom taxonomies) so\n\t\t// per-post assignments can resolve to existing rows. Done before any\n\t\t// content insert because WXR exports list terms at the top of the\n\t\t// file but per-item assignments only reference them by slug.\n\t\tconst taxonomyPlan = await preImportWxrTaxonomies(\n\t\t\temdash.db,\n\t\t\twxr.posts,\n\t\t\twxr.categories,\n\t\t\twxr.tags,\n\t\t\twxr.terms,\n\t\t\tconfig.locale,\n\t\t);\n\n\t\t// Multilingual imports (WPML / Polylang -- see #1080) need a term\n\t\t// row at each per-post locale, all sharing the canonical term's\n\t\t// `translation_group`. Without this, `getTermsForEntry(..., locale)`\n\t\t// on non-canonical translations comes back empty.\n\t\t//\n\t\t// The mirror raises `WxrTaxonomyConflictError` with an operator-\n\t\t// actionable message when an existing locale row has an\n\t\t// incompatible group. Surface its `publicMessage` directly so the\n\t\t// admin UI can tell the user which (taxonomy, slug, locale) needs\n\t\t// reconciliation. Other errors (DB connectivity, unexpected\n\t\t// repository failures) re-throw to the outer catch where\n\t\t// `handleError` masks them with the generic \"Failed to import\n\t\t// content\" -- exposing raw DB errors to clients would leak schema\n\t\t// names and bypass the AGENTS.md \"never expose error.message\" rule.\n\t\tconst postLocales = new Set<string>();\n\t\tfor (const post of wxr.posts) {\n\t\t\tif (post.locale) postLocales.add(post.locale);\n\t\t}\n\t\tif (postLocales.size > 0) {\n\t\t\ttry {\n\t\t\t\tawait mirrorTermsToLocales(emdash.db, taxonomyPlan, postLocales, config.locale);\n\t\t\t} catch (mirrorError) {\n\t\t\t\tif (isWxrTaxonomyConflictError(mirrorError)) {\n\t\t\t\t\tconsole.error(\"[WXR_IMPORT_TAXONOMY_CONFLICT]\", mirrorError);\n\t\t\t\t\treturn apiError(\"WXR_IMPORT_TAXONOMY_CONFLICT\", mirrorError.publicMessage, 409);\n\t\t\t\t}\n\t\t\t\tthrow mirrorError;\n\t\t\t}\n\t\t}\n\n\t\t// Import content (locale from config scopes all items)\n\t\tconst result = await importContent(\n\t\t\twxr.posts,\n\t\t\tconfig,\n\t\t\temdash,\n\t\t\temdashManifest,\n\t\t\tattachmentMap,\n\t\t\tconfig.locale,\n\t\t\tauthorDisplayNames,\n\t\t\ttaxonomyPlan,\n\t\t);\n\n\t\t// Import reusable blocks as sections (if enabled)\n\t\tif (config.importSections !== false) {\n\t\t\tconst sectionsResult = await importReusableBlocksAsSections(wxr.posts, emdash.db);\n\t\t\tresult.sections = {\n\t\t\t\tcreated: sectionsResult.sectionsCreated,\n\t\t\t\tskipped: sectionsResult.sectionsSkipped,\n\t\t\t};\n\t\t\t// Add section errors to main errors array\n\t\t\tresult.errors.push(...sectionsResult.errors);\n\t\t\tif (sectionsResult.errors.length > 0) {\n\t\t\t\tresult.success = false;\n\t\t\t}\n\t\t}\n\n\t\treturn apiSuccess(result);\n\t} catch (error) {\n\t\treturn handleError(error, \"Failed to import content\", \"WXR_IMPORT_ERROR\");\n\t}\n};\n\nexport async function importContent(\n\tposts: WxrPost[],\n\tconfig: ImportConfig,\n\temdash: EmDashHandlers,\n\tmanifest: EmDashManifest,\n\tattachmentMap: Map<string, string>,\n\tlocale: string | undefined,\n\tauthorDisplayNames: Map<string, string> | undefined,\n\ttaxonomyPlan: TaxonomyImportPlan,\n): Promise<ImportResult> {\n\tconst result: ImportResult = {\n\t\tsuccess: true,\n\t\timported: 0,\n\t\tskipped: 0,\n\t\terrors: [],\n\t\tbyCollection: {},\n\t\ttaxonomies: {\n\t\t\ttermsCreated: taxonomyPlan.termsCreated,\n\t\t\ttermsReused: taxonomyPlan.termsReused,\n\t\t\tassignments: 0,\n\t\t\tmissingTaxonomies: taxonomyPlan.missingTaxonomies,\n\t\t},\n\t};\n\n\t// Create content repository for checking existing items\n\tconst contentRepo = new ContentRepository(emdash.db);\n\tconst bylineRepo = new BylineRepository(emdash.db);\n\tconst bylineCache = new Map<string, string>();\n\n\t// Source-side translation group ID -> the EmDash ID of the first post we\n\t// imported for that group. Subsequent translations are linked via\n\t// `translationOf` so they share a `translation_group` on the EmDash side.\n\tconst translationGroupMap = new Map<string, string>();\n\n\tfor (const post of posts) {\n\t\tconst postType = post.postType || \"post\";\n\t\tconst mapping = config.postTypeMappings[postType];\n\n\t\t// Skip if not mapped or disabled\n\t\tif (!mapping || !mapping.enabled) {\n\t\t\tresult.skipped++;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Defensive: mapping.collection is already sanitized by prepare, but the user\n\t\t// could manually edit the import config between prepare and execute.\n\t\tconst collection = sanitizeSlug(mapping.collection);\n\n\t\t// Check if collection exists in manifest\n\t\tif (!manifest?.collections[collection]) {\n\t\t\tresult.errors.push({\n\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\terror: `Collection \"${collection}\" does not exist`,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\ttry {\n\t\t\t// Convert content to Portable Text\n\t\t\tconst content = post.content ? gutenbergToPortableText(post.content) : [];\n\n\t\t\t// Generate slug from post name or title\n\t\t\tconst slug = post.postName || slugify(post.title || `post-${post.id || Date.now()}`);\n\n\t\t\t// Per-post locale: prefer the value extracted from WPML/Polylang\n\t\t\t// metadata; fall back to the upload-wide locale. Two translations\n\t\t\t// sharing `post_name` (e.g. /en/hello + /ar/hello) collide on the\n\t\t\t// `UNIQUE(slug, locale)` constraint when they share a locale, so\n\t\t\t// honouring the per-post value is what makes multilingual imports\n\t\t\t// land correctly. See issue #1080.\n\t\t\tconst postLocale = post.locale ?? locale;\n\n\t\t\t// Check if already exists (idempotency). Match against the\n\t\t\t// per-post locale so the same slug in different locales doesn't\n\t\t\t// false-positive as duplicate.\n\t\t\tif (config.skipExisting) {\n\t\t\t\tconst existing = await contentRepo.findBySlug(collection, slug, postLocale);\n\t\t\t\tif (existing) {\n\t\t\t\t\t// Record the translation group mapping so later\n\t\t\t\t\t// translations in this WXR can link to the existing\n\t\t\t\t\t// item. We deliberately trust the WXR's grouping over\n\t\t\t\t\t// the existing row's `translation_group`: a singleton\n\t\t\t\t\t// existing row gets folded into the WXR's group when\n\t\t\t\t\t// `handleContentCreate` resolves the new translation's\n\t\t\t\t\t// `translationOf`. Pre-existing translations that\n\t\t\t\t\t// already belong to a different group are left alone --\n\t\t\t\t\t// the user is responsible for reconciling those through\n\t\t\t\t\t// the admin if they don't match the WXR.\n\t\t\t\t\tif (post.translationGroup) {\n\t\t\t\t\t\ttranslationGroupMap.set(post.translationGroup, existing.id);\n\t\t\t\t\t}\n\t\t\t\t\tresult.skipped++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Resolve translation group: if this post belongs to a group and\n\t\t\t// we've already imported one of its translations, link to it.\n\t\t\tlet translationOf: string | undefined;\n\t\t\tif (post.translationGroup) {\n\t\t\t\ttranslationOf = translationGroupMap.get(post.translationGroup);\n\t\t\t}\n\n\t\t\t// Map WordPress status to EmDash status\n\t\t\tconst status = mapStatus(post.status);\n\n\t\t\t// Build data object with required fields\n\t\t\tconst data: Record<string, unknown> = {\n\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\tcontent,\n\t\t\t\texcerpt: post.excerpt || undefined,\n\t\t\t};\n\n\t\t\t// Only add featured_image if the collection has this field and we have a value\n\t\t\tconst collectionSchema = manifest.collections[collection];\n\t\t\tconst hasFeaturedImageField = collectionSchema?.fields\n\t\t\t\t? \"featured_image\" in collectionSchema.fields\n\t\t\t\t: false;\n\t\t\tif (hasFeaturedImageField) {\n\t\t\t\tconst thumbnailId = post.meta.get(\"_thumbnail_id\");\n\t\t\t\tconst featuredImage = thumbnailId ? attachmentMap.get(String(thumbnailId)) : undefined;\n\t\t\t\tif (featuredImage) {\n\t\t\t\t\tdata.featured_image = featuredImage;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Resolve author ID from mappings\n\t\t\tlet authorId: string | undefined;\n\t\t\tif (config.authorMappings && post.creator) {\n\t\t\t\tconst mappedUserId = config.authorMappings[post.creator];\n\t\t\t\tif (mappedUserId !== undefined && mappedUserId !== null) {\n\t\t\t\t\tauthorId = mappedUserId;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst bylineId = await resolveImportByline(\n\t\t\t\tpost.creator,\n\t\t\t\tauthorDisplayNames?.get(post.creator ?? \"\") ?? post.creator,\n\t\t\t\tauthorId,\n\t\t\t\tbylineRepo,\n\t\t\t\tbylineCache,\n\t\t\t);\n\n\t\t\t// Preserve original WordPress dates using the shared WXR date parser.\n\t\t\t// Fallback chain: postDateGmt (UTC) → pubDate (RFC 2822) → postDate (site-local).\n\t\t\tconst parsedDate = parseWxrDate(post.postDateGmt, post.pubDate, post.postDate);\n\t\t\tconst createdAt = parsedDate ? parsedDate.toISOString() : undefined;\n\t\t\tconst publishedAt = status === \"published\" && createdAt ? createdAt : undefined;\n\n\t\t\t// Create the content item\n\t\t\tconst createResult = await emdash.handleContentCreate(collection, {\n\t\t\t\tdata,\n\t\t\t\tslug,\n\t\t\t\tstatus,\n\t\t\t\tauthorId,\n\t\t\t\tbylines: bylineId ? [{ bylineId }] : undefined,\n\t\t\t\tlocale: postLocale,\n\t\t\t\ttranslationOf,\n\t\t\t\tcreatedAt,\n\t\t\t\tpublishedAt,\n\t\t\t});\n\n\t\t\tif (createResult.success) {\n\t\t\t\tresult.imported++;\n\t\t\t\tresult.byCollection[collection] = (result.byCollection[collection] || 0) + 1;\n\n\t\t\t\t// `handleContentCreate` returns `data: { item, _rev? }` on\n\t\t\t\t// success (see `ApiResult<ContentResponse>` in\n\t\t\t\t// `api/handlers/content.ts`). `HandlerResponse.data` is\n\t\t\t\t// typed as `unknown` to avoid coupling the route surface to\n\t\t\t\t// internal handler types, so we narrow here.\n\t\t\t\t// eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler contract documented at handleContentCreate\n\t\t\t\tconst createdItem = (createResult.data as { item: { id: string } } | undefined)?.item;\n\n\t\t\t\t// Track translation group: the first imported post in a group\n\t\t\t\t// becomes the anchor that later translations link to.\n\t\t\t\tif (\n\t\t\t\t\tcreatedItem &&\n\t\t\t\t\tpost.translationGroup &&\n\t\t\t\t\t!translationGroupMap.has(post.translationGroup)\n\t\t\t\t) {\n\t\t\t\t\ttranslationGroupMap.set(post.translationGroup, createdItem.id);\n\t\t\t\t}\n\n\t\t\t\t// Attach taxonomy assignments parsed from the WXR's per-item\n\t\t\t\t// <category> elements.\n\t\t\t\t//\n\t\t\t\t// Anchors (no `translationOf`) get an additive attach -- the\n\t\t\t\t// row is fresh, no inherited pivots to consider.\n\t\t\t\t//\n\t\t\t\t// Translations replace only taxonomies they explicitly carry.\n\t\t\t\t// Since assignments belong to the content translation_group,\n\t\t\t\t// that replacement is reflected in every sibling locale.\n\t\t\t\tif (createdItem) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst written = translationOf\n\t\t\t\t\t\t\t? await setPostTermAssignmentsReplacing(\n\t\t\t\t\t\t\t\t\temdash.db,\n\t\t\t\t\t\t\t\t\tcollection,\n\t\t\t\t\t\t\t\t\tcreatedItem.id,\n\t\t\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t\t\ttaxonomyPlan,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: await attachPostTaxonomies(\n\t\t\t\t\t\t\t\t\temdash.db,\n\t\t\t\t\t\t\t\t\tcollection,\n\t\t\t\t\t\t\t\t\tcreatedItem.id,\n\t\t\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t\t\ttaxonomyPlan,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\tif (result.taxonomies) {\n\t\t\t\t\t\t\tresult.taxonomies.assignments += written;\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (taxError) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`Failed to attach taxonomies for \"${post.title || \"Untitled\"}\":`,\n\t\t\t\t\t\t\ttaxError,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tresult.errors.push({\n\t\t\t\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\t\t\t\terror:\n\t\t\t\t\t\t\t\ttaxError instanceof Error && taxError.message\n\t\t\t\t\t\t\t\t\t? `Imported but failed to attach taxonomies: ${taxError.message}`\n\t\t\t\t\t\t\t\t\t: \"Imported but failed to attach taxonomies\",\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tresult.errors.push({\n\t\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\t\terror:\n\t\t\t\t\t\ttypeof createResult.error === \"object\" && createResult.error !== null\n\t\t\t\t\t\t\t? (createResult.error as { message?: string }).message || \"Unknown error\"\n\t\t\t\t\t\t\t: String(createResult.error),\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(`Import error for \"${post.title || \"Untitled\"}\":`, error);\n\t\t\tresult.errors.push({\n\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\terror: error instanceof Error && error.message ? error.message : \"Failed to import item\",\n\t\t\t});\n\t\t}\n\t}\n\n\tresult.success = result.errors.length === 0;\n\treturn result;\n}\n\nfunction mapStatus(wpStatus: string | undefined): string {\n\tswitch (wpStatus) {\n\t\tcase \"publish\":\n\t\t\treturn \"published\";\n\t\tcase \"draft\":\n\t\t\treturn \"draft\";\n\t\tcase \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AClB,OAAO,KAAK,SAAS;IACrB,OAAO,iBAAiB,SAAS,MAAM,UAAU,MAAM,UAAU;IACjE,CAAC;;;AAIJ,QAAO,UAAU,OAAO,OAAO,WAAW;AAC1C,QAAO;;AAGR,SAAS,UAAU,UAAsC;AACxD,SAAQ,UAAR;EACC,KAAK,UACJ,QAAO;EACR,KAAK,QACJ,QAAO;EACR,KAAK,UACJ,QAAO;EACR,KAAK,UACJ,QAAO;EACR,QACC,QAAO"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import "../../../../../options-
|
|
2
|
-
import "../../../../../types-
|
|
3
|
-
import "../../../../../types-
|
|
4
|
-
import "../../../../../
|
|
5
|
-
import "../../../../../
|
|
6
|
-
import "../../../../../runner-
|
|
7
|
-
import "../../../../../index-
|
|
8
|
-
import "../../../../../types-
|
|
9
|
-
import "../../../../../hreflang-
|
|
10
|
-
import "../../../../../validate-
|
|
1
|
+
import "../../../../../options-D8Y0VHc7.mjs";
|
|
2
|
+
import "../../../../../types-tJWDK__M.mjs";
|
|
3
|
+
import "../../../../../types-BouXpOsa.mjs";
|
|
4
|
+
import "../../../../../entry-lock-CGAtrwAR.mjs";
|
|
5
|
+
import "../../../../../config-CGAhyOjP.mjs";
|
|
6
|
+
import "../../../../../runner-CfwysRM0.mjs";
|
|
7
|
+
import "../../../../../index-1ECYpfiF.mjs";
|
|
8
|
+
import "../../../../../types-DaEg7KX2.mjs";
|
|
9
|
+
import "../../../../../hreflang-CQpu5bMy.mjs";
|
|
10
|
+
import "../../../../../validate-Df6Dvwbw.mjs";
|
|
11
11
|
import { EmDashHandlers } from "../../../../types.mjs";
|
|
12
12
|
import { AttachmentInfo } from "./analyze.mjs";
|
|
13
13
|
import { APIRoute } from "astro";
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import "../../../../../config-C3EBstHi.mjs";
|
|
2
2
|
import "../../../../../base64-CvLhUKQv.mjs";
|
|
3
3
|
import "../../../../../types-CQPWhPxE.mjs";
|
|
4
|
-
import "../../../../../dist-
|
|
5
|
-
import { t as enrichImageMetadata } from "../../../../../enrich-
|
|
6
|
-
import {
|
|
7
|
-
import { n as apiSuccess, r as handleError, t as apiError } from "../../../../../error-
|
|
8
|
-
import { n as parseBody, t as isParseError } from "../../../../../parse-
|
|
9
|
-
import "../../../../../media-
|
|
10
|
-
import "../../../../../
|
|
11
|
-
import { C as wpMediaImportBody } from "../../../../../relations-
|
|
12
|
-
import "../../../../../status-
|
|
4
|
+
import "../../../../../dist-BAsh8dbf.mjs";
|
|
5
|
+
import { t as enrichImageMetadata } from "../../../../../enrich-t2Xvjdqa.mjs";
|
|
6
|
+
import { a as ssrfSafeFetch, s as validateExternalUrl, t as SsrfError } from "../../../../../ssrf-gl4gFNhw.mjs";
|
|
7
|
+
import { n as apiSuccess, r as handleError, t as apiError } from "../../../../../error-BDcFyoRt.mjs";
|
|
8
|
+
import { n as parseBody, t as isParseError } from "../../../../../parse-WRg5C3NX.mjs";
|
|
9
|
+
import "../../../../../media-C1EIZKh1.mjs";
|
|
10
|
+
import "../../../../../entry-lock-DIYHAaSw.mjs";
|
|
11
|
+
import { C as wpMediaImportBody } from "../../../../../relations-rOmbndUJ.mjs";
|
|
12
|
+
import "../../../../../status-Cenfk_r5.mjs";
|
|
13
13
|
import "../../../../../api/schemas/index.mjs";
|
|
14
|
-
import "../../../../../ssrf-
|
|
15
|
-
import { r as requirePerm } from "../../../../../authorize-
|
|
14
|
+
import "../../../../../ssrf-TQhaljuI.mjs";
|
|
15
|
+
import { r as requirePerm } from "../../../../../authorize-C2QHlWSS.mjs";
|
|
16
16
|
import { ulid } from "ulidx";
|
|
17
17
|
import mime from "mime/lite";
|
|
18
18
|
import * as path from "node:path";
|