emdash 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{adapters-C0ONzkUP.d.mts → adapters-34EN2eXO.d.mts} +34 -2
- package/dist/adapters-34EN2eXO.d.mts.map +1 -0
- package/dist/after-CBU2vkoO.mjs +96 -0
- package/dist/after-CBU2vkoO.mjs.map +1 -0
- package/dist/{allowed-origins-CCEi9bPI.mjs → allowed-origins-DW7sYyqg.mjs} +2 -2
- package/dist/{allowed-origins-CCEi9bPI.mjs.map → allowed-origins-DW7sYyqg.mjs.map} +1 -1
- package/dist/api/route-utils.d.mts +3 -4
- package/dist/api/route-utils.d.mts.map +1 -1
- package/dist/api/route-utils.mjs +26 -25
- package/dist/api/route-utils.mjs.map +1 -1
- package/dist/api/schemas/index.d.mts +2 -2
- package/dist/api/schemas/index.mjs +6 -5
- package/dist/{api-DgPbMlng.mjs → api-DdAsirBe.mjs} +321 -428
- package/dist/api-DdAsirBe.mjs.map +1 -0
- package/dist/{api-tokens-p-iMzvXR.mjs → api-tokens-CFXu8F_2.mjs} +2 -2
- package/dist/{api-tokens-p-iMzvXR.mjs.map → api-tokens-CFXu8F_2.mjs.map} +1 -1
- package/dist/{apply-1_6ra7NP.mjs → apply-D5zfeD09.mjs} +139 -102
- package/dist/apply-D5zfeD09.mjs.map +1 -0
- package/dist/astro/index.d.mts +12 -12
- package/dist/astro/index.d.mts.map +1 -1
- package/dist/astro/index.mjs +103 -35
- package/dist/astro/index.mjs.map +1 -1
- package/dist/astro/middleware/auth.d.mts +10 -10
- package/dist/astro/middleware/auth.mjs +9 -9
- package/dist/astro/middleware/media-usage-write-fence.d.mts +7 -0
- package/dist/astro/middleware/media-usage-write-fence.d.mts.map +1 -0
- package/dist/astro/middleware/media-usage-write-fence.mjs +35 -0
- package/dist/astro/middleware/media-usage-write-fence.mjs.map +1 -0
- package/dist/astro/middleware/redirect.d.mts.map +1 -1
- package/dist/astro/middleware/redirect.mjs +13 -10
- package/dist/astro/middleware/redirect.mjs.map +1 -1
- package/dist/astro/middleware/request-context.mjs +5 -5
- package/dist/astro/middleware/setup.mjs +1 -1
- package/dist/astro/middleware.d.mts +12 -11
- package/dist/astro/middleware.d.mts.map +1 -1
- package/dist/astro/middleware.mjs +1915 -223
- package/dist/astro/middleware.mjs.map +1 -1
- package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +9 -8
- package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs.map +1 -1
- package/dist/astro/routes/api/admin/allowed-domains/index.mjs +9 -8
- package/dist/astro/routes/api/admin/allowed-domains/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +5 -5
- package/dist/astro/routes/api/admin/api-tokens/index.mjs +6 -6
- package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +6 -6
- package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +12 -11
- package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs.map +1 -1
- package/dist/astro/routes/api/admin/byline-fields/index.mjs +12 -11
- package/dist/astro/routes/api/admin/byline-fields/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +12 -11
- package/dist/astro/routes/api/admin/byline-fields/reorder.mjs.map +1 -1
- package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +20 -20
- package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +20 -20
- package/dist/astro/routes/api/admin/bylines/index.mjs +20 -20
- package/dist/astro/routes/api/admin/comments/_id_/status.mjs +18 -17
- package/dist/astro/routes/api/admin/comments/_id_/status.mjs.map +1 -1
- package/dist/astro/routes/api/admin/comments/_id_.mjs +8 -8
- package/dist/astro/routes/api/admin/comments/bulk.mjs +14 -13
- package/dist/astro/routes/api/admin/comments/bulk.mjs.map +1 -1
- package/dist/astro/routes/api/admin/comments/counts.mjs +8 -8
- package/dist/astro/routes/api/admin/comments/index.mjs +14 -13
- package/dist/astro/routes/api/admin/comments/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +6 -6
- package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +5 -5
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.d.mts +8 -0
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.d.mts.map +1 -0
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs +36 -0
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs.map +1 -0
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.d.mts +8 -0
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.d.mts.map +1 -0
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs +36 -0
- package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs.map +1 -0
- package/dist/astro/routes/api/admin/media-usage/repair.mjs +15 -14
- package/dist/astro/routes/api/admin/media-usage/repair.mjs.map +1 -1
- package/dist/astro/routes/api/admin/media-usage/work/index.d.mts +8 -0
- package/dist/astro/routes/api/admin/media-usage/work/index.d.mts.map +1 -0
- package/dist/astro/routes/api/admin/media-usage/work/index.mjs +37 -0
- package/dist/astro/routes/api/admin/media-usage/work/index.mjs.map +1 -0
- package/dist/astro/routes/api/admin/media-usage/work/retry.d.mts +8 -0
- package/dist/astro/routes/api/admin/media-usage/work/retry.d.mts.map +1 -0
- package/dist/astro/routes/api/admin/media-usage/work/retry.mjs +37 -0
- package/dist/astro/routes/api/admin/media-usage/work/retry.mjs.map +1 -0
- package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +5 -5
- package/dist/astro/routes/api/admin/oauth-clients/index.mjs +5 -5
- package/dist/astro/routes/api/admin/plugins/_id_/disable.d.mts.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +56 -47
- package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/enable.d.mts.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +56 -47
- package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +52 -46
- package/dist/astro/routes/api/admin/plugins/_id_/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/mcp.mjs +6 -6
- package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs +52 -46
- package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/uninstall.d.mts.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +55 -46
- package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/update.d.mts.map +1 -1
- package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +55 -46
- package/dist/astro/routes/api/admin/plugins/_id_/update.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/index.mjs +52 -46
- package/dist/astro/routes/api/admin/plugins/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +4 -4
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +52 -46
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.d.mts.map +1 -1
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +55 -46
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +52 -46
- package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.d.mts.map +1 -1
- package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs +55 -46
- 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 +56 -47
- package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs +52 -46
- 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 +56 -47
- package/dist/astro/routes/api/admin/plugins/registry/install.mjs.map +1 -1
- package/dist/astro/routes/api/admin/plugins/updates.mjs +52 -46
- package/dist/astro/routes/api/admin/plugins/updates.mjs.map +1 -1
- package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +52 -46
- package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +4 -4
- package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +52 -46
- package/dist/astro/routes/api/admin/themes/marketplace/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/users/_id_/disable.mjs +4 -4
- package/dist/astro/routes/api/admin/users/_id_/enable.mjs +3 -3
- package/dist/astro/routes/api/admin/users/_id_/index.mjs +10 -9
- package/dist/astro/routes/api/admin/users/_id_/index.mjs.map +1 -1
- package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +6 -6
- package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs.map +1 -1
- package/dist/astro/routes/api/admin/users/index.mjs +9 -8
- package/dist/astro/routes/api/admin/users/index.mjs.map +1 -1
- package/dist/astro/routes/api/auth/dev-bypass.mjs +8 -8
- package/dist/astro/routes/api/auth/invite/accept.mjs +3 -3
- package/dist/astro/routes/api/auth/invite/complete.mjs +14 -13
- package/dist/astro/routes/api/auth/invite/complete.mjs.map +1 -1
- package/dist/astro/routes/api/auth/invite/index.mjs +12 -11
- package/dist/astro/routes/api/auth/invite/index.mjs.map +1 -1
- package/dist/astro/routes/api/auth/invite/register-options.mjs +13 -12
- package/dist/astro/routes/api/auth/invite/register-options.mjs.map +1 -1
- package/dist/astro/routes/api/auth/logout.mjs +4 -4
- package/dist/astro/routes/api/auth/magic-link/send.mjs +14 -13
- package/dist/astro/routes/api/auth/magic-link/send.mjs.map +1 -1
- package/dist/astro/routes/api/auth/magic-link/verify.mjs +4 -4
- package/dist/astro/routes/api/auth/me.mjs +10 -9
- package/dist/astro/routes/api/auth/me.mjs.map +1 -1
- package/dist/astro/routes/api/auth/mode.mjs +4 -4
- package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +4 -4
- package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
- package/dist/astro/routes/api/auth/passkey/_id_.mjs +9 -8
- package/dist/astro/routes/api/auth/passkey/_id_.mjs.map +1 -1
- package/dist/astro/routes/api/auth/passkey/index.mjs +3 -3
- package/dist/astro/routes/api/auth/passkey/options.mjs +15 -14
- package/dist/astro/routes/api/auth/passkey/options.mjs.map +1 -1
- package/dist/astro/routes/api/auth/passkey/register/options.mjs +13 -12
- package/dist/astro/routes/api/auth/passkey/register/options.mjs.map +1 -1
- package/dist/astro/routes/api/auth/passkey/register/verify.mjs +14 -13
- package/dist/astro/routes/api/auth/passkey/register/verify.mjs.map +1 -1
- package/dist/astro/routes/api/auth/passkey/verify.mjs +14 -13
- package/dist/astro/routes/api/auth/passkey/verify.mjs.map +1 -1
- package/dist/astro/routes/api/auth/signup/complete.mjs +14 -13
- package/dist/astro/routes/api/auth/signup/complete.mjs.map +1 -1
- package/dist/astro/routes/api/auth/signup/request.mjs +14 -13
- package/dist/astro/routes/api/auth/signup/request.mjs.map +1 -1
- package/dist/astro/routes/api/auth/signup/verify.mjs +3 -3
- package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +20 -19
- package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs.map +1 -1
- package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +17 -16
- package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +5 -5
- package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +5 -5
- package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +15 -15
- package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +11 -10
- package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs +21 -20
- 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 +21 -20
- package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +5 -5
- package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +11 -10
- package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.d.mts.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +47 -34
- package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +5 -5
- package/dist/astro/routes/api/content/_collection_/_id_.mjs +11 -10
- package/dist/astro/routes/api/content/_collection_/_id_.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/authors.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/index.mjs +11 -10
- package/dist/astro/routes/api/content/_collection_/index.mjs.map +1 -1
- package/dist/astro/routes/api/content/_collection_/trash.mjs +10 -9
- package/dist/astro/routes/api/content/_collection_/trash.mjs.map +1 -1
- package/dist/astro/routes/api/dashboard.mjs +12 -10
- package/dist/astro/routes/api/dashboard.mjs.map +1 -1
- package/dist/astro/routes/api/dev/emails.mjs +4 -4
- package/dist/astro/routes/api/import/probe.d.mts +3 -3
- package/dist/astro/routes/api/import/probe.mjs +22 -20
- package/dist/astro/routes/api/import/probe.mjs.map +1 -1
- package/dist/astro/routes/api/import/wordpress/analyze.mjs +5 -5
- package/dist/astro/routes/api/import/wordpress/execute.d.mts +11 -11
- package/dist/astro/routes/api/import/wordpress/execute.mjs +18 -18
- package/dist/astro/routes/api/import/wordpress/execute.mjs.map +1 -1
- package/dist/astro/routes/api/import/wordpress/media.d.mts +10 -10
- package/dist/astro/routes/api/import/wordpress/media.mjs +14 -12
- package/dist/astro/routes/api/import/wordpress/media.mjs.map +1 -1
- package/dist/astro/routes/api/import/wordpress/prepare.mjs +13 -12
- package/dist/astro/routes/api/import/wordpress/prepare.mjs.map +1 -1
- package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +11 -11
- package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +15 -15
- package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
- package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +22 -20
- package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs.map +1 -1
- package/dist/astro/routes/api/import/wordpress-plugin/callback.mjs +1 -1
- package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +11 -11
- package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +32 -31
- package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs.map +1 -1
- package/dist/astro/routes/api/manifest.mjs +6 -6
- package/dist/astro/routes/api/mcp.d.mts.map +1 -1
- package/dist/astro/routes/api/mcp.mjs +174 -72
- package/dist/astro/routes/api/mcp.mjs.map +1 -1
- package/dist/astro/routes/api/media/_id_/confirm.mjs +14 -12
- package/dist/astro/routes/api/media/_id_/confirm.mjs.map +1 -1
- package/dist/astro/routes/api/media/_id_/upload.mjs +7 -7
- package/dist/astro/routes/api/media/_id_/usage.mjs +17 -16
- package/dist/astro/routes/api/media/_id_/usage.mjs.map +1 -1
- package/dist/astro/routes/api/media/_id_.mjs +16 -15
- package/dist/astro/routes/api/media/_id_.mjs.map +1 -1
- package/dist/astro/routes/api/media/file/_...key_.mjs +3 -3
- package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +4 -4
- package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +4 -4
- package/dist/astro/routes/api/media/providers/index.mjs +4 -4
- package/dist/astro/routes/api/media/upload-url.mjs +11 -10
- package/dist/astro/routes/api/media/upload-url.mjs.map +1 -1
- package/dist/astro/routes/api/media.mjs +19 -16
- package/dist/astro/routes/api/media.mjs.map +1 -1
- package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +13 -13
- package/dist/astro/routes/api/menus/_name_/items.mjs +13 -13
- package/dist/astro/routes/api/menus/_name_/reorder.mjs +13 -13
- package/dist/astro/routes/api/menus/_name_/translations.mjs +13 -13
- package/dist/astro/routes/api/menus/_name_.mjs +13 -13
- package/dist/astro/routes/api/menus/index.mjs +13 -13
- package/dist/astro/routes/api/oauth/authorize.mjs +6 -6
- package/dist/astro/routes/api/oauth/device/authorize.mjs +7 -7
- package/dist/astro/routes/api/oauth/device/code.mjs +10 -10
- package/dist/astro/routes/api/oauth/device/token.mjs +9 -9
- package/dist/astro/routes/api/oauth/register.mjs +4 -4
- package/dist/astro/routes/api/oauth/token/refresh.mjs +7 -7
- package/dist/astro/routes/api/oauth/token/revoke.mjs +7 -7
- package/dist/astro/routes/api/oauth/token.mjs +7 -7
- package/dist/astro/routes/api/openapi.json.mjs +183 -6
- package/dist/astro/routes/api/openapi.json.mjs.map +1 -1
- package/dist/astro/routes/api/plugins/_pluginId_/_...path_.d.mts.map +1 -1
- package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +8 -7
- package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs.map +1 -1
- package/dist/astro/routes/api/redirects/404s/index.mjs +14 -13
- package/dist/astro/routes/api/redirects/404s/index.mjs.map +1 -1
- package/dist/astro/routes/api/redirects/404s/summary.mjs +14 -13
- package/dist/astro/routes/api/redirects/404s/summary.mjs.map +1 -1
- package/dist/astro/routes/api/redirects/_id_.mjs +16 -14
- package/dist/astro/routes/api/redirects/_id_.mjs.map +1 -1
- package/dist/astro/routes/api/redirects/index.mjs +16 -14
- package/dist/astro/routes/api/redirects/index.mjs.map +1 -1
- package/dist/astro/routes/api/relations/_id_/index.mjs +21 -20
- package/dist/astro/routes/api/relations/_id_/index.mjs.map +1 -1
- package/dist/astro/routes/api/relations/_id_/translations.mjs +16 -15
- package/dist/astro/routes/api/relations/_id_/translations.mjs.map +1 -1
- package/dist/astro/routes/api/relations/index.mjs +21 -20
- package/dist/astro/routes/api/relations/index.mjs.map +1 -1
- package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +4 -4
- package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +5 -5
- package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +52 -46
- 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 +52 -46
- 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 +52 -46
- package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs.map +1 -1
- package/dist/astro/routes/api/schema/collections/_slug_/index.d.mts.map +1 -1
- package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +52 -46
- package/dist/astro/routes/api/schema/collections/_slug_/index.mjs.map +1 -1
- package/dist/astro/routes/api/schema/collections/index.mjs +52 -46
- package/dist/astro/routes/api/schema/collections/index.mjs.map +1 -1
- package/dist/astro/routes/api/schema/collections/reorder.d.mts +8 -0
- package/dist/astro/routes/api/schema/collections/reorder.d.mts.map +1 -0
- package/dist/astro/routes/api/schema/collections/reorder.mjs +71 -0
- package/dist/astro/routes/api/schema/collections/reorder.mjs.map +1 -0
- package/dist/astro/routes/api/schema/index.mjs +14 -11
- package/dist/astro/routes/api/schema/index.mjs.map +1 -1
- package/dist/astro/routes/api/schema/orphans/_slug_.mjs +52 -46
- package/dist/astro/routes/api/schema/orphans/_slug_.mjs.map +1 -1
- package/dist/astro/routes/api/schema/orphans/index.mjs +52 -46
- package/dist/astro/routes/api/schema/orphans/index.mjs.map +1 -1
- package/dist/astro/routes/api/search/enable.d.mts +1 -0
- package/dist/astro/routes/api/search/enable.d.mts.map +1 -1
- package/dist/astro/routes/api/search/enable.mjs +19 -15
- package/dist/astro/routes/api/search/enable.mjs.map +1 -1
- package/dist/astro/routes/api/search/index.mjs +13 -13
- package/dist/astro/routes/api/search/rebuild.mjs +15 -15
- package/dist/astro/routes/api/search/rebuild.mjs.map +1 -1
- package/dist/astro/routes/api/search/stats.mjs +9 -9
- package/dist/astro/routes/api/search/suggest.mjs +13 -13
- package/dist/astro/routes/api/sections/_slug_.mjs +13 -12
- package/dist/astro/routes/api/sections/_slug_.mjs.map +1 -1
- package/dist/astro/routes/api/sections/index.mjs +13 -12
- package/dist/astro/routes/api/sections/index.mjs.map +1 -1
- package/dist/astro/routes/api/settings/backups/archives/_name_.mjs +8 -8
- package/dist/astro/routes/api/settings/backups/archives/index.mjs +7 -7
- package/dist/astro/routes/api/settings/backups/export.mjs +8 -8
- package/dist/astro/routes/api/settings/backups/index.mjs +9 -9
- package/dist/astro/routes/api/settings/email.mjs +6 -6
- package/dist/astro/routes/api/settings.mjs +18 -17
- package/dist/astro/routes/api/settings.mjs.map +1 -1
- package/dist/astro/routes/api/setup/admin-verify.mjs +15 -14
- package/dist/astro/routes/api/setup/admin-verify.mjs.map +1 -1
- package/dist/astro/routes/api/setup/admin.mjs +14 -13
- package/dist/astro/routes/api/setup/admin.mjs.map +1 -1
- package/dist/astro/routes/api/setup/dev-bypass.mjs +34 -32
- package/dist/astro/routes/api/setup/dev-bypass.mjs.map +1 -1
- package/dist/astro/routes/api/setup/dev-reset.mjs +4 -4
- package/dist/astro/routes/api/setup/index.mjs +36 -34
- package/dist/astro/routes/api/setup/index.mjs.map +1 -1
- package/dist/astro/routes/api/setup/status.mjs +5 -5
- package/dist/astro/routes/api/snapshot.mjs +10 -10
- package/dist/astro/routes/api/taxonomies/_name_/reorder.d.mts +8 -0
- package/dist/astro/routes/api/taxonomies/_name_/reorder.d.mts.map +1 -0
- package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs +44 -0
- package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs.map +1 -0
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +19 -18
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs.map +1 -1
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +19 -18
- 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 +21 -19
- package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs.map +1 -1
- package/dist/astro/routes/api/taxonomies/_name_/translations.d.mts +8 -0
- package/dist/astro/routes/api/taxonomies/_name_/translations.d.mts.map +1 -0
- package/dist/astro/routes/api/taxonomies/_name_/translations.mjs +46 -0
- package/dist/astro/routes/api/taxonomies/_name_/translations.mjs.map +1 -0
- package/dist/astro/routes/api/taxonomies/_name_.d.mts +19 -0
- package/dist/astro/routes/api/taxonomies/_name_.d.mts.map +1 -0
- package/dist/astro/routes/api/taxonomies/_name_.mjs +88 -0
- package/dist/astro/routes/api/taxonomies/_name_.mjs.map +1 -0
- package/dist/astro/routes/api/taxonomies/index.mjs +19 -18
- package/dist/astro/routes/api/taxonomies/index.mjs.map +1 -1
- package/dist/astro/routes/api/themes/preview.mjs +8 -8
- package/dist/astro/routes/api/typegen.mjs +6 -6
- 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.mjs +10 -9
- package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs.map +1 -1
- package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +13 -12
- package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs.map +1 -1
- package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +13 -12
- package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs.map +1 -1
- package/dist/astro/routes/api/widget-areas/_name_.mjs +8 -7
- package/dist/astro/routes/api/widget-areas/_name_.mjs.map +1 -1
- package/dist/astro/routes/api/widget-areas/index.mjs +13 -12
- package/dist/astro/routes/api/widget-areas/index.mjs.map +1 -1
- package/dist/astro/routes/api/widget-components.mjs +4 -4
- package/dist/astro/routes/robots.txt.mjs +11 -10
- package/dist/astro/routes/robots.txt.mjs.map +1 -1
- package/dist/astro/routes/sitemap-_collection_.xml.mjs +14 -14
- package/dist/astro/routes/sitemap.xml.mjs +12 -11
- package/dist/astro/routes/sitemap.xml.mjs.map +1 -1
- package/dist/astro/types.d.mts +41 -17
- package/dist/astro/types.d.mts.map +1 -1
- package/dist/auth/providers/github.d.mts +1 -1
- package/dist/auth/providers/google.d.mts +1 -1
- package/dist/{authorize-R5iYYrpa.mjs → authorize-1iFJzPaZ.mjs} +2 -2
- package/dist/{authorize-R5iYYrpa.mjs.map → authorize-1iFJzPaZ.mjs.map} +1 -1
- package/dist/{backup-LpQ1V_sR.mjs → backup-LHjIAVNP.mjs} +5 -5
- package/dist/{backup-LpQ1V_sR.mjs.map → backup-LHjIAVNP.mjs.map} +1 -1
- package/dist/{base64-B-PsqheR.mjs → base64-CvLhUKQv.mjs} +1 -1
- package/dist/{base64-B-PsqheR.mjs.map → base64-CvLhUKQv.mjs.map} +1 -1
- package/dist/bundle-CBEXrBnb.mjs +663 -0
- package/dist/bundle-CBEXrBnb.mjs.map +1 -0
- package/dist/{byline-fields-T9ZLZMxJ.mjs → byline-fields-C5S8wygO.mjs} +2 -2
- package/dist/{byline-fields-T9ZLZMxJ.mjs.map → byline-fields-C5S8wygO.mjs.map} +1 -1
- package/dist/{byline-C5TAqs8N.mjs → byline-pEcoDps8.mjs} +9 -9
- package/dist/{byline-C5TAqs8N.mjs.map → byline-pEcoDps8.mjs.map} +1 -1
- package/dist/{byline-registry-BCuOp4UF.mjs → byline-registry-DDun8sxh.mjs} +4 -4
- package/dist/{byline-registry-BCuOp4UF.mjs.map → byline-registry-DDun8sxh.mjs.map} +1 -1
- package/dist/{bylines-B8-WGdja.mjs → bylines-BWemdX2k.mjs} +8 -8
- package/dist/{bylines-B8-WGdja.mjs.map → bylines-BWemdX2k.mjs.map} +1 -1
- package/dist/{bylines-DGuqBLjV.mjs → bylines-DJfSfXCL.mjs} +5 -5
- package/dist/{bylines-DGuqBLjV.mjs.map → bylines-DJfSfXCL.mjs.map} +1 -1
- package/dist/cache-CBJaDy_E.mjs +108 -0
- package/dist/cache-CBJaDy_E.mjs.map +1 -0
- package/dist/{challenge-store-BFzgFRog.mjs → challenge-store-CZyFVaad.mjs} +1 -1
- package/dist/{challenge-store-BFzgFRog.mjs.map → challenge-store-CZyFVaad.mjs.map} +1 -1
- package/dist/{chunks-D5dlPeRb.mjs → chunks-DfPax1I0.mjs} +2 -2
- package/dist/{chunks-D5dlPeRb.mjs.map → chunks-DfPax1I0.mjs.map} +1 -1
- package/dist/cli/index.mjs +193 -707
- package/dist/cli/index.mjs.map +1 -1
- package/dist/client/cf-access.d.mts +1 -1
- package/dist/client/index.d.mts +74 -4
- package/dist/client/index.d.mts.map +1 -1
- package/dist/client/index.mjs +25 -2
- package/dist/client/index.mjs.map +1 -1
- package/dist/collection-deletion-C8BugSGz.mjs +779 -0
- package/dist/collection-deletion-C8BugSGz.mjs.map +1 -0
- package/dist/{comment-DnTxxVHv.mjs → comment-Dxlep6cE.mjs} +3 -3
- package/dist/{comment-DnTxxVHv.mjs.map → comment-Dxlep6cE.mjs.map} +1 -1
- package/dist/{comment-reaction-BUlUz2bh.mjs → comment-reaction-D6qfHKBc.mjs} +2 -2
- package/dist/{comment-reaction-BUlUz2bh.mjs.map → comment-reaction-D6qfHKBc.mjs.map} +1 -1
- package/dist/{comments-QPKgK3nk.mjs → comments-CTOuhTSX.mjs} +3 -3
- package/dist/{comments-QPKgK3nk.mjs.map → comments-CTOuhTSX.mjs.map} +1 -1
- package/dist/{components-DZkL4Fx0.mjs → components-CQy3lh9x.mjs} +1 -1
- package/dist/{components-DZkL4Fx0.mjs.map → components-CQy3lh9x.mjs.map} +1 -1
- package/dist/{config-DyF3OKg_.mjs → config-C3EBstHi.mjs} +18 -2
- package/dist/config-C3EBstHi.mjs.map +1 -0
- package/dist/{content-CpfKV9QE.mjs → content-BNfwh7xX.mjs} +667 -183
- package/dist/content-BNfwh7xX.mjs.map +1 -0
- package/dist/content-list-query-DhQ84eVV.d.mts +26 -0
- package/dist/content-list-query-DhQ84eVV.d.mts.map +1 -0
- package/dist/content-refresh-DNERP4-f.mjs +2560 -0
- package/dist/content-refresh-DNERP4-f.mjs.map +1 -0
- package/dist/{context-kO4YZB03.mjs → context-DRgOvSnW.mjs} +28 -20
- package/dist/context-DRgOvSnW.mjs.map +1 -0
- package/dist/{cron-BlKIMD_e.mjs → cron-Y9aLtgrA.mjs} +1 -1
- package/dist/{cron-BlKIMD_e.mjs.map → cron-Y9aLtgrA.mjs.map} +1 -1
- package/dist/{dashboard-DoBwPnON.mjs → dashboard-CB8J89rJ.mjs} +45 -11
- package/dist/dashboard-CB8J89rJ.mjs.map +1 -0
- package/dist/db/index.d.mts +4 -4
- package/dist/db/index.mjs +3 -3
- package/dist/db/index.mjs.map +1 -1
- package/dist/db/libsql.d.mts +1 -1
- package/dist/db/postgres.d.mts +1 -1
- package/dist/db/sqlite.d.mts +1 -1
- package/dist/{db-errors-CcWLaRiR.mjs → db-errors-Cl-sKYTm.mjs} +1 -1
- package/dist/{db-errors-CcWLaRiR.mjs.map → db-errors-Cl-sKYTm.mjs.map} +1 -1
- package/dist/{default-C4v9KP56.mjs → default-DdDl3fxv.mjs} +1 -1
- package/dist/{default-C4v9KP56.mjs.map → default-DdDl3fxv.mjs.map} +1 -1
- package/dist/deferred-tasks-BMsa9F64.d.mts +9 -0
- package/dist/deferred-tasks-BMsa9F64.d.mts.map +1 -0
- package/dist/{device-flow-DhUsyJU6.mjs → device-flow-CaioYGK3.mjs} +5 -5
- package/dist/{device-flow-DhUsyJU6.mjs.map → device-flow-CaioYGK3.mjs.map} +1 -1
- package/dist/{dialect-helpers-DFwyWjTM.mjs → dialect-helpers-BSbfaO3F.mjs} +24 -16
- package/dist/dialect-helpers-BSbfaO3F.mjs.map +1 -0
- package/dist/dist-D_6CKR8z.mjs +810 -0
- package/dist/dist-D_6CKR8z.mjs.map +1 -0
- package/dist/{email-console-C-9Ng8DM.mjs → email-console-BHNjIwiB.mjs} +1 -1
- package/dist/{email-console-C-9Ng8DM.mjs.map → email-console-BHNjIwiB.mjs.map} +1 -1
- package/dist/{enrich-CFJJgxs_.mjs → enrich-_ySMEvEE.mjs} +2 -2
- package/dist/{enrich-CFJJgxs_.mjs.map → enrich-_ySMEvEE.mjs.map} +1 -1
- package/dist/{error-DmmN74gW.mjs → error-DupyJZE2.mjs} +3 -3
- package/dist/{error-DmmN74gW.mjs.map → error-DupyJZE2.mjs.map} +1 -1
- package/dist/{errors-DtEXIQQV.mjs → errors-CLUPm7aD.mjs} +15 -2
- package/dist/errors-CLUPm7aD.mjs.map +1 -0
- package/dist/{escape-CdW31WsG.mjs → escape-C_aLKP3H.mjs} +1 -1
- package/dist/{escape-CdW31WsG.mjs.map → escape-C_aLKP3H.mjs.map} +1 -1
- package/dist/{field-defs-cache-QMVnzTH6.mjs → field-defs-cache-hg6QkjV9.mjs} +5 -5
- package/dist/{field-defs-cache-QMVnzTH6.mjs.map → field-defs-cache-hg6QkjV9.mjs.map} +1 -1
- package/dist/{fts-manager-vncsZIJm.mjs → fts-manager-CZ-5dVwJ.mjs} +111 -61
- package/dist/fts-manager-CZ-5dVwJ.mjs.map +1 -0
- package/dist/{hash-Cb7U1b5M.mjs → hash-Cg0TXJPV.mjs} +1 -1
- package/dist/{hash-Cb7U1b5M.mjs.map → hash-Cg0TXJPV.mjs.map} +1 -1
- package/dist/{hreflang-CZbSx6Bg.d.mts → hreflang-D3Uehfv2.d.mts} +2 -2
- package/dist/{hreflang-CZbSx6Bg.d.mts.map → hreflang-D3Uehfv2.d.mts.map} +1 -1
- package/dist/{hreflang-Bg-zMpkr.mjs → hreflang-DNswoYsi.mjs} +7 -7
- package/dist/{hreflang-Bg-zMpkr.mjs.map → hreflang-DNswoYsi.mjs.map} +1 -1
- package/dist/{import-PKhLeXvn.mjs → import-B41u8Rot.mjs} +7 -7
- package/dist/{import-PKhLeXvn.mjs.map → import-B41u8Rot.mjs.map} +1 -1
- package/dist/{index-j9rTh3cp.d.mts → index-C3Y-rsyN.d.mts} +286 -93
- package/dist/index-C3Y-rsyN.d.mts.map +1 -0
- package/dist/{index-BeNto_Vs.d.mts → index-Cof4-Fab.d.mts} +5 -10
- package/dist/index-Cof4-Fab.d.mts.map +1 -0
- package/dist/index.d.mts +20 -19
- package/dist/index.mjs +79 -71
- package/dist/{init-lock-DJkX6Hto.mjs → init-lock-6b309ZrF.mjs} +1 -1
- package/dist/{init-lock-DJkX6Hto.mjs.map → init-lock-6b309ZrF.mjs.map} +1 -1
- package/dist/{load-BwTdWE8B.mjs → load-DmvJrtxS.mjs} +2 -2
- package/dist/{load-BwTdWE8B.mjs.map → load-DmvJrtxS.mjs.map} +1 -1
- package/dist/{loader-C1XOLV5b.mjs → loader-DLBqRiGP.mjs} +120 -64
- package/dist/loader-DLBqRiGP.mjs.map +1 -0
- package/dist/{manifest-schema-bCq54i7F.mjs → manifest-schema-BXbUAHod.mjs} +1 -1
- package/dist/{manifest-schema-bCq54i7F.mjs.map → manifest-schema-BXbUAHod.mjs.map} +1 -1
- package/dist/media/image-endpoint.mjs +1 -1
- package/dist/media/index.d.mts +1 -1
- package/dist/media/index.mjs +3 -2
- package/dist/media/index.mjs.map +1 -1
- package/dist/media/local-runtime.d.mts +12 -12
- package/dist/media/local-runtime.mjs +10 -9
- package/dist/media/local-runtime.mjs.map +1 -1
- package/dist/{media-DWIzoVFL.mjs → media-BWWWb8kg.mjs} +92 -3
- package/dist/media-BWWWb8kg.mjs.map +1 -0
- package/dist/{media-tQDZEdu7.mjs → media-CzhAn2--.mjs} +2 -2
- package/dist/{media-tQDZEdu7.mjs.map → media-CzhAn2--.mjs.map} +1 -1
- package/dist/{media-allowlist-B7TPD6aq.mjs → media-allowlist-BD6HhgXA.mjs} +14 -3
- package/dist/media-allowlist-BD6HhgXA.mjs.map +1 -0
- package/dist/{media-upload-Bc9Nc5Zf.mjs → media-upload-9yas9zGH.mjs} +11 -9
- package/dist/{media-upload-Bc9Nc5Zf.mjs.map → media-upload-9yas9zGH.mjs.map} +1 -1
- package/dist/{media-url-BCm5vBn6.mjs → media-url-BvoX88FA.mjs} +1 -1
- package/dist/{media-url-BCm5vBn6.mjs.map → media-url-BvoX88FA.mjs.map} +1 -1
- package/dist/{media-usage-DPJcNaAq.mjs → media-usage-De3qvwjc.mjs} +138 -61
- package/dist/media-usage-De3qvwjc.mjs.map +1 -0
- package/dist/media-usage-work-B9Bksh_b.mjs +152 -0
- package/dist/media-usage-work-B9Bksh_b.mjs.map +1 -0
- package/dist/media-usage-work-DrCbqBcl.mjs +424 -0
- package/dist/media-usage-work-DrCbqBcl.mjs.map +1 -0
- package/dist/media-usage-write-fence-aHEgN1zB.mjs +42 -0
- package/dist/media-usage-write-fence-aHEgN1zB.mjs.map +1 -0
- package/dist/{menus-C6qhqP4X.mjs → menus-CC-yn1F9.mjs} +554 -121
- package/dist/menus-CC-yn1F9.mjs.map +1 -0
- package/dist/{menus-BxPLFfIc.mjs → menus-fxvEDYE6.mjs} +5 -5
- package/dist/{menus-BxPLFfIc.mjs.map → menus-fxvEDYE6.mjs.map} +1 -1
- package/dist/{mode-fiXRMfeA.mjs → mode-Bpe-tNNy.mjs} +1 -1
- package/dist/{mode-fiXRMfeA.mjs.map → mode-Bpe-tNNy.mjs.map} +1 -1
- package/dist/{normalize-C-SHXmra.mjs → normalize-Bc-s_r-a.mjs} +1 -1
- package/dist/{normalize-C-SHXmra.mjs.map → normalize-Bc-s_r-a.mjs.map} +1 -1
- package/dist/{oauth-authorization-C9tFinly.mjs → oauth-authorization-BXO1MKej.mjs} +5 -5
- package/dist/{oauth-authorization-C9tFinly.mjs.map → oauth-authorization-BXO1MKej.mjs.map} +1 -1
- package/dist/{oauth-clients-BwTxE1aE.mjs → oauth-clients-C_DNqtRu.mjs} +1 -1
- package/dist/{oauth-clients-BwTxE1aE.mjs.map → oauth-clients-C_DNqtRu.mjs.map} +1 -1
- package/dist/{oauth-state-store-DaRUwPWO.mjs → oauth-state-store-DwAxMtk4.mjs} +1 -1
- package/dist/{oauth-state-store-DaRUwPWO.mjs.map → oauth-state-store-DwAxMtk4.mjs.map} +1 -1
- package/dist/{oauth-user-lookup-CzuzOSlF.mjs → oauth-user-lookup-BxfZizdk.mjs} +1 -1
- package/dist/{oauth-user-lookup-CzuzOSlF.mjs.map → oauth-user-lookup-BxfZizdk.mjs.map} +1 -1
- package/dist/object-cache/memory.d.mts +1 -1
- package/dist/{object-cache-Bok5j2ae.mjs → object-cache-71tPfV4A.mjs} +106 -5
- package/dist/object-cache-71tPfV4A.mjs.map +1 -0
- package/dist/{options-BlmBHTvX.mjs → options-CBXIHUoT.mjs} +1 -1
- package/dist/{options-BlmBHTvX.mjs.map → options-CBXIHUoT.mjs.map} +1 -1
- package/dist/{options-aeIs8WFu.d.mts → options-DRe1pIBL.d.mts} +4 -3
- package/dist/options-DRe1pIBL.d.mts.map +1 -0
- package/dist/page/index.d.mts +2 -2
- package/dist/{parse-BL49yb9D.mjs → parse-DFbuc-Fh.mjs} +2 -2
- package/dist/{parse-BL49yb9D.mjs.map → parse-DFbuc-Fh.mjs.map} +1 -1
- package/dist/{passkey-config-KMhgFjdQ.mjs → passkey-config-_2GOwwK8.mjs} +1 -1
- package/dist/{passkey-config-KMhgFjdQ.mjs.map → passkey-config-_2GOwwK8.mjs.map} +1 -1
- package/dist/{placeholder-Dxo5Zt58.d.mts → placeholder-CzW7Lshs.d.mts} +1 -1
- package/dist/{placeholder-Dxo5Zt58.d.mts.map → placeholder-CzW7Lshs.d.mts.map} +1 -1
- package/dist/plugin-types.d.mts +8 -1
- package/dist/plugin-types.d.mts.map +1 -1
- package/dist/plugin-utils.d.mts +10 -10
- package/dist/plugins/adapt-sandbox-entry.d.mts +10 -10
- package/dist/plugins/adapt-sandbox-entry.mjs +7 -4
- package/dist/plugins/adapt-sandbox-entry.mjs.map +1 -1
- package/dist/{portable-text-CNahFfj6.mjs → portable-text-DhKbDAGr.mjs} +1 -1
- package/dist/{portable-text-CNahFfj6.mjs.map → portable-text-DhKbDAGr.mjs.map} +1 -1
- package/dist/{preview-D4Jnbfx7.mjs → preview-PW-nOnq4.mjs} +2 -2
- package/dist/{preview-D4Jnbfx7.mjs.map → preview-PW-nOnq4.mjs.map} +1 -1
- package/dist/{public-url-DSGTnJFw.mjs → public-url-CWoFhQT8.mjs} +14 -3
- package/dist/public-url-CWoFhQT8.mjs.map +1 -0
- package/dist/{query-DCiXI7OZ.mjs → query-BgjfiLUQ.mjs} +38 -77
- package/dist/query-BgjfiLUQ.mjs.map +1 -0
- package/dist/{query-1xOcEy18.mjs → query-vgZNwIhh.mjs} +4 -4
- package/dist/{query-1xOcEy18.mjs.map → query-vgZNwIhh.mjs.map} +1 -1
- package/dist/{rate-limit-Vkp9gQ1Y.mjs → rate-limit-L5anykgo.mjs} +2 -2
- package/dist/{rate-limit-Vkp9gQ1Y.mjs.map → rate-limit-L5anykgo.mjs.map} +1 -1
- package/dist/{redirect-BJ6d1yHh.mjs → redirect-COsS6SWJ.mjs} +3 -3
- package/dist/{redirect-BJ6d1yHh.mjs.map → redirect-COsS6SWJ.mjs.map} +1 -1
- package/dist/{redirect-CDgfv9vh.mjs → redirect-KBNE3UEs.mjs} +1 -1
- package/dist/{redirect-CDgfv9vh.mjs.map → redirect-KBNE3UEs.mjs.map} +1 -1
- package/dist/{redirects-Cwkq2H-G.mjs → redirects-CufRQt0Q.mjs} +5 -5
- package/dist/{redirects-Cwkq2H-G.mjs.map → redirects-CufRQt0Q.mjs.map} +1 -1
- package/dist/{redirects-BOn2DIUs.mjs → redirects-cV9g7V-0.mjs} +149 -16
- package/dist/redirects-cV9g7V-0.mjs.map +1 -0
- package/dist/registry-C581V4TP.mjs +1275 -0
- package/dist/registry-C581V4TP.mjs.map +1 -0
- package/dist/{relation-DJ5DZh7B.mjs → relation-DtmAQH7s.mjs} +3 -3
- package/dist/{relation-DJ5DZh7B.mjs.map → relation-DtmAQH7s.mjs.map} +1 -1
- package/dist/{relations-C4duJnwI.mjs → relations-BBApI4e2.mjs} +3 -3
- package/dist/{relations-C4duJnwI.mjs.map → relations-BBApI4e2.mjs.map} +1 -1
- package/dist/{relations-DpTjftCl.mjs → relations-DICSyfsh.mjs} +6 -6
- package/dist/{relations-DpTjftCl.mjs.map → relations-DICSyfsh.mjs.map} +1 -1
- package/dist/{relations-DHFQGX0h.d.mts → relations-DItI3MN9.d.mts} +401 -40
- package/dist/relations-DItI3MN9.d.mts.map +1 -0
- package/dist/request-context.d.mts +3 -0
- package/dist/request-context.d.mts.map +1 -1
- package/dist/request-context.mjs.map +1 -1
- package/dist/{request-meta-DzXYYI-n.mjs → request-meta-DgZJh3zG.mjs} +2 -2
- package/dist/{request-meta-DzXYYI-n.mjs.map → request-meta-DgZJh3zG.mjs.map} +1 -1
- package/dist/{resolve-BUvFE0Lr.mjs → resolve-DOhVEvty.mjs} +2 -2
- package/dist/{resolve-BUvFE0Lr.mjs.map → resolve-DOhVEvty.mjs.map} +1 -1
- package/dist/{runner-BsI18UgP.mjs → runner-BiDvq5dv.mjs} +1404 -235
- package/dist/runner-BiDvq5dv.mjs.map +1 -0
- package/dist/{runner-CHdkERbt.d.mts → runner-CgQbELYC.d.mts} +2 -2
- package/dist/{runner-CHdkERbt.d.mts.map → runner-CgQbELYC.d.mts.map} +1 -1
- package/dist/runtime.d.mts +11 -11
- package/dist/runtime.mjs +5 -4
- package/dist/runtime.mjs.map +1 -1
- package/dist/{schema-eqZhkR0S.mjs → schema-BFyTg38T.mjs} +3 -3
- package/dist/{schema-eqZhkR0S.mjs.map → schema-BFyTg38T.mjs.map} +1 -1
- package/dist/schema-CeQSNwB3.mjs +390 -0
- package/dist/schema-CeQSNwB3.mjs.map +1 -0
- package/dist/{scopes-Be2d8bSb.mjs → scopes-BVeuhGBE.mjs} +3 -3
- package/dist/{scopes-Be2d8bSb.mjs.map → scopes-BVeuhGBE.mjs.map} +1 -1
- package/dist/{search-CeO678cp.mjs → search-BpuPKZb0.mjs} +26 -16
- package/dist/search-BpuPKZb0.mjs.map +1 -0
- package/dist/{secrets-870d-7yA.mjs → secrets-dtYs2hDo.mjs} +5 -5
- package/dist/{secrets-870d-7yA.mjs.map → secrets-dtYs2hDo.mjs.map} +1 -1
- package/dist/{sections-DSuEfirn.mjs → sections-COctk6hf.mjs} +3 -3
- package/dist/{sections-DSuEfirn.mjs.map → sections-COctk6hf.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.mjs +20 -19
- package/dist/seo/index.mjs.map +1 -1
- package/dist/{seo-C3GDfT0V.mjs → seo-AFpVvTqr.mjs} +6 -4
- package/dist/seo-AFpVvTqr.mjs.map +1 -0
- package/dist/{seo-BAPKiED8.mjs → seo-CvDxfvFb.mjs} +3 -3
- package/dist/{seo-BAPKiED8.mjs.map → seo-CvDxfvFb.mjs.map} +1 -1
- package/dist/{service-DyFT-k-R.mjs → service-xMiMSTsR.mjs} +4 -4
- package/dist/{service-DyFT-k-R.mjs.map → service-xMiMSTsR.mjs.map} +1 -1
- package/dist/{session-user-BrK2zz7S.mjs → session-user-BzVemLkw.mjs} +2 -2
- package/dist/{session-user-BrK2zz7S.mjs.map → session-user-BzVemLkw.mjs.map} +1 -1
- package/dist/{settings-DgKouY2S.mjs → settings-B372MV0p.mjs} +7 -7
- package/dist/{settings-DgKouY2S.mjs.map → settings-B372MV0p.mjs.map} +1 -1
- package/dist/{settings-CREKyj8I.mjs → settings-BE9aqn_9.mjs} +3 -3
- package/dist/{settings-CREKyj8I.mjs.map → settings-BE9aqn_9.mjs.map} +1 -1
- package/dist/{setup-complete-L7bMK2VI.mjs → setup-complete-DF7TAfD5.mjs} +2 -2
- package/dist/{setup-complete-L7bMK2VI.mjs.map → setup-complete-DF7TAfD5.mjs.map} +1 -1
- package/dist/{setup-nonce-Ct5tjWcq.mjs → setup-nonce-Do-U_cg9.mjs} +1 -1
- package/dist/{setup-nonce-Ct5tjWcq.mjs.map → setup-nonce-Do-U_cg9.mjs.map} +1 -1
- package/dist/{single-flight-cache-C2exrGAi.mjs → single-flight-cache-B0eLKS6K.mjs} +2 -2
- package/dist/{single-flight-cache-C2exrGAi.mjs.map → single-flight-cache-B0eLKS6K.mjs.map} +1 -1
- package/dist/site-url-Bowsi9T-.mjs +16 -0
- package/dist/site-url-Bowsi9T-.mjs.map +1 -0
- package/dist/slugify-B994zkXC.mjs +17 -0
- package/dist/slugify-B994zkXC.mjs.map +1 -0
- package/dist/{snapshot-BdpUJKD-.mjs → snapshot-B5h6aPMh.mjs} +2 -2
- package/dist/{snapshot-BdpUJKD-.mjs.map → snapshot-B5h6aPMh.mjs.map} +1 -1
- package/dist/{ssrf-CviKqWmq.mjs → ssrf-Cpvg_n3A.mjs} +1 -1
- package/dist/{ssrf-CviKqWmq.mjs.map → ssrf-Cpvg_n3A.mjs.map} +1 -1
- package/dist/{state-xxv6ZTMv.mjs → state-DYwPue40.mjs} +1 -1
- package/dist/{state-xxv6ZTMv.mjs.map → state-DYwPue40.mjs.map} +1 -1
- package/dist/{status-COfycGIU.mjs → status-CWVYpbD8.mjs} +1 -1
- package/dist/{status-COfycGIU.mjs.map → status-CWVYpbD8.mjs.map} +1 -1
- package/dist/storage/local.d.mts +1 -1
- package/dist/storage/local.mjs +1 -1
- package/dist/storage/s3.d.mts +1 -1
- package/dist/storage/s3.mjs +1 -1
- package/dist/{taxonomies-B61CRSha.mjs → taxonomies-B0o9ExNV.mjs} +85 -75
- package/dist/taxonomies-B0o9ExNV.mjs.map +1 -0
- package/dist/{taxonomies-Dbdki3Un.mjs → taxonomies-Dk3MAklL.mjs} +360 -56
- package/dist/taxonomies-Dk3MAklL.mjs.map +1 -0
- package/dist/taxonomy-CPeM8d2o.mjs +484 -0
- package/dist/taxonomy-CPeM8d2o.mjs.map +1 -0
- package/dist/{tokens-DVltpO2D.mjs → tokens-C39klX8R.mjs} +2 -2
- package/dist/{tokens-DVltpO2D.mjs.map → tokens-C39klX8R.mjs.map} +1 -1
- package/dist/{transaction-D0FOsb3X.mjs → transaction-NQj4VJ7Z.mjs} +1 -1
- package/dist/{transaction-D0FOsb3X.mjs.map → transaction-NQj4VJ7Z.mjs.map} +1 -1
- package/dist/{transport-BWQo0Foy.mjs → transport--CfOflrp.mjs} +1 -1
- package/dist/{transport-BWQo0Foy.mjs.map → transport--CfOflrp.mjs.map} +1 -1
- package/dist/{transport-DokJOScS.d.mts → transport-B_rfeU-a.d.mts} +1 -1
- package/dist/{transport-DokJOScS.d.mts.map → transport-B_rfeU-a.d.mts.map} +1 -1
- package/dist/{trusted-proxy-CwjQj0YG.mjs → trusted-proxy-CEVekpby.mjs} +1 -1
- package/dist/{trusted-proxy-CwjQj0YG.mjs.map → trusted-proxy-CEVekpby.mjs.map} +1 -1
- package/dist/{types-o7xo7VgH.mjs → types-75KIqzL9.mjs} +20 -3
- package/dist/types-75KIqzL9.mjs.map +1 -0
- package/dist/{types-C9P3ysxq.d.mts → types-BPuloofb.d.mts} +1 -1
- package/dist/{types-C9P3ysxq.d.mts.map → types-BPuloofb.d.mts.map} +1 -1
- package/dist/{types-BD40g7zz.mjs → types-BW1syrlw.mjs} +1 -1
- package/dist/{types-BD40g7zz.mjs.map → types-BW1syrlw.mjs.map} +1 -1
- package/dist/{types-jISEalTX.d.mts → types-C3_AbkDP.d.mts} +53 -10
- package/dist/types-C3_AbkDP.d.mts.map +1 -0
- package/dist/{types-84Bque3-.d.mts → types-CAGdePf3.d.mts} +133 -1
- package/dist/types-CAGdePf3.d.mts.map +1 -0
- package/dist/{types-CcSZCcF1.d.mts → types-CFUfyt1s.d.mts} +1 -1
- package/dist/{types-CcSZCcF1.d.mts.map → types-CFUfyt1s.d.mts.map} +1 -1
- package/dist/{types-DQLZ58GV.d.mts → types-CPx2lIGo.d.mts} +1 -1
- package/dist/{types-DQLZ58GV.d.mts.map → types-CPx2lIGo.d.mts.map} +1 -1
- package/dist/{types-XrQQ-Aex.mjs → types-CQPWhPxE.mjs} +15 -11
- package/dist/types-CQPWhPxE.mjs.map +1 -0
- package/dist/{types-BQY7VYw6.d.mts → types-Cs-TFLNf.d.mts} +28 -8
- package/dist/types-Cs-TFLNf.d.mts.map +1 -0
- package/dist/types-CtzytVXn.mjs +18 -0
- package/dist/types-CtzytVXn.mjs.map +1 -0
- package/dist/{types-DqZVPILm.d.mts → types-D4_1Ga4L.d.mts} +44 -5
- package/dist/types-D4_1Ga4L.d.mts.map +1 -0
- package/dist/{types-Dr2GLlwu.d.mts → types-DefV3OiO.d.mts} +1 -1
- package/dist/{types-Dr2GLlwu.d.mts.map → types-DefV3OiO.d.mts.map} +1 -1
- package/dist/{types-DsAMyD_o.d.mts → types-X0MThr7x.d.mts} +1 -1
- package/dist/{types-DsAMyD_o.d.mts.map → types-X0MThr7x.d.mts.map} +1 -1
- package/dist/{upload-attempts-C5yd6Gae.mjs → upload-attempts-hlne3iA1.mjs} +1 -1
- package/dist/{upload-attempts-C5yd6Gae.mjs.map → upload-attempts-hlne3iA1.mjs.map} +1 -1
- package/dist/url-pattern-BHS0V5Ng.mjs +33 -0
- package/dist/url-pattern-BHS0V5Ng.mjs.map +1 -0
- package/dist/{user-BAumEmpA.mjs → user-sHgJ62SP.mjs} +3 -3
- package/dist/{user-BAumEmpA.mjs.map → user-sHgJ62SP.mjs.map} +1 -1
- package/dist/{utils-BbUgmeZG.mjs → utils-D4vD_Y98.mjs} +3 -3
- package/dist/{utils-BbUgmeZG.mjs.map → utils-D4vD_Y98.mjs.map} +1 -1
- package/dist/{validate-Bs_wT2ul.mjs → validate-BkqIG_Uj.mjs} +24 -5
- package/dist/validate-BkqIG_Uj.mjs.map +1 -0
- package/dist/{validate-VPnKoIzW.mjs → validate-BpwoDOgt.mjs} +25 -2
- package/dist/validate-BpwoDOgt.mjs.map +1 -0
- package/dist/{validate-CdYcY-Ln.d.mts → validate-DeGtBN84.d.mts} +25 -7
- package/dist/validate-DeGtBN84.d.mts.map +1 -0
- package/dist/{validation-BngR0nit.mjs → validation-CiJb_X5o.mjs} +14 -13
- package/dist/{validation-BngR0nit.mjs.map → validation-CiJb_X5o.mjs.map} +1 -1
- package/dist/version-x0NjTScG.mjs +7 -0
- package/dist/{version-Bdfb34kk.mjs.map → version-x0NjTScG.mjs.map} +1 -1
- package/dist/{widgets-L-VndTKD.mjs → widgets-Cwzvww0W.mjs} +3 -3
- package/dist/{widgets-L-VndTKD.mjs.map → widgets-Cwzvww0W.mjs.map} +1 -1
- package/dist/{wxr-taxonomies-DueaLFd9.d.mts → wxr-taxonomies-CmC0ZsDr.d.mts} +1 -1
- package/dist/{wxr-taxonomies-DueaLFd9.d.mts.map → wxr-taxonomies-CmC0ZsDr.d.mts.map} +1 -1
- package/dist/{wxr-taxonomies-BexjtNid.mjs → wxr-taxonomies-QZjWxjyk.mjs} +13 -32
- package/dist/{wxr-taxonomies-BexjtNid.mjs.map → wxr-taxonomies-QZjWxjyk.mjs.map} +1 -1
- package/dist/{zod-generator-DMzfga3g.mjs → zod-generator-D11MhxG4.mjs} +53 -6
- package/dist/zod-generator-D11MhxG4.mjs.map +1 -0
- package/package.json +18 -7
- package/src/after.ts +6 -1
- package/src/api/errors.ts +13 -0
- package/src/api/handlers/content.ts +172 -33
- package/src/api/handlers/dashboard.ts +12 -2
- package/src/api/handlers/index.ts +16 -0
- package/src/api/handlers/manifest.ts +2 -0
- package/src/api/handlers/marketplace.ts +14 -0
- package/src/api/handlers/media-allowlist.ts +13 -2
- package/src/api/handlers/media-usage-work.ts +188 -0
- package/src/api/handlers/media-usage.ts +5 -3
- package/src/api/handlers/registry.ts +14 -0
- package/src/api/handlers/revision.ts +19 -5
- package/src/api/handlers/schema.ts +46 -3
- package/src/api/handlers/seo.ts +5 -2
- package/src/api/handlers/snapshot.ts +1 -1
- package/src/api/handlers/taxonomies.ts +446 -83
- package/src/api/media-usage-write-fence.ts +64 -0
- package/src/api/openapi/document.ts +247 -0
- package/src/api/public-url.ts +14 -2
- package/src/api/schemas/common.ts +3 -1
- package/src/api/schemas/content.ts +122 -1
- package/src/api/schemas/media-usage.ts +133 -0
- package/src/api/schemas/schema.ts +91 -3
- package/src/api/schemas/search.ts +2 -0
- package/src/api/schemas/taxonomies.ts +58 -8
- package/src/api/site-url.ts +16 -6
- package/src/api/types.ts +1 -0
- package/src/astro/integration/index.ts +55 -42
- package/src/astro/integration/routes.ts +48 -4
- package/src/astro/integration/runtime.ts +28 -0
- package/src/astro/integration/virtual-modules.ts +27 -1
- package/src/astro/integration/vite-config.ts +16 -1
- package/src/astro/middleware/media-usage-write-fence.ts +30 -0
- package/src/astro/middleware/redirect.ts +14 -12
- package/src/astro/middleware/scoped-db.ts +35 -4
- package/src/astro/middleware.ts +131 -30
- package/src/astro/routes/api/admin/comments/[id]/status.ts +1 -1
- package/src/astro/routes/api/admin/media-usage/collection-deletions/index.ts +22 -0
- package/src/astro/routes/api/admin/media-usage/collection-deletions/retry.ts +22 -0
- package/src/astro/routes/api/admin/media-usage/work/index.ts +26 -0
- package/src/astro/routes/api/admin/media-usage/work/retry.ts +26 -0
- package/src/astro/routes/api/admin/plugins/[id]/disable.ts +4 -0
- package/src/astro/routes/api/admin/plugins/[id]/enable.ts +4 -0
- package/src/astro/routes/api/admin/plugins/[id]/uninstall.ts +4 -0
- package/src/astro/routes/api/admin/plugins/[id]/update.ts +4 -0
- package/src/astro/routes/api/admin/plugins/marketplace/[id]/install.ts +4 -0
- package/src/astro/routes/api/admin/plugins/registry/[id]/uninstall.ts +4 -0
- package/src/astro/routes/api/admin/plugins/registry/[id]/update.ts +4 -0
- package/src/astro/routes/api/admin/plugins/registry/install.ts +4 -0
- package/src/astro/routes/api/admin/users/[id]/send-recovery.ts +2 -2
- package/src/astro/routes/api/auth/invite/index.ts +2 -2
- package/src/astro/routes/api/auth/magic-link/send.ts +2 -2
- package/src/astro/routes/api/auth/signup/request.ts +2 -2
- package/src/astro/routes/api/comments/[collection]/[contentId]/index.ts +1 -1
- package/src/astro/routes/api/content/[collection]/[id]/terms/[taxonomy].ts +67 -31
- package/src/astro/routes/api/import/wordpress/execute.ts +3 -10
- package/src/astro/routes/api/mcp.ts +1 -0
- package/src/astro/routes/api/plugins/[pluginId]/[...path].ts +7 -1
- package/src/astro/routes/api/schema/collections/[slug]/index.ts +1 -7
- package/src/astro/routes/api/schema/collections/reorder.ts +31 -0
- package/src/astro/routes/api/schema/index.ts +2 -0
- package/src/astro/routes/api/search/enable.ts +5 -1
- package/src/astro/routes/api/search/rebuild.ts +6 -1
- package/src/astro/routes/api/taxonomies/[name]/reorder.ts +41 -0
- package/src/astro/routes/api/taxonomies/[name]/terms/index.ts +1 -0
- package/src/astro/routes/api/taxonomies/[name]/translations.ts +48 -0
- package/src/astro/routes/api/taxonomies/[name].ts +102 -0
- package/src/astro/types.ts +31 -4
- package/src/cleanup.ts +25 -26
- package/src/cli/commands/dev.ts +13 -3
- package/src/cli/commands/doctor.ts +193 -6
- package/src/cli/commands/export-seed.ts +6 -1
- package/src/cli/index.ts +1 -1
- package/src/client/index.ts +119 -0
- package/src/components/Block.astro +12 -0
- package/src/components/CommentForm.astro +1 -1
- package/src/components/Comments.astro +1 -1
- package/src/components/InlinePortableTextEditor.tsx +260 -32
- package/src/components/OrderedList.astro +14 -0
- package/src/components/PortableText.astro +26 -4
- package/src/components/index.ts +12 -1
- package/src/components/ordered-list.ts +549 -0
- package/src/content/converters/mark-safety.ts +120 -0
- package/src/content/converters/numbered-list.ts +148 -0
- package/src/content/converters/portable-text-to-prosemirror.ts +84 -25
- package/src/content/converters/prosemirror-to-portable-text.ts +35 -14
- package/src/content/converters/types.ts +2 -0
- package/src/content/portable-text-lists.ts +205 -0
- package/src/content-list-query.ts +29 -0
- package/src/database/dialect-helpers.ts +3 -22
- package/src/database/migrations/055_content_translation_group_locale_index.ts +67 -0
- package/src/database/migrations/056_taxonomy_term_sort_order.ts +189 -0
- package/src/database/migrations/057_collection_hidden.ts +24 -0
- package/src/database/migrations/058_collection_sort_order.ts +20 -0
- package/src/database/migrations/059_revision_prune_queue.ts +36 -0
- package/src/database/migrations/060_collection_admin_config.ts +16 -0
- package/src/database/migrations/061_media_usage_cleanup.ts +77 -0
- package/src/database/migrations/062_media_usage_cleanup_fence.ts +295 -0
- package/src/database/migrations/063_media_usage_incremental_work.ts +397 -0
- package/src/database/migrations/064_fts_plain_text.ts +253 -0
- package/src/database/migrations/065_media_usage_collection_deletion.ts +85 -0
- package/src/database/migrations/066_media_usage_reconciliation.ts +115 -0
- package/src/database/migrations/067_indexed_content_fields.ts +39 -0
- package/src/database/migrations/068_content_taxonomy_entry_groups.ts +61 -0
- package/src/database/migrations/069_collection_title_date_fields.ts +45 -0
- package/src/database/migrations/070_collection_routable.ts +18 -0
- package/src/database/migrations/runner.ts +32 -0
- package/src/database/repositories/content.ts +1051 -273
- package/src/database/repositories/media-usage-work.ts +848 -0
- package/src/database/repositories/media-usage.ts +1502 -138
- package/src/database/repositories/revision.ts +98 -22
- package/src/database/repositories/taxonomy.ts +429 -103
- package/src/database/repositories/types.ts +58 -2
- package/src/database/types.ts +147 -17
- package/src/database/validate.ts +39 -0
- package/src/db/adapters.ts +36 -0
- package/src/db/index.ts +3 -0
- package/src/deferred-tasks.ts +71 -0
- package/src/emdash-runtime.ts +493 -110
- package/src/fields/file.ts +7 -4
- package/src/fields/image.ts +8 -1
- package/src/fields/types.ts +18 -5
- package/src/i18n/config.ts +32 -0
- package/src/i18n/repair-locale-casing.ts +0 -14
- package/src/i18n/taxonomy-locale-diagnostic.ts +47 -0
- package/src/import/wxr-taxonomies.ts +7 -47
- package/src/index.ts +27 -2
- package/src/loader.ts +165 -89
- package/src/mcp/server.ts +242 -34
- package/src/media/usage/activation.ts +626 -0
- package/src/media/usage/capture-triggers.ts +543 -0
- package/src/media/usage/cleanup.ts +305 -0
- package/src/media/usage/collection-deletion-processor.ts +356 -0
- package/src/media/usage/collection-deletion.ts +836 -0
- package/src/media/usage/content-fields.ts +40 -3
- package/src/media/usage/content-refresh.ts +356 -47
- package/src/media/usage/content-repair.ts +180 -61
- package/src/media/usage/content-snapshots.ts +85 -105
- package/src/media/usage/gc.ts +50 -0
- package/src/media/usage/projection-fingerprint.ts +129 -0
- package/src/media/usage/reconciliation-processor.ts +372 -0
- package/src/media/usage/reconciliation.ts +1117 -0
- package/src/media/usage/source-key.ts +4 -0
- package/src/media/usage/types.ts +2 -0
- package/src/media/usage/work-processor.ts +248 -0
- package/src/menus/index.ts +246 -141
- package/src/object-cache/index.ts +160 -3
- package/src/plugin-types.ts +8 -0
- package/src/plugins/adapt-sandbox-entry.ts +24 -5
- package/src/plugins/context.ts +24 -7
- package/src/plugins/index.ts +9 -0
- package/src/plugins/routes.ts +77 -1
- package/src/plugins/sandbox/index.ts +10 -1
- package/src/plugins/sandbox/types.ts +78 -1
- package/src/plugins/scheduler/node.ts +13 -1
- package/src/plugins/scheduler/types.ts +2 -0
- package/src/plugins/storage-indexes.ts +50 -11
- package/src/plugins/types.ts +39 -2
- package/src/query.ts +50 -79
- package/src/redirects/cache.ts +79 -19
- package/src/request-context.ts +3 -0
- package/src/scheduled-publish.ts +6 -1
- package/src/scheduler-health.ts +46 -0
- package/src/schema/registry.ts +863 -249
- package/src/schema/types.ts +74 -8
- package/src/schema/url-pattern.ts +33 -0
- package/src/schema/zod-generator.ts +77 -5
- package/src/search/fts-manager.ts +167 -86
- package/src/search/index.ts +2 -0
- package/src/search/query.ts +32 -11
- package/src/search/types.ts +8 -0
- package/src/seed/apply.ts +89 -16
- package/src/seed/types.ts +21 -3
- package/src/seed/validate.ts +52 -2
- package/src/taxonomies/index.ts +88 -82
- package/src/taxonomies/term-counts.ts +23 -12
- package/src/ui-comments.ts +19 -0
- package/src/ui.ts +11 -3
- package/src/utils/slugify.ts +1 -29
- package/src/virtual-modules.d.ts +24 -0
- package/dist/adapters-C0ONzkUP.d.mts.map +0 -1
- package/dist/after-B1IIdH3Y.mjs +0 -29
- package/dist/after-B1IIdH3Y.mjs.map +0 -1
- package/dist/api-DgPbMlng.mjs.map +0 -1
- package/dist/apply-1_6ra7NP.mjs.map +0 -1
- package/dist/cache-B26cufFd.mjs +0 -65
- package/dist/cache-B26cufFd.mjs.map +0 -1
- package/dist/config-DyF3OKg_.mjs.map +0 -1
- package/dist/content-CpfKV9QE.mjs.map +0 -1
- package/dist/content-refresh-DgqUBeTv.mjs +0 -1629
- package/dist/content-refresh-DgqUBeTv.mjs.map +0 -1
- package/dist/context-kO4YZB03.mjs.map +0 -1
- package/dist/dashboard-DoBwPnON.mjs.map +0 -1
- package/dist/dialect-helpers-DFwyWjTM.mjs.map +0 -1
- package/dist/errors-DtEXIQQV.mjs.map +0 -1
- package/dist/fts-manager-vncsZIJm.mjs.map +0 -1
- package/dist/index-BeNto_Vs.d.mts.map +0 -1
- package/dist/index-j9rTh3cp.d.mts.map +0 -1
- package/dist/loader-C1XOLV5b.mjs.map +0 -1
- package/dist/media-DWIzoVFL.mjs.map +0 -1
- package/dist/media-allowlist-B7TPD6aq.mjs.map +0 -1
- package/dist/media-usage-DPJcNaAq.mjs.map +0 -1
- package/dist/menus-C6qhqP4X.mjs.map +0 -1
- package/dist/object-cache-Bok5j2ae.mjs.map +0 -1
- package/dist/options-aeIs8WFu.d.mts.map +0 -1
- package/dist/public-url-DSGTnJFw.mjs.map +0 -1
- package/dist/query-DCiXI7OZ.mjs.map +0 -1
- package/dist/redirects-BOn2DIUs.mjs.map +0 -1
- package/dist/registry-BP1JK2xh.mjs +0 -795
- package/dist/registry-BP1JK2xh.mjs.map +0 -1
- package/dist/relations-DHFQGX0h.d.mts.map +0 -1
- package/dist/runner-BsI18UgP.mjs.map +0 -1
- package/dist/search-CeO678cp.mjs.map +0 -1
- package/dist/seo-C3GDfT0V.mjs.map +0 -1
- package/dist/site-url-8N3kSyVZ.mjs +0 -13
- package/dist/site-url-8N3kSyVZ.mjs.map +0 -1
- package/dist/slugify-C_tqlU4G.mjs +0 -30
- package/dist/slugify-C_tqlU4G.mjs.map +0 -1
- package/dist/taxonomies-B61CRSha.mjs.map +0 -1
- package/dist/taxonomies-Dbdki3Un.mjs.map +0 -1
- package/dist/taxonomy-DvwWAPvA.mjs +0 -304
- package/dist/taxonomy-DvwWAPvA.mjs.map +0 -1
- package/dist/types-84Bque3-.d.mts.map +0 -1
- package/dist/types-BQY7VYw6.d.mts.map +0 -1
- package/dist/types-DqZVPILm.d.mts.map +0 -1
- package/dist/types-XrQQ-Aex.mjs.map +0 -1
- package/dist/types-jISEalTX.d.mts.map +0 -1
- package/dist/types-o7xo7VgH.mjs.map +0 -1
- package/dist/validate-Bs_wT2ul.mjs.map +0 -1
- package/dist/validate-CdYcY-Ln.d.mts.map +0 -1
- package/dist/validate-VPnKoIzW.mjs.map +0 -1
- package/dist/version-Bdfb34kk.mjs +0 -7
- package/dist/zod-generator-DMzfga3g.mjs.map +0 -1
- /package/dist/{api-tokens-CEsW_jCg.mjs → api-tokens-CyTsLszZ.mjs} +0 -0
- /package/dist/{ssrf-BB__xfNM.mjs → ssrf-DpXgKsna.mjs} +0 -0
- /package/dist/{types-CK0LxPUQ.mjs → types-CP1CflWf.mjs} +0 -0
|
@@ -0,0 +1,1117 @@
|
|
|
1
|
+
import { sql, type Kysely, type RawBuilder, type Selectable } from "kysely";
|
|
2
|
+
import { ulid } from "ulidx";
|
|
3
|
+
|
|
4
|
+
import { isPostgres } from "../../database/dialect-helpers.js";
|
|
5
|
+
import type { Database, MediaUsageReconciliationTable } from "../../database/types.js";
|
|
6
|
+
import { validateIdentifier } from "../../database/validate.js";
|
|
7
|
+
|
|
8
|
+
const ACTIVATION_KEY = "incremental_capture";
|
|
9
|
+
const CONTENT_ADAPTER_ID = "content-media";
|
|
10
|
+
const COLLECTION_SCOPE = "collection";
|
|
11
|
+
const MAX_CANDIDATES = 100;
|
|
12
|
+
const MAX_PORTABLE_DURATION_SECONDS = 365 * 24 * 60 * 60;
|
|
13
|
+
const STABLE_ERROR_CODE_PATTERN = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
14
|
+
|
|
15
|
+
export type MediaUsageReconciliationState = "pending" | "retry" | "leased" | "failed";
|
|
16
|
+
export type MediaUsageReconciliationPhase = "scan" | "sources";
|
|
17
|
+
|
|
18
|
+
export interface MediaUsageReconciliationRecord {
|
|
19
|
+
collectionId: string;
|
|
20
|
+
collectionSlug: string;
|
|
21
|
+
runToken: string;
|
|
22
|
+
targetEpoch: number | string | null;
|
|
23
|
+
fieldFingerprint: string | null;
|
|
24
|
+
state: MediaUsageReconciliationState;
|
|
25
|
+
phase: MediaUsageReconciliationPhase;
|
|
26
|
+
scanCursor: string | null;
|
|
27
|
+
scanUpperId: string | null;
|
|
28
|
+
sourceCursor: string | null;
|
|
29
|
+
sourceUpperKey: string | null;
|
|
30
|
+
attemptCount: number;
|
|
31
|
+
nextAttemptAt: string;
|
|
32
|
+
leaseToken: string | null;
|
|
33
|
+
leaseExpiresAt: string | null;
|
|
34
|
+
lastErrorCode: string | null;
|
|
35
|
+
createdAt: string;
|
|
36
|
+
updatedAt: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface MediaUsageReconciliationClaim extends MediaUsageReconciliationRecord {
|
|
40
|
+
leaseToken: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface MediaUsageReconciliationSourceCandidate {
|
|
44
|
+
sourceKey: string;
|
|
45
|
+
contentId: string | null;
|
|
46
|
+
sourceVariant: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type MediaUsageReconciliationWorkBarrier =
|
|
50
|
+
| { state: "empty" }
|
|
51
|
+
| { state: "pending" }
|
|
52
|
+
| { state: "failed"; errorCode: string };
|
|
53
|
+
|
|
54
|
+
export class MediaUsageReconciliationRepository {
|
|
55
|
+
constructor(private db: Kysely<Database>) {}
|
|
56
|
+
|
|
57
|
+
async findByIdentity(
|
|
58
|
+
collectionId: string,
|
|
59
|
+
runToken: string,
|
|
60
|
+
): Promise<MediaUsageReconciliationRecord | null> {
|
|
61
|
+
assertIdentity({ collectionId, runToken });
|
|
62
|
+
const row = await this.db
|
|
63
|
+
.selectFrom("_emdash_media_usage_reconciliations")
|
|
64
|
+
.selectAll()
|
|
65
|
+
.where("collection_id", "=", collectionId)
|
|
66
|
+
.where("run_token", "=", runToken)
|
|
67
|
+
.executeTakeFirst();
|
|
68
|
+
return row ? rowToRecord(row) : null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async beginRun(claim: MediaUsageReconciliationClaim): Promise<number | string | null> {
|
|
72
|
+
const now = timestampOffset(this.db, 0);
|
|
73
|
+
const sameRun = sql<boolean>`status = 'running' AND cursor = ${claim.runToken}`;
|
|
74
|
+
const row = await this.db
|
|
75
|
+
.updateTable("_emdash_media_usage_index_status as status")
|
|
76
|
+
.set({
|
|
77
|
+
status: "running",
|
|
78
|
+
started_at: sql<string | null>`CASE WHEN ${sameRun} THEN started_at ELSE ${now} END`,
|
|
79
|
+
completed_at: null,
|
|
80
|
+
cursor: claim.runToken,
|
|
81
|
+
indexed_source_count: 0,
|
|
82
|
+
failed_source_count: 0,
|
|
83
|
+
last_error_code: null,
|
|
84
|
+
change_epoch: sql<number>`CASE WHEN ${sameRun} THEN change_epoch ELSE change_epoch + 1 END`,
|
|
85
|
+
reconciliation_required: 1,
|
|
86
|
+
updated_at: now,
|
|
87
|
+
})
|
|
88
|
+
.where("status.adapter_id", "=", CONTENT_ADAPTER_ID)
|
|
89
|
+
.where("status.scope_type", "=", COLLECTION_SCOPE)
|
|
90
|
+
.where("status.collection_id", "=", claim.collectionId)
|
|
91
|
+
.where("status.scope_key", "=", claim.collectionSlug)
|
|
92
|
+
.where("status.capture_state", "=", "active")
|
|
93
|
+
.where("status.reconciliation_required", "=", 1)
|
|
94
|
+
.where((eb) =>
|
|
95
|
+
eb.or([eb("status.status", "!=", "running"), eb("status.cursor", "=", claim.runToken)]),
|
|
96
|
+
)
|
|
97
|
+
.where(this.liveClaimExists(claim))
|
|
98
|
+
.returning("change_epoch")
|
|
99
|
+
.executeTakeFirst();
|
|
100
|
+
return row?.change_epoch ?? null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async findScanUpperId(claim: MediaUsageReconciliationClaim): Promise<string | null> {
|
|
104
|
+
const tableName = contentTableName(claim.collectionSlug);
|
|
105
|
+
const result = await sql<{ id: string }>`
|
|
106
|
+
SELECT content.id
|
|
107
|
+
FROM ${sql.ref(tableName)} AS content
|
|
108
|
+
WHERE ${this.liveClaimExistsSql(claim)}
|
|
109
|
+
ORDER BY content.id DESC
|
|
110
|
+
LIMIT 1
|
|
111
|
+
`.execute(this.db);
|
|
112
|
+
return result.rows[0]?.id ?? null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async initializeScan(input: {
|
|
116
|
+
claim: MediaUsageReconciliationClaim;
|
|
117
|
+
targetEpoch: number | string;
|
|
118
|
+
fieldFingerprint: string;
|
|
119
|
+
scanUpperId: string | null;
|
|
120
|
+
}): Promise<boolean> {
|
|
121
|
+
const result = await this.db
|
|
122
|
+
.updateTable("_emdash_media_usage_reconciliations as reconciliation")
|
|
123
|
+
.set({
|
|
124
|
+
target_epoch: input.targetEpoch,
|
|
125
|
+
field_fingerprint: input.fieldFingerprint,
|
|
126
|
+
phase: "scan",
|
|
127
|
+
scan_cursor: null,
|
|
128
|
+
scan_upper_id: input.scanUpperId,
|
|
129
|
+
source_cursor: null,
|
|
130
|
+
source_upper_key: null,
|
|
131
|
+
attempt_count: 0,
|
|
132
|
+
last_error_code: null,
|
|
133
|
+
updated_at: timestampOffset(this.db, 0),
|
|
134
|
+
})
|
|
135
|
+
.where("reconciliation.collection_id", "=", input.claim.collectionId)
|
|
136
|
+
.where("reconciliation.run_token", "=", input.claim.runToken)
|
|
137
|
+
.where("reconciliation.target_epoch", "is", null)
|
|
138
|
+
.where("reconciliation.state", "=", "leased")
|
|
139
|
+
.where("reconciliation.lease_token", "=", input.claim.leaseToken)
|
|
140
|
+
.where(liveLease(this.db))
|
|
141
|
+
.where(this.statusOwnsRun(input.claim, input.targetEpoch))
|
|
142
|
+
.executeTakeFirst();
|
|
143
|
+
return Number(result.numUpdatedRows ?? 0) === 1;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async findScanPage(
|
|
147
|
+
reconciliation: MediaUsageReconciliationRecord,
|
|
148
|
+
limit: number,
|
|
149
|
+
): Promise<string[]> {
|
|
150
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 50) {
|
|
151
|
+
throw new Error("Reconciliation scan page limit must be from 1 to 50");
|
|
152
|
+
}
|
|
153
|
+
if (!reconciliation.leaseToken || reconciliation.targetEpoch === null) return [];
|
|
154
|
+
const tableName = contentTableName(reconciliation.collectionSlug);
|
|
155
|
+
const lowerBound = reconciliation.scanCursor
|
|
156
|
+
? sql`AND content.id > ${reconciliation.scanCursor}`
|
|
157
|
+
: sql``;
|
|
158
|
+
const upperBound = reconciliation.scanUpperId
|
|
159
|
+
? sql`AND content.id <= ${reconciliation.scanUpperId}`
|
|
160
|
+
: sql`AND 1 = 0`;
|
|
161
|
+
const result = await sql<{ id: string }>`
|
|
162
|
+
SELECT content.id
|
|
163
|
+
FROM ${sql.ref(tableName)} AS content
|
|
164
|
+
WHERE 1 = 1
|
|
165
|
+
${lowerBound}
|
|
166
|
+
${upperBound}
|
|
167
|
+
AND ${this.liveClaimExistsSql(reconciliation)}
|
|
168
|
+
ORDER BY content.id ASC
|
|
169
|
+
LIMIT ${limit}
|
|
170
|
+
`.execute(this.db);
|
|
171
|
+
return result.rows.map((row) => row.id);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async checkpointScan(input: {
|
|
175
|
+
claim: MediaUsageReconciliationClaim;
|
|
176
|
+
targetEpoch: number | string;
|
|
177
|
+
previousCursor: string | null;
|
|
178
|
+
nextCursor: string;
|
|
179
|
+
}): Promise<boolean> {
|
|
180
|
+
let query = this.db
|
|
181
|
+
.updateTable("_emdash_media_usage_reconciliations as reconciliation")
|
|
182
|
+
.set({
|
|
183
|
+
scan_cursor: input.nextCursor,
|
|
184
|
+
attempt_count: 0,
|
|
185
|
+
last_error_code: null,
|
|
186
|
+
updated_at: timestampOffset(this.db, 0),
|
|
187
|
+
})
|
|
188
|
+
.where("reconciliation.collection_id", "=", input.claim.collectionId)
|
|
189
|
+
.where("reconciliation.run_token", "=", input.claim.runToken)
|
|
190
|
+
.where("reconciliation.target_epoch", "=", input.targetEpoch)
|
|
191
|
+
.where("reconciliation.state", "=", "leased")
|
|
192
|
+
.where("reconciliation.phase", "=", "scan")
|
|
193
|
+
.where("reconciliation.lease_token", "=", input.claim.leaseToken)
|
|
194
|
+
.where(liveLease(this.db))
|
|
195
|
+
.where(this.statusOwnsRun(input.claim, input.targetEpoch));
|
|
196
|
+
query = input.previousCursor
|
|
197
|
+
? query.where("reconciliation.scan_cursor", "=", input.previousCursor)
|
|
198
|
+
: query.where("reconciliation.scan_cursor", "is", null);
|
|
199
|
+
const result = await query.executeTakeFirst();
|
|
200
|
+
return Number(result.numUpdatedRows ?? 0) === 1;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async ownsRun(
|
|
204
|
+
claim: MediaUsageReconciliationClaim,
|
|
205
|
+
targetEpoch: number | string,
|
|
206
|
+
): Promise<boolean> {
|
|
207
|
+
const result = await sql<{ owned: boolean | number }>`
|
|
208
|
+
SELECT ${this.statusOwnsRun(claim, targetEpoch)} AS owned
|
|
209
|
+
`.execute(this.db);
|
|
210
|
+
return Boolean(result.rows[0]?.owned);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async restartRun(
|
|
214
|
+
claim: MediaUsageReconciliationClaim,
|
|
215
|
+
previousEpoch: number | string,
|
|
216
|
+
): Promise<number | string | null> {
|
|
217
|
+
const now = timestampOffset(this.db, 0);
|
|
218
|
+
const interruptedRestart = sql<boolean>`status = 'running'
|
|
219
|
+
AND cursor = ${claim.runToken}
|
|
220
|
+
AND change_epoch > ${previousEpoch}`;
|
|
221
|
+
const row = await this.db
|
|
222
|
+
.updateTable("_emdash_media_usage_index_status as status")
|
|
223
|
+
.set({
|
|
224
|
+
status: "running",
|
|
225
|
+
started_at: sql<
|
|
226
|
+
string | null
|
|
227
|
+
>`CASE WHEN ${interruptedRestart} THEN started_at ELSE ${now} END`,
|
|
228
|
+
completed_at: null,
|
|
229
|
+
cursor: claim.runToken,
|
|
230
|
+
last_error_code: null,
|
|
231
|
+
change_epoch: sql<number>`CASE WHEN ${interruptedRestart} THEN change_epoch ELSE change_epoch + 1 END`,
|
|
232
|
+
reconciliation_required: 1,
|
|
233
|
+
updated_at: now,
|
|
234
|
+
})
|
|
235
|
+
.where("status.adapter_id", "=", CONTENT_ADAPTER_ID)
|
|
236
|
+
.where("status.scope_type", "=", COLLECTION_SCOPE)
|
|
237
|
+
.where("status.collection_id", "=", claim.collectionId)
|
|
238
|
+
.where("status.scope_key", "=", claim.collectionSlug)
|
|
239
|
+
.where("status.capture_state", "=", "active")
|
|
240
|
+
.where("status.reconciliation_required", "=", 1)
|
|
241
|
+
.where((eb) =>
|
|
242
|
+
eb.or([eb("status.status", "!=", "running"), eb("status.cursor", "=", claim.runToken)]),
|
|
243
|
+
)
|
|
244
|
+
.where(this.liveClaimExists(claim))
|
|
245
|
+
.returning("change_epoch")
|
|
246
|
+
.executeTakeFirst();
|
|
247
|
+
return row?.change_epoch ?? null;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
async restartScan(input: {
|
|
251
|
+
claim: MediaUsageReconciliationClaim;
|
|
252
|
+
previousEpoch: number | string;
|
|
253
|
+
targetEpoch: number | string;
|
|
254
|
+
fieldFingerprint: string;
|
|
255
|
+
scanUpperId: string | null;
|
|
256
|
+
}): Promise<boolean> {
|
|
257
|
+
const result = await this.db
|
|
258
|
+
.updateTable("_emdash_media_usage_reconciliations as reconciliation")
|
|
259
|
+
.set({
|
|
260
|
+
target_epoch: input.targetEpoch,
|
|
261
|
+
field_fingerprint: input.fieldFingerprint,
|
|
262
|
+
phase: "scan",
|
|
263
|
+
scan_cursor: null,
|
|
264
|
+
scan_upper_id: input.scanUpperId,
|
|
265
|
+
source_cursor: null,
|
|
266
|
+
source_upper_key: null,
|
|
267
|
+
attempt_count: 0,
|
|
268
|
+
next_attempt_at: timestampOffset(this.db, 0),
|
|
269
|
+
last_error_code: null,
|
|
270
|
+
updated_at: timestampOffset(this.db, 0),
|
|
271
|
+
})
|
|
272
|
+
.where("reconciliation.collection_id", "=", input.claim.collectionId)
|
|
273
|
+
.where("reconciliation.run_token", "=", input.claim.runToken)
|
|
274
|
+
.where("reconciliation.target_epoch", "=", input.previousEpoch)
|
|
275
|
+
.where("reconciliation.state", "=", "leased")
|
|
276
|
+
.where("reconciliation.lease_token", "=", input.claim.leaseToken)
|
|
277
|
+
.where(liveLease(this.db))
|
|
278
|
+
.where(this.statusOwnsRun(input.claim, input.targetEpoch))
|
|
279
|
+
.executeTakeFirst();
|
|
280
|
+
return Number(result.numUpdatedRows ?? 0) === 1;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
async findWorkBarrier(collectionId: string): Promise<MediaUsageReconciliationWorkBarrier> {
|
|
284
|
+
if (!collectionId) throw new Error("Reconciliation work barrier requires a collection ID");
|
|
285
|
+
const failed = await this.db
|
|
286
|
+
.selectFrom("_emdash_media_usage_work")
|
|
287
|
+
.select("last_error_code")
|
|
288
|
+
.where("collection_id", "=", collectionId)
|
|
289
|
+
.where("state", "=", "failed")
|
|
290
|
+
.orderBy("content_id")
|
|
291
|
+
.limit(1)
|
|
292
|
+
.executeTakeFirst();
|
|
293
|
+
if (failed) {
|
|
294
|
+
return {
|
|
295
|
+
state: "failed",
|
|
296
|
+
errorCode: failed.last_error_code ?? "MEDIA_USAGE_PROCESSING_FAILED",
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
const pending = await this.db
|
|
300
|
+
.selectFrom("_emdash_media_usage_work")
|
|
301
|
+
.select("content_id")
|
|
302
|
+
.where("collection_id", "=", collectionId)
|
|
303
|
+
.limit(1)
|
|
304
|
+
.executeTakeFirst();
|
|
305
|
+
return pending ? { state: "pending" } : { state: "empty" };
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
async findSourceUpperKey(
|
|
309
|
+
claim: MediaUsageReconciliationClaim,
|
|
310
|
+
targetEpoch: number | string,
|
|
311
|
+
): Promise<string | null> {
|
|
312
|
+
const row = await this.db
|
|
313
|
+
.selectFrom("_emdash_media_usage_sources as source")
|
|
314
|
+
.select("source.source_key")
|
|
315
|
+
.where("source.source_type", "=", "content")
|
|
316
|
+
.where("source.collection_id", "=", claim.collectionId)
|
|
317
|
+
.where("source.identity_version", "=", 1)
|
|
318
|
+
.where(this.liveClaimExists(claim))
|
|
319
|
+
.where(this.statusOwnsRun(claim, targetEpoch))
|
|
320
|
+
.orderBy("source.source_key", "desc")
|
|
321
|
+
.limit(1)
|
|
322
|
+
.executeTakeFirst();
|
|
323
|
+
return row?.source_key ?? null;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
async transitionToSources(input: {
|
|
327
|
+
claim: MediaUsageReconciliationClaim;
|
|
328
|
+
targetEpoch: number | string;
|
|
329
|
+
fieldFingerprint: string;
|
|
330
|
+
sourceUpperKey: string | null;
|
|
331
|
+
}): Promise<boolean> {
|
|
332
|
+
const result = await this.db
|
|
333
|
+
.updateTable("_emdash_media_usage_reconciliations as reconciliation")
|
|
334
|
+
.set({
|
|
335
|
+
phase: "sources",
|
|
336
|
+
source_cursor: null,
|
|
337
|
+
source_upper_key: input.sourceUpperKey,
|
|
338
|
+
attempt_count: 0,
|
|
339
|
+
last_error_code: null,
|
|
340
|
+
updated_at: timestampOffset(this.db, 0),
|
|
341
|
+
})
|
|
342
|
+
.where("reconciliation.collection_id", "=", input.claim.collectionId)
|
|
343
|
+
.where("reconciliation.run_token", "=", input.claim.runToken)
|
|
344
|
+
.where("reconciliation.target_epoch", "=", input.targetEpoch)
|
|
345
|
+
.where("reconciliation.field_fingerprint", "=", input.fieldFingerprint)
|
|
346
|
+
.where("reconciliation.state", "=", "leased")
|
|
347
|
+
.where("reconciliation.phase", "=", "scan")
|
|
348
|
+
.where("reconciliation.lease_token", "=", input.claim.leaseToken)
|
|
349
|
+
.where(liveLease(this.db))
|
|
350
|
+
.where(this.statusOwnsRun(input.claim, input.targetEpoch))
|
|
351
|
+
.where((eb) =>
|
|
352
|
+
eb.not(
|
|
353
|
+
eb.exists(
|
|
354
|
+
eb
|
|
355
|
+
.selectFrom("_emdash_media_usage_work as work")
|
|
356
|
+
.select("work.content_id")
|
|
357
|
+
.where("work.collection_id", "=", input.claim.collectionId),
|
|
358
|
+
),
|
|
359
|
+
),
|
|
360
|
+
)
|
|
361
|
+
.executeTakeFirst();
|
|
362
|
+
return Number(result.numUpdatedRows ?? 0) === 1;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
async findSourcePage(
|
|
366
|
+
reconciliation: MediaUsageReconciliationRecord,
|
|
367
|
+
limit: number,
|
|
368
|
+
): Promise<MediaUsageReconciliationSourceCandidate[]> {
|
|
369
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 50) {
|
|
370
|
+
throw new Error("Reconciliation source page limit must be from 1 to 50");
|
|
371
|
+
}
|
|
372
|
+
if (!reconciliation.leaseToken || reconciliation.targetEpoch === null) return [];
|
|
373
|
+
let query = this.db
|
|
374
|
+
.selectFrom("_emdash_media_usage_sources as source")
|
|
375
|
+
.select(["source.source_key", "source.content_id", "source.source_variant"])
|
|
376
|
+
.where("source.source_type", "=", "content")
|
|
377
|
+
.where("source.collection_id", "=", reconciliation.collectionId)
|
|
378
|
+
.where("source.identity_version", "=", 1)
|
|
379
|
+
.where(this.liveClaimExists(reconciliation))
|
|
380
|
+
.where(this.statusOwnsRun(reconciliation, reconciliation.targetEpoch));
|
|
381
|
+
if (reconciliation.sourceCursor) {
|
|
382
|
+
query = query.where("source.source_key", ">", reconciliation.sourceCursor);
|
|
383
|
+
}
|
|
384
|
+
if (reconciliation.sourceUpperKey) {
|
|
385
|
+
query = query.where("source.source_key", "<=", reconciliation.sourceUpperKey);
|
|
386
|
+
} else {
|
|
387
|
+
query = query.where(sql<boolean>`1 = 0`);
|
|
388
|
+
}
|
|
389
|
+
const rows = await query.orderBy("source.source_key").limit(limit).execute();
|
|
390
|
+
return rows.map((row) => ({
|
|
391
|
+
sourceKey: row.source_key,
|
|
392
|
+
contentId: row.content_id,
|
|
393
|
+
sourceVariant: row.source_variant,
|
|
394
|
+
}));
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
async findMissingContentIds(
|
|
398
|
+
collectionSlug: string,
|
|
399
|
+
contentIds: readonly string[],
|
|
400
|
+
): Promise<string[]> {
|
|
401
|
+
const unique = [...new Set(contentIds)];
|
|
402
|
+
if (unique.length === 0) return [];
|
|
403
|
+
if (unique.length > 50 || unique.some((contentId) => !contentId)) {
|
|
404
|
+
throw new Error("Reconciliation source page has invalid content identity");
|
|
405
|
+
}
|
|
406
|
+
const tableName = contentTableName(collectionSlug);
|
|
407
|
+
const existing = await sql<{ id: string }>`
|
|
408
|
+
SELECT id FROM ${sql.ref(tableName)} WHERE id IN (${sql.join(unique)})
|
|
409
|
+
`.execute(this.db);
|
|
410
|
+
const present = new Set(existing.rows.map((row) => row.id));
|
|
411
|
+
return unique.filter((contentId) => !present.has(contentId));
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
async checkpointSources(input: {
|
|
415
|
+
claim: MediaUsageReconciliationClaim;
|
|
416
|
+
targetEpoch: number | string;
|
|
417
|
+
previousCursor: string | null;
|
|
418
|
+
nextCursor: string;
|
|
419
|
+
}): Promise<boolean> {
|
|
420
|
+
let query = this.db
|
|
421
|
+
.updateTable("_emdash_media_usage_reconciliations as reconciliation")
|
|
422
|
+
.set({
|
|
423
|
+
source_cursor: input.nextCursor,
|
|
424
|
+
attempt_count: 0,
|
|
425
|
+
last_error_code: null,
|
|
426
|
+
updated_at: timestampOffset(this.db, 0),
|
|
427
|
+
})
|
|
428
|
+
.where("reconciliation.collection_id", "=", input.claim.collectionId)
|
|
429
|
+
.where("reconciliation.run_token", "=", input.claim.runToken)
|
|
430
|
+
.where("reconciliation.target_epoch", "=", input.targetEpoch)
|
|
431
|
+
.where("reconciliation.state", "=", "leased")
|
|
432
|
+
.where("reconciliation.phase", "=", "sources")
|
|
433
|
+
.where("reconciliation.lease_token", "=", input.claim.leaseToken)
|
|
434
|
+
.where(liveLease(this.db))
|
|
435
|
+
.where(this.statusOwnsRun(input.claim, input.targetEpoch));
|
|
436
|
+
query = input.previousCursor
|
|
437
|
+
? query.where("reconciliation.source_cursor", "=", input.previousCursor)
|
|
438
|
+
: query.where("reconciliation.source_cursor", "is", null);
|
|
439
|
+
const result = await query.executeTakeFirst();
|
|
440
|
+
return Number(result.numUpdatedRows ?? 0) === 1;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
async finishFailedCoverage(collectionId: string, runToken: string): Promise<boolean> {
|
|
444
|
+
assertIdentity({ collectionId, runToken });
|
|
445
|
+
const now = timestampOffset(this.db, 0);
|
|
446
|
+
const result = await this.db
|
|
447
|
+
.updateTable("_emdash_media_usage_index_status as status")
|
|
448
|
+
.set({
|
|
449
|
+
status: sql<string>`CASE WHEN EXISTS (
|
|
450
|
+
SELECT 1 FROM _emdash_media_usage_sources AS source
|
|
451
|
+
WHERE source.source_type = 'content'
|
|
452
|
+
AND source.collection_id = ${collectionId}
|
|
453
|
+
AND source.identity_version = 1
|
|
454
|
+
LIMIT 1
|
|
455
|
+
) THEN 'partial' ELSE 'failed' END`,
|
|
456
|
+
completed_at: null,
|
|
457
|
+
cursor: null,
|
|
458
|
+
last_error_code: sql<string>`CASE WHEN (
|
|
459
|
+
SELECT reconciliation.last_error_code
|
|
460
|
+
FROM _emdash_media_usage_reconciliations AS reconciliation
|
|
461
|
+
WHERE reconciliation.collection_id = ${collectionId}
|
|
462
|
+
AND reconciliation.run_token = ${runToken}
|
|
463
|
+
) = 'MEDIA_USAGE_RECONCILIATION_ENTRY_FAILED'
|
|
464
|
+
THEN COALESCE(
|
|
465
|
+
(SELECT work.last_error_code
|
|
466
|
+
FROM _emdash_media_usage_work AS work
|
|
467
|
+
WHERE work.collection_id = ${collectionId} AND work.state = 'failed'
|
|
468
|
+
ORDER BY work.content_id LIMIT 1),
|
|
469
|
+
'MEDIA_USAGE_RECONCILIATION_ENTRY_FAILED'
|
|
470
|
+
)
|
|
471
|
+
ELSE (
|
|
472
|
+
SELECT reconciliation.last_error_code
|
|
473
|
+
FROM _emdash_media_usage_reconciliations AS reconciliation
|
|
474
|
+
WHERE reconciliation.collection_id = ${collectionId}
|
|
475
|
+
AND reconciliation.run_token = ${runToken}
|
|
476
|
+
) END`,
|
|
477
|
+
reconciliation_required: 1,
|
|
478
|
+
updated_at: now,
|
|
479
|
+
})
|
|
480
|
+
.where("status.adapter_id", "=", CONTENT_ADAPTER_ID)
|
|
481
|
+
.where("status.scope_type", "=", COLLECTION_SCOPE)
|
|
482
|
+
.where("status.collection_id", "=", collectionId)
|
|
483
|
+
.where("status.status", "=", "running")
|
|
484
|
+
.where("status.cursor", "=", runToken)
|
|
485
|
+
.where((eb) =>
|
|
486
|
+
eb.exists(
|
|
487
|
+
eb
|
|
488
|
+
.selectFrom("_emdash_media_usage_reconciliations as reconciliation")
|
|
489
|
+
.select("reconciliation.collection_id")
|
|
490
|
+
.where("reconciliation.collection_id", "=", collectionId)
|
|
491
|
+
.where("reconciliation.run_token", "=", runToken)
|
|
492
|
+
.where("reconciliation.state", "=", "failed"),
|
|
493
|
+
),
|
|
494
|
+
)
|
|
495
|
+
.executeTakeFirst();
|
|
496
|
+
return Number(result.numUpdatedRows ?? 0) === 1;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
async finalizeCoverage(input: {
|
|
500
|
+
claim: MediaUsageReconciliationClaim;
|
|
501
|
+
targetEpoch: number | string;
|
|
502
|
+
fieldFingerprint: string;
|
|
503
|
+
schemaVersion: number;
|
|
504
|
+
}): Promise<boolean> {
|
|
505
|
+
const now = timestampOffset(this.db, 0);
|
|
506
|
+
const result = await this.db
|
|
507
|
+
.updateTable("_emdash_media_usage_index_status as status")
|
|
508
|
+
.set({
|
|
509
|
+
status: "complete",
|
|
510
|
+
schema_version: input.schemaVersion,
|
|
511
|
+
completed_at: now,
|
|
512
|
+
cursor: null,
|
|
513
|
+
last_error_code: null,
|
|
514
|
+
reconciliation_required: 0,
|
|
515
|
+
updated_at: now,
|
|
516
|
+
})
|
|
517
|
+
.where("status.adapter_id", "=", CONTENT_ADAPTER_ID)
|
|
518
|
+
.where("status.scope_type", "=", COLLECTION_SCOPE)
|
|
519
|
+
.where("status.collection_id", "=", input.claim.collectionId)
|
|
520
|
+
.where("status.scope_key", "=", input.claim.collectionSlug)
|
|
521
|
+
.where("status.capture_state", "=", "active")
|
|
522
|
+
.where("status.reconciliation_required", "=", 1)
|
|
523
|
+
.where("status.status", "=", "running")
|
|
524
|
+
.where("status.cursor", "=", input.claim.runToken)
|
|
525
|
+
.where("status.change_epoch", "=", input.targetEpoch)
|
|
526
|
+
.where((eb) =>
|
|
527
|
+
eb.not(
|
|
528
|
+
eb.exists(
|
|
529
|
+
eb
|
|
530
|
+
.selectFrom("_emdash_media_usage_work as work")
|
|
531
|
+
.select("work.content_id")
|
|
532
|
+
.where("work.collection_id", "=", input.claim.collectionId),
|
|
533
|
+
),
|
|
534
|
+
),
|
|
535
|
+
)
|
|
536
|
+
.where((eb) =>
|
|
537
|
+
eb.exists(
|
|
538
|
+
eb
|
|
539
|
+
.selectFrom("_emdash_media_usage_reconciliations as reconciliation")
|
|
540
|
+
.innerJoin("_emdash_collections as collection", (join) =>
|
|
541
|
+
join
|
|
542
|
+
.onRef("collection.id", "=", "reconciliation.collection_id")
|
|
543
|
+
.onRef("collection.slug", "=", "reconciliation.collection_slug"),
|
|
544
|
+
)
|
|
545
|
+
.select("reconciliation.collection_id")
|
|
546
|
+
.where("reconciliation.collection_id", "=", input.claim.collectionId)
|
|
547
|
+
.where("reconciliation.run_token", "=", input.claim.runToken)
|
|
548
|
+
.where("reconciliation.target_epoch", "=", input.targetEpoch)
|
|
549
|
+
.where("reconciliation.field_fingerprint", "=", input.fieldFingerprint)
|
|
550
|
+
.where("reconciliation.state", "=", "leased")
|
|
551
|
+
.where("reconciliation.phase", "=", "sources")
|
|
552
|
+
.where("reconciliation.lease_token", "=", input.claim.leaseToken)
|
|
553
|
+
.where(liveLease(this.db, "reconciliation.lease_expires_at"))
|
|
554
|
+
.where((inner) =>
|
|
555
|
+
inner.not(
|
|
556
|
+
inner.exists(
|
|
557
|
+
inner
|
|
558
|
+
.selectFrom("_emdash_media_usage_collection_deletions as deletion")
|
|
559
|
+
.select("deletion.collection_id")
|
|
560
|
+
.where("deletion.collection_id", "=", input.claim.collectionId),
|
|
561
|
+
),
|
|
562
|
+
),
|
|
563
|
+
),
|
|
564
|
+
),
|
|
565
|
+
)
|
|
566
|
+
.where((eb) =>
|
|
567
|
+
eb.exists(
|
|
568
|
+
eb
|
|
569
|
+
.selectFrom("_emdash_media_usage_activation as activation")
|
|
570
|
+
.select("activation.task_key")
|
|
571
|
+
.where("activation.task_key", "=", ACTIVATION_KEY)
|
|
572
|
+
.where("activation.state", "=", "active"),
|
|
573
|
+
),
|
|
574
|
+
)
|
|
575
|
+
.executeTakeFirst();
|
|
576
|
+
return Number(result.numUpdatedRows ?? 0) === 1;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
async deleteFinalized(claim: MediaUsageReconciliationClaim): Promise<boolean> {
|
|
580
|
+
const result = await this.db
|
|
581
|
+
.deleteFrom("_emdash_media_usage_reconciliations as reconciliation")
|
|
582
|
+
.where("reconciliation.collection_id", "=", claim.collectionId)
|
|
583
|
+
.where("reconciliation.run_token", "=", claim.runToken)
|
|
584
|
+
.where("reconciliation.state", "=", "leased")
|
|
585
|
+
.where("reconciliation.lease_token", "=", claim.leaseToken)
|
|
586
|
+
.where((eb) =>
|
|
587
|
+
eb.exists(
|
|
588
|
+
eb
|
|
589
|
+
.selectFrom("_emdash_media_usage_index_status as status")
|
|
590
|
+
.select("status.collection_id")
|
|
591
|
+
.where("status.collection_id", "=", claim.collectionId)
|
|
592
|
+
.where("status.scope_key", "=", claim.collectionSlug)
|
|
593
|
+
.where("status.status", "=", "complete")
|
|
594
|
+
.where("status.reconciliation_required", "=", 0),
|
|
595
|
+
),
|
|
596
|
+
)
|
|
597
|
+
.executeTakeFirst();
|
|
598
|
+
return Number(result.numDeletedRows ?? 0) === 1;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
async deleteOneObsolete(): Promise<boolean> {
|
|
602
|
+
const result = await sql<{ collection_id: string }>`
|
|
603
|
+
DELETE FROM _emdash_media_usage_reconciliations
|
|
604
|
+
WHERE (collection_id, run_token) IN (
|
|
605
|
+
SELECT reconciliation.collection_id, reconciliation.run_token
|
|
606
|
+
FROM _emdash_media_usage_reconciliations AS reconciliation
|
|
607
|
+
INNER JOIN _emdash_media_usage_index_status AS status
|
|
608
|
+
ON status.collection_id = reconciliation.collection_id
|
|
609
|
+
AND status.scope_key = reconciliation.collection_slug
|
|
610
|
+
WHERE status.adapter_id = ${CONTENT_ADAPTER_ID}
|
|
611
|
+
AND status.scope_type = ${COLLECTION_SCOPE}
|
|
612
|
+
AND status.reconciliation_required = 0
|
|
613
|
+
ORDER BY reconciliation.updated_at, reconciliation.collection_id
|
|
614
|
+
LIMIT 1
|
|
615
|
+
)
|
|
616
|
+
RETURNING collection_id
|
|
617
|
+
`.execute(this.db);
|
|
618
|
+
return result.rows.length === 1;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
private liveClaimExists(
|
|
622
|
+
claim: Pick<
|
|
623
|
+
MediaUsageReconciliationRecord,
|
|
624
|
+
"collectionId" | "collectionSlug" | "runToken" | "leaseToken"
|
|
625
|
+
>,
|
|
626
|
+
): RawBuilder<boolean> {
|
|
627
|
+
return this.liveClaimExistsSql(claim);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
private liveClaimExistsSql(
|
|
631
|
+
claim: Pick<
|
|
632
|
+
MediaUsageReconciliationRecord,
|
|
633
|
+
"collectionId" | "collectionSlug" | "runToken" | "leaseToken"
|
|
634
|
+
>,
|
|
635
|
+
): RawBuilder<boolean> {
|
|
636
|
+
return sql<boolean>`EXISTS (
|
|
637
|
+
SELECT 1
|
|
638
|
+
FROM _emdash_media_usage_reconciliations AS reconciliation
|
|
639
|
+
INNER JOIN _emdash_collections AS collection
|
|
640
|
+
ON collection.id = reconciliation.collection_id
|
|
641
|
+
AND collection.slug = reconciliation.collection_slug
|
|
642
|
+
WHERE reconciliation.collection_id = ${claim.collectionId}
|
|
643
|
+
AND reconciliation.collection_slug = ${claim.collectionSlug}
|
|
644
|
+
AND reconciliation.run_token = ${claim.runToken}
|
|
645
|
+
AND reconciliation.state = 'leased'
|
|
646
|
+
AND reconciliation.lease_token = ${claim.leaseToken}
|
|
647
|
+
AND ${liveLease(this.db, "reconciliation.lease_expires_at")}
|
|
648
|
+
AND EXISTS (
|
|
649
|
+
SELECT 1 FROM _emdash_media_usage_activation AS activation
|
|
650
|
+
WHERE activation.task_key = ${ACTIVATION_KEY}
|
|
651
|
+
AND activation.state = 'active'
|
|
652
|
+
)
|
|
653
|
+
AND NOT EXISTS (
|
|
654
|
+
SELECT 1 FROM _emdash_media_usage_collection_deletions AS deletion
|
|
655
|
+
WHERE deletion.collection_id = reconciliation.collection_id
|
|
656
|
+
)
|
|
657
|
+
)`;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
private statusOwnsRun(
|
|
661
|
+
claim: Pick<MediaUsageReconciliationRecord, "collectionId" | "collectionSlug" | "runToken">,
|
|
662
|
+
targetEpoch: number | string,
|
|
663
|
+
): RawBuilder<boolean> {
|
|
664
|
+
return sql<boolean>`EXISTS (
|
|
665
|
+
SELECT 1 FROM _emdash_media_usage_index_status AS status
|
|
666
|
+
WHERE status.adapter_id = ${CONTENT_ADAPTER_ID}
|
|
667
|
+
AND status.scope_type = ${COLLECTION_SCOPE}
|
|
668
|
+
AND status.collection_id = ${claim.collectionId}
|
|
669
|
+
AND status.scope_key = ${claim.collectionSlug}
|
|
670
|
+
AND status.capture_state = 'active'
|
|
671
|
+
AND status.reconciliation_required = 1
|
|
672
|
+
AND status.status = 'running'
|
|
673
|
+
AND status.cursor = ${claim.runToken}
|
|
674
|
+
AND status.change_epoch = ${targetEpoch}
|
|
675
|
+
)`;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
async seedNextCandidate(): Promise<boolean> {
|
|
679
|
+
const runToken = ulid();
|
|
680
|
+
const now = timestampOffset(this.db, 0);
|
|
681
|
+
const result = await sql<{ collection_id: string }>`
|
|
682
|
+
INSERT INTO _emdash_media_usage_reconciliations (
|
|
683
|
+
collection_id,
|
|
684
|
+
collection_slug,
|
|
685
|
+
run_token,
|
|
686
|
+
next_attempt_at,
|
|
687
|
+
updated_at
|
|
688
|
+
)
|
|
689
|
+
SELECT status.collection_id, status.scope_key, ${runToken}, ${now}, ${now}
|
|
690
|
+
FROM _emdash_media_usage_index_status AS status
|
|
691
|
+
INNER JOIN _emdash_collections AS collection
|
|
692
|
+
ON collection.id = status.collection_id
|
|
693
|
+
AND collection.slug = status.scope_key
|
|
694
|
+
WHERE status.adapter_id = ${CONTENT_ADAPTER_ID}
|
|
695
|
+
AND status.scope_type = ${COLLECTION_SCOPE}
|
|
696
|
+
AND status.capture_state = 'active'
|
|
697
|
+
AND status.reconciliation_required = 1
|
|
698
|
+
AND status.collection_id IS NOT NULL
|
|
699
|
+
AND EXISTS (
|
|
700
|
+
SELECT 1 FROM _emdash_media_usage_activation AS activation
|
|
701
|
+
WHERE activation.task_key = ${ACTIVATION_KEY}
|
|
702
|
+
AND activation.state = 'active'
|
|
703
|
+
)
|
|
704
|
+
AND NOT EXISTS (
|
|
705
|
+
SELECT 1 FROM _emdash_media_usage_reconciliations AS existing
|
|
706
|
+
WHERE existing.collection_id = status.collection_id
|
|
707
|
+
)
|
|
708
|
+
AND NOT EXISTS (
|
|
709
|
+
SELECT 1 FROM _emdash_media_usage_collection_deletions AS deletion
|
|
710
|
+
WHERE deletion.collection_id = status.collection_id
|
|
711
|
+
)
|
|
712
|
+
ORDER BY status.collection_id
|
|
713
|
+
LIMIT 1
|
|
714
|
+
ON CONFLICT (collection_id) DO NOTHING
|
|
715
|
+
RETURNING collection_id
|
|
716
|
+
`.execute(this.db);
|
|
717
|
+
return result.rows.length === 1;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
async findDue(limit: number): Promise<MediaUsageReconciliationRecord[]> {
|
|
721
|
+
assertLimit(limit);
|
|
722
|
+
const nextAttemptIsDue = timestampIsDue(this.db, "next_attempt_at");
|
|
723
|
+
const leaseIsDue = timestampIsDue(this.db, "lease_expires_at");
|
|
724
|
+
const result = await sql<Selectable<MediaUsageReconciliationTable>>`
|
|
725
|
+
WITH pending_candidates AS (
|
|
726
|
+
SELECT * FROM _emdash_media_usage_reconciliations
|
|
727
|
+
WHERE state = 'pending' AND ${nextAttemptIsDue}
|
|
728
|
+
ORDER BY next_attempt_at, updated_at, collection_id
|
|
729
|
+
LIMIT ${limit}
|
|
730
|
+
), retry_candidates AS (
|
|
731
|
+
SELECT * FROM _emdash_media_usage_reconciliations
|
|
732
|
+
WHERE state = 'retry' AND ${nextAttemptIsDue}
|
|
733
|
+
ORDER BY next_attempt_at, updated_at, collection_id
|
|
734
|
+
LIMIT ${limit}
|
|
735
|
+
), leased_candidates AS (
|
|
736
|
+
SELECT * FROM _emdash_media_usage_reconciliations
|
|
737
|
+
WHERE state = 'leased' AND ${leaseIsDue}
|
|
738
|
+
ORDER BY lease_expires_at, updated_at, collection_id
|
|
739
|
+
LIMIT ${limit}
|
|
740
|
+
), candidates AS (
|
|
741
|
+
SELECT * FROM pending_candidates
|
|
742
|
+
UNION ALL SELECT * FROM retry_candidates
|
|
743
|
+
UNION ALL SELECT * FROM leased_candidates
|
|
744
|
+
)
|
|
745
|
+
SELECT * FROM candidates
|
|
746
|
+
ORDER BY CASE WHEN state = 'leased' THEN lease_expires_at ELSE next_attempt_at END,
|
|
747
|
+
updated_at,
|
|
748
|
+
collection_id
|
|
749
|
+
LIMIT ${limit}
|
|
750
|
+
`.execute(this.db);
|
|
751
|
+
return result.rows.map(rowToRecord);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
async findFailed(limit: number): Promise<MediaUsageReconciliationRecord[]> {
|
|
755
|
+
assertLimit(limit);
|
|
756
|
+
const rows = await this.db
|
|
757
|
+
.selectFrom("_emdash_media_usage_reconciliations as reconciliation")
|
|
758
|
+
.innerJoin("_emdash_media_usage_index_status as status", (join) =>
|
|
759
|
+
join
|
|
760
|
+
.onRef("status.collection_id", "=", "reconciliation.collection_id")
|
|
761
|
+
.onRef("status.scope_key", "=", "reconciliation.collection_slug"),
|
|
762
|
+
)
|
|
763
|
+
.selectAll("reconciliation")
|
|
764
|
+
.where("reconciliation.state", "=", "failed")
|
|
765
|
+
.where("status.adapter_id", "=", CONTENT_ADAPTER_ID)
|
|
766
|
+
.where("status.scope_type", "=", COLLECTION_SCOPE)
|
|
767
|
+
.where((eb) =>
|
|
768
|
+
eb.or([
|
|
769
|
+
eb("status.reconciliation_required", "=", 0),
|
|
770
|
+
eb.and([
|
|
771
|
+
eb("status.status", "=", "running"),
|
|
772
|
+
eb("status.cursor", "=", eb.ref("reconciliation.run_token")),
|
|
773
|
+
]),
|
|
774
|
+
eb.and([
|
|
775
|
+
eb("status.cursor", "is", null),
|
|
776
|
+
eb("status.change_epoch", ">", eb.ref("reconciliation.target_epoch")),
|
|
777
|
+
]),
|
|
778
|
+
]),
|
|
779
|
+
)
|
|
780
|
+
.orderBy("reconciliation.updated_at")
|
|
781
|
+
.orderBy("reconciliation.collection_id")
|
|
782
|
+
.limit(limit)
|
|
783
|
+
.execute();
|
|
784
|
+
return rows.map(rowToRecord);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
async claim(input: {
|
|
788
|
+
collectionId: string;
|
|
789
|
+
runToken: string;
|
|
790
|
+
leaseDurationSeconds: number;
|
|
791
|
+
}): Promise<MediaUsageReconciliationClaim | null> {
|
|
792
|
+
assertIdentity(input);
|
|
793
|
+
assertDuration(input.leaseDurationSeconds, "lease duration");
|
|
794
|
+
const leaseToken = ulid();
|
|
795
|
+
const row = await this.db
|
|
796
|
+
.updateTable("_emdash_media_usage_reconciliations as reconciliation")
|
|
797
|
+
.set({
|
|
798
|
+
state: "leased",
|
|
799
|
+
lease_token: leaseToken,
|
|
800
|
+
lease_expires_at: timestampOffset(this.db, input.leaseDurationSeconds),
|
|
801
|
+
updated_at: timestampOffset(this.db, 0),
|
|
802
|
+
})
|
|
803
|
+
.where("reconciliation.collection_id", "=", input.collectionId)
|
|
804
|
+
.where("reconciliation.run_token", "=", input.runToken)
|
|
805
|
+
.where((eb) =>
|
|
806
|
+
eb.or([
|
|
807
|
+
eb.and([
|
|
808
|
+
eb("reconciliation.state", "in", ["pending", "retry"]),
|
|
809
|
+
timestampIsDue(this.db, "reconciliation.next_attempt_at"),
|
|
810
|
+
]),
|
|
811
|
+
eb.and([
|
|
812
|
+
eb("reconciliation.state", "=", "leased"),
|
|
813
|
+
timestampIsDue(this.db, "reconciliation.lease_expires_at"),
|
|
814
|
+
]),
|
|
815
|
+
]),
|
|
816
|
+
)
|
|
817
|
+
.where((eb) =>
|
|
818
|
+
eb.exists(
|
|
819
|
+
eb
|
|
820
|
+
.selectFrom("_emdash_media_usage_activation as activation")
|
|
821
|
+
.select("activation.task_key")
|
|
822
|
+
.where("activation.task_key", "=", ACTIVATION_KEY)
|
|
823
|
+
.where("activation.state", "=", "active"),
|
|
824
|
+
),
|
|
825
|
+
)
|
|
826
|
+
.where((eb) =>
|
|
827
|
+
eb.exists(
|
|
828
|
+
eb
|
|
829
|
+
.selectFrom("_emdash_media_usage_index_status as status")
|
|
830
|
+
.innerJoin("_emdash_collections as collection", (join) =>
|
|
831
|
+
join
|
|
832
|
+
.onRef("collection.id", "=", "status.collection_id")
|
|
833
|
+
.onRef("collection.slug", "=", "status.scope_key"),
|
|
834
|
+
)
|
|
835
|
+
.select("status.collection_id")
|
|
836
|
+
.whereRef("status.collection_id", "=", "reconciliation.collection_id")
|
|
837
|
+
.whereRef("status.scope_key", "=", "reconciliation.collection_slug")
|
|
838
|
+
.where("status.adapter_id", "=", CONTENT_ADAPTER_ID)
|
|
839
|
+
.where("status.scope_type", "=", COLLECTION_SCOPE)
|
|
840
|
+
.where("status.capture_state", "=", "active")
|
|
841
|
+
.where("status.reconciliation_required", "=", 1),
|
|
842
|
+
),
|
|
843
|
+
)
|
|
844
|
+
.where((eb) =>
|
|
845
|
+
eb.not(
|
|
846
|
+
eb.exists(
|
|
847
|
+
eb
|
|
848
|
+
.selectFrom("_emdash_media_usage_collection_deletions as deletion")
|
|
849
|
+
.select("deletion.collection_id")
|
|
850
|
+
.whereRef("deletion.collection_id", "=", "reconciliation.collection_id"),
|
|
851
|
+
),
|
|
852
|
+
),
|
|
853
|
+
)
|
|
854
|
+
.returningAll()
|
|
855
|
+
.executeTakeFirst();
|
|
856
|
+
return row
|
|
857
|
+
? ({ ...rowToRecord(row), leaseToken } satisfies MediaUsageReconciliationClaim)
|
|
858
|
+
: null;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
async release(input: {
|
|
862
|
+
collectionId: string;
|
|
863
|
+
runToken: string;
|
|
864
|
+
leaseToken: string;
|
|
865
|
+
delaySeconds: number;
|
|
866
|
+
}): Promise<boolean> {
|
|
867
|
+
assertLeaseIdentity(input);
|
|
868
|
+
assertDuration(input.delaySeconds, "release delay", true);
|
|
869
|
+
const result = await this.db
|
|
870
|
+
.updateTable("_emdash_media_usage_reconciliations")
|
|
871
|
+
.set({
|
|
872
|
+
state: "pending",
|
|
873
|
+
next_attempt_at: timestampOffset(this.db, input.delaySeconds),
|
|
874
|
+
lease_token: null,
|
|
875
|
+
lease_expires_at: null,
|
|
876
|
+
updated_at: timestampOffset(this.db, 0),
|
|
877
|
+
})
|
|
878
|
+
.where("collection_id", "=", input.collectionId)
|
|
879
|
+
.where("run_token", "=", input.runToken)
|
|
880
|
+
.where("state", "=", "leased")
|
|
881
|
+
.where("lease_token", "=", input.leaseToken)
|
|
882
|
+
.where(liveLease(this.db))
|
|
883
|
+
.executeTakeFirst();
|
|
884
|
+
return Number(result.numUpdatedRows ?? 0) === 1;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
async recordFailure(input: {
|
|
888
|
+
collectionId: string;
|
|
889
|
+
runToken: string;
|
|
890
|
+
leaseToken: string;
|
|
891
|
+
errorCode: string;
|
|
892
|
+
retryDelaySeconds: number;
|
|
893
|
+
terminal: boolean;
|
|
894
|
+
}): Promise<boolean> {
|
|
895
|
+
assertLeaseIdentity(input);
|
|
896
|
+
if (!STABLE_ERROR_CODE_PATTERN.test(input.errorCode)) {
|
|
897
|
+
throw new Error("Reconciliation failure requires a stable error code");
|
|
898
|
+
}
|
|
899
|
+
assertDuration(input.retryDelaySeconds, "retry delay", true);
|
|
900
|
+
const result = await this.db
|
|
901
|
+
.updateTable("_emdash_media_usage_reconciliations")
|
|
902
|
+
.set({
|
|
903
|
+
state: input.terminal
|
|
904
|
+
? "failed"
|
|
905
|
+
: sql<string>`CASE WHEN attempt_count >= 4 THEN 'failed' ELSE 'retry' END`,
|
|
906
|
+
...(input.terminal
|
|
907
|
+
? {
|
|
908
|
+
target_epoch: sql<number | string | null>`COALESCE(
|
|
909
|
+
target_epoch,
|
|
910
|
+
(SELECT status.change_epoch
|
|
911
|
+
FROM _emdash_media_usage_index_status AS status
|
|
912
|
+
WHERE status.adapter_id = ${CONTENT_ADAPTER_ID}
|
|
913
|
+
AND status.scope_type = ${COLLECTION_SCOPE}
|
|
914
|
+
AND status.collection_id = ${input.collectionId}
|
|
915
|
+
AND status.status = 'running'
|
|
916
|
+
AND status.cursor = ${input.runToken})
|
|
917
|
+
)`,
|
|
918
|
+
}
|
|
919
|
+
: {}),
|
|
920
|
+
attempt_count: sql<number>`attempt_count + 1`,
|
|
921
|
+
next_attempt_at: timestampOffset(this.db, input.retryDelaySeconds),
|
|
922
|
+
lease_token: null,
|
|
923
|
+
lease_expires_at: null,
|
|
924
|
+
last_error_code: input.errorCode,
|
|
925
|
+
updated_at: timestampOffset(this.db, 0),
|
|
926
|
+
})
|
|
927
|
+
.where("collection_id", "=", input.collectionId)
|
|
928
|
+
.where("run_token", "=", input.runToken)
|
|
929
|
+
.where("state", "=", "leased")
|
|
930
|
+
.where("lease_token", "=", input.leaseToken)
|
|
931
|
+
.where(liveLease(this.db))
|
|
932
|
+
.executeTakeFirst();
|
|
933
|
+
return Number(result.numUpdatedRows ?? 0) === 1;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
async recordEntryFailure(claim: MediaUsageReconciliationClaim): Promise<boolean> {
|
|
937
|
+
const result = await this.db
|
|
938
|
+
.updateTable("_emdash_media_usage_reconciliations as reconciliation")
|
|
939
|
+
.set({
|
|
940
|
+
state: "failed",
|
|
941
|
+
attempt_count: sql<number>`attempt_count + 1`,
|
|
942
|
+
next_attempt_at: timestampOffset(this.db, 0),
|
|
943
|
+
lease_token: null,
|
|
944
|
+
lease_expires_at: null,
|
|
945
|
+
last_error_code: "MEDIA_USAGE_RECONCILIATION_ENTRY_FAILED",
|
|
946
|
+
updated_at: timestampOffset(this.db, 0),
|
|
947
|
+
})
|
|
948
|
+
.where("reconciliation.collection_id", "=", claim.collectionId)
|
|
949
|
+
.where("reconciliation.run_token", "=", claim.runToken)
|
|
950
|
+
.where("reconciliation.state", "=", "leased")
|
|
951
|
+
.where("reconciliation.lease_token", "=", claim.leaseToken)
|
|
952
|
+
.where(liveLease(this.db))
|
|
953
|
+
.where((eb) =>
|
|
954
|
+
eb.exists(
|
|
955
|
+
eb
|
|
956
|
+
.selectFrom("_emdash_media_usage_work as work")
|
|
957
|
+
.select("work.content_id")
|
|
958
|
+
.where("work.collection_id", "=", claim.collectionId)
|
|
959
|
+
.where("work.state", "=", "failed"),
|
|
960
|
+
),
|
|
961
|
+
)
|
|
962
|
+
.executeTakeFirst();
|
|
963
|
+
return Number(result.numUpdatedRows ?? 0) === 1;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
async resetFailedForNewEpoch(
|
|
967
|
+
observed: Selectable<MediaUsageReconciliationTable> | MediaUsageReconciliationRecord,
|
|
968
|
+
): Promise<boolean> {
|
|
969
|
+
const collectionId =
|
|
970
|
+
"collection_id" in observed ? observed.collection_id : observed.collectionId;
|
|
971
|
+
const runToken = "run_token" in observed ? observed.run_token : observed.runToken;
|
|
972
|
+
const targetEpoch = "target_epoch" in observed ? observed.target_epoch : observed.targetEpoch;
|
|
973
|
+
if (targetEpoch === null) return false;
|
|
974
|
+
const now = timestampOffset(this.db, 0);
|
|
975
|
+
const result = await this.db
|
|
976
|
+
.updateTable("_emdash_media_usage_reconciliations as reconciliation")
|
|
977
|
+
.set({
|
|
978
|
+
state: "pending",
|
|
979
|
+
phase: "scan",
|
|
980
|
+
target_epoch: null,
|
|
981
|
+
field_fingerprint: null,
|
|
982
|
+
scan_cursor: null,
|
|
983
|
+
scan_upper_id: null,
|
|
984
|
+
source_cursor: null,
|
|
985
|
+
source_upper_key: null,
|
|
986
|
+
attempt_count: 0,
|
|
987
|
+
next_attempt_at: now,
|
|
988
|
+
lease_token: null,
|
|
989
|
+
lease_expires_at: null,
|
|
990
|
+
last_error_code: null,
|
|
991
|
+
updated_at: now,
|
|
992
|
+
})
|
|
993
|
+
.where("reconciliation.collection_id", "=", collectionId)
|
|
994
|
+
.where("reconciliation.run_token", "=", runToken)
|
|
995
|
+
.where("reconciliation.state", "=", "failed")
|
|
996
|
+
.where("reconciliation.target_epoch", "=", targetEpoch)
|
|
997
|
+
.where((eb) =>
|
|
998
|
+
eb.exists(
|
|
999
|
+
eb
|
|
1000
|
+
.selectFrom("_emdash_media_usage_index_status as status")
|
|
1001
|
+
.select("status.collection_id")
|
|
1002
|
+
.whereRef("status.collection_id", "=", "reconciliation.collection_id")
|
|
1003
|
+
.whereRef("status.scope_key", "=", "reconciliation.collection_slug")
|
|
1004
|
+
.where("status.adapter_id", "=", CONTENT_ADAPTER_ID)
|
|
1005
|
+
.where("status.scope_type", "=", COLLECTION_SCOPE)
|
|
1006
|
+
.where("status.capture_state", "=", "active")
|
|
1007
|
+
.where("status.reconciliation_required", "=", 1)
|
|
1008
|
+
.where("status.cursor", "is", null)
|
|
1009
|
+
.where("status.change_epoch", ">", targetEpoch),
|
|
1010
|
+
),
|
|
1011
|
+
)
|
|
1012
|
+
.executeTakeFirst();
|
|
1013
|
+
return Number(result.numUpdatedRows ?? 0) === 1;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
function rowToRecord(
|
|
1018
|
+
row: Selectable<MediaUsageReconciliationTable>,
|
|
1019
|
+
): MediaUsageReconciliationRecord {
|
|
1020
|
+
if (!isState(row.state) || !isPhase(row.phase) || !Number.isSafeInteger(row.attempt_count)) {
|
|
1021
|
+
throw new Error("Invalid media usage reconciliation lifecycle");
|
|
1022
|
+
}
|
|
1023
|
+
return {
|
|
1024
|
+
collectionId: row.collection_id,
|
|
1025
|
+
collectionSlug: row.collection_slug,
|
|
1026
|
+
runToken: row.run_token,
|
|
1027
|
+
targetEpoch: row.target_epoch,
|
|
1028
|
+
fieldFingerprint: row.field_fingerprint,
|
|
1029
|
+
state: row.state,
|
|
1030
|
+
phase: row.phase,
|
|
1031
|
+
scanCursor: row.scan_cursor,
|
|
1032
|
+
scanUpperId: row.scan_upper_id,
|
|
1033
|
+
sourceCursor: row.source_cursor,
|
|
1034
|
+
sourceUpperKey: row.source_upper_key,
|
|
1035
|
+
attemptCount: row.attempt_count,
|
|
1036
|
+
nextAttemptAt: row.next_attempt_at,
|
|
1037
|
+
leaseToken: row.lease_token,
|
|
1038
|
+
leaseExpiresAt: row.lease_expires_at,
|
|
1039
|
+
lastErrorCode: row.last_error_code,
|
|
1040
|
+
createdAt: row.created_at,
|
|
1041
|
+
updatedAt: row.updated_at,
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
function isState(state: string): state is MediaUsageReconciliationState {
|
|
1046
|
+
return state === "pending" || state === "retry" || state === "leased" || state === "failed";
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
function isPhase(phase: string): phase is MediaUsageReconciliationPhase {
|
|
1050
|
+
return phase === "scan" || phase === "sources";
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
function assertLimit(limit: number): void {
|
|
1054
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > MAX_CANDIDATES) {
|
|
1055
|
+
throw new Error("Reconciliation candidate limit must be from 1 to 100");
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
function assertIdentity(input: { collectionId: string; runToken: string }): void {
|
|
1060
|
+
if (!input.collectionId || !input.runToken) {
|
|
1061
|
+
throw new Error("Reconciliation requires an exact collection and run token");
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
function assertLeaseIdentity(input: {
|
|
1066
|
+
collectionId: string;
|
|
1067
|
+
runToken: string;
|
|
1068
|
+
leaseToken: string;
|
|
1069
|
+
}): void {
|
|
1070
|
+
assertIdentity(input);
|
|
1071
|
+
if (!input.leaseToken) throw new Error("Reconciliation requires a lease token");
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
function assertDuration(value: number, label: string, allowZero = false): void {
|
|
1075
|
+
if (
|
|
1076
|
+
!Number.isSafeInteger(value) ||
|
|
1077
|
+
value < (allowZero ? 0 : 1) ||
|
|
1078
|
+
value > MAX_PORTABLE_DURATION_SECONDS
|
|
1079
|
+
) {
|
|
1080
|
+
throw new Error(`Reconciliation ${label} is outside the portable range`);
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
function liveLease(db: Kysely<Database>, column = "lease_expires_at"): RawBuilder<boolean> {
|
|
1085
|
+
const expiry = sql.ref(column);
|
|
1086
|
+
return isPostgres(db)
|
|
1087
|
+
? sql<boolean>`${expiry} > to_char(statement_timestamp() AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"')`
|
|
1088
|
+
: sql<boolean>`${expiry} > strftime('%Y-%m-%dT%H:%M:%fZ', 'now')`;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
function timestampIsDue(db: Kysely<Database>, column: string): RawBuilder<boolean> {
|
|
1092
|
+
const value = sql.ref(column);
|
|
1093
|
+
return isPostgres(db)
|
|
1094
|
+
? sql<boolean>`${value} <= to_char(statement_timestamp() AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"')`
|
|
1095
|
+
: sql<boolean>`${value} <= strftime('%Y-%m-%dT%H:%M:%fZ', 'now')`;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
function timestampOffset(db: Kysely<Database>, offsetSeconds: number): RawBuilder<string> {
|
|
1099
|
+
if (isPostgres(db)) {
|
|
1100
|
+
return sql<string>`to_char(
|
|
1101
|
+
(clock_timestamp() AT TIME ZONE 'UTC') + (${offsetSeconds} * INTERVAL '1 second'),
|
|
1102
|
+
'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'
|
|
1103
|
+
)`;
|
|
1104
|
+
}
|
|
1105
|
+
return sql<string>`strftime(
|
|
1106
|
+
'%Y-%m-%dT%H:%M:%fZ',
|
|
1107
|
+
'now',
|
|
1108
|
+
${`${offsetSeconds >= 0 ? "+" : ""}${offsetSeconds} seconds`}
|
|
1109
|
+
)`;
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
function contentTableName(collectionSlug: string): string {
|
|
1113
|
+
validateIdentifier(collectionSlug, "collection slug");
|
|
1114
|
+
const tableName = `ec_${collectionSlug}`;
|
|
1115
|
+
validateIdentifier(tableName, "content table");
|
|
1116
|
+
return tableName;
|
|
1117
|
+
}
|