emdash 0.0.0-b → 0.0.2
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 +1336 -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-C0hCbYnD.mjs +1412 -0
- package/dist/runner-C0hCbYnD.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 +684 -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 +349 -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 +335 -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 +116 -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 +115 -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 +101 -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 +58 -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 +68 -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 +697 -0
- package/src/cli/commands/schema.ts +233 -0
- package/src/cli/commands/search-cmd.ts +54 -0
- package/src/cli/commands/seed.ts +286 -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 +170 -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 +39 -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 +249 -0
- package/src/storage/s3.ts +263 -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,60 @@
|
|
|
1
|
+
import { t as Interceptor } from "../transport-BFGblqwG.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/client/cf-access.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Parse headers from the EMDASH_HEADERS env var.
|
|
6
|
+
* Format: newline-separated "Name: Value" pairs.
|
|
7
|
+
* Blank lines and malformed entries are silently skipped.
|
|
8
|
+
*/
|
|
9
|
+
declare function parseHeadersFromEnv(): Record<string, string>;
|
|
10
|
+
/**
|
|
11
|
+
* Parse an array of "Name: Value" strings into a headers record.
|
|
12
|
+
* Malformed entries are silently skipped. Later values override earlier ones.
|
|
13
|
+
*/
|
|
14
|
+
declare function parseHeaderStrings(headers: string[]): Record<string, string>;
|
|
15
|
+
/**
|
|
16
|
+
* Collect all --header flag values from process.argv.
|
|
17
|
+
*
|
|
18
|
+
* citty doesn't support repeatable string args, so we parse argv directly.
|
|
19
|
+
* Handles both `--header "Name: Value"` and `--header="Name: Value"`.
|
|
20
|
+
*/
|
|
21
|
+
declare function parseHeadersFromArgv(): string[];
|
|
22
|
+
/**
|
|
23
|
+
* Resolve custom headers from all sources.
|
|
24
|
+
* Priority: env var < CLI flags (later wins).
|
|
25
|
+
*/
|
|
26
|
+
declare function resolveCustomHeaders(): Record<string, string>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a transport interceptor that injects custom headers on every request.
|
|
29
|
+
*/
|
|
30
|
+
declare function customHeadersInterceptor(headers: Record<string, string>): Interceptor;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a fetch wrapper that injects custom headers.
|
|
33
|
+
* Used by the login command for raw fetch calls before the client is created.
|
|
34
|
+
*/
|
|
35
|
+
declare function createHeaderAwareFetch(headers: Record<string, string>): typeof fetch;
|
|
36
|
+
/**
|
|
37
|
+
* Check whether a response (fetched with `redirect: "manual"`) is a
|
|
38
|
+
* Cloudflare Access redirect.
|
|
39
|
+
*/
|
|
40
|
+
declare function isAccessRedirect(response: Response): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Try to get a cached Cloudflare Access JWT via `cloudflared access token`.
|
|
43
|
+
*
|
|
44
|
+
* Returns the JWT string if cloudflared is installed and has a cached token.
|
|
45
|
+
* Returns null if cloudflared is not installed or has no cached token.
|
|
46
|
+
*/
|
|
47
|
+
declare function getCachedAccessToken(appUrl: string): Promise<string | null>;
|
|
48
|
+
/**
|
|
49
|
+
* Launch `cloudflared access login` for interactive browser-based auth.
|
|
50
|
+
*
|
|
51
|
+
* This opens a browser window for the user to authenticate with their IdP.
|
|
52
|
+
* On success, cloudflared caches the JWT locally. Call `getCachedAccessToken`
|
|
53
|
+
* afterwards to retrieve it.
|
|
54
|
+
*
|
|
55
|
+
* Returns true if the command succeeded, false otherwise.
|
|
56
|
+
*/
|
|
57
|
+
declare function runCloudflaredLogin(appUrl: string): Promise<boolean>;
|
|
58
|
+
//#endregion
|
|
59
|
+
export { createHeaderAwareFetch, customHeadersInterceptor, getCachedAccessToken, isAccessRedirect, parseHeaderStrings, parseHeadersFromArgv, parseHeadersFromEnv, resolveCustomHeaders, runCloudflaredLogin };
|
|
60
|
+
//# sourceMappingURL=cf-access.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cf-access.d.mts","names":[],"sources":["../../src/client/cf-access.ts"],"mappings":";;;;;;;;iBAiDgB,mBAAA,CAAA,GAAuB,MAAA;;AAgFvC;;;iBAtEgB,kBAAA,CAAmB,OAAA,aAAoB,MAAA;;;;;;AA6FvD;iBA5EgB,oBAAA,CAAA;;;;AAwFhB;iBAhEgB,oBAAA,CAAA,GAAwB,MAAA;;;;iBASxB,wBAAA,CAAyB,OAAA,EAAS,MAAA,mBAAyB,WAAA;;;;;iBAoB3D,sBAAA,CAAuB,OAAA,EAAS,MAAA,0BAAgC,KAAA;;;;;iBAuBhE,gBAAA,CAAiB,QAAA,EAAU,QAAA;;;;;;;iBAYrB,oBAAA,CAAqB,MAAA,WAAiB,OAAA;;;;;;;;;;iBAoBtC,mBAAA,CAAoB,MAAA,WAAiB,OAAA"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
|
|
4
|
+
//#region src/client/cf-access.ts
|
|
5
|
+
/**
|
|
6
|
+
* Custom headers + Cloudflare Access support for the EmDash client.
|
|
7
|
+
*
|
|
8
|
+
* Two concerns live here:
|
|
9
|
+
*
|
|
10
|
+
* 1. **Custom headers** — injects user-provided headers on every request.
|
|
11
|
+
* Used for reverse proxy auth (CF Access service tokens, Tailscale, etc.)
|
|
12
|
+
* Headers come from three sources (all merged, later wins):
|
|
13
|
+
* - EMDASH_HEADERS env var (newline-separated "Name: Value" pairs)
|
|
14
|
+
* - --header CLI flags (repeatable, "Name: Value" format)
|
|
15
|
+
* - Stored credentials (persisted during `emdash login --header`)
|
|
16
|
+
*
|
|
17
|
+
* 2. **Cloudflare Access detection** — when the login command hits an Access
|
|
18
|
+
* redirect, it tries `cloudflared access token` for a cached JWT, or
|
|
19
|
+
* prompts the user to run `cloudflared access login <url>`.
|
|
20
|
+
*
|
|
21
|
+
* @example CF Access service token:
|
|
22
|
+
* emdash login --url https://cms.example.com \
|
|
23
|
+
* --header "CF-Access-Client-Id: xxx" \
|
|
24
|
+
* --header "CF-Access-Client-Secret: yyy"
|
|
25
|
+
*
|
|
26
|
+
* @example Via env var:
|
|
27
|
+
* EMDASH_HEADERS="CF-Access-Client-Id: xxx\nCF-Access-Client-Secret: yyy"
|
|
28
|
+
*/
|
|
29
|
+
const execFileAsync = promisify(execFile);
|
|
30
|
+
/**
|
|
31
|
+
* Parse a single "Name: Value" header string. Returns null if malformed.
|
|
32
|
+
*/
|
|
33
|
+
function parseHeaderLine(line) {
|
|
34
|
+
const idx = line.indexOf(":");
|
|
35
|
+
if (idx === -1) return null;
|
|
36
|
+
const name = line.slice(0, idx).trim();
|
|
37
|
+
const value = line.slice(idx + 1).trim();
|
|
38
|
+
if (!name) return null;
|
|
39
|
+
return [name, value];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Parse headers from the EMDASH_HEADERS env var.
|
|
43
|
+
* Format: newline-separated "Name: Value" pairs.
|
|
44
|
+
* Blank lines and malformed entries are silently skipped.
|
|
45
|
+
*/
|
|
46
|
+
function parseHeadersFromEnv() {
|
|
47
|
+
const raw = process.env["EMDASH_HEADERS"];
|
|
48
|
+
if (!raw) return {};
|
|
49
|
+
return parseHeaderStrings(raw.split("\n"));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Parse an array of "Name: Value" strings into a headers record.
|
|
53
|
+
* Malformed entries are silently skipped. Later values override earlier ones.
|
|
54
|
+
*/
|
|
55
|
+
function parseHeaderStrings(headers) {
|
|
56
|
+
const result = {};
|
|
57
|
+
for (const h of headers) {
|
|
58
|
+
const parsed = parseHeaderLine(h);
|
|
59
|
+
if (parsed) result[parsed[0]] = parsed[1];
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Collect all --header flag values from process.argv.
|
|
65
|
+
*
|
|
66
|
+
* citty doesn't support repeatable string args, so we parse argv directly.
|
|
67
|
+
* Handles both `--header "Name: Value"` and `--header="Name: Value"`.
|
|
68
|
+
*/
|
|
69
|
+
function parseHeadersFromArgv() {
|
|
70
|
+
const headers = [];
|
|
71
|
+
const argv = process.argv;
|
|
72
|
+
for (let i = 0; i < argv.length; i++) {
|
|
73
|
+
const arg = argv[i];
|
|
74
|
+
if (arg === "--header" || arg === "-H") {
|
|
75
|
+
const next = argv[i + 1];
|
|
76
|
+
if (next && !next.startsWith("-")) {
|
|
77
|
+
headers.push(next);
|
|
78
|
+
i++;
|
|
79
|
+
}
|
|
80
|
+
} else if (arg.startsWith("--header=")) headers.push(arg.slice(9));
|
|
81
|
+
else if (arg.startsWith("-H=")) headers.push(arg.slice(3));
|
|
82
|
+
}
|
|
83
|
+
return headers;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Resolve custom headers from all sources.
|
|
87
|
+
* Priority: env var < CLI flags (later wins).
|
|
88
|
+
*/
|
|
89
|
+
function resolveCustomHeaders() {
|
|
90
|
+
const envHeaders = parseHeadersFromEnv();
|
|
91
|
+
const cliHeaders = parseHeaderStrings(parseHeadersFromArgv());
|
|
92
|
+
return {
|
|
93
|
+
...envHeaders,
|
|
94
|
+
...cliHeaders
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Creates a transport interceptor that injects custom headers on every request.
|
|
99
|
+
*/
|
|
100
|
+
function customHeadersInterceptor(headers) {
|
|
101
|
+
const entries = Object.entries(headers);
|
|
102
|
+
if (entries.length === 0) return (request, next) => next(request);
|
|
103
|
+
return (request, next) => {
|
|
104
|
+
const h = new Headers(request.headers);
|
|
105
|
+
for (const [name, value] of entries) h.set(name, value);
|
|
106
|
+
return next(new Request(request, { headers: h }));
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Creates a fetch wrapper that injects custom headers.
|
|
111
|
+
* Used by the login command for raw fetch calls before the client is created.
|
|
112
|
+
*/
|
|
113
|
+
function createHeaderAwareFetch(headers) {
|
|
114
|
+
if (Object.keys(headers).length === 0) return globalThis.fetch.bind(globalThis);
|
|
115
|
+
return (input, init) => {
|
|
116
|
+
const h = new Headers(init?.headers);
|
|
117
|
+
for (const [name, value] of Object.entries(headers)) h.set(name, value);
|
|
118
|
+
return globalThis.fetch(input, {
|
|
119
|
+
...init,
|
|
120
|
+
headers: h
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const ACCESS_LOGIN_PATTERN = /cloudflareaccess\.com\/cdn-cgi\/access\/login/;
|
|
125
|
+
/**
|
|
126
|
+
* Check whether a response (fetched with `redirect: "manual"`) is a
|
|
127
|
+
* Cloudflare Access redirect.
|
|
128
|
+
*/
|
|
129
|
+
function isAccessRedirect(response) {
|
|
130
|
+
if (response.status !== 301 && response.status !== 302) return false;
|
|
131
|
+
const location = response.headers.get("location") ?? "";
|
|
132
|
+
return ACCESS_LOGIN_PATTERN.test(location);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Try to get a cached Cloudflare Access JWT via `cloudflared access token`.
|
|
136
|
+
*
|
|
137
|
+
* Returns the JWT string if cloudflared is installed and has a cached token.
|
|
138
|
+
* Returns null if cloudflared is not installed or has no cached token.
|
|
139
|
+
*/
|
|
140
|
+
async function getCachedAccessToken(appUrl) {
|
|
141
|
+
const origin = new URL(appUrl).origin;
|
|
142
|
+
try {
|
|
143
|
+
const { stdout } = await execFileAsync("cloudflared", [
|
|
144
|
+
"access",
|
|
145
|
+
"token",
|
|
146
|
+
"-app",
|
|
147
|
+
origin
|
|
148
|
+
]);
|
|
149
|
+
return stdout.trim() || null;
|
|
150
|
+
} catch {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Launch `cloudflared access login` for interactive browser-based auth.
|
|
156
|
+
*
|
|
157
|
+
* This opens a browser window for the user to authenticate with their IdP.
|
|
158
|
+
* On success, cloudflared caches the JWT locally. Call `getCachedAccessToken`
|
|
159
|
+
* afterwards to retrieve it.
|
|
160
|
+
*
|
|
161
|
+
* Returns true if the command succeeded, false otherwise.
|
|
162
|
+
*/
|
|
163
|
+
async function runCloudflaredLogin(appUrl) {
|
|
164
|
+
const origin = new URL(appUrl).origin;
|
|
165
|
+
try {
|
|
166
|
+
await execFileAsync("cloudflared", [
|
|
167
|
+
"access",
|
|
168
|
+
"login",
|
|
169
|
+
origin
|
|
170
|
+
]);
|
|
171
|
+
return true;
|
|
172
|
+
} catch {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
//#endregion
|
|
178
|
+
export { createHeaderAwareFetch, customHeadersInterceptor, getCachedAccessToken, isAccessRedirect, parseHeaderStrings, parseHeadersFromArgv, parseHeadersFromEnv, resolveCustomHeaders, runCloudflaredLogin };
|
|
179
|
+
//# sourceMappingURL=cf-access.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cf-access.mjs","names":[],"sources":["../../src/client/cf-access.ts"],"sourcesContent":["/**\n * Custom headers + Cloudflare Access support for the EmDash client.\n *\n * Two concerns live here:\n *\n * 1. **Custom headers** — injects user-provided headers on every request.\n * Used for reverse proxy auth (CF Access service tokens, Tailscale, etc.)\n * Headers come from three sources (all merged, later wins):\n * - EMDASH_HEADERS env var (newline-separated \"Name: Value\" pairs)\n * - --header CLI flags (repeatable, \"Name: Value\" format)\n * - Stored credentials (persisted during `emdash login --header`)\n *\n * 2. **Cloudflare Access detection** — when the login command hits an Access\n * redirect, it tries `cloudflared access token` for a cached JWT, or\n * prompts the user to run `cloudflared access login <url>`.\n *\n * @example CF Access service token:\n * emdash login --url https://cms.example.com \\\n * --header \"CF-Access-Client-Id: xxx\" \\\n * --header \"CF-Access-Client-Secret: yyy\"\n *\n * @example Via env var:\n * EMDASH_HEADERS=\"CF-Access-Client-Id: xxx\\nCF-Access-Client-Secret: yyy\"\n */\n\nimport { execFile } from \"node:child_process\";\nimport { promisify } from \"node:util\";\n\nimport type { Interceptor } from \"./transport.js\";\n\nconst execFileAsync = promisify(execFile);\n\n/**\n * Parse a single \"Name: Value\" header string. Returns null if malformed.\n */\nfunction parseHeaderLine(line: string): [string, string] | null {\n\tconst idx = line.indexOf(\":\");\n\tif (idx === -1) return null;\n\tconst name = line.slice(0, idx).trim();\n\tconst value = line.slice(idx + 1).trim();\n\tif (!name) return null;\n\treturn [name, value];\n}\n\n/**\n * Parse headers from the EMDASH_HEADERS env var.\n * Format: newline-separated \"Name: Value\" pairs.\n * Blank lines and malformed entries are silently skipped.\n */\nexport function parseHeadersFromEnv(): Record<string, string> {\n\tconst raw = process.env[\"EMDASH_HEADERS\"];\n\tif (!raw) return {};\n\treturn parseHeaderStrings(raw.split(\"\\n\"));\n}\n\n/**\n * Parse an array of \"Name: Value\" strings into a headers record.\n * Malformed entries are silently skipped. Later values override earlier ones.\n */\nexport function parseHeaderStrings(headers: string[]): Record<string, string> {\n\tconst result: Record<string, string> = {};\n\tfor (const h of headers) {\n\t\tconst parsed = parseHeaderLine(h);\n\t\tif (parsed) {\n\t\t\tresult[parsed[0]] = parsed[1];\n\t\t}\n\t}\n\treturn result;\n}\n\n/**\n * Collect all --header flag values from process.argv.\n *\n * citty doesn't support repeatable string args, so we parse argv directly.\n * Handles both `--header \"Name: Value\"` and `--header=\"Name: Value\"`.\n */\nexport function parseHeadersFromArgv(): string[] {\n\tconst headers: string[] = [];\n\tconst argv = process.argv;\n\tfor (let i = 0; i < argv.length; i++) {\n\t\tconst arg = argv[i];\n\t\tif (arg === \"--header\" || arg === \"-H\") {\n\t\t\tconst next = argv[i + 1];\n\t\t\tif (next && !next.startsWith(\"-\")) {\n\t\t\t\theaders.push(next);\n\t\t\t\ti++; // skip value\n\t\t\t}\n\t\t} else if (arg.startsWith(\"--header=\")) {\n\t\t\theaders.push(arg.slice(\"--header=\".length));\n\t\t} else if (arg.startsWith(\"-H=\")) {\n\t\t\theaders.push(arg.slice(\"-H=\".length));\n\t\t}\n\t}\n\treturn headers;\n}\n\n/**\n * Resolve custom headers from all sources.\n * Priority: env var < CLI flags (later wins).\n */\nexport function resolveCustomHeaders(): Record<string, string> {\n\tconst envHeaders = parseHeadersFromEnv();\n\tconst cliHeaders = parseHeaderStrings(parseHeadersFromArgv());\n\treturn { ...envHeaders, ...cliHeaders };\n}\n\n/**\n * Creates a transport interceptor that injects custom headers on every request.\n */\nexport function customHeadersInterceptor(headers: Record<string, string>): Interceptor {\n\tconst entries = Object.entries(headers);\n\tif (entries.length === 0) {\n\t\t// No-op interceptor\n\t\treturn (request, next) => next(request);\n\t}\n\n\treturn (request, next) => {\n\t\tconst h = new Headers(request.headers);\n\t\tfor (const [name, value] of entries) {\n\t\t\th.set(name, value);\n\t\t}\n\t\treturn next(new Request(request, { headers: h }));\n\t};\n}\n\n/**\n * Creates a fetch wrapper that injects custom headers.\n * Used by the login command for raw fetch calls before the client is created.\n */\nexport function createHeaderAwareFetch(headers: Record<string, string>): typeof fetch {\n\tif (Object.keys(headers).length === 0) {\n\t\treturn globalThis.fetch.bind(globalThis);\n\t}\n\treturn (input: RequestInfo | URL, init?: RequestInit) => {\n\t\tconst h = new Headers(init?.headers);\n\t\tfor (const [name, value] of Object.entries(headers)) {\n\t\t\th.set(name, value);\n\t\t}\n\t\treturn globalThis.fetch(input, { ...init, headers: h });\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Cloudflare Access detection\n// ---------------------------------------------------------------------------\n\nconst ACCESS_LOGIN_PATTERN = /cloudflareaccess\\.com\\/cdn-cgi\\/access\\/login/;\n\n/**\n * Check whether a response (fetched with `redirect: \"manual\"`) is a\n * Cloudflare Access redirect.\n */\nexport function isAccessRedirect(response: Response): boolean {\n\tif (response.status !== 301 && response.status !== 302) return false;\n\tconst location = response.headers.get(\"location\") ?? \"\";\n\treturn ACCESS_LOGIN_PATTERN.test(location);\n}\n\n/**\n * Try to get a cached Cloudflare Access JWT via `cloudflared access token`.\n *\n * Returns the JWT string if cloudflared is installed and has a cached token.\n * Returns null if cloudflared is not installed or has no cached token.\n */\nexport async function getCachedAccessToken(appUrl: string): Promise<string | null> {\n\tconst origin = new URL(appUrl).origin;\n\ttry {\n\t\tconst { stdout } = await execFileAsync(\"cloudflared\", [\"access\", \"token\", \"-app\", origin]);\n\t\tconst token = stdout.trim();\n\t\treturn token || null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Launch `cloudflared access login` for interactive browser-based auth.\n *\n * This opens a browser window for the user to authenticate with their IdP.\n * On success, cloudflared caches the JWT locally. Call `getCachedAccessToken`\n * afterwards to retrieve it.\n *\n * Returns true if the command succeeded, false otherwise.\n */\nexport async function runCloudflaredLogin(appUrl: string): Promise<boolean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E1F,SADc,OAAO,MAAM,IACX;SACT;AACP,SAAO;;;;;;;;;;;;AAaT,eAAsB,oBAAoB,QAAkC;CAC3E,MAAM,SAAS,IAAI,IAAI,OAAO,CAAC;AAC/B,KAAI;AACH,QAAM,cAAc,eAAe;GAAC;GAAU;GAAS;GAAO,CAAC;AAC/D,SAAO;SACA;AACP,SAAO"}
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { a as tokenInterceptor, i as devBypassInterceptor, n as createTransport, r as csrfInterceptor, t as Interceptor } from "../transport-BFGblqwG.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/client/portable-text.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Portable Text <-> Markdown conversion layer.
|
|
6
|
+
*
|
|
7
|
+
* Three tiers of block handling:
|
|
8
|
+
* Tier 1: Standard PT blocks <-> standard Markdown (headings, paragraphs, lists, etc.)
|
|
9
|
+
* Tier 2: EmDash custom blocks <-> Markdown directives (future)
|
|
10
|
+
* Tier 3: Unknown blocks <-> opaque HTML comment fences (preserved, not editable)
|
|
11
|
+
*/
|
|
12
|
+
/** Minimal Portable Text block shape */
|
|
13
|
+
interface PortableTextBlock {
|
|
14
|
+
_type: string;
|
|
15
|
+
_key?: string;
|
|
16
|
+
style?: string;
|
|
17
|
+
level?: number;
|
|
18
|
+
listItem?: string;
|
|
19
|
+
markDefs?: MarkDef[];
|
|
20
|
+
children?: PortableTextSpan[];
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
interface PortableTextSpan {
|
|
24
|
+
_type: string;
|
|
25
|
+
_key?: string;
|
|
26
|
+
text?: string;
|
|
27
|
+
marks?: string[];
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
interface MarkDef {
|
|
31
|
+
_key: string;
|
|
32
|
+
_type: string;
|
|
33
|
+
href?: string;
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Convert Portable Text blocks to Markdown.
|
|
38
|
+
* Unknown block types are serialized as opaque fences.
|
|
39
|
+
*/
|
|
40
|
+
declare function portableTextToMarkdown(blocks: PortableTextBlock[]): string;
|
|
41
|
+
/**
|
|
42
|
+
* Convert Markdown to Portable Text blocks.
|
|
43
|
+
* Opaque fences (<!--ec:block ... -->) are deserialized and spliced back in.
|
|
44
|
+
*/
|
|
45
|
+
declare function markdownToPortableText(markdown: string): PortableTextBlock[];
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/client/index.d.ts
|
|
48
|
+
interface EmDashClientOptions {
|
|
49
|
+
/** Base URL of the EmDash instance */
|
|
50
|
+
baseUrl: string;
|
|
51
|
+
/** API token (ec_pat_...) or OAuth token (ec_oat_...) */
|
|
52
|
+
token?: string;
|
|
53
|
+
/** OAuth refresh token for auto-refresh on 401 */
|
|
54
|
+
refreshToken?: string;
|
|
55
|
+
/** Called when a token is refreshed (for persisting new access token) */
|
|
56
|
+
onTokenRefresh?: (accessToken: string, expiresIn: number) => void;
|
|
57
|
+
/** Use dev-bypass authentication (localhost only) */
|
|
58
|
+
devBypass?: boolean;
|
|
59
|
+
/** Additional request interceptors */
|
|
60
|
+
interceptors?: Interceptor[];
|
|
61
|
+
}
|
|
62
|
+
/** Standard API error shape */
|
|
63
|
+
interface ApiError {
|
|
64
|
+
code: string;
|
|
65
|
+
message: string;
|
|
66
|
+
details?: Record<string, unknown>;
|
|
67
|
+
}
|
|
68
|
+
/** Standard API response wrapper */
|
|
69
|
+
interface ClientResponse<T> {
|
|
70
|
+
success: true;
|
|
71
|
+
data: T;
|
|
72
|
+
}
|
|
73
|
+
/** Paginated list response */
|
|
74
|
+
interface ListResult<T> {
|
|
75
|
+
items: T[];
|
|
76
|
+
nextCursor?: string;
|
|
77
|
+
}
|
|
78
|
+
/** Content item as returned by the API */
|
|
79
|
+
interface ContentItem {
|
|
80
|
+
id: string;
|
|
81
|
+
type: string;
|
|
82
|
+
slug: string | null;
|
|
83
|
+
status: string;
|
|
84
|
+
data: Record<string, unknown>;
|
|
85
|
+
authorId: string | null;
|
|
86
|
+
createdAt: string;
|
|
87
|
+
updatedAt: string;
|
|
88
|
+
publishedAt: string | null;
|
|
89
|
+
scheduledAt: string | null;
|
|
90
|
+
liveRevisionId: string | null;
|
|
91
|
+
draftRevisionId: string | null;
|
|
92
|
+
locale: string | null;
|
|
93
|
+
translationGroup: string | null;
|
|
94
|
+
_rev?: string;
|
|
95
|
+
}
|
|
96
|
+
/** Collection metadata */
|
|
97
|
+
interface Collection {
|
|
98
|
+
slug: string;
|
|
99
|
+
label: string;
|
|
100
|
+
labelSingular: string;
|
|
101
|
+
description?: string;
|
|
102
|
+
icon?: string;
|
|
103
|
+
supports: string[];
|
|
104
|
+
}
|
|
105
|
+
/** Collection with fields */
|
|
106
|
+
interface CollectionWithFields extends Collection {
|
|
107
|
+
fields: Field[];
|
|
108
|
+
}
|
|
109
|
+
/** Field metadata */
|
|
110
|
+
interface Field {
|
|
111
|
+
slug: string;
|
|
112
|
+
label: string;
|
|
113
|
+
type: string;
|
|
114
|
+
required: boolean;
|
|
115
|
+
unique: boolean;
|
|
116
|
+
defaultValue?: unknown;
|
|
117
|
+
validation?: unknown;
|
|
118
|
+
widget?: string;
|
|
119
|
+
options?: unknown;
|
|
120
|
+
sortOrder?: number;
|
|
121
|
+
}
|
|
122
|
+
/** Media item */
|
|
123
|
+
interface MediaItem {
|
|
124
|
+
id: string;
|
|
125
|
+
filename: string;
|
|
126
|
+
key: string;
|
|
127
|
+
mimeType: string;
|
|
128
|
+
size: number;
|
|
129
|
+
width?: number;
|
|
130
|
+
height?: number;
|
|
131
|
+
alt?: string;
|
|
132
|
+
caption?: string;
|
|
133
|
+
createdAt: string;
|
|
134
|
+
updatedAt: string;
|
|
135
|
+
}
|
|
136
|
+
/** Search result */
|
|
137
|
+
interface SearchResult {
|
|
138
|
+
id: string;
|
|
139
|
+
collection: string;
|
|
140
|
+
title: string;
|
|
141
|
+
excerpt?: string;
|
|
142
|
+
score: number;
|
|
143
|
+
}
|
|
144
|
+
/** Taxonomy */
|
|
145
|
+
interface Taxonomy {
|
|
146
|
+
name: string;
|
|
147
|
+
label: string;
|
|
148
|
+
hierarchical: boolean;
|
|
149
|
+
}
|
|
150
|
+
/** Taxonomy term */
|
|
151
|
+
interface Term {
|
|
152
|
+
id: string;
|
|
153
|
+
slug: string;
|
|
154
|
+
label: string;
|
|
155
|
+
parentId?: string | null;
|
|
156
|
+
description?: string;
|
|
157
|
+
count?: number;
|
|
158
|
+
}
|
|
159
|
+
/** Menu */
|
|
160
|
+
interface Menu {
|
|
161
|
+
name: string;
|
|
162
|
+
label: string;
|
|
163
|
+
}
|
|
164
|
+
/** Menu with items */
|
|
165
|
+
interface MenuWithItems extends Menu {
|
|
166
|
+
items: MenuItem[];
|
|
167
|
+
}
|
|
168
|
+
/** Menu item */
|
|
169
|
+
interface MenuItem {
|
|
170
|
+
id: string;
|
|
171
|
+
type: string;
|
|
172
|
+
label: string;
|
|
173
|
+
customUrl?: string;
|
|
174
|
+
referenceCollection?: string;
|
|
175
|
+
referenceId?: string;
|
|
176
|
+
target?: string;
|
|
177
|
+
parentId?: string | null;
|
|
178
|
+
sortOrder: number;
|
|
179
|
+
}
|
|
180
|
+
/** Full schema export (returned by /api/schema) */
|
|
181
|
+
interface SchemaExport {
|
|
182
|
+
collections: Array<{
|
|
183
|
+
slug: string;
|
|
184
|
+
label: string;
|
|
185
|
+
labelSingular: string;
|
|
186
|
+
description?: string;
|
|
187
|
+
icon?: string;
|
|
188
|
+
supports: string[];
|
|
189
|
+
fields: Array<{
|
|
190
|
+
slug: string;
|
|
191
|
+
label: string;
|
|
192
|
+
type: string;
|
|
193
|
+
required: boolean;
|
|
194
|
+
unique: boolean;
|
|
195
|
+
defaultValue?: unknown;
|
|
196
|
+
validation?: unknown;
|
|
197
|
+
widget?: string;
|
|
198
|
+
options?: unknown;
|
|
199
|
+
}>;
|
|
200
|
+
}>;
|
|
201
|
+
version: string;
|
|
202
|
+
}
|
|
203
|
+
/** Manifest — full schema + field descriptors */
|
|
204
|
+
interface Manifest {
|
|
205
|
+
version: string;
|
|
206
|
+
hash: string;
|
|
207
|
+
collections: Record<string, {
|
|
208
|
+
label: string;
|
|
209
|
+
labelSingular: string;
|
|
210
|
+
supports: string[];
|
|
211
|
+
fields: Record<string, {
|
|
212
|
+
kind: string;
|
|
213
|
+
label?: string;
|
|
214
|
+
required?: boolean;
|
|
215
|
+
}>;
|
|
216
|
+
}>;
|
|
217
|
+
}
|
|
218
|
+
declare class EmDashApiError extends Error {
|
|
219
|
+
readonly status: number;
|
|
220
|
+
readonly code: string;
|
|
221
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
222
|
+
constructor(status: number, code: string, message: string, details?: Record<string, unknown> | undefined);
|
|
223
|
+
}
|
|
224
|
+
declare class EmDashClientError extends Error {
|
|
225
|
+
constructor(message: string);
|
|
226
|
+
}
|
|
227
|
+
declare class EmDashClient {
|
|
228
|
+
private readonly baseUrl;
|
|
229
|
+
private readonly transport;
|
|
230
|
+
/** Cached field schemas per collection for PT conversion */
|
|
231
|
+
private fieldSchemaCache;
|
|
232
|
+
constructor(options: EmDashClientOptions);
|
|
233
|
+
/** List all collections */
|
|
234
|
+
collections(): Promise<Collection[]>;
|
|
235
|
+
/** Get a single collection with its fields */
|
|
236
|
+
collection(slug: string): Promise<CollectionWithFields>;
|
|
237
|
+
/** Create a collection */
|
|
238
|
+
createCollection(input: {
|
|
239
|
+
slug: string;
|
|
240
|
+
label: string;
|
|
241
|
+
labelSingular?: string;
|
|
242
|
+
description?: string;
|
|
243
|
+
icon?: string;
|
|
244
|
+
supports?: string[];
|
|
245
|
+
}): Promise<Collection>;
|
|
246
|
+
/** Delete a collection */
|
|
247
|
+
deleteCollection(slug: string): Promise<void>;
|
|
248
|
+
/** Create a field on a collection */
|
|
249
|
+
createField(collection: string, input: {
|
|
250
|
+
slug: string;
|
|
251
|
+
type: string;
|
|
252
|
+
label: string;
|
|
253
|
+
required?: boolean;
|
|
254
|
+
unique?: boolean;
|
|
255
|
+
defaultValue?: unknown;
|
|
256
|
+
validation?: unknown;
|
|
257
|
+
widget?: string;
|
|
258
|
+
options?: unknown;
|
|
259
|
+
sortOrder?: number;
|
|
260
|
+
}): Promise<Field>;
|
|
261
|
+
/** Delete a field from a collection */
|
|
262
|
+
deleteField(collection: string, fieldSlug: string): Promise<void>;
|
|
263
|
+
/** Get full manifest (schema + field descriptors + features) */
|
|
264
|
+
manifest(): Promise<Manifest>;
|
|
265
|
+
/** Export full schema as JSON (used by `emdash types`) */
|
|
266
|
+
schemaExport(): Promise<SchemaExport>;
|
|
267
|
+
/** Export schema as TypeScript type definitions (used by `emdash types`) */
|
|
268
|
+
schemaTypes(): Promise<string>;
|
|
269
|
+
/** List content in a collection */
|
|
270
|
+
list(collection: string, options?: {
|
|
271
|
+
status?: string;
|
|
272
|
+
limit?: number;
|
|
273
|
+
cursor?: string;
|
|
274
|
+
orderBy?: string;
|
|
275
|
+
order?: "asc" | "desc";
|
|
276
|
+
locale?: string;
|
|
277
|
+
}): Promise<ListResult<ContentItem>>;
|
|
278
|
+
/** Async iterator that auto-follows cursors */
|
|
279
|
+
listAll(collection: string, options?: {
|
|
280
|
+
status?: string;
|
|
281
|
+
limit?: number;
|
|
282
|
+
orderBy?: string;
|
|
283
|
+
order?: "asc" | "desc";
|
|
284
|
+
locale?: string;
|
|
285
|
+
}): AsyncGenerator<ContentItem>;
|
|
286
|
+
/**
|
|
287
|
+
* Get a single content item. Returns the item with a `_rev` token
|
|
288
|
+
* that can be passed to update() for optimistic concurrency.
|
|
289
|
+
*/
|
|
290
|
+
get(collection: string, id: string, options?: {
|
|
291
|
+
raw?: boolean;
|
|
292
|
+
locale?: string;
|
|
293
|
+
}): Promise<ContentItem>;
|
|
294
|
+
/** Create a new content item */
|
|
295
|
+
create(collection: string, input: {
|
|
296
|
+
data: Record<string, unknown>;
|
|
297
|
+
slug?: string;
|
|
298
|
+
status?: string;
|
|
299
|
+
locale?: string;
|
|
300
|
+
translationOf?: string;
|
|
301
|
+
}): Promise<ContentItem>;
|
|
302
|
+
/**
|
|
303
|
+
* Update a content item. Pass `_rev` from a prior get() for optimistic
|
|
304
|
+
* concurrency — the server returns 409 if the item has changed.
|
|
305
|
+
* Omit `_rev` for a blind write (no conflict detection).
|
|
306
|
+
*/
|
|
307
|
+
update(collection: string, id: string, input: {
|
|
308
|
+
data?: Record<string, unknown>;
|
|
309
|
+
slug?: string;
|
|
310
|
+
status?: string;
|
|
311
|
+
_rev?: string;
|
|
312
|
+
}): Promise<ContentItem>;
|
|
313
|
+
/** Delete (soft) a content item */
|
|
314
|
+
delete(collection: string, id: string): Promise<void>;
|
|
315
|
+
/** Publish a content item */
|
|
316
|
+
publish(collection: string, id: string): Promise<void>;
|
|
317
|
+
/** Unpublish a content item */
|
|
318
|
+
unpublish(collection: string, id: string): Promise<void>;
|
|
319
|
+
/** Schedule publishing */
|
|
320
|
+
schedule(collection: string, id: string, options: {
|
|
321
|
+
at: string;
|
|
322
|
+
}): Promise<void>;
|
|
323
|
+
/** Restore a trashed content item */
|
|
324
|
+
restore(collection: string, id: string): Promise<void>;
|
|
325
|
+
/** Compare live and draft revisions */
|
|
326
|
+
compare(collection: string, id: string): Promise<{
|
|
327
|
+
hasChanges: boolean;
|
|
328
|
+
live: Record<string, unknown> | null;
|
|
329
|
+
draft: Record<string, unknown> | null;
|
|
330
|
+
}>;
|
|
331
|
+
/** Discard draft revision, reverting to the published version */
|
|
332
|
+
discardDraft(collection: string, id: string): Promise<void>;
|
|
333
|
+
/**
|
|
334
|
+
* Get all translations of a content item.
|
|
335
|
+
* Returns the translation group ID and a summary of each locale version.
|
|
336
|
+
*/
|
|
337
|
+
translations(collection: string, id: string): Promise<{
|
|
338
|
+
translationGroup: string;
|
|
339
|
+
translations: Array<{
|
|
340
|
+
id: string;
|
|
341
|
+
locale: string | null;
|
|
342
|
+
slug: string | null;
|
|
343
|
+
status: string;
|
|
344
|
+
updatedAt: string;
|
|
345
|
+
}>;
|
|
346
|
+
}>;
|
|
347
|
+
/** List media items */
|
|
348
|
+
mediaList(options?: {
|
|
349
|
+
mimeType?: string;
|
|
350
|
+
limit?: number;
|
|
351
|
+
cursor?: string;
|
|
352
|
+
}): Promise<ListResult<MediaItem>>;
|
|
353
|
+
/** Get a single media item */
|
|
354
|
+
mediaGet(id: string): Promise<MediaItem>;
|
|
355
|
+
/** Upload a media file */
|
|
356
|
+
mediaUpload(file: Uint8Array | Blob, filename: string, options?: {
|
|
357
|
+
alt?: string;
|
|
358
|
+
caption?: string;
|
|
359
|
+
contentType?: string;
|
|
360
|
+
}): Promise<MediaItem>;
|
|
361
|
+
/** Delete a media item */
|
|
362
|
+
mediaDelete(id: string): Promise<void>;
|
|
363
|
+
/** Full-text search */
|
|
364
|
+
search(query: string, options?: {
|
|
365
|
+
collection?: string;
|
|
366
|
+
locale?: string;
|
|
367
|
+
limit?: number;
|
|
368
|
+
}): Promise<SearchResult[]>;
|
|
369
|
+
/** List taxonomies */
|
|
370
|
+
taxonomies(): Promise<Taxonomy[]>;
|
|
371
|
+
/** List terms in a taxonomy */
|
|
372
|
+
terms(taxonomy: string, options?: {
|
|
373
|
+
limit?: number;
|
|
374
|
+
cursor?: string;
|
|
375
|
+
}): Promise<ListResult<Term>>;
|
|
376
|
+
/** Create a taxonomy term */
|
|
377
|
+
createTerm(taxonomy: string, input: {
|
|
378
|
+
slug: string;
|
|
379
|
+
label: string;
|
|
380
|
+
parentId?: string;
|
|
381
|
+
description?: string;
|
|
382
|
+
}): Promise<Term>;
|
|
383
|
+
/** List menus */
|
|
384
|
+
menus(): Promise<Menu[]>;
|
|
385
|
+
/** Get a menu with its items */
|
|
386
|
+
menu(name: string): Promise<MenuWithItems>;
|
|
387
|
+
/** Make a typed JSON request to the API */
|
|
388
|
+
private request;
|
|
389
|
+
/** Make a raw request — caller handles response */
|
|
390
|
+
private requestRaw;
|
|
391
|
+
/** Assert a response is OK, throw typed error if not */
|
|
392
|
+
private assertOk;
|
|
393
|
+
/** Get cached field schemas for a collection, fetching if needed */
|
|
394
|
+
private getFieldSchemas;
|
|
395
|
+
}
|
|
396
|
+
//#endregion
|
|
397
|
+
export { ApiError, ClientResponse, Collection, CollectionWithFields, ContentItem, EmDashApiError, EmDashClient, EmDashClientError, EmDashClientOptions, Field, type Interceptor, ListResult, Manifest, MediaItem, Menu, MenuItem, MenuWithItems, type PortableTextBlock, SchemaExport, SearchResult, Taxonomy, Term, createTransport, csrfInterceptor, devBypassInterceptor, markdownToPortableText, portableTextToMarkdown, tokenInterceptor };
|
|
398
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/client/portable-text.ts","../../src/client/index.ts"],"mappings":";;;;;;AAcA;;;;;;UAAiB,iBAAA;EAChB,KAAA;EACA,IAAA;EACA,KAAA;EACA,KAAA;EACA,QAAA;EACA,QAAA,GAAW,OAAA;EACX,QAAA,GAAW,gBAAA;EAAA,CACV,GAAA;AAAA;AAAA,UAGQ,gBAAA;EACT,KAAA;EACA,IAAA;EACA,IAAA;EACA,KAAA;EAAA,CACC,GAAA;AAAA;AAAA,UAGQ,OAAA;EACT,IAAA;EACA,KAAA;EACA,IAAA;EAAA,CACC,GAAA;AAAA;;;;;iBAgBc,sBAAA,CAAuB,MAAA,EAAQ,iBAAA;;;;AAA/C;iBA6HgB,sBAAA,CAAuB,QAAA,WAAmB,iBAAA;;;UCnIzC,mBAAA;EDtBS;ECwBzB,OAAA;EDxByB;EC0BzB,KAAA;EDxBA;EC0BA,YAAA;EDxBA;EC0BA,cAAA,IAAkB,WAAA,UAAqB,SAAA;EDzB3B;EC2BZ,SAAA;EDxBS;EC0BT,YAAA,GAAe,WAAA;AAAA;;UAIC,QAAA;EAChB,IAAA;EACA,OAAA;EACA,OAAA,GAAU,MAAA;AAAA;;UAIM,cAAA;EAChB,OAAA;EACA,IAAA,EAAM,CAAA;AAAA;;UAIU,UAAA;EAChB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