@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,60 @@
|
|
|
1
|
+
import type { Actor } from "../types/actor";
|
|
2
|
+
import type { RbacConfig, ResolvedCollection } from "../types/config";
|
|
3
|
+
import type { DatabaseAdapter } from "../types/database";
|
|
4
|
+
import type { FieldDefinition } from "../types/fields";
|
|
5
|
+
import type { JsonObject } from "../types/json";
|
|
6
|
+
import type { Tx } from "../types/query";
|
|
7
|
+
import type { LocaleContext } from "./locales";
|
|
8
|
+
export interface RelationLoaderOptions {
|
|
9
|
+
adapter: DatabaseAdapter;
|
|
10
|
+
tx: Tx;
|
|
11
|
+
locale: LocaleContext;
|
|
12
|
+
/** Every declared collection and global, keyed by name. */
|
|
13
|
+
collections: Record<string, ResolvedCollection>;
|
|
14
|
+
includeTrashed?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whose read this is.
|
|
17
|
+
*
|
|
18
|
+
* A related document is filtered by the rules of the collection it belongs
|
|
19
|
+
* to, not by the one that pointed at it: `depth` must not be a way to read
|
|
20
|
+
* a field through a relation that cannot be read directly.
|
|
21
|
+
*/
|
|
22
|
+
actor?: Actor | null;
|
|
23
|
+
rbac?: RbacConfig | undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* `depth`, resolved by batching instead of by joining.
|
|
27
|
+
*
|
|
28
|
+
* Collect the ids at this level, run one query per target collection, then
|
|
29
|
+
* recurse. The query count depends on the shape of the schema, never on the
|
|
30
|
+
* number of documents — which is the N+1 problem Payload users hit with
|
|
31
|
+
* `depth`, and the reason section 12 rules joins out: one batching strategy
|
|
32
|
+
* works identically on Postgres, SQLite and MongoDB.
|
|
33
|
+
*/
|
|
34
|
+
export declare class RelationLoader {
|
|
35
|
+
private readonly options;
|
|
36
|
+
/** Shared across levels, so a document fetched once is never fetched again. */
|
|
37
|
+
private readonly cache;
|
|
38
|
+
/** Counted so a test can assert the absence of N+1 rather than infer it. */
|
|
39
|
+
private queries;
|
|
40
|
+
constructor(options: RelationLoaderOptions);
|
|
41
|
+
get queryCount(): number;
|
|
42
|
+
expand(documents: JsonObject[], collection: ResolvedCollection, depth: number): Promise<void>;
|
|
43
|
+
private load;
|
|
44
|
+
/**
|
|
45
|
+
* Replaces ids with documents, remembering what was replaced so the next
|
|
46
|
+
* level can be batched. A reference that no longer resolves stays an id
|
|
47
|
+
* rather than becoming `null`: losing the value would hide the dangling
|
|
48
|
+
* reference instead of reporting it.
|
|
49
|
+
*/
|
|
50
|
+
private substitute;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* What a field points at.
|
|
54
|
+
*
|
|
55
|
+
* `media` is a relation that does not spell it out: the value is an id in the
|
|
56
|
+
* `media` table, which is what makes the usage counting in section 6
|
|
57
|
+
* possible. Treating it as one here means `depth` resolves a cover image.
|
|
58
|
+
*/
|
|
59
|
+
export declare function relationTarget(field: FieldDefinition): string | undefined;
|
|
60
|
+
//# sourceMappingURL=relations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../../src/engine/relations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAIzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,eAAe,CAAC;IACzB,EAAE,EAAE,EAAE,CAAC;IACP,MAAM,EAAE,aAAa,CAAC;IACtB,2DAA2D;IAC3D,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAChD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,qBAAa,cAAc;IAMb,OAAO,CAAC,QAAQ,CAAC,OAAO;IALpC,+EAA+E;IAC/E,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAwC;IAC9D,4EAA4E;IAC5E,OAAO,CAAC,OAAO,CAAK;IAEpB,YAA6B,OAAO,EAAE,qBAAqB,EAAI;IAE/D,IAAI,UAAU,IAAI,MAAM,CAEvB;IAEK,MAAM,CACV,SAAS,EAAE,UAAU,EAAE,EACvB,UAAU,EAAE,kBAAkB,EAC9B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CA8Cf;YAEa,IAAI;IAiElB;;;;;OAKG;IACH,OAAO,CAAC,UAAU;CA4BnB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAGzE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DatabaseAdapter } from "../types/database";
|
|
2
|
+
import type { ScopedDb } from "../types/hooks";
|
|
3
|
+
import type { Tx } from "../types/query";
|
|
4
|
+
/**
|
|
5
|
+
* `ctx.db`: the handle that bypasses access control, by name.
|
|
6
|
+
*
|
|
7
|
+
* Everything it does happens inside the caller's transaction, so a hook that
|
|
8
|
+
* writes an audit row and then throws leaves nothing behind. The alternative
|
|
9
|
+
* — a pooled connection of its own — would commit independently of the
|
|
10
|
+
* operation that triggered it.
|
|
11
|
+
*/
|
|
12
|
+
export declare function scopedDb(adapter: DatabaseAdapter, tx: Tx): ScopedDb;
|
|
13
|
+
//# sourceMappingURL=scoped-db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoped-db.d.ts","sourceRoot":"","sources":["../../src/engine/scoped-db.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAwB,EAAE,EAAS,MAAM,gBAAgB,CAAC;AAEtE;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,EAAE,GAAG,QAAQ,CA6CnE"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { ResolvedCollection } from "../types/config";
|
|
2
|
+
import type { FieldDefinition } from "../types/fields";
|
|
3
|
+
import type { ScopedDb } from "../types/hooks";
|
|
4
|
+
import type { JsonObject } from "../types/json";
|
|
5
|
+
/**
|
|
6
|
+
* The `slug` field's behaviour: made from another field when empty, cleaned
|
|
7
|
+
* when typed, unique where it has to be, and remembered when it changes.
|
|
8
|
+
*
|
|
9
|
+
* Here rather than in a hook because every one of those has to happen on
|
|
10
|
+
* every write path — the panel, the REST API, an import, a scheduled change,
|
|
11
|
+
* a script — and a hook is something a project can forget to register.
|
|
12
|
+
*
|
|
13
|
+
* The history lives in its own table, `slug_history`, one row per previous
|
|
14
|
+
* address: a real column with a unique index answers "who owned this URL"
|
|
15
|
+
* in one lookup on every engine, where a list inside the document body would
|
|
16
|
+
* be a `LIKE` over every row of the collection.
|
|
17
|
+
*/
|
|
18
|
+
export declare const slugHistoryTable = "slug_history";
|
|
19
|
+
export interface SlugFieldOptions {
|
|
20
|
+
from?: string;
|
|
21
|
+
history?: boolean;
|
|
22
|
+
unique?: boolean;
|
|
23
|
+
maxLength?: number;
|
|
24
|
+
slugify?: (text: string) => string;
|
|
25
|
+
}
|
|
26
|
+
/** The field's own `slugify`, or the built-in one at its `maxLength`. */
|
|
27
|
+
export declare function slugCleaner(field: FieldDefinition): (text: string) => string;
|
|
28
|
+
export declare function slugFields(collection: ResolvedCollection): [string, FieldDefinition][];
|
|
29
|
+
export declare function slugOptions(field: FieldDefinition): SlugFieldOptions;
|
|
30
|
+
/** One slug that stopped being a document's address in a write. */
|
|
31
|
+
export interface SlugMove {
|
|
32
|
+
field: string;
|
|
33
|
+
/** Empty for a field that is not localized, like `media_usages`. */
|
|
34
|
+
locale: string;
|
|
35
|
+
from: string;
|
|
36
|
+
to: string;
|
|
37
|
+
}
|
|
38
|
+
export interface PrepareSlugsOptions {
|
|
39
|
+
db: ScopedDb;
|
|
40
|
+
collection: ResolvedCollection;
|
|
41
|
+
/** What the write asks for, after the `before` hooks. */
|
|
42
|
+
input: JsonObject;
|
|
43
|
+
/** The stored body before this write; null for a create. */
|
|
44
|
+
stored: JsonObject | null;
|
|
45
|
+
locale: string;
|
|
46
|
+
/** Null for a create whose id is not known to the caller yet. */
|
|
47
|
+
documentId: string | null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Fills in, cleans and checks every slug field a write touches.
|
|
51
|
+
*
|
|
52
|
+
* Returns the input with the slugs settled and the moves the write implies,
|
|
53
|
+
* which `recordSlugMoves` writes once the document row exists.
|
|
54
|
+
*/
|
|
55
|
+
export declare function prepareSlugs(options: PrepareSlugsOptions): Promise<{
|
|
56
|
+
input: JsonObject;
|
|
57
|
+
moves: SlugMove[];
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Writes what `prepareSlugs` decided, inside the same transaction.
|
|
61
|
+
*
|
|
62
|
+
* The old slug becomes a previous address of the document; a slug the
|
|
63
|
+
* document moves back to stops being one, so an address is never both.
|
|
64
|
+
*/
|
|
65
|
+
export declare function recordSlugMoves(db: ScopedDb, collection: ResolvedCollection, documentId: string, moves: SlugMove[], now: Date): Promise<void>;
|
|
66
|
+
export declare function removePreviousSlugRow(db: ScopedDb, collection: ResolvedCollection, documentId: string, field: string, locale: string, slug: string): Promise<void>;
|
|
67
|
+
/** Every previous address of one document goes when the document does. */
|
|
68
|
+
export declare function releaseSlugs(db: ScopedDb, collection: ResolvedCollection, documentId: string): Promise<void>;
|
|
69
|
+
interface SlugScope {
|
|
70
|
+
db: ScopedDb;
|
|
71
|
+
collection: ResolvedCollection;
|
|
72
|
+
documentId: string | null;
|
|
73
|
+
field: string;
|
|
74
|
+
/** Empty for a field that is not localized. */
|
|
75
|
+
locale: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Refuses a slug another document uses, as its address or as a previous one.
|
|
79
|
+
*
|
|
80
|
+
* Trashed documents count: restoring a page must never bring back a URL
|
|
81
|
+
* somebody else has taken since. A previous address is not taken over
|
|
82
|
+
* silently either — it is a redirect somebody relies on — so the message
|
|
83
|
+
* says where it leads and how to free it.
|
|
84
|
+
*/
|
|
85
|
+
export declare function assertFree(scope: SlugScope & {
|
|
86
|
+
slug: string;
|
|
87
|
+
}): Promise<void>;
|
|
88
|
+
export interface SlugCandidate {
|
|
89
|
+
id: string;
|
|
90
|
+
/** The locale the slug matched in; null for a field that is not localized. */
|
|
91
|
+
locale: string | null;
|
|
92
|
+
current: boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Every document a slug points at, best match first: a current address in
|
|
96
|
+
* the requested locale, then in another locale, then a previous address in
|
|
97
|
+
* the requested locale, then in another.
|
|
98
|
+
*
|
|
99
|
+
* Trashed documents are left out — a trashed page has no address — and so
|
|
100
|
+
* is anything that is not a slug at all, before a query is spent on it.
|
|
101
|
+
*/
|
|
102
|
+
export declare function slugCandidates(options: {
|
|
103
|
+
db: ScopedDb;
|
|
104
|
+
collection: ResolvedCollection;
|
|
105
|
+
field: string;
|
|
106
|
+
slug: string;
|
|
107
|
+
locale: string | null;
|
|
108
|
+
locales: string[];
|
|
109
|
+
}): Promise<SlugCandidate[]>;
|
|
110
|
+
export interface PreviousSlugRow {
|
|
111
|
+
slug: string;
|
|
112
|
+
field: string;
|
|
113
|
+
locale: string | null;
|
|
114
|
+
createdAt: string | null;
|
|
115
|
+
}
|
|
116
|
+
export declare function previousSlugRows(options: {
|
|
117
|
+
db: ScopedDb;
|
|
118
|
+
collection: ResolvedCollection;
|
|
119
|
+
documentId: string;
|
|
120
|
+
field?: string;
|
|
121
|
+
locale?: string | null;
|
|
122
|
+
}): Promise<PreviousSlugRow[]>;
|
|
123
|
+
export {};
|
|
124
|
+
//# sourceMappingURL=slugs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slugs.d.ts","sourceRoot":"","sources":["../../src/engine/slugs.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAIhD;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAK/C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC;AAED,yEAAyE;AACzE,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAK5E;AAED,wBAAgB,UAAU,CACxB,UAAU,EAAE,kBAAkB,GAC7B,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,CAI7B;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB,CAEpE;AAED,mEAAmE;AACnE,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,QAAQ,CAAC;IACb,UAAU,EA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MAAM,CAAA;CAAE,GAClC,OAAO,CAAC,IAAI,CAAC,CAcf;AA6FD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,8EAA8E;IAC9E,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE;IAC5C,EAAE,EAAE,QAAQ,CAAC;IACb,UAAU,EAAE,kBAAkB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CA4D3B;AAmBD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAC9C,EAAE,EAAE,QAAQ,CAAC;IACb,UAAU,EAAE,kBAAkB,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAsB7B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ResolvedCmsConfig, ResolvedCollection } from "../types/config";
|
|
2
|
+
import type { DatabaseAdapter } from "../types/database";
|
|
3
|
+
import type { TrashListArgs, TrashPage } from "../types/trash";
|
|
4
|
+
export interface ListTrashedOptions {
|
|
5
|
+
adapter: DatabaseAdapter;
|
|
6
|
+
config: ResolvedCmsConfig;
|
|
7
|
+
/** Collections and globals, by name. */
|
|
8
|
+
collections: Record<string, ResolvedCollection>;
|
|
9
|
+
args: TrashListArgs;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The trash across collections.
|
|
13
|
+
*
|
|
14
|
+
* One query, not one per collection: the panel shows a single list ordered by
|
|
15
|
+
* when things were deleted, and assembling that from per-collection pages
|
|
16
|
+
* would page wrongly the moment two collections have entries.
|
|
17
|
+
*
|
|
18
|
+
* Access control is folded into the filter rather than applied afterwards —
|
|
19
|
+
* the same rule as everywhere else (stage 4). Each collection contributes one
|
|
20
|
+
* branch of an `OR`, carrying its own `read` filter; a collection the actor
|
|
21
|
+
* may not read contributes nothing and is therefore invisible rather than
|
|
22
|
+
* forbidden.
|
|
23
|
+
*/
|
|
24
|
+
export declare function listTrashed(options: ListTrashedOptions): Promise<TrashPage>;
|
|
25
|
+
//# sourceMappingURL=trash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trash.d.ts","sourceRoot":"","sources":["../../src/engine/trash.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAa/D,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,eAAe,CAAC;IACzB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAChD,IAAI,EAAE,aAAa,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,SAAS,CAAC,CAuFpB"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One error type for everything a caller can provoke.
|
|
3
|
+
*
|
|
4
|
+
* A hook that throws, an access rule that refuses and a field that fails
|
|
5
|
+
* validation all end up in the same HTTP response builder, so they all carry
|
|
6
|
+
* the status and a machine-readable code instead of leaving the transport
|
|
7
|
+
* layer to guess from the message.
|
|
8
|
+
*/
|
|
9
|
+
export declare class CmsError extends Error {
|
|
10
|
+
readonly status: number;
|
|
11
|
+
readonly code: string;
|
|
12
|
+
readonly details?: unknown;
|
|
13
|
+
constructor(message: string, options?: {
|
|
14
|
+
status?: number;
|
|
15
|
+
code?: string;
|
|
16
|
+
details?: unknown;
|
|
17
|
+
/**
|
|
18
|
+
* The error this one replaces, for the operator's log.
|
|
19
|
+
*
|
|
20
|
+
* `details` is part of the response and `cause` never is: when a
|
|
21
|
+
* provider or a driver fails, the caller gets a sentence and a code
|
|
22
|
+
* while the original stack stays where somebody debugging can reach it.
|
|
23
|
+
*/
|
|
24
|
+
cause?: unknown;
|
|
25
|
+
});
|
|
26
|
+
static notFound(message?: string): CmsError;
|
|
27
|
+
static forbidden(message?: string): CmsError;
|
|
28
|
+
static unauthorized(message?: string): CmsError;
|
|
29
|
+
static conflict(message: string): CmsError;
|
|
30
|
+
static validation(message: string, details?: unknown): CmsError;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A mistake in the configuration, not in a request.
|
|
34
|
+
*
|
|
35
|
+
* These are thrown while `heyoCms()` is still building, so they must read like
|
|
36
|
+
* a compiler diagnostic: what is wrong, where, and what to write instead.
|
|
37
|
+
*/
|
|
38
|
+
export declare class CmsConfigError extends Error {
|
|
39
|
+
readonly path: string;
|
|
40
|
+
constructor(path: string, message: string);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAE3B,YACE,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QACP,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB;;;;;;WAMG;QACH,KAAK,CAAC,EAAE,OAAO,CAAC;KACZ,EAOP;IAED,MAAM,CAAC,QAAQ,CAAC,OAAO,SAAc,GAAG,QAAQ,CAE/C;IAED,MAAM,CAAC,SAAS,CAAC,OAAO,SAAc,GAAG,QAAQ,CAEhD;IAED,MAAM,CAAC,YAAY,CAAC,OAAO,SAAiB,GAAG,QAAQ,CAEtD;IAED,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAEzC;IAED,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAM9D;CACF;AAED;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAIxC;CACF"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { FieldDefinition, FieldOptions } from "../types/fields";
|
|
2
|
+
import type { JsonObject, JsonValue } from "../types/json";
|
|
3
|
+
import { type FieldValue } from "./registry";
|
|
4
|
+
export interface TextOptions extends FieldOptions {
|
|
5
|
+
default?: string;
|
|
6
|
+
minLength?: number;
|
|
7
|
+
maxLength?: number;
|
|
8
|
+
/** Source string for the pattern; kept serialisable for the snapshot. */
|
|
9
|
+
pattern?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const text: import("./registry").FieldBuilder<string, TextOptions>;
|
|
12
|
+
export interface TextareaOptions extends TextOptions {
|
|
13
|
+
rows?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const textarea: import("./registry").FieldBuilder<string, TextareaOptions>;
|
|
16
|
+
/** A ProseMirror document. TipTap writes it, the serialisers read it. */
|
|
17
|
+
export type RichTextValue = JsonObject;
|
|
18
|
+
export interface RichTextOptions extends FieldOptions {
|
|
19
|
+
/** Editor nodes allowed in this field; the panel hides the rest. */
|
|
20
|
+
nodes?: string[];
|
|
21
|
+
default?: RichTextValue;
|
|
22
|
+
}
|
|
23
|
+
export declare const richText: import("./registry").FieldBuilder<JsonObject, RichTextOptions>;
|
|
24
|
+
export interface NumberOptions extends FieldOptions {
|
|
25
|
+
default?: number;
|
|
26
|
+
min?: number;
|
|
27
|
+
max?: number;
|
|
28
|
+
integer?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare const number: import("./registry").FieldBuilder<number, NumberOptions>;
|
|
31
|
+
export interface BooleanOptions extends FieldOptions {
|
|
32
|
+
default?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare const boolean: import("./registry").FieldBuilder<boolean, BooleanOptions>;
|
|
35
|
+
export interface DateOptions extends FieldOptions {
|
|
36
|
+
default?: string;
|
|
37
|
+
/** `date` hides the clock in the panel; storage is identical. */
|
|
38
|
+
mode?: "date" | "datetime";
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Dates are ISO strings, not `Date` objects.
|
|
42
|
+
*
|
|
43
|
+
* The value travels through JSON on every path the engine has — storage, REST,
|
|
44
|
+
* webhook payloads — and a string survives all of them unchanged. Converting
|
|
45
|
+
* at the edges would mean three places that can disagree about time zones.
|
|
46
|
+
*/
|
|
47
|
+
export declare const date: import("./registry").FieldBuilder<string, DateOptions>;
|
|
48
|
+
export type SelectChoice = string | {
|
|
49
|
+
label: string;
|
|
50
|
+
value: string;
|
|
51
|
+
};
|
|
52
|
+
export interface SelectOptions extends FieldOptions {
|
|
53
|
+
options: readonly SelectChoice[];
|
|
54
|
+
default?: string;
|
|
55
|
+
}
|
|
56
|
+
/** Literal choices become a union in the document type. */
|
|
57
|
+
export type SelectValue<TOptions extends {
|
|
58
|
+
options: readonly SelectChoice[];
|
|
59
|
+
}> = TOptions["options"][number] extends infer TChoice ? TChoice extends string ? TChoice : TChoice extends {
|
|
60
|
+
value: infer TValue;
|
|
61
|
+
} ? TValue : never : never;
|
|
62
|
+
/**
|
|
63
|
+
* A plain choice field.
|
|
64
|
+
*
|
|
65
|
+
* `status` is one of its uses and nothing more: the engine attaches no meaning
|
|
66
|
+
* to it, which is what removed the whole publish/unpublish lifecycle from the
|
|
67
|
+
* core (sections 3 and 11).
|
|
68
|
+
*/
|
|
69
|
+
export declare function select<const TOptions extends SelectOptions>(options: TOptions): FieldDefinition<FieldValue<SelectValue<TOptions>, TOptions>>;
|
|
70
|
+
export interface MultiselectOptions extends FieldOptions {
|
|
71
|
+
options: readonly SelectChoice[];
|
|
72
|
+
default?: string[];
|
|
73
|
+
minItems?: number;
|
|
74
|
+
maxItems?: number;
|
|
75
|
+
}
|
|
76
|
+
export declare function multiselect<const TOptions extends MultiselectOptions>(options: TOptions): FieldDefinition<FieldValue<SelectValue<TOptions>[], TOptions>>;
|
|
77
|
+
export interface JsonFieldOptions extends FieldOptions {
|
|
78
|
+
default?: JsonValue;
|
|
79
|
+
}
|
|
80
|
+
export declare const json: import("./registry").FieldBuilder<JsonValue, JsonFieldOptions>;
|
|
81
|
+
export interface MediaOptions extends FieldOptions {
|
|
82
|
+
/** MIME whitelist for the picker, e.g. `image/*`. */
|
|
83
|
+
accept?: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A reference to a row in `media`.
|
|
87
|
+
*
|
|
88
|
+
* Storing the id rather than a URL is what makes the media lifecycle work:
|
|
89
|
+
* `media_usages` can count references, and a file that loses its last one is
|
|
90
|
+
* orphaned rather than deleted (section 6).
|
|
91
|
+
*/
|
|
92
|
+
export declare const media: import("./registry").FieldBuilder<string, MediaOptions>;
|
|
93
|
+
export interface RelationOptions extends FieldOptions {
|
|
94
|
+
relationTo?: string;
|
|
95
|
+
/** Many-to-many: the value is an array of ids. */
|
|
96
|
+
many?: boolean;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A reference to another collection.
|
|
100
|
+
*
|
|
101
|
+
* Resolved by a batch loader rather than a join: one query per collection per
|
|
102
|
+
* depth level works the same on all three engines and removes the N+1 problem
|
|
103
|
+
* that Payload users hit with `depth` (section 12).
|
|
104
|
+
*/
|
|
105
|
+
export declare function relation<const TOptions extends RelationOptions>(to: string, options?: TOptions): FieldDefinition<FieldValue<string, TOptions>>;
|
|
106
|
+
export interface SlugOptions extends FieldOptions {
|
|
107
|
+
/**
|
|
108
|
+
* The field a slug is made from while it is empty: `"title"`.
|
|
109
|
+
*
|
|
110
|
+
* Made once, on the write that first has a value for it, and then left
|
|
111
|
+
* alone: retitling a page must not move its URL. Clearing the slug makes
|
|
112
|
+
* it again. The same function is the panel's "Generate" button.
|
|
113
|
+
*/
|
|
114
|
+
from?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Keep every slug a document stops using as a previous address of it.
|
|
117
|
+
*
|
|
118
|
+
* `cms.api.<collection>.resolveSlug()` finds a document by a previous
|
|
119
|
+
* address too, which is what a 301 from an old URL is built on; a new
|
|
120
|
+
* document cannot take an address an old one still redirects from. Needs
|
|
121
|
+
* the `slug_history` table, which `heyo-cms generate` adds.
|
|
122
|
+
*/
|
|
123
|
+
history?: boolean;
|
|
124
|
+
/** The longest slug produced; longer input is cut at a hyphen. 96 by default. */
|
|
125
|
+
maxLength?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Your own transliteration, when the built-in one is not the house style:
|
|
128
|
+
* `&` as `and`, a language's own rules. Used everywhere a slug is made or
|
|
129
|
+
* cleaned — writes, the Generate button, previous slugs. Its output must
|
|
130
|
+
* still match `slugPattern`; `maxLength` is then yours to apply.
|
|
131
|
+
*/
|
|
132
|
+
slugify?: (text: string) => string;
|
|
133
|
+
default?: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A URL slug: `"lodz-in-autumn"`.
|
|
137
|
+
*
|
|
138
|
+
* What makes it more than `text` with a pattern is the engine, on every
|
|
139
|
+
* write path — the panel, the REST API, an import, a scheduled change:
|
|
140
|
+
*
|
|
141
|
+
* - a typed slug is cleaned (`"Łódź in Autumn!"` becomes `lodz-in-autumn`);
|
|
142
|
+
* - an empty one is made `from` another field, with `-2`, `-3`… until free;
|
|
143
|
+
* - it is unique within the collection — per language when localized, which
|
|
144
|
+
* a database index cannot express, so the engine checks it, trashed
|
|
145
|
+
* documents included;
|
|
146
|
+
* - with `history`, a changed slug stays a previous address of the document,
|
|
147
|
+
* which `resolveSlug()` finds and nobody else may take.
|
|
148
|
+
*
|
|
149
|
+
* ```ts
|
|
150
|
+
* slug: slug({ from: "title", localized: true, history: true })
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export declare function slug<const TOptions extends SlugOptions>(options?: TOptions): FieldDefinition<FieldValue<string, TOptions>>;
|
|
154
|
+
export declare const email: import("./registry").FieldBuilder<string, TextOptions>;
|
|
155
|
+
export declare const url: import("./registry").FieldBuilder<string, TextOptions>;
|
|
156
|
+
/**
|
|
157
|
+
* SEO as fields, not as a plugin.
|
|
158
|
+
*
|
|
159
|
+
* A plugin would own the fields, the prompts and the panel section; a preset
|
|
160
|
+
* spreads into `fields` and stays editable (`...seoFields()`), which is the
|
|
161
|
+
* decision recorded in section 11.
|
|
162
|
+
*/
|
|
163
|
+
export declare function seoFields(): {
|
|
164
|
+
seoTitle: FieldDefinition<string | null>;
|
|
165
|
+
seoDescription: FieldDefinition<string | null>;
|
|
166
|
+
ogImage: FieldDefinition<string | null>;
|
|
167
|
+
canonical: FieldDefinition<string | null>;
|
|
168
|
+
};
|
|
169
|
+
//# sourceMappingURL=builtin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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GAMG;AACH,wBAAgB,SAAS,IAAI;IAC3B,QAAQ,EAAE,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACzC,cAAc,EAAE,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC/C,OAAO,EAAE,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACxC,SAAS,EAAE,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC3C,CAuBA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AACpB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { FieldDefinition, FieldOptions, FieldType } from "../types/fields";
|
|
2
|
+
import type { JsonValue } from "../types/json";
|
|
3
|
+
/**
|
|
4
|
+
* Nullability is a property of the options, not of the field type.
|
|
5
|
+
*
|
|
6
|
+
* `text()` holds `string | null` and `text({ required: true })` holds
|
|
7
|
+
* `string`, and both facts are visible in the inferred document type instead
|
|
8
|
+
* of being discovered at runtime.
|
|
9
|
+
*/
|
|
10
|
+
export type FieldValue<TValue, TOptions> = TOptions extends {
|
|
11
|
+
required: true;
|
|
12
|
+
} ? TValue : TValue | null;
|
|
13
|
+
export interface FieldBuilderOptions extends FieldOptions {
|
|
14
|
+
default?: JsonValue;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A field builder: what `text`, `select` or a third-party `rating` is.
|
|
18
|
+
*
|
|
19
|
+
* `const TOptions` captures literal option values, which is what lets
|
|
20
|
+
* `select({ options: ["draft", "published"] })` infer a union rather than
|
|
21
|
+
* `string`.
|
|
22
|
+
*/
|
|
23
|
+
export type FieldBuilder<TValue, TOptions extends FieldOptions> = <const TGiven extends TOptions>(options?: TGiven) => FieldDefinition<FieldValue<TValue, TGiven>>;
|
|
24
|
+
export declare function registerFieldType<TValue, TOptions extends FieldOptions>(type: FieldType<TValue, TOptions>): void;
|
|
25
|
+
export declare function getFieldType<TValue = unknown>(name: string): FieldType<TValue, FieldOptions> | undefined;
|
|
26
|
+
export declare function registeredFieldTypes(): string[];
|
|
27
|
+
/**
|
|
28
|
+
* Declares a field type and returns its builder.
|
|
29
|
+
*
|
|
30
|
+
* Every built-in field goes through this function. A shortcut for built-ins
|
|
31
|
+
* would mean the public extension API is the one nobody uses, which is how
|
|
32
|
+
* extension points rot (stage 9).
|
|
33
|
+
*/
|
|
34
|
+
export declare function defineField<TValue, TOptions extends FieldOptions>(type: FieldType<TValue, TOptions>): FieldBuilder<TValue, TOptions>;
|
|
35
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/fields/registry.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,eAAe,EACf,YAAY,EACZ,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,CAAC,MAAM,EAAE,QAAQ,IAAI,QAAQ,SAAS;IAAE,QAAQ,EAAE,IAAI,CAAA;CAAE,GAC1E,MAAM,GACN,MAAM,GAAG,IAAI,CAAC;AAElB,MAAM,WAAW,mBAAoB,SAAQ,YAAY;IACvD,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,CAAC,MAAM,EAAE,QAAQ,SAAS,YAAY,IAAI,CAChE,KAAK,CAAC,MAAM,SAAS,QAAQ,EAE7B,OAAO,CAAC,EAAE,MAAM,KACb,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAUjD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,SAAS,YAAY,EACrE,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,GAChC,IAAI,CASN;AAED,wBAAgB,YAAY,CAAC,MAAM,GAAG,OAAO,EAC3C,IAAI,EAAE,MAAM,GACX,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,SAAS,CAE7C;AAED,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAE/C;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,QAAQ,SAAS,YAAY,EAC/D,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,GAChC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAkGhC"}
|
package/dist/fields.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The field registry and every built-in type.
|
|
3
|
+
*
|
|
4
|
+
* Built-ins are declared with the same `defineField()` a third-party package
|
|
5
|
+
* uses, so there is no privileged path into the registry (stage 9).
|
|
6
|
+
*/
|
|
7
|
+
export * from "./fields/index";
|
|
8
|
+
export { isSlug, slugify, slugPattern, type SlugifyOptions } from "./slugify";
|
|
9
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/fields.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Mn,sn,ye}from"./index-abfzb1ve.js";import{po,Ko,Yo,O}from"./index-67e458ws.js";import{z as e}from"zod";var i=e.looseObject({label:e.string().optional(),description:e.string().optional(),localized:e.boolean().optional(),required:e.boolean().optional(),unique:e.boolean().optional(),index:e.boolean().optional(),readOnly:e.boolean().optional()}),a=e.lazy(()=>e.union([e.string(),e.number(),e.boolean(),e.null(),e.array(a),e.record(e.string(),a)])),g=O({name:"text",optionsSchema:i.extend({default:e.string().optional(),minLength:e.number().int().nonnegative().optional(),maxLength:e.number().int().positive().optional(),pattern:e.string().optional()}),schema:(n)=>{let t=e.string();if(n.minLength!==void 0)t=t.min(n.minLength);if(n.maxLength!==void 0)t=t.max(n.maxLength);if(n.pattern!==void 0)t=t.regex(new RegExp(n.pattern));return t},column:(n)=>({type:"text",...n.default===void 0?{}:{default:n.default}}),aiActions:["generate","improve","summarize","translate"]}),x=O({name:"textarea",optionsSchema:i.extend({default:e.string().optional(),maxLength:e.number().int().positive().optional(),rows:e.number().int().positive().optional()}),schema:(n)=>n.maxLength===void 0?e.string():e.string().max(n.maxLength),column:()=>({type:"text"}),aiActions:["generate","improve","summarize","translate"]}),w=O({name:"richText",optionsSchema:i.extend({nodes:e.array(e.string()).optional()}),schema:()=>e.looseObject({type:e.string()}),column:()=>({type:"json"}),aiActions:["generate","improve","summarize","translate"]}),k=O({name:"number",optionsSchema:i.extend({default:e.number().optional(),min:e.number().optional(),max:e.number().optional(),integer:e.boolean().optional()}),schema:(n)=>{let t=n.integer===!0?e.number().int():e.number();if(n.min!==void 0)t=t.min(n.min);if(n.max!==void 0)t=t.max(n.max);return t},column:(n)=>({type:n.integer===!0?"integer":"real",...n.default===void 0?{}:{default:n.default}})}),D=O({name:"boolean",optionsSchema:i.extend({default:e.boolean().optional()}),schema:()=>e.boolean(),column:(n)=>({type:"boolean",...n.default===void 0?{}:{default:n.default}})}),L=O({name:"date",optionsSchema:i.extend({default:e.string().optional(),mode:e.enum(["date","datetime"]).optional()}),schema:()=>e.string().refine((n)=>!Number.isNaN(Date.parse(n)),"must be an ISO 8601 date"),column:()=>({type:"timestamp"})}),d=(n)=>n.map((t)=>typeof t==="string"?t:t.value),m=i.extend({options:e.array(e.union([e.string(),e.strictObject({label:e.string(),value:e.string()})])).min(1),default:e.string().optional()}),f=O({name:"select",optionsSchema:m,schema:(n)=>e.enum(d(n.options)),column:(n)=>({type:"text",...n.default===void 0?{}:{default:n.default}})});function v(n){return f(n)}var h=O({name:"multiselect",optionsSchema:m.extend({default:e.array(e.string()).optional(),minItems:e.number().int().nonnegative().optional(),maxItems:e.number().int().positive().optional()}),schema:(n)=>{let t=e.array(e.enum(d(n.options)));if(n.minItems!==void 0)t=t.min(n.minItems);if(n.maxItems!==void 0)t=t.max(n.maxItems);return t},column:()=>({type:"json",array:!0}),aiActions:["tags"]});function Z(n){return h(n)}var j=O({name:"json",optionsSchema:i,schema:()=>a,column:()=>({type:"json"})}),y=O({name:"media",optionsSchema:i.extend({accept:e.string().optional()}),schema:()=>e.string().min(1),column:()=>({type:"text"}),aiActions:["alt"]}),T=O({name:"relation",optionsSchema:i.extend({relationTo:e.string().min(1),many:e.boolean().optional()}),schema:()=>e.string().min(1),column:(n)=>({type:"text",...n.many===!0?{type:"json",array:!0}:{}}),aiActions:["tags"]});function R(n,t){return T({...t??{},relationTo:n})}var b=O({name:"slug",optionsSchema:i.extend({from:e.string().min(1).optional(),history:e.boolean().optional(),maxLength:e.number().int().min(8).max(512).optional(),slugify:e.function().optional(),default:e.string().optional()}),schema:(n)=>e.string().max(n.maxLength??96).regex(new RegExp(Mn),"lowercase letters, digits and single hyphens only"),column:(n)=>({type:"text",...n.default===void 0?{}:{default:n.default}})});function I(n){let t={...n??{}},s=t.localized===!0,{maxLength:l,from:r}=t,c=t.slugify??((o)=>ye(o,l===void 0?{}:{maxLength:l}));return b({...t,unique:s?t.unique===!1?!1:void 0:t.unique??!0,index:s?void 0:t.index??!0,...t.generate===void 0&&r!==void 0?{generate:({fields:o})=>{let p=o[r],u=typeof p==="string"?c(p):"";return u===""?null:u}}:{}})}var C=O({name:"email",optionsSchema:i,schema:()=>e.string().email(),column:()=>({type:"text"})}),F=O({name:"url",optionsSchema:i,schema:()=>e.string().url(),column:()=>({type:"text"})});function J(){return{seoTitle:g({label:"SEO title",localized:!0,maxLength:70,aiGenerate:{label:"Suggest an SEO title",prompt:"Write a search-friendly title under 60 characters."}}),seoDescription:x({label:"SEO description",localized:!0,maxLength:160,aiGenerate:{label:"Suggest an SEO description",prompt:"Summarise the article in one sentence under 155 characters."}}),ogImage:y({label:"Social image",accept:"image/*"}),canonical:F({label:"Canonical URL"})}}export{D as boolean,L as date,O as defineField,C as email,Ko as getFieldType,sn as isSlug,j as json,y as media,Z as multiselect,k as number,po as registerFieldType,Yo as registeredFieldTypes,R as relation,w as richText,v as select,J as seoFields,I as slug,Mn as slugPattern,ye as slugify,g as text,x as textarea,F as url};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Actor, OperationSource } from "../types/actor";
|
|
2
|
+
import type { ResolvedCmsConfig } from "../types/config";
|
|
3
|
+
/**
|
|
4
|
+
* Who may call the administrative endpoints.
|
|
5
|
+
*
|
|
6
|
+
* Document and media routes need nothing from this file: the engine already
|
|
7
|
+
* answers "may this actor do this" for them, including the anonymous case —
|
|
8
|
+
* a collection with `read: () => true` is a public API and that is the point.
|
|
9
|
+
*
|
|
10
|
+
* The endpoints that manage the CMS itself are different. `GET /users` has no
|
|
11
|
+
* collection to carry an `access` rule, so the rule is here, and it has two
|
|
12
|
+
* parts:
|
|
13
|
+
*
|
|
14
|
+
* 1. **Always an authenticated caller.** Without `rbac` a collection defaults
|
|
15
|
+
* to open, which is a sensible default for content and a catastrophic one
|
|
16
|
+
* for user management.
|
|
17
|
+
* 2. **With `rbac`, also the permission.** Declaring roles is the statement
|
|
18
|
+
* that this deployment distinguishes between editors, so the distinction
|
|
19
|
+
* is applied here too.
|
|
20
|
+
*
|
|
21
|
+
* The permission names follow the same `resource:action` grammar as
|
|
22
|
+
* everything else — `users:invite`, `roles:create`, `webhooks:create`,
|
|
23
|
+
* `activity:read`, `jobs:run` — so an administrator writes them in `rbac`
|
|
24
|
+
* without learning a second vocabulary.
|
|
25
|
+
*/
|
|
26
|
+
export declare function requireActor(actor: Actor | null): Actor;
|
|
27
|
+
export declare function requirePermission(config: ResolvedCmsConfig, actor: Actor | null, permission: string): Actor;
|
|
28
|
+
/**
|
|
29
|
+
* A session, specifically.
|
|
30
|
+
*
|
|
31
|
+
* Used by the endpoints that mint credentials: an API key that can create
|
|
32
|
+
* another API key turns a leaked read-only key into a permanent foothold,
|
|
33
|
+
* and the same argument applies to enrolling a second factor.
|
|
34
|
+
*/
|
|
35
|
+
export declare function requireSession(actor: Actor | null): Actor;
|
|
36
|
+
/**
|
|
37
|
+
* Where the call came from, for hooks, events and the activity log.
|
|
38
|
+
*
|
|
39
|
+
* Everything over HTTP is `rest` unless the panel says otherwise with a
|
|
40
|
+
* header. Trusting a client header is fine precisely because it grants
|
|
41
|
+
* nothing: it is a label on a log line, and the panel is the only thing that
|
|
42
|
+
* sends it.
|
|
43
|
+
*/
|
|
44
|
+
export declare function requestSource(request: Request): OperationSource;
|
|
45
|
+
//# sourceMappingURL=guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../src/http/guard.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,KAAK,CAKvD;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,KAAK,GAAG,IAAI,EACnB,UAAU,EAAE,MAAM,GACjB,KAAK,CAOP;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,KAAK,CAQzD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,CAI/D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CmsHandler, CmsInstance, RouteInspection } from "../types/instance";
|
|
2
|
+
import type { JsonObject } from "../types/json";
|
|
3
|
+
/**
|
|
4
|
+
* `cms.handler`: the only HTTP contract in the product.
|
|
5
|
+
*
|
|
6
|
+
* `basePath` is stripped and the rest is matched, which is the whole of the
|
|
7
|
+
* Better Auth arrangement the plan asks for (section 10): one catch-all route
|
|
8
|
+
* in any framework mounts the API, the panel and every plugin route, and a
|
|
9
|
+
* route added to the core or to a plugin tomorrow needs no change in the
|
|
10
|
+
* application.
|
|
11
|
+
*
|
|
12
|
+
* The order inside a request is fixed and worth knowing:
|
|
13
|
+
*
|
|
14
|
+
* 1. the path is resolved against `basePath`,
|
|
15
|
+
* 2. the caller is resolved from the cookie or the `Authorization` header,
|
|
16
|
+
* 3. `hooks.before` run, and may answer instead of the route,
|
|
17
|
+
* 4. the route's own middleware wrap the handler,
|
|
18
|
+
* 5. `hooks.after` see the response and may add to it.
|
|
19
|
+
*
|
|
20
|
+
* Authentication is resolved before the hooks because a rate limiter that
|
|
21
|
+
* cannot tell an editor from a stranger is a rate limiter on the wrong thing.
|
|
22
|
+
*/
|
|
23
|
+
export interface CmsHttp {
|
|
24
|
+
handler: CmsHandler;
|
|
25
|
+
/** What `cms.inspect().routes` prints. */
|
|
26
|
+
routes(): RouteInspection[];
|
|
27
|
+
/** The generated document, memoised. */
|
|
28
|
+
openapi(): JsonObject;
|
|
29
|
+
}
|
|
30
|
+
export declare function createCmsHttp(cms: CmsInstance): CmsHttp;
|
|
31
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/http/handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AA0BhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,UAAU,CAAC;IACpB,0CAA0C;IAC1C,MAAM,IAAI,eAAe,EAAE,CAAC;IAC5B,wCAAwC;IACxC,OAAO,IAAI,UAAU,CAAC;CACvB;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAkHvD"}
|