emdash 0.0.0-b → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -43
- package/dist/adapters-BLMa4JGD.d.mts +106 -0
- package/dist/adapters-BLMa4JGD.d.mts.map +1 -0
- package/dist/apply-Bjfq_b4-.mjs +1293 -0
- package/dist/apply-Bjfq_b4-.mjs.map +1 -0
- package/dist/astro/index.d.mts +51 -0
- package/dist/astro/index.d.mts.map +1 -0
- package/dist/astro/index.mjs +1333 -0
- package/dist/astro/index.mjs.map +1 -0
- package/dist/astro/middleware/auth.d.mts +31 -0
- package/dist/astro/middleware/auth.d.mts.map +1 -0
- package/dist/astro/middleware/auth.mjs +654 -0
- package/dist/astro/middleware/auth.mjs.map +1 -0
- package/dist/astro/middleware/redirect.d.mts +22 -0
- package/dist/astro/middleware/redirect.d.mts.map +1 -0
- package/dist/astro/middleware/redirect.mjs +63 -0
- package/dist/astro/middleware/redirect.mjs.map +1 -0
- package/dist/astro/middleware/request-context.d.mts +18 -0
- package/dist/astro/middleware/request-context.d.mts.map +1 -0
- package/dist/astro/middleware/request-context.mjs +1310 -0
- package/dist/astro/middleware/request-context.mjs.map +1 -0
- package/dist/astro/middleware/setup.d.mts +20 -0
- package/dist/astro/middleware/setup.d.mts.map +1 -0
- package/dist/astro/middleware/setup.mjs +47 -0
- package/dist/astro/middleware/setup.mjs.map +1 -0
- package/dist/astro/middleware.d.mts +13 -0
- package/dist/astro/middleware.d.mts.map +1 -0
- package/dist/astro/middleware.mjs +1613 -0
- package/dist/astro/middleware.mjs.map +1 -0
- package/dist/astro/types.d.mts +250 -0
- package/dist/astro/types.d.mts.map +1 -0
- package/dist/astro/types.mjs +1 -0
- package/dist/base64-MBPo9ozB.mjs +59 -0
- package/dist/base64-MBPo9ozB.mjs.map +1 -0
- package/dist/byline-CL847F26.mjs +213 -0
- package/dist/byline-CL847F26.mjs.map +1 -0
- package/dist/bylines-C2a-2TGt.mjs +136 -0
- package/dist/bylines-C2a-2TGt.mjs.map +1 -0
- package/dist/chunk-ClPoSABd.mjs +21 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.mjs +3909 -0
- package/dist/cli/index.mjs.map +1 -0
- package/dist/client/cf-access.d.mts +60 -0
- package/dist/client/cf-access.d.mts.map +1 -0
- package/dist/client/cf-access.mjs +179 -0
- package/dist/client/cf-access.mjs.map +1 -0
- package/dist/client/index.d.mts +398 -0
- package/dist/client/index.d.mts.map +1 -0
- package/dist/client/index.mjs +346 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/config-CKE8p9xM.mjs +55 -0
- package/dist/config-CKE8p9xM.mjs.map +1 -0
- package/dist/connection-B4zVnQIa.mjs +40 -0
- package/dist/connection-B4zVnQIa.mjs.map +1 -0
- package/dist/content-D6C2WsZC.mjs +824 -0
- package/dist/content-D6C2WsZC.mjs.map +1 -0
- package/dist/db/index.d.mts +4 -0
- package/dist/db/index.mjs +62 -0
- package/dist/db/index.mjs.map +1 -0
- package/dist/db/libsql.d.mts +11 -0
- package/dist/db/libsql.d.mts.map +1 -0
- package/dist/db/libsql.mjs +17 -0
- package/dist/db/libsql.mjs.map +1 -0
- package/dist/db/postgres.d.mts +11 -0
- package/dist/db/postgres.d.mts.map +1 -0
- package/dist/db/postgres.mjs +30 -0
- package/dist/db/postgres.mjs.map +1 -0
- package/dist/db/sqlite.d.mts +11 -0
- package/dist/db/sqlite.d.mts.map +1 -0
- package/dist/db/sqlite.mjs +16 -0
- package/dist/db/sqlite.mjs.map +1 -0
- package/dist/default-Cyi4aAxu.mjs +81 -0
- package/dist/default-Cyi4aAxu.mjs.map +1 -0
- package/dist/dialect-helpers-B9uSp2GJ.mjs +90 -0
- package/dist/dialect-helpers-B9uSp2GJ.mjs.map +1 -0
- package/dist/error-Cxz0tQeO.mjs +27 -0
- package/dist/error-Cxz0tQeO.mjs.map +1 -0
- package/dist/index-C1xF3OGh.d.mts +4527 -0
- package/dist/index-C1xF3OGh.d.mts.map +1 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.mjs +30 -0
- package/dist/load-yOOlckBj.mjs +28 -0
- package/dist/load-yOOlckBj.mjs.map +1 -0
- package/dist/loader-fz8Q_3EO.mjs +447 -0
- package/dist/loader-fz8Q_3EO.mjs.map +1 -0
- package/dist/manifest-schema-Dcl0R6nM.mjs +184 -0
- package/dist/manifest-schema-Dcl0R6nM.mjs.map +1 -0
- package/dist/media/index.d.mts +26 -0
- package/dist/media/index.d.mts.map +1 -0
- package/dist/media/index.mjs +55 -0
- package/dist/media/index.mjs.map +1 -0
- package/dist/media/local-runtime.d.mts +39 -0
- package/dist/media/local-runtime.d.mts.map +1 -0
- package/dist/media/local-runtime.mjs +133 -0
- package/dist/media/local-runtime.mjs.map +1 -0
- package/dist/media-DqHVh136.mjs +200 -0
- package/dist/media-DqHVh136.mjs.map +1 -0
- package/dist/mode-C2EzN1uE.mjs +23 -0
- package/dist/mode-C2EzN1uE.mjs.map +1 -0
- package/dist/page/index.d.mts +140 -0
- package/dist/page/index.d.mts.map +1 -0
- package/dist/page/index.mjs +416 -0
- package/dist/page/index.mjs.map +1 -0
- package/dist/placeholder-CmGAmqeO.d.mts +276 -0
- package/dist/placeholder-CmGAmqeO.d.mts.map +1 -0
- package/dist/placeholder-SmpOx-_v.mjs +243 -0
- package/dist/placeholder-SmpOx-_v.mjs.map +1 -0
- package/dist/plugin-utils.d.mts +58 -0
- package/dist/plugin-utils.d.mts.map +1 -0
- package/dist/plugin-utils.mjs +78 -0
- package/dist/plugin-utils.mjs.map +1 -0
- package/dist/plugins/adapt-sandbox-entry.d.mts +22 -0
- package/dist/plugins/adapt-sandbox-entry.d.mts.map +1 -0
- package/dist/plugins/adapt-sandbox-entry.mjs +113 -0
- package/dist/plugins/adapt-sandbox-entry.mjs.map +1 -0
- package/dist/query-CS_iSj34.mjs +460 -0
- package/dist/query-CS_iSj34.mjs.map +1 -0
- package/dist/redirect-DIfIni3r.mjs +329 -0
- package/dist/redirect-DIfIni3r.mjs.map +1 -0
- package/dist/registry-D_w5HW4G.mjs +863 -0
- package/dist/registry-D_w5HW4G.mjs.map +1 -0
- package/dist/request-context.d.mts +49 -0
- package/dist/request-context.d.mts.map +1 -0
- package/dist/request-context.mjs +43 -0
- package/dist/request-context.mjs.map +1 -0
- package/dist/runner-B-u2F2b6.mjs +1412 -0
- package/dist/runner-B-u2F2b6.mjs.map +1 -0
- package/dist/runner-EAtf0ZIe.d.mts +27 -0
- package/dist/runner-EAtf0ZIe.d.mts.map +1 -0
- package/dist/runtime.d.mts +26 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +42 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/search-DG603UrT.mjs +9211 -0
- package/dist/search-DG603UrT.mjs.map +1 -0
- package/dist/seed/index.d.mts +3 -0
- package/dist/seed/index.mjs +15 -0
- package/dist/seo/index.d.mts +70 -0
- package/dist/seo/index.d.mts.map +1 -0
- package/dist/seo/index.mjs +70 -0
- package/dist/seo/index.mjs.map +1 -0
- package/dist/storage/local.d.mts +39 -0
- package/dist/storage/local.d.mts.map +1 -0
- package/dist/storage/local.mjs +166 -0
- package/dist/storage/local.mjs.map +1 -0
- package/dist/storage/s3.d.mts +32 -0
- package/dist/storage/s3.d.mts.map +1 -0
- package/dist/storage/s3.mjs +175 -0
- package/dist/storage/s3.mjs.map +1 -0
- package/dist/tokens-DpgrkrXK.mjs +171 -0
- package/dist/tokens-DpgrkrXK.mjs.map +1 -0
- package/dist/transport-BFGblqwG.d.mts +42 -0
- package/dist/transport-BFGblqwG.d.mts.map +1 -0
- package/dist/transport-yxiQsi8I.mjs +418 -0
- package/dist/transport-yxiQsi8I.mjs.map +1 -0
- package/dist/types-BRuPJGdV.d.mts +102 -0
- package/dist/types-BRuPJGdV.d.mts.map +1 -0
- package/dist/types-C4-fAxN3.d.mts +182 -0
- package/dist/types-C4-fAxN3.d.mts.map +1 -0
- package/dist/types-CMMN0pNg.mjs +31 -0
- package/dist/types-CMMN0pNg.mjs.map +1 -0
- package/dist/types-CUBbjgmP.mjs +16 -0
- package/dist/types-CUBbjgmP.mjs.map +1 -0
- package/dist/types-DRjfYOEv.d.mts +426 -0
- package/dist/types-DRjfYOEv.d.mts.map +1 -0
- package/dist/types-DY5zk5HN.mjs +73 -0
- package/dist/types-DY5zk5HN.mjs.map +1 -0
- package/dist/types-DaNLHo_T.d.mts +184 -0
- package/dist/types-DaNLHo_T.d.mts.map +1 -0
- package/dist/types-DvhsUmSJ.d.mts +1111 -0
- package/dist/types-DvhsUmSJ.d.mts.map +1 -0
- package/dist/validate-CpBtVMsD.d.mts +378 -0
- package/dist/validate-CpBtVMsD.d.mts.map +1 -0
- package/dist/validate-CqRJb_xU.mjs +97 -0
- package/dist/validate-CqRJb_xU.mjs.map +1 -0
- package/dist/validate-O7PWmlnq.mjs +328 -0
- package/dist/validate-O7PWmlnq.mjs.map +1 -0
- package/locals.d.ts +46 -0
- package/package.json +233 -19
- package/src/api/authorize.ts +63 -0
- package/src/api/csrf.ts +48 -0
- package/src/api/error.ts +99 -0
- package/src/api/errors.ts +445 -0
- package/src/api/escape.ts +9 -0
- package/src/api/handlers/api-tokens.ts +240 -0
- package/src/api/handlers/comments.ts +314 -0
- package/src/api/handlers/content.ts +1315 -0
- package/src/api/handlers/dashboard.ts +205 -0
- package/src/api/handlers/device-flow.ts +687 -0
- package/src/api/handlers/index.ts +163 -0
- package/src/api/handlers/manifest.ts +158 -0
- package/src/api/handlers/marketplace.ts +930 -0
- package/src/api/handlers/media.ts +207 -0
- package/src/api/handlers/menus.ts +493 -0
- package/src/api/handlers/oauth-authorization.ts +429 -0
- package/src/api/handlers/oauth-clients.ts +353 -0
- package/src/api/handlers/oauth-user-lookup.ts +39 -0
- package/src/api/handlers/plugins.ts +254 -0
- package/src/api/handlers/redirects.ts +360 -0
- package/src/api/handlers/revision.ts +145 -0
- package/src/api/handlers/schema.ts +534 -0
- package/src/api/handlers/sections.ts +289 -0
- package/src/api/handlers/seo.ts +115 -0
- package/src/api/handlers/settings.ts +49 -0
- package/src/api/handlers/snapshot.ts +350 -0
- package/src/api/handlers/taxonomies.ts +523 -0
- package/src/api/index.ts +6 -0
- package/src/api/openapi/document.ts +2368 -0
- package/src/api/openapi/index.ts +1 -0
- package/src/api/parse.ts +139 -0
- package/src/api/redirect.ts +14 -0
- package/src/api/rev.ts +67 -0
- package/src/api/schemas/auth.ts +112 -0
- package/src/api/schemas/bylines.ts +85 -0
- package/src/api/schemas/comments.ts +117 -0
- package/src/api/schemas/common.ts +89 -0
- package/src/api/schemas/content.ts +191 -0
- package/src/api/schemas/import.ts +52 -0
- package/src/api/schemas/index.ts +17 -0
- package/src/api/schemas/media.ts +116 -0
- package/src/api/schemas/menus.ts +111 -0
- package/src/api/schemas/redirects.ts +155 -0
- package/src/api/schemas/schema.ts +203 -0
- package/src/api/schemas/search.ts +63 -0
- package/src/api/schemas/sections.ts +67 -0
- package/src/api/schemas/settings.ts +63 -0
- package/src/api/schemas/setup.ts +37 -0
- package/src/api/schemas/taxonomies.ts +113 -0
- package/src/api/schemas/users.ts +96 -0
- package/src/api/schemas/widgets.ts +80 -0
- package/src/api/site-url.ts +25 -0
- package/src/api/types.ts +82 -0
- package/src/astro/index.ts +27 -0
- package/src/astro/integration/index.ts +303 -0
- package/src/astro/integration/routes.ts +834 -0
- package/src/astro/integration/runtime.ts +338 -0
- package/src/astro/integration/virtual-modules.ts +469 -0
- package/src/astro/integration/vite-config.ts +328 -0
- package/src/astro/middleware/auth.ts +743 -0
- package/src/astro/middleware/redirect.ts +89 -0
- package/src/astro/middleware/request-context.ts +129 -0
- package/src/astro/middleware/setup.ts +89 -0
- package/src/astro/middleware.ts +398 -0
- package/src/astro/routes/PluginRegistry.tsx +15 -0
- package/src/astro/routes/admin.astro +81 -0
- package/src/astro/routes/api/admin/allowed-domains/[domain].ts +112 -0
- package/src/astro/routes/api/admin/allowed-domains/index.ts +108 -0
- package/src/astro/routes/api/admin/api-tokens/[id].ts +40 -0
- package/src/astro/routes/api/admin/api-tokens/index.ts +68 -0
- package/src/astro/routes/api/admin/bylines/[id]/index.ts +87 -0
- package/src/astro/routes/api/admin/bylines/index.ts +72 -0
- package/src/astro/routes/api/admin/comments/[id]/status.ts +120 -0
- package/src/astro/routes/api/admin/comments/[id].ts +64 -0
- package/src/astro/routes/api/admin/comments/bulk.ts +42 -0
- package/src/astro/routes/api/admin/comments/counts.ts +30 -0
- package/src/astro/routes/api/admin/comments/index.ts +46 -0
- package/src/astro/routes/api/admin/hooks/exclusive/[hookName].ts +91 -0
- package/src/astro/routes/api/admin/hooks/exclusive/index.ts +51 -0
- package/src/astro/routes/api/admin/oauth-clients/[id].ts +110 -0
- package/src/astro/routes/api/admin/oauth-clients/index.ts +71 -0
- package/src/astro/routes/api/admin/plugins/[id]/disable.ts +39 -0
- package/src/astro/routes/api/admin/plugins/[id]/enable.ts +39 -0
- package/src/astro/routes/api/admin/plugins/[id]/index.ts +38 -0
- package/src/astro/routes/api/admin/plugins/[id]/uninstall.ts +48 -0
- package/src/astro/routes/api/admin/plugins/[id]/update.ts +59 -0
- package/src/astro/routes/api/admin/plugins/index.ts +32 -0
- package/src/astro/routes/api/admin/plugins/marketplace/[id]/icon.ts +61 -0
- package/src/astro/routes/api/admin/plugins/marketplace/[id]/index.ts +33 -0
- package/src/astro/routes/api/admin/plugins/marketplace/[id]/install.ts +62 -0
- package/src/astro/routes/api/admin/plugins/marketplace/index.ts +38 -0
- package/src/astro/routes/api/admin/plugins/updates.ts +28 -0
- package/src/astro/routes/api/admin/themes/marketplace/[id]/index.ts +33 -0
- package/src/astro/routes/api/admin/themes/marketplace/[id]/thumbnail.ts +61 -0
- package/src/astro/routes/api/admin/themes/marketplace/index.ts +45 -0
- package/src/astro/routes/api/admin/users/[id]/disable.ts +69 -0
- package/src/astro/routes/api/admin/users/[id]/enable.ts +48 -0
- package/src/astro/routes/api/admin/users/[id]/index.ts +146 -0
- package/src/astro/routes/api/admin/users/[id]/send-recovery.ts +72 -0
- package/src/astro/routes/api/admin/users/index.ts +66 -0
- package/src/astro/routes/api/auth/dev-bypass.ts +139 -0
- package/src/astro/routes/api/auth/invite/accept.ts +52 -0
- package/src/astro/routes/api/auth/invite/complete.ts +84 -0
- package/src/astro/routes/api/auth/invite/index.ts +99 -0
- package/src/astro/routes/api/auth/logout.ts +40 -0
- package/src/astro/routes/api/auth/magic-link/send.ts +89 -0
- package/src/astro/routes/api/auth/magic-link/verify.ts +71 -0
- package/src/astro/routes/api/auth/me.ts +60 -0
- package/src/astro/routes/api/auth/oauth/[provider]/callback.ts +219 -0
- package/src/astro/routes/api/auth/oauth/[provider].ts +119 -0
- package/src/astro/routes/api/auth/passkey/[id].ts +124 -0
- package/src/astro/routes/api/auth/passkey/index.ts +54 -0
- package/src/astro/routes/api/auth/passkey/options.ts +82 -0
- package/src/astro/routes/api/auth/passkey/register/options.ts +86 -0
- package/src/astro/routes/api/auth/passkey/register/verify.ts +117 -0
- package/src/astro/routes/api/auth/passkey/verify.ts +66 -0
- package/src/astro/routes/api/auth/signup/complete.ts +85 -0
- package/src/astro/routes/api/auth/signup/request.ts +77 -0
- package/src/astro/routes/api/auth/signup/verify.ts +53 -0
- package/src/astro/routes/api/comments/[collection]/[contentId]/index.ts +312 -0
- package/src/astro/routes/api/content/[collection]/[id]/compare.ts +28 -0
- package/src/astro/routes/api/content/[collection]/[id]/discard-draft.ts +54 -0
- package/src/astro/routes/api/content/[collection]/[id]/duplicate.ts +61 -0
- package/src/astro/routes/api/content/[collection]/[id]/permanent.ts +33 -0
- package/src/astro/routes/api/content/[collection]/[id]/preview-url.ts +107 -0
- package/src/astro/routes/api/content/[collection]/[id]/publish.ts +56 -0
- package/src/astro/routes/api/content/[collection]/[id]/restore.ts +54 -0
- package/src/astro/routes/api/content/[collection]/[id]/revisions.ts +31 -0
- package/src/astro/routes/api/content/[collection]/[id]/schedule.ts +105 -0
- package/src/astro/routes/api/content/[collection]/[id]/terms/[taxonomy].ts +140 -0
- package/src/astro/routes/api/content/[collection]/[id]/translations.ts +30 -0
- package/src/astro/routes/api/content/[collection]/[id]/unpublish.ts +56 -0
- package/src/astro/routes/api/content/[collection]/[id].ts +137 -0
- package/src/astro/routes/api/content/[collection]/index.ts +59 -0
- package/src/astro/routes/api/content/[collection]/trash.ts +33 -0
- package/src/astro/routes/api/dashboard.ts +32 -0
- package/src/astro/routes/api/dev/emails.ts +36 -0
- package/src/astro/routes/api/import/probe.ts +47 -0
- package/src/astro/routes/api/import/wordpress/analyze.ts +510 -0
- package/src/astro/routes/api/import/wordpress/execute.ts +283 -0
- package/src/astro/routes/api/import/wordpress/media.ts +338 -0
- package/src/astro/routes/api/import/wordpress/prepare.ts +181 -0
- package/src/astro/routes/api/import/wordpress/rewrite-urls.ts +393 -0
- package/src/astro/routes/api/import/wordpress-plugin/analyze.ts +111 -0
- package/src/astro/routes/api/import/wordpress-plugin/callback.ts +58 -0
- package/src/astro/routes/api/import/wordpress-plugin/execute.ts +347 -0
- package/src/astro/routes/api/manifest.ts +62 -0
- package/src/astro/routes/api/mcp.ts +124 -0
- package/src/astro/routes/api/media/[id]/confirm.ts +93 -0
- package/src/astro/routes/api/media/[id].ts +145 -0
- package/src/astro/routes/api/media/file/[key].ts +79 -0
- package/src/astro/routes/api/media/providers/[providerId]/[itemId].ts +86 -0
- package/src/astro/routes/api/media/providers/[providerId]/index.ts +111 -0
- package/src/astro/routes/api/media/providers/index.ts +30 -0
- package/src/astro/routes/api/media/upload-url.ts +137 -0
- package/src/astro/routes/api/media.ts +190 -0
- package/src/astro/routes/api/menus/[name]/items.ts +87 -0
- package/src/astro/routes/api/menus/[name]/reorder.ts +33 -0
- package/src/astro/routes/api/menus/[name].ts +65 -0
- package/src/astro/routes/api/menus/index.ts +47 -0
- package/src/astro/routes/api/oauth/authorize.ts +412 -0
- package/src/astro/routes/api/oauth/device/authorize.ts +45 -0
- package/src/astro/routes/api/oauth/device/code.ts +51 -0
- package/src/astro/routes/api/oauth/device/token.ts +69 -0
- package/src/astro/routes/api/oauth/token/refresh.ts +38 -0
- package/src/astro/routes/api/oauth/token/revoke.ts +38 -0
- package/src/astro/routes/api/oauth/token.ts +184 -0
- package/src/astro/routes/api/openapi.json.ts +32 -0
- package/src/astro/routes/api/plugins/[pluginId]/[...path].ts +92 -0
- package/src/astro/routes/api/redirects/404s/index.ts +72 -0
- package/src/astro/routes/api/redirects/404s/summary.ts +33 -0
- package/src/astro/routes/api/redirects/[id].ts +84 -0
- package/src/astro/routes/api/redirects/index.ts +52 -0
- package/src/astro/routes/api/revisions/[revisionId]/index.ts +29 -0
- package/src/astro/routes/api/revisions/[revisionId]/restore.ts +62 -0
- package/src/astro/routes/api/schema/collections/[slug]/fields/[fieldSlug].ts +76 -0
- package/src/astro/routes/api/schema/collections/[slug]/fields/index.ts +52 -0
- package/src/astro/routes/api/schema/collections/[slug]/fields/reorder.ts +32 -0
- package/src/astro/routes/api/schema/collections/[slug]/index.ts +80 -0
- package/src/astro/routes/api/schema/collections/index.ts +47 -0
- package/src/astro/routes/api/schema/index.ts +109 -0
- package/src/astro/routes/api/schema/orphans/[slug].ts +36 -0
- package/src/astro/routes/api/schema/orphans/index.ts +26 -0
- package/src/astro/routes/api/search/enable.ts +64 -0
- package/src/astro/routes/api/search/index.ts +55 -0
- package/src/astro/routes/api/search/rebuild.ts +72 -0
- package/src/astro/routes/api/search/stats.ts +35 -0
- package/src/astro/routes/api/search/suggest.ts +53 -0
- package/src/astro/routes/api/sections/[slug].ts +84 -0
- package/src/astro/routes/api/sections/index.ts +52 -0
- package/src/astro/routes/api/settings/email.ts +150 -0
- package/src/astro/routes/api/settings.ts +67 -0
- package/src/astro/routes/api/setup/admin-verify.ts +100 -0
- package/src/astro/routes/api/setup/admin.ts +94 -0
- package/src/astro/routes/api/setup/dev-bypass.ts +199 -0
- package/src/astro/routes/api/setup/dev-reset.ts +40 -0
- package/src/astro/routes/api/setup/index.ts +126 -0
- package/src/astro/routes/api/setup/status.ts +122 -0
- package/src/astro/routes/api/snapshot.ts +75 -0
- package/src/astro/routes/api/taxonomies/[name]/terms/[slug].ts +95 -0
- package/src/astro/routes/api/taxonomies/[name]/terms/index.ts +69 -0
- package/src/astro/routes/api/taxonomies/index.ts +59 -0
- package/src/astro/routes/api/themes/preview.ts +77 -0
- package/src/astro/routes/api/typegen.ts +114 -0
- package/src/astro/routes/api/well-known/auth.ts +68 -0
- package/src/astro/routes/api/well-known/oauth-authorization-server.ts +44 -0
- package/src/astro/routes/api/well-known/oauth-protected-resource.ts +37 -0
- package/src/astro/routes/api/widget-areas/[name]/reorder.ts +72 -0
- package/src/astro/routes/api/widget-areas/[name]/widgets/[id].ts +127 -0
- package/src/astro/routes/api/widget-areas/[name]/widgets.ts +80 -0
- package/src/astro/routes/api/widget-areas/[name].ts +87 -0
- package/src/astro/routes/api/widget-areas/index.ts +99 -0
- package/src/astro/routes/api/widget-components.ts +22 -0
- package/src/astro/routes/robots.txt.ts +77 -0
- package/src/astro/routes/sitemap.xml.ts +97 -0
- package/src/astro/storage/adapters.ts +74 -0
- package/src/astro/storage/index.ts +19 -0
- package/src/astro/storage/types.ts +60 -0
- package/src/astro/types.ts +346 -0
- package/src/auth/api-tokens.ts +25 -0
- package/src/auth/challenge-store.ts +80 -0
- package/src/auth/mode.ts +96 -0
- package/src/auth/oauth-state-store.ts +96 -0
- package/src/auth/passkey-config.ts +27 -0
- package/src/auth/rate-limit.ts +158 -0
- package/src/auth/scopes.ts +33 -0
- package/src/auth/types.ts +104 -0
- package/src/aws-sdk.d.ts +100 -0
- package/src/bylines/index.ts +237 -0
- package/src/cleanup.ts +153 -0
- package/src/cli/client-factory.ts +100 -0
- package/src/cli/commands/auth.ts +46 -0
- package/src/cli/commands/bundle-utils.ts +247 -0
- package/src/cli/commands/bundle.ts +609 -0
- package/src/cli/commands/content.ts +442 -0
- package/src/cli/commands/dev.ts +191 -0
- package/src/cli/commands/doctor.ts +211 -0
- package/src/cli/commands/export-seed.ts +630 -0
- package/src/cli/commands/import/wordpress.ts +1056 -0
- package/src/cli/commands/init.ts +192 -0
- package/src/cli/commands/login.ts +547 -0
- package/src/cli/commands/media.ts +165 -0
- package/src/cli/commands/menu.ts +67 -0
- package/src/cli/commands/plugin-init.ts +291 -0
- package/src/cli/commands/plugin-validate.ts +31 -0
- package/src/cli/commands/plugin.ts +33 -0
- package/src/cli/commands/publish.ts +699 -0
- package/src/cli/commands/schema.ts +233 -0
- package/src/cli/commands/search-cmd.ts +54 -0
- package/src/cli/commands/seed.ts +288 -0
- package/src/cli/commands/taxonomy.ts +128 -0
- package/src/cli/commands/types.ts +68 -0
- package/src/cli/credentials.ts +236 -0
- package/src/cli/index.ts +70 -0
- package/src/cli/output.ts +75 -0
- package/src/cli/wxr/parser.ts +969 -0
- package/src/client/cf-access.ts +193 -0
- package/src/client/index.ts +854 -0
- package/src/client/portable-text.ts +413 -0
- package/src/client/transport.ts +200 -0
- package/src/comments/moderator.ts +46 -0
- package/src/comments/notifications.ts +144 -0
- package/src/comments/query.ts +105 -0
- package/src/comments/service.ts +213 -0
- package/src/components/Break.astro +45 -0
- package/src/components/Button.astro +71 -0
- package/src/components/Buttons.astro +49 -0
- package/src/components/Code.astro +59 -0
- package/src/components/Columns.astro +59 -0
- package/src/components/CommentForm.astro +315 -0
- package/src/components/Comments.astro +232 -0
- package/src/components/Cover.astro +128 -0
- package/src/components/EmDashBodyEnd.astro +32 -0
- package/src/components/EmDashBodyStart.astro +32 -0
- package/src/components/EmDashHead.astro +53 -0
- package/src/components/EmDashImage.astro +178 -0
- package/src/components/EmDashMedia.astro +167 -0
- package/src/components/Embed.astro +128 -0
- package/src/components/File.astro +122 -0
- package/src/components/Gallery.astro +93 -0
- package/src/components/HtmlBlock.astro +33 -0
- package/src/components/Image.astro +178 -0
- package/src/components/InlineEditor.astro +27 -0
- package/src/components/InlinePortableTextEditor.tsx +1905 -0
- package/src/components/LiveSearch.astro +614 -0
- package/src/components/PortableText.astro +51 -0
- package/src/components/Pullquote.astro +51 -0
- package/src/components/Table.astro +108 -0
- package/src/components/WidgetArea.astro +22 -0
- package/src/components/WidgetRenderer.astro +72 -0
- package/src/components/index.ts +116 -0
- package/src/components/marks/Link.astro +31 -0
- package/src/components/marks/StrikeThrough.astro +7 -0
- package/src/components/marks/Subscript.astro +7 -0
- package/src/components/marks/Superscript.astro +7 -0
- package/src/components/marks/Underline.astro +7 -0
- package/src/components/widgets/Archives.astro +65 -0
- package/src/components/widgets/Categories.astro +35 -0
- package/src/components/widgets/RecentPosts.astro +51 -0
- package/src/components/widgets/Search.astro +18 -0
- package/src/components/widgets/Tags.astro +38 -0
- package/src/content/converters/index.ts +9 -0
- package/src/content/converters/portable-text-to-prosemirror.ts +385 -0
- package/src/content/converters/prosemirror-to-portable-text.ts +413 -0
- package/src/content/converters/types.ts +120 -0
- package/src/content/index.ts +5 -0
- package/src/database/connection.ts +67 -0
- package/src/database/dialect-helpers.ts +138 -0
- package/src/database/index.ts +5 -0
- package/src/database/migrations/001_initial.ts +136 -0
- package/src/database/migrations/002_media_status.ts +26 -0
- package/src/database/migrations/003_schema_registry.ts +79 -0
- package/src/database/migrations/004_plugins.ts +62 -0
- package/src/database/migrations/005_menus.ts +67 -0
- package/src/database/migrations/006_taxonomy_defs.ts +51 -0
- package/src/database/migrations/007_widgets.ts +42 -0
- package/src/database/migrations/008_auth.ts +194 -0
- package/src/database/migrations/009_user_disabled.ts +27 -0
- package/src/database/migrations/011_sections.ts +65 -0
- package/src/database/migrations/012_search.ts +25 -0
- package/src/database/migrations/013_scheduled_publishing.ts +51 -0
- package/src/database/migrations/014_draft_revisions.ts +72 -0
- package/src/database/migrations/015_indexes.ts +82 -0
- package/src/database/migrations/016_api_tokens.ts +89 -0
- package/src/database/migrations/017_authorization_codes.ts +45 -0
- package/src/database/migrations/018_seo.ts +56 -0
- package/src/database/migrations/019_i18n.ts +618 -0
- package/src/database/migrations/020_collection_url_pattern.ts +23 -0
- package/src/database/migrations/021_remove_section_categories.ts +43 -0
- package/src/database/migrations/022_marketplace_plugin_state.ts +46 -0
- package/src/database/migrations/023_plugin_metadata.ts +33 -0
- package/src/database/migrations/024_media_placeholders.ts +32 -0
- package/src/database/migrations/025_oauth_clients.ts +28 -0
- package/src/database/migrations/026_cron_tasks.ts +49 -0
- package/src/database/migrations/027_comments.ts +87 -0
- package/src/database/migrations/028_drop_author_url.ts +9 -0
- package/src/database/migrations/029_redirects.ts +67 -0
- package/src/database/migrations/030_widen_scheduled_index.ts +48 -0
- package/src/database/migrations/031_bylines.ts +90 -0
- package/src/database/migrations/032_rate_limits.ts +42 -0
- package/src/database/migrations/runner.ts +170 -0
- package/src/database/repositories/audit.ts +294 -0
- package/src/database/repositories/byline.ts +387 -0
- package/src/database/repositories/comment.ts +458 -0
- package/src/database/repositories/content.ts +1144 -0
- package/src/database/repositories/index.ts +30 -0
- package/src/database/repositories/media.ts +347 -0
- package/src/database/repositories/options.ts +150 -0
- package/src/database/repositories/plugin-storage.ts +373 -0
- package/src/database/repositories/redirect.ts +480 -0
- package/src/database/repositories/revision.ts +200 -0
- package/src/database/repositories/seo.ts +176 -0
- package/src/database/repositories/taxonomy.ts +294 -0
- package/src/database/repositories/types.ts +132 -0
- package/src/database/repositories/user.ts +258 -0
- package/src/database/transaction.ts +54 -0
- package/src/database/types.ts +501 -0
- package/src/database/validate.ts +138 -0
- package/src/db/adapters.ts +125 -0
- package/src/db/index.ts +37 -0
- package/src/db/libsql.ts +23 -0
- package/src/db/postgres.ts +30 -0
- package/src/db/sqlite.ts +27 -0
- package/src/emdash-runtime.ts +2096 -0
- package/src/fields/boolean.ts +34 -0
- package/src/fields/datetime.ts +44 -0
- package/src/fields/file.ts +41 -0
- package/src/fields/image.ts +34 -0
- package/src/fields/index.ts +42 -0
- package/src/fields/integer.ts +50 -0
- package/src/fields/json.ts +37 -0
- package/src/fields/multiselect.ts +48 -0
- package/src/fields/number.ts +52 -0
- package/src/fields/portable-text.ts +33 -0
- package/src/fields/reference.ts +29 -0
- package/src/fields/richtext.ts +31 -0
- package/src/fields/select.ts +46 -0
- package/src/fields/slug.ts +38 -0
- package/src/fields/text.ts +55 -0
- package/src/fields/textarea.ts +52 -0
- package/src/fields/types.ts +64 -0
- package/src/i18n/config.ts +68 -0
- package/src/import/index.ts +90 -0
- package/src/import/menus.ts +436 -0
- package/src/import/registry.ts +111 -0
- package/src/import/sections.ts +103 -0
- package/src/import/settings.ts +281 -0
- package/src/import/sources/wordpress-plugin.ts +641 -0
- package/src/import/sources/wordpress-rest.ts +191 -0
- package/src/import/sources/wxr.ts +330 -0
- package/src/import/ssrf.ts +260 -0
- package/src/import/types.ts +418 -0
- package/src/import/utils.ts +412 -0
- package/src/index.ts +481 -0
- package/src/loader.ts +770 -0
- package/src/mcp/server.ts +1463 -0
- package/src/media/index.ts +32 -0
- package/src/media/local-runtime.ts +213 -0
- package/src/media/local.ts +46 -0
- package/src/media/normalize.ts +190 -0
- package/src/media/placeholder.ts +150 -0
- package/src/media/provider-loader.ts +78 -0
- package/src/media/types.ts +279 -0
- package/src/menus/index.ts +324 -0
- package/src/menus/types.ts +112 -0
- package/src/page/context.ts +93 -0
- package/src/page/fragments.ts +89 -0
- package/src/page/index.ts +58 -0
- package/src/page/jsonld.ts +94 -0
- package/src/page/metadata.ts +185 -0
- package/src/page/seo-contributions.ts +136 -0
- package/src/plugin-utils.ts +80 -0
- package/src/plugins/adapt-sandbox-entry.ts +207 -0
- package/src/plugins/context.ts +833 -0
- package/src/plugins/cron.ts +361 -0
- package/src/plugins/define-plugin.ts +259 -0
- package/src/plugins/email-console.ts +73 -0
- package/src/plugins/email.ts +209 -0
- package/src/plugins/hooks.ts +1273 -0
- package/src/plugins/index.ts +193 -0
- package/src/plugins/manager.ts +595 -0
- package/src/plugins/manifest-schema.ts +230 -0
- package/src/plugins/marketplace.ts +460 -0
- package/src/plugins/request-meta.ts +139 -0
- package/src/plugins/routes.ts +302 -0
- package/src/plugins/sandbox/index.ts +18 -0
- package/src/plugins/sandbox/noop.ts +76 -0
- package/src/plugins/sandbox/types.ts +173 -0
- package/src/plugins/scheduler/node.ts +122 -0
- package/src/plugins/scheduler/piggyback.ts +71 -0
- package/src/plugins/scheduler/types.ts +27 -0
- package/src/plugins/state.ts +208 -0
- package/src/plugins/storage-indexes.ts +326 -0
- package/src/plugins/storage-query.ts +240 -0
- package/src/plugins/types.ts +1284 -0
- package/src/preview/helpers.ts +27 -0
- package/src/preview/index.ts +40 -0
- package/src/preview/tokens.ts +279 -0
- package/src/preview/urls.ts +118 -0
- package/src/query.ts +674 -0
- package/src/redirects/patterns.ts +224 -0
- package/src/request-context.ts +67 -0
- package/src/runtime.ts +21 -0
- package/src/schema/index.ts +29 -0
- package/src/schema/query.ts +44 -0
- package/src/schema/registry.ts +965 -0
- package/src/schema/types.ts +276 -0
- package/src/schema/zod-generator.ts +413 -0
- package/src/search/fts-manager.ts +452 -0
- package/src/search/index.ts +26 -0
- package/src/search/query.ts +396 -0
- package/src/search/text-extraction.ts +162 -0
- package/src/search/types.ts +114 -0
- package/src/sections/index.ts +226 -0
- package/src/sections/types.ts +86 -0
- package/src/seed/apply.ts +1141 -0
- package/src/seed/default.ts +86 -0
- package/src/seed/index.ts +28 -0
- package/src/seed/load.ts +35 -0
- package/src/seed/types.ts +341 -0
- package/src/seed/validate.ts +642 -0
- package/src/seo/index.ts +179 -0
- package/src/settings/index.ts +203 -0
- package/src/settings/types.ts +58 -0
- package/src/storage/index.ts +28 -0
- package/src/storage/local.ts +253 -0
- package/src/storage/s3.ts +271 -0
- package/src/storage/types.ts +204 -0
- package/src/taxonomies/index.ts +309 -0
- package/src/taxonomies/types.ts +61 -0
- package/src/ui.ts +75 -0
- package/src/utils/base64.ts +73 -0
- package/src/utils/hash.ts +36 -0
- package/src/utils/sanitize.ts +20 -0
- package/src/utils/slugify.ts +29 -0
- package/src/utils/url.ts +48 -0
- package/src/virtual-modules.d.ts +111 -0
- package/src/visual-editing/editable.ts +108 -0
- package/src/visual-editing/toolbar.ts +1229 -0
- package/src/widgets/components.ts +105 -0
- package/src/widgets/index.ts +131 -0
- package/src/widgets/types.ts +81 -0
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed error codes and status mapping for the EmDash REST API.
|
|
3
|
+
*
|
|
4
|
+
* All handler-level and route-level error codes are defined here.
|
|
5
|
+
* Routes and handlers should import error codes from this module
|
|
6
|
+
* instead of using ad-hoc strings.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const ErrorCode = {
|
|
10
|
+
// Shared (used across domains)
|
|
11
|
+
NOT_FOUND: "NOT_FOUND",
|
|
12
|
+
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
13
|
+
INVALID_INPUT: "INVALID_INPUT",
|
|
14
|
+
INVALID_JSON: "INVALID_JSON",
|
|
15
|
+
CONFLICT: "CONFLICT",
|
|
16
|
+
NOT_CONFIGURED: "NOT_CONFIGURED",
|
|
17
|
+
UNAUTHORIZED: "UNAUTHORIZED",
|
|
18
|
+
FORBIDDEN: "FORBIDDEN",
|
|
19
|
+
RATE_LIMITED: "RATE_LIMITED",
|
|
20
|
+
NOT_AUTHENTICATED: "NOT_AUTHENTICATED",
|
|
21
|
+
NOT_IMPLEMENTED: "NOT_IMPLEMENTED",
|
|
22
|
+
NOT_SUPPORTED: "NOT_SUPPORTED",
|
|
23
|
+
MISSING_PARAM: "MISSING_PARAM",
|
|
24
|
+
CSRF_REJECTED: "CSRF_REJECTED",
|
|
25
|
+
|
|
26
|
+
// Content
|
|
27
|
+
CONTENT_CREATE_ERROR: "CONTENT_CREATE_ERROR",
|
|
28
|
+
CONTENT_UPDATE_ERROR: "CONTENT_UPDATE_ERROR",
|
|
29
|
+
CONTENT_DELETE_ERROR: "CONTENT_DELETE_ERROR",
|
|
30
|
+
CONTENT_LIST_ERROR: "CONTENT_LIST_ERROR",
|
|
31
|
+
CONTENT_GET_ERROR: "CONTENT_GET_ERROR",
|
|
32
|
+
CONTENT_DUPLICATE_ERROR: "CONTENT_DUPLICATE_ERROR",
|
|
33
|
+
CONTENT_RESTORE_ERROR: "CONTENT_RESTORE_ERROR",
|
|
34
|
+
CONTENT_PUBLISH_ERROR: "CONTENT_PUBLISH_ERROR",
|
|
35
|
+
CONTENT_UNPUBLISH_ERROR: "CONTENT_UNPUBLISH_ERROR",
|
|
36
|
+
CONTENT_SCHEDULE_ERROR: "CONTENT_SCHEDULE_ERROR",
|
|
37
|
+
CONTENT_UNSCHEDULE_ERROR: "CONTENT_UNSCHEDULE_ERROR",
|
|
38
|
+
CONTENT_DISCARD_DRAFT_ERROR: "CONTENT_DISCARD_DRAFT_ERROR",
|
|
39
|
+
CONTENT_COMPARE_ERROR: "CONTENT_COMPARE_ERROR",
|
|
40
|
+
CONTENT_TRANSLATIONS_ERROR: "CONTENT_TRANSLATIONS_ERROR",
|
|
41
|
+
CONTENT_COUNT_ERROR: "CONTENT_COUNT_ERROR",
|
|
42
|
+
|
|
43
|
+
// Revisions
|
|
44
|
+
REVISION_LIST_ERROR: "REVISION_LIST_ERROR",
|
|
45
|
+
REVISION_GET_ERROR: "REVISION_GET_ERROR",
|
|
46
|
+
REVISION_RESTORE_ERROR: "REVISION_RESTORE_ERROR",
|
|
47
|
+
INVALID_REVISION: "INVALID_REVISION",
|
|
48
|
+
|
|
49
|
+
// Schema
|
|
50
|
+
SCHEMA_LIST_ERROR: "SCHEMA_LIST_ERROR",
|
|
51
|
+
SCHEMA_GET_ERROR: "SCHEMA_GET_ERROR",
|
|
52
|
+
SCHEMA_CREATE_ERROR: "SCHEMA_CREATE_ERROR",
|
|
53
|
+
SCHEMA_UPDATE_ERROR: "SCHEMA_UPDATE_ERROR",
|
|
54
|
+
SCHEMA_DELETE_ERROR: "SCHEMA_DELETE_ERROR",
|
|
55
|
+
SCHEMA_EXPORT_ERROR: "SCHEMA_EXPORT_ERROR",
|
|
56
|
+
SCHEMA_FIELD_LIST_ERROR: "SCHEMA_FIELD_LIST_ERROR",
|
|
57
|
+
SCHEMA_FIELD_GET_ERROR: "SCHEMA_FIELD_GET_ERROR",
|
|
58
|
+
SCHEMA_FIELD_CREATE_ERROR: "SCHEMA_FIELD_CREATE_ERROR",
|
|
59
|
+
SCHEMA_FIELD_UPDATE_ERROR: "SCHEMA_FIELD_UPDATE_ERROR",
|
|
60
|
+
SCHEMA_FIELD_DELETE_ERROR: "SCHEMA_FIELD_DELETE_ERROR",
|
|
61
|
+
SCHEMA_FIELD_REORDER_ERROR: "SCHEMA_FIELD_REORDER_ERROR",
|
|
62
|
+
ORPHAN_LIST_ERROR: "ORPHAN_LIST_ERROR",
|
|
63
|
+
ORPHAN_REGISTER_ERROR: "ORPHAN_REGISTER_ERROR",
|
|
64
|
+
COLLECTION_EXISTS: "COLLECTION_EXISTS",
|
|
65
|
+
COLLECTION_NOT_FOUND: "COLLECTION_NOT_FOUND",
|
|
66
|
+
TABLE_NOT_FOUND: "TABLE_NOT_FOUND",
|
|
67
|
+
FIELD_EXISTS: "FIELD_EXISTS",
|
|
68
|
+
RESERVED_SLUG: "RESERVED_SLUG",
|
|
69
|
+
INVALID_SLUG: "INVALID_SLUG",
|
|
70
|
+
CREATE_FAILED: "CREATE_FAILED",
|
|
71
|
+
UPDATE_FAILED: "UPDATE_FAILED",
|
|
72
|
+
REGISTER_FAILED: "REGISTER_FAILED",
|
|
73
|
+
|
|
74
|
+
// Media
|
|
75
|
+
MEDIA_LIST_ERROR: "MEDIA_LIST_ERROR",
|
|
76
|
+
MEDIA_GET_ERROR: "MEDIA_GET_ERROR",
|
|
77
|
+
MEDIA_CREATE_ERROR: "MEDIA_CREATE_ERROR",
|
|
78
|
+
MEDIA_UPDATE_ERROR: "MEDIA_UPDATE_ERROR",
|
|
79
|
+
MEDIA_DELETE_ERROR: "MEDIA_DELETE_ERROR",
|
|
80
|
+
NO_STORAGE: "NO_STORAGE",
|
|
81
|
+
NO_FILE: "NO_FILE",
|
|
82
|
+
INVALID_TYPE: "INVALID_TYPE",
|
|
83
|
+
UPLOAD_ERROR: "UPLOAD_ERROR",
|
|
84
|
+
UPLOAD_URL_ERROR: "UPLOAD_URL_ERROR",
|
|
85
|
+
CONFIRM_ERROR: "CONFIRM_ERROR",
|
|
86
|
+
CONFIRM_FAILED: "CONFIRM_FAILED",
|
|
87
|
+
FILE_NOT_FOUND: "FILE_NOT_FOUND",
|
|
88
|
+
INVALID_STATE: "INVALID_STATE",
|
|
89
|
+
FILE_SERVE_ERROR: "FILE_SERVE_ERROR",
|
|
90
|
+
STORAGE_NOT_CONFIGURED: "STORAGE_NOT_CONFIGURED",
|
|
91
|
+
PROVIDER_LIST_ERROR: "PROVIDER_LIST_ERROR",
|
|
92
|
+
PROVIDER_UPLOAD_ERROR: "PROVIDER_UPLOAD_ERROR",
|
|
93
|
+
PROVIDER_GET_ERROR: "PROVIDER_GET_ERROR",
|
|
94
|
+
PROVIDER_DELETE_ERROR: "PROVIDER_DELETE_ERROR",
|
|
95
|
+
|
|
96
|
+
// Comments
|
|
97
|
+
COMMENT_LIST_ERROR: "COMMENT_LIST_ERROR",
|
|
98
|
+
COMMENT_GET_ERROR: "COMMENT_GET_ERROR",
|
|
99
|
+
COMMENT_STATUS_ERROR: "COMMENT_STATUS_ERROR",
|
|
100
|
+
COMMENT_DELETE_ERROR: "COMMENT_DELETE_ERROR",
|
|
101
|
+
COMMENT_BULK_ERROR: "COMMENT_BULK_ERROR",
|
|
102
|
+
COMMENT_INBOX_ERROR: "COMMENT_INBOX_ERROR",
|
|
103
|
+
COMMENT_COUNTS_ERROR: "COMMENT_COUNTS_ERROR",
|
|
104
|
+
COMMENT_CREATE_ERROR: "COMMENT_CREATE_ERROR",
|
|
105
|
+
COMMENTS_DISABLED: "COMMENTS_DISABLED",
|
|
106
|
+
COMMENTS_CLOSED: "COMMENTS_CLOSED",
|
|
107
|
+
COMMENT_REJECTED: "COMMENT_REJECTED",
|
|
108
|
+
|
|
109
|
+
// Auth
|
|
110
|
+
ACCOUNT_DISABLED: "ACCOUNT_DISABLED",
|
|
111
|
+
ADMIN_EXISTS: "ADMIN_EXISTS",
|
|
112
|
+
SETUP_COMPLETE: "SETUP_COMPLETE",
|
|
113
|
+
CREDENTIAL_EXISTS: "CREDENTIAL_EXISTS",
|
|
114
|
+
CHALLENGE_EXPIRED: "CHALLENGE_EXPIRED",
|
|
115
|
+
PASSKEY_REGISTER_ERROR: "PASSKEY_REGISTER_ERROR",
|
|
116
|
+
PASSKEY_REGISTER_OPTIONS_ERROR: "PASSKEY_REGISTER_OPTIONS_ERROR",
|
|
117
|
+
PASSKEY_OPTIONS_ERROR: "PASSKEY_OPTIONS_ERROR",
|
|
118
|
+
PASSKEY_VERIFY_ERROR: "PASSKEY_VERIFY_ERROR",
|
|
119
|
+
PASSKEY_LIST_ERROR: "PASSKEY_LIST_ERROR",
|
|
120
|
+
PASSKEY_RENAME_ERROR: "PASSKEY_RENAME_ERROR",
|
|
121
|
+
PASSKEY_DELETE_ERROR: "PASSKEY_DELETE_ERROR",
|
|
122
|
+
PASSKEY_LIMIT: "PASSKEY_LIMIT",
|
|
123
|
+
LAST_PASSKEY: "LAST_PASSKEY",
|
|
124
|
+
LOGOUT_ERROR: "LOGOUT_ERROR",
|
|
125
|
+
SELF_ROLE_CHANGE: "SELF_ROLE_CHANGE",
|
|
126
|
+
EMAIL_IN_USE: "EMAIL_IN_USE",
|
|
127
|
+
EMAIL_NOT_CONFIGURED: "EMAIL_NOT_CONFIGURED",
|
|
128
|
+
USER_EXISTS: "USER_EXISTS",
|
|
129
|
+
INVALID_TOKEN: "INVALID_TOKEN",
|
|
130
|
+
TOKEN_EXPIRED: "TOKEN_EXPIRED",
|
|
131
|
+
DOMAIN_NOT_ALLOWED: "DOMAIN_NOT_ALLOWED",
|
|
132
|
+
INVITE_CREATE_ERROR: "INVITE_CREATE_ERROR",
|
|
133
|
+
INVITE_VALIDATE_ERROR: "INVITE_VALIDATE_ERROR",
|
|
134
|
+
INVITE_COMPLETE_ERROR: "INVITE_COMPLETE_ERROR",
|
|
135
|
+
SIGNUP_VERIFY_ERROR: "SIGNUP_VERIFY_ERROR",
|
|
136
|
+
SIGNUP_COMPLETE_ERROR: "SIGNUP_COMPLETE_ERROR",
|
|
137
|
+
RECOVERY_SEND_ERROR: "RECOVERY_SEND_ERROR",
|
|
138
|
+
USER_LIST_ERROR: "USER_LIST_ERROR",
|
|
139
|
+
USER_DETAIL_ERROR: "USER_DETAIL_ERROR",
|
|
140
|
+
USER_UPDATE_ERROR: "USER_UPDATE_ERROR",
|
|
141
|
+
USER_DISABLE_ERROR: "USER_DISABLE_ERROR",
|
|
142
|
+
USER_ENABLE_ERROR: "USER_ENABLE_ERROR",
|
|
143
|
+
|
|
144
|
+
// OAuth (internal codes -- distinct from RFC OAuthErrorCode)
|
|
145
|
+
UNSUPPORTED_RESPONSE_TYPE: "UNSUPPORTED_RESPONSE_TYPE",
|
|
146
|
+
INVALID_REDIRECT_URI: "INVALID_REDIRECT_URI",
|
|
147
|
+
INVALID_CLIENT: "INVALID_CLIENT",
|
|
148
|
+
INVALID_SCOPE: "INVALID_SCOPE",
|
|
149
|
+
AUTHORIZATION_ERROR: "AUTHORIZATION_ERROR",
|
|
150
|
+
INVALID_GRANT: "INVALID_GRANT",
|
|
151
|
+
UNSUPPORTED_GRANT_TYPE: "UNSUPPORTED_GRANT_TYPE",
|
|
152
|
+
INVALID_CODE: "INVALID_CODE",
|
|
153
|
+
EXPIRED_CODE: "EXPIRED_CODE",
|
|
154
|
+
INSUFFICIENT_ROLE: "INSUFFICIENT_ROLE",
|
|
155
|
+
TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR",
|
|
156
|
+
TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR",
|
|
157
|
+
TOKEN_REVOKE_ERROR: "TOKEN_REVOKE_ERROR",
|
|
158
|
+
TOKEN_CREATE_ERROR: "TOKEN_CREATE_ERROR",
|
|
159
|
+
TOKEN_LIST_ERROR: "TOKEN_LIST_ERROR",
|
|
160
|
+
TOKEN_ERROR: "TOKEN_ERROR",
|
|
161
|
+
DEVICE_CODE_ERROR: "DEVICE_CODE_ERROR",
|
|
162
|
+
AUTHORIZE_ERROR: "AUTHORIZE_ERROR",
|
|
163
|
+
CLIENT_LIST_ERROR: "CLIENT_LIST_ERROR",
|
|
164
|
+
CLIENT_GET_ERROR: "CLIENT_GET_ERROR",
|
|
165
|
+
CLIENT_CREATE_ERROR: "CLIENT_CREATE_ERROR",
|
|
166
|
+
CLIENT_UPDATE_ERROR: "CLIENT_UPDATE_ERROR",
|
|
167
|
+
CLIENT_DELETE_ERROR: "CLIENT_DELETE_ERROR",
|
|
168
|
+
|
|
169
|
+
// Allowed domains
|
|
170
|
+
DOMAIN_LIST_ERROR: "DOMAIN_LIST_ERROR",
|
|
171
|
+
DOMAIN_CREATE_ERROR: "DOMAIN_CREATE_ERROR",
|
|
172
|
+
DOMAIN_UPDATE_ERROR: "DOMAIN_UPDATE_ERROR",
|
|
173
|
+
DOMAIN_DELETE_ERROR: "DOMAIN_DELETE_ERROR",
|
|
174
|
+
|
|
175
|
+
// Plugins / Marketplace
|
|
176
|
+
PLUGIN_LIST_ERROR: "PLUGIN_LIST_ERROR",
|
|
177
|
+
PLUGIN_GET_ERROR: "PLUGIN_GET_ERROR",
|
|
178
|
+
PLUGIN_ENABLE_ERROR: "PLUGIN_ENABLE_ERROR",
|
|
179
|
+
PLUGIN_DISABLE_ERROR: "PLUGIN_DISABLE_ERROR",
|
|
180
|
+
PLUGIN_ID_CONFLICT: "PLUGIN_ID_CONFLICT",
|
|
181
|
+
MARKETPLACE_NOT_CONFIGURED: "MARKETPLACE_NOT_CONFIGURED",
|
|
182
|
+
MARKETPLACE_UNAVAILABLE: "MARKETPLACE_UNAVAILABLE",
|
|
183
|
+
MARKETPLACE_ERROR: "MARKETPLACE_ERROR",
|
|
184
|
+
SANDBOX_NOT_AVAILABLE: "SANDBOX_NOT_AVAILABLE",
|
|
185
|
+
ALREADY_INSTALLED: "ALREADY_INSTALLED",
|
|
186
|
+
ALREADY_UP_TO_DATE: "ALREADY_UP_TO_DATE",
|
|
187
|
+
NO_VERSION: "NO_VERSION",
|
|
188
|
+
MANIFEST_MISMATCH: "MANIFEST_MISMATCH",
|
|
189
|
+
MANIFEST_VERSION_MISMATCH: "MANIFEST_VERSION_MISMATCH",
|
|
190
|
+
AUDIT_FAILED: "AUDIT_FAILED",
|
|
191
|
+
CHECKSUM_MISMATCH: "CHECKSUM_MISMATCH",
|
|
192
|
+
INVALID_BUNDLE: "INVALID_BUNDLE",
|
|
193
|
+
BUNDLE_EXTRACT_FAILED: "BUNDLE_EXTRACT_FAILED",
|
|
194
|
+
BUNDLE_DOWNLOAD_FAILED: "BUNDLE_DOWNLOAD_FAILED",
|
|
195
|
+
CAPABILITY_ESCALATION: "CAPABILITY_ESCALATION",
|
|
196
|
+
ROUTE_VISIBILITY_ESCALATION: "ROUTE_VISIBILITY_ESCALATION",
|
|
197
|
+
INSTALL_FAILED: "INSTALL_FAILED",
|
|
198
|
+
UNINSTALL_FAILED: "UNINSTALL_FAILED",
|
|
199
|
+
SEARCH_FAILED: "SEARCH_FAILED",
|
|
200
|
+
GET_PLUGIN_FAILED: "GET_PLUGIN_FAILED",
|
|
201
|
+
GET_THEME_FAILED: "GET_THEME_FAILED",
|
|
202
|
+
THEME_SEARCH_FAILED: "THEME_SEARCH_FAILED",
|
|
203
|
+
UPDATE_CHECK_FAILED: "UPDATE_CHECK_FAILED",
|
|
204
|
+
EXCLUSIVE_HOOKS_LIST_ERROR: "EXCLUSIVE_HOOKS_LIST_ERROR",
|
|
205
|
+
EXCLUSIVE_HOOK_SET_ERROR: "EXCLUSIVE_HOOK_SET_ERROR",
|
|
206
|
+
|
|
207
|
+
// Menus
|
|
208
|
+
MENU_LIST_ERROR: "MENU_LIST_ERROR",
|
|
209
|
+
MENU_CREATE_ERROR: "MENU_CREATE_ERROR",
|
|
210
|
+
MENU_GET_ERROR: "MENU_GET_ERROR",
|
|
211
|
+
MENU_UPDATE_ERROR: "MENU_UPDATE_ERROR",
|
|
212
|
+
MENU_DELETE_ERROR: "MENU_DELETE_ERROR",
|
|
213
|
+
MENU_ITEM_CREATE_ERROR: "MENU_ITEM_CREATE_ERROR",
|
|
214
|
+
MENU_ITEM_UPDATE_ERROR: "MENU_ITEM_UPDATE_ERROR",
|
|
215
|
+
MENU_ITEM_DELETE_ERROR: "MENU_ITEM_DELETE_ERROR",
|
|
216
|
+
MENU_REORDER_ERROR: "MENU_REORDER_ERROR",
|
|
217
|
+
|
|
218
|
+
// Taxonomies
|
|
219
|
+
TAXONOMY_LIST_ERROR: "TAXONOMY_LIST_ERROR",
|
|
220
|
+
TAXONOMY_CREATE_ERROR: "TAXONOMY_CREATE_ERROR",
|
|
221
|
+
TERM_LIST_ERROR: "TERM_LIST_ERROR",
|
|
222
|
+
TERM_CREATE_ERROR: "TERM_CREATE_ERROR",
|
|
223
|
+
TERM_GET_ERROR: "TERM_GET_ERROR",
|
|
224
|
+
TERM_UPDATE_ERROR: "TERM_UPDATE_ERROR",
|
|
225
|
+
TERM_DELETE_ERROR: "TERM_DELETE_ERROR",
|
|
226
|
+
TERMS_GET_ERROR: "TERMS_GET_ERROR",
|
|
227
|
+
TERMS_SET_ERROR: "TERMS_SET_ERROR",
|
|
228
|
+
|
|
229
|
+
// Sections
|
|
230
|
+
SECTION_LIST_ERROR: "SECTION_LIST_ERROR",
|
|
231
|
+
SECTION_CREATE_ERROR: "SECTION_CREATE_ERROR",
|
|
232
|
+
SECTION_GET_ERROR: "SECTION_GET_ERROR",
|
|
233
|
+
SECTION_UPDATE_ERROR: "SECTION_UPDATE_ERROR",
|
|
234
|
+
SECTION_DELETE_ERROR: "SECTION_DELETE_ERROR",
|
|
235
|
+
|
|
236
|
+
// Redirects
|
|
237
|
+
REDIRECT_LIST_ERROR: "REDIRECT_LIST_ERROR",
|
|
238
|
+
REDIRECT_CREATE_ERROR: "REDIRECT_CREATE_ERROR",
|
|
239
|
+
REDIRECT_GET_ERROR: "REDIRECT_GET_ERROR",
|
|
240
|
+
REDIRECT_UPDATE_ERROR: "REDIRECT_UPDATE_ERROR",
|
|
241
|
+
REDIRECT_DELETE_ERROR: "REDIRECT_DELETE_ERROR",
|
|
242
|
+
NOT_FOUND_LIST_ERROR: "NOT_FOUND_LIST_ERROR",
|
|
243
|
+
NOT_FOUND_SUMMARY_ERROR: "NOT_FOUND_SUMMARY_ERROR",
|
|
244
|
+
NOT_FOUND_CLEAR_ERROR: "NOT_FOUND_CLEAR_ERROR",
|
|
245
|
+
NOT_FOUND_PRUNE_ERROR: "NOT_FOUND_PRUNE_ERROR",
|
|
246
|
+
|
|
247
|
+
// Widgets
|
|
248
|
+
WIDGET_AREA_LIST_ERROR: "WIDGET_AREA_LIST_ERROR",
|
|
249
|
+
WIDGET_AREA_CREATE_ERROR: "WIDGET_AREA_CREATE_ERROR",
|
|
250
|
+
WIDGET_AREA_GET_ERROR: "WIDGET_AREA_GET_ERROR",
|
|
251
|
+
WIDGET_AREA_DELETE_ERROR: "WIDGET_AREA_DELETE_ERROR",
|
|
252
|
+
WIDGET_CREATE_ERROR: "WIDGET_CREATE_ERROR",
|
|
253
|
+
WIDGET_UPDATE_ERROR: "WIDGET_UPDATE_ERROR",
|
|
254
|
+
WIDGET_DELETE_ERROR: "WIDGET_DELETE_ERROR",
|
|
255
|
+
WIDGET_REORDER_ERROR: "WIDGET_REORDER_ERROR",
|
|
256
|
+
WIDGET_COMPONENTS_ERROR: "WIDGET_COMPONENTS_ERROR",
|
|
257
|
+
|
|
258
|
+
// Setup
|
|
259
|
+
ALREADY_CONFIGURED: "ALREADY_CONFIGURED",
|
|
260
|
+
INVALID_SEED: "INVALID_SEED",
|
|
261
|
+
INVALID_REDIRECT: "INVALID_REDIRECT",
|
|
262
|
+
SETUP_ERROR: "SETUP_ERROR",
|
|
263
|
+
SETUP_STATUS_ERROR: "SETUP_STATUS_ERROR",
|
|
264
|
+
SETUP_ADMIN_ERROR: "SETUP_ADMIN_ERROR",
|
|
265
|
+
SETUP_VERIFY_ERROR: "SETUP_VERIFY_ERROR",
|
|
266
|
+
DEV_BYPASS_ERROR: "DEV_BYPASS_ERROR",
|
|
267
|
+
DEV_RESET_ERROR: "DEV_RESET_ERROR",
|
|
268
|
+
MIGRATION_ERROR: "MIGRATION_ERROR",
|
|
269
|
+
SEED_ERROR: "SEED_ERROR",
|
|
270
|
+
|
|
271
|
+
// Settings
|
|
272
|
+
SETTINGS_READ_ERROR: "SETTINGS_READ_ERROR",
|
|
273
|
+
SETTINGS_UPDATE_ERROR: "SETTINGS_UPDATE_ERROR",
|
|
274
|
+
EMAIL_SETTINGS_READ_ERROR: "EMAIL_SETTINGS_READ_ERROR",
|
|
275
|
+
EMAIL_TEST_ERROR: "EMAIL_TEST_ERROR",
|
|
276
|
+
|
|
277
|
+
// Search
|
|
278
|
+
SEARCH_ERROR: "SEARCH_ERROR",
|
|
279
|
+
STATS_ERROR: "STATS_ERROR",
|
|
280
|
+
SUGGESTION_ERROR: "SUGGESTION_ERROR",
|
|
281
|
+
REBUILD_ERROR: "REBUILD_ERROR",
|
|
282
|
+
|
|
283
|
+
// Import
|
|
284
|
+
WXR_ANALYZE_ERROR: "WXR_ANALYZE_ERROR",
|
|
285
|
+
WXR_PREPARE_ERROR: "WXR_PREPARE_ERROR",
|
|
286
|
+
WXR_IMPORT_ERROR: "WXR_IMPORT_ERROR",
|
|
287
|
+
IMPORT_ERROR: "IMPORT_ERROR",
|
|
288
|
+
REWRITE_ERROR: "REWRITE_ERROR",
|
|
289
|
+
WP_PLUGIN_ANALYZE_ERROR: "WP_PLUGIN_ANALYZE_ERROR",
|
|
290
|
+
WP_PLUGIN_IMPORT_ERROR: "WP_PLUGIN_IMPORT_ERROR",
|
|
291
|
+
SSRF_BLOCKED: "SSRF_BLOCKED",
|
|
292
|
+
PROBE_ERROR: "PROBE_ERROR",
|
|
293
|
+
|
|
294
|
+
// Dashboard
|
|
295
|
+
DASHBOARD_ERROR: "DASHBOARD_ERROR",
|
|
296
|
+
DASHBOARD_STATS_ERROR: "DASHBOARD_STATS_ERROR",
|
|
297
|
+
|
|
298
|
+
// Misc
|
|
299
|
+
SNAPSHOT_ERROR: "SNAPSHOT_ERROR",
|
|
300
|
+
TYPEGEN_ERROR: "TYPEGEN_ERROR",
|
|
301
|
+
SITEMAP_ERROR: "SITEMAP_ERROR",
|
|
302
|
+
NO_DB: "NO_DB",
|
|
303
|
+
INVALID_REQUEST: "INVALID_REQUEST",
|
|
304
|
+
UNKNOWN_ACTION: "UNKNOWN_ACTION",
|
|
305
|
+
} as const;
|
|
306
|
+
|
|
307
|
+
export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* OAuth RFC 6749 error codes.
|
|
311
|
+
*
|
|
312
|
+
* These MUST be lowercase per the RFC spec. Used only by OAuth token endpoints.
|
|
313
|
+
* Separate from ErrorCode to prevent mixing conventions.
|
|
314
|
+
*/
|
|
315
|
+
export const OAuthErrorCode = {
|
|
316
|
+
INVALID_GRANT: "invalid_grant",
|
|
317
|
+
UNSUPPORTED_GRANT_TYPE: "unsupported_grant_type",
|
|
318
|
+
EXPIRED_TOKEN: "expired_token",
|
|
319
|
+
ACCESS_DENIED: "access_denied",
|
|
320
|
+
AUTHORIZATION_PENDING: "authorization_pending",
|
|
321
|
+
} as const;
|
|
322
|
+
|
|
323
|
+
export type OAuthErrorCode = (typeof OAuthErrorCode)[keyof typeof OAuthErrorCode];
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Map a handler error code to an HTTP status code.
|
|
327
|
+
*
|
|
328
|
+
* Shared codes have explicit mappings. Domain-specific `*_ERROR` codes
|
|
329
|
+
* (used in catch blocks via handleError) default to 500. Everything else
|
|
330
|
+
* defaults to 400 (client error).
|
|
331
|
+
*/
|
|
332
|
+
export function mapErrorStatus(code: string | undefined): number {
|
|
333
|
+
switch (code) {
|
|
334
|
+
// 400 Bad Request
|
|
335
|
+
case ErrorCode.VALIDATION_ERROR:
|
|
336
|
+
case ErrorCode.INVALID_INPUT:
|
|
337
|
+
case ErrorCode.INVALID_JSON:
|
|
338
|
+
case ErrorCode.MISSING_PARAM:
|
|
339
|
+
case ErrorCode.INVALID_REQUEST:
|
|
340
|
+
case ErrorCode.NOT_SUPPORTED:
|
|
341
|
+
case ErrorCode.INVALID_SLUG:
|
|
342
|
+
case ErrorCode.RESERVED_SLUG:
|
|
343
|
+
case ErrorCode.INVALID_TYPE:
|
|
344
|
+
case ErrorCode.NO_FILE:
|
|
345
|
+
case ErrorCode.INVALID_STATE:
|
|
346
|
+
case ErrorCode.INVALID_SEED:
|
|
347
|
+
case ErrorCode.INVALID_REDIRECT:
|
|
348
|
+
case ErrorCode.INVALID_TOKEN:
|
|
349
|
+
case ErrorCode.INVALID_REVISION:
|
|
350
|
+
case ErrorCode.INVALID_CODE:
|
|
351
|
+
case ErrorCode.CHALLENGE_EXPIRED:
|
|
352
|
+
case ErrorCode.EXPIRED_CODE:
|
|
353
|
+
case ErrorCode.LAST_PASSKEY:
|
|
354
|
+
case ErrorCode.PASSKEY_LIMIT:
|
|
355
|
+
case ErrorCode.ADMIN_EXISTS:
|
|
356
|
+
case ErrorCode.SETUP_COMPLETE:
|
|
357
|
+
case ErrorCode.SELF_ROLE_CHANGE:
|
|
358
|
+
case ErrorCode.SSRF_BLOCKED:
|
|
359
|
+
case ErrorCode.UNKNOWN_ACTION:
|
|
360
|
+
return 400;
|
|
361
|
+
|
|
362
|
+
// 401 Unauthorized
|
|
363
|
+
case ErrorCode.UNAUTHORIZED:
|
|
364
|
+
case ErrorCode.NOT_AUTHENTICATED:
|
|
365
|
+
return 401;
|
|
366
|
+
|
|
367
|
+
// 403 Forbidden
|
|
368
|
+
case ErrorCode.FORBIDDEN:
|
|
369
|
+
case ErrorCode.CSRF_REJECTED:
|
|
370
|
+
case ErrorCode.ACCOUNT_DISABLED:
|
|
371
|
+
case ErrorCode.COMMENTS_DISABLED:
|
|
372
|
+
case ErrorCode.COMMENTS_CLOSED:
|
|
373
|
+
case ErrorCode.COMMENT_REJECTED:
|
|
374
|
+
case ErrorCode.DOMAIN_NOT_ALLOWED:
|
|
375
|
+
case ErrorCode.INSUFFICIENT_ROLE:
|
|
376
|
+
case ErrorCode.CAPABILITY_ESCALATION:
|
|
377
|
+
case ErrorCode.ROUTE_VISIBILITY_ESCALATION:
|
|
378
|
+
case ErrorCode.AUDIT_FAILED:
|
|
379
|
+
return 403;
|
|
380
|
+
|
|
381
|
+
// 404 Not Found
|
|
382
|
+
case ErrorCode.NOT_FOUND:
|
|
383
|
+
case ErrorCode.TABLE_NOT_FOUND:
|
|
384
|
+
case ErrorCode.COLLECTION_NOT_FOUND:
|
|
385
|
+
case ErrorCode.FILE_NOT_FOUND:
|
|
386
|
+
case ErrorCode.NO_VERSION:
|
|
387
|
+
return 404;
|
|
388
|
+
|
|
389
|
+
// 409 Conflict
|
|
390
|
+
case ErrorCode.CONFLICT:
|
|
391
|
+
case ErrorCode.COLLECTION_EXISTS:
|
|
392
|
+
case ErrorCode.FIELD_EXISTS:
|
|
393
|
+
case ErrorCode.CREDENTIAL_EXISTS:
|
|
394
|
+
case ErrorCode.EMAIL_IN_USE:
|
|
395
|
+
case ErrorCode.USER_EXISTS:
|
|
396
|
+
case ErrorCode.PLUGIN_ID_CONFLICT:
|
|
397
|
+
case ErrorCode.ALREADY_INSTALLED:
|
|
398
|
+
case ErrorCode.ALREADY_CONFIGURED:
|
|
399
|
+
case ErrorCode.ALREADY_UP_TO_DATE:
|
|
400
|
+
return 409;
|
|
401
|
+
|
|
402
|
+
// 410 Gone
|
|
403
|
+
case ErrorCode.TOKEN_EXPIRED:
|
|
404
|
+
return 410;
|
|
405
|
+
|
|
406
|
+
// 422 Unprocessable Entity
|
|
407
|
+
case ErrorCode.CHECKSUM_MISMATCH:
|
|
408
|
+
case ErrorCode.INVALID_BUNDLE:
|
|
409
|
+
case ErrorCode.BUNDLE_EXTRACT_FAILED:
|
|
410
|
+
return 422;
|
|
411
|
+
|
|
412
|
+
// 429 Too Many Requests
|
|
413
|
+
case ErrorCode.RATE_LIMITED:
|
|
414
|
+
return 429;
|
|
415
|
+
|
|
416
|
+
// 500 Internal Server Error
|
|
417
|
+
case ErrorCode.NOT_CONFIGURED:
|
|
418
|
+
case ErrorCode.NO_STORAGE:
|
|
419
|
+
case ErrorCode.NO_DB:
|
|
420
|
+
case ErrorCode.STORAGE_NOT_CONFIGURED:
|
|
421
|
+
case ErrorCode.EMAIL_NOT_CONFIGURED:
|
|
422
|
+
return 500;
|
|
423
|
+
|
|
424
|
+
// 501 Not Implemented
|
|
425
|
+
case ErrorCode.NOT_IMPLEMENTED:
|
|
426
|
+
return 501;
|
|
427
|
+
|
|
428
|
+
// 502 Bad Gateway
|
|
429
|
+
case ErrorCode.BUNDLE_DOWNLOAD_FAILED:
|
|
430
|
+
return 502;
|
|
431
|
+
|
|
432
|
+
// 503 Service Unavailable
|
|
433
|
+
case ErrorCode.MARKETPLACE_UNAVAILABLE:
|
|
434
|
+
case ErrorCode.MARKETPLACE_NOT_CONFIGURED:
|
|
435
|
+
case ErrorCode.SANDBOX_NOT_AVAILABLE:
|
|
436
|
+
return 503;
|
|
437
|
+
|
|
438
|
+
// Domain-specific *_ERROR codes are catch-block codes -- always 500.
|
|
439
|
+
// WARNING: If adding a new code that ends in _ERROR but represents a
|
|
440
|
+
// client error (4xx), add it to an explicit case above or it will
|
|
441
|
+
// be incorrectly mapped to 500.
|
|
442
|
+
default:
|
|
443
|
+
return code?.endsWith("_ERROR") ? 500 : 400;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** HTML-escape a string to prevent XSS when interpolated into HTML/JS */
|
|
2
|
+
export function escapeHtml(str: string): string {
|
|
3
|
+
return str
|
|
4
|
+
.replaceAll("&", "&")
|
|
5
|
+
.replaceAll("<", "<")
|
|
6
|
+
.replaceAll(">", ">")
|
|
7
|
+
.replaceAll('"', """)
|
|
8
|
+
.replaceAll("'", "'");
|
|
9
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API token management handlers.
|
|
3
|
+
*
|
|
4
|
+
* Creates, lists, and revokes Personal Access Tokens (PATs).
|
|
5
|
+
* Token format: ec_pat_<base64url>
|
|
6
|
+
* Only the SHA-256 hash is stored — raw token shown once at creation.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { Kysely } from "kysely";
|
|
10
|
+
import { ulid } from "ulidx";
|
|
11
|
+
|
|
12
|
+
import { hashApiToken, generatePrefixedToken } from "../../auth/api-tokens.js";
|
|
13
|
+
import type { Database } from "../../database/types.js";
|
|
14
|
+
import type { ApiResult } from "../types.js";
|
|
15
|
+
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Types
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
export interface ApiTokenInfo {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
prefix: string;
|
|
24
|
+
scopes: string[];
|
|
25
|
+
userId: string;
|
|
26
|
+
expiresAt: string | null;
|
|
27
|
+
lastUsedAt: string | null;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ApiTokenCreateResult {
|
|
32
|
+
/** The raw token — shown once, never stored */
|
|
33
|
+
token: string;
|
|
34
|
+
/** Token metadata */
|
|
35
|
+
info: ApiTokenInfo;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Handlers
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Create a new API token for a user.
|
|
44
|
+
*/
|
|
45
|
+
export async function handleApiTokenCreate(
|
|
46
|
+
db: Kysely<Database>,
|
|
47
|
+
userId: string,
|
|
48
|
+
input: {
|
|
49
|
+
name: string;
|
|
50
|
+
scopes: string[];
|
|
51
|
+
expiresAt?: string;
|
|
52
|
+
},
|
|
53
|
+
): Promise<ApiResult<ApiTokenCreateResult>> {
|
|
54
|
+
try {
|
|
55
|
+
const id = ulid();
|
|
56
|
+
const { raw, hash, prefix } = generatePrefixedToken("ec_pat_");
|
|
57
|
+
|
|
58
|
+
await db
|
|
59
|
+
.insertInto("_emdash_api_tokens")
|
|
60
|
+
.values({
|
|
61
|
+
id,
|
|
62
|
+
name: input.name,
|
|
63
|
+
token_hash: hash,
|
|
64
|
+
prefix,
|
|
65
|
+
user_id: userId,
|
|
66
|
+
scopes: JSON.stringify(input.scopes),
|
|
67
|
+
expires_at: input.expiresAt ?? null,
|
|
68
|
+
})
|
|
69
|
+
.execute();
|
|
70
|
+
|
|
71
|
+
const info: ApiTokenInfo = {
|
|
72
|
+
id,
|
|
73
|
+
name: input.name,
|
|
74
|
+
prefix,
|
|
75
|
+
scopes: input.scopes,
|
|
76
|
+
userId,
|
|
77
|
+
expiresAt: input.expiresAt ?? null,
|
|
78
|
+
lastUsedAt: null,
|
|
79
|
+
createdAt: new Date().toISOString(),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
return { success: true, data: { token: raw, info } };
|
|
83
|
+
} catch {
|
|
84
|
+
return {
|
|
85
|
+
success: false,
|
|
86
|
+
error: {
|
|
87
|
+
code: "TOKEN_CREATE_ERROR",
|
|
88
|
+
message: "Failed to create API token",
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* List all API tokens for a user (never returns the raw token or hash).
|
|
96
|
+
*/
|
|
97
|
+
export async function handleApiTokenList(
|
|
98
|
+
db: Kysely<Database>,
|
|
99
|
+
userId: string,
|
|
100
|
+
): Promise<ApiResult<{ items: ApiTokenInfo[] }>> {
|
|
101
|
+
try {
|
|
102
|
+
const rows = await db
|
|
103
|
+
.selectFrom("_emdash_api_tokens")
|
|
104
|
+
.select([
|
|
105
|
+
"id",
|
|
106
|
+
"name",
|
|
107
|
+
"prefix",
|
|
108
|
+
"scopes",
|
|
109
|
+
"user_id",
|
|
110
|
+
"expires_at",
|
|
111
|
+
"last_used_at",
|
|
112
|
+
"created_at",
|
|
113
|
+
])
|
|
114
|
+
.where("user_id", "=", userId)
|
|
115
|
+
.orderBy("created_at", "desc")
|
|
116
|
+
.execute();
|
|
117
|
+
|
|
118
|
+
const items: ApiTokenInfo[] = rows.map((row) => ({
|
|
119
|
+
id: row.id,
|
|
120
|
+
name: row.name,
|
|
121
|
+
prefix: row.prefix,
|
|
122
|
+
scopes: JSON.parse(row.scopes) as string[],
|
|
123
|
+
userId: row.user_id,
|
|
124
|
+
expiresAt: row.expires_at,
|
|
125
|
+
lastUsedAt: row.last_used_at,
|
|
126
|
+
createdAt: row.created_at,
|
|
127
|
+
}));
|
|
128
|
+
|
|
129
|
+
return { success: true, data: { items } };
|
|
130
|
+
} catch {
|
|
131
|
+
return {
|
|
132
|
+
success: false,
|
|
133
|
+
error: {
|
|
134
|
+
code: "TOKEN_LIST_ERROR",
|
|
135
|
+
message: "Failed to list API tokens",
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Revoke (delete) an API token.
|
|
143
|
+
*/
|
|
144
|
+
export async function handleApiTokenRevoke(
|
|
145
|
+
db: Kysely<Database>,
|
|
146
|
+
tokenId: string,
|
|
147
|
+
userId: string,
|
|
148
|
+
): Promise<ApiResult<{ revoked: boolean }>> {
|
|
149
|
+
try {
|
|
150
|
+
const result = await db
|
|
151
|
+
.deleteFrom("_emdash_api_tokens")
|
|
152
|
+
.where("id", "=", tokenId)
|
|
153
|
+
.where("user_id", "=", userId)
|
|
154
|
+
.executeTakeFirst();
|
|
155
|
+
|
|
156
|
+
if (result.numDeletedRows === 0n) {
|
|
157
|
+
return {
|
|
158
|
+
success: false,
|
|
159
|
+
error: { code: "NOT_FOUND", message: "Token not found" },
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return { success: true, data: { revoked: true } };
|
|
164
|
+
} catch {
|
|
165
|
+
return {
|
|
166
|
+
success: false,
|
|
167
|
+
error: {
|
|
168
|
+
code: "TOKEN_REVOKE_ERROR",
|
|
169
|
+
message: "Failed to revoke API token",
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Resolve a raw API token (ec_pat_...) to a user ID and scopes.
|
|
177
|
+
* Updates last_used_at on successful lookup.
|
|
178
|
+
* Returns null if the token is invalid or expired.
|
|
179
|
+
*/
|
|
180
|
+
export async function resolveApiToken(
|
|
181
|
+
db: Kysely<Database>,
|
|
182
|
+
rawToken: string,
|
|
183
|
+
): Promise<{ userId: string; scopes: string[] } | null> {
|
|
184
|
+
const hash = hashApiToken(rawToken);
|
|
185
|
+
|
|
186
|
+
const row = await db
|
|
187
|
+
.selectFrom("_emdash_api_tokens")
|
|
188
|
+
.select(["id", "user_id", "scopes", "expires_at"])
|
|
189
|
+
.where("token_hash", "=", hash)
|
|
190
|
+
.executeTakeFirst();
|
|
191
|
+
|
|
192
|
+
if (!row) return null;
|
|
193
|
+
|
|
194
|
+
// Check expiry
|
|
195
|
+
if (row.expires_at && new Date(row.expires_at) < new Date()) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Update last_used_at (fire-and-forget, don't block the request)
|
|
200
|
+
db.updateTable("_emdash_api_tokens")
|
|
201
|
+
.set({ last_used_at: new Date().toISOString() })
|
|
202
|
+
.where("id", "=", row.id)
|
|
203
|
+
.execute()
|
|
204
|
+
.catch(() => {}); // Non-critical, swallow errors
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
userId: row.user_id,
|
|
208
|
+
scopes: JSON.parse(row.scopes) as string[],
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Resolve an OAuth access token (ec_oat_...) to a user ID and scopes.
|
|
214
|
+
* Returns null if the token is invalid or expired.
|
|
215
|
+
*/
|
|
216
|
+
export async function resolveOAuthToken(
|
|
217
|
+
db: Kysely<Database>,
|
|
218
|
+
rawToken: string,
|
|
219
|
+
): Promise<{ userId: string; scopes: string[] } | null> {
|
|
220
|
+
const hash = hashApiToken(rawToken);
|
|
221
|
+
|
|
222
|
+
const row = await db
|
|
223
|
+
.selectFrom("_emdash_oauth_tokens")
|
|
224
|
+
.select(["user_id", "scopes", "expires_at", "token_type"])
|
|
225
|
+
.where("token_hash", "=", hash)
|
|
226
|
+
.where("token_type", "=", "access")
|
|
227
|
+
.executeTakeFirst();
|
|
228
|
+
|
|
229
|
+
if (!row) return null;
|
|
230
|
+
|
|
231
|
+
// Check expiry
|
|
232
|
+
if (new Date(row.expires_at) < new Date()) {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return {
|
|
237
|
+
userId: row.user_id,
|
|
238
|
+
scopes: JSON.parse(row.scopes) as string[],
|
|
239
|
+
};
|
|
240
|
+
}
|