@heyo-sh/heyo-cms 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +44 -2
- package/dist/access/index.d.ts +9 -0
- package/dist/access/index.d.ts.map +1 -0
- package/dist/access/permissions.d.ts +54 -0
- package/dist/access/permissions.d.ts.map +1 -0
- package/dist/adapters/astro.d.ts +45 -0
- package/dist/adapters/astro.d.ts.map +1 -0
- package/dist/adapters/astro.js +1 -0
- package/dist/adapters/deliver.d.ts +26 -0
- package/dist/adapters/deliver.d.ts.map +1 -0
- package/dist/adapters/next.d.ts +45 -0
- package/dist/adapters/next.d.ts.map +1 -0
- package/dist/adapters/next.js +1 -0
- package/dist/adapters/nuxt.d.ts +51 -0
- package/dist/adapters/nuxt.d.ts.map +1 -0
- package/dist/adapters/nuxt.js +1 -0
- package/dist/adapters/react-router.d.ts +36 -0
- package/dist/adapters/react-router.d.ts.map +1 -0
- package/dist/adapters/react-router.js +1 -0
- package/dist/adapters/sveltekit.d.ts +41 -0
- package/dist/adapters/sveltekit.d.ts.map +1 -0
- package/dist/adapters/sveltekit.js +1 -0
- package/dist/ai/assistant/context.d.ts +64 -0
- package/dist/ai/assistant/context.d.ts.map +1 -0
- package/dist/ai/assistant/limits.d.ts +10 -0
- package/dist/ai/assistant/limits.d.ts.map +1 -0
- package/dist/ai/assistant/plans.d.ts +83 -0
- package/dist/ai/assistant/plans.d.ts.map +1 -0
- package/dist/ai/assistant/prompt.d.ts +22 -0
- package/dist/ai/assistant/prompt.d.ts.map +1 -0
- package/dist/ai/assistant/run.d.ts +59 -0
- package/dist/ai/assistant/run.d.ts.map +1 -0
- package/dist/ai/assistant/runtime.d.ts +35 -0
- package/dist/ai/assistant/runtime.d.ts.map +1 -0
- package/dist/ai/assistant/schema.d.ts +66 -0
- package/dist/ai/assistant/schema.d.ts.map +1 -0
- package/dist/ai/assistant/tools.d.ts +41 -0
- package/dist/ai/assistant/tools.d.ts.map +1 -0
- package/dist/ai/assistant/values.d.ts +33 -0
- package/dist/ai/assistant/values.d.ts.map +1 -0
- package/dist/ai/crypto.d.ts +12 -0
- package/dist/ai/crypto.d.ts.map +1 -0
- package/dist/ai/index.d.ts +19 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/pi.d.ts +89 -0
- package/dist/ai/pi.d.ts.map +1 -0
- package/dist/ai/registry.d.ts +66 -0
- package/dist/ai/registry.d.ts.map +1 -0
- package/dist/ai/service.d.ts +31 -0
- package/dist/ai/service.d.ts.map +1 -0
- package/dist/ai/variant-translation.d.ts +6 -0
- package/dist/ai/variant-translation.d.ts.map +1 -0
- package/dist/ai.d.ts +12 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +1 -0
- package/dist/auth/config.d.ts +65 -0
- package/dist/auth/config.d.ts.map +1 -0
- package/dist/auth/crypto.d.ts +44 -0
- package/dist/auth/crypto.d.ts.map +1 -0
- package/dist/auth/index.d.ts +15 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/oauth.d.ts +93 -0
- package/dist/auth/oauth.d.ts.map +1 -0
- package/dist/auth/service.d.ts +38 -0
- package/dist/auth/service.d.ts.map +1 -0
- package/dist/auth/totp.d.ts +34 -0
- package/dist/auth/totp.d.ts.map +1 -0
- package/dist/auth.d.ts +9 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +30 -0
- package/dist/client/index.d.ts +51 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/types.d.ts +363 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client.d.ts +46 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +1 -0
- package/dist/config.d.ts +31 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +1 -0
- package/dist/content/export.d.ts +28 -0
- package/dist/content/export.d.ts.map +1 -0
- package/dist/content/import.d.ts +65 -0
- package/dist/content/import.d.ts.map +1 -0
- package/dist/content/records.d.ts +73 -0
- package/dist/content/records.d.ts.map +1 -0
- package/dist/content.d.ts +12 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/content.js +1 -0
- package/dist/db/d1.d.ts +29 -0
- package/dist/db/d1.d.ts.map +1 -0
- package/dist/db/d1.js +1 -0
- package/dist/db/mongodb.d.ts +128 -0
- package/dist/db/mongodb.d.ts.map +1 -0
- package/dist/db/mongodb.js +2 -0
- package/dist/db/postgres.d.ts +37 -0
- package/dist/db/postgres.d.ts.map +1 -0
- package/dist/db/postgres.js +1 -0
- package/dist/db/sql/adapter.d.ts +57 -0
- package/dist/db/sql/adapter.d.ts.map +1 -0
- package/dist/db/sql/compile.d.ts +50 -0
- package/dist/db/sql/compile.d.ts.map +1 -0
- package/dist/db/sql/ddl.d.ts +34 -0
- package/dist/db/sql/ddl.d.ts.map +1 -0
- package/dist/db/sql/dialect.d.ts +37 -0
- package/dist/db/sql/dialect.d.ts.map +1 -0
- package/dist/db/sql/driver.d.ts +34 -0
- package/dist/db/sql/driver.d.ts.map +1 -0
- package/dist/db/sql/introspect.d.ts +15 -0
- package/dist/db/sql/introspect.d.ts.map +1 -0
- package/dist/db/sqlite.d.ts +50 -0
- package/dist/db/sqlite.d.ts.map +1 -0
- package/dist/db/sqlite.js +1 -0
- package/dist/defaults.d.ts +5 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/duration.d.ts +12 -0
- package/dist/duration.d.ts.map +1 -0
- package/dist/editor/builtin.d.ts +45 -0
- package/dist/editor/builtin.d.ts.map +1 -0
- package/dist/editor/index.d.ts +14 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/markdown.d.ts +19 -0
- package/dist/editor/markdown.d.ts.map +1 -0
- package/dist/editor/registry.d.ts +30 -0
- package/dist/editor/registry.d.ts.map +1 -0
- package/dist/editor/serialize.d.ts +41 -0
- package/dist/editor/serialize.d.ts.map +1 -0
- package/dist/editor.d.ts +10 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +1 -0
- package/dist/engine/access.d.ts +33 -0
- package/dist/engine/access.d.ts.map +1 -0
- package/dist/engine/activity.d.ts +16 -0
- package/dist/engine/activity.d.ts.map +1 -0
- package/dist/engine/cursor.d.ts +19 -0
- package/dist/engine/cursor.d.ts.map +1 -0
- package/dist/engine/documents.d.ts +81 -0
- package/dist/engine/documents.d.ts.map +1 -0
- package/dist/engine/engine.d.ts +295 -0
- package/dist/engine/engine.d.ts.map +1 -0
- package/dist/engine/field-access.d.ts +21 -0
- package/dist/engine/field-access.d.ts.map +1 -0
- package/dist/engine/hooks.d.ts +58 -0
- package/dist/engine/hooks.d.ts.map +1 -0
- package/dist/engine/index.d.ts +20 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/jobs.d.ts +63 -0
- package/dist/engine/jobs.d.ts.map +1 -0
- package/dist/engine/locales.d.ts +40 -0
- package/dist/engine/locales.d.ts.map +1 -0
- package/dist/engine/outbox.d.ts +81 -0
- package/dist/engine/outbox.d.ts.map +1 -0
- package/dist/engine/relations.d.ts +60 -0
- package/dist/engine/relations.d.ts.map +1 -0
- package/dist/engine/scoped-db.d.ts +13 -0
- package/dist/engine/scoped-db.d.ts.map +1 -0
- package/dist/engine/slugs.d.ts +124 -0
- package/dist/engine/slugs.d.ts.map +1 -0
- package/dist/engine/trash.d.ts +25 -0
- package/dist/engine/trash.d.ts.map +1 -0
- package/dist/errors.d.ts +42 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/fields/builtin.d.ts +169 -0
- package/dist/fields/builtin.d.ts.map +1 -0
- package/dist/fields/index.d.ts +3 -0
- package/dist/fields/index.d.ts.map +1 -0
- package/dist/fields/registry.d.ts +35 -0
- package/dist/fields/registry.d.ts.map +1 -0
- package/dist/fields.d.ts +9 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +1 -0
- package/dist/http/guard.d.ts +45 -0
- package/dist/http/guard.d.ts.map +1 -0
- package/dist/http/handler.d.ts +31 -0
- package/dist/http/handler.d.ts.map +1 -0
- package/dist/http/index.d.ts +13 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/openapi.d.ts +5 -0
- package/dist/http/openapi.d.ts.map +1 -0
- package/dist/http/params.d.ts +32 -0
- package/dist/http/params.d.ts.map +1 -0
- package/dist/http/request-db.d.ts +19 -0
- package/dist/http/request-db.d.ts.map +1 -0
- package/dist/http/respond.d.ts +48 -0
- package/dist/http/respond.d.ts.map +1 -0
- package/dist/http/rich-text.d.ts +41 -0
- package/dist/http/rich-text.d.ts.map +1 -0
- package/dist/http/router.d.ts +55 -0
- package/dist/http/router.d.ts.map +1 -0
- package/dist/http/routes/access.d.ts +13 -0
- package/dist/http/routes/access.d.ts.map +1 -0
- package/dist/http/routes/admin.d.ts +28 -0
- package/dist/http/routes/admin.d.ts.map +1 -0
- package/dist/http/routes/ai.d.ts +26 -0
- package/dist/http/routes/ai.d.ts.map +1 -0
- package/dist/http/routes/auth.d.ts +13 -0
- package/dist/http/routes/auth.d.ts.map +1 -0
- package/dist/http/routes/documents.d.ts +24 -0
- package/dist/http/routes/documents.d.ts.map +1 -0
- package/dist/http/routes/generate.d.ts +5 -0
- package/dist/http/routes/generate.d.ts.map +1 -0
- package/dist/http/routes/media.d.ts +58 -0
- package/dist/http/routes/media.d.ts.map +1 -0
- package/dist/http/routes/panel.d.ts +20 -0
- package/dist/http/routes/panel.d.ts.map +1 -0
- package/dist/http/routes/system.d.ts +25 -0
- package/dist/http/routes/system.d.ts.map +1 -0
- package/dist/http/routes/webhooks.d.ts +17 -0
- package/dist/http/routes/webhooks.d.ts.map +1 -0
- package/dist/http/spec.d.ts +28 -0
- package/dist/http/spec.d.ts.map +1 -0
- package/dist/http.d.ts +17 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +1 -0
- package/dist/i18n/index.d.ts +12 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/names.d.ts +25 -0
- package/dist/i18n/names.d.ts.map +1 -0
- package/dist/ids.d.ts +28 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/index-2ddk43me.js +2 -0
- package/dist/index-2prbs05k.js +2 -0
- package/dist/index-385ggnge.js +2 -0
- package/dist/index-466cwb0b.js +2 -0
- package/dist/index-4qrep5f0.js +26 -0
- package/dist/index-67e458ws.js +2 -0
- package/dist/index-6m1kjq9g.js +2 -0
- package/dist/index-6w10rch0.js +3 -0
- package/dist/index-761dec5z.js +2 -0
- package/dist/index-8nzmqy0f.js +2 -0
- package/dist/index-8x2em6c8.js +14 -0
- package/dist/index-91fa1gzf.js +2 -0
- package/dist/index-9g2n7xa6.js +2 -0
- package/dist/index-a8jcwqsf.js +2 -0
- package/dist/index-abfzb1ve.js +2 -0
- package/dist/index-cv0hpz3d.js +2 -0
- package/dist/index-ebtj6ebd.js +0 -0
- package/dist/index-g041kfa5.js +18 -0
- package/dist/index-g4crf47y.js +0 -0
- package/dist/index-hbx67b20.js +7 -0
- package/dist/index-hpast878.js +40 -0
- package/dist/index-kc1j3h6z.js +2 -0
- package/dist/index-p2cqsmvw.js +2 -0
- package/dist/index-rg9tpg3p.js +5 -0
- package/dist/index-rw0hze6x.js +2 -0
- package/dist/index-s9x07zb3.js +2 -0
- package/dist/index-sgdnp83t.js +2 -0
- package/dist/index-szaq03qq.js +2 -0
- package/dist/index-vkwzdfte.js +5 -0
- package/dist/index-vzhxn50e.js +2 -0
- package/dist/index-x72d1hzh.js +2 -0
- package/dist/index-y8kzzn94.js +2 -0
- package/dist/index-ypcmns0v.js +2 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/jobs/runner.d.ts +77 -0
- package/dist/jobs/runner.d.ts.map +1 -0
- package/dist/jobs.d.ts +11 -0
- package/dist/jobs.d.ts.map +1 -0
- package/dist/jobs.js +1 -0
- package/dist/media/cloudflare.d.ts +58 -0
- package/dist/media/cloudflare.d.ts.map +1 -0
- package/dist/media/document.d.ts +29 -0
- package/dist/media/document.d.ts.map +1 -0
- package/dist/media/gc.d.ts +46 -0
- package/dist/media/gc.d.ts.map +1 -0
- package/dist/media/index.d.ts +20 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/pipeline.d.ts +55 -0
- package/dist/media/pipeline.d.ts.map +1 -0
- package/dist/media/probe.d.ts +6 -0
- package/dist/media/probe.d.ts.map +1 -0
- package/dist/media/service.d.ts +26 -0
- package/dist/media/service.d.ts.map +1 -0
- package/dist/media/sharp.d.ts +28 -0
- package/dist/media/sharp.d.ts.map +1 -0
- package/dist/media/strip.d.ts +16 -0
- package/dist/media/strip.d.ts.map +1 -0
- package/dist/media/urls.d.ts +77 -0
- package/dist/media/urls.d.ts.map +1 -0
- package/dist/media/usages.d.ts +77 -0
- package/dist/media/usages.d.ts.map +1 -0
- package/dist/media/variants.d.ts +61 -0
- package/dist/media/variants.d.ts.map +1 -0
- package/dist/migrations.d.ts +115 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +1 -0
- package/dist/panel.d.ts +31 -0
- package/dist/panel.d.ts.map +1 -0
- package/dist/plugins/indexnow.d.ts +82 -0
- package/dist/plugins/indexnow.d.ts.map +1 -0
- package/dist/plugins.d.ts +9 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +1 -0
- package/dist/query.d.ts +40 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +1 -0
- package/dist/run-bjge3v8e.js +6 -0
- package/dist/schema/describe.d.ts +19 -0
- package/dist/schema/describe.d.ts.map +1 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/plan.d.ts +20 -0
- package/dist/schema/plan.d.ts.map +1 -0
- package/dist/schema/snapshot.d.ts +24 -0
- package/dist/schema/snapshot.d.ts.map +1 -0
- package/dist/schema/system.d.ts +31 -0
- package/dist/schema/system.d.ts.map +1 -0
- package/dist/schema.d.ts +7 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +1 -0
- package/dist/slugify.d.ts +31 -0
- package/dist/slugify.d.ts.map +1 -0
- package/dist/storage/bytes.d.ts +17 -0
- package/dist/storage/bytes.d.ts.map +1 -0
- package/dist/storage/http.d.ts +43 -0
- package/dist/storage/http.d.ts.map +1 -0
- package/dist/storage/local.d.ts +31 -0
- package/dist/storage/local.d.ts.map +1 -0
- package/dist/storage/providers.d.ts +95 -0
- package/dist/storage/providers.d.ts.map +1 -0
- package/dist/storage/sign.d.ts +53 -0
- package/dist/storage/sign.d.ts.map +1 -0
- package/dist/strings.d.ts +13 -0
- package/dist/strings.d.ts.map +1 -0
- package/dist/telemetry.d.ts +137 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +1 -0
- package/dist/types/activity.d.ts +68 -0
- package/dist/types/activity.d.ts.map +1 -0
- package/dist/types/actor.d.ts +26 -0
- package/dist/types/actor.d.ts.map +1 -0
- package/dist/types/ai.d.ts +357 -0
- package/dist/types/ai.d.ts.map +1 -0
- package/dist/types/api.d.ts +268 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/auth.d.ts +310 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/config.d.ts +647 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/database.d.ts +75 -0
- package/dist/types/database.d.ts.map +1 -0
- package/dist/types/editor.d.ts +166 -0
- package/dist/types/editor.d.ts.map +1 -0
- package/dist/types/events.d.ts +72 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/fields.d.ts +142 -0
- package/dist/types/fields.d.ts.map +1 -0
- package/dist/types/hooks.d.ts +142 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/index.d.ts +25 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/instance.d.ts +263 -0
- package/dist/types/instance.d.ts.map +1 -0
- package/dist/types/jobs.d.ts +78 -0
- package/dist/types/jobs.d.ts.map +1 -0
- package/dist/types/json.d.ts +24 -0
- package/dist/types/json.d.ts.map +1 -0
- package/dist/types/locales.d.ts +30 -0
- package/dist/types/locales.d.ts.map +1 -0
- package/dist/types/media.d.ts +342 -0
- package/dist/types/media.d.ts.map +1 -0
- package/dist/types/panel.d.ts +249 -0
- package/dist/types/panel.d.ts.map +1 -0
- package/dist/types/plugin.d.ts +194 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/query.d.ts +101 -0
- package/dist/types/query.d.ts.map +1 -0
- package/dist/types/schema.d.ts +203 -0
- package/dist/types/schema.d.ts.map +1 -0
- package/dist/types/storage.d.ts +61 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/telemetry.d.ts +14 -0
- package/dist/types/telemetry.d.ts.map +1 -0
- package/dist/types/trash.d.ts +42 -0
- package/dist/types/trash.d.ts.map +1 -0
- package/dist/types/webhooks.d.ts +133 -0
- package/dist/types/webhooks.d.ts.map +1 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/uploads.d.ts +22 -0
- package/dist/uploads.d.ts.map +1 -0
- package/dist/uploads.js +9 -0
- package/dist/webhooks/index.d.ts +10 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/job.d.ts +17 -0
- package/dist/webhooks/job.d.ts.map +1 -0
- package/dist/webhooks/service.d.ts +53 -0
- package/dist/webhooks/service.d.ts.map +1 -0
- package/dist/webhooks/sign.d.ts +26 -0
- package/dist/webhooks/sign.d.ts.map +1 -0
- package/dist/webhooks.d.ts +10 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +1 -0
- package/package.json +187 -4
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e}from"./index-x72d1hzh.js";var c=new Set(["dashboard","collection-list","document","global","media","trash","settings"]),g=100,r=200,f=120,m=new Set(["users","roles","locales","keys","ai","webhooks","deployment","activity"]);function no(l){if(typeof l!=="object"||l===null||Array.isArray(l))return;let n=l,i=n.kind;if(typeof i!=="string"||!c.has(i))return;let t=Array.isArray(n.dirtyFields)?n.dirtyFields.filter((s)=>typeof s==="string").slice(0,g):void 0,o=Number(n.baselineRevision);return{kind:i,...typeof n.collectionSlug==="string"?{collectionSlug:n.collectionSlug.slice(0,r)}:{},...typeof n.documentId==="string"?{documentId:n.documentId.slice(0,r)}:{},...typeof n.mediaId==="string"?{mediaId:n.mediaId.slice(0,r)}:{},...typeof n.tab==="string"&&n.tab.trim().length>0?{tab:n.tab.trim().slice(0,f)}:{},...typeof n.locale==="string"?{locale:n.locale}:{},...t&&t.length>0?{dirtyFields:t}:{},...Number.isInteger(o)&&o>0?{baselineRevision:o}:{}}}function oo(l,n,i){let t=i!==void 0&&a(l,i)?i:l.i18n.defaultLocale;if(!n)return{kind:"dashboard",collection:null,documentId:null,mediaId:null,tab:null,locale:t,dirtyFields:[],baselineRevision:null};let o=n.locale!==void 0&&a(l,n.locale)?n.locale:t,s=C(l,n);return{kind:n.kind,collection:s,documentId:n.documentId??null,mediaId:n.kind==="media"?n.mediaId??null:null,tab:b(n,s),locale:o,dirtyFields:n.dirtyFields??[],baselineRevision:n.baselineRevision??null}}function b(l,n){let i=l.tab;if(!i)return null;if(l.kind==="settings")return m.has(i)?i:null;if(l.kind==="media")return i==="active"||i==="orphaned"?i:null;if(l.kind==="document"||l.kind==="global")return n?.fields[i]?.type==="richText"?i:null;return null}function C(l,n){if(n.collectionSlug===void 0)return null;let i=n.kind==="global"?"global":n.kind==="document"||n.kind==="collection-list"?"collection":void 0;if(i===void 0)return null;let t={...l.collections,...l.globals},o=Object.values(t).find((s)=>s.slug===n.collectionSlug);if(!o||o.kind!==i)return null;return o}function L(l,n,i){let t={...l.collections,...l.globals},o=t[n],s=Object.values(t).find((u)=>u.slug===n);if(o&&s&&o.name!==s.name)throw e.validation(`"${n}" is ambiguous: it names ${o.name} and is the slug of ${s.name}. Use an unambiguous name or slug from describe_cms.`);let d=o??s;if(!d)throw e.notFound(`There is no collection called "${n}". Call describe_cms for the list.`);if(i&&d.kind!==i)throw e.validation(`"${n}" is a ${d.kind}, not a ${i}.`);return d}function a(l,n){return l.i18n.locales.includes(n)}function de(l,n,i){if(i!==void 0&&a(l,i))return i;if(i!==void 0)throw e.validation(`"${i}" is not a configured locale. Call describe_cms for the list.`);return n.locale}var ue={maxTurns:8,maxToolCalls:16,timeoutMs:90000};
|
|
2
|
+
export{no,oo,L,de,ue};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@heyo-sh/heyo-cms`.
|
|
3
|
+
*
|
|
4
|
+
* The configuration surface and the contracts. Databases, fields and storage
|
|
5
|
+
* come from their own entry points so a Worker bundle only carries what it
|
|
6
|
+
* uses.
|
|
7
|
+
*/
|
|
8
|
+
export { defaultAdminPath, defaultBasePath, defaultMigrationsDirectory, defineCollection, defineGlobal, heyoCms, systemActor, } from "./config";
|
|
9
|
+
export { aiActionsFor, createAi, defineAiAction, getAiAction, piCompletion, registeredAiActions, } from "./ai/index";
|
|
10
|
+
export { defineEditorMark, defineEditorNode, describeEditorSchema, getEditorMark, getEditorNode, registeredEditorMarks, registeredEditorNodes, renderRichText, richTextFromMarkdown, richTextFromText, richTextToHtml, richTextToMarkdown, richTextToPlainText, } from "./editor/index";
|
|
11
|
+
export { createWebhooks, signatureHeader, signPayload, verifySignature, webhookRetryJob, } from "./webhooks/index";
|
|
12
|
+
export { cmsScheduled, runDueJobs, startJobRunner, type JobRunnerHandle, type JobRunnerOptions, } from "./jobs/runner";
|
|
13
|
+
export { expandRoles, grants, intersectPermissions, isValidScope, permissionFor, permits, scopePermissions, } from "./access/index";
|
|
14
|
+
export { CmsConfigError, CmsError } from "./errors";
|
|
15
|
+
export { isRtlLocale, localeName, localeRecords, LOCALE_NAMES, } from "./i18n/index";
|
|
16
|
+
export { createId, createOrderedId } from "./ids";
|
|
17
|
+
export { createCmsHttp, Router, type CmsHttp, type RouteRecord, } from "./http/index";
|
|
18
|
+
export { applyFieldReadAccess, assertFieldWriteAccess, buildHookPipeline, cursorWhere, encodeCursor, globalRowId, hookPipelineEntries, listTrashed, localeContext, resolveLocalized, rowToDocument, scheduledPatch, scopedDb, toStoredData, validateFields, CmsEngine, EventBuffer, JobRunner, Outbox, RelationLoader, relationTarget, runAfterHooks, runBeforeHooks, type CollectionHookPipeline, type EngineOptions, type EventDispatch, type JobDefinition, type JobHost, type ListTrashedOptions, type LocaleContext, type ScheduledPatch, type WriteIntent, } from "./engine/index";
|
|
19
|
+
export { collectMediaReferences, createMedia, mediaGcJob, prepareUpload, probeImage, referencesMedia, stripImageMetadata, syncMediaUsages, toMediaDocument, variantKey, variantTransform, type MediaGcContext, type MediaReference, type MediaServiceOptions, type PreparedUpload, } from "./media/index";
|
|
20
|
+
export { parseByteSize, parseDuration } from "./duration";
|
|
21
|
+
export { describePanel } from "./panel";
|
|
22
|
+
export { buildSchemaSnapshot, documentsDataColumn, documentsTableName, emptySnapshot, planMigration, systemTableNames, systemTables, } from "./schema/index";
|
|
23
|
+
export { defineField } from "./fields/registry";
|
|
24
|
+
export type * from "./types/index";
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,0BAA0B,EAC1B,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,WAAW,EACX,YAAY,EACZ,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,cAAc,EACd,eAAe,EACf,WAAW,EACX,eAAe,EACf,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,UAAU,EACV,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,EACX,MAAM,EACN,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,OAAO,EACP,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EACL,WAAW,EACX,UAAU,EACV,aAAa,EACb,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EACL,aAAa,EACb,MAAM,EACN,KAAK,OAAO,EACZ,KAAK,WAAW,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,SAAS,EACT,WAAW,EACX,SAAS,EACT,MAAM,EACN,cAAc,EACd,cAAc,EACd,aAAa,EACb,cAAc,EACd,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,OAAO,EACZ,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,WAAW,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,sBAAsB,EACtB,WAAW,EACX,UAAU,EACV,aAAa,EACb,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,mBAAmB,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{he,En}from"./index-g041kfa5.js";import{pe,Y,Le,me,fe,I}from"./index-8x2em6c8.js";import{It,Wn,E,rt,jt,Et,_e,C,fn,A,$e,Je,Ie}from"./index-sgdnp83t.js";import"./index-6m1kjq9g.js";import"./index-abfzb1ve.js";import{dt,je,He,Wt,ut,pt,mt,ft,vn,zt,ht,te,Ht,Bt,Vt,xn,Gt,Kt,Vn,Gn,Kn,yt}from"./index-cv0hpz3d.js";import{Se,jn,qe}from"./index-hpast878.js";import{V,J,Ee,bt,Be,F,Yt,Ge,An,Zt}from"./index-kc1j3h6z.js";import"./index-g4crf47y.js";import{ct,bn,wn}from"./index-a8jcwqsf.js";import{Ke,Rt}from"./index-6w10rch0.js";import{Ae,ke,Cn}from"./index-466cwb0b.js";import{en,tn,nn}from"./index-91fa1gzf.js";import{d}from"./index-9g2n7xa6.js";import{k,Z,Ot,rn,ao,lo,Te,Q,co,X,uo}from"./index-hbx67b20.js";import{ge,et,tt}from"./index-y8kzzn94.js";import{O}from"./index-67e458ws.js";import{Ce}from"./index-vzhxn50e.js";import{p,ln,Pt,_t}from"./index-s9x07zb3.js";import{nt,ot}from"./index-761dec5z.js";import"./index-2prbs05k.js";import{w,se}from"./index-rw0hze6x.js";import{b,ve}from"./index-8nzmqy0f.js";import{e,n}from"./index-x72d1hzh.js";export{n as CmsConfigError,ht as CmsEngine,e as CmsError,pt as EventBuffer,ut as JobRunner,Ht as LOCALE_NAMES,mt as Outbox,ft as RelationLoader,Se as Router,Le as aiActionsFor,fe as applyFieldReadAccess,I as assertFieldWriteAccess,dt as buildHookPipeline,Pt as buildSchemaSnapshot,wn as cmsScheduled,tn as collectMediaReferences,Rt as createAi,qe as createCmsHttp,b as createId,Zt as createMedia,ve as createOrderedId,Gt as createWebhooks,J as cursorWhere,et as defaultAdminPath,ge as defaultBasePath,tt as defaultMigrationsDirectory,pe as defineAiAction,Vn as defineCollection,Z as defineEditorMark,k as defineEditorNode,O as defineField,Gn as defineGlobal,Te as describeEditorSchema,jn as describePanel,ln as documentsDataColumn,p as documentsTableName,_t as emptySnapshot,V as encodeCursor,rt as expandRoles,Y as getAiAction,rn as getEditorMark,Ot as getEditorNode,te as globalRowId,Wn as grants,Kn as heyoCms,Wt as hookPipelineEntries,jt as intersectPermissions,Vt as isRtlLocale,_e as isValidScope,zt as listTrashed,C as localeContext,Bt as localeName,xn as localeRecords,Yt as mediaGcJob,se as parseByteSize,w as parseDuration,It as permissionFor,E as permits,Ke as piCompletion,Ce as planMigration,An as prepareUpload,Ee as probeImage,en as referencesMedia,me as registeredAiActions,lo as registeredEditorMarks,ao as registeredEditorNodes,vn as relationTarget,Q as renderRichText,fn as resolveLocalized,he as richTextFromMarkdown,En as richTextFromText,co as richTextToHtml,X as richTextToMarkdown,uo as richTextToPlainText,A as rowToDocument,He as runAfterHooks,je as runBeforeHooks,ct as runDueJobs,Ie as scheduledPatch,Et as scopePermissions,d as scopedDb,ke as signPayload,Ae as signatureHeader,bn as startJobRunner,Ge as stripImageMetadata,nn as syncMediaUsages,yt as systemActor,ot as systemTableNames,nt as systemTables,F as toMediaDocument,$e as toStoredData,Je as validateFields,Be as variantKey,bt as variantTransform,Cn as verifySignature,Kt as webhookRetryJob};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Duration } from "../types/config";
|
|
2
|
+
import type { CmsInstance } from "../types/instance";
|
|
3
|
+
import type { JobRunArgs, JobRunReport } from "../types/jobs";
|
|
4
|
+
/**
|
|
5
|
+
* Something has to call `cms.jobs.run()`.
|
|
6
|
+
*
|
|
7
|
+
* The package deliberately starts no timer of its own (stage 5): it has to
|
|
8
|
+
* load on Workers and on Lambda, where a `setInterval` either does nothing
|
|
9
|
+
* or keeps an invocation alive and bills for it. So the sweeps are a
|
|
10
|
+
* function, and this file is the two ways a deployment calls it — a timer
|
|
11
|
+
* for a process that has one, and a handler for a platform that owns the
|
|
12
|
+
* clock.
|
|
13
|
+
*
|
|
14
|
+
* Both do the same two things in the same order: run what is due, then drain
|
|
15
|
+
* the outbox. The second part is not optional on serverless, where the
|
|
16
|
+
* process freezes the moment the handler returns and anything still in the
|
|
17
|
+
* outbox waits for the next cron.
|
|
18
|
+
*/
|
|
19
|
+
export interface RunDueOptions extends JobRunArgs {
|
|
20
|
+
/** Delivers the events the sweep produced before returning. Default true. */
|
|
21
|
+
drainEvents?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function runDueJobs(cms: CmsInstance, options?: RunDueOptions): Promise<JobRunReport>;
|
|
24
|
+
export interface JobRunnerOptions extends RunDueOptions {
|
|
25
|
+
cms: CmsInstance;
|
|
26
|
+
/** How often to sweep. Defaults to one minute. */
|
|
27
|
+
interval?: Duration | number;
|
|
28
|
+
/** Runs one sweep immediately instead of waiting for the first tick. */
|
|
29
|
+
immediate?: boolean;
|
|
30
|
+
onReport?: (report: JobRunReport) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Called when a sweep throws.
|
|
33
|
+
*
|
|
34
|
+
* A sweep that throws is a database that is unreachable, not a job that
|
|
35
|
+
* failed — individual failures are recorded and counted inside the report.
|
|
36
|
+
* Default: log to `console.error`, because a background loop that swallows
|
|
37
|
+
* its own outage is worse than a noisy one.
|
|
38
|
+
*/
|
|
39
|
+
onError?: (error: unknown) => void;
|
|
40
|
+
/** Stops the loop. The same signal a server shutdown already has. */
|
|
41
|
+
signal?: AbortSignal;
|
|
42
|
+
}
|
|
43
|
+
export interface JobRunnerHandle {
|
|
44
|
+
/** Runs one sweep now, outside the schedule. */
|
|
45
|
+
runNow(): Promise<JobRunReport>;
|
|
46
|
+
/** Stops the loop and waits for a sweep in flight. */
|
|
47
|
+
stop(): Promise<void>;
|
|
48
|
+
readonly running: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The Node and Bun answer: a timer that never overlaps itself.
|
|
52
|
+
*
|
|
53
|
+
* Overlap is the failure that matters here. A sweep that takes longer than
|
|
54
|
+
* the interval — a backlog of scheduled changes, a slow webhook endpoint —
|
|
55
|
+
* would otherwise start a second pass over the same rows, and every job in
|
|
56
|
+
* the product claims its row before acting precisely because that must stay
|
|
57
|
+
* harmless. Not starting the second pass is cheaper than relying on it.
|
|
58
|
+
*/
|
|
59
|
+
export declare function startJobRunner(options: JobRunnerOptions): JobRunnerHandle;
|
|
60
|
+
/**
|
|
61
|
+
* The Workers answer: the platform owns the clock.
|
|
62
|
+
*
|
|
63
|
+
* ```ts
|
|
64
|
+
* export default {
|
|
65
|
+
* fetch: (request) => cms.handler(request),
|
|
66
|
+
* scheduled: cmsScheduled(cms),
|
|
67
|
+
* };
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* `waitUntil` is used when the platform provides it, so the outbox drain is
|
|
71
|
+
* allowed to outlive the handler rather than being killed halfway through a
|
|
72
|
+
* webhook.
|
|
73
|
+
*/
|
|
74
|
+
export declare function cmsScheduled(cms: CmsInstance, options?: RunDueOptions): (event: unknown, env?: unknown, context?: {
|
|
75
|
+
waitUntil?: (promise: Promise<unknown>) => void;
|
|
76
|
+
}) => Promise<void>;
|
|
77
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/jobs/runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE9D;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC/C,6EAA6E;IAC7E,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAsB,UAAU,CAC9B,GAAG,EAAE,WAAW,EAChB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAKvB;AAED,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,GAAG,EAAE,WAAW,CAAC;IACjB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC7B,wEAAwE;IACxE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,qEAAqE;IACrE,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,gDAAgD;IAChD,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAChC,sDAAsD;IACtD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAqEzE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,WAAW,EAChB,OAAO,GAAE,aAAkB,GAC1B,CACD,KAAK,EAAE,OAAO,EACd,GAAG,CAAC,EAAE,OAAO,EACb,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,IAAI,CAAA;CAAE,KAC1D,OAAO,CAAC,IAAI,CAAC,CAMjB"}
|
package/dist/jobs.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@heyo-sh/heyo-cms/jobs`.
|
|
3
|
+
*
|
|
4
|
+
* The scheduled-change sweep, the trash purge, `media-gc` and the webhook
|
|
5
|
+
* retries all run from `cms.jobs.run()`. This entry point is how something
|
|
6
|
+
* calls it on a schedule: a timer in a long-lived process, or the platform's
|
|
7
|
+
* own cron on Workers and Vercel.
|
|
8
|
+
*/
|
|
9
|
+
export { cmsScheduled, runDueJobs, startJobRunner, type JobRunnerHandle, type JobRunnerOptions, type RunDueOptions, } from "./jobs/runner";
|
|
10
|
+
export type { CmsJobs, JobFailure, JobResult, JobRunArgs, JobRunReport, } from "./types/jobs";
|
|
11
|
+
//# sourceMappingURL=jobs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs.d.ts","sourceRoot":"","sources":["../src/jobs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,YAAY,EACZ,UAAU,EACV,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,OAAO,EACP,UAAU,EACV,SAAS,EACT,UAAU,EACV,YAAY,GACb,MAAM,cAAc,CAAC"}
|
package/dist/jobs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ct,bn,wn}from"./index-a8jcwqsf.js";export{wn as cmsScheduled,ct as runDueJobs,bn as startJobRunner};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ImageInfo, ImageProcessor, ImageTransform } from "../types/media";
|
|
2
|
+
/** The Workers Images binding, structurally. Typing it avoids depending on the types. */
|
|
3
|
+
export interface CloudflareImagesBinding {
|
|
4
|
+
input(image: ReadableStream<Uint8Array>): CloudflareImageTransformer;
|
|
5
|
+
}
|
|
6
|
+
export interface CloudflareImageTransformer {
|
|
7
|
+
transform(options: Record<string, unknown>): CloudflareImageTransformer;
|
|
8
|
+
output(options: Record<string, unknown>): Promise<CloudflareImageOutput>;
|
|
9
|
+
}
|
|
10
|
+
export interface CloudflareImageOutput {
|
|
11
|
+
contentType(): string;
|
|
12
|
+
image(): ReadableStream<Uint8Array>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The binding, or where to get it.
|
|
16
|
+
*
|
|
17
|
+
* A function, usually: the processor is constructed while the configuration
|
|
18
|
+
* module loads, and on Workers the bindings only exist once a request (or the
|
|
19
|
+
* `cloudflare:workers` module) hands them over. Returning `undefined` is
|
|
20
|
+
* allowed — that is "this runtime has no binding", reported as an error only
|
|
21
|
+
* if something actually asks for pixels.
|
|
22
|
+
*/
|
|
23
|
+
export type CloudflareImagesSource = CloudflareImagesBinding | (() => CloudflareImagesBinding | undefined | Promise<CloudflareImagesBinding | undefined>);
|
|
24
|
+
export declare function cloudflareImages(source: CloudflareImagesSource): ImageProcessor;
|
|
25
|
+
export interface CloudflarePlan {
|
|
26
|
+
/** What to pass to `.transform()`, or null when only re-encoding. */
|
|
27
|
+
options: Record<string, unknown> | null;
|
|
28
|
+
/** The dimensions the output should have, for when the probe cannot say. */
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* One `ImageTransform`, translated into the binding's vocabulary.
|
|
34
|
+
*
|
|
35
|
+
* The crop and the focal point are resolved here rather than delegated:
|
|
36
|
+
* `sourceRegion` already turns both into a single rectangle of the original
|
|
37
|
+
* (the exact logic the sharp processor uses, tested in isolation), and that
|
|
38
|
+
* rectangle becomes a `trim`. It is sent as an origin and a size —
|
|
39
|
+
* `{ top, left, width, height }` — rather than as four margins: the size is
|
|
40
|
+
* what the rest of the plan is computed from, and stating it means the
|
|
41
|
+
* service cannot round its way to a rectangle one pixel off the one the
|
|
42
|
+
* dimensions were reported for.
|
|
43
|
+
*
|
|
44
|
+
* The fit names do not line up one to one, and two of them are false friends:
|
|
45
|
+
*
|
|
46
|
+
* | heyo-cms (sharp) | Cloudflare |
|
|
47
|
+
* | ---------------------- | ---------------- |
|
|
48
|
+
* | `inside` (default) | `scale-down` |
|
|
49
|
+
* | `contain` (letterbox) | `pad` |
|
|
50
|
+
* | `cover` | `cover`, clamped |
|
|
51
|
+
* | `outside` | computed + `scale-down` |
|
|
52
|
+
*
|
|
53
|
+
* `scale-down` never enlarges, which matches the `withoutEnlargement` the
|
|
54
|
+
* sharp processor always sets; `cover` would enlarge, so the requested box is
|
|
55
|
+
* shrunk to the source first — a 400px logo asked for at 1920 stays 400px.
|
|
56
|
+
*/
|
|
57
|
+
export declare function cloudflareTransform(info: ImageInfo, transform: ImageTransform): CloudflarePlan;
|
|
58
|
+
//# sourceMappingURL=cloudflare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../../src/media/cloudflare.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,cAAc,EAEf,MAAM,gBAAgB,CAAC;AAuCxB,yFAAyF;AACzF,MAAM,WAAW,uBAAuB;IACtC,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,0BAA0B,CAAC;CACtE;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,0BAA0B,CAAC;IACxE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC1E;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,IAAI,MAAM,CAAC;IACtB,KAAK,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;CACrC;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,GAC9B,uBAAuB,GACvB,CAAC,MACG,uBAAuB,GACvB,SAAS,GACT,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAAC,CAAC;AAEtD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,sBAAsB,GAC7B,cAAc,CA+ChB;AAED,MAAM,WAAW,cAAc;IAC7B,qEAAqE;IACrE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxC,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,cAAc,GACxB,cAAc,CAiEhB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { JsonObject } from "../types/json";
|
|
2
|
+
import type { MediaDocument } from "../types/media";
|
|
3
|
+
import type { Row } from "../types/query";
|
|
4
|
+
import type { StorageAdapter } from "../types/storage";
|
|
5
|
+
/**
|
|
6
|
+
* Metadata keys the engine owns.
|
|
7
|
+
*
|
|
8
|
+
* The crop rectangle and the list of rendered sizes live inside the `metadata`
|
|
9
|
+
* column because they are per-file facts no index ever has to answer about,
|
|
10
|
+
* and two more columns on a system table is two more migrations for every
|
|
11
|
+
* deployment that will ever exist. They are hidden from
|
|
12
|
+
* `MediaDocument.metadata` and refused on write, so "your metadata" stays
|
|
13
|
+
* yours.
|
|
14
|
+
*/
|
|
15
|
+
export declare const reservedMetadata: readonly ["crop", "variants"];
|
|
16
|
+
/**
|
|
17
|
+
* A `media` row as the rest of the world sees it.
|
|
18
|
+
*
|
|
19
|
+
* `url` is where the deployment serves the file: under `uploads.publicPath`
|
|
20
|
+
* when there is one, otherwise the adapter's public URL. Never a signed one:
|
|
21
|
+
* signing is cryptography, and making this asynchronous would charge every
|
|
22
|
+
* list of twenty-five files twenty-five signatures for a feature most
|
|
23
|
+
* deployments do not use. A private bucket signs at the moment of serving
|
|
24
|
+
* instead, which is what `cms.media.variant()` returns.
|
|
25
|
+
*/
|
|
26
|
+
export declare function toMediaDocument(row: Row, storage: StorageAdapter, publicPath?: string): MediaDocument;
|
|
27
|
+
/** The document as an event payload: plain JSON, no behaviour, no aliasing. */
|
|
28
|
+
export declare function mediaJson(media: MediaDocument): JsonObject;
|
|
29
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/media/document.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAwB,aAAa,EAAe,MAAM,gBAAgB,CAAC;AACvF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGvD;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,YAAI,MAAM,EAAE,UAAU,CAAU,CAAC;AAE9D;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,cAAc,EACvB,UAAU,CAAC,EAAE,MAAM,GAClB,aAAa,CAmCf;AAED,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,UAAU,CAE1D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { JobDefinition } from "../engine/jobs";
|
|
2
|
+
import type { BufferedEvent, OutboxEntryMeta } from "../engine/outbox";
|
|
3
|
+
import type { ResolvedCmsConfig, UploadsConfig } from "../types/config";
|
|
4
|
+
import type { DatabaseAdapter } from "../types/database";
|
|
5
|
+
import type { MediaCollectArgs, MediaCollectReport, MediaDocument } from "../types/media";
|
|
6
|
+
import type { Row, Tx } from "../types/query";
|
|
7
|
+
import type { StorageAdapter } from "../types/storage";
|
|
8
|
+
export interface MediaGcContext {
|
|
9
|
+
config: ResolvedCmsConfig;
|
|
10
|
+
database: () => Promise<DatabaseAdapter>;
|
|
11
|
+
storage: () => Promise<StorageAdapter>;
|
|
12
|
+
emit: (tx: Tx, events: BufferedEvent[], meta: OutboxEntryMeta) => Promise<void>;
|
|
13
|
+
deliver: () => void;
|
|
14
|
+
}
|
|
15
|
+
/** Files whose grace period has run out, oldest obligation first. */
|
|
16
|
+
export declare function dueMedia(context: MediaGcContext, now: Date, limit: number): Promise<Row[]>;
|
|
17
|
+
export declare function collectMedia(context: MediaGcContext, args?: MediaCollectArgs): Promise<MediaCollectReport>;
|
|
18
|
+
export type CollectOutcome = "purged" | "reclaimed" | "taken";
|
|
19
|
+
/**
|
|
20
|
+
* Takes one file, or discovers it should not be taken.
|
|
21
|
+
*
|
|
22
|
+
* The status change is a conditional update — the same portable claim the
|
|
23
|
+
* outbox and the scheduler use — so two collectors running at once cannot
|
|
24
|
+
* both delete the same object, on any of the three engines and without a
|
|
25
|
+
* lock.
|
|
26
|
+
*/
|
|
27
|
+
export declare function collectOne(context: MediaGcContext, row: Row, now: Date): Promise<CollectOutcome>;
|
|
28
|
+
/**
|
|
29
|
+
* The sweep, as the job registry sees it.
|
|
30
|
+
*
|
|
31
|
+
* Registered next to `scheduled-changes` and `trash-purge` rather than run on
|
|
32
|
+
* a timer of its own: the deployment decides what calls `cms.jobs.run()`,
|
|
33
|
+
* because the package does not know whether it is in a process that has
|
|
34
|
+
* timers (stage 5).
|
|
35
|
+
*/
|
|
36
|
+
export declare function mediaGcJob(context: MediaGcContext): JobDefinition;
|
|
37
|
+
/**
|
|
38
|
+
* Every object this file owns: the original and every size rendered from it.
|
|
39
|
+
*
|
|
40
|
+
* The recorded list plus the declared one. A size removed from the
|
|
41
|
+
* configuration still has objects in the bucket, and a size added since the
|
|
42
|
+
* last render has none but costs nothing to ask about — and a leaked
|
|
43
|
+
* derivative is a file nobody will ever find again.
|
|
44
|
+
*/
|
|
45
|
+
export declare function storageKeysOf(media: MediaDocument, uploads: UploadsConfig | undefined): string[];
|
|
46
|
+
//# sourceMappingURL=gc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gc.d.ts","sourceRoot":"","sources":["../../src/media/gc.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAmBvD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IACzC,OAAO,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;IACvC,IAAI,EAAE,CACJ,EAAE,EAAE,EAAE,EACN,MAAM,EAAE,aAAa,EAAE,EACvB,IAAI,EAAE,eAAe,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,qEAAqE;AACrE,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,cAAc,EACvB,GAAG,EAAE,IAAI,EACT,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,GAAG,EAAE,CAAC,CAqBhB;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,cAAc,EACvB,IAAI,GAAE,gBAAqB,GAC1B,OAAO,CAAC,kBAAkB,CAAC,CAyB7B;AAED,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAC;AAE9D;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,cAAc,EACvB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,IAAI,GACR,OAAO,CAAC,cAAc,CAAC,CAyDzB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa,CAcjE;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,aAAa,GAAG,SAAS,GACjC,MAAM,EAAE,CASV"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media: storage, processing and the lifecycle.
|
|
3
|
+
*
|
|
4
|
+
* Three separate concerns that only make sense together. Storage is where the
|
|
5
|
+
* bytes live; processing is what happens to them on the way in and on the way
|
|
6
|
+
* out; the lifecycle is the reference counting that lets a file be removed
|
|
7
|
+
* from a page without being destroyed (section 6).
|
|
8
|
+
*
|
|
9
|
+
* Nothing here is HTTP-aware. The routes in stage 7 and the library screen in
|
|
10
|
+
* stage 8 call exactly these functions.
|
|
11
|
+
*/
|
|
12
|
+
export { mediaJson, reservedMetadata, toMediaDocument } from "./document";
|
|
13
|
+
export { collectMedia, collectOne, dueMedia, mediaGcJob, storageKeysOf, type CollectOutcome, type MediaGcContext, } from "./gc";
|
|
14
|
+
export { matchesMime, prepareUpload, sanitiseFilename, type PrepareUploadOptions, type PreparedUpload, } from "./pipeline";
|
|
15
|
+
export { extensionFor, imageContentType, probeImage } from "./probe";
|
|
16
|
+
export { createMedia, type MediaServiceOptions } from "./service";
|
|
17
|
+
export { stripImageMetadata } from "./strip";
|
|
18
|
+
export { collectMediaReferences, mediaTable, mediaUsagesTable, purgeDeadline, referencesMedia, richTextMediaAttribute, syncMediaUsages, type MediaReference, type SyncMediaUsagesOptions, type SyncMediaUsagesResult, } from "./usages";
|
|
19
|
+
export { renderVariant, variantContentType, variantKey, variantNames, variantQuery, variantSize, variantTransform, } from "./variants";
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/media/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EACL,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,UAAU,EACV,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,MAAM,CAAC;AACd,OAAO,EACL,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,KAAK,oBAAoB,EACzB,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EACL,sBAAsB,EACtB,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,GAC3B,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { UploadsConfig } from "../types/config";
|
|
2
|
+
import type { ImageInfo } from "../types/media";
|
|
3
|
+
/**
|
|
4
|
+
* What happens between "here is a file" and "it is in the bucket".
|
|
5
|
+
*
|
|
6
|
+
* Validate, identify, shrink, strip, fingerprint — in that order, and all of
|
|
7
|
+
* it before a single byte reaches storage. Doing any of it afterwards would
|
|
8
|
+
* mean a rejected upload still costs a write, and a downscale that failed
|
|
9
|
+
* would leave the original in the bucket forever.
|
|
10
|
+
*/
|
|
11
|
+
export interface PreparedUpload {
|
|
12
|
+
data: Uint8Array;
|
|
13
|
+
contentType: string;
|
|
14
|
+
filename: string;
|
|
15
|
+
/** Null for anything that is not an image we can read. */
|
|
16
|
+
info: ImageInfo | null;
|
|
17
|
+
checksum: string;
|
|
18
|
+
extension: string;
|
|
19
|
+
/**
|
|
20
|
+
* Why the configured processing did not happen, when it failed.
|
|
21
|
+
*
|
|
22
|
+
* Null when it ran, or when there was nothing to run. Set when the
|
|
23
|
+
* processor threw and the original was stored instead (see
|
|
24
|
+
* `renderOriginal`): the upload succeeds, and the caller reports this as
|
|
25
|
+
* `media.processing.failed` so somebody can notice.
|
|
26
|
+
*/
|
|
27
|
+
processingError: string | null;
|
|
28
|
+
}
|
|
29
|
+
export interface PrepareUploadOptions {
|
|
30
|
+
bytes: Uint8Array;
|
|
31
|
+
filename: string;
|
|
32
|
+
/** What the client claimed. Overruled by the bytes when they disagree. */
|
|
33
|
+
contentType: string;
|
|
34
|
+
uploads: UploadsConfig;
|
|
35
|
+
}
|
|
36
|
+
export declare function prepareUpload(options: PrepareUploadOptions): Promise<PreparedUpload>;
|
|
37
|
+
/**
|
|
38
|
+
* A processor that cannot run at all, as opposed to one that failed once.
|
|
39
|
+
*
|
|
40
|
+
* `image_processor_missing` is a deployment mistake — no binding, no `sharp`
|
|
41
|
+
* installed — and degrading to the original would hide it until somebody
|
|
42
|
+
* wondered, months later, why nothing was ever converted. Every other error
|
|
43
|
+
* is the kind that goes away on its own.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isProcessorMisconfigured(error: unknown): boolean;
|
|
46
|
+
export declare function describeError(error: unknown): string;
|
|
47
|
+
export declare function matchesMime(contentType: string, pattern: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* A filename that is safe to show, log and put in a header.
|
|
50
|
+
*
|
|
51
|
+
* It is never used to build a storage key — those are derived from the id —
|
|
52
|
+
* so this is about display and `content-disposition`, not about traversal.
|
|
53
|
+
*/
|
|
54
|
+
export declare function sanitiseFilename(filename: string): string;
|
|
55
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/media/pipeline.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,gBAAgB,CAAC;AAIhE;;;;;;;GAOG;AAEH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;OAOG;IACH,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,cAAc,CAAC,CAgEzB;AAwGD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEhE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAUpD;AAoBD,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAMzE;AAWD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOzD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ImageFormat, ImageInfo } from "../types/media";
|
|
2
|
+
export declare function imageContentType(format: ImageFormat): string;
|
|
3
|
+
export declare function probeImage(bytes: Uint8Array): ImageInfo | null;
|
|
4
|
+
/** The extension a stored object should carry for a content type. */
|
|
5
|
+
export declare function extensionFor(contentType: string): string;
|
|
6
|
+
//# sourceMappingURL=probe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../../src/media/probe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAyB7D,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAE5D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,CAS9D;AAED,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAuBxD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { BufferedEvent, OutboxEntryMeta } from "../engine/outbox";
|
|
2
|
+
import type { ResolvedCmsConfig } from "../types/config";
|
|
3
|
+
import type { DatabaseAdapter } from "../types/database";
|
|
4
|
+
import type { CmsMedia } from "../types/media";
|
|
5
|
+
import type { Tx } from "../types/query";
|
|
6
|
+
export interface MediaServiceOptions {
|
|
7
|
+
config: ResolvedCmsConfig;
|
|
8
|
+
database: () => Promise<DatabaseAdapter>;
|
|
9
|
+
/** Appends events to the outbox inside the caller's transaction. */
|
|
10
|
+
emit: (tx: Tx, events: BufferedEvent[], meta: OutboxEntryMeta) => Promise<void>;
|
|
11
|
+
/** Schedules delivery once the transaction has committed. */
|
|
12
|
+
deliver: () => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* `cms.media`.
|
|
16
|
+
*
|
|
17
|
+
* Media is a high-level setting rather than a plugin (section 3), and a file
|
|
18
|
+
* is not a document: it has a lifecycle no document has — active, orphaned,
|
|
19
|
+
* collected — and a body that lives somewhere the database cannot see. Hence
|
|
20
|
+
* its own service, with the same rule as `cms.api`: everything is a method
|
|
21
|
+
* rather than a route, so the REST endpoints in stage 7, the panel in stage 8
|
|
22
|
+
* and a seed script all get identical behaviour, including the parts that are
|
|
23
|
+
* easy to get wrong.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createMedia(options: MediaServiceOptions): CmsMedia;
|
|
26
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/media/service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAQvE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,KAAK,EACV,QAAQ,EAiBT,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAO,EAAE,EAAS,MAAM,gBAAgB,CAAC;AA4BrD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IACzC,oEAAoE;IACpE,IAAI,EAAE,CACJ,EAAE,EAAE,EAAE,EACN,MAAM,EAAE,aAAa,EAAE,EACvB,IAAI,EAAE,eAAe,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,mBAAmB,GAAG,QAAQ,CA8uBlE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ImageProcessor, ImageTransform } from "../types/media";
|
|
2
|
+
export interface SharpImagesOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The decompression-bomb ceiling, in pixels.
|
|
5
|
+
*
|
|
6
|
+
* `sharp` defaults to roughly 268 megapixels. The upload pipeline already
|
|
7
|
+
* refuses anything over `uploads.limits.maxImageDimensions`, so this is the
|
|
8
|
+
* second fence rather than the first.
|
|
9
|
+
*/
|
|
10
|
+
limitInputPixels?: number | false;
|
|
11
|
+
/**
|
|
12
|
+
* Honour the EXIF orientation flag before doing anything else.
|
|
13
|
+
*
|
|
14
|
+
* On by default, and it matters: a phone photograph is stored sideways with
|
|
15
|
+
* a flag saying so, and stripping metadata without applying the flag first
|
|
16
|
+
* turns every portrait into a landscape.
|
|
17
|
+
*/
|
|
18
|
+
autoOrient?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function sharpImages(options?: SharpImagesOptions): ImageProcessor;
|
|
21
|
+
/** The rectangle of the source that a cover crop should keep. */
|
|
22
|
+
export declare function sourceRegion(width: number, height: number, transform: ImageTransform): {
|
|
23
|
+
left: number;
|
|
24
|
+
top: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
} | null;
|
|
28
|
+
//# sourceMappingURL=sharp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharp.d.ts","sourceRoot":"","sources":["../../src/media/sharp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,cAAc,EACd,cAAc,EAEf,MAAM,gBAAgB,CAAC;AAwBxB,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAClC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AA8CD,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,cAAc,CA6D5E;AAED,iEAAiE;AACjE,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,cAAc,GACxB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA0BrE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata removal, without a decoder.
|
|
3
|
+
*
|
|
4
|
+
* `stripMetadata` exists for one concrete reason: a photograph taken on a
|
|
5
|
+
* phone carries the coordinates of the place it was taken, and a CMS that
|
|
6
|
+
* publishes it publishes those too (section 6). That is a privacy obligation,
|
|
7
|
+
* not an optimisation, so it must not depend on whether an optional image
|
|
8
|
+
* processor happens to be installed — which is why it is implemented here, by
|
|
9
|
+
* dropping container chunks rather than by re-encoding pixels.
|
|
10
|
+
*
|
|
11
|
+
* ICC colour profiles are deliberately kept. Dropping them is what most tools
|
|
12
|
+
* do under "strip metadata", and it visibly shifts the colours of every
|
|
13
|
+
* wide-gamut photograph, which is not what anybody asking for privacy meant.
|
|
14
|
+
*/
|
|
15
|
+
export declare function stripImageMetadata(bytes: Uint8Array, contentType: string): Uint8Array;
|
|
16
|
+
//# sourceMappingURL=strip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip.d.ts","sourceRoot":"","sources":["../../src/media/strip.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,MAAM,GAClB,UAAU,CAaZ"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { ImagesConfig, ResolvedCmsConfig } from "../types/config";
|
|
2
|
+
import type { MediaDocument, MediaImage, MediaImageInput, MediaImageOptions, MediaSrcsetOptions, MediaUrlInput, MediaUrlOptions } from "../types/media";
|
|
3
|
+
/**
|
|
4
|
+
* Where a file is served from, and what an `<img>` needs to show it well.
|
|
5
|
+
*
|
|
6
|
+
* Everything here is arithmetic on the configuration and the `media` row: no
|
|
7
|
+
* storage call, no rendering, no database. That is what lets a page with
|
|
8
|
+
* forty pictures build forty `srcset`s without forty round trips — the sizes
|
|
9
|
+
* a variant *will* have are known before it has ever been rendered, because
|
|
10
|
+
* the processors never enlarge and the fits are deterministic.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* The file name in a public URL: the uploaded name, as a slug, with the
|
|
14
|
+
* extension of what is actually served.
|
|
15
|
+
*
|
|
16
|
+
* Only for people and image search, which reads it; the route ignores it.
|
|
17
|
+
* The extension follows the content type rather than the upload, so a PNG
|
|
18
|
+
* converted to WebP is `diagram.webp` and not a `.png` that is not one.
|
|
19
|
+
*/
|
|
20
|
+
export declare function publicFileName(media: Pick<MediaDocument, "filename">, contentType: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* The address of the original under `uploads.publicPath`, or null without one.
|
|
23
|
+
*
|
|
24
|
+
* Kept separate from `mediaUrl` because `toMediaDocument` needs it and has no
|
|
25
|
+
* use for the rest: `MediaDocument.url` is this, when the deployment serves
|
|
26
|
+
* its own files.
|
|
27
|
+
*/
|
|
28
|
+
export declare function publicOriginalUrl(publicPath: string | undefined, media: Pick<MediaDocument, "id" | "filename" | "mimeType">): string | null;
|
|
29
|
+
/**
|
|
30
|
+
* `cms.media.url()`.
|
|
31
|
+
*
|
|
32
|
+
* With `uploads.publicPath`:
|
|
33
|
+
*
|
|
34
|
+
* /media/med_…/condition-report.png the original
|
|
35
|
+
* /media/med_…/card/condition-report.webp a declared size
|
|
36
|
+
*
|
|
37
|
+
* Without it, the CMS's own API route, `<basePath>/media/med_…/card`. A size
|
|
38
|
+
* nothing here can render — no processor, or an SVG — is the original's URL
|
|
39
|
+
* with the size in the query, which is what an image CDN in front of the
|
|
40
|
+
* deployment reads. A size that would not change the picture is the
|
|
41
|
+
* original's URL outright, so the browser reuses what it already has.
|
|
42
|
+
*/
|
|
43
|
+
export declare function mediaUrl(config: ResolvedCmsConfig, media: MediaUrlInput, options?: MediaUrlOptions): string;
|
|
44
|
+
/**
|
|
45
|
+
* The pixel size a named size will have for this file, before it exists.
|
|
46
|
+
*
|
|
47
|
+
* The same arithmetic the processors perform: the crop first, then the fit,
|
|
48
|
+
* never enlarging. Null when the file has no known dimensions (not an image,
|
|
49
|
+
* or one whose header could not be read).
|
|
50
|
+
*/
|
|
51
|
+
export declare function variantDimensions(images: ImagesConfig | undefined, name: string, media: Pick<MediaUrlInput, "width" | "height" | "crop">): {
|
|
52
|
+
width: number;
|
|
53
|
+
height: number;
|
|
54
|
+
} | null;
|
|
55
|
+
/**
|
|
56
|
+
* `cms.media.srcset()`: the declared sizes that keep the picture's shape, as
|
|
57
|
+
* a width-descriptor list, with the original at the top end.
|
|
58
|
+
*
|
|
59
|
+
* Only sizes that do not change the aspect ratio belong in one `srcset` —
|
|
60
|
+
* the browser assumes every candidate is the same picture — so a `cover`
|
|
61
|
+
* square is left out unless asked for by name. Sizes the file is too small
|
|
62
|
+
* for collapse into the original. With a crop the original is not the same
|
|
63
|
+
* picture as its sizes, so it is left out and the largest size tops the list.
|
|
64
|
+
*
|
|
65
|
+
* Null when there is nothing to choose between: a vector, a file with no
|
|
66
|
+
* known width, or a configuration without sizes.
|
|
67
|
+
*/
|
|
68
|
+
export declare function mediaSrcset(config: ResolvedCmsConfig, media: MediaUrlInput, options?: MediaSrcsetOptions): string | null;
|
|
69
|
+
/**
|
|
70
|
+
* `cms.media.image()`: everything an `<img>` needs for one file.
|
|
71
|
+
*
|
|
72
|
+
* Width and height are always the ones of the `src` — that is what the
|
|
73
|
+
* browser reserves space with before a byte arrives, and a wrong ratio there
|
|
74
|
+
* is the layout shift it exists to prevent.
|
|
75
|
+
*/
|
|
76
|
+
export declare function mediaImage(config: ResolvedCmsConfig, media: MediaImageInput, options?: MediaImageOptions): MediaImage;
|
|
77
|
+
//# sourceMappingURL=urls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../../src/media/urls.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAUxB;;;;;;;;GAQG;AAEH;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,EACtC,WAAW,EAAE,MAAM,GAClB,MAAM,CAGR;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,GAAG,UAAU,GAAG,UAAU,CAAC,GACzD,MAAM,GAAG,IAAI,CAGf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,eAAoB,GAC5B,MAAM,CAmCR;AAOD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC,GACtD;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA6C1C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,kBAAuB,GAC/B,MAAM,GAAG,IAAI,CAKf;AA4CD;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,eAAe,EACtB,OAAO,GAAE,iBAAsB,GAC9B,UAAU,CAqCZ"}
|