@dyrected/core 2.6.4 → 2.7.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.
@@ -0,0 +1,2100 @@
1
+ import { icons } from 'lucide-react';
2
+ import { LoggerOptions, DestinationStream, Logger } from 'pino';
3
+
4
+ /**
5
+ * Minimum HTTP request context passed to every server-side hook and resolver.
6
+ *
7
+ * The full Web Standard `Request` is available as `raw` when you need it, but
8
+ * most hooks only need `query` (URL search parameters).
9
+ */
10
+ interface HookRequestContext {
11
+ /** Parsed URL query-string parameters, e.g. `{ page: '2', search: 'hello' }`. */
12
+ query: Record<string, string>;
13
+ /** Incoming HTTP headers, lowercased. */
14
+ headers: Record<string, string>;
15
+ /** The raw Web Standard `Request` object. Useful for streaming or advanced header inspection. */
16
+ raw?: Request;
17
+ }
18
+ /**
19
+ * Base shape of an authenticated user as decoded from the JWT.
20
+ *
21
+ * The actual shape will include every field on your auth collection — this
22
+ * interface only guarantees the properties that Dyrected always stamps on the
23
+ * token. Extend it in your own codebase for stronger typing:
24
+ *
25
+ * @example
26
+ * declare module '@dyrected/core' {
27
+ * interface AuthenticatedUser {
28
+ * role: 'admin' | 'editor'
29
+ * organizationId: string
30
+ * }
31
+ * }
32
+ */
33
+ interface AuthenticatedUser {
34
+ /** The user's document ID in the database. */
35
+ sub: string;
36
+ /** The user's email address. */
37
+ email?: string;
38
+ /** Slug of the collection this user was authenticated against. */
39
+ collection: string;
40
+ /** Array of role strings, if your auth collection has a `roles` field. */
41
+ roles?: string[];
42
+ /** Any additional fields from the auth collection document. */
43
+ [key: string]: unknown;
44
+ }
45
+
46
+ interface AccessFunctionArgs<TDoc extends object = Record<string, unknown>, TUser extends AuthenticatedUser = AuthenticatedUser> {
47
+ user: TUser | undefined;
48
+ doc?: TDoc;
49
+ data?: Partial<TDoc>;
50
+ req: HookRequestContext;
51
+ }
52
+ interface NamedAccessPolicy<TDoc extends object = Record<string, unknown>> {
53
+ policy: string;
54
+ params?: Record<string, unknown>;
55
+ }
56
+ type AccessResult = boolean | Record<string, unknown>;
57
+ /**
58
+ * A function that determines whether the current user can perform an operation.
59
+ *
60
+ * Return `true` to allow, `false` to deny.
61
+ * Return a `where`-style object to allow access only to matching documents
62
+ * (useful for multi-tenant setups where users can only see their own data).
63
+ *
64
+ * Can also be expressed as a Jexl expression **string** for simple role checks
65
+ * that need to be serialised (e.g. stored in the database or sent to the Admin UI).
66
+ *
67
+ * @template TDoc The shape of the collection's document.
68
+ *
69
+ * @example
70
+ * // Simple role check
71
+ * access: {
72
+ * delete: ({ user }) => user?.roles?.includes('admin') ?? false,
73
+ * }
74
+ *
75
+ * @example
76
+ * // Row-level: users can only read their own documents
77
+ * access: {
78
+ * read: ({ user }) => ({ owner: { equals: user?.sub } }),
79
+ * }
80
+ *
81
+ * @example
82
+ * // Jexl string — evaluated server-side
83
+ * access: {
84
+ * update: "user.roles contains 'editor'",
85
+ * }
86
+ */
87
+ type AccessFunction<TDoc extends object = Record<string, unknown>, TUser extends AuthenticatedUser = AuthenticatedUser> = (args: AccessFunctionArgs<TDoc, TUser>) => AccessResult | Promise<AccessResult>;
88
+ type AccessRule<TDoc extends object = Record<string, unknown>, TUser extends AuthenticatedUser = AuthenticatedUser> = boolean | string | AccessFunction<TDoc, TUser> | NamedAccessPolicy<TDoc>;
89
+ type AccessPolicyResolver<TDoc extends object = Record<string, unknown>, TUser extends AuthenticatedUser = AuthenticatedUser> = (args: AccessFunctionArgs<TDoc, TUser> & {
90
+ params?: Record<string, unknown>;
91
+ }) => AccessResult | Promise<AccessResult>;
92
+
93
+ /**
94
+ * The minimum shape of every document returned by the database layer.
95
+ *
96
+ * All documents have an `id` field assigned by the adapter. Additional fields
97
+ * are stored as `unknown` until you narrow them with your own interface.
98
+ *
99
+ * Use this as the base when declaring your collection document types:
100
+ * ```ts
101
+ * interface Post extends BaseDocument {
102
+ * title: string
103
+ * slug: string
104
+ * }
105
+ * ```
106
+ */
107
+ interface BaseDocument {
108
+ /** The document's unique identifier, assigned by the database adapter. */
109
+ id: string;
110
+ [key: string]: any;
111
+ }
112
+ /**
113
+ * The envelope returned by collection list endpoints (`GET /api/collections/:slug`).
114
+ *
115
+ * @template T The document type.
116
+ */
117
+ interface PaginatedResult<T = Record<string, any>> {
118
+ /** The documents on the current page. */
119
+ docs: T[];
120
+ /** Total number of documents matching the query (across all pages). */
121
+ total: number;
122
+ /** Maximum number of documents per page as requested. */
123
+ limit: number;
124
+ /** The current page number (1-indexed). */
125
+ page: number;
126
+ /** Total number of pages given the current `limit`. */
127
+ totalPages: number;
128
+ /** Whether a next page exists. */
129
+ hasNextPage: boolean;
130
+ /** Whether a previous page exists. */
131
+ hasPrevPage: boolean;
132
+ }
133
+ /**
134
+ * Metadata returned after a file is uploaded and stored.
135
+ * Stored on the document in upload collections.
136
+ */
137
+ interface FileData {
138
+ filename: string;
139
+ filesize?: number;
140
+ mimeType: string;
141
+ /** Public URL of the stored file. */
142
+ url: string;
143
+ width?: number;
144
+ height?: number;
145
+ focalPoint?: {
146
+ x: number;
147
+ y: number;
148
+ };
149
+ /** Base64-encoded BlurHash string for progressive image loading. */
150
+ blurhash?: string;
151
+ /** `'upload'` for server-stored files; `'external'` for provider-managed files. */
152
+ type?: "upload" | "external";
153
+ provider?: string;
154
+ provider_metadata?: unknown;
155
+ [key: string]: unknown;
156
+ }
157
+
158
+ /** A valid icon component name from the Lucide icon set bundled with Dyrected Admin. */
159
+ type AdminIconName = keyof typeof icons;
160
+ /** Ordered custom component keys rendered around the built-in Admin dashboard. */
161
+ interface AdminDashboardComponentSlots {
162
+ beforeDashboard?: string[];
163
+ afterDashboard?: string[];
164
+ }
165
+ /** Ordered custom component keys rendered around a collection's list content. */
166
+ interface CollectionListComponentSlots {
167
+ beforeList?: string[];
168
+ beforeListTable?: string[];
169
+ afterListTable?: string[];
170
+ afterList?: string[];
171
+ }
172
+ /**
173
+ * Branding and metadata options for the Dyrected Admin UI.
174
+ *
175
+ * @example
176
+ * admin: {
177
+ * branding: {
178
+ * logo: '/logo.svg',
179
+ * primaryColor: '#6366f1',
180
+ * },
181
+ * meta: {
182
+ * titleSuffix: '- My App',
183
+ * },
184
+ * }
185
+ */
186
+ interface AdminConfig {
187
+ /** Custom component slots around the built-in dashboard. */
188
+ components?: AdminDashboardComponentSlots;
189
+ branding?: {
190
+ /** Full logo image shown in the expanded sidebar. URL or imported image asset. */
191
+ logo?: string;
192
+ /** Compact logo mark used in the collapsed sidebar state. */
193
+ logoMark?: string;
194
+ /** Text alternative or addition to the logo image. */
195
+ logoText?: string;
196
+ /**
197
+ * Brand colour used for committed, filled actions — Save, Create, Upload —
198
+ * and active/selected states. Accepts a hex string, a named colour
199
+ * (`amber`, `lime`, `violet`, `green`, `blue`, `red`, `purple`, `orange`),
200
+ * or a raw HSL triplet (`"217 91% 60%"`). Applied in both light and dark mode.
201
+ *
202
+ * This is one half of the two-colour brand model. Use {@link accentColor}
203
+ * for links and navigation accents. If you only set `primaryColor`, it is
204
+ * reused for accents too, matching the single-brand-colour look.
205
+ * @example '#6366f1'
206
+ * @example 'blue'
207
+ * @example 'hsl(240 50% 60%)'
208
+ */
209
+ primaryColor?: string;
210
+ /**
211
+ * Brand colour used for links, active navigation details, hover text, and
212
+ * focus rings — the "accent" half of the two-colour brand model, mapped to
213
+ * the admin's `--intelligence` token. Accepts the same formats as
214
+ * {@link primaryColor} and applies in both light and dark mode.
215
+ *
216
+ * Set this when your brand has a distinct link/accent colour separate from
217
+ * your primary action colour. When omitted, accents fall back to
218
+ * `primaryColor` (if set) or the built-in default.
219
+ * @example '#8b5cf6'
220
+ * @example 'violet'
221
+ */
222
+ accentColor?: string;
223
+ /** Browser tab favicon URL. */
224
+ favicon?: string;
225
+ /** Font family for body and UI text. Must be loaded separately. */
226
+ fontSans?: string;
227
+ /** Font family for headings. Must be loaded separately. */
228
+ fontSerif?: string;
229
+ };
230
+ meta?: {
231
+ /**
232
+ * String appended to every Admin page's `<title>`.
233
+ * @default '- Dyrected'
234
+ */
235
+ titleSuffix?: string;
236
+ };
237
+ /**
238
+ * The canonical/base URL of the frontend website for links and iframe live previews.
239
+ */
240
+ siteUrl?: string;
241
+ }
242
+
243
+ type DeclarativeHookExpression = string;
244
+ /**
245
+ * @deprecated Use {@link FieldBeforeChangeHook} or `FieldAfterReadHook` instead.
246
+ * This alias remains for backwards compatibility.
247
+ */
248
+ type FieldHook<TDoc extends object = Record<string, unknown>, TValue = unknown> = FieldBeforeChangeHook<TValue, TDoc>;
249
+ /**
250
+ * Runs before Dyrected queries the database for a list or single-document fetch.
251
+ *
252
+ * Return a new `where` query object to override or extend the current filter.
253
+ * Return `undefined` (or nothing) to leave the query unchanged.
254
+ */
255
+ type CollectionBeforeReadHook = (args: {
256
+ req: HookRequestContext;
257
+ query?: Record<string, unknown>;
258
+ user?: AuthenticatedUser;
259
+ db: ReadonlyDatabaseAdapter;
260
+ }) => Record<string, unknown> | void | Promise<Record<string, unknown> | void>;
261
+ type CollectionBeforeReadHookEntry = CollectionBeforeReadHook | DeclarativeHookExpression;
262
+ /**
263
+ * Runs after a document (or list of documents) is fetched from the database,
264
+ * before the response is sent to the client.
265
+ */
266
+ type CollectionAfterReadHook<TDoc extends object = Record<string, unknown>> = (args: {
267
+ doc: TDoc;
268
+ req: HookRequestContext;
269
+ user?: AuthenticatedUser;
270
+ db: ReadonlyDatabaseAdapter;
271
+ }) => TDoc | Promise<TDoc>;
272
+ type CollectionAfterReadHookEntry<TDoc extends object = Record<string, unknown>> = CollectionAfterReadHook<TDoc> | DeclarativeHookExpression;
273
+ /**
274
+ * Runs **before** a document is created or updated in the database.
275
+ */
276
+ type CollectionBeforeChangeHook<TDoc extends object = Record<string, unknown>> = (args: {
277
+ data: Partial<TDoc>;
278
+ doc?: TDoc;
279
+ req: HookRequestContext;
280
+ user?: AuthenticatedUser;
281
+ operation: "create" | "update";
282
+ db: ReadonlyDatabaseAdapter;
283
+ }) => Partial<TDoc> | void | Promise<Partial<TDoc> | void>;
284
+ type CollectionBeforeChangeHookEntry<TDoc extends object = Record<string, unknown>> = CollectionBeforeChangeHook<TDoc> | DeclarativeHookExpression;
285
+ /**
286
+ * Runs **after** a document is created or updated in the database.
287
+ */
288
+ type CollectionAfterChangeHook<TDoc extends object = Record<string, unknown>> = (args: {
289
+ doc: TDoc;
290
+ previousDoc?: TDoc;
291
+ req: HookRequestContext;
292
+ user?: AuthenticatedUser;
293
+ operation: "create" | "update";
294
+ db: DatabaseAdapter;
295
+ }) => void | Promise<void>;
296
+ /**
297
+ * Runs **before** a document is deleted from the database.
298
+ */
299
+ type CollectionBeforeDeleteHook<TDoc extends object = Record<string, unknown>> = (args: {
300
+ id: string;
301
+ doc: TDoc;
302
+ req: HookRequestContext;
303
+ user?: AuthenticatedUser;
304
+ db: ReadonlyDatabaseAdapter;
305
+ }) => void | Promise<void>;
306
+ /**
307
+ * Runs **after** a document has been deleted from the database.
308
+ */
309
+ type CollectionAfterDeleteHook<TDoc extends object = Record<string, unknown>> = (args: {
310
+ id: string;
311
+ doc: TDoc;
312
+ req: HookRequestContext;
313
+ user?: AuthenticatedUser;
314
+ db: DatabaseAdapter;
315
+ }) => void | Promise<void>;
316
+ /** @see {@link CollectionBeforeReadHook} */
317
+ type GlobalBeforeReadHook = CollectionBeforeReadHook;
318
+ type GlobalBeforeReadHookEntry = CollectionBeforeReadHookEntry;
319
+ /**
320
+ * Runs after the global document is fetched, before the response is sent.
321
+ */
322
+ type GlobalAfterReadHook<TDoc extends object = Record<string, unknown>> = (args: {
323
+ doc: TDoc;
324
+ req: HookRequestContext;
325
+ user?: AuthenticatedUser;
326
+ db: ReadonlyDatabaseAdapter;
327
+ }) => TDoc | Promise<TDoc>;
328
+ type GlobalAfterReadHookEntry<TDoc extends object = Record<string, unknown>> = GlobalAfterReadHook<TDoc> | DeclarativeHookExpression;
329
+ /**
330
+ * Runs before the global document is updated.
331
+ * Operation is always `'update'` (globals cannot be created or deleted).
332
+ */
333
+ type GlobalBeforeChangeHook<TDoc extends object = Record<string, unknown>> = (args: {
334
+ data: Partial<TDoc>;
335
+ doc?: TDoc;
336
+ req: HookRequestContext;
337
+ user?: AuthenticatedUser;
338
+ operation: "update";
339
+ db: ReadonlyDatabaseAdapter;
340
+ }) => Partial<TDoc> | void | Promise<Partial<TDoc> | void>;
341
+ type GlobalBeforeChangeHookEntry<TDoc extends object = Record<string, unknown>> = GlobalBeforeChangeHook<TDoc> | DeclarativeHookExpression;
342
+ /**
343
+ * Runs after the global document is updated. Side-effects only.
344
+ */
345
+ type GlobalAfterChangeHook<TDoc extends object = Record<string, unknown>> = (args: {
346
+ doc: TDoc;
347
+ previousDoc?: TDoc;
348
+ req: HookRequestContext;
349
+ user?: AuthenticatedUser;
350
+ operation: "update";
351
+ db: DatabaseAdapter;
352
+ }) => void | Promise<void>;
353
+ /**
354
+ * @deprecated Use the specific hook types instead:
355
+ * `CollectionBeforeChangeHook`, `CollectionAfterReadHook`, etc.
356
+ *
357
+ * This broad type remains for backwards compatibility with the internal hook runner.
358
+ */
359
+ type HookFunction<TDoc extends object = Record<string, unknown>> = (args: {
360
+ data?: Partial<TDoc>;
361
+ doc?: TDoc;
362
+ user?: AuthenticatedUser;
363
+ req?: HookRequestContext;
364
+ operation?: "create" | "update" | "delete";
365
+ db?: DatabaseAdapter;
366
+ [key: string]: unknown;
367
+ }) => unknown | Promise<unknown>;
368
+
369
+ declare const LIFECYCLE_EVENT_NAMES: readonly ["revision.created", "workflow.transitioned", "entry.published", "entry.unpublished"];
370
+ type LifecycleEventName = (typeof LIFECYCLE_EVENT_NAMES)[number];
371
+ interface WorkflowState {
372
+ /** Stable machine-readable state key. */
373
+ name: string;
374
+ /** Label rendered in the Admin UI. */
375
+ label: string;
376
+ /** Marks the state whose revision is visible to public readers. */
377
+ published?: boolean;
378
+ /** Optional visual tone used by the Admin UI. */
379
+ color?: "neutral" | "warning" | "success" | "danger" | "info";
380
+ }
381
+ interface WorkflowTransition {
382
+ /** Stable transition key used by the REST and SDK APIs. */
383
+ name: string;
384
+ label: string;
385
+ from: string | string[];
386
+ to: string;
387
+ /** Every listed capability is required. */
388
+ requiredCapabilities?: string[];
389
+ /** Require a non-empty comment when performing the transition. */
390
+ requireComment?: boolean;
391
+ /** Remove the public snapshot after this transition commits. */
392
+ unpublish?: boolean;
393
+ }
394
+ interface WorkflowRole {
395
+ /** Existing user role value, for example `editor` or `publisher`. */
396
+ role: string;
397
+ capabilities: string[];
398
+ }
399
+ /**
400
+ * Configuration for a collection's editorial workflow: the states a document
401
+ * can be in, the transitions between them, and the roles allowed to perform
402
+ * each. Attach it to a collection's `workflow`, or build one with
403
+ * `definePublishingWorkflow`.
404
+ */
405
+ interface WorkflowConfig<TDoc extends object = Record<string, unknown>> {
406
+ /** The state every new document starts in, e.g. `"draft"`. */
407
+ initialState: string;
408
+ /** State used for a new working revision created from published content. */
409
+ draftState?: string;
410
+ /** All states a document can occupy. Exactly one should be marked `published`. */
411
+ states: WorkflowState[];
412
+ /** The allowed moves between states, each with its own capability and comment rules. */
413
+ transitions: WorkflowTransition[];
414
+ /** Maps values in `user.roles` to workflow capabilities. */
415
+ roles?: WorkflowRole[];
416
+ /** Server-side hooks that run around every transition. */
417
+ hooks?: {
418
+ /** Runs before a transition commits — throw to validate or block the move. */
419
+ beforeTransition?: CollectionBeforeTransitionHook<TDoc>[];
420
+ /** Runs after a transition commits — trigger notifications or downstream work. */
421
+ afterTransition?: CollectionAfterTransitionHook<TDoc>[];
422
+ };
423
+ }
424
+ interface WorkflowMetadata {
425
+ /** The document's current workflow state, e.g. `"draft"` or `"published"`. */
426
+ state: string;
427
+ /** Revision counter, incremented on every committed transition. */
428
+ revision: number;
429
+ /** Revision number currently exposed as the public snapshot, once published. */
430
+ publishedRevision?: number;
431
+ /** ISO timestamp of the most recent publish. */
432
+ publishedAt?: string;
433
+ /** Id of the user who last published this document. */
434
+ publishedBy?: string;
435
+ /** Transitions currently allowed for the requesting user. Response-only. */
436
+ availableTransitions?: string[];
437
+ }
438
+ interface WorkflowTransitionContext<TDoc extends object = Record<string, unknown>> {
439
+ /** The transition being performed. */
440
+ transition: WorkflowTransition;
441
+ /** State the document is moving out of. */
442
+ from: string;
443
+ /** State the document is moving into. */
444
+ to: string;
445
+ /** The document as it stands before the transition commits. */
446
+ doc: TDoc;
447
+ /** The user performing the transition, when the request is authenticated. */
448
+ user?: AuthenticatedUser;
449
+ /** Comment supplied with the transition; required when `requireComment` is set. */
450
+ comment?: string;
451
+ /** Request context for the transition. */
452
+ req: HookRequestContext;
453
+ /** Transaction-scoped database adapter for reads and writes inside the hook. */
454
+ db: DatabaseAdapter;
455
+ }
456
+ type CollectionBeforeTransitionHook<TDoc extends object = Record<string, unknown>> = (args: WorkflowTransitionContext<TDoc>) => void | Promise<void>;
457
+ type CollectionAfterTransitionHook<TDoc extends object = Record<string, unknown>> = (args: WorkflowTransitionContext<TDoc> & {
458
+ event: LifecycleEvent;
459
+ }) => void | Promise<void>;
460
+ interface LifecycleEvent<TPayload = Record<string, unknown>> {
461
+ /** Unique id for this event. */
462
+ id: string;
463
+ /** The lifecycle event name, e.g. `"workflow.transitioned"` or `"entry.published"`. */
464
+ name: LifecycleEventName;
465
+ /** Slug of the collection the event is about. */
466
+ collection: string;
467
+ /** Id of the document the event is about. */
468
+ documentId: string;
469
+ /** ISO timestamp of when the event occurred. */
470
+ occurredAt: string;
471
+ /** Id of the user who triggered the event, when known. */
472
+ actorId?: string;
473
+ /** Event-specific data, such as the transition name and affected revision. */
474
+ payload: TPayload;
475
+ /** Number of delivery attempts made so far. */
476
+ attempts: number;
477
+ /** Current delivery status as the dispatcher works through the queue. */
478
+ status: "pending" | "processing" | "delivered" | "failed";
479
+ /** ISO timestamp of the next delivery retry, while pending. */
480
+ nextAttemptAt?: string;
481
+ /** ISO timestamp of successful delivery. */
482
+ deliveredAt?: string;
483
+ /** Message from the most recent failed delivery attempt. */
484
+ lastError?: string;
485
+ }
486
+ type LifecycleEventHandler = (event: LifecycleEvent) => void | Promise<void>;
487
+
488
+ /**
489
+ * Configures account lockout behavior for an auth-enabled collection.
490
+ *
491
+ * This protects collection login endpoints from repeated password guessing by
492
+ * temporarily locking an account after too many failed attempts.
493
+ */
494
+ interface AuthConfig {
495
+ /**
496
+ * How many failed login attempts are allowed before the account is locked.
497
+ *
498
+ * Defaults to `5`. Set to `0` to disable Dyrected's built-in account lockout
499
+ * for this collection.
500
+ */
501
+ maxLoginAttempts?: number;
502
+ /**
503
+ * How long, in milliseconds, an account stays locked after reaching the
504
+ * failed-attempt limit.
505
+ *
506
+ * Defaults to `10 * 60 * 1000` (10 minutes).
507
+ */
508
+ lockTime?: number;
509
+ }
510
+ /**
511
+ * Use this contract when you want the exact shape of a collection config.
512
+ *
513
+ * Most collection work comes down to a small set of top-level options: giving
514
+ * the collection a stable slug, defining its fields, deciding how it should
515
+ * appear in the Admin UI, and choosing whether it also handles access, hooks,
516
+ * auth, uploads, workflows, or other optional behavior.
517
+ *
518
+ * Pass your document's TypeScript type as the generic parameter `TDoc` to get
519
+ * fully typed hooks and access functions.
520
+ *
521
+ * @example
522
+ * ```ts
523
+ * interface Post {
524
+ * id: string
525
+ * title: string
526
+ * slug: string
527
+ * status: 'draft' | 'published'
528
+ * publishedAt?: string
529
+ * }
530
+ *
531
+ * export const Posts = defineCollection<Post>({
532
+ * slug: 'posts',
533
+ * hooks: {
534
+ * beforeChange: [({ data, operation }) => {
535
+ * // `data` is typed as Partial<Post>
536
+ * if (operation === 'create') return { ...data, status: 'draft' }
537
+ * return data
538
+ * }],
539
+ * afterChange: [({ doc, previousDoc }) => {
540
+ * // `doc` and `previousDoc` are typed as Post
541
+ * if (doc.status !== previousDoc?.status) notifySubscribers(doc)
542
+ * }],
543
+ * },
544
+ * fields: [...],
545
+ * })
546
+ * ```
547
+ *
548
+ * @see {@link https://dyrected.com/docs/basics/configuration/collections Collections documentation}
549
+ * @template TDoc The TypeScript shape of a document in this collection.
550
+ * Defaults to `Record<string, unknown>` for untyped usage.
551
+ */
552
+ interface CollectionConfig<TDoc extends object = Record<string, unknown>> {
553
+ /**
554
+ * Unique identifier for this collection.
555
+ *
556
+ * Dyrected uses the slug for API routes, SDK calls, Admin URLs, and as the
557
+ * underlying database table or collection name. Treat it as part of the
558
+ * long-term data contract rather than a cosmetic label.
559
+ *
560
+ * Use kebab-case, for example `'blog-posts'`, `'team-members'`, or
561
+ * `'contact-submissions'`.
562
+ */
563
+ slug: string;
564
+ /**
565
+ * Restricts this collection to one specific site in a multi-tenant setup.
566
+ *
567
+ * Use this when the collection should belong to a single site rather than
568
+ * the whole installation. When set, only requests bearing a matching
569
+ * `X-Site-Id` header can access it.
570
+ */
571
+ siteId?: string;
572
+ /**
573
+ * If `true`, this collection is shared across all sites in a multi-tenant
574
+ * setup and accessible regardless of the `X-Site-Id` header.
575
+ *
576
+ * Use this for content that should stay common across sites, such as shared
577
+ * taxonomies, reusable assets, or centrally managed reference data.
578
+ */
579
+ shared?: boolean;
580
+ /**
581
+ * Human-readable names for documents in this collection, shown in the Admin UI.
582
+ *
583
+ * Use this when the slug is technical or when you want the dashboard to read
584
+ * more naturally. For example, `slug: 'people'` might use
585
+ * `labels: { singular: 'Person', plural: 'People' }`.
586
+ *
587
+ * @see {@link https://dyrected.com/docs/basics/configuration/collections#labels Collections labels}
588
+ */
589
+ labels?: {
590
+ singular: string;
591
+ plural: string;
592
+ };
593
+ /**
594
+ * If `true` or an auth config object, this collection is an auth collection. It gains
595
+ * `POST /api/collections/:slug/login` and `POST /api/collections/:slug/logout`
596
+ * endpoints, and documents are expected to have a `password` field.
597
+ *
598
+ * Turn this on when each document should behave like an account that can log
599
+ * in, hold credentials, and participate in user flows. Typical examples are
600
+ * `users`, `admins`, `members`, or `customers`.
601
+ *
602
+ * Pass an object when you want to tune built-in account lockout behavior for
603
+ * repeated failed logins.
604
+ *
605
+ * @see {@link https://dyrected.com/docs/features/authentication/overview Authentication overview}
606
+ */
607
+ auth?: boolean | AuthConfig;
608
+ /**
609
+ * If `true` or a config object, this collection supports file uploads.
610
+ * Documents gain file-related fields (`url`, `filename`, `mimeType`, etc.)
611
+ * and the create endpoint accepts `multipart/form-data`.
612
+ *
613
+ * Turn this on when each document in the collection should represent a
614
+ * stored file, such as an image, PDF, video, or downloadable asset.
615
+ *
616
+ * @see {@link https://dyrected.com/docs/features/upload/overview Upload overview}
617
+ */
618
+ upload?: boolean | UploadConfig;
619
+ /**
620
+ * Field definitions that make up the document schema for this collection.
621
+ *
622
+ * This is the main schema contract for every document in the collection. It
623
+ * decides what editors can fill in, how data is validated, how records are
624
+ * stored, and what the API and SDK return.
625
+ *
626
+ * In practice, fields are where you model the actual content structure of the
627
+ * collection: simple values such as text and dates, relationships to other
628
+ * collections, nested objects and arrays, and flexible `blocks` fields for
629
+ * reusable page sections or long-form layouts.
630
+ *
631
+ * @see {@link https://dyrected.com/docs/basics/fields/overview Fields overview}
632
+ * @see {@link https://dyrected.com/docs/basics/fields/blocks Blocks and page sections}
633
+ */
634
+ fields: Field[];
635
+ /**
636
+ * If `true`, Dyrected automatically adds the built-in system fields
637
+ * `createdAt`, `updatedAt`, `createdBy`, and `updatedBy` to every document.
638
+ * Defaults to `true`.
639
+ */
640
+ timestamps?: boolean;
641
+ /**
642
+ * Initial documents to seed into this collection the first time it is
643
+ * fetched and found to be empty.
644
+ *
645
+ * Use this for starter records, demo content, or sensible defaults that
646
+ * should appear automatically before editors create anything themselves.
647
+ */
648
+ initialData?: Partial<TDoc>[];
649
+ /**
650
+ * If `true`, every create, update, and delete operation on this collection
651
+ * is logged to the `__audit` collection with before/after snapshots and the
652
+ * acting user's identity.
653
+ *
654
+ * Turn this on when you need accountability around changes, such as knowing
655
+ * who changed what, inspecting before-and-after state, or supporting
656
+ * compliance and operational review.
657
+ */
658
+ audit?: boolean;
659
+ /**
660
+ * Optional state-machine workflow for this collection. Workflow-enabled
661
+ * entries keep an editable working revision and an independent public
662
+ * snapshot, so editing published content never changes the live response.
663
+ *
664
+ * Use this when content moves through stages such as draft, review, and
665
+ * published, or when teams need an approval process before changes go live.
666
+ */
667
+ workflow?: WorkflowConfig<TDoc>;
668
+ /**
669
+ * If `true`, enables zero-config draft and publish functionality.
670
+ * Documents start as drafts, editors can save working drafts without affecting
671
+ * live content, and any authorized editor can publish or unpublish entries.
672
+ */
673
+ drafts?: boolean;
674
+ /**
675
+ * Collection-level access control.
676
+ *
677
+ * Each key is an operation; the value can be a function, a Jexl string, a
678
+ * boolean, or a named policy reference. Returning `true` allows access and
679
+ * `false` denies it. Returning a `where`-style object grants access only to
680
+ * matching documents.
681
+ *
682
+ * @example
683
+ * access: {
684
+ * read: () => true,
685
+ * create: ({ user }) => !!user,
686
+ * update: ({ user }) => user?.roles?.includes('editor') ?? false,
687
+ * delete: ({ user }) => user?.roles?.includes('admin') ?? false,
688
+ * }
689
+ *
690
+ * @see {@link https://dyrected.com/docs/basics/access-control/overview Access control overview}
691
+ */
692
+ access?: {
693
+ read?: AccessRule<TDoc>;
694
+ create?: AccessRule<TDoc>;
695
+ update?: AccessRule<TDoc>;
696
+ delete?: AccessRule<TDoc>;
697
+ /**
698
+ * Controls who can read this collection's audit log (`GET /:slug/__audit`),
699
+ * for collections with `audit` enabled. Falls back to the `read` rule when
700
+ * omitted, so the audit trail is visible to whoever can read the documents.
701
+ * Set it explicitly to gate the audit log separately — for example, admins
702
+ * only, even on a collection anyone can read.
703
+ */
704
+ readAudit?: AccessRule<TDoc>;
705
+ };
706
+ /**
707
+ * Collection-level lifecycle hooks.
708
+ *
709
+ * Hooks run in the order they appear in the array. The return value of each
710
+ * hook is passed as the input to the next. Throwing inside any hook aborts
711
+ * the operation and returns a `500` error.
712
+ *
713
+ * See the Hooks reference for the full lifecycle diagram.
714
+ *
715
+ * @see {@link https://dyrected.com/docs/basics/hooks/overview Hooks overview}
716
+ * @see {@link https://dyrected.com/docs/basics/hooks/collections Collection hooks}
717
+ */
718
+ hooks?: {
719
+ /**
720
+ * Runs before the database is queried. Return a modified `where` object
721
+ * to override the query filter.
722
+ */
723
+ beforeRead?: CollectionBeforeReadHookEntry[];
724
+ /**
725
+ * Runs after documents are fetched. Return a modified doc to change what
726
+ * the client receives. Runs on every document in a list response.
727
+ */
728
+ afterRead?: CollectionAfterReadHookEntry<TDoc>[];
729
+ /**
730
+ * Runs before create or update. Return modified data to change what is
731
+ * written to the database. Throw to abort the write entirely.
732
+ */
733
+ beforeChange?: CollectionBeforeChangeHookEntry<TDoc>[];
734
+ /**
735
+ * Runs after create or update is committed. For side-effects only:
736
+ * webhooks, cache busting, and notifications. Return value is ignored.
737
+ *
738
+ * Errors are isolated: caught, logged, and discarded so a failing
739
+ * side-effect never turns a successful write into an HTTP 500.
740
+ * See `CollectionAfterChangeHook` for await-vs-fire-and-forget guidance.
741
+ */
742
+ afterChange?: CollectionAfterChangeHook<TDoc>[];
743
+ /** Runs before a document is deleted. Throw to cancel the deletion. */
744
+ beforeDelete?: CollectionBeforeDeleteHook<TDoc>[];
745
+ /**
746
+ * Runs after a document has been deleted. For cleanup side-effects only.
747
+ *
748
+ * Errors are isolated: caught, logged, and discarded. The deletion is
749
+ * already committed and will not be undone.
750
+ */
751
+ afterDelete?: CollectionAfterDeleteHook<TDoc>[];
752
+ };
753
+ /**
754
+ * Admin UI configuration for this collection.
755
+ *
756
+ * @see {@link https://dyrected.com/docs/basics/configuration/collections#admin-options Admin options}
757
+ */
758
+ admin?: {
759
+ /**
760
+ * Lucide icon displayed beside this collection in the Admin sidebar.
761
+ * Uses Lucide component names, e.g. `'Newspaper'` or `'ShoppingBag'`.
762
+ */
763
+ icon?: AdminIconName;
764
+ /** Custom component slots for this collection's list view. */
765
+ components?: CollectionListComponentSlots;
766
+ /**
767
+ * The field name used as the document's display title in the Admin list
768
+ * view and breadcrumbs. Defaults to `'title'` if the field exists.
769
+ */
770
+ useAsTitle?: string;
771
+ /**
772
+ * Field names to show as columns in the Admin list view.
773
+ * Defaults to a sensible set of the first few non-structural fields.
774
+ */
775
+ defaultColumns?: string[];
776
+ /** Short helper copy rendered under the collection title in the Admin list view. */
777
+ description?: string;
778
+ /**
779
+ * Field names included in backend free-text search for this collection.
780
+ * When omitted, Dyrected infers a conservative default from common text-like fields.
781
+ */
782
+ searchableFields?: string[];
783
+ /**
784
+ * Groups this collection under a named section in the Admin sidebar.
785
+ * Collections with the same `group` are visually grouped together.
786
+ */
787
+ group?: string;
788
+ /** If `true`, this collection is not shown in the Admin UI sidebar. */
789
+ hidden?: boolean;
790
+ /** If `false`, disables the filter UI entirely for this collection. Defaults to `true`. */
791
+ filterable?: boolean;
792
+ /**
793
+ * Enables draft autosave in the Admin editor for workflow-enabled
794
+ * collections. Defaults to `true` when the collection uses `workflow` or
795
+ * `drafts: true`.
796
+ */
797
+ autosave?: boolean;
798
+ /**
799
+ * Debounce duration in milliseconds for Admin draft autosave.
800
+ * Defaults to `1500`.
801
+ */
802
+ autosaveDelayMs?: number;
803
+ /**
804
+ * URL to open in the Live Preview pane when editing a document.
805
+ *
806
+ * Pass a Jexl string to keep the config serializable, for example
807
+ * `'slug == "home" ? "/" : "/" + slug'`. This is usually the best
808
+ * default, especially when the schema needs to stay portable across
809
+ * environments such as Dyrected Cloud.
810
+ *
811
+ * Pass a function when you need custom runtime logic in a self-hosted
812
+ * project.
813
+ *
814
+ * @example
815
+ * previewUrl: 'slug == "home" ? "/" : "/" + slug'
816
+ *
817
+ * @example
818
+ * previewUrl: (doc) => `/blog/${doc.slug}`
819
+ */
820
+ previewUrl?: string | ((doc: TDoc, opts: {
821
+ locale?: string;
822
+ }) => string | null);
823
+ /**
824
+ * How the Live Preview pane communicates with the frontend.
825
+ * - `postMessage` sends a `postMessage` with the current doc data.
826
+ * - `token` passes a short-lived preview token as a query parameter.
827
+ */
828
+ previewMode?: "postMessage" | "token";
829
+ /**
830
+ * Frontend URL pattern for this collection, used by `url` fields to
831
+ * resolve internal links. Use `{fieldName}` placeholders.
832
+ *
833
+ * This is a plain route pattern string, not a Jexl expression.
834
+ *
835
+ * @example
836
+ * urlPattern: '/blog/{slug}' // /blog/my-post
837
+ * urlPattern: '/{slug}' // /about
838
+ */
839
+ urlPattern?: string;
840
+ };
841
+ }
842
+ /**
843
+ * Defines a Dyrected global — a singleton document without pagination or IDs.
844
+ *
845
+ * Globals are ideal for site-wide settings, feature flags, or any data where
846
+ * there is always exactly one record, such as `site-settings`, `navigation`,
847
+ * or `theme`.
848
+ *
849
+ * Pass your document's TypeScript type as the generic parameter `TDoc` to get
850
+ * fully typed hooks.
851
+ *
852
+ * @example
853
+ * ```ts
854
+ * interface SiteSettings {
855
+ * siteName: string
856
+ * tagline: string
857
+ * maintenanceMode: boolean
858
+ * }
859
+ *
860
+ * export const Settings = defineGlobal<SiteSettings>({
861
+ * slug: 'site-settings',
862
+ * hooks: {
863
+ * afterChange: [({ doc }) => {
864
+ * // `doc` is typed as SiteSettings
865
+ * if (doc.maintenanceMode) alertOnCall()
866
+ * }],
867
+ * },
868
+ * fields: [...],
869
+ * })
870
+ * ```
871
+ *
872
+ * @template TDoc The TypeScript shape of this global's document.
873
+ */
874
+ interface GlobalConfig<TDoc extends object = Record<string, unknown>> {
875
+ /**
876
+ * Unique identifier for this global.
877
+ * Used as the URL segment (`/api/globals/:slug`) and the storage key.
878
+ */
879
+ slug: string;
880
+ /** Restricts this global to a specific site in a multi-tenant deployment. */
881
+ siteId?: string;
882
+ /**
883
+ * If `true`, this global is shared across all sites in a multi-tenant
884
+ * deployment.
885
+ */
886
+ shared?: boolean;
887
+ /** Human-readable label shown in the Admin UI sidebar. */
888
+ label?: string;
889
+ /** Field definitions for this global's document schema. */
890
+ fields: Field[];
891
+ /** Access control for reading and updating this global. */
892
+ access?: {
893
+ read?: AccessRule<TDoc>;
894
+ update?: AccessRule<TDoc>;
895
+ };
896
+ /**
897
+ * Global-level lifecycle hooks.
898
+ * Globals support `beforeRead`, `afterRead`, `beforeChange`, and `afterChange`.
899
+ * There are no delete hooks since globals cannot be deleted.
900
+ */
901
+ hooks?: {
902
+ beforeRead?: GlobalBeforeReadHookEntry[];
903
+ afterRead?: GlobalAfterReadHookEntry<TDoc>[];
904
+ beforeChange?: GlobalBeforeChangeHookEntry<TDoc>[];
905
+ afterChange?: GlobalAfterChangeHook<TDoc>[];
906
+ };
907
+ /** Admin UI configuration for this global. */
908
+ admin?: {
909
+ /**
910
+ * Lucide icon displayed beside this global in the Admin sidebar.
911
+ * Uses Lucide component names, e.g. `'Settings2'` or `'Palette'`.
912
+ */
913
+ icon?: AdminIconName;
914
+ /** Groups this global under a named section in the Admin sidebar. */
915
+ group?: string;
916
+ /** If `true`, this global is not shown in the Admin UI sidebar. */
917
+ hidden?: boolean;
918
+ };
919
+ /**
920
+ * Initial data to seed this global with the first time it is fetched and
921
+ * found to be empty.
922
+ */
923
+ initialData?: Partial<TDoc>;
924
+ }
925
+
926
+ /**
927
+ * The interface every database adapter must implement.
928
+ *
929
+ * Dyrected ships adapters for PostgreSQL, MySQL, SQLite, and MongoDB.
930
+ * Implement this interface to connect any other database.
931
+ */
932
+ interface DatabaseAdapter {
933
+ /** Find a paginated list of documents in a collection. */
934
+ find(args: {
935
+ collection: string;
936
+ where?: Record<string, unknown>;
937
+ limit?: number;
938
+ page?: number;
939
+ sort?: string;
940
+ /**
941
+ * The collection's field definitions. Optional, so simple adapters can
942
+ * ignore it; SQL adapters use it to sort numeric fields by magnitude.
943
+ */
944
+ fields?: Field[];
945
+ }): Promise<PaginatedResult>;
946
+ /** Find a single document by its ID. Returns `null` if not found. */
947
+ findOne(args: {
948
+ collection: string;
949
+ id: string;
950
+ }): Promise<BaseDocument | null>;
951
+ /** Insert a new document and return it with its generated `id`. */
952
+ create(args: {
953
+ collection: string;
954
+ data: Record<string, unknown>;
955
+ }): Promise<BaseDocument>;
956
+ /** Update a document by ID and return the updated document. */
957
+ update(args: {
958
+ collection: string;
959
+ id: string;
960
+ data: Record<string, unknown>;
961
+ }): Promise<BaseDocument>;
962
+ /** Delete a document by ID. Return value is intentionally untyped — callers do not use it. */
963
+ delete(args: {
964
+ collection: string;
965
+ id: string;
966
+ }): Promise<unknown>;
967
+ /** Fetch the singleton document for a global. Returns an empty object if not yet initialised. */
968
+ getGlobal(args: {
969
+ slug: string;
970
+ }): Promise<Record<string, unknown>>;
971
+ /** Create or replace the singleton document for a global. */
972
+ updateGlobal(args: {
973
+ slug: string;
974
+ data: Record<string, unknown>;
975
+ }): Promise<Record<string, unknown>>;
976
+ /**
977
+ * Sync the database schema with the current collection and global configs.
978
+ * Called on startup to create tables/collections that don't exist yet.
979
+ * Not all adapters implement this (e.g. MongoDB is schema-less).
980
+ */
981
+ sync?(collections: CollectionConfig[], globals: GlobalConfig[]): Promise<void>;
982
+ /**
983
+ * Execute a raw SQL query or database command.
984
+ * Optional — not all adapters support raw access.
985
+ */
986
+ execute?(query: string, params?: unknown[]): Promise<unknown>;
987
+ /**
988
+ * Run all adapter operations in `callback` as one atomic transaction.
989
+ * Shipped adapters implement this; workflow transitions require it.
990
+ */
991
+ transaction?<T>(callback: (db: DatabaseAdapter) => Promise<T>): Promise<T>;
992
+ }
993
+ /**
994
+ * Read-only view of the database adapter. Exposes only `find`, `findOne`,
995
+ * and `getGlobal` — no write operations.
996
+ *
997
+ * Passed to `beforeChange`, `beforeDelete`, `beforeRead`, `afterRead`,
998
+ * and field-level hooks. Write operations are available in `afterChange`
999
+ * and `afterDelete` hooks where the full {@link DatabaseAdapter} is provided.
1000
+ */
1001
+ type ReadonlyDatabaseAdapter = Pick<DatabaseAdapter, "find" | "findOne" | "getGlobal">;
1002
+ /**
1003
+ * The interface every storage adapter must implement.
1004
+ *
1005
+ * Dyrected ships adapters for local disk, AWS S3 and other S3-compatible
1006
+ * services through the S3 adapter, Cloudinary, and Backblaze B2. Implement
1007
+ * this interface to use any other storage provider.
1008
+ */
1009
+ interface StorageAdapter {
1010
+ /**
1011
+ * Upload a file and return its metadata (URL, dimensions, etc.).
1012
+ * The `prefix` is a path prefix used for multi-tenant setups.
1013
+ */
1014
+ upload(args: {
1015
+ filename: string;
1016
+ buffer: Uint8Array;
1017
+ mimeType: string;
1018
+ prefix?: string;
1019
+ }): Promise<FileData>;
1020
+ /** Delete a file by its stored filename. */
1021
+ delete(args: {
1022
+ filename: string;
1023
+ }): Promise<void>;
1024
+ /** Return the public URL for a stored file. */
1025
+ getURL(args: {
1026
+ filename: string;
1027
+ }): string;
1028
+ /**
1029
+ * Retrieve the file's raw bytes and MIME type for serving via the API.
1030
+ * Only needed by adapters that serve files through the Dyrected API
1031
+ * (e.g. `LocalStorage`). Cloud adapters return `null` here and rely on
1032
+ * direct CDN URLs instead.
1033
+ */
1034
+ resolve?(args: {
1035
+ filename: string;
1036
+ }): Promise<{
1037
+ buffer: Uint8Array;
1038
+ mimeType: string;
1039
+ } | null>;
1040
+ }
1041
+ /**
1042
+ * Processes uploaded images — generates metadata (dimensions, BlurHash) and
1043
+ * produces resized variants defined in `UploadConfig.imageSizes`.
1044
+ *
1045
+ * @example
1046
+ * import { SharpImageService } from '@dyrected/image-sharp'
1047
+ * defineConfig({ image: new SharpImageService(), ... })
1048
+ */
1049
+ interface ImageService {
1050
+ process(args: {
1051
+ buffer: Uint8Array;
1052
+ mimeType: string;
1053
+ config?: boolean | UploadConfig;
1054
+ focalPoint?: {
1055
+ x: number;
1056
+ y: number;
1057
+ };
1058
+ }): Promise<{
1059
+ metadata: {
1060
+ width?: number;
1061
+ height?: number;
1062
+ /** Base64-encoded BlurHash for progressive loading. */
1063
+ blurhash?: string;
1064
+ };
1065
+ /** Generated image sizes keyed by their `name`. */
1066
+ sizes?: Record<string, {
1067
+ buffer: Uint8Array;
1068
+ width: number;
1069
+ height: number;
1070
+ filename: string;
1071
+ }>;
1072
+ }>;
1073
+ }
1074
+
1075
+ type FieldType = "text" | "textarea" | "richText" | "number" | "boolean" | "date" | "datetime" | "time" | "select" | "multiSelect" | "radio" | "relationship" | "array" | "object" | "json" | "blocks" | "image" | "email" | "url" | "icon" | "join" | "row";
1076
+ interface DynamicOptionsResolverArgs {
1077
+ /** Database adapter available to server-side option resolvers. */
1078
+ db?: DatabaseAdapter;
1079
+ /** Authenticated user making the request, if any. */
1080
+ user?: AuthenticatedUser;
1081
+ /** Current HTTP request context, including query parameters. */
1082
+ req: HookRequestContext;
1083
+ }
1084
+ type DynamicOptionsResolver = (args: DynamicOptionsResolverArgs) => Promise<DynamicOptionItem[]> | DynamicOptionItem[];
1085
+ interface DynamicOptionsConfig {
1086
+ /** Resolver function executed on the server to produce option items. */
1087
+ resolve: DynamicOptionsResolver;
1088
+ /** Cache duration in seconds for identical resolver calls. */
1089
+ cacheTTL?: number;
1090
+ }
1091
+ type DynamicOptionItem = string | {
1092
+ label: string;
1093
+ value: unknown;
1094
+ };
1095
+ interface Block {
1096
+ /** Stable identifier stored in each block row as `blockType`. */
1097
+ slug: string;
1098
+ /** Human-readable labels shown in the Admin block picker. */
1099
+ labels?: {
1100
+ /** Singular label, for example `Hero`. */
1101
+ singular: string;
1102
+ /** Plural label, for example `Heroes`. */
1103
+ plural: string;
1104
+ };
1105
+ /**
1106
+ * Lucide icon name shown on the block card and in the block library.
1107
+ * Falls back to a generic layout icon when omitted.
1108
+ */
1109
+ icon?: AdminIconName;
1110
+ /** Short one-line summary shown under the block name (block card subtitle). */
1111
+ description?: string;
1112
+ /**
1113
+ * Presentation variants for this block. All variants share the same `fields`;
1114
+ * only the rendered layout differs. The chosen variant is stored on each block
1115
+ * row under the reserved `variant` key and passed to the render component as a
1116
+ * `variant` prop. Switching variant preserves the author's content.
1117
+ */
1118
+ variants?: BlockVariant[];
1119
+ /** Fields that make up this block's payload. */
1120
+ fields: Field[];
1121
+ }
1122
+ /**
1123
+ * A single presentation variant of a {@link Block}. Variants are a layout choice
1124
+ * over a shared field set — for example a Hero rendered "centered" vs "split".
1125
+ */
1126
+ interface BlockVariant {
1127
+ /** Stable identifier stored on the block row as `variant`. */
1128
+ slug: string;
1129
+ /** Human-readable label shown in the variant switcher. Defaults to `slug`. */
1130
+ label?: string;
1131
+ /** Lucide icon name shown beside the variant label. */
1132
+ icon?: AdminIconName;
1133
+ /** Short one-line summary of what this variant looks like. */
1134
+ description?: string;
1135
+ }
1136
+ interface FieldBase {
1137
+ /** Stored key for this field. Omit only for layout-only fields such as `row` or `join`. */
1138
+ name?: string;
1139
+ /** Human-readable label shown in the Admin UI. */
1140
+ label?: string;
1141
+ /** Whether the field must have a value when saving. */
1142
+ required?: boolean;
1143
+ /** Whether values for this field must be unique across the collection. */
1144
+ unique?: boolean;
1145
+ /** Default value used when a new document omits this field. */
1146
+ defaultValue?: unknown;
1147
+ /** Static or dynamic option source for supported selection fields. */
1148
+ options?: string[] | {
1149
+ label: string;
1150
+ value: unknown;
1151
+ }[] | DynamicOptionsResolver | DynamicOptionsConfig;
1152
+ /** Target collection slug for `relationship` fields. */
1153
+ relationTo?: string;
1154
+ /** Whether the field stores multiple values instead of one. */
1155
+ hasMany?: boolean;
1156
+ /** Child fields for `object` and `array` field types. */
1157
+ fields?: Field[];
1158
+ /** Allowed block definitions for a `blocks` field. */
1159
+ blocks?: Block[];
1160
+ /**
1161
+ * Shared block slugs pulled from the root `defineConfig({ blocks: [...] })`
1162
+ * registry for a `blocks` field.
1163
+ *
1164
+ * Use this when the same block types should be reused across multiple fields
1165
+ * without inlining the full block schema into each field definition.
1166
+ */
1167
+ blockReferences?: string[];
1168
+ /** Target collection slug for `join` fields. */
1169
+ collection?: string;
1170
+ /** Back-reference field name on the joined collection. */
1171
+ on?: string;
1172
+ /** Maximum number of joined documents returned by a `join` field. */
1173
+ limit?: number;
1174
+ /** Field-level read, create, and update access rules. Supports functions, Jexl strings, booleans, and named policies. */
1175
+ access?: {
1176
+ /** Controls whether this field is returned in API responses. */
1177
+ read?: AccessRule;
1178
+ /** Controls whether this field may be set when creating a document. Falls back to `update` when omitted. */
1179
+ create?: AccessRule;
1180
+ /** Controls whether incoming writes may change this field on update. */
1181
+ update?: AccessRule;
1182
+ };
1183
+ /** Admin-only presentation options for this field. */
1184
+ admin?: BaseFieldAdmin;
1185
+ /** Previous storage key this field falls back to. When the field has no value, its value is read from the old key at read time, then rewritten under the new key on the next save. */
1186
+ renameTo?: string;
1187
+ /** Whether SQL adapters should promote this field into a first-class column. */
1188
+ promoted?: boolean;
1189
+ }
1190
+ interface BaseFieldAdmin {
1191
+ /** Placeholder text shown when the input has no value. */
1192
+ placeholder?: string;
1193
+ /** For nested object-like fields, choose which child field should summarize the value in admin surfaces. */
1194
+ useAsTitle?: string;
1195
+ /** Custom component key registered in the Admin UI. */
1196
+ component?: string;
1197
+ /** Help text rendered below the field. */
1198
+ description?: string;
1199
+ /** Hides the field from the Admin form without deleting stored data. */
1200
+ hidden?: boolean;
1201
+ /** Excludes the field from Admin list filtering. */
1202
+ filterable?: boolean;
1203
+ /** Renders the field as non-editable in the Admin UI. */
1204
+ readOnly?: boolean;
1205
+ /** Hides the field's label in the Admin form (e.g. single-field array rows where the label is redundant). */
1206
+ hideLabel?: boolean;
1207
+ /** Reactive condition controlling whether the field is visible in the Admin UI. */
1208
+ condition?: ((data: Record<string, unknown>, siblingData: Record<string, unknown>) => boolean) | string;
1209
+ /** Tab name used when the edit form is rendered as tabs. */
1210
+ tab?: string;
1211
+ /** CSS width hint used when the field appears inside a `row`. */
1212
+ width?: string;
1213
+ }
1214
+ interface FieldBeforeChangeHookArgs<TValue = unknown, TDoc extends object = Record<string, unknown>> {
1215
+ /** Current field value after previous hooks in the chain. */
1216
+ value: TValue;
1217
+ /** Existing stored document before the write, if this is an update. */
1218
+ originalDoc?: TDoc;
1219
+ /** Full incoming payload being written. */
1220
+ data: Record<string, unknown>;
1221
+ /** Authenticated user performing the write, if any. */
1222
+ user?: AuthenticatedUser;
1223
+ /** Read-only database adapter for related lookups. */
1224
+ db: ReadonlyDatabaseAdapter;
1225
+ }
1226
+ type FieldBeforeChangeHook<TValue = unknown, TDoc extends object = Record<string, unknown>> = (args: FieldBeforeChangeHookArgs<TValue, TDoc>) => unknown;
1227
+ interface FieldAfterReadHookArgs<TValue = unknown, TDoc extends object = Record<string, unknown>> {
1228
+ /** Raw stored field value before this hook transforms it. */
1229
+ value: TValue;
1230
+ /** Full document currently being returned to the caller. */
1231
+ doc: TDoc;
1232
+ /** Authenticated user requesting the document, if any. */
1233
+ user?: AuthenticatedUser;
1234
+ /** Read-only database adapter for related lookups. */
1235
+ db: ReadonlyDatabaseAdapter;
1236
+ }
1237
+ type FieldAfterReadHook<TValue = unknown, TDoc extends object = Record<string, unknown>> = (args: FieldAfterReadHookArgs<TValue, TDoc>) => unknown;
1238
+ type FieldHooks<TValue> = {
1239
+ hooks?: {
1240
+ beforeChange?: Array<FieldBeforeChangeHook<TValue> | DeclarativeHookExpression>;
1241
+ afterRead?: Array<FieldAfterReadHook<TValue>>;
1242
+ };
1243
+ };
1244
+ interface FieldAdminOnChangeHookArgs<TValue = unknown> {
1245
+ /** Current field value in the form state. */
1246
+ value: TValue;
1247
+ /** Current values for sibling fields at the same nesting level. */
1248
+ siblingData: Record<string, unknown>;
1249
+ /** Current values for the entire form. */
1250
+ data: Record<string, unknown>;
1251
+ /** Imperative setter for async or derived updates. */
1252
+ setValue: (value: unknown) => void;
1253
+ }
1254
+ type FieldAdminOnChangeHook<TValue = unknown> = (args: FieldAdminOnChangeHookArgs<TValue>) => unknown;
1255
+ type FieldAdminHooks<TValue> = {
1256
+ admin?: {
1257
+ hooks?: {
1258
+ onChange?: FieldAdminOnChangeHook<TValue> | DeclarativeHookExpression;
1259
+ };
1260
+ };
1261
+ };
1262
+ interface FieldAdminOptionsHookArgs {
1263
+ /** Current values for sibling fields at the same nesting level. */
1264
+ siblingData: Record<string, unknown>;
1265
+ /** Current values for the entire form. */
1266
+ data: Record<string, unknown>;
1267
+ }
1268
+ type FieldAdminOptionsHookResult = Array<string | {
1269
+ label: string;
1270
+ value: unknown;
1271
+ }>;
1272
+ type FieldAdminOptionsHook = (args: FieldAdminOptionsHookArgs) => FieldAdminOptionsHookResult | Promise<FieldAdminOptionsHookResult>;
1273
+ type TypedField<TType extends FieldType, TValue, TAdminExtra = Record<never, never>> = Omit<FieldBase, "admin"> & {
1274
+ type: TType;
1275
+ admin?: BaseFieldAdmin & TAdminExtra;
1276
+ } & FieldHooks<TValue> & FieldAdminHooks<TValue>;
1277
+ /**
1278
+ * A semantic color for a badge or status pill in the Admin UI. The Admin panel
1279
+ * maps each tone to a themed color, so you pick meaning (`success`, `danger`)
1280
+ * rather than a raw color and it stays consistent in light and dark mode.
1281
+ */
1282
+ type DisplayTone = "neutral" | "primary" | "success" | "warning" | "danger" | "info";
1283
+ /**
1284
+ * How a `select`, `radio`, or `multiSelect` value is presented in read-only
1285
+ * Admin surfaces (list cells). Renders the chosen option as a colored badge —
1286
+ * ideal for statuses like `draft`/`published`. Display only and
1287
+ * JSON-serializable so it round-trips through Dyrected Cloud.
1288
+ *
1289
+ * Pass the shorthand `"badge"` for neutral badges, or an object to color and
1290
+ * relabel each value.
1291
+ */
1292
+ type OptionFormat =
1293
+ /** Shorthand for `{ type: "badge" }` — every value renders as a neutral badge. */
1294
+ "badge" | {
1295
+ type: "badge";
1296
+ /** Maps an option value to a color tone. Values not listed use `defaultTone`. */
1297
+ tones?: Record<string, DisplayTone>;
1298
+ /** Overrides the displayed text per option value. Falls back to the option's label. */
1299
+ labels?: Record<string, string>;
1300
+ /** Tone for values missing from `tones`. Defaults to `"neutral"`. */
1301
+ defaultTone?: DisplayTone;
1302
+ };
1303
+ /**
1304
+ * How a `boolean` value is presented in read-only Admin surfaces. Replaces the
1305
+ * default `Yes`/`No` badge with your own labels and tones — for example
1306
+ * `Active`/`Inactive` or `In stock`/`Sold out`. Display only.
1307
+ */
1308
+ type BooleanFormat = {
1309
+ type: "boolean";
1310
+ /** Presentation for a `true` value. */
1311
+ true?: {
1312
+ label?: string;
1313
+ tone?: DisplayTone;
1314
+ };
1315
+ /** Presentation for a `false` value. */
1316
+ false?: {
1317
+ label?: string;
1318
+ tone?: DisplayTone;
1319
+ };
1320
+ };
1321
+ /**
1322
+ * How a `text` or `textarea` value is presented in read-only Admin surfaces.
1323
+ * Display only — the stored string is unchanged. Pass a shorthand string for the
1324
+ * simple transforms, or an object for `truncate` and `mask`.
1325
+ */
1326
+ type TextFormat =
1327
+ /** Shorthand for the matching object form. */
1328
+ "uppercase" | "lowercase" | "capitalize" | "code"
1329
+ /** Change the letter case for display. */
1330
+ | {
1331
+ type: "uppercase" | "lowercase" | "capitalize";
1332
+ }
1333
+ /** Render in a monospace pill — good for IDs, SKUs, and short codes. */
1334
+ | {
1335
+ type: "code";
1336
+ }
1337
+ /** Cut the text to `length` characters with a trailing ellipsis. */
1338
+ | {
1339
+ type: "truncate";
1340
+ length: number;
1341
+ }
1342
+ /**
1343
+ * Hide all but the last few characters — for tokens, keys, or reference
1344
+ * numbers you don't want fully visible in a list.
1345
+ */
1346
+ | {
1347
+ type: "mask";
1348
+ /** How many trailing characters stay visible. Defaults to `4`. */
1349
+ reveal?: number;
1350
+ /** Character used for the hidden portion. Defaults to `"•"`. */
1351
+ character?: string;
1352
+ };
1353
+ /**
1354
+ * How a `url` or `email` value is presented in read-only Admin surfaces.
1355
+ * Renders the value as a clickable link (a `mailto:` link for `email`) instead
1356
+ * of plain text. Display only.
1357
+ */
1358
+ type LinkFormat =
1359
+ /** Shorthand for `{ type: "link" }`. */
1360
+ "link" | {
1361
+ type: "link";
1362
+ /** Open the link in a new tab. Defaults to `true`. */
1363
+ newTab?: boolean;
1364
+ };
1365
+ /**
1366
+ * How a `json` value is presented in read-only Admin surfaces. Display only.
1367
+ */
1368
+ type JsonFormat =
1369
+ /** Shorthand for the matching object form. */
1370
+ "summary" | "code"
1371
+ /** A compact key count, e.g. `{ 3 keys }`. */
1372
+ | {
1373
+ type: "summary";
1374
+ }
1375
+ /** A truncated inline monospace preview of the raw JSON. */
1376
+ | {
1377
+ type: "code";
1378
+ };
1379
+ type BooleanFieldAdmin = {
1380
+ /** Boolean presentation style. */
1381
+ layout?: "checkbox" | "switch";
1382
+ /** How the value is displayed in read-only Admin surfaces. Does not affect storage or editing. */
1383
+ format?: BooleanFormat;
1384
+ };
1385
+ type SelectFieldAdmin = {
1386
+ /** Select presentation style. */
1387
+ layout?: "radio" | "select";
1388
+ /** Radio orientation when `layout: 'radio'` is used. */
1389
+ direction?: "horizontal" | "vertical";
1390
+ /** How the value is displayed in read-only Admin surfaces. Does not affect storage or editing. */
1391
+ format?: OptionFormat;
1392
+ hooks?: {
1393
+ /** Client-side option recalculation for dependent dropdowns or radios. */
1394
+ options?: FieldAdminOptionsHook;
1395
+ };
1396
+ };
1397
+ type RadioFieldAdmin = {
1398
+ /** Radio group orientation. */
1399
+ direction?: "horizontal" | "vertical";
1400
+ /** How the value is displayed in read-only Admin surfaces. Does not affect storage or editing. */
1401
+ format?: OptionFormat;
1402
+ hooks?: {
1403
+ /** Client-side option recalculation for dependent radio groups. */
1404
+ options?: FieldAdminOptionsHook;
1405
+ };
1406
+ };
1407
+ type MultiSelectFieldAdmin = {
1408
+ /** How each selected value is displayed in read-only Admin surfaces. Does not affect storage or editing. */
1409
+ format?: OptionFormat;
1410
+ hooks?: {
1411
+ /** Client-side option recalculation for dependent multi-select fields. */
1412
+ options?: FieldAdminOptionsHook;
1413
+ };
1414
+ };
1415
+ interface CharacterLimitFieldConfig {
1416
+ /** Advisory maximum character count exposed to editors and client tooling. */
1417
+ maxLength?: number;
1418
+ }
1419
+ interface WordLimitFieldConfig {
1420
+ /** Advisory maximum word count exposed to editors and client tooling. */
1421
+ maxWords?: number;
1422
+ }
1423
+ interface NumberLimitFieldConfig {
1424
+ /** Advisory minimum numeric value exposed to editors and client tooling. */
1425
+ min?: number;
1426
+ /** Advisory maximum numeric value exposed to editors and client tooling. */
1427
+ max?: number;
1428
+ }
1429
+ type CharacterLimitFieldAdmin = {
1430
+ /** Admin-only compatibility alias for `field.maxLength`. Prefer the top-level field property. */
1431
+ maxLength?: number;
1432
+ };
1433
+ type WordLimitFieldAdmin = {
1434
+ /** Admin-only compatibility alias for `field.maxWords`. Prefer the top-level field property. */
1435
+ maxWords?: number;
1436
+ };
1437
+ type NumberLimitFieldAdmin = {
1438
+ /** Admin-only compatibility alias for `field.min`. Prefer the top-level field property. */
1439
+ min?: number;
1440
+ /** Admin-only compatibility alias for `field.max`. Prefer the top-level field property. */
1441
+ max?: number;
1442
+ };
1443
+ /**
1444
+ * How a `number` field's value is presented in read-only Admin surfaces (list
1445
+ * cells and read-only inputs). Display only — the stored value is unchanged, and
1446
+ * editing still uses a plain numeric input. Every option is JSON-serializable so
1447
+ * it round-trips through Dyrected Cloud.
1448
+ *
1449
+ * Pass a shorthand string for defaults (`format: "currency"`) or an object to
1450
+ * configure it (`format: { type: "currency", currency: "NGN" }`).
1451
+ */
1452
+ type NumberFormat =
1453
+ /** Shorthand for the matching object form, using that format's defaults. */
1454
+ "decimal" | "currency" | "percent" | "compact" | "bytes" | "rating"
1455
+ /** Grouped number, e.g. `1234.5` → `1,234.5`. */
1456
+ | {
1457
+ type: "decimal";
1458
+ /** BCP 47 locale tag. Defaults to the viewer's browser locale. */
1459
+ locale?: string;
1460
+ minimumFractionDigits?: number;
1461
+ maximumFractionDigits?: number;
1462
+ }
1463
+ /** Currency amount, e.g. `1234.5` → `$1,234.50`. */
1464
+ | {
1465
+ type: "currency";
1466
+ /** ISO 4217 currency code, e.g. `"USD"`, `"NGN"`, `"EUR"`. Defaults to `"USD"`. */
1467
+ currency?: string;
1468
+ /** BCP 47 locale tag. Defaults to the viewer's browser locale. */
1469
+ locale?: string;
1470
+ minimumFractionDigits?: number;
1471
+ maximumFractionDigits?: number;
1472
+ }
1473
+ /**
1474
+ * Percentage. By default the stored value is a ratio, so `0.5` → `50%`. Set
1475
+ * `scale: false` when the stored value is already a percentage, so `50` → `50%`.
1476
+ */
1477
+ | {
1478
+ type: "percent";
1479
+ /** BCP 47 locale tag. Defaults to the viewer's browser locale. */
1480
+ locale?: string;
1481
+ /** `false` when the stored number is already scaled to 0–100. Defaults to `true`. */
1482
+ scale?: boolean;
1483
+ minimumFractionDigits?: number;
1484
+ maximumFractionDigits?: number;
1485
+ }
1486
+ /** A measurement unit, e.g. `5` → `5 km` with `unit: "kilometer"`. */
1487
+ | {
1488
+ type: "unit";
1489
+ /** A [sanctioned Intl unit](https://tc39.es/proposal-unified-intl-numberformat/section6/locales-currencies-tz_proposed_out.html#sec-issanctionedsimpleunitidentifier), e.g. `"kilometer"`, `"liter"`, `"celsius"`. */
1490
+ unit: string;
1491
+ unitDisplay?: "short" | "long" | "narrow";
1492
+ /** BCP 47 locale tag. Defaults to the viewer's browser locale. */
1493
+ locale?: string;
1494
+ maximumFractionDigits?: number;
1495
+ }
1496
+ /** Abbreviated large numbers, e.g. `1200` → `1.2K`. */
1497
+ | {
1498
+ type: "compact";
1499
+ /** BCP 47 locale tag. Defaults to the viewer's browser locale. */
1500
+ locale?: string;
1501
+ maximumFractionDigits?: number;
1502
+ }
1503
+ /** A byte count rendered with units, e.g. `1536` → `1.5 KB`. */
1504
+ | {
1505
+ type: "bytes";
1506
+ /** Use 1024-based units (`KiB`, `MiB`) instead of 1000-based (`KB`, `MB`). Defaults to `false`. */
1507
+ binary?: boolean;
1508
+ maximumFractionDigits?: number;
1509
+ }
1510
+ /** A star rating, e.g. `4` → `★★★★☆` with `max: 5`. */
1511
+ | {
1512
+ type: "rating";
1513
+ /** Total number of stars. Defaults to `5`. */
1514
+ max?: number;
1515
+ };
1516
+ /**
1517
+ * How a `date`, `datetime`, or `time` field's value is presented in read-only
1518
+ * Admin surfaces. Display only and JSON-serializable so it round-trips through
1519
+ * Dyrected Cloud.
1520
+ *
1521
+ * Pass a shorthand string (`format: "relative"`) or an object for finer control
1522
+ * (`format: { type: "date", dateStyle: "long" }`).
1523
+ */
1524
+ type DateFormat =
1525
+ /** Shorthand for the matching object form, using that format's defaults. */
1526
+ "date" | "datetime" | "time" | "relative"
1527
+ /** Calendar date, e.g. `Jan 5, 2026`. */
1528
+ | {
1529
+ type: "date";
1530
+ dateStyle?: "short" | "medium" | "long" | "full";
1531
+ /** BCP 47 locale tag. Defaults to the viewer's browser locale. */
1532
+ locale?: string;
1533
+ }
1534
+ /** Date and time together, e.g. `Jan 5, 2026, 2:30 PM`. */
1535
+ | {
1536
+ type: "datetime";
1537
+ dateStyle?: "short" | "medium" | "long" | "full";
1538
+ timeStyle?: "short" | "medium" | "long" | "full";
1539
+ /** BCP 47 locale tag. Defaults to the viewer's browser locale. */
1540
+ locale?: string;
1541
+ }
1542
+ /** Time of day, e.g. `2:30 PM`. */
1543
+ | {
1544
+ type: "time";
1545
+ timeStyle?: "short" | "medium" | "long" | "full";
1546
+ /** BCP 47 locale tag. Defaults to the viewer's browser locale. */
1547
+ locale?: string;
1548
+ }
1549
+ /** Relative to now, e.g. `3 days ago`, `in 2 hours`. */
1550
+ | {
1551
+ type: "relative";
1552
+ /** BCP 47 locale tag. Defaults to the viewer's browser locale. */
1553
+ locale?: string;
1554
+ };
1555
+ type TextFieldAdmin = CharacterLimitFieldAdmin & WordLimitFieldAdmin & {
1556
+ /** How the value is displayed in read-only Admin surfaces. Does not affect storage or editing. */
1557
+ format?: TextFormat;
1558
+ };
1559
+ type TextareaFieldAdmin = CharacterLimitFieldAdmin & WordLimitFieldAdmin & {
1560
+ /** How the value is displayed in read-only Admin surfaces. Does not affect storage or editing. */
1561
+ format?: TextFormat;
1562
+ };
1563
+ type EmailFieldAdmin = CharacterLimitFieldAdmin & {
1564
+ /** How the value is displayed in read-only Admin surfaces. Does not affect storage or editing. */
1565
+ format?: LinkFormat;
1566
+ };
1567
+ type UrlFieldAdmin = CharacterLimitFieldAdmin & {
1568
+ /** How the value is displayed in read-only Admin surfaces. Does not affect storage or editing. */
1569
+ format?: LinkFormat;
1570
+ };
1571
+ type IconFieldAdmin = CharacterLimitFieldAdmin;
1572
+ type JsonFieldAdmin = {
1573
+ /** How the value is displayed in read-only Admin surfaces. Does not affect storage or editing. */
1574
+ format?: JsonFormat;
1575
+ };
1576
+ type NumberFieldAdmin = NumberLimitFieldAdmin & {
1577
+ /** How the value is displayed in read-only Admin surfaces (list cells, read-only inputs). Does not affect storage or editing. */
1578
+ format?: NumberFormat;
1579
+ };
1580
+ type DateFieldAdmin = {
1581
+ /** How the value is displayed in read-only Admin surfaces (list cells, read-only inputs). Does not affect storage or editing. */
1582
+ format?: DateFormat;
1583
+ };
1584
+ type JoinFieldAdmin = {
1585
+ /** Whether the join field should show the "Create new" action in the Admin UI. Defaults to `true`. */
1586
+ showCreateButton?: boolean;
1587
+ /** Whether the join field should show the "View all" action in the Admin UI. Defaults to `true`. */
1588
+ showViewButton?: boolean;
1589
+ };
1590
+ interface UrlLinkValue {
1591
+ /** Whether the link is a custom URL or a reference to an internal document. */
1592
+ type: "custom" | "internal";
1593
+ /** The link URL. Absolute for custom links; may be a site-relative path for internal links. */
1594
+ url?: string;
1595
+ /** For internal links, the collection slug of the referenced document. */
1596
+ relationTo?: string;
1597
+ /** For internal links, the ID of the referenced document. */
1598
+ value?: string;
1599
+ /** Optional display label shown for the link. */
1600
+ label?: string;
1601
+ }
1602
+ /**
1603
+ * Editor capabilities available on a `richText` field. Each feature maps to a
1604
+ * formatting control in the Admin editor toolbar and to the underlying editor
1605
+ * schema, so disabling a feature removes both its toolbar button and the
1606
+ * capability itself (including keyboard shortcuts and paste handling).
1607
+ */
1608
+ type RichTextFeature = "bold" | "italic" | "underline" | "strike" | "heading" | "bulletList" | "orderedList" | "blockquote" | "align" | "link" | "table" | "image";
1609
+ /** Heading levels offered by the `heading` rich-text feature. */
1610
+ type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
1611
+ interface RichTextFieldConfig {
1612
+ /**
1613
+ * Editor capabilities to enable, in toolbar order. When omitted, every
1614
+ * {@link RichTextFeature} is enabled (the default toolbar). Provide a subset
1615
+ * to restrict what editors can do — for example `['bold', 'italic', 'link']`
1616
+ * for a lightweight inline editor.
1617
+ */
1618
+ features?: RichTextFeature[];
1619
+ /**
1620
+ * Heading levels offered when the `heading` feature is enabled.
1621
+ * Defaults to `[1, 2, 3]`.
1622
+ */
1623
+ headingLevels?: HeadingLevel[];
1624
+ /**
1625
+ * Upload collection slug used by the `image` feature's media picker.
1626
+ * Defaults to the first collection configured with `upload: true`.
1627
+ */
1628
+ uploadCollection?: string;
1629
+ }
1630
+ type TextField = TypedField<"text", string, TextFieldAdmin> & CharacterLimitFieldConfig & WordLimitFieldConfig;
1631
+ type TextareaField = TypedField<"textarea", string, TextareaFieldAdmin> & CharacterLimitFieldConfig & WordLimitFieldConfig;
1632
+ type EmailField = TypedField<"email", string, EmailFieldAdmin> & CharacterLimitFieldConfig;
1633
+ type UrlField = TypedField<"url", string | UrlLinkValue, UrlFieldAdmin> & CharacterLimitFieldConfig;
1634
+ type IconField = TypedField<"icon", string, IconFieldAdmin> & CharacterLimitFieldConfig;
1635
+ /** A calendar day, stored and returned as an ISO date string. */
1636
+ type DateField = TypedField<"date", string, DateFieldAdmin>;
1637
+ /** A specific instant, stored and returned as an ISO date-time string. */
1638
+ type DateTimeField = TypedField<"datetime", string, DateFieldAdmin>;
1639
+ /** A local time of day, stored as a string when the date is modeled elsewhere. */
1640
+ type TimeField = TypedField<"time", string, DateFieldAdmin>;
1641
+ /** A single choice from a fixed or dynamically-resolved set of options, stored as the chosen value. */
1642
+ type SelectField = TypedField<"select", string, SelectFieldAdmin>;
1643
+ /** A single choice shown as radio buttons, stored as the chosen value. */
1644
+ type RadioField = TypedField<"radio", string, RadioFieldAdmin>;
1645
+ /** A numeric value. Optional advisory `min`/`max` guide editors without enforcing server-side validation. */
1646
+ type NumberField = TypedField<"number", number, NumberFieldAdmin> & NumberLimitFieldConfig;
1647
+ /** A `true`/`false` value, shown to editors as a checkbox or switch. */
1648
+ type BooleanField = TypedField<"boolean", boolean, BooleanFieldAdmin>;
1649
+ /** Several choices from a fixed or dynamically-resolved set, stored as an array of the chosen values. */
1650
+ type MultiSelectField = TypedField<"multiSelect", string[], MultiSelectFieldAdmin>;
1651
+ /** A reference to one or more documents in another collection, stored as an ID or array of IDs. Use `relationTo` to name the target and `hasMany` for multiple. */
1652
+ type RelationshipField = TypedField<"relationship", string | string[]>;
1653
+ /** A reference to one or more documents in an upload-enabled collection, stored as an ID or array of IDs. Use `relationTo` to name the target and `hasMany` for multiple. */
1654
+ type ImageField = TypedField<"image", string | string[]>;
1655
+ /** Formatted content authored in the admin editor, stored as an HTML string. */
1656
+ type RichTextField = TypedField<"richText", string> & RichTextFieldConfig;
1657
+ /** An arbitrary JSON value. Dyrected stores it as-is and does not validate its shape. */
1658
+ type JsonField = TypedField<"json", Record<string, unknown>, JsonFieldAdmin>;
1659
+ /** A group of nested `fields` stored as an embedded object under this field's `name`. */
1660
+ type ObjectField = TypedField<"object", unknown>;
1661
+ /** A repeatable list of rows that all share the same `fields`, stored as an array of objects. */
1662
+ type ArrayField = TypedField<"array", unknown>;
1663
+ /** Flexible content built from a controlled set of typed `blocks`, stored as an ordered array where each row records its `blockType`. */
1664
+ type BlocksField = TypedField<"blocks", unknown>;
1665
+ /** A virtual reverse relationship that surfaces documents pointing back at this one via `collection` and `on`. Read-only; nothing is stored on this document. */
1666
+ type JoinField = TypedField<"join", unknown, JoinFieldAdmin>;
1667
+ /** A layout-only container that arranges its child `fields` horizontally in the admin UI. Stores no value of its own. */
1668
+ type RowField = TypedField<"row", unknown>;
1669
+ type Field = TextField | TextareaField | EmailField | UrlField | IconField | DateField | DateTimeField | TimeField | SelectField | RadioField | NumberField | BooleanField | MultiSelectField | RelationshipField | ImageField | RichTextField | JsonField | ObjectField | ArrayField | BlocksField | JoinField | RowField;
1670
+ interface UploadConfig {
1671
+ /** Allowed MIME types for uploaded files. */
1672
+ allowedMimeTypes?: string[];
1673
+ /** Maximum upload size in bytes. */
1674
+ maxFileSize?: number;
1675
+ /** Local filesystem destination used by disk-based storage adapters. */
1676
+ staticDir?: string;
1677
+ /** Public URL prefix for disk-based uploads. */
1678
+ staticURL?: string;
1679
+ /** Generated image size name used as the Admin media thumbnail. */
1680
+ adminThumbnail?: string;
1681
+ imageSizes?: {
1682
+ /** Stable name used to reference this generated size. */
1683
+ name: string;
1684
+ /** Target width in pixels. */
1685
+ width?: number;
1686
+ /** Target height in pixels. */
1687
+ height?: number;
1688
+ /** Crop strategy forwarded to the image processor. */
1689
+ crop?: string;
1690
+ /** Resize fit strategy forwarded to the image processor. */
1691
+ fit?: string;
1692
+ /** Prevents upscaling smaller source images. */
1693
+ withoutEnlargement?: boolean;
1694
+ /** Format-specific options forwarded to the image processor. */
1695
+ formatOptions?: Record<string, unknown>;
1696
+ }[];
1697
+ }
1698
+
1699
+ interface AdminAuthMember {
1700
+ id: string;
1701
+ email: string;
1702
+ name?: string;
1703
+ roles: string[];
1704
+ siteAccess?: string[];
1705
+ status?: "active" | "pending";
1706
+ [key: string]: any;
1707
+ }
1708
+ type AdminAuthProvisioningMode = "jit_only" | "jit_plus_membership_management" | "preprovisioned_only";
1709
+ interface AdminAuthClaimMapping {
1710
+ sub?: string;
1711
+ email?: string;
1712
+ name?: string;
1713
+ roles?: string;
1714
+ groups?: string;
1715
+ siteIds?: string;
1716
+ workspaceIds?: string;
1717
+ }
1718
+ interface AdminAuthResolvedIdentity {
1719
+ sub: string;
1720
+ email?: string;
1721
+ name?: string;
1722
+ roles?: string[];
1723
+ groups?: string[];
1724
+ siteIds?: string[];
1725
+ workspaceIds?: string[];
1726
+ rawClaims?: Record<string, unknown>;
1727
+ }
1728
+ interface AdminAuthAccessResolution {
1729
+ allowed: boolean;
1730
+ roles?: string[];
1731
+ data?: Record<string, unknown>;
1732
+ }
1733
+ interface AdminAuthResolveAccessArgs {
1734
+ identity: AdminAuthResolvedIdentity;
1735
+ providerId: string;
1736
+ siteId?: string;
1737
+ workspaceId?: string;
1738
+ req: {
1739
+ method: string;
1740
+ path: string;
1741
+ url: string;
1742
+ headers: Record<string, string | undefined>;
1743
+ };
1744
+ user: Record<string, unknown> | null;
1745
+ }
1746
+ interface AdminAuthProviderMembersConfig {
1747
+ list?: (args: {
1748
+ limit?: number;
1749
+ page?: number;
1750
+ sort?: string;
1751
+ where?: Record<string, any>;
1752
+ req: HookRequestContext;
1753
+ }) => Promise<{
1754
+ docs: AdminAuthMember[];
1755
+ totalDocs: number;
1756
+ limit: number;
1757
+ page: number;
1758
+ totalPages: number;
1759
+ hasNextPage: boolean;
1760
+ hasPrevPage: boolean;
1761
+ }>;
1762
+ get?: (args: {
1763
+ externalSubject: string;
1764
+ req: HookRequestContext;
1765
+ }) => Promise<AdminAuthMember | null>;
1766
+ create?: (args: {
1767
+ data: Record<string, any>;
1768
+ req: HookRequestContext;
1769
+ }) => Promise<AdminAuthMember>;
1770
+ update?: (args: {
1771
+ externalSubject: string;
1772
+ data: Record<string, any>;
1773
+ req: HookRequestContext;
1774
+ }) => Promise<AdminAuthMember>;
1775
+ delete?: (args: {
1776
+ externalSubject: string;
1777
+ req: HookRequestContext;
1778
+ }) => Promise<void>;
1779
+ }
1780
+ interface BaseAdminAuthProvider {
1781
+ id: string;
1782
+ type: "oidc" | "custom" | "cloud";
1783
+ displayName?: string;
1784
+ autoRedirect?: boolean;
1785
+ allowJitProvisioning?: boolean;
1786
+ claimMapping?: AdminAuthClaimMapping;
1787
+ members?: AdminAuthProviderMembersConfig;
1788
+ }
1789
+ interface OIDCAdminAuthProvider extends BaseAdminAuthProvider {
1790
+ type: "oidc";
1791
+ issuer: string;
1792
+ clientId: string;
1793
+ clientSecret: string;
1794
+ redirectUri?: string;
1795
+ scopes?: string[];
1796
+ authorizationEndpoint?: string;
1797
+ tokenEndpoint?: string;
1798
+ userInfoEndpoint?: string;
1799
+ }
1800
+ interface CustomAdminAuthProvider extends BaseAdminAuthProvider {
1801
+ type: "custom" | "cloud";
1802
+ startUrl?: string;
1803
+ issuer?: string;
1804
+ audience?: string;
1805
+ secret?: string;
1806
+ jwksUri?: string;
1807
+ tokenParam?: string;
1808
+ }
1809
+ type AdminAuthProvider = OIDCAdminAuthProvider | CustomAdminAuthProvider;
1810
+ interface PublicAdminAuthProvider {
1811
+ id: string;
1812
+ type: AdminAuthProvider["type"];
1813
+ displayName: string;
1814
+ autoRedirect?: boolean;
1815
+ }
1816
+ interface PublicAdminAuthConfig {
1817
+ mode: "local" | "external";
1818
+ collectionSlug?: string;
1819
+ provisioningMode?: AdminAuthProvisioningMode;
1820
+ providers: PublicAdminAuthProvider[];
1821
+ }
1822
+ interface AdminAuthConfig {
1823
+ mode: "local" | "external";
1824
+ collectionSlug?: string;
1825
+ provisioningMode?: AdminAuthProvisioningMode;
1826
+ providers: AdminAuthProvider[];
1827
+ resolveAccess?: (args: AdminAuthResolveAccessArgs) => Promise<AdminAuthAccessResolution> | AdminAuthAccessResolution;
1828
+ }
1829
+
1830
+ type DyrectedLoggerConfig = {
1831
+ options: LoggerOptions;
1832
+ destination?: DestinationStream;
1833
+ } | Logger;
1834
+ interface DyrectedObservabilityConfig {
1835
+ requestLogging?: {
1836
+ enabled?: boolean;
1837
+ logBodies?: boolean;
1838
+ maxBodyBytes?: number;
1839
+ redactPaths?: string[];
1840
+ includeHeaders?: string[];
1841
+ redactHeaders?: string[];
1842
+ };
1843
+ sampling?: {
1844
+ successRate?: number;
1845
+ traceSuccessRate?: number;
1846
+ bodySuccessRate?: number;
1847
+ alwaysKeep4xx?: boolean;
1848
+ alwaysKeep5xx?: boolean;
1849
+ };
1850
+ tracing?: {
1851
+ enabled?: boolean;
1852
+ serviceName?: string;
1853
+ exporter?: "otlp" | "console" | "none";
1854
+ headers?: Record<string, string>;
1855
+ endpoint?: string;
1856
+ };
1857
+ metrics?: {
1858
+ enabled?: boolean;
1859
+ exporter?: "otlp" | "prometheus" | "none";
1860
+ endpoint?: string;
1861
+ path?: string;
1862
+ };
1863
+ transports?: {
1864
+ targets?: Array<{
1865
+ type: "stdout";
1866
+ } | {
1867
+ type: "stderr";
1868
+ } | {
1869
+ type: "file";
1870
+ path: string;
1871
+ } | {
1872
+ type: "otlp";
1873
+ endpoint: string;
1874
+ headers?: Record<string, string>;
1875
+ }>;
1876
+ };
1877
+ }
1878
+ type TrustProxyConfig = boolean | number;
1879
+ interface RateLimitConfig {
1880
+ /**
1881
+ * Enable in-process request rate limiting for HTTP API routes.
1882
+ *
1883
+ * This protects routes at the Dyrected app layer. For production you should
1884
+ * still prefer an edge or proxy limit in front of it when possible.
1885
+ */
1886
+ enabled?: boolean;
1887
+ /**
1888
+ * Time window, in milliseconds, used to count requests from the same client.
1889
+ *
1890
+ * Defaults to `15 * 60 * 1000` (15 minutes).
1891
+ */
1892
+ window?: number;
1893
+ /**
1894
+ * Maximum number of requests a client may make within the current window.
1895
+ *
1896
+ * Defaults to `500`.
1897
+ */
1898
+ max?: number;
1899
+ /**
1900
+ * Trust upstream proxy forwarding headers when resolving the client IP.
1901
+ *
1902
+ * Set to `true` when Dyrected is deployed behind a reverse proxy or
1903
+ * platform edge that correctly sets `X-Forwarded-For`. Set to a number to
1904
+ * trust that many proxy hops from the right side of the header chain.
1905
+ */
1906
+ trustProxy?: TrustProxyConfig;
1907
+ /**
1908
+ * Route prefixes that should be subject to rate limiting.
1909
+ *
1910
+ * Defaults to `['/api']`.
1911
+ */
1912
+ paths?: string[];
1913
+ /**
1914
+ * Optional escape hatch for requests that should bypass the in-app limiter.
1915
+ *
1916
+ * Return `true` to skip limiting for the current request.
1917
+ */
1918
+ skip?: (args: {
1919
+ ip: string;
1920
+ path: string;
1921
+ method: string;
1922
+ req: HookRequestContext;
1923
+ }) => boolean | Promise<boolean>;
1924
+ }
1925
+ /**
1926
+ * The root configuration object passed to `createDyrectedApp`.
1927
+ *
1928
+ * This is the single source of truth for your entire Dyrected instance —
1929
+ * collections, globals, database adapter, storage, email, and more.
1930
+ *
1931
+ * @example
1932
+ * import { defineConfig } from '@dyrected/core'
1933
+ * import { SQLiteAdapter } from '@dyrected/db-sqlite'
1934
+ *
1935
+ * export default defineConfig({
1936
+ * db: new SQLiteAdapter({ filename: './db.sqlite' }),
1937
+ * collections: [Posts, Users],
1938
+ * globals: [SiteSettings],
1939
+ * })
1940
+ */
1941
+ interface DyrectedConfig<TUser extends AuthenticatedUser = AuthenticatedUser> {
1942
+ /**
1943
+ * Reusable block definitions that `blocks` fields can reference by slug via
1944
+ * `blockReferences`.
1945
+ */
1946
+ blocks?: Block[];
1947
+ /** Collection definitions. Each collection maps to a database table/collection. */
1948
+ collections: CollectionConfig<any>[];
1949
+ /** Global (singleton) definitions. Each global maps to a single document. */
1950
+ globals: GlobalConfig<any>[];
1951
+ /**
1952
+ * The database adapter. Required for all data operations.
1953
+ * @see DatabaseAdapter
1954
+ */
1955
+ db?: DatabaseAdapter;
1956
+ /**
1957
+ * The storage adapter for file uploads.
1958
+ * Required when any collection has `upload: true`.
1959
+ * @see StorageAdapter
1960
+ */
1961
+ storage?: StorageAdapter;
1962
+ /**
1963
+ * The image processing service. Required when any upload collection
1964
+ * defines `imageSizes`.
1965
+ * @see ImageService
1966
+ */
1967
+ image?: ImageService;
1968
+ /**
1969
+ * Runtime logger configuration. Accepts either logger options/destination or
1970
+ * a fully-instantiated Pino logger.
1971
+ */
1972
+ logger?: DyrectedLoggerConfig;
1973
+ /**
1974
+ * Request logging, redaction, sampling, tracing, metrics, and transport
1975
+ * configuration for the Dyrected server runtime.
1976
+ */
1977
+ observability?: DyrectedObservabilityConfig;
1978
+ /** Admin UI branding and metadata. */
1979
+ admin?: AdminConfig;
1980
+ /**
1981
+ * Deployment-level authentication strategy for the CMS dashboard (`/admin`).
1982
+ * This is separate from collection-level `auth: true`, which continues to
1983
+ * power application/customer auth independently.
1984
+ */
1985
+ adminAuth?: AdminAuthConfig;
1986
+ /**
1987
+ * Named access policies available to collection, global, and field access
1988
+ * rules via `{ policy: 'name' }`.
1989
+ *
1990
+ * A policy can be a **function** (full server logic, evaluated to a static
1991
+ * boolean when serialized for the admin panel) or a **Jexl string** (or
1992
+ * boolean). String policies are inlined when the schema is sent to the admin,
1993
+ * so the admin panel evaluates them live against the current form — the same
1994
+ * way it evaluates inline Jexl rules.
1995
+ */
1996
+ accessPolicies?: Record<string, AccessPolicyResolver<Record<string, unknown>, TUser> | string | boolean>;
1997
+ /**
1998
+ * Email transport configuration. Required for welcome emails, password
1999
+ * resets, and invite links.
2000
+ *
2001
+ * @example
2002
+ * email: {
2003
+ * from: 'no-reply@myapp.com',
2004
+ * send: async ({ to, subject, html }) => {
2005
+ * await resend.emails.send({ from, to, subject, html })
2006
+ * },
2007
+ * }
2008
+ */
2009
+ email?: {
2010
+ /** The `From` address for all outbound emails. */
2011
+ from: string;
2012
+ /** The send function. Wire in any email provider (Resend, SendGrid, SES, etc.). */
2013
+ send: (args: {
2014
+ to: string;
2015
+ subject: string;
2016
+ html: string;
2017
+ }) => Promise<void>;
2018
+ /** Override the default email templates. */
2019
+ templates?: {
2020
+ welcome?: (args: {
2021
+ email: string;
2022
+ }) => {
2023
+ subject?: string;
2024
+ html: string;
2025
+ };
2026
+ invite?: (args: {
2027
+ token: string;
2028
+ invitedByEmail?: string;
2029
+ url?: string;
2030
+ }) => {
2031
+ subject?: string;
2032
+ html: string;
2033
+ };
2034
+ resetPassword?: (args: {
2035
+ token: string;
2036
+ url?: string;
2037
+ }) => {
2038
+ subject?: string;
2039
+ html: string;
2040
+ };
2041
+ passwordChanged?: (args: {
2042
+ email: string;
2043
+ }) => {
2044
+ subject?: string;
2045
+ html: string;
2046
+ };
2047
+ };
2048
+ };
2049
+ /**
2050
+ * Redis connection URL. Required for distributed caching of dynamic option
2051
+ * resolvers and other server-side caches in multi-instance deployments.
2052
+ *
2053
+ * @example
2054
+ * redis: { url: process.env.REDIS_URL }
2055
+ */
2056
+ redis?: {
2057
+ url: string;
2058
+ };
2059
+ /** Durable lifecycle-event delivery configuration. */
2060
+ events?: {
2061
+ handlers: LifecycleEventHandler[];
2062
+ /** Maximum delivery attempts before an event remains failed. Defaults to 8. */
2063
+ maxAttempts?: number;
2064
+ /** Initial exponential-backoff delay in milliseconds. Defaults to 1000. */
2065
+ retryDelayMs?: number;
2066
+ };
2067
+ /**
2068
+ * Cross-Origin Resource Sharing (CORS) configuration.
2069
+ * List all origins that are allowed to call the Dyrected API.
2070
+ *
2071
+ * @example
2072
+ * cors: { origins: ['https://myapp.com', 'https://www.myapp.com'] }
2073
+ */
2074
+ cors?: {
2075
+ origins: string[];
2076
+ };
2077
+ /**
2078
+ * App-level HTTP request rate limiting.
2079
+ *
2080
+ * Similar to Payload's `rateLimit` option, this counts requests by client IP
2081
+ * over a rolling time window and returns `429` responses once the limit is
2082
+ * exhausted.
2083
+ */
2084
+ rateLimit?: RateLimitConfig;
2085
+ /**
2086
+ * Callback to dynamically fetch additional collections and globals for a
2087
+ * given site ID at request time. Used in multi-tenant deployments where each
2088
+ * site has its own schema stored in the database.
2089
+ */
2090
+ onSchemaFetch?: (siteId: string) => Promise<{
2091
+ blocks?: Block[];
2092
+ collections?: CollectionConfig<any>[];
2093
+ globals?: GlobalConfig<any>[];
2094
+ accessPolicies?: Record<string, AccessPolicyResolver<Record<string, unknown>, TUser> | string | boolean>;
2095
+ admin?: AdminConfig;
2096
+ adminAuth?: AdminAuthConfig;
2097
+ }>;
2098
+ }
2099
+
2100
+ export { type AdminIconName as $, type AdminAuthConfig as A, type Block as B, type CollectionConfig as C, type DyrectedConfig as D, type EmailField as E, type Field as F, type GlobalConfig as G, type HookRequestContext as H, type IconField as I, type JoinField as J, type AdminAuthProvider as K, type LifecycleEventName as L, type MultiSelectField as M, type NumberField as N, type ObjectField as O, type PublicAdminAuthConfig as P, type AdminAuthProviderMembersConfig as Q, type RadioField as R, type SelectField as S, type TextField as T, type UrlField as U, type AdminAuthProvisioningMode as V, type WorkflowConfig as W, type AdminAuthResolveAccessArgs as X, type AdminAuthResolvedIdentity as Y, type AdminConfig as Z, type AdminDashboardComponentSlots as _, type DeclarativeHookExpression as a, type MultiSelectFieldAdmin as a$, type BaseAdminAuthProvider as a0, type BaseFieldAdmin as a1, type BlockVariant as a2, type BooleanFieldAdmin as a3, type BooleanFormat as a4, type CharacterLimitFieldAdmin as a5, type CharacterLimitFieldConfig as a6, type CollectionAfterChangeHook as a7, type CollectionAfterDeleteHook as a8, type CollectionAfterReadHook as a9, type FieldAdminOptionsHookResult as aA, type FieldAfterReadHook as aB, type FieldAfterReadHookArgs as aC, type FieldBase as aD, type FieldBeforeChangeHook as aE, type FieldBeforeChangeHookArgs as aF, type FieldHook as aG, type FieldHooks as aH, type FieldType as aI, type FileData as aJ, type GlobalAfterChangeHook as aK, type GlobalAfterReadHook as aL, type GlobalAfterReadHookEntry as aM, type GlobalBeforeChangeHook as aN, type GlobalBeforeChangeHookEntry as aO, type GlobalBeforeReadHook as aP, type GlobalBeforeReadHookEntry as aQ, type HeadingLevel as aR, type HookFunction as aS, type IconFieldAdmin as aT, type ImageService as aU, type JoinFieldAdmin as aV, type JsonFieldAdmin as aW, type JsonFormat as aX, LIFECYCLE_EVENT_NAMES as aY, type LifecycleEventHandler as aZ, type LinkFormat as a_, type CollectionAfterReadHookEntry as aa, type CollectionAfterTransitionHook as ab, type CollectionBeforeChangeHook as ac, type CollectionBeforeChangeHookEntry as ad, type CollectionBeforeDeleteHook as ae, type CollectionBeforeReadHook as af, type CollectionBeforeReadHookEntry as ag, type CollectionBeforeTransitionHook as ah, type CollectionListComponentSlots as ai, type CustomAdminAuthProvider as aj, type DatabaseAdapter as ak, type DateFieldAdmin as al, type DateFormat as am, type DisplayTone as an, type DynamicOptionItem as ao, type DynamicOptionsConfig as ap, type DynamicOptionsResolver as aq, type DynamicOptionsResolverArgs as ar, type DyrectedLoggerConfig as as, type DyrectedObservabilityConfig as at, type EmailFieldAdmin as au, type FieldAdminHooks as av, type FieldAdminOnChangeHook as aw, type FieldAdminOnChangeHookArgs as ax, type FieldAdminOptionsHook as ay, type FieldAdminOptionsHookArgs as az, type AuthenticatedUser as b, type NamedAccessPolicy as b0, type NumberFieldAdmin as b1, type NumberFormat as b2, type NumberLimitFieldAdmin as b3, type NumberLimitFieldConfig as b4, type OIDCAdminAuthProvider as b5, type OptionFormat as b6, type PaginatedResult as b7, type PublicAdminAuthProvider as b8, type RadioFieldAdmin as b9, type RateLimitConfig as ba, type ReadonlyDatabaseAdapter as bb, type RichTextFeature as bc, type RichTextFieldConfig as bd, type SelectFieldAdmin as be, type StorageAdapter as bf, type TextFieldAdmin as bg, type TextFormat as bh, type TextareaFieldAdmin as bi, type TrustProxyConfig as bj, type TypedField as bk, type UploadConfig as bl, type UrlFieldAdmin as bm, type UrlLinkValue as bn, type WordLimitFieldAdmin as bo, type WordLimitFieldConfig as bp, type WorkflowMetadata as bq, type WorkflowRole as br, type WorkflowState as bs, type WorkflowTransitionContext as bt, type WorkflowTransition as c, type LifecycleEvent as d, type BaseDocument as e, type ArrayField as f, type BlocksField as g, type BooleanField as h, type AuthConfig as i, type AccessPolicyResolver as j, type DateField as k, type DateTimeField as l, type ImageField as m, type JsonField as n, type RelationshipField as o, type RichTextField as p, type RowField as q, type TextareaField as r, type TimeField as s, type AccessFunction as t, type AccessFunctionArgs as u, type AccessResult as v, type AccessRule as w, type AdminAuthAccessResolution as x, type AdminAuthClaimMapping as y, type AdminAuthMember as z };