@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,75 @@
|
|
|
1
|
+
import type { Mutation, MutationResult, Query, Row, Tx } from "./query";
|
|
2
|
+
import type { MigrationArtifact, MigrationStep, SchemaSnapshot } from "./schema";
|
|
3
|
+
/**
|
|
4
|
+
* What an engine can and cannot do, stated rather than hidden.
|
|
5
|
+
*
|
|
6
|
+
* The engine reads these flags instead of assuming Postgres. A `false` here
|
|
7
|
+
* must have a designed answer in the engine (compensating writes, no SQL
|
|
8
|
+
* artefacts), not a runtime surprise.
|
|
9
|
+
*/
|
|
10
|
+
export interface DatabaseCapabilities {
|
|
11
|
+
/** MongoDB only has transactions on a replica set. */
|
|
12
|
+
transactions: boolean;
|
|
13
|
+
/** MongoDB has no DDL: its migrations are indexes and backfills. */
|
|
14
|
+
sqlMigrations: boolean;
|
|
15
|
+
/** Filtering and sorting on paths inside the document body. */
|
|
16
|
+
jsonQuery: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** A migration that has been applied, as recorded in the journal table. */
|
|
19
|
+
export interface AppliedMigration {
|
|
20
|
+
id: string;
|
|
21
|
+
appliedAt: Date;
|
|
22
|
+
/** Hash of the artifact, so an edited migration is detected, not replayed. */
|
|
23
|
+
checksum: string;
|
|
24
|
+
}
|
|
25
|
+
export interface DatabaseAdapter {
|
|
26
|
+
/** `postgres`, `sqlite`, `d1`, `mongodb`. Printed by `cms.inspect()`. */
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly capabilities: DatabaseCapabilities;
|
|
29
|
+
/**
|
|
30
|
+
* Tells the adapter what the rows look like.
|
|
31
|
+
*
|
|
32
|
+
* Encoding is engine-specific — a timestamp is `timestamptz` on Postgres,
|
|
33
|
+
* epoch milliseconds on SQLite and a native `Date` on MongoDB — so the
|
|
34
|
+
* adapter needs the schema to translate values in both directions. The
|
|
35
|
+
* engine hands it over once, right after building the adapter.
|
|
36
|
+
*/
|
|
37
|
+
useSchema(schema: SchemaSnapshot): void;
|
|
38
|
+
/**
|
|
39
|
+
* Reads the live schema.
|
|
40
|
+
*
|
|
41
|
+
* Used to detect drift, not to diff: `generate` compares the configuration
|
|
42
|
+
* against the snapshot committed next to the migrations, so it works
|
|
43
|
+
* offline and can never propose dropping a table it does not own.
|
|
44
|
+
*/
|
|
45
|
+
introspect(): Promise<SchemaSnapshot>;
|
|
46
|
+
/**
|
|
47
|
+
* Deterministic diff. Called with two snapshots and nothing else: the same
|
|
48
|
+
* pair must always produce the same steps in the same order, or `generate`
|
|
49
|
+
* would write a migration for a schema that did not change.
|
|
50
|
+
*/
|
|
51
|
+
plan(from: SchemaSnapshot, to: SchemaSnapshot): MigrationStep[];
|
|
52
|
+
/** Serialises steps into the file that lands in the repository. */
|
|
53
|
+
render(steps: MigrationStep[], id: string): MigrationArtifact;
|
|
54
|
+
/** Applies a rendered migration. The CLI never constructs SQL itself. */
|
|
55
|
+
applyMigration(artifact: MigrationArtifact): Promise<void>;
|
|
56
|
+
/** Journal access, so `migrate` and `status` share one source of truth. */
|
|
57
|
+
listAppliedMigrations(): Promise<AppliedMigration[]>;
|
|
58
|
+
recordMigration(id: string, checksum: string): Promise<void>;
|
|
59
|
+
transaction<T>(fn: (tx: Tx) => Promise<T>): Promise<T>;
|
|
60
|
+
query(tx: Tx, query: Query): Promise<Row[]>;
|
|
61
|
+
mutate(tx: Tx, mutation: Mutation): Promise<MutationResult>;
|
|
62
|
+
/** Releases pooled connections. Long-running servers never call it. */
|
|
63
|
+
close?(): Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* How a database is configured in `heyoCms({ database })`.
|
|
67
|
+
*
|
|
68
|
+
* Adapters are built lazily: a Cloudflare D1 binding only exists inside a
|
|
69
|
+
* request, and a `DATABASE_URL` only exists in a deployment, so constructing
|
|
70
|
+
* the adapter while the config module is being imported would turn a missing
|
|
71
|
+
* secret into an unhandled module error.
|
|
72
|
+
*/
|
|
73
|
+
export type DatabaseAdapterFactory = () => DatabaseAdapter | Promise<DatabaseAdapter>;
|
|
74
|
+
export type DatabaseConfig = DatabaseAdapter | DatabaseAdapterFactory;
|
|
75
|
+
//# sourceMappingURL=database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/types/database.ts"],"names":[],"mappings":"AAAA,OAA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AC,CAAC;IAE7D,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACvD,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAC5C,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAE5D,uEAAuE;IACvE,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,GAAG,MACnC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAE7C,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { ComponentType, JsonObject, JsonValue } from "./json";
|
|
2
|
+
/**
|
|
3
|
+
* The editor contract (stage 9).
|
|
4
|
+
*
|
|
5
|
+
* A rich-text field holds a ProseMirror document, which is JSON and therefore
|
|
6
|
+
* storable anywhere, and useless to anybody who cannot render it. That is the
|
|
7
|
+
* problem this file exists to prevent: a custom node that only the panel
|
|
8
|
+
* understands turns `GET /posts/1` into a tree of unknown shapes, and every
|
|
9
|
+
* consumer — a static site, an RSS feed, an AI prompt — has to reimplement it.
|
|
10
|
+
*
|
|
11
|
+
* So a node is not registered unless it can serialise itself. `toHtml` and
|
|
12
|
+
* `toMarkdown` are required properties of `defineEditorNode()`, not optional
|
|
13
|
+
* conveniences, and the registry refuses a definition that lacks either.
|
|
14
|
+
*/
|
|
15
|
+
/** A mark on a text node: `bold`, `link`, a custom one. */
|
|
16
|
+
export interface RichTextMark {
|
|
17
|
+
type: string;
|
|
18
|
+
attrs?: Record<string, JsonValue>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* One node of a ProseMirror document.
|
|
22
|
+
*
|
|
23
|
+
* Deliberately permissive: the engine stores whatever the editor produced,
|
|
24
|
+
* including nodes this deployment has never heard of, because refusing to
|
|
25
|
+
* store an unknown node would make an editor upgrade a data migration.
|
|
26
|
+
*/
|
|
27
|
+
export interface RichTextNode {
|
|
28
|
+
type: string;
|
|
29
|
+
attrs?: Record<string, JsonValue>;
|
|
30
|
+
content?: RichTextNode[];
|
|
31
|
+
text?: string;
|
|
32
|
+
marks?: RichTextMark[];
|
|
33
|
+
}
|
|
34
|
+
/** The value a `richText()` field holds. `{ type: "doc", content: [...] }`. */
|
|
35
|
+
export interface RichTextDocument extends JsonObject {
|
|
36
|
+
type: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* What a serialiser is handed.
|
|
40
|
+
*
|
|
41
|
+
* `children` is the already-serialised content of the node, so a definition
|
|
42
|
+
* never walks the tree itself — which is what keeps a third-party node from
|
|
43
|
+
* having to know how the rest of the document is rendered.
|
|
44
|
+
*/
|
|
45
|
+
export interface NodeSerializerContext {
|
|
46
|
+
node: RichTextNode;
|
|
47
|
+
/** The serialised children, joined by the default rule for the format. */
|
|
48
|
+
children: string;
|
|
49
|
+
/** The same children unjoined, for a list that has to number them. */
|
|
50
|
+
childStrings: string[];
|
|
51
|
+
/** The nodes' own children, for a definition that needs their shape. */
|
|
52
|
+
childNodes: RichTextNode[];
|
|
53
|
+
/** How deep the node sits. A list item uses it for indentation. */
|
|
54
|
+
depth: number;
|
|
55
|
+
/** Zero-based position among its siblings. An ordered list uses it. */
|
|
56
|
+
index: number;
|
|
57
|
+
/**
|
|
58
|
+
* Resolves a media id to a URL, when the caller knows how.
|
|
59
|
+
*
|
|
60
|
+
* Optional because the same document is serialised in places that cannot
|
|
61
|
+
* reach the database — a CLI export, a prompt — and a node that cannot
|
|
62
|
+
* resolve a file is expected to fall back to whatever `src` it carries.
|
|
63
|
+
*/
|
|
64
|
+
mediaUrl?: (id: string) => string | null;
|
|
65
|
+
/**
|
|
66
|
+
* Resolves a media id to everything an `<img>` needs, when the caller
|
|
67
|
+
* knows the file: its URL, its dimensions, a `srcset`. Preferred over
|
|
68
|
+
* `mediaUrl` when both are given. See `cms.media.renderRichText()`.
|
|
69
|
+
*/
|
|
70
|
+
mediaImage?: (id: string) => RichTextMediaImage | null;
|
|
71
|
+
/** Attributes every rendered image gets; see `RenderRichTextOptions.images`. */
|
|
72
|
+
images?: RichTextImageOptions;
|
|
73
|
+
}
|
|
74
|
+
/** A library file, resolved for an `<img>`. Null fields are left out of the tag. */
|
|
75
|
+
export interface RichTextMediaImage {
|
|
76
|
+
src: string;
|
|
77
|
+
width?: number | null;
|
|
78
|
+
height?: number | null;
|
|
79
|
+
srcset?: string | null;
|
|
80
|
+
sizes?: string | null;
|
|
81
|
+
/** The library's alt text, used when the node has none of its own. */
|
|
82
|
+
alt?: string | null;
|
|
83
|
+
}
|
|
84
|
+
export interface RichTextImageOptions {
|
|
85
|
+
loading?: "lazy" | "eager";
|
|
86
|
+
decoding?: "async" | "sync" | "auto";
|
|
87
|
+
}
|
|
88
|
+
export type NodeSerializer = (context: NodeSerializerContext) => string;
|
|
89
|
+
export interface MarkSerializerContext {
|
|
90
|
+
mark: RichTextMark;
|
|
91
|
+
/** The text the mark wraps, already escaped for the target format. */
|
|
92
|
+
text: string;
|
|
93
|
+
}
|
|
94
|
+
export type MarkSerializer = (context: MarkSerializerContext) => string;
|
|
95
|
+
/**
|
|
96
|
+
* A node type, as `defineEditorNode()` registers it.
|
|
97
|
+
*
|
|
98
|
+
* `schema` is the ProseMirror node spec. It travels to the panel as data so
|
|
99
|
+
* the editor can build its schema at runtime, which is the only way one
|
|
100
|
+
* static bundle can serve a deployment that installed a plugin yesterday.
|
|
101
|
+
*/
|
|
102
|
+
export interface EditorNodeDefinition {
|
|
103
|
+
name: string;
|
|
104
|
+
/** `block`, `inline`, or a custom group a parent's `content` can name. */
|
|
105
|
+
group?: string;
|
|
106
|
+
/** ProseMirror content expression, e.g. `"inline*"` or `"block+"`. */
|
|
107
|
+
content?: string;
|
|
108
|
+
inline?: boolean;
|
|
109
|
+
/** A node with no editable content of its own: an image, a divider. */
|
|
110
|
+
atom?: boolean;
|
|
111
|
+
/** Attribute names and their defaults. Serialisable, so the panel gets them. */
|
|
112
|
+
attrs?: Record<string, {
|
|
113
|
+
default?: JsonValue;
|
|
114
|
+
}>;
|
|
115
|
+
/** Marks allowed inside. `""` forbids all of them. */
|
|
116
|
+
marks?: string;
|
|
117
|
+
/** Required. A node that cannot render as HTML is a node a REST client cannot use. */
|
|
118
|
+
toHtml: NodeSerializer;
|
|
119
|
+
/** Required, for the same reason: Markdown is what an AI prompt and an export speak. */
|
|
120
|
+
toMarkdown: NodeSerializer;
|
|
121
|
+
/** Plain text, for search indexes and excerpts. Defaults to the children. */
|
|
122
|
+
toText?: NodeSerializer;
|
|
123
|
+
/** The panel's React component for a node view. Never imported by the core. */
|
|
124
|
+
Component?: ComponentType<Record<string, unknown>>;
|
|
125
|
+
}
|
|
126
|
+
export interface EditorMarkDefinition {
|
|
127
|
+
name: string;
|
|
128
|
+
attrs?: Record<string, {
|
|
129
|
+
default?: JsonValue;
|
|
130
|
+
}>;
|
|
131
|
+
toHtml: MarkSerializer;
|
|
132
|
+
toMarkdown: MarkSerializer;
|
|
133
|
+
}
|
|
134
|
+
/** What `renderRichText()` produces. */
|
|
135
|
+
export type RichTextFormat = "html" | "markdown" | "text";
|
|
136
|
+
export interface RenderRichTextOptions {
|
|
137
|
+
format: RichTextFormat;
|
|
138
|
+
mediaUrl?: (id: string) => string | null;
|
|
139
|
+
/** Resolves a media id to a full image description; wins over `mediaUrl`. */
|
|
140
|
+
mediaImage?: (id: string) => RichTextMediaImage | null;
|
|
141
|
+
/** `loading` and `decoding` for every image. Nothing is added when omitted. */
|
|
142
|
+
images?: RichTextImageOptions;
|
|
143
|
+
}
|
|
144
|
+
/** The node and mark registry, as `cms.inspect()` and the panel read it. */
|
|
145
|
+
export interface EditorSchemaDescription {
|
|
146
|
+
nodes: {
|
|
147
|
+
name: string;
|
|
148
|
+
group?: string;
|
|
149
|
+
content?: string;
|
|
150
|
+
inline: boolean;
|
|
151
|
+
atom: boolean;
|
|
152
|
+
attrs: Record<string, {
|
|
153
|
+
default?: JsonValue;
|
|
154
|
+
}>;
|
|
155
|
+
marks?: string;
|
|
156
|
+
/** Whether a plugin registered a component for the panel to render. */
|
|
157
|
+
component: boolean;
|
|
158
|
+
}[];
|
|
159
|
+
marks: {
|
|
160
|
+
name: string;
|
|
161
|
+
attrs: Record<string, {
|
|
162
|
+
default?: JsonValue;
|
|
163
|
+
}>;
|
|
164
|
+
}[];
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../src/types/editor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnE;;;;;;;;;;;;GAYG;AAEH,2DAA2D;AAC3D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACnC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAClC,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;CACxB;AAED,+EAA+E;AAC/E,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI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AAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B;AAED,4EAA4E;AAC5E,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,OAAO,CAAC;QAChB,IAAI,EAAE,OAAO,CAAC;QACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,OAAO,CAAC,EAAE,SAAS,CAAA;SAAE,CAAC,CAAC;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,uEAAuE;QACvE,SAAS,EAAE,OAAO,CAAC;KACpB,EAAE,CAAC;IACJ,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,OAAO,CAAC,EAAE,SAAS,CAAA;SAAE,CAAC,CAAC;KAChD,EAAE,CAAC;CACL"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ActorSource } from "./actor";
|
|
2
|
+
import type { JsonObject } from "./json";
|
|
3
|
+
/**
|
|
4
|
+
* The event catalogue from section 7.
|
|
5
|
+
*
|
|
6
|
+
* Webhook subscriptions, the activity log and the paid versions package all
|
|
7
|
+
* read from this one list, so an event added here is immediately subscribable
|
|
8
|
+
* without touching the webhook layer.
|
|
9
|
+
*/
|
|
10
|
+
export type DocumentEventType = "document.created" | "document.updated" | "document.field.changed" | "document.scheduled" | "document.schedule.applied"
|
|
11
|
+
/**
|
|
12
|
+
* The one addition to the catalogue in section 7.
|
|
13
|
+
*
|
|
14
|
+
* A cancellation reported as `document.scheduled` with an empty payload
|
|
15
|
+
* would make every subscriber to "something was scheduled" tell its users
|
|
16
|
+
* about a schedule that no longer exists.
|
|
17
|
+
*/
|
|
18
|
+
| "document.schedule.cancelled" | "document.trashed" | "document.restored" | "document.purged";
|
|
19
|
+
export type MediaEventType = "media.uploaded" | "media.updated" | "media.orphaned" | "media.reclaimed" | "media.purged" | "media.processing.failed";
|
|
20
|
+
export type LocaleEventType = "translation.completed";
|
|
21
|
+
/**
|
|
22
|
+
* What the AI runtime reports.
|
|
23
|
+
*
|
|
24
|
+
* `ai.task.*` is one field action. `ai.agent.*` is one run of the panel-wide
|
|
25
|
+
* assistant, and `ai.agent.mutation.applied` is one write inside such a run —
|
|
26
|
+
* emitted *in addition to* the ordinary `document.updated`, not instead of
|
|
27
|
+
* it, so a subscriber that cares about content hears it the usual way and a
|
|
28
|
+
* subscriber auditing the agent can correlate by `runId`.
|
|
29
|
+
*
|
|
30
|
+
* None of them carry the prompt, the reply or the record. They carry the run
|
|
31
|
+
* id, the model, the usage, the duration, the tool names and the fields that
|
|
32
|
+
* changed — which is what an audit needs and all an audit may have.
|
|
33
|
+
*/
|
|
34
|
+
export type AiEventType = "ai.task.completed" | "ai.task.failed" | "ai.agent.completed" | "ai.agent.failed" | "ai.agent.mutation.applied";
|
|
35
|
+
export type AccessEventType = "user.invited" | "user.joined" | "user.removed" | "role.changed" | "apikey.created" | "apikey.revoked";
|
|
36
|
+
export type SystemEventType = "migration.applied" | "job.failed";
|
|
37
|
+
export type CmsEventType = DocumentEventType | MediaEventType | LocaleEventType | AiEventType | AccessEventType | SystemEventType;
|
|
38
|
+
/**
|
|
39
|
+
* Anything a plugin emits. The template literal keeps editor completion for
|
|
40
|
+
* the catalogue while leaving room for `analytics.rollup.finished`.
|
|
41
|
+
*/
|
|
42
|
+
export type AnyEventType = CmsEventType | (string & {});
|
|
43
|
+
/**
|
|
44
|
+
* An event as it is stored in the outbox and delivered to webhooks.
|
|
45
|
+
*
|
|
46
|
+
* `previous` is part of the contract rather than an optimisation: the paid
|
|
47
|
+
* versions package is specified to reconstruct history from events alone
|
|
48
|
+
* (section 4), which is only possible if every change carries both sides.
|
|
49
|
+
*/
|
|
50
|
+
export interface CmsEvent<TData extends JsonObject = JsonObject> {
|
|
51
|
+
id: string;
|
|
52
|
+
type: AnyEventType;
|
|
53
|
+
createdAt: string;
|
|
54
|
+
actor: {
|
|
55
|
+
id: string;
|
|
56
|
+
source: ActorSource;
|
|
57
|
+
} | null;
|
|
58
|
+
data: TData;
|
|
59
|
+
previous: JsonObject | null;
|
|
60
|
+
}
|
|
61
|
+
export type CmsEventListener<TData extends JsonObject = JsonObject> = (event: CmsEvent<TData>) => void | Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* The emitter handed to hooks.
|
|
64
|
+
*
|
|
65
|
+
* It queues into the outbox inside the running transaction and never performs
|
|
66
|
+
* the side effect itself: a rolled back transaction must not send a webhook,
|
|
67
|
+
* and a committed one must send it even if the process dies (section 5).
|
|
68
|
+
*/
|
|
69
|
+
export interface HookEventEmitter {
|
|
70
|
+
emit(type: AnyEventType, data: JsonObject, previous?: JsonObject | null): void;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GACzB,kBAAkB,GAClB,kBAAkB,GAClB,wBAAwB,GACxB,oBAAoB,GACpB,2BAA2B;AAC7B;;;;;;GAMG;GACD,6BAA6B,GAC7B,kBAAkB,GAClB,mBAAmB,GACnB,iBAAiB,CAAC;AAEtB,MAAM,MAAM,cAAc,GACtB,gBAAgB,GAChB,eAAe,GACf,gBAAgB,GAChB,iBAAiB,GACjB,cAAc,GACd,yBAAyB,CAAC;AAE9B,MAAM,MAAM,eAAe,GAAG,uBAAuB,CAAC;AAEtD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,WAAW,GACnB,mBAAmB,GACnB,gBAAgB,GAChB,oBAAoB,GACpB,iBAAiB,GACjB,2BAA2B,CAAC;AAEhC,MAAM,MAAM,eAAe,GACvB,cAAc,GACd,aAAa,GACb,cAAc,GACd,cAAc,GACd,gBAAgB,GAChB,gBAAgB,CAAC;AAErB,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,YAAY,CAAC;AAEjE,MAAM,MAAM,YAAY,GACpB,iBAAiB,GACjB,cAAc,GACd,eAAe,GACf,WAAW,GACX,eAAe,GACf,eAAe,CAAC;AAEpB;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU;IAC7D,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,WAAW,CAAA;KAAE,GAAG,IAAI,CAAC;IAClD,IAAI,EAAE,KAAK,CAAC;IACZ,QAAQ,EAAE,UAAU,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,MAAM,gBAAgB,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU,IAAI,CACpE,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KACnB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CACF,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,UAAU,EAChB,QAAQ,CAAC,EAAE,UAAU,GAAG,IAAI,GAC3B,IAAI,CAAC;CACT"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { ZodType } from "zod";
|
|
2
|
+
import type { Actor } from "./actor";
|
|
3
|
+
import type { ComponentType, JsonObject, JsonValue } from "./json";
|
|
4
|
+
import type { ColumnDefinition } from "./schema";
|
|
5
|
+
/** A model reference. The provider id comes from the pi catalogue (section 8). */
|
|
6
|
+
export interface AiModelRef {
|
|
7
|
+
provider: string;
|
|
8
|
+
model: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* One AI action on one field — one entry in the menu next to that field.
|
|
12
|
+
*
|
|
13
|
+
* Nothing is shared between actions: each has its own prompt, its own context
|
|
14
|
+
* and optionally its own model. A missing key means the action does not exist
|
|
15
|
+
* in the panel at all, which is how AI stays opt-in per field (section 8).
|
|
16
|
+
*/
|
|
17
|
+
export interface FieldAiAction {
|
|
18
|
+
/** Defaults to the action key. */
|
|
19
|
+
label?: string;
|
|
20
|
+
prompt?: string;
|
|
21
|
+
/** Fields of the document the model is allowed to see for this action. */
|
|
22
|
+
context?: string[];
|
|
23
|
+
model?: AiModelRef;
|
|
24
|
+
maxLength?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* `true` turns on a built-in action with its default prompt; an object
|
|
28
|
+
* customises it. Unknown keys are custom actions registered with
|
|
29
|
+
* `defineAiAction()`.
|
|
30
|
+
*/
|
|
31
|
+
export type FieldAiConfig = Record<string, FieldAiAction | true>;
|
|
32
|
+
/** What an access rule is told about the row it is deciding on. */
|
|
33
|
+
export interface FieldAccessContext {
|
|
34
|
+
actor: Actor | null;
|
|
35
|
+
record?: Record<string, unknown>;
|
|
36
|
+
locale: string | null;
|
|
37
|
+
}
|
|
38
|
+
export type FieldAccessRule = (context: FieldAccessContext) => boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Field-level access.
|
|
41
|
+
*
|
|
42
|
+
* There is no `access.publish` anywhere in the engine: who may publish is
|
|
43
|
+
* whoever may write the `status` field, which is exactly this (section 11).
|
|
44
|
+
*/
|
|
45
|
+
export interface FieldAccess {
|
|
46
|
+
read?: FieldAccessRule;
|
|
47
|
+
update?: FieldAccessRule;
|
|
48
|
+
}
|
|
49
|
+
/** Panel-only presentation. The engine never reads these. */
|
|
50
|
+
export interface FieldAdminOptions {
|
|
51
|
+
placeholder?: string;
|
|
52
|
+
hidden?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/** Server-side, deterministic generator. `fields` contains only readable sibling fields. */
|
|
55
|
+
export type FieldGenerator = (args: {
|
|
56
|
+
fields: JsonObject;
|
|
57
|
+
locale: string;
|
|
58
|
+
}) => JsonValue | Promise<JsonValue>;
|
|
59
|
+
/** Options every field accepts, whatever its type. */
|
|
60
|
+
export interface FieldOptions {
|
|
61
|
+
label?: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
/** Stored as `{ [locale]: value }` inside the document body. */
|
|
64
|
+
localized?: boolean;
|
|
65
|
+
required?: boolean;
|
|
66
|
+
unique?: boolean;
|
|
67
|
+
index?: boolean;
|
|
68
|
+
readOnly?: boolean;
|
|
69
|
+
/** Generate this field from the current form values, without AI. */
|
|
70
|
+
generate?: FieldGenerator;
|
|
71
|
+
/** Generate an AI suggestion for this particular field; context names sibling fields. */
|
|
72
|
+
aiGenerate?: FieldAiAction;
|
|
73
|
+
/** @deprecated Use aiGenerate for field generation. Other legacy actions remain supported. */
|
|
74
|
+
ai?: FieldAiConfig;
|
|
75
|
+
access?: FieldAccess;
|
|
76
|
+
admin?: FieldAdminOptions;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A field as the engine sees it after a builder has validated its options.
|
|
80
|
+
*
|
|
81
|
+
* `TValue` is the value for a single locale. A localized field stores a record
|
|
82
|
+
* keyed by locale code in the document body, but every read resolves one
|
|
83
|
+
* locale before the value reaches a hook, the API or a template, so a
|
|
84
|
+
* consumer never has to know which fields are translated.
|
|
85
|
+
*/
|
|
86
|
+
export interface FieldDefinition<TValue = unknown> {
|
|
87
|
+
readonly type: string;
|
|
88
|
+
readonly options: FieldOptions & Record<string, unknown>;
|
|
89
|
+
/** Validates one locale's value. Validation is zod, never a hook. */
|
|
90
|
+
readonly schema: ZodType<TValue>;
|
|
91
|
+
readonly column: ColumnDefinition;
|
|
92
|
+
readonly localized: boolean;
|
|
93
|
+
readonly required: boolean;
|
|
94
|
+
readonly defaultValue?: JsonValue;
|
|
95
|
+
readonly generate?: FieldGenerator;
|
|
96
|
+
readonly aiGenerate?: FieldAiAction;
|
|
97
|
+
readonly ai?: FieldAiConfig;
|
|
98
|
+
readonly access?: FieldAccess;
|
|
99
|
+
readonly admin?: FieldAdminOptions;
|
|
100
|
+
/** Collection targeted by a relation field; drives the batch loader. */
|
|
101
|
+
readonly relationTo?: string;
|
|
102
|
+
}
|
|
103
|
+
export interface FieldInputProps<TValue> {
|
|
104
|
+
value: TValue;
|
|
105
|
+
onChange: (value: TValue) => void;
|
|
106
|
+
field: FieldDefinition<TValue>;
|
|
107
|
+
name: string;
|
|
108
|
+
locale: string | null;
|
|
109
|
+
disabled?: boolean;
|
|
110
|
+
readOnly?: boolean;
|
|
111
|
+
error?: string;
|
|
112
|
+
}
|
|
113
|
+
export interface FieldCellProps<TValue> {
|
|
114
|
+
value: TValue;
|
|
115
|
+
field: FieldDefinition<TValue>;
|
|
116
|
+
name: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A registered field type.
|
|
120
|
+
*
|
|
121
|
+
* Built-in fields are declared with exactly this contract through
|
|
122
|
+
* `defineField()`, so a third-party field is never a second-class citizen
|
|
123
|
+
* (stage 9). `Input` and `Cell` are optional: the core must not depend on a
|
|
124
|
+
* renderer, and the panel falls back to the input registered for the
|
|
125
|
+
* underlying column type.
|
|
126
|
+
*/
|
|
127
|
+
export interface FieldType<TValue, TOptions extends FieldOptions = FieldOptions> {
|
|
128
|
+
name: string;
|
|
129
|
+
schema(options: TOptions): ZodType<TValue>;
|
|
130
|
+
column(options: TOptions): ColumnDefinition;
|
|
131
|
+
/** Validates the options object itself, at config build time. */
|
|
132
|
+
optionsSchema?: ZodType<TOptions>;
|
|
133
|
+
/** AI action keys this type can expose, used to reject typos in `ai`. */
|
|
134
|
+
aiActions?: string[];
|
|
135
|
+
Input?: ComponentType<FieldInputProps<TValue>>;
|
|
136
|
+
Cell?: ComponentType<FieldCellProps<TValue>>;
|
|
137
|
+
}
|
|
138
|
+
/** The value type a field definition carries, for document inference. */
|
|
139
|
+
export type InferFieldValue<TField> = TField extends FieldDefinition<infer TValue> ? TValue : never;
|
|
140
|
+
/** A collection's fields, keyed by field name. */
|
|
141
|
+
export type FieldsConfig = Record<string, FieldDefinition>;
|
|
142
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/types/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,kFAAkF;AAClF,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC,CAAC;AAEjE,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,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C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,gBAAgB,CAAC;IAC5C,iEAAiE;IACjE,aAAa,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClC,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,aAAa,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,IAAI,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;CAC9C;AAED,yEAAyE;AACzE,MAAM,MAAM,eAAe,CAAC,MAAM,IAChC,MAAM,SAAS,eAAe,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC;AAEhE,kDAAkD;AAClD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { Actor, OperationSource } from "./actor";
|
|
2
|
+
import type { HookEventEmitter } from "./events";
|
|
3
|
+
import type { CmsInstance } from "./instance";
|
|
4
|
+
import type { JsonObject } from "./json";
|
|
5
|
+
import type { Mutation, MutationResult, Query, Row, Tx, Where } from "./query";
|
|
6
|
+
/**
|
|
7
|
+
* The operations a hook can observe.
|
|
8
|
+
*
|
|
9
|
+
* There is no `publish` here. The engine has no document lifecycle: status is
|
|
10
|
+
* an ordinary `select()` field, so publishing is an update and nothing else
|
|
11
|
+
* (sections 3 and 11).
|
|
12
|
+
*/
|
|
13
|
+
export type HookOperation = "create" | "update" | "delete";
|
|
14
|
+
/**
|
|
15
|
+
* Database access that bypasses access control, on purpose and by name.
|
|
16
|
+
*
|
|
17
|
+
* The alternative — an `overrideAccess: true` flag buried in an options object
|
|
18
|
+
* — is how Payload makes a security decision look like a formatting choice.
|
|
19
|
+
* Here `ctx.db` always bypasses and `ctx.cms` always enforces, and the reader
|
|
20
|
+
* can tell which is which without opening the call site.
|
|
21
|
+
*/
|
|
22
|
+
export interface ScopedDb {
|
|
23
|
+
query(query: Query): Promise<Row[]>;
|
|
24
|
+
mutate(mutation: Mutation): Promise<MutationResult>;
|
|
25
|
+
find(table: string, where?: Where): Promise<Row[]>;
|
|
26
|
+
findOne(table: string, where: Where): Promise<Row | null>;
|
|
27
|
+
insert(table: string, values: Row): Promise<Row>;
|
|
28
|
+
update(table: string, where: Where, set: Row): Promise<number>;
|
|
29
|
+
delete(table: string, where: Where): Promise<number>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* One context object for every hook, whatever the operation.
|
|
33
|
+
*
|
|
34
|
+
* Payload's hooks each receive a differently shaped argument, which is why
|
|
35
|
+
* its documentation needs a table per hook. One shape means one thing to
|
|
36
|
+
* learn, and the engine can pass the same object down the whole pipeline.
|
|
37
|
+
*/
|
|
38
|
+
export interface HookContext {
|
|
39
|
+
actor: Actor | null;
|
|
40
|
+
collection: string;
|
|
41
|
+
operation: HookOperation;
|
|
42
|
+
locale: string | null;
|
|
43
|
+
/** The transaction the operation runs in. */
|
|
44
|
+
tx: Tx;
|
|
45
|
+
/** Bypasses access control. */
|
|
46
|
+
db: ScopedDb;
|
|
47
|
+
/** Enforces access control. */
|
|
48
|
+
cms: CmsInstance;
|
|
49
|
+
/** Side effects go here, never inline: the outbox decides when they run. */
|
|
50
|
+
events: HookEventEmitter;
|
|
51
|
+
source: OperationSource;
|
|
52
|
+
/** Passing values between hooks in one operation. */
|
|
53
|
+
meta: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* What every hook may return — the same four cases for all of them.
|
|
57
|
+
*
|
|
58
|
+
* `undefined` continue unchanged, `{ data }` continue with a replacement,
|
|
59
|
+
* `false` stop silently, `throw CmsError` stop with a status.
|
|
60
|
+
*/
|
|
61
|
+
export type HookResult<TData> = void | undefined | false | {
|
|
62
|
+
data: TData;
|
|
63
|
+
};
|
|
64
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
65
|
+
export interface CreateHookInput<TDoc> {
|
|
66
|
+
data: TDoc;
|
|
67
|
+
}
|
|
68
|
+
export interface UpdateHookInput<TDoc> {
|
|
69
|
+
data: Partial<TDoc>;
|
|
70
|
+
previous: TDoc;
|
|
71
|
+
}
|
|
72
|
+
export interface UpdateHookOutput<TDoc> {
|
|
73
|
+
doc: TDoc;
|
|
74
|
+
previous: TDoc;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Hooks for one collection.
|
|
78
|
+
*
|
|
79
|
+
* `before` runs in the transaction ahead of the write, `after` runs in the
|
|
80
|
+
* same transaction behind it. There is no third moment: anything that must
|
|
81
|
+
* not be rolled back is an event (section 5).
|
|
82
|
+
*/
|
|
83
|
+
export interface CollectionDatabaseHooks<TDoc extends JsonObject = JsonObject> {
|
|
84
|
+
create?: {
|
|
85
|
+
before?: (input: CreateHookInput<TDoc>, context: HookContext) => MaybePromise<HookResult<TDoc>>;
|
|
86
|
+
after?: (doc: TDoc, context: HookContext) => MaybePromise<void>;
|
|
87
|
+
};
|
|
88
|
+
update?: {
|
|
89
|
+
before?: (input: UpdateHookInput<TDoc>, context: HookContext) => MaybePromise<HookResult<Partial<TDoc>>>;
|
|
90
|
+
after?: (output: UpdateHookOutput<TDoc>, context: HookContext) => MaybePromise<void>;
|
|
91
|
+
};
|
|
92
|
+
delete?: {
|
|
93
|
+
before?: (doc: TDoc, context: HookContext) => MaybePromise<HookResult<TDoc>>;
|
|
94
|
+
after?: (doc: TDoc, context: HookContext) => MaybePromise<void>;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** `databaseHooks`, keyed by collection name. */
|
|
98
|
+
export type DatabaseHooks<TCollections extends Record<string, unknown>> = {
|
|
99
|
+
[K in keyof TCollections]?: CollectionDatabaseHooks<JsonObject>;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* The HTTP layer: rate limiting, response decoration, telemetry.
|
|
103
|
+
*
|
|
104
|
+
* A `before` hook that returns a `Response` short-circuits the request, which
|
|
105
|
+
* is what makes rate limiting expressible without a separate middleware
|
|
106
|
+
* concept.
|
|
107
|
+
*/
|
|
108
|
+
export interface HttpHookContext {
|
|
109
|
+
request: Request;
|
|
110
|
+
/** Path with `basePath` already stripped, as the router sees it. */
|
|
111
|
+
path: string;
|
|
112
|
+
method: string;
|
|
113
|
+
/**
|
|
114
|
+
* The request's headers in a `before` hook, the response's in an `after`
|
|
115
|
+
* one — which is the only pair that is useful: before the route there is no
|
|
116
|
+
* response to decorate, and after it the request's headers are already in
|
|
117
|
+
* `request`.
|
|
118
|
+
*/
|
|
119
|
+
headers: Headers;
|
|
120
|
+
/** The response status. Present in an `after` hook only. */
|
|
121
|
+
status?: number;
|
|
122
|
+
/**
|
|
123
|
+
* Who is calling, resolved from the cookie or the `Authorization` header
|
|
124
|
+
* before any hook runs: a rate limiter that cannot tell an editor from a
|
|
125
|
+
* stranger is a rate limiter on the wrong thing.
|
|
126
|
+
*/
|
|
127
|
+
actor: Actor | null;
|
|
128
|
+
cms: CmsInstance;
|
|
129
|
+
/** One object per request, shared by the `before` and `after` hooks. */
|
|
130
|
+
meta: Record<string, unknown>;
|
|
131
|
+
}
|
|
132
|
+
export interface HttpHook {
|
|
133
|
+
matcher: (context: HttpHookContext) => boolean;
|
|
134
|
+
handler: (context: HttpHookContext) => MaybePromise<void | Response>;
|
|
135
|
+
/** Lower runs first. Plugin hooks default to 0, user hooks to 100. */
|
|
136
|
+
priority?: number;
|
|
137
|
+
}
|
|
138
|
+
export interface HttpHooks {
|
|
139
|
+
before?: HttpHook[];
|
|
140
|
+
after?: HttpHook[];
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/types/h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AAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC;IAC/C,OAAO,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,YAAY,CAAC,IAAI,GAAG,QAAQ,CAAC,CAAC;IACrE,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;CACpB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type * from "./activity";
|
|
2
|
+
export type * from "./actor";
|
|
3
|
+
export type * from "./ai";
|
|
4
|
+
export type * from "./api";
|
|
5
|
+
export type * from "./auth";
|
|
6
|
+
export type * from "./config";
|
|
7
|
+
export type * from "./database";
|
|
8
|
+
export type * from "./editor";
|
|
9
|
+
export type * from "./events";
|
|
10
|
+
export type * from "./fields";
|
|
11
|
+
export type * from "./hooks";
|
|
12
|
+
export type * from "./instance";
|
|
13
|
+
export type * from "./jobs";
|
|
14
|
+
export type * from "./json";
|
|
15
|
+
export type * from "./locales";
|
|
16
|
+
export type * from "./media";
|
|
17
|
+
export type * from "./panel";
|
|
18
|
+
export type * from "./plugin";
|
|
19
|
+
export type * from "./query";
|
|
20
|
+
export type * from "./schema";
|
|
21
|
+
export type * from "./storage";
|
|
22
|
+
export type * from "./telemetry";
|
|
23
|
+
export type * from "./trash";
|
|
24
|
+
export type * from "./webhooks";
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,MAAM,CAAC;AAC1B,mBAAmB,OAAO,CAAC;AAC3B,mBAAmB,QAAQ,CAAC;AAC5B,mBAAmB,UAAU,CAAC;AAC9B,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,UAAU,CAAC;AAC9B,mBAAmB,UAAU,CAAC;AAC9B,mBAAmB,UAAU,CAAC;AAC9B,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,QAAQ,CAAC;AAC5B,mBAAmB,QAAQ,CAAC;AAC5B,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,UAAU,CAAC;AAC9B,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,UAAU,CAAC;AAC9B,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,aAAa,CAAC;AACjC,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,YAAY,CAAC"}
|