@heyo-sh/heyo-cms 0.0.0-stage → 0.1.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 +38 -0
- package/dist/adapters/astro.d.ts.map +1 -0
- package/dist/adapters/astro.js +1 -0
- package/dist/adapters/next.d.ts +31 -0
- package/dist/adapters/next.d.ts.map +1 -0
- package/dist/adapters/next.js +1 -0
- package/dist/adapters/nuxt.d.ts +47 -0
- package/dist/adapters/nuxt.d.ts.map +1 -0
- package/dist/adapters/nuxt.js +1 -0
- package/dist/adapters/react-router.d.ts +29 -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 +37 -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 +340 -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 +35 -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 +39 -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 +276 -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/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 +142 -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 +8 -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 +30 -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 +28 -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-2757kej5.js +2 -0
- package/dist/index-2kb5nbxx.js +2 -0
- package/dist/index-2z1qe5mw.js +2 -0
- package/dist/index-34s342fz.js +2 -0
- package/dist/index-5ngtc7gy.js +2 -0
- package/dist/index-7a231xfp.js +2 -0
- package/dist/index-7k091gpe.js +2 -0
- package/dist/index-9g2n7xa6.js +2 -0
- package/dist/index-9x1z3b85.js +5 -0
- package/dist/index-9zqnf6gx.js +23 -0
- package/dist/index-b2ecggck.js +26 -0
- package/dist/index-cbwwtcm4.js +2 -0
- package/dist/index-ebtj6ebd.js +0 -0
- package/dist/index-g4crf47y.js +0 -0
- package/dist/index-gpwcmmvr.js +2 -0
- package/dist/index-hq05mc1n.js +3 -0
- package/dist/index-hy1x46nf.js +2 -0
- package/dist/index-k8wbg1dw.js +2 -0
- package/dist/index-kbsgt44t.js +2 -0
- package/dist/index-m82a0shw.js +2 -0
- package/dist/index-md79xr6h.js +5 -0
- package/dist/index-nvgwyykk.js +40 -0
- package/dist/index-ty698y02.js +2 -0
- package/dist/index-vq2978e7.js +14 -0
- package/dist/index-vxw0a03g.js +2 -0
- package/dist/index-wj8y1xcj.js +2 -0
- package/dist/index-x72d1hzh.js +2 -0
- package/dist/index-y5mwknr9.js +2 -0
- package/dist/index-ymq6jsar.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/document.d.ts +28 -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 +36 -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/usages.d.ts +69 -0
- package/dist/media/usages.d.ts.map +1 -0
- package/dist/media/variants.d.ts +50 -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/query.d.ts +40 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +1 -0
- package/dist/run-3r72dwhs.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 +22 -0
- package/dist/schema/snapshot.d.ts.map +1 -0
- package/dist/schema/system.d.ts +22 -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/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 +212 -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 +632 -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 +140 -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 +245 -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 +172 -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 +21 -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 +183 -4
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Actor } from "../types/actor";
|
|
2
|
+
import type { DatabaseAdapter } from "../types/database";
|
|
3
|
+
import type { AnyEventType, CmsEvent, HookEventEmitter } from "../types/events";
|
|
4
|
+
import type { JsonObject } from "../types/json";
|
|
5
|
+
import type { Tx } from "../types/query";
|
|
6
|
+
export declare const outboxTable = "outbox";
|
|
7
|
+
export interface BufferedEvent {
|
|
8
|
+
type: AnyEventType;
|
|
9
|
+
data: JsonObject;
|
|
10
|
+
previous: JsonObject | null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* `ctx.events`: the only way a hook causes a side effect.
|
|
14
|
+
*
|
|
15
|
+
* Emitting queues; it never sends. A mail or a webhook fired inside the
|
|
16
|
+
* transaction would go out even when the write is rolled back, and a mail
|
|
17
|
+
* fired after the commit without a record would be lost when the process
|
|
18
|
+
* dies between the two. The queue is drained into the outbox table by the
|
|
19
|
+
* engine, inside the same transaction as the write (section 5).
|
|
20
|
+
*/
|
|
21
|
+
export declare class EventBuffer implements HookEventEmitter {
|
|
22
|
+
private readonly queued;
|
|
23
|
+
emit(type: AnyEventType, data: JsonObject, previous?: JsonObject | null): void;
|
|
24
|
+
/** Empties the queue; the caller is now responsible for the events. */
|
|
25
|
+
take(): BufferedEvent[];
|
|
26
|
+
}
|
|
27
|
+
export interface OutboxEntryMeta {
|
|
28
|
+
actor: Actor | null;
|
|
29
|
+
collection?: string;
|
|
30
|
+
documentId?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface OutboxOptions {
|
|
33
|
+
/** Section 7: five attempts, then the delivery is dead. */
|
|
34
|
+
maxAttempts?: number;
|
|
35
|
+
/** Exponential by default: 1s, 2s, 4s, 8s. */
|
|
36
|
+
backoff?: (attempt: number) => number;
|
|
37
|
+
/** Abandoned deliveries become claimable again. Subscribers must deduplicate event.id. */
|
|
38
|
+
leaseMs?: number;
|
|
39
|
+
now?: () => Date;
|
|
40
|
+
}
|
|
41
|
+
export type EventDispatch = (event: CmsEvent) => Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* The transactional outbox.
|
|
44
|
+
*
|
|
45
|
+
* Rows are written inside the transaction that produced them and delivered
|
|
46
|
+
* afterwards. That is the whole mechanism behind two promises the plan makes:
|
|
47
|
+
* a rolled back write sends nothing, and a committed one sends even if the
|
|
48
|
+
* process dies one line later (sections 5 and 7). It also means an engine
|
|
49
|
+
* without real transactions still has a defined behaviour — the row lands in
|
|
50
|
+
* the same operation sequence as the document, and the worker is idempotent
|
|
51
|
+
* because it claims a row before delivering it.
|
|
52
|
+
*/
|
|
53
|
+
export declare class Outbox {
|
|
54
|
+
private readonly adapter;
|
|
55
|
+
private readonly dispatch;
|
|
56
|
+
private readonly maxAttempts;
|
|
57
|
+
private readonly backoff;
|
|
58
|
+
private readonly leaseMs;
|
|
59
|
+
private readonly now;
|
|
60
|
+
constructor(adapter: DatabaseAdapter, dispatch: EventDispatch, options?: OutboxOptions);
|
|
61
|
+
append(tx: Tx, events: BufferedEvent[], meta: OutboxEntryMeta): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Delivers what is due and reports how much it delivered.
|
|
64
|
+
*
|
|
65
|
+
* Claim, deliver, settle — three short transactions rather than one long
|
|
66
|
+
* one, because a delivery is an HTTP call and holding a row lock across it
|
|
67
|
+
* is how an outbox turns into an outage.
|
|
68
|
+
*/
|
|
69
|
+
drain(limit?: number): Promise<number>;
|
|
70
|
+
/**
|
|
71
|
+
* Takes ownership of a row, or finds out somebody else already has.
|
|
72
|
+
*
|
|
73
|
+
* A conditional update is the portable claim: it works on all three
|
|
74
|
+
* engines, needs no row locking and makes a second worker — or a retried
|
|
75
|
+
* request on serverless — harmless.
|
|
76
|
+
*/
|
|
77
|
+
private hasPredecessor;
|
|
78
|
+
private claim;
|
|
79
|
+
private settle;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=outbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox.d.ts","sourceRoot":"","sources":["../../src/engine/outbox.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAO,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAG9C,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,UAAU,GAAG,IAAI,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,qBAAa,WAAY,YAAW,gBAAgB;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuB;IAE9C,IAAI,CACF,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,UAAU,EAChB,QAAQ,GAAE,UAAU,GAAG,IAAW,GACjC,IAAI,CAEN;IAED,uEAAuE;IACvE,IAAI,IAAI,aAAa,EAAE,CAEtB;CACF;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;IACtC,0FAA0F;IAC1F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE/D;;;;;;;;;;GAUG;AACH,qBAAa,MAAM;IAOf,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAP3B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IACtD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAa;IAEjC,YACmB,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,aAAa,EACxC,OAAO,GAAE,aAAkB,EAM5B;IAEK,MAAM,CACV,EAAE,EAAE,EAAE,EACN,MAAM,EAAE,aAAa,EAAE,EACvB,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,IAAI,CAAC,CA2Bf;IAED;;;;;;OAMG;IACG,KAAK,CAAC,KAAK,SAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAmCvC;IAED;;;;;;OAMG;YACW,cAAc;YAoBd,KAAK;YAuBL,MAAM;CAmCrB"}
|
|
@@ -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,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,142 @@
|
|
|
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
|
+
/**
|
|
107
|
+
* There is no `slug` type, and that is deliberate.
|
|
108
|
+
*
|
|
109
|
+
* It was one of these for a while, and it earned its keep by being `text`
|
|
110
|
+
* with `unique`, `index` and a hyphen pattern already set — plus a `from`
|
|
111
|
+
* option that promised the value would be derived from another field and
|
|
112
|
+
* never did it, because nothing in the engine generates one field out of
|
|
113
|
+
* another. A type whose only feature is a default and a promise is a type
|
|
114
|
+
* that teaches the wrong thing. A URL handle is a `text` field:
|
|
115
|
+
*
|
|
116
|
+
* ```ts
|
|
117
|
+
* handle: text({
|
|
118
|
+
* unique: true,
|
|
119
|
+
* index: true,
|
|
120
|
+
* pattern: "^[a-z0-9]+(?:-[a-z0-9]+)*$",
|
|
121
|
+
* })
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* and generating it from the title is a `create.before` hook, which runs
|
|
125
|
+
* before validation precisely so that it can fill a required field.
|
|
126
|
+
*/
|
|
127
|
+
export declare const email: import("./registry").FieldBuilder<string, TextOptions>;
|
|
128
|
+
export declare const url: import("./registry").FieldBuilder<string, TextOptions>;
|
|
129
|
+
/**
|
|
130
|
+
* SEO as fields, not as a plugin.
|
|
131
|
+
*
|
|
132
|
+
* A plugin would own the fields, the prompts and the panel section; a preset
|
|
133
|
+
* spreads into `fields` and stays editable (`...seoFields()`), which is the
|
|
134
|
+
* decision recorded in section 11.
|
|
135
|
+
*/
|
|
136
|
+
export declare function seoFields(): {
|
|
137
|
+
seoTitle: FieldDefinition<string | null>;
|
|
138
|
+
seoDescription: FieldDefinition<string | null>;
|
|
139
|
+
ogImage: FieldDefinition<string | null>;
|
|
140
|
+
canonical: FieldDefinition<string | null>;
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=builtin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtin.d.ts","sourceRoot":"","sources":["../../src/fields/builtin.ts"],"names":[],"mappings":"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"}
|
|
@@ -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,8 @@
|
|
|
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
|
+
//# 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"}
|
package/dist/fields.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ro,Jo,No,T}from"./index-k8wbg1dw.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()}),o=e.lazy(()=>e.union([e.string(),e.number(),e.boolean(),e.null(),e.array(o),e.record(e.string(),o)])),l=T({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"]}),r=T({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"]}),f=T({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"]}),O=T({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}})}),h=T({name:"boolean",optionsSchema:i.extend({default:e.boolean().optional()}),schema:()=>e.boolean(),column:(n)=>({type:"boolean",...n.default===void 0?{}:{default:n.default}})}),y=T({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"})}),a=(n)=>n.map((t)=>typeof t==="string"?t:t.value),s=i.extend({options:e.array(e.union([e.string(),e.strictObject({label:e.string(),value:e.string()})])).min(1),default:e.string().optional()}),p=T({name:"select",optionsSchema:s,schema:(n)=>e.enum(a(n.options)),column:(n)=>({type:"text",...n.default===void 0?{}:{default:n.default}})});function b(n){return p(n)}var m=T({name:"multiselect",optionsSchema:s.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(a(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 F(n){return m(n)}var S=T({name:"json",optionsSchema:i,schema:()=>o,column:()=>({type:"json"})}),u=T({name:"media",optionsSchema:i.extend({accept:e.string().optional()}),schema:()=>e.string().min(1),column:()=>({type:"text"}),aiActions:["alt"]}),d=T({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 V(n,t){return d({...t??{},relationTo:n})}var z=T({name:"email",optionsSchema:i,schema:()=>e.string().email(),column:()=>({type:"text"})}),c=T({name:"url",optionsSchema:i,schema:()=>e.string().url(),column:()=>({type:"text"})});function w(){return{seoTitle:l({label:"SEO title",localized:!0,maxLength:70,aiGenerate:{label:"Suggest an SEO title",prompt:"Write a search-friendly title under 60 characters."}}),seoDescription:r({label:"SEO description",localized:!0,maxLength:160,aiGenerate:{label:"Suggest an SEO description",prompt:"Summarise the article in one sentence under 155 characters."}}),ogImage:u({label:"Social image",accept:"image/*"}),canonical:c({label:"Canonical URL"})}}export{h as boolean,y as date,T as defineField,z as email,Jo as getFieldType,S as json,u as media,F as multiselect,O as number,ro as registerFieldType,No as registeredFieldTypes,V as relation,f as richText,b as select,w as seoFields,l as text,r as textarea,c 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;AAsBhD;;;;;;;;;;;;;;;;;;;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,CAsFvD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The HTTP layer.
|
|
3
|
+
*
|
|
4
|
+
* Nothing here knows how a document is stored, who may read it or what a
|
|
5
|
+
* hook does: every handler parses a URL, calls one method on the instance and
|
|
6
|
+
* serialises the answer. That is what keeps `cms.api.posts.find()` and
|
|
7
|
+
* `GET /api/heyo-cms/posts` the same operation rather than two implementations
|
|
8
|
+
* of the same intention (section 10).
|
|
9
|
+
*/
|
|
10
|
+
export { createCmsHttp, type CmsHttp } from "./handler";
|
|
11
|
+
export { buildOpenApi } from "./openapi";
|
|
12
|
+
export { Router, type RouteHandler, type RouteMatch, type RouteMiddleware, type RouteRecord, } from "./router";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,aAAa,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACL,MAAM,EACN,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,WAAW,GACjB,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CmsInstance } from "../types/instance";
|
|
2
|
+
import type { JsonObject } from "../types/json";
|
|
3
|
+
import type { RouteRecord } from "./router";
|
|
4
|
+
export declare function buildOpenApi(cms: CmsInstance, routes: RouteRecord[]): JsonObject;
|
|
5
|
+
//# sourceMappingURL=openapi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../src/http/openapi.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAgD5C,wBAAgB,YAAY,CAC1B,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,WAAW,EAAE,GACpB,UAAU,CAiEZ"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Actor } from "../types/actor";
|
|
2
|
+
import type { FindArgs, ReadArgs } from "../types/api";
|
|
3
|
+
import type { ResolvedCollection } from "../types/config";
|
|
4
|
+
import type { OrderBy, Where } from "../types/query";
|
|
5
|
+
export interface ReadQueryOptions {
|
|
6
|
+
actor: Actor | null;
|
|
7
|
+
/** `rest` for everything over HTTP; the panel is marked by a header. */
|
|
8
|
+
source: ReadArgs["source"];
|
|
9
|
+
}
|
|
10
|
+
/** Locale, depth and the trash flag: what every read takes. */
|
|
11
|
+
export declare function readArgs(query: URLSearchParams, options: ReadQueryOptions): ReadArgs;
|
|
12
|
+
/** The whole of `GET /posts`: filters, sort, paging. */
|
|
13
|
+
export declare function findArgs(query: URLSearchParams, collection: ResolvedCollection, options: ReadQueryOptions): FindArgs;
|
|
14
|
+
/**
|
|
15
|
+
* The filter, from either syntax.
|
|
16
|
+
*
|
|
17
|
+
* Both are resolved through the same path resolver, which is what makes a
|
|
18
|
+
* localized field filterable without the caller knowing it is stored as a map:
|
|
19
|
+
* `?title=Hello` with `?locale=de` becomes `data.title.de`, because that is
|
|
20
|
+
* where the German title lives (section 9).
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseWhere(query: URLSearchParams, collection: ResolvedCollection, locale: string | null): Where | undefined;
|
|
23
|
+
export declare function parseSort(raw: string | null, collection: ResolvedCollection, locale: string | null): OrderBy[] | undefined;
|
|
24
|
+
export declare function integer(raw: string | null, name: string, min: number, max: number): number | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* `?flag`, `?flag=true` and `?flag=1` all mean yes.
|
|
27
|
+
*
|
|
28
|
+
* A bare `?permanent` with no value is what somebody types, and reading it as
|
|
29
|
+
* "false" would make a destructive flag silently do nothing.
|
|
30
|
+
*/
|
|
31
|
+
export declare function boolean(raw: string | null, name: string): boolean | undefined;
|
|
32
|
+
//# sourceMappingURL=params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/http/params.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAA2B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAiF9E,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,wEAAwE;IACxE,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;CAC5B;AAED,+DAA+D;AAC/D,wBAAgB,QAAQ,CACtB,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,gBAAgB,GACxB,QAAQ,CAiBV;AAED,wDAAwD;AACxD,wBAAgB,QAAQ,CACtB,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,kBAAkB,EAC9B,OAAO,EAAE,gBAAgB,GACxB,QAAQ,CAkBV;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,kBAAkB,EAC9B,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,KAAK,GAAG,SAAS,CAiCnB;AA0ED,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,UAAU,EAAE,kBAAkB,EAC9B,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,OAAO,EAAE,GAAG,SAAS,CAevB;AA2HD,wBAAgB,OAAO,CACrB,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,MAAM,GAAG,SAAS,CAOpB;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAK7E"}
|