@dyrected/core 2.18.1 → 2.20.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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as Field, B as Block, C as CollectionConfig, D as DyrectedConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, G as GlobalConfig, a as DeclarativeHookExpression, W as WorkflowConfig, b as AuthenticatedUser, c as WorkflowTransition, L as LifecycleEventName, d as LifecycleEvent, e as DatabaseAdapter, f as BaseDocument, H as HookRequestContext, T as TaskRunResult, g as TaskConfig, h as DetailActionOptions, i as DetailAction, j as DetailComputedOptions, k as ComputedHandler, l as DetailComputed, m as DetailCustomOptions, n as DetailCustom, o as DetailDividerOptions, p as DetailDivider, q as DisplayFieldOptions, r as DetailField, s as DetailItem, t as DetailGridOptions, u as DetailGrid, v as DetailRepeatOptions, w as DetailRepeat, x as DetailSectionOptions, y as DetailSection, z as DetailTabOptions, E as DetailTab, I as DetailTabsOptions, J as DetailTabs, K as DetailTextOptions, M as DetailText, N as DetailSchema, O as DyrectedContext, Q as AIConfig, R as AIPIIConfig, S as IdStrategy, U as CompiledNavTree, V as CompiledNavItem, X as UserNavigationPreferences, Y as DefineWorkspaceOptions, Z as ViewConfig, _ as ArrayField, $ as FieldType, a0 as BooleanField, a1 as AuthConfig, a2 as AccessPolicyResolver, a3 as DateField, a4 as DateTimeField, a5 as EmailField, a6 as IconField, a7 as ImageField, a8 as JoinField, a9 as JsonField, aa as MoneyField, ab as MultiSelectField, ac as NumberField, ad as ObjectField, ae as RadioField, af as RelationshipField, ag as RichTextField, ah as RowField, ai as SelectField, aj as TextField, ak as TextareaField, al as TimeField, am as UrlField } from './app-x7J5BIqK.cjs';
2
- export { an as AIAction, ao as AIActionStatus, ap as AIActionType, aq as AIAuditActionType, ar as AIAuditRecord, as as AIChunk, at as AIMessage, au as AIPIIPattern, av as AIRateLimitResult, aw as AIRateLimitStore, ax as AIThread, ay as AIToolContext, az as AIToolDefinition, aA as AI_ACTIONS_COLLECTION, aB as AI_AUDIT_COLLECTION, aC as AI_CHUNKS_COLLECTION, aD as AI_MESSAGES_COLLECTION, aE as AI_THREADS_COLLECTION, aF as AccessConfig, aG as AccessFunction, aH as AccessFunctionArgs, aI as AccessResult, aJ as AccessRule, aK as ActionConfig, aL as ActionConfigBase, aM as ActionConfigWithHandler, aN as ActionConfigWithMutation, aO as ActionContext, aP as ActionType, aQ as AdminAuthAccessResolution, aR as AdminAuthClaimMapping, aS as AdminAuthMember, aT as AdminAuthProvider, aU as AdminAuthProviderMembersConfig, aV as AdminAuthProvisioningMode, aW as AdminAuthResolveAccessArgs, aX as AdminAuthResolvedIdentity, aY as AdminConfig, aZ as AdminDashboardComponentSlots, a_ as AdminIconName, a$ as AggregateArgs, b0 as AggregateCastType, b1 as AggregateCollectionResult, b2 as AggregateInput, b3 as AggregateOperation, b4 as AggregateResult, b5 as BaseAdminAuthProvider, b6 as BaseFieldAdmin, b7 as BlockVariant, b8 as BlocksField, b9 as BooleanFieldAdmin, ba as BooleanFormat, bb as CURRENT_NAV_PREFERENCES_VERSION, bc as CalendarViewConfig, bd as CardsViewConfig, be as CharacterLimitFieldAdmin, bf as CharacterLimitFieldConfig, bg as CollectionAfterChangeHook, bh as CollectionAfterDeleteHook, bi as CollectionAfterReadHook, bj as CollectionAfterReadHookEntry, bk as CollectionAfterTransitionHook, bl as CollectionBeforeChangeHook, bm as CollectionBeforeChangeHookEntry, bn as CollectionBeforeCommitHook, bo as CollectionBeforeDeleteHook, bp as CollectionBeforeReadHook, bq as CollectionBeforeReadHookEntry, br as CollectionBeforeTransitionHook, bs as CollectionIndex, bt as CollectionListComponentSlots, bu as CollectionRAGConfig, bv as CollectionSchemaResult, bw as CollectionSummaryResult, bx as CollectionViewComponentSlots, by as CompiledNavGroup, bz as CountOperation, bA as CustomAdminAuthProvider, bB as DEFAULT_USER_NAV_PREFERENCES, bC as DateFieldAdmin, bD as DateFormat, bE as DefaultValueContext, bF as DefineActionOptions, bG as DefineCalendarViewOptions, bH as DefineCardsViewOptions, bI as DefineGanttViewOptions, bJ as DefineKanbanViewOptions, bK as DefineTableViewOptions, bL as DefineViewBaseOptions, bM as DefineViewOptions, bN as DetailSpan, bO as DisplayTone, bP as DisplayVariant, bQ as DistinctCountOperation, bR as DistinctValuesOperation, bS as DynamicOptionItem, bT as DynamicOptionsConfig, bU as DynamicOptionsResolver, bV as DynamicOptionsResolverArgs, bW as DyrectedAIContext, bX as DyrectedLoggerConfig, bY as DyrectedObservabilityConfig, bZ as EmailFieldAdmin, b_ as FieldAdminHooks, b$ as FieldAdminOnChangeHook, c0 as FieldAdminOnChangeHookArgs, c1 as FieldAdminOptionsHook, c2 as FieldAdminOptionsHookArgs, c3 as FieldAdminOptionsHookResult, c4 as FieldAfterReadHook, c5 as FieldAfterReadHookArgs, c6 as FieldBase, c7 as FieldBeforeChangeHook, c8 as FieldBeforeChangeHookArgs, c9 as FieldHook, ca as FieldHooks, cb as FileData, cc as GanttViewConfig, cd as GetDocumentResult, ce as GlobalAfterChangeHook, cf as GlobalAfterReadHook, cg as GlobalAfterReadHookEntry, ch as GlobalBeforeChangeHook, ci as GlobalBeforeChangeHookEntry, cj as GlobalBeforeReadHook, ck as GlobalBeforeReadHookEntry, cl as GlobalRAGConfig, cm as GlobalSchemaResult, cn as GlobalSummaryResult, co as HeadingLevel, cp as HookFunction, cq as IconFieldAdmin, cr as ImageService, cs as ImageTransformOptions, ct as InferAggregateResult, cu as JoinFieldAdmin, cv as JsonFieldAdmin, cw as JsonFormat, cx as KanbanViewConfig, cy as LIFECYCLE_EVENT_NAMES, cz as LifecycleEventHandler, cA as LinkFormat, cB as MetricColor, cC as MoneyFieldAdmin, cD as MoneyFieldConfig, cE as MultiSelectFieldAdmin, cF as NamedAccessPolicy, cG as NavBadgeConfig, cH as NavGroup, cI as NumberFieldAdmin, cJ as NumberFormat, cK as NumberLimitFieldAdmin, cL as NumberLimitFieldConfig, cM as NumericOperation, cN as NumericUpdateOperator, cO as OIDCAdminAuthProvider, cP as OptionFormat, cQ as PaginatedResult, cR as PinnedNavItemRef, cS as PublicAdminAuthProvider, cT as QueryCollectionResult, cU as RAGSearchResult, cV as RadioFieldAdmin, cW as RateLimitConfig, cX as ReadonlyDatabaseAdapter, cY as RichTextFeature, cZ as RichTextFieldConfig, c_ as SelectFieldAdmin, c$ as SqlWhereResult, d0 as StorageAdapter, d1 as TableViewConfig, d2 as TaskContext, d3 as TaskLogger, d4 as TaskRunStatus, d5 as TextFieldAdmin, d6 as TextFormat, d7 as TextareaFieldAdmin, d8 as TrustProxyConfig, d9 as TypedField, da as UploadConfig, db as UrlFieldAdmin, dc as UrlLinkValue, dd as ViewActionFeatures, de as ViewComponentSlots, df as ViewConfigBase, dg as ViewLayout, dh as ViewMetric, di as ViewSubMetric, dj as WhereClause, dk as WhereOperator, dl as WhereOperatorName, dm as WordLimitFieldAdmin, dn as WordLimitFieldConfig, dp as WorkflowMetadata, dq as WorkflowOnTransitionContext, dr as WorkflowOnTransitionHook, ds as WorkflowRole, dt as WorkflowState, du as WorkflowTransitionContext, dv as coerceBooleanWhere, dw as defineAction, dx as defineCalendarView, dy as defineCardsView, dz as defineGanttView, dA as defineKanbanView, dB as defineTableView, dC as defineView, dD as defineWorkspace, dE as isAICollection, dF as parseMongoWhere, dG as parseSqlWhere } from './app-x7J5BIqK.cjs';
1
+ import { F as Field, B as Block, C as CollectionConfig, D as DyrectedConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, G as GlobalConfig, a as DeclarativeHookExpression, W as WorkflowConfig, b as AuthenticatedUser, c as WorkflowTransition, L as LifecycleEventName, d as LifecycleEvent, e as DatabaseAdapter, f as BaseDocument, H as HookRequestContext, T as TaskRunResult, g as TaskConfig, h as DetailActionOptions, i as DetailAction, j as DetailComputedOptions, k as ComputedHandler, l as DetailComputed, m as DetailCustomOptions, n as DetailCustom, o as DetailDividerOptions, p as DetailDivider, q as DisplayFieldOptions, r as DetailField, s as DetailItem, t as DetailGridOptions, u as DetailGrid, v as DetailRepeatOptions, w as DetailRepeat, x as DetailSectionOptions, y as DetailSection, z as DetailTabOptions, E as DetailTab, I as DetailTabsOptions, J as DetailTabs, K as DetailTextOptions, M as DetailText, N as DetailSchema, O as DyrectedContext, Q as AIConfig, R as AIPIIConfig, S as IdStrategy, U as CompiledNavTree, V as CompiledNavItem, X as UserNavigationPreferences, Y as DefineWorkspaceOptions, Z as ViewConfig, _ as DateTimeField, $ as RelationshipField, a0 as SelectField, a1 as ArrayField, a2 as FieldType, a3 as BooleanField, a4 as AuthConfig, a5 as AccessPolicyResolver, a6 as DateField, a7 as TextField, a8 as EmailField, a9 as IconField, aa as ImageField, ab as JoinField, ac as JsonField, ad as MoneyField, ae as MultiSelectField, af as NumberField, ag as ObjectField, ah as RadioField, ai as RichTextField, aj as RowField, ak as TextareaField, al as TimeField, am as UrlField } from './app-v23fNf58.cjs';
2
+ export { an as AIAction, ao as AIActionStatus, ap as AIActionType, aq as AIAuditActionType, ar as AIAuditRecord, as as AIChunk, at as AIMessage, au as AIPIIPattern, av as AIRateLimitResult, aw as AIRateLimitStore, ax as AIThread, ay as AIToolContext, az as AIToolDefinition, aA as AI_ACTIONS_COLLECTION, aB as AI_AUDIT_COLLECTION, aC as AI_CHUNKS_COLLECTION, aD as AI_MESSAGES_COLLECTION, aE as AI_THREADS_COLLECTION, aF as AccessConfig, aG as AccessFunction, aH as AccessFunctionArgs, aI as AccessResult, aJ as AccessRule, aK as ActionConfig, aL as ActionConfigBase, aM as ActionConfigWithHandler, aN as ActionConfigWithMutation, aO as ActionContext, aP as ActionType, aQ as AdminAuthAccessResolution, aR as AdminAuthClaimMapping, aS as AdminAuthMember, aT as AdminAuthProvider, aU as AdminAuthProviderMembersConfig, aV as AdminAuthProvisioningMode, aW as AdminAuthResolveAccessArgs, aX as AdminAuthResolvedIdentity, aY as AdminConfig, aZ as AdminDashboardComponentSlots, a_ as AdminIconName, a$ as AggregateArgs, b0 as AggregateCastType, b1 as AggregateCollectionResult, b2 as AggregateInput, b3 as AggregateOperation, b4 as AggregateResult, b5 as AppTrashConfig, b6 as BaseAdminAuthProvider, b7 as BaseFieldAdmin, b8 as BlockVariant, b9 as BlocksField, ba as BooleanFieldAdmin, bb as BooleanFormat, bc as CURRENT_NAV_PREFERENCES_VERSION, bd as CalendarViewConfig, be as CardsViewConfig, bf as CharacterLimitFieldAdmin, bg as CharacterLimitFieldConfig, bh as CollectionAfterChangeHook, bi as CollectionAfterDeleteHook, bj as CollectionAfterReadHook, bk as CollectionAfterReadHookEntry, bl as CollectionAfterRestoreHook, bm as CollectionAfterTransitionHook, bn as CollectionAfterTrashHook, bo as CollectionBeforeChangeHook, bp as CollectionBeforeChangeHookEntry, bq as CollectionBeforeCommitHook, br as CollectionBeforeDeleteHook, bs as CollectionBeforeReadHook, bt as CollectionBeforeReadHookEntry, bu as CollectionBeforeRestoreHook, bv as CollectionBeforeTransitionHook, bw as CollectionBeforeTrashHook, bx as CollectionEmailConfig, by as CollectionIndex, bz as CollectionListComponentSlots, bA as CollectionRAGConfig, bB as CollectionSchemaResult, bC as CollectionSummaryResult, bD as CollectionViewComponentSlots, bE as CompiledNavGroup, bF as CountOperation, bG as CustomAdminAuthProvider, bH as DEFAULT_USER_NAV_PREFERENCES, bI as DateFieldAdmin, bJ as DateFormat, bK as DefaultValueContext, bL as DefineActionOptions, bM as DefineCalendarViewOptions, bN as DefineCardsViewOptions, bO as DefineGanttViewOptions, bP as DefineKanbanViewOptions, bQ as DefineTableViewOptions, bR as DefineViewBaseOptions, bS as DefineViewOptions, bT as DetailSpan, bU as DisplayTone, bV as DisplayVariant, bW as DistinctCountOperation, bX as DistinctValuesOperation, bY as DynamicOptionItem, bZ as DynamicOptionsConfig, b_ as DynamicOptionsResolver, b$ as DynamicOptionsResolverArgs, c0 as DyrectedAIContext, c1 as DyrectedLoggerConfig, c2 as DyrectedObservabilityConfig, c3 as EmailFieldAdmin, c4 as EmailTemplateArgs, c5 as EmailTemplateResult, c6 as FieldAdminHooks, c7 as FieldAdminOnChangeHook, c8 as FieldAdminOnChangeHookArgs, c9 as FieldAdminOptionsHook, ca as FieldAdminOptionsHookArgs, cb as FieldAdminOptionsHookResult, cc as FieldAfterReadHook, cd as FieldAfterReadHookArgs, ce as FieldBase, cf as FieldBeforeChangeHook, cg as FieldBeforeChangeHookArgs, ch as FieldHook, ci as FieldHooks, cj as FileData, ck as GanttViewConfig, cl as GetDocumentResult, cm as GlobalAfterChangeHook, cn as GlobalAfterReadHook, co as GlobalAfterReadHookEntry, cp as GlobalBeforeChangeHook, cq as GlobalBeforeChangeHookEntry, cr as GlobalBeforeReadHook, cs as GlobalBeforeReadHookEntry, ct as GlobalRAGConfig, cu as GlobalSchemaResult, cv as GlobalSummaryResult, cw as HeadingLevel, cx as HookFunction, cy as IconFieldAdmin, cz as ImageService, cA as ImageTransformOptions, cB as InferAggregateResult, cC as JoinFieldAdmin, cD as JsonFieldAdmin, cE as JsonFormat, cF as KanbanViewConfig, cG as LIFECYCLE_EVENT_NAMES, cH as LifecycleEventHandler, cI as LinkFormat, cJ as MetricColor, cK as MoneyFieldAdmin, cL as MoneyFieldConfig, cM as MultiSelectFieldAdmin, cN as NamedAccessPolicy, cO as NavBadgeConfig, cP as NavGroup, cQ as NumberFieldAdmin, cR as NumberFormat, cS as NumberLimitFieldAdmin, cT as NumberLimitFieldConfig, cU as NumericOperation, cV as NumericUpdateOperator, cW as OIDCAdminAuthProvider, cX as OptionFormat, cY as OutboundEmail, cZ as PaginatedResult, c_ as PinnedNavItemRef, c$ as PublicAdminAuthProvider, d0 as QueryCollectionResult, d1 as RAGSearchResult, d2 as RadioFieldAdmin, d3 as RateLimitConfig, d4 as ReadonlyDatabaseAdapter, d5 as RichTextFeature, d6 as RichTextFieldConfig, d7 as SelectFieldAdmin, d8 as SqlWhereResult, d9 as StorageAdapter, da as TableViewConfig, db as TaskContext, dc as TaskLogger, dd as TaskRunStatus, de as TextFieldAdmin, df as TextFormat, dg as TextareaFieldAdmin, dh as TrashConfig, di as TrustProxyConfig, dj as TypedField, dk as UploadConfig, dl as UrlFieldAdmin, dm as UrlLinkValue, dn as ViewActionFeatures, dp as ViewComponentSlots, dq as ViewConfigBase, dr as ViewLayout, ds as ViewMetric, dt as ViewSubMetric, du as WhereClause, dv as WhereOperator, dw as WhereOperatorName, dx as WordLimitFieldAdmin, dy as WordLimitFieldConfig, dz as WorkflowMetadata, dA as WorkflowOnTransitionContext, dB as WorkflowOnTransitionHook, dC as WorkflowRole, dD as WorkflowState, dE as WorkflowTransitionContext, dF as coerceBooleanWhere, dG as defineAction, dH as defineCalendarView, dI as defineCardsView, dJ as defineGanttView, dK as defineKanbanView, dL as defineTableView, dM as defineView, dN as defineWorkspace, dO as isAICollection, dP as parseMongoWhere, dQ as parseSqlWhere } from './app-v23fNf58.cjs';
3
3
  import jexl from 'jexl';
4
4
  import { Context } from 'hono';
5
5
  export { z } from 'zod';
@@ -17,7 +17,7 @@ type FieldValueType<F extends Field> = F["type"] extends "text" | "textarea" | "
17
17
  hasMany: true;
18
18
  } ? string[] : string : F["type"] extends "image" ? F extends {
19
19
  hasMany: true;
20
- } ? string[] : string : F["type"] extends "richText" | "json" ? Record<string, unknown> : F["type"] extends "object" ? F extends {
20
+ } ? string[] : string : F["type"] extends "richText" ? string | Record<string, unknown> : F["type"] extends "json" ? Record<string, unknown> : F["type"] extends "object" ? F extends {
21
21
  fields: infer SF extends readonly Field[];
22
22
  } ? Prettify<InferDocShape<SF>> : Record<string, unknown> : F["type"] extends "array" ? F extends {
23
23
  fields: infer SF extends readonly Field[];
@@ -133,6 +133,8 @@ declare class DyrectedAIError extends Error {
133
133
  */
134
134
  declare function asCollection<T extends CollectionConfig<any>>(config: T): T;
135
135
 
136
+ declare const EMAIL_TEMPLATES_COLLECTION_SLUG = "__email_templates";
137
+ declare const EMAIL_TEMPLATES_COLLECTION_CONFIG: CollectionConfig;
136
138
  /**
137
139
  * Normalizes the Dyrected configuration by injecting system fields
138
140
  * (createdAt, updatedAt, createdBy, updatedBy) into every collection and
@@ -150,8 +152,8 @@ declare function getAdminRoleForCollection(collection?: CollectionConfig | null)
150
152
  /**
151
153
  * Checks whether a user possesses an administrative role.
152
154
  * Considers:
153
- * 1. The collection's configured `adminRole` (e.g. 'super_admin')
154
- * 2. Standard admin roles ('admin', 'super_admin')
155
+ * 1. The collection's configured `adminRole` (e.g. 'super_admin' or 'super admin')
156
+ * 2. Standard admin roles ('admin', 'super_admin', 'super admin', 'superadmin', 'owner')
155
157
  */
156
158
  declare function isUserAdmin(user: any, collection?: CollectionConfig | null): boolean;
157
159
 
@@ -719,6 +721,11 @@ interface TaskRunner {
719
721
  }): void;
720
722
  /** Stops polling and waits for any run in progress to settle. */
721
723
  stop(): Promise<void>;
724
+ /** Lists all registered tasks with their configured cron expression. */
725
+ getTasks(): Array<{
726
+ name: string;
727
+ cron?: string;
728
+ }>;
722
729
  }
723
730
  /**
724
731
  * Creates the runner for the tasks in `config.tasks`. Coordination between
@@ -1547,6 +1554,133 @@ declare function pruneNavigationForUser(tree: CompiledNavTree, user?: any): Comp
1547
1554
  */
1548
1555
  declare function resolveAllCollectionViews(collection: CollectionConfig, config?: Partial<DyrectedConfig> | null): ViewConfig[];
1549
1556
 
1557
+ declare const TRASH_COLLECTION = "__trash";
1558
+ /**
1559
+ * Internal system collections managed directly by Dyrected engine features.
1560
+ * These should never be exposed in public API schemas or user collection navigation.
1561
+ */
1562
+ declare const INTERNAL_SYSTEM_COLLECTIONS: Set<string>;
1563
+ /**
1564
+ * Internal collection holding snapshots of trashed documents across all collections.
1565
+ */
1566
+ declare const TRASH_COLLECTION_CONFIG: CollectionConfig;
1567
+ /**
1568
+ * Deterministic primary key for a trash entry: `${collection}:${docId}`.
1569
+ */
1570
+ declare function getTrashEntryId(collection: string, docId: string): string;
1571
+ interface ResolvedTrashConfig {
1572
+ enabled: boolean;
1573
+ retentionDays: number | null;
1574
+ allowPermanentDelete: boolean;
1575
+ }
1576
+ /**
1577
+ * Resolves trash settings for a collection based on collection and app-level config.
1578
+ *
1579
+ * Resolution order:
1580
+ * | Collection trash | App trash.enabled | Result |
1581
+ * |---|---|---|
1582
+ * | false | any | hard delete |
1583
+ * | true / object | any | trash enabled |
1584
+ * | omitted | false | hard delete |
1585
+ * | omitted | omitted / true | trash enabled (default: 30 days retention) |
1586
+ */
1587
+ declare function resolveTrashConfig(collection: CollectionConfig, appConfig?: DyrectedConfig): ResolvedTrashConfig;
1588
+ /**
1589
+ * Validates trash configuration for app and collections.
1590
+ */
1591
+ declare function assertValidTrashInConfig(config: DyrectedConfig, source?: string): void;
1592
+ /**
1593
+ * Resolves a human-readable title for a document snapshot using collection useAsTitle.
1594
+ */
1595
+ declare function resolveDocumentTitle(collection: CollectionConfig, doc: any): string;
1596
+ /**
1597
+ * Creates the built-in purge task that automatically permanently deletes
1598
+ * expired documents from __trash.
1599
+ */
1600
+ declare function createTrashPurgeTask(config: DyrectedConfig): TaskConfig;
1601
+ interface SoftDeleteOptions {
1602
+ db: any;
1603
+ config: DyrectedConfig;
1604
+ collection: string;
1605
+ id: string;
1606
+ deletedBy?: string | null;
1607
+ }
1608
+ declare function softDeleteDocument(options: SoftDeleteOptions): Promise<{
1609
+ id: string;
1610
+ purgeAt: number | null;
1611
+ }>;
1612
+ interface RestoreDocumentOptions {
1613
+ db: any;
1614
+ config: DyrectedConfig;
1615
+ collection: string;
1616
+ trashId: string;
1617
+ overrides?: Record<string, unknown>;
1618
+ }
1619
+ declare function restoreDocument(options: RestoreDocumentOptions): Promise<{
1620
+ restoredDoc: any;
1621
+ }>;
1622
+
1623
+ declare const emailTokens: {
1624
+ readonly colors: {
1625
+ readonly canvas: "#f6f7f2";
1626
+ readonly surface: "#ffffff";
1627
+ readonly text: "#171717";
1628
+ readonly muted: "#62665b";
1629
+ readonly subtle: "#8a8f82";
1630
+ readonly border: "#dde0d7";
1631
+ readonly accent: "#b6ff2e";
1632
+ readonly code: "#f1f3ec";
1633
+ readonly codeBorder: "#e2e5dc";
1634
+ readonly dangerSurface: "#fff2f0";
1635
+ readonly dangerBorder: "#ffc9c2";
1636
+ readonly dangerText: "#9f251b";
1637
+ };
1638
+ readonly font: "Arial, 'Helvetica Neue', Helvetica, sans-serif";
1639
+ readonly mono: "'Courier New', Courier, monospace";
1640
+ readonly radius: {
1641
+ readonly card: "12px";
1642
+ readonly control: "6px";
1643
+ };
1644
+ readonly width: "600px";
1645
+ };
1646
+ declare function escapeHtml(value: string): string;
1647
+ declare function heading(content: string): string;
1648
+ declare function paragraph(content: string, margin?: string, size?: string): string;
1649
+ declare function sectionLabel(content: string): string;
1650
+ declare function divider(): string;
1651
+ declare function spacer(height?: number): string;
1652
+ declare function row(content: string, cellStyle?: string): string;
1653
+ declare function table(content: string, style?: string): string;
1654
+ declare function detailBox(content: string, monospace?: boolean): string;
1655
+ declare function eventList(events: ReadonlyArray<{
1656
+ label: string;
1657
+ value: string;
1658
+ }>): string;
1659
+ declare function ctaButton(label: string, href: string): string;
1660
+ declare function safeLinkDetailBox(href: string): string;
1661
+ declare function alertBox(content: string): string;
1662
+ type TemplateBlock = string | false | null | undefined;
1663
+ interface LayoutOptions {
1664
+ preheader: string;
1665
+ title: string;
1666
+ content: string | (TemplateBlock | TemplateBlock[])[];
1667
+ footer: string | (TemplateBlock | TemplateBlock[])[];
1668
+ siteName?: string;
1669
+ }
1670
+ declare function resolveBlocks(input: string | (TemplateBlock | TemplateBlock[])[]): string;
1671
+ declare function layout({ preheader, title, content, footer, siteName }: LayoutOptions): string;
1672
+ /**
1673
+ * Returns the canonical, bulletproof Dyrected HTML email template
1674
+ * for a specific auth purpose (invite, resetPassword, welcome, passwordChanged).
1675
+ * Formatted using responsive tables and inline styles tested across Gmail, Apple Mail, Outlook, and mobile clients.
1676
+ */
1677
+ declare function getDefaultEmailTemplate(purpose: "invite" | "resetPassword" | "welcome" | "passwordChanged" | string, options?: {
1678
+ siteName?: string;
1679
+ }): {
1680
+ subject: string;
1681
+ rawHtml: string;
1682
+ };
1683
+
1550
1684
  type TopLevelFieldName<TFields extends readonly Field[]> = Extract<TFields[number], {
1551
1685
  name: string;
1552
1686
  }>["name"];
@@ -1970,9 +2104,12 @@ declare const _defineJoinFieldBase: <const T extends Omit<JoinField, "type">>(fi
1970
2104
  * })
1971
2105
  * ```
1972
2106
  */
1973
- declare function defineRelationshipField<TValidSlugs extends string = string>(config: Omit<Omit<Parameters<typeof _defineRelationshipFieldBase>[0], "type">, "relationTo"> & {
2107
+ declare function defineRelationshipField<TValidSlugs extends string = string, const T extends Omit<Omit<Parameters<typeof _defineRelationshipFieldBase>[0], "type">, "relationTo"> & {
2108
+ relationTo: TValidSlugs;
2109
+ } = any>(config: T): T & {
2110
+ type: "relationship";
1974
2111
  relationTo: TValidSlugs;
1975
- }): RelationshipField;
2112
+ };
1976
2113
  declare function defineRelationshipField(config: Parameters<typeof _defineRelationshipFieldBase>[0]): RelationshipField;
1977
2114
  /**
1978
2115
  * Define an `image` field with automatic slug inference from your collection config.
@@ -2013,6 +2150,162 @@ declare function defineJoinField<TValidSlugs extends string = string>(config: Om
2013
2150
  collection: TValidSlugs;
2014
2151
  }): JoinField;
2015
2152
  declare function defineJoinField(config: Parameters<typeof _defineJoinFieldBase>[0]): JoinField;
2153
+ interface CreatedAtFieldOptions extends Partial<Omit<DateTimeField, "type">> {
2154
+ type?: "datetime" | "date";
2155
+ }
2156
+ /**
2157
+ * Define a `createdAt` timestamp field.
2158
+ * Defaults to `type: "datetime"`, `name: "createdAt"`, `label: "Created At"`, and `admin: { readOnly: true }`.
2159
+ *
2160
+ * @example
2161
+ * ```ts
2162
+ * defineCreatedAtField()
2163
+ * defineCreatedAtField({ name: "created_at", admin: { position: "sidebar" } })
2164
+ * ```
2165
+ */
2166
+ declare function defineCreatedAtField<const T extends CreatedAtFieldOptions = {
2167
+ name: "createdAt";
2168
+ }>(config?: T): (T extends {
2169
+ type: "date";
2170
+ } ? DateField : DateTimeField) & {
2171
+ name: T extends {
2172
+ name: infer N extends string;
2173
+ } ? N : "createdAt";
2174
+ type: T extends {
2175
+ type: infer Type extends "datetime" | "date";
2176
+ } ? Type : "datetime";
2177
+ };
2178
+ interface UpdatedAtFieldOptions extends Partial<Omit<DateTimeField, "type">> {
2179
+ type?: "datetime" | "date";
2180
+ }
2181
+ /**
2182
+ * Define an `updatedAt` timestamp field.
2183
+ * Defaults to `type: "datetime"`, `name: "updatedAt"`, `label: "Updated At"`, and `admin: { readOnly: true }`.
2184
+ *
2185
+ * @example
2186
+ * ```ts
2187
+ * defineUpdatedAtField()
2188
+ * defineUpdatedAtField({ name: "updated_at", admin: { position: "sidebar" } })
2189
+ * ```
2190
+ */
2191
+ declare function defineUpdatedAtField<const T extends UpdatedAtFieldOptions = {
2192
+ name: "updatedAt";
2193
+ }>(config?: T): (T extends {
2194
+ type: "date";
2195
+ } ? DateField : DateTimeField) & {
2196
+ name: T extends {
2197
+ name: infer N extends string;
2198
+ } ? N : "updatedAt";
2199
+ type: T extends {
2200
+ type: infer Type extends "datetime" | "date";
2201
+ } ? Type : "datetime";
2202
+ };
2203
+ interface CreatedByFieldOptions<TValidSlugs extends string = string> extends Partial<Omit<RelationshipField, "type" | "relationTo">> {
2204
+ type?: "relationship" | "text";
2205
+ relationTo?: TValidSlugs | TValidSlugs[];
2206
+ }
2207
+ /**
2208
+ * Define a `createdBy` audit user field.
2209
+ * Defaults to `type: "relationship"`, `name: "createdBy"`, `label: "Created By"`, `relationTo: "users"`, and `admin: { readOnly: true }`.
2210
+ * If `type: "text"` is specified, creates a read-only text field instead of a relationship.
2211
+ *
2212
+ * @example
2213
+ * ```ts
2214
+ * defineCreatedByField() // relationship to 'users'
2215
+ * defineCreatedByField({ relationTo: 'authors' }) // relationship to 'authors'
2216
+ * defineCreatedByField({ type: 'text' }) // text user identifier
2217
+ * ```
2218
+ */
2219
+ declare function defineCreatedByField<TValidSlugs extends string = string, const T extends CreatedByFieldOptions<TValidSlugs> = CreatedByFieldOptions<TValidSlugs>>(config?: T): (T extends {
2220
+ type: "text";
2221
+ } ? TextField : RelationshipField) & {
2222
+ name: T extends {
2223
+ name: infer N extends string;
2224
+ } ? N : "createdBy";
2225
+ type: T extends {
2226
+ type: "text";
2227
+ } ? "text" : "relationship";
2228
+ };
2229
+ interface UpdatedByFieldOptions<TValidSlugs extends string = string> extends Partial<Omit<RelationshipField, "type" | "relationTo">> {
2230
+ type?: "relationship" | "text";
2231
+ relationTo?: TValidSlugs | TValidSlugs[];
2232
+ }
2233
+ /**
2234
+ * Define an `updatedBy` audit user field.
2235
+ * Defaults to `type: "relationship"`, `name: "updatedBy"`, `label: "Updated By"`, `relationTo: "users"`, and `admin: { readOnly: true }`.
2236
+ * If `type: "text"` is specified, creates a read-only text field instead of a relationship.
2237
+ *
2238
+ * @example
2239
+ * ```ts
2240
+ * defineUpdatedByField() // relationship to 'users'
2241
+ * defineUpdatedByField({ relationTo: 'authors' }) // relationship to 'authors'
2242
+ * defineUpdatedByField({ type: 'text' }) // text user identifier
2243
+ * ```
2244
+ */
2245
+ declare function defineUpdatedByField<TValidSlugs extends string = string, const T extends UpdatedByFieldOptions<TValidSlugs> = UpdatedByFieldOptions<TValidSlugs>>(config?: T): (T extends {
2246
+ type: "text";
2247
+ } ? TextField : RelationshipField) & {
2248
+ name: T extends {
2249
+ name: infer N extends string;
2250
+ } ? N : "updatedBy";
2251
+ type: T extends {
2252
+ type: "text";
2253
+ } ? "text" : "relationship";
2254
+ };
2255
+ interface RoleOption {
2256
+ value: string;
2257
+ label: string;
2258
+ }
2259
+ interface RolesFieldOptions extends Partial<Omit<SelectField, "type" | "options">> {
2260
+ type?: "select" | "multiSelect";
2261
+ multiple?: boolean;
2262
+ hasMany?: boolean;
2263
+ roles?: readonly string[] | readonly RoleOption[];
2264
+ options?: readonly string[] | readonly RoleOption[] | SelectField["options"];
2265
+ /**
2266
+ * The role name or names authorized to update this field.
2267
+ * Defaults to `"admin"`.
2268
+ * Can be a single role (`"super-admin"`) or an array (`["owner", "super-admin"]`).
2269
+ */
2270
+ adminRole?: string | readonly string[];
2271
+ }
2272
+ /**
2273
+ * Define a `roles` authorization field on an auth or users collection.
2274
+ * Replaces manual select/multiSelect field boilerplate with built-in role options,
2275
+ * safe non-self-elevation update access control, and singular/multiple mode support.
2276
+ *
2277
+ * @example
2278
+ * ```ts
2279
+ * defineRolesField() // single select with admin, editor, viewer
2280
+ * defineRoles({ multiple: true }) // multiSelect roles array
2281
+ * defineRoles({ roles: ['super-admin', 'moderator', 'member'], adminRole: 'super-admin' })
2282
+ * defineRoles({ name: 'role' }) // singular role
2283
+ * ```
2284
+ */
2285
+ declare function defineRolesField<const T extends RolesFieldOptions = {
2286
+ name: "roles";
2287
+ }>(config?: T): (T extends {
2288
+ multiple: true;
2289
+ } | {
2290
+ hasMany: true;
2291
+ } | {
2292
+ type: "multiSelect";
2293
+ } ? MultiSelectField : SelectField) & {
2294
+ name: T extends {
2295
+ name: infer N extends string;
2296
+ } ? N : "roles";
2297
+ type: T extends {
2298
+ multiple: true;
2299
+ } | {
2300
+ hasMany: true;
2301
+ } | {
2302
+ type: "multiSelect";
2303
+ } ? "multiSelect" : "select";
2304
+ };
2305
+ /**
2306
+ * Convenience alias for {@link defineRolesField}.
2307
+ */
2308
+ declare const defineRoles: typeof defineRolesField;
2016
2309
  /**
2017
2310
  * Group fields under a named tab in the Admin edit form. Tabs are presentational
2018
2311
  * only: `defineTab` returns the given fields unchanged except that each one's
@@ -2047,4 +2340,4 @@ declare function defineTab<const T extends readonly Field[]>(args: {
2047
2340
  fields: T;
2048
2341
  }): T;
2049
2342
 
2050
- export { AIConfig, type AIErrorCode, AIPIIConfig, type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BASE62_ALPHABET, BUILTIN_JEXL_HELPERS, BaseDocument, Block, BooleanField, CROCKFORD_BASE32, CollectionConfig, CompiledNavItem, CompiledNavTree, ComputedHandler, type ConfigDiagnostic, ConfigValidationError, ConflictError, DatabaseAdapter, DateField, DateTimeField, type DeclarativeAccessSurface, type DeclarativeAccessValidationIssue, type DeclarativeAdminSurface, type DeclarativeAdminValidationIssue, DeclarativeHookExpression, type DeclarativeHookSurface, type DeclarativeHookValidationIssue, type DeclarativePreviewSurface, type DeclarativePreviewValidationIssue, DefineWorkspaceOptions, DetailAction, DetailActionOptions, DetailComputed, DetailComputedOptions, DetailCustom, DetailCustomOptions, DetailDivider, DetailDividerOptions, DetailField, DetailGrid, DetailGridOptions, DetailItem, DetailRepeat, DetailRepeatOptions, DetailSchema, DetailSection, DetailSectionOptions, DetailTab, DetailTabOptions, DetailTabs, DetailTabsOptions, DetailText, DetailTextOptions, DisplayFieldOptions, DuplicateKeyError, DyrectedAIError, DyrectedConfig, DyrectedError, EmailField, type ExprFunction, type ExtractCollectionSlugs, Field, FieldConditionBuilder, FieldType, ForbiddenError, type GenerateIdOptions, GlobalConfig, HookRequestContext, IconField, IdStrategy, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MatchBuilder, MoneyField, MultiSelectField, NANOID_ALPHABET, NON_NEGOTIABLE_CREDENTIAL_FIELDS, NotFoundError, NumberField, ObjectField, PII_REGEX_PATTERNS, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RESERVED_NAVIGATION_SLUGS, RadioField, type ReconcileNavigationOptions, type ReconciledNavTree, RelationshipField, RichTextField, RowField, type SanitizeDocForAIOptions, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SystemDocFields, TASK_LOCKS_COLLECTION, TASK_LOCKS_COLLECTION_CONFIG, TaskConfig, TaskRunResult, type TaskRunner, TextField, TextareaField, TimeField, UNASSIGNED_GROUP_KEY, type UploadDocFields, UrlField, UserNavigationPreferences, ValidationError, ViewConfig, WORKFLOW_HISTORY_COLLECTION, type WhenFunction, WorkflowConfig, WorkflowTransition, abs, addDays, asCollection, assertValidAdminConditionsInConfig, assertValidDeclarativeAccessInConfig, assertValidDeclarativeHookExpression, assertValidDeclarativeHookResult, assertValidDeclarativeHooksInConfig, assertValidNavigationSlugs, assertValidPreviewUrlsInConfig, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, capitalize, ceil, clamp, coalesce, collectAdminConditionValidationIssues, collectConfigDiagnostics, collectDeclarativeAccessValidationIssues, collectDeclarativeHookValidationIssues, collectPreviewUrlValidationIssues, compact, compileNavigation, count, createLifecycleEvent, createTaskRunner, createWorkflowDocument, defaultValue, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMoneyField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTask, defineTextField, defineTextareaField, defineTimeField, defineUrlField, diffDays, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, displayAction, displayComputed, displayCustom, displayCustomComponent, displayDivider, displayField, displayGrid, displayRepeat, displaySection, displayTab, displayTabs, displayText, endsWith, evaluateDetailComputed, evaluateJexl, evaluateJexlSync, executeFieldAfterRead, executeFieldBeforeChange, expr, first, floor, formatConfigDiagnostics, formatDate, formatJexlValue, generateDefaultDetailSchema, generateDocumentId, generateId, generateOpenApi, get, getAdminAuthCollection, getAdminRoleForCollection, getAllowedSitesForUser, getPublicAdminAuthConfig, includes, initializeWorkflowDocument, isConfigValidationError, isDetailItemVisible, isEmpty, isFuture, isPast, isSiteAuthorized, isUserAdmin, join, last, length, lower, maskEmail, maskPhone, maskTextPII, materializeWorkflowDocument, max, min, nanoid, nextCronRun, normalizeConfig, normalizeDetailItem, normalizeGroupKey, now, numericFieldNames, parseCron, parseSort, pow, prefixedId, pruneNavigationForUser, publishedStateName, publishingWorkflow, readingTime, reconcileNavigation, registerJexlHelpers, replace, resolveAdminAuthCollection, resolveAllCollectionViews, resolveAuthorizedSiteId, resolveIndexName, resolvePrefix, round, runCollectionHooks, sanitizeDocForAI, saveWorkflowDraft, simplePublishingWorkflow, slugify, sqrt, startsWith, sum, today, transitionWorkflow, trim, truncate, ulid, unique, upper, uuid, validateAdminConditionExpression, validateDeclarativeAccessExpression, validateDeclarativeHookExpression, validatePreviewUrlExpression, when, wordCount, workflowCapabilities };
2343
+ export { AIConfig, type AIErrorCode, AIPIIConfig, type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BASE62_ALPHABET, BUILTIN_JEXL_HELPERS, BaseDocument, Block, BooleanField, CROCKFORD_BASE32, CollectionConfig, CompiledNavItem, CompiledNavTree, ComputedHandler, type ConfigDiagnostic, ConfigValidationError, ConflictError, type CreatedAtFieldOptions, type CreatedByFieldOptions, DatabaseAdapter, DateField, DateTimeField, type DeclarativeAccessSurface, type DeclarativeAccessValidationIssue, type DeclarativeAdminSurface, type DeclarativeAdminValidationIssue, DeclarativeHookExpression, type DeclarativeHookSurface, type DeclarativeHookValidationIssue, type DeclarativePreviewSurface, type DeclarativePreviewValidationIssue, DefineWorkspaceOptions, DetailAction, DetailActionOptions, DetailComputed, DetailComputedOptions, DetailCustom, DetailCustomOptions, DetailDivider, DetailDividerOptions, DetailField, DetailGrid, DetailGridOptions, DetailItem, DetailRepeat, DetailRepeatOptions, DetailSchema, DetailSection, DetailSectionOptions, DetailTab, DetailTabOptions, DetailTabs, DetailTabsOptions, DetailText, DetailTextOptions, DisplayFieldOptions, DuplicateKeyError, DyrectedAIError, DyrectedConfig, DyrectedError, EMAIL_TEMPLATES_COLLECTION_CONFIG, EMAIL_TEMPLATES_COLLECTION_SLUG, EmailField, type ExprFunction, type ExtractCollectionSlugs, Field, FieldConditionBuilder, FieldType, ForbiddenError, type GenerateIdOptions, GlobalConfig, HookRequestContext, INTERNAL_SYSTEM_COLLECTIONS, IconField, IdStrategy, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, type LayoutOptions, LifecycleEvent, LifecycleEventName, MatchBuilder, MoneyField, MultiSelectField, NANOID_ALPHABET, NON_NEGOTIABLE_CREDENTIAL_FIELDS, NotFoundError, NumberField, ObjectField, PII_REGEX_PATTERNS, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RESERVED_NAVIGATION_SLUGS, RadioField, type ReconcileNavigationOptions, type ReconciledNavTree, RelationshipField, type ResolvedTrashConfig, type RestoreDocumentOptions, RichTextField, type RoleOption, type RolesFieldOptions, RowField, type SanitizeDocForAIOptions, SelectField, type SoftDeleteOptions, type SortClause, type SortDirection, type SqlSortDialect, type SystemDocFields, TASK_LOCKS_COLLECTION, TASK_LOCKS_COLLECTION_CONFIG, TRASH_COLLECTION, TRASH_COLLECTION_CONFIG, TaskConfig, TaskRunResult, type TaskRunner, type TemplateBlock, TextField, TextareaField, TimeField, UNASSIGNED_GROUP_KEY, type UpdatedAtFieldOptions, type UpdatedByFieldOptions, type UploadDocFields, UrlField, UserNavigationPreferences, ValidationError, ViewConfig, WORKFLOW_HISTORY_COLLECTION, type WhenFunction, WorkflowConfig, WorkflowTransition, abs, addDays, alertBox, asCollection, assertValidAdminConditionsInConfig, assertValidDeclarativeAccessInConfig, assertValidDeclarativeHookExpression, assertValidDeclarativeHookResult, assertValidDeclarativeHooksInConfig, assertValidNavigationSlugs, assertValidPreviewUrlsInConfig, assertValidTrashInConfig, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, capitalize, ceil, clamp, coalesce, collectAdminConditionValidationIssues, collectConfigDiagnostics, collectDeclarativeAccessValidationIssues, collectDeclarativeHookValidationIssues, collectPreviewUrlValidationIssues, compact, compileNavigation, count, createLifecycleEvent, createTaskRunner, createTrashPurgeTask, createWorkflowDocument, ctaButton, defaultValue, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineCreatedAtField, defineCreatedByField, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMoneyField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRoles, defineRolesField, defineRowField, defineSelectField, defineTab, defineTask, defineTextField, defineTextareaField, defineTimeField, defineUpdatedAtField, defineUpdatedByField, defineUrlField, detailBox, diffDays, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, displayAction, displayComputed, displayCustom, displayCustomComponent, displayDivider, displayField, displayGrid, displayRepeat, displaySection, displayTab, displayTabs, displayText, divider, emailTokens, endsWith, escapeHtml, evaluateDetailComputed, evaluateJexl, evaluateJexlSync, eventList, executeFieldAfterRead, executeFieldBeforeChange, expr, first, floor, formatConfigDiagnostics, formatDate, formatJexlValue, generateDefaultDetailSchema, generateDocumentId, generateId, generateOpenApi, get, getAdminAuthCollection, getAdminRoleForCollection, getAllowedSitesForUser, getDefaultEmailTemplate, getPublicAdminAuthConfig, getTrashEntryId, heading, includes, initializeWorkflowDocument, isConfigValidationError, isDetailItemVisible, isEmpty, isFuture, isPast, isSiteAuthorized, isUserAdmin, join, last, layout, length, lower, maskEmail, maskPhone, maskTextPII, materializeWorkflowDocument, max, min, nanoid, nextCronRun, normalizeConfig, normalizeDetailItem, normalizeGroupKey, now, numericFieldNames, paragraph, parseCron, parseSort, pow, prefixedId, pruneNavigationForUser, publishedStateName, publishingWorkflow, readingTime, reconcileNavigation, registerJexlHelpers, replace, resolveAdminAuthCollection, resolveAllCollectionViews, resolveAuthorizedSiteId, resolveBlocks, resolveDocumentTitle, resolveIndexName, resolvePrefix, resolveTrashConfig, restoreDocument, round, row, runCollectionHooks, safeLinkDetailBox, sanitizeDocForAI, saveWorkflowDraft, sectionLabel, simplePublishingWorkflow, slugify, softDeleteDocument, spacer, sqrt, startsWith, sum, table, today, transitionWorkflow, trim, truncate, ulid, unique, upper, uuid, validateAdminConditionExpression, validateDeclarativeAccessExpression, validateDeclarativeHookExpression, validatePreviewUrlExpression, when, wordCount, workflowCapabilities };