@dyrected/core 2.13.5 → 2.14.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/{app-De-3eNn1.d.cts → app-Cp8RudRI.d.cts} +252 -63
- package/dist/{app-De-3eNn1.d.ts → app-Cp8RudRI.d.ts} +252 -63
- package/dist/index.cjs +46 -5
- package/dist/index.d.cts +139 -25
- package/dist/index.d.ts +139 -25
- package/dist/index.js +40 -5
- package/dist/server.cjs +70 -9
- package/dist/server.d.cts +93 -3
- package/dist/server.d.ts +93 -3
- package/dist/server.js +46 -8
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as Field, B as Block,
|
|
2
|
-
export { ab as AIAction, ac as AIActionStatus, ad as AIActionType, ae as AIAuditActionType, af as AIAuditRecord, ag as AIChunk, ah as AIMessage, ai as AIPIIPattern, aj as AIRateLimitResult, ak as AIRateLimitStore, al as AIThread, am as AIToolContext, an as AIToolDefinition, ao as AI_ACTIONS_COLLECTION, ap as AI_AUDIT_COLLECTION, aq as AI_CHUNKS_COLLECTION, ar as AI_MESSAGES_COLLECTION, as as AI_THREADS_COLLECTION, at as AccessConfig, au as AccessFunction, av as AccessFunctionArgs, aw as AccessResult, ax as AccessRule, ay as ActionConfig, az as
|
|
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 BaseDocument, H as HookRequestContext, f as DetailComputedOptions, g as ComputedHandler, h as DetailComputed, i as DetailCustomOptions, j as DetailCustom, k as DetailDividerOptions, l as DetailDivider, m as DisplayFieldOptions, n as DetailField, o as DetailItem, p as DetailGridOptions, q as DetailGrid, r as DetailRepeatOptions, s as DetailRepeat, t as DetailSectionOptions, u as DetailSection, v as DetailTabOptions, w as DetailTab, x as DetailTabsOptions, y as DetailTabs, z as DetailTextOptions, E as DetailText, I as DetailSchema, J as DyrectedContext, K as AIConfig, M as AIPIIConfig, N as ArrayField, O as FieldType, Q as BooleanField, R as AuthConfig, S as AccessPolicyResolver, T as DateField, U as DateTimeField, V as EmailField, X as IconField, Y as ImageField, Z as JoinField, _ as JsonField, $ as MultiSelectField, a0 as NumberField, a1 as ObjectField, a2 as RadioField, a3 as RelationshipField, a4 as RichTextField, a5 as RowField, a6 as SelectField, a7 as TextField, a8 as TextareaField, a9 as TimeField, aa as UrlField } from './app-Cp8RudRI.cjs';
|
|
2
|
+
export { ab as AIAction, ac as AIActionStatus, ad as AIActionType, ae as AIAuditActionType, af as AIAuditRecord, ag as AIChunk, ah as AIMessage, ai as AIPIIPattern, aj as AIRateLimitResult, ak as AIRateLimitStore, al as AIThread, am as AIToolContext, an as AIToolDefinition, ao as AI_ACTIONS_COLLECTION, ap as AI_AUDIT_COLLECTION, aq as AI_CHUNKS_COLLECTION, ar as AI_MESSAGES_COLLECTION, as as AI_THREADS_COLLECTION, at as AccessConfig, au as AccessFunction, av as AccessFunctionArgs, aw as AccessResult, ax as AccessRule, ay as ActionConfig, az as ActionConfigBase, aA as ActionConfigWithHandler, aB as ActionConfigWithMutation, aC as ActionContext, aD as ActionType, aE as AdminAuthAccessResolution, aF as AdminAuthClaimMapping, aG as AdminAuthMember, aH as AdminAuthProvider, aI as AdminAuthProviderMembersConfig, aJ as AdminAuthProvisioningMode, aK as AdminAuthResolveAccessArgs, aL as AdminAuthResolvedIdentity, aM as AdminConfig, aN as AdminDashboardComponentSlots, aO as AdminIconName, aP as AggregateArgs, aQ as AggregateCastType, aR as AggregateCollectionResult, aS as AggregateInput, aT as AggregateOperation, aU as AggregateResult, aV as BaseAdminAuthProvider, aW as BaseFieldAdmin, aX as BlockVariant, aY as BlocksField, aZ as BooleanFieldAdmin, a_ as BooleanFormat, a$ as CharacterLimitFieldAdmin, b0 as CharacterLimitFieldConfig, b1 as CollectionAfterChangeHook, b2 as CollectionAfterDeleteHook, b3 as CollectionAfterReadHook, b4 as CollectionAfterReadHookEntry, b5 as CollectionAfterTransitionHook, b6 as CollectionBeforeChangeHook, b7 as CollectionBeforeChangeHookEntry, b8 as CollectionBeforeDeleteHook, b9 as CollectionBeforeReadHook, ba as CollectionBeforeReadHookEntry, bb as CollectionBeforeTransitionHook, bc as CollectionListComponentSlots, bd as CollectionRAGConfig, be as CollectionSchemaResult, bf as CollectionSummaryResult, bg as CollectionViewComponentSlots, bh as CountOperation, bi as CustomAdminAuthProvider, bj as DatabaseAdapter, bk as DateFieldAdmin, bl as DateFormat, bm as DefaultValueContext, bn as DefineActionOptions, bo as DefineCalendarViewOptions, bp as DefineCardsViewOptions, bq as DefineGanttViewOptions, br as DefineKanbanViewOptions, bs as DefineTableViewOptions, bt as DefineViewBaseOptions, bu as DefineViewOptions, bv as DetailSpan, bw as DisplayTone, bx as DisplayVariant, by as DistinctCountOperation, bz as DistinctValuesOperation, bA as DynamicOptionItem, bB as DynamicOptionsConfig, bC as DynamicOptionsResolver, bD as DynamicOptionsResolverArgs, bE as DyrectedAIContext, bF as DyrectedLoggerConfig, bG as DyrectedObservabilityConfig, bH as EmailFieldAdmin, bI as FieldAdminHooks, bJ as FieldAdminOnChangeHook, bK as FieldAdminOnChangeHookArgs, bL as FieldAdminOptionsHook, bM as FieldAdminOptionsHookArgs, bN as FieldAdminOptionsHookResult, bO as FieldAfterReadHook, bP as FieldAfterReadHookArgs, bQ as FieldBase, bR as FieldBeforeChangeHook, bS as FieldBeforeChangeHookArgs, bT as FieldHook, bU as FieldHooks, bV as FileData, bW as GetDocumentResult, bX as GlobalAfterChangeHook, bY as GlobalAfterReadHook, bZ as GlobalAfterReadHookEntry, b_ as GlobalBeforeChangeHook, b$ as GlobalBeforeChangeHookEntry, c0 as GlobalBeforeReadHook, c1 as GlobalBeforeReadHookEntry, c2 as GlobalRAGConfig, c3 as GlobalSchemaResult, c4 as GlobalSummaryResult, c5 as HeadingLevel, c6 as HookFunction, c7 as IconFieldAdmin, c8 as ImageService, c9 as ImageTransformOptions, ca as InferAggregateResult, cb as JoinFieldAdmin, cc as JsonFieldAdmin, cd as JsonFormat, ce as LIFECYCLE_EVENT_NAMES, cf as LifecycleEventHandler, cg as LinkFormat, ch as MetricColor, ci as MultiSelectFieldAdmin, cj as NamedAccessPolicy, ck as NumberFieldAdmin, cl as NumberFormat, cm as NumberLimitFieldAdmin, cn as NumberLimitFieldConfig, co as NumericOperation, cp as OIDCAdminAuthProvider, cq as OptionFormat, cr as PaginatedResult, cs as PublicAdminAuthProvider, ct as QueryCollectionResult, cu as RAGSearchResult, cv as RadioFieldAdmin, cw as RateLimitConfig, cx as ReadonlyDatabaseAdapter, cy as RichTextFeature, cz as RichTextFieldConfig, cA as SelectFieldAdmin, cB as SqlWhereResult, cC as StorageAdapter, cD as TextFieldAdmin, cE as TextFormat, cF as TextareaFieldAdmin, cG as TrustProxyConfig, cH as TypedField, cI as UploadConfig, cJ as UrlFieldAdmin, cK as UrlLinkValue, cL as ViewActionFeatures, cM as ViewComponentSlots, cN as ViewConfig, cO as ViewLayout, cP as ViewMetric, cQ as ViewSubMetric, cR as WhereClause, cS as WhereOperator, cT as WhereOperatorName, cU as WordLimitFieldAdmin, cV as WordLimitFieldConfig, cW as WorkflowMetadata, cX as WorkflowRole, cY as WorkflowState, cZ as WorkflowTransitionContext, c_ as defineAction, c$ as defineCalendarView, d0 as defineCardsView, d1 as defineGanttView, d2 as defineKanbanView, d3 as defineTableView, d4 as defineView, d5 as isAICollection, d6 as parseMongoWhere, d7 as parseSqlWhere } from './app-Cp8RudRI.cjs';
|
|
3
3
|
import jexl from 'jexl';
|
|
4
4
|
import { Context } from 'hono';
|
|
5
5
|
export { z } from 'zod';
|
|
@@ -96,6 +96,43 @@ declare class DyrectedAIError extends Error {
|
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Helper to work around TypeScript readonly inference issues with `const` collection definitions.
|
|
101
|
+
*
|
|
102
|
+
* When using `const Collection = defineCollection({...})`, TypeScript may infer all properties
|
|
103
|
+
* as readonly, which can cause type compatibility issues with the schema type system in complex
|
|
104
|
+
* nested field scenarios. This is a known TypeScript limitation with deep readonly inference.
|
|
105
|
+
*
|
|
106
|
+
* **Note**: The collection works perfectly at runtime. This is purely a type-checking limitation.
|
|
107
|
+
*
|
|
108
|
+
* Use this helper or `satisfies` when you hit type errors:
|
|
109
|
+
*
|
|
110
|
+
* Option 1: Wrap with asCollection (automatic in defineCollection):
|
|
111
|
+
* ```ts
|
|
112
|
+
* const Pages = asCollection(defineCollection({
|
|
113
|
+
* slug: "pages",
|
|
114
|
+
* fields: [...]
|
|
115
|
+
* }))
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* Option 2: Use `satisfies` pattern:
|
|
119
|
+
* ```ts
|
|
120
|
+
* const Pages = {
|
|
121
|
+
* slug: "pages",
|
|
122
|
+
* fields: [...]
|
|
123
|
+
* } satisfies CollectionConfig
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* Option 3: Use // @ts-expect-error for readonly inference only:
|
|
127
|
+
* ```ts
|
|
128
|
+
* // @ts-expect-error TypeScript readonly inference limitation with deeply nested fields
|
|
129
|
+
* const Pages = defineCollection({...})
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* The collection functions and APIs work correctly despite the type error.
|
|
133
|
+
*/
|
|
134
|
+
declare function asCollection<T extends CollectionConfig<any>>(config: T): T;
|
|
135
|
+
|
|
99
136
|
/**
|
|
100
137
|
* Normalizes the Dyrected configuration by injecting system fields
|
|
101
138
|
* (createdAt, updatedAt, createdBy, updatedBy) into every collection and
|
|
@@ -1311,24 +1348,27 @@ type TypedBlockForConfig<TBlock extends Block, TCollections extends readonly unk
|
|
|
1311
1348
|
type TypedBlocksForConfig<TBlocks extends readonly Block[], TCollections extends readonly unknown[], TRootBlocks extends readonly Block[], TPolicyNames extends string> = {
|
|
1312
1349
|
[K in keyof TBlocks]: TBlocks[K] extends Block ? TypedBlockForConfig<TBlocks[K], TCollections, TRootBlocks, TPolicyNames> : TBlocks[K];
|
|
1313
1350
|
};
|
|
1351
|
+
type MutableOmit<T, K extends PropertyKey> = {
|
|
1352
|
+
[P in keyof T as P extends K ? never : P]: T[P];
|
|
1353
|
+
};
|
|
1314
1354
|
type TypedFieldForConfig<TField extends Field, TCollections extends readonly unknown[], TBlocks extends readonly Block[], TPolicyNames extends string> = TField extends {
|
|
1315
1355
|
type: "relationship";
|
|
1316
|
-
} ?
|
|
1356
|
+
} ? MutableOmit<TField, "relationTo" | "access"> & {
|
|
1317
1357
|
relationTo?: TypedReference<PropertyType<TField, "relationTo">, CollectionSlug<TCollections>, "collection slug">;
|
|
1318
1358
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1319
1359
|
} : TField extends {
|
|
1320
1360
|
type: "image";
|
|
1321
|
-
} ?
|
|
1361
|
+
} ? MutableOmit<TField, "relationTo" | "access"> & {
|
|
1322
1362
|
relationTo?: TypedReference<PropertyType<TField, "relationTo">, UploadCollectionSlug<TCollections>, "upload collection slug">;
|
|
1323
1363
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1324
1364
|
} : TField extends {
|
|
1325
1365
|
type: "richText";
|
|
1326
|
-
} ?
|
|
1366
|
+
} ? MutableOmit<TField, "uploadCollection" | "access"> & {
|
|
1327
1367
|
uploadCollection?: TypedReference<PropertyType<TField, "uploadCollection">, UploadCollectionSlug<TCollections>, "upload collection slug">;
|
|
1328
1368
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1329
1369
|
} : TField extends {
|
|
1330
1370
|
type: "join";
|
|
1331
|
-
} ?
|
|
1371
|
+
} ? MutableOmit<TField, "collection" | "on" | "access"> & {
|
|
1332
1372
|
collection?: TypedReference<PropertyType<TField, "collection">, CollectionSlug<TCollections>, "collection slug">;
|
|
1333
1373
|
on?: TypedReference<PropertyType<TField, "on">, CollectionFieldNamesBySlug<TCollections, Extract<PropertyType<TField, "collection">, string>> | TopLevelFieldName<Extract<CollectionBySlug<TCollections, CollectionSlug<TCollections>>, {
|
|
1334
1374
|
fields: readonly Field[];
|
|
@@ -1336,30 +1376,30 @@ type TypedFieldForConfig<TField extends Field, TCollections extends readonly unk
|
|
|
1336
1376
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1337
1377
|
} : TField extends {
|
|
1338
1378
|
type: "blocks";
|
|
1339
|
-
} ?
|
|
1379
|
+
} ? MutableOmit<TField, "blocks" | "blockReferences" | "access"> & {
|
|
1340
1380
|
blocks?: TField["blocks"] extends readonly Block[] ? TypedBlocksForConfig<TField["blocks"], TCollections, TBlocks, TPolicyNames> : TField["blocks"];
|
|
1341
1381
|
blockReferences?: TypedReferenceList<PropertyType<TField, "blockReferences">, BlockSlug<TBlocks>, "block slug">;
|
|
1342
1382
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1343
1383
|
} : TField extends {
|
|
1344
1384
|
type: "array";
|
|
1345
1385
|
fields: infer TSubFields extends readonly Field[];
|
|
1346
|
-
} ?
|
|
1386
|
+
} ? MutableOmit<TField, "fields" | "access" | "admin"> & {
|
|
1347
1387
|
fields: TypedFields<TSubFields, TCollections, TBlocks, TPolicyNames>;
|
|
1348
1388
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1349
1389
|
admin?: TypedNestedFieldAdmin<TSubFields, PropertyType<TField, "admin">>;
|
|
1350
1390
|
} : TField extends {
|
|
1351
1391
|
type: "object";
|
|
1352
1392
|
fields: infer TSubFields extends readonly Field[];
|
|
1353
|
-
} ?
|
|
1393
|
+
} ? MutableOmit<TField, "fields" | "access" | "admin"> & {
|
|
1354
1394
|
fields: TypedFields<TSubFields, TCollections, TBlocks, TPolicyNames>;
|
|
1355
1395
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1356
1396
|
admin?: TypedNestedFieldAdmin<TSubFields, PropertyType<TField, "admin">>;
|
|
1357
1397
|
} : TField extends {
|
|
1358
1398
|
fields: infer TSubFields extends readonly Field[];
|
|
1359
|
-
} ?
|
|
1399
|
+
} ? MutableOmit<TField, "fields" | "access"> & {
|
|
1360
1400
|
fields: TypedFields<TSubFields, TCollections, TBlocks, TPolicyNames>;
|
|
1361
1401
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1362
|
-
} :
|
|
1402
|
+
} : MutableOmit<TField, "access"> & {
|
|
1363
1403
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1364
1404
|
};
|
|
1365
1405
|
type TypedFields<TFields extends readonly Field[], TCollections extends readonly unknown[], TBlocks extends readonly Block[], TPolicyNames extends string> = {
|
|
@@ -1527,6 +1567,10 @@ declare function defineField<const T extends Field>(field: T): T;
|
|
|
1527
1567
|
* ```
|
|
1528
1568
|
*/
|
|
1529
1569
|
declare function defineBlock<const T extends Block>(block: T): T;
|
|
1570
|
+
/** The member of the {@link Field} union that has the given `type`. */
|
|
1571
|
+
type FieldOfType<TType extends FieldType> = Extract<Field, {
|
|
1572
|
+
type: TType;
|
|
1573
|
+
}>;
|
|
1530
1574
|
/** Define a `text` field. */
|
|
1531
1575
|
declare const defineTextField: <const T extends Omit<TextField, "type">>(field: T) => T & {
|
|
1532
1576
|
type: "text";
|
|
@@ -1571,10 +1615,6 @@ declare const defineMultiSelectField: <const T extends Omit<MultiSelectField, "t
|
|
|
1571
1615
|
declare const defineRadioField: <const T extends Omit<RadioField, "type">>(field: T) => T & {
|
|
1572
1616
|
type: "radio";
|
|
1573
1617
|
};
|
|
1574
|
-
/** Define a `relationship` field. */
|
|
1575
|
-
declare const defineRelationshipField: <const T extends Omit<RelationshipField, "type">>(field: T) => T & {
|
|
1576
|
-
type: "relationship";
|
|
1577
|
-
};
|
|
1578
1618
|
/** Define an `array` field. */
|
|
1579
1619
|
declare const defineArrayField: <const T extends Omit<ArrayField, "type">>(field: T) => T & {
|
|
1580
1620
|
type: "array";
|
|
@@ -1588,13 +1628,9 @@ declare const defineJsonField: <const T extends Omit<JsonField, "type">>(field:
|
|
|
1588
1628
|
type: "json";
|
|
1589
1629
|
};
|
|
1590
1630
|
/** Define a `blocks` field. */
|
|
1591
|
-
declare const defineBlocksField: <const T extends Omit<
|
|
1631
|
+
declare const defineBlocksField: <const T extends Omit<FieldOfType<"blocks">, "type">>(field: T) => T & {
|
|
1592
1632
|
type: "blocks";
|
|
1593
1633
|
};
|
|
1594
|
-
/** Define an `image` field. */
|
|
1595
|
-
declare const defineImageField: <const T extends Omit<ImageField, "type">>(field: T) => T & {
|
|
1596
|
-
type: "image";
|
|
1597
|
-
};
|
|
1598
1634
|
/** Define an `email` field. */
|
|
1599
1635
|
declare const defineEmailField: <const T extends Omit<EmailField, "type">>(field: T) => T & {
|
|
1600
1636
|
type: "email";
|
|
@@ -1607,14 +1643,92 @@ declare const defineUrlField: <const T extends Omit<UrlField, "type">>(field: T)
|
|
|
1607
1643
|
declare const defineIconField: <const T extends Omit<IconField, "type">>(field: T) => T & {
|
|
1608
1644
|
type: "icon";
|
|
1609
1645
|
};
|
|
1610
|
-
/** Define a `join` field. */
|
|
1611
|
-
declare const defineJoinField: <const T extends Omit<JoinField, "type">>(field: T) => T & {
|
|
1612
|
-
type: "join";
|
|
1613
|
-
};
|
|
1614
1646
|
/** Define a layout-only `row` field. */
|
|
1615
1647
|
declare const defineRowField: <const T extends Omit<RowField, "type">>(field: T) => T & {
|
|
1616
1648
|
type: "row";
|
|
1617
1649
|
};
|
|
1650
|
+
/**
|
|
1651
|
+
* Extract valid collection slugs from a collection config array.
|
|
1652
|
+
* Used to type-safe `relationTo` and `collection` field properties.
|
|
1653
|
+
* @example
|
|
1654
|
+
* ```ts
|
|
1655
|
+
* type ValidSlugs = ExtractCollectionSlugs<typeof collections>;
|
|
1656
|
+
* // ValidSlugs = "posts" | "comments" | "users"
|
|
1657
|
+
* ```
|
|
1658
|
+
*/
|
|
1659
|
+
type ExtractCollectionSlugs<TCollections extends readonly CollectionConfig<any>[]> = Extract<TCollections[number], {
|
|
1660
|
+
slug: string;
|
|
1661
|
+
}>["slug"];
|
|
1662
|
+
/** Base relationship field definer (internal). */
|
|
1663
|
+
declare const _defineRelationshipFieldBase: <const T extends Omit<RelationshipField, "type">>(field: T) => T & {
|
|
1664
|
+
type: "relationship";
|
|
1665
|
+
};
|
|
1666
|
+
/** Base image field definer (internal). */
|
|
1667
|
+
declare const _defineImageFieldBase: <const T extends Omit<ImageField, "type">>(field: T) => T & {
|
|
1668
|
+
type: "image";
|
|
1669
|
+
};
|
|
1670
|
+
/** Base join field definer (internal). */
|
|
1671
|
+
declare const _defineJoinFieldBase: <const T extends Omit<JoinField, "type">>(field: T) => T & {
|
|
1672
|
+
type: "join";
|
|
1673
|
+
};
|
|
1674
|
+
/**
|
|
1675
|
+
* Define a `relationship` field with automatic slug inference from your collection config.
|
|
1676
|
+
* The `relationTo` parameter is type-checked at compile time against available collections.
|
|
1677
|
+
*
|
|
1678
|
+
* @example
|
|
1679
|
+
* ```ts
|
|
1680
|
+
* import { dyrectedSchema } from './schema';
|
|
1681
|
+
* type ValidSlugs = ExtractCollectionSlugs<typeof dyrectedSchema.collections>;
|
|
1682
|
+
*
|
|
1683
|
+
* defineRelationshipField<ValidSlugs>({
|
|
1684
|
+
* name: 'author',
|
|
1685
|
+
* relationTo: 'users', // ✅ TypeScript validates against your collections
|
|
1686
|
+
* })
|
|
1687
|
+
* ```
|
|
1688
|
+
*/
|
|
1689
|
+
declare function defineRelationshipField<TValidSlugs extends string = string>(config: Omit<Omit<Parameters<typeof _defineRelationshipFieldBase>[0], "type">, "relationTo"> & {
|
|
1690
|
+
relationTo: TValidSlugs;
|
|
1691
|
+
}): RelationshipField;
|
|
1692
|
+
declare function defineRelationshipField(config: Parameters<typeof _defineRelationshipFieldBase>[0]): RelationshipField;
|
|
1693
|
+
/**
|
|
1694
|
+
* Define an `image` field with automatic slug inference from your collection config.
|
|
1695
|
+
* The `relationTo` parameter is type-checked at compile time against available collections.
|
|
1696
|
+
*
|
|
1697
|
+
* @example
|
|
1698
|
+
* ```ts
|
|
1699
|
+
* import { dyrectedSchema } from './schema';
|
|
1700
|
+
* type ValidSlugs = ExtractCollectionSlugs<typeof dyrectedSchema.collections>;
|
|
1701
|
+
*
|
|
1702
|
+
* defineImageField<ValidSlugs>({
|
|
1703
|
+
* name: 'cover',
|
|
1704
|
+
* relationTo: 'media', // ✅ TypeScript validates against your collections
|
|
1705
|
+
* })
|
|
1706
|
+
* ```
|
|
1707
|
+
*/
|
|
1708
|
+
declare function defineImageField<TValidSlugs extends string = string>(config: Omit<Omit<Parameters<typeof _defineImageFieldBase>[0], "type">, "relationTo"> & {
|
|
1709
|
+
relationTo: TValidSlugs;
|
|
1710
|
+
}): ImageField;
|
|
1711
|
+
declare function defineImageField(config: Parameters<typeof _defineImageFieldBase>[0]): ImageField;
|
|
1712
|
+
/**
|
|
1713
|
+
* Define a `join` field with automatic slug inference from your collection config.
|
|
1714
|
+
* The `collection` parameter is type-checked at compile time against available collections.
|
|
1715
|
+
*
|
|
1716
|
+
* @example
|
|
1717
|
+
* ```ts
|
|
1718
|
+
* import { dyrectedSchema } from './schema';
|
|
1719
|
+
* type ValidSlugs = ExtractCollectionSlugs<typeof dyrectedSchema.collections>;
|
|
1720
|
+
*
|
|
1721
|
+
* defineJoinField<ValidSlugs>({
|
|
1722
|
+
* name: 'post_comments',
|
|
1723
|
+
* collection: 'posts', // ✅ TypeScript validates against your collections
|
|
1724
|
+
* on: 'comments',
|
|
1725
|
+
* })
|
|
1726
|
+
* ```
|
|
1727
|
+
*/
|
|
1728
|
+
declare function defineJoinField<TValidSlugs extends string = string>(config: Omit<Omit<Parameters<typeof _defineJoinFieldBase>[0], "type">, "collection"> & {
|
|
1729
|
+
collection: TValidSlugs;
|
|
1730
|
+
}): JoinField;
|
|
1731
|
+
declare function defineJoinField(config: Parameters<typeof _defineJoinFieldBase>[0]): JoinField;
|
|
1618
1732
|
/**
|
|
1619
1733
|
* Group fields under a named tab in the Admin edit form. Tabs are presentational
|
|
1620
1734
|
* only: `defineTab` returns the given fields unchanged except that each one's
|
|
@@ -1649,4 +1763,4 @@ declare function defineTab<const T extends readonly Field[]>(args: {
|
|
|
1649
1763
|
fields: T;
|
|
1650
1764
|
}): T;
|
|
1651
1765
|
|
|
1652
|
-
export { AIConfig, type AIErrorCode, AIPIIConfig, type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BUILTIN_JEXL_HELPERS, BaseDocument, Block,
|
|
1766
|
+
export { AIConfig, type AIErrorCode, AIPIIConfig, type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BUILTIN_JEXL_HELPERS, BaseDocument, Block, BooleanField, CollectionConfig, ComputedHandler, type ConfigDiagnostic, ConfigValidationError, DateField, DateTimeField, type DeclarativeAccessSurface, type DeclarativeAccessValidationIssue, type DeclarativeAdminSurface, type DeclarativeAdminValidationIssue, DeclarativeHookExpression, type DeclarativeHookSurface, type DeclarativeHookValidationIssue, type DeclarativePreviewSurface, type DeclarativePreviewValidationIssue, DetailComputed, DetailComputedOptions, DetailCustom, DetailCustomOptions, DetailDivider, DetailDividerOptions, DetailField, DetailGrid, DetailGridOptions, DetailItem, DetailRepeat, DetailRepeatOptions, DetailSchema, DetailSection, DetailSectionOptions, DetailTab, DetailTabOptions, DetailTabs, DetailTabsOptions, DetailText, DetailTextOptions, DisplayFieldOptions, DyrectedAIError, DyrectedConfig, EmailField, type ExprFunction, type ExtractCollectionSlugs, Field, FieldConditionBuilder, FieldType, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MatchBuilder, MultiSelectField, NON_NEGOTIABLE_CREDENTIAL_FIELDS, NumberField, ObjectField, PII_REGEX_PATTERNS, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, type SanitizeDocForAIOptions, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhenFunction, WorkflowConfig, WorkflowTransition, abs, addDays, asCollection, assertValidAdminConditionsInConfig, assertValidDeclarativeAccessInConfig, assertValidDeclarativeHookExpression, assertValidDeclarativeHookResult, assertValidDeclarativeHooksInConfig, assertValidPreviewUrlsInConfig, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, capitalize, ceil, clamp, coalesce, collectAdminConditionValidationIssues, collectConfigDiagnostics, collectDeclarativeAccessValidationIssues, collectDeclarativeHookValidationIssues, collectPreviewUrlValidationIssues, compact, count, createLifecycleEvent, createWorkflowDocument, defaultValue, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, diffDays, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, displayComputed, displayCustom, displayCustomComponent, displayDivider, displayField, displayGrid, displayRepeat, displaySection, displayTab, displayTabs, displayText, endsWith, evaluateDetailComputed, evaluateJexl, evaluateJexlSync, executeFieldAfterRead, executeFieldBeforeChange, expr, first, floor, formatConfigDiagnostics, formatDate, formatJexlValue, generateDefaultDetailSchema, 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, normalizeConfig, normalizeDetailItem, now, numericFieldNames, parseSort, pow, publishedStateName, publishingWorkflow, readingTime, registerJexlHelpers, replace, resolveAdminAuthCollection, resolveAuthorizedSiteId, round, runCollectionHooks, sanitizeDocForAI, saveWorkflowDraft, simplePublishingWorkflow, slugify, sqrt, startsWith, sum, today, transitionWorkflow, trim, truncate, unique, upper, validateAdminConditionExpression, validateDeclarativeAccessExpression, validateDeclarativeHookExpression, validatePreviewUrlExpression, when, wordCount, workflowCapabilities };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as Field, B as Block,
|
|
2
|
-
export { ab as AIAction, ac as AIActionStatus, ad as AIActionType, ae as AIAuditActionType, af as AIAuditRecord, ag as AIChunk, ah as AIMessage, ai as AIPIIPattern, aj as AIRateLimitResult, ak as AIRateLimitStore, al as AIThread, am as AIToolContext, an as AIToolDefinition, ao as AI_ACTIONS_COLLECTION, ap as AI_AUDIT_COLLECTION, aq as AI_CHUNKS_COLLECTION, ar as AI_MESSAGES_COLLECTION, as as AI_THREADS_COLLECTION, at as AccessConfig, au as AccessFunction, av as AccessFunctionArgs, aw as AccessResult, ax as AccessRule, ay as ActionConfig, az as
|
|
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 BaseDocument, H as HookRequestContext, f as DetailComputedOptions, g as ComputedHandler, h as DetailComputed, i as DetailCustomOptions, j as DetailCustom, k as DetailDividerOptions, l as DetailDivider, m as DisplayFieldOptions, n as DetailField, o as DetailItem, p as DetailGridOptions, q as DetailGrid, r as DetailRepeatOptions, s as DetailRepeat, t as DetailSectionOptions, u as DetailSection, v as DetailTabOptions, w as DetailTab, x as DetailTabsOptions, y as DetailTabs, z as DetailTextOptions, E as DetailText, I as DetailSchema, J as DyrectedContext, K as AIConfig, M as AIPIIConfig, N as ArrayField, O as FieldType, Q as BooleanField, R as AuthConfig, S as AccessPolicyResolver, T as DateField, U as DateTimeField, V as EmailField, X as IconField, Y as ImageField, Z as JoinField, _ as JsonField, $ as MultiSelectField, a0 as NumberField, a1 as ObjectField, a2 as RadioField, a3 as RelationshipField, a4 as RichTextField, a5 as RowField, a6 as SelectField, a7 as TextField, a8 as TextareaField, a9 as TimeField, aa as UrlField } from './app-Cp8RudRI.js';
|
|
2
|
+
export { ab as AIAction, ac as AIActionStatus, ad as AIActionType, ae as AIAuditActionType, af as AIAuditRecord, ag as AIChunk, ah as AIMessage, ai as AIPIIPattern, aj as AIRateLimitResult, ak as AIRateLimitStore, al as AIThread, am as AIToolContext, an as AIToolDefinition, ao as AI_ACTIONS_COLLECTION, ap as AI_AUDIT_COLLECTION, aq as AI_CHUNKS_COLLECTION, ar as AI_MESSAGES_COLLECTION, as as AI_THREADS_COLLECTION, at as AccessConfig, au as AccessFunction, av as AccessFunctionArgs, aw as AccessResult, ax as AccessRule, ay as ActionConfig, az as ActionConfigBase, aA as ActionConfigWithHandler, aB as ActionConfigWithMutation, aC as ActionContext, aD as ActionType, aE as AdminAuthAccessResolution, aF as AdminAuthClaimMapping, aG as AdminAuthMember, aH as AdminAuthProvider, aI as AdminAuthProviderMembersConfig, aJ as AdminAuthProvisioningMode, aK as AdminAuthResolveAccessArgs, aL as AdminAuthResolvedIdentity, aM as AdminConfig, aN as AdminDashboardComponentSlots, aO as AdminIconName, aP as AggregateArgs, aQ as AggregateCastType, aR as AggregateCollectionResult, aS as AggregateInput, aT as AggregateOperation, aU as AggregateResult, aV as BaseAdminAuthProvider, aW as BaseFieldAdmin, aX as BlockVariant, aY as BlocksField, aZ as BooleanFieldAdmin, a_ as BooleanFormat, a$ as CharacterLimitFieldAdmin, b0 as CharacterLimitFieldConfig, b1 as CollectionAfterChangeHook, b2 as CollectionAfterDeleteHook, b3 as CollectionAfterReadHook, b4 as CollectionAfterReadHookEntry, b5 as CollectionAfterTransitionHook, b6 as CollectionBeforeChangeHook, b7 as CollectionBeforeChangeHookEntry, b8 as CollectionBeforeDeleteHook, b9 as CollectionBeforeReadHook, ba as CollectionBeforeReadHookEntry, bb as CollectionBeforeTransitionHook, bc as CollectionListComponentSlots, bd as CollectionRAGConfig, be as CollectionSchemaResult, bf as CollectionSummaryResult, bg as CollectionViewComponentSlots, bh as CountOperation, bi as CustomAdminAuthProvider, bj as DatabaseAdapter, bk as DateFieldAdmin, bl as DateFormat, bm as DefaultValueContext, bn as DefineActionOptions, bo as DefineCalendarViewOptions, bp as DefineCardsViewOptions, bq as DefineGanttViewOptions, br as DefineKanbanViewOptions, bs as DefineTableViewOptions, bt as DefineViewBaseOptions, bu as DefineViewOptions, bv as DetailSpan, bw as DisplayTone, bx as DisplayVariant, by as DistinctCountOperation, bz as DistinctValuesOperation, bA as DynamicOptionItem, bB as DynamicOptionsConfig, bC as DynamicOptionsResolver, bD as DynamicOptionsResolverArgs, bE as DyrectedAIContext, bF as DyrectedLoggerConfig, bG as DyrectedObservabilityConfig, bH as EmailFieldAdmin, bI as FieldAdminHooks, bJ as FieldAdminOnChangeHook, bK as FieldAdminOnChangeHookArgs, bL as FieldAdminOptionsHook, bM as FieldAdminOptionsHookArgs, bN as FieldAdminOptionsHookResult, bO as FieldAfterReadHook, bP as FieldAfterReadHookArgs, bQ as FieldBase, bR as FieldBeforeChangeHook, bS as FieldBeforeChangeHookArgs, bT as FieldHook, bU as FieldHooks, bV as FileData, bW as GetDocumentResult, bX as GlobalAfterChangeHook, bY as GlobalAfterReadHook, bZ as GlobalAfterReadHookEntry, b_ as GlobalBeforeChangeHook, b$ as GlobalBeforeChangeHookEntry, c0 as GlobalBeforeReadHook, c1 as GlobalBeforeReadHookEntry, c2 as GlobalRAGConfig, c3 as GlobalSchemaResult, c4 as GlobalSummaryResult, c5 as HeadingLevel, c6 as HookFunction, c7 as IconFieldAdmin, c8 as ImageService, c9 as ImageTransformOptions, ca as InferAggregateResult, cb as JoinFieldAdmin, cc as JsonFieldAdmin, cd as JsonFormat, ce as LIFECYCLE_EVENT_NAMES, cf as LifecycleEventHandler, cg as LinkFormat, ch as MetricColor, ci as MultiSelectFieldAdmin, cj as NamedAccessPolicy, ck as NumberFieldAdmin, cl as NumberFormat, cm as NumberLimitFieldAdmin, cn as NumberLimitFieldConfig, co as NumericOperation, cp as OIDCAdminAuthProvider, cq as OptionFormat, cr as PaginatedResult, cs as PublicAdminAuthProvider, ct as QueryCollectionResult, cu as RAGSearchResult, cv as RadioFieldAdmin, cw as RateLimitConfig, cx as ReadonlyDatabaseAdapter, cy as RichTextFeature, cz as RichTextFieldConfig, cA as SelectFieldAdmin, cB as SqlWhereResult, cC as StorageAdapter, cD as TextFieldAdmin, cE as TextFormat, cF as TextareaFieldAdmin, cG as TrustProxyConfig, cH as TypedField, cI as UploadConfig, cJ as UrlFieldAdmin, cK as UrlLinkValue, cL as ViewActionFeatures, cM as ViewComponentSlots, cN as ViewConfig, cO as ViewLayout, cP as ViewMetric, cQ as ViewSubMetric, cR as WhereClause, cS as WhereOperator, cT as WhereOperatorName, cU as WordLimitFieldAdmin, cV as WordLimitFieldConfig, cW as WorkflowMetadata, cX as WorkflowRole, cY as WorkflowState, cZ as WorkflowTransitionContext, c_ as defineAction, c$ as defineCalendarView, d0 as defineCardsView, d1 as defineGanttView, d2 as defineKanbanView, d3 as defineTableView, d4 as defineView, d5 as isAICollection, d6 as parseMongoWhere, d7 as parseSqlWhere } from './app-Cp8RudRI.js';
|
|
3
3
|
import jexl from 'jexl';
|
|
4
4
|
import { Context } from 'hono';
|
|
5
5
|
export { z } from 'zod';
|
|
@@ -96,6 +96,43 @@ declare class DyrectedAIError extends Error {
|
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Helper to work around TypeScript readonly inference issues with `const` collection definitions.
|
|
101
|
+
*
|
|
102
|
+
* When using `const Collection = defineCollection({...})`, TypeScript may infer all properties
|
|
103
|
+
* as readonly, which can cause type compatibility issues with the schema type system in complex
|
|
104
|
+
* nested field scenarios. This is a known TypeScript limitation with deep readonly inference.
|
|
105
|
+
*
|
|
106
|
+
* **Note**: The collection works perfectly at runtime. This is purely a type-checking limitation.
|
|
107
|
+
*
|
|
108
|
+
* Use this helper or `satisfies` when you hit type errors:
|
|
109
|
+
*
|
|
110
|
+
* Option 1: Wrap with asCollection (automatic in defineCollection):
|
|
111
|
+
* ```ts
|
|
112
|
+
* const Pages = asCollection(defineCollection({
|
|
113
|
+
* slug: "pages",
|
|
114
|
+
* fields: [...]
|
|
115
|
+
* }))
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* Option 2: Use `satisfies` pattern:
|
|
119
|
+
* ```ts
|
|
120
|
+
* const Pages = {
|
|
121
|
+
* slug: "pages",
|
|
122
|
+
* fields: [...]
|
|
123
|
+
* } satisfies CollectionConfig
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* Option 3: Use // @ts-expect-error for readonly inference only:
|
|
127
|
+
* ```ts
|
|
128
|
+
* // @ts-expect-error TypeScript readonly inference limitation with deeply nested fields
|
|
129
|
+
* const Pages = defineCollection({...})
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* The collection functions and APIs work correctly despite the type error.
|
|
133
|
+
*/
|
|
134
|
+
declare function asCollection<T extends CollectionConfig<any>>(config: T): T;
|
|
135
|
+
|
|
99
136
|
/**
|
|
100
137
|
* Normalizes the Dyrected configuration by injecting system fields
|
|
101
138
|
* (createdAt, updatedAt, createdBy, updatedBy) into every collection and
|
|
@@ -1311,24 +1348,27 @@ type TypedBlockForConfig<TBlock extends Block, TCollections extends readonly unk
|
|
|
1311
1348
|
type TypedBlocksForConfig<TBlocks extends readonly Block[], TCollections extends readonly unknown[], TRootBlocks extends readonly Block[], TPolicyNames extends string> = {
|
|
1312
1349
|
[K in keyof TBlocks]: TBlocks[K] extends Block ? TypedBlockForConfig<TBlocks[K], TCollections, TRootBlocks, TPolicyNames> : TBlocks[K];
|
|
1313
1350
|
};
|
|
1351
|
+
type MutableOmit<T, K extends PropertyKey> = {
|
|
1352
|
+
[P in keyof T as P extends K ? never : P]: T[P];
|
|
1353
|
+
};
|
|
1314
1354
|
type TypedFieldForConfig<TField extends Field, TCollections extends readonly unknown[], TBlocks extends readonly Block[], TPolicyNames extends string> = TField extends {
|
|
1315
1355
|
type: "relationship";
|
|
1316
|
-
} ?
|
|
1356
|
+
} ? MutableOmit<TField, "relationTo" | "access"> & {
|
|
1317
1357
|
relationTo?: TypedReference<PropertyType<TField, "relationTo">, CollectionSlug<TCollections>, "collection slug">;
|
|
1318
1358
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1319
1359
|
} : TField extends {
|
|
1320
1360
|
type: "image";
|
|
1321
|
-
} ?
|
|
1361
|
+
} ? MutableOmit<TField, "relationTo" | "access"> & {
|
|
1322
1362
|
relationTo?: TypedReference<PropertyType<TField, "relationTo">, UploadCollectionSlug<TCollections>, "upload collection slug">;
|
|
1323
1363
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1324
1364
|
} : TField extends {
|
|
1325
1365
|
type: "richText";
|
|
1326
|
-
} ?
|
|
1366
|
+
} ? MutableOmit<TField, "uploadCollection" | "access"> & {
|
|
1327
1367
|
uploadCollection?: TypedReference<PropertyType<TField, "uploadCollection">, UploadCollectionSlug<TCollections>, "upload collection slug">;
|
|
1328
1368
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1329
1369
|
} : TField extends {
|
|
1330
1370
|
type: "join";
|
|
1331
|
-
} ?
|
|
1371
|
+
} ? MutableOmit<TField, "collection" | "on" | "access"> & {
|
|
1332
1372
|
collection?: TypedReference<PropertyType<TField, "collection">, CollectionSlug<TCollections>, "collection slug">;
|
|
1333
1373
|
on?: TypedReference<PropertyType<TField, "on">, CollectionFieldNamesBySlug<TCollections, Extract<PropertyType<TField, "collection">, string>> | TopLevelFieldName<Extract<CollectionBySlug<TCollections, CollectionSlug<TCollections>>, {
|
|
1334
1374
|
fields: readonly Field[];
|
|
@@ -1336,30 +1376,30 @@ type TypedFieldForConfig<TField extends Field, TCollections extends readonly unk
|
|
|
1336
1376
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1337
1377
|
} : TField extends {
|
|
1338
1378
|
type: "blocks";
|
|
1339
|
-
} ?
|
|
1379
|
+
} ? MutableOmit<TField, "blocks" | "blockReferences" | "access"> & {
|
|
1340
1380
|
blocks?: TField["blocks"] extends readonly Block[] ? TypedBlocksForConfig<TField["blocks"], TCollections, TBlocks, TPolicyNames> : TField["blocks"];
|
|
1341
1381
|
blockReferences?: TypedReferenceList<PropertyType<TField, "blockReferences">, BlockSlug<TBlocks>, "block slug">;
|
|
1342
1382
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1343
1383
|
} : TField extends {
|
|
1344
1384
|
type: "array";
|
|
1345
1385
|
fields: infer TSubFields extends readonly Field[];
|
|
1346
|
-
} ?
|
|
1386
|
+
} ? MutableOmit<TField, "fields" | "access" | "admin"> & {
|
|
1347
1387
|
fields: TypedFields<TSubFields, TCollections, TBlocks, TPolicyNames>;
|
|
1348
1388
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1349
1389
|
admin?: TypedNestedFieldAdmin<TSubFields, PropertyType<TField, "admin">>;
|
|
1350
1390
|
} : TField extends {
|
|
1351
1391
|
type: "object";
|
|
1352
1392
|
fields: infer TSubFields extends readonly Field[];
|
|
1353
|
-
} ?
|
|
1393
|
+
} ? MutableOmit<TField, "fields" | "access" | "admin"> & {
|
|
1354
1394
|
fields: TypedFields<TSubFields, TCollections, TBlocks, TPolicyNames>;
|
|
1355
1395
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1356
1396
|
admin?: TypedNestedFieldAdmin<TSubFields, PropertyType<TField, "admin">>;
|
|
1357
1397
|
} : TField extends {
|
|
1358
1398
|
fields: infer TSubFields extends readonly Field[];
|
|
1359
|
-
} ?
|
|
1399
|
+
} ? MutableOmit<TField, "fields" | "access"> & {
|
|
1360
1400
|
fields: TypedFields<TSubFields, TCollections, TBlocks, TPolicyNames>;
|
|
1361
1401
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1362
|
-
} :
|
|
1402
|
+
} : MutableOmit<TField, "access"> & {
|
|
1363
1403
|
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
1364
1404
|
};
|
|
1365
1405
|
type TypedFields<TFields extends readonly Field[], TCollections extends readonly unknown[], TBlocks extends readonly Block[], TPolicyNames extends string> = {
|
|
@@ -1527,6 +1567,10 @@ declare function defineField<const T extends Field>(field: T): T;
|
|
|
1527
1567
|
* ```
|
|
1528
1568
|
*/
|
|
1529
1569
|
declare function defineBlock<const T extends Block>(block: T): T;
|
|
1570
|
+
/** The member of the {@link Field} union that has the given `type`. */
|
|
1571
|
+
type FieldOfType<TType extends FieldType> = Extract<Field, {
|
|
1572
|
+
type: TType;
|
|
1573
|
+
}>;
|
|
1530
1574
|
/** Define a `text` field. */
|
|
1531
1575
|
declare const defineTextField: <const T extends Omit<TextField, "type">>(field: T) => T & {
|
|
1532
1576
|
type: "text";
|
|
@@ -1571,10 +1615,6 @@ declare const defineMultiSelectField: <const T extends Omit<MultiSelectField, "t
|
|
|
1571
1615
|
declare const defineRadioField: <const T extends Omit<RadioField, "type">>(field: T) => T & {
|
|
1572
1616
|
type: "radio";
|
|
1573
1617
|
};
|
|
1574
|
-
/** Define a `relationship` field. */
|
|
1575
|
-
declare const defineRelationshipField: <const T extends Omit<RelationshipField, "type">>(field: T) => T & {
|
|
1576
|
-
type: "relationship";
|
|
1577
|
-
};
|
|
1578
1618
|
/** Define an `array` field. */
|
|
1579
1619
|
declare const defineArrayField: <const T extends Omit<ArrayField, "type">>(field: T) => T & {
|
|
1580
1620
|
type: "array";
|
|
@@ -1588,13 +1628,9 @@ declare const defineJsonField: <const T extends Omit<JsonField, "type">>(field:
|
|
|
1588
1628
|
type: "json";
|
|
1589
1629
|
};
|
|
1590
1630
|
/** Define a `blocks` field. */
|
|
1591
|
-
declare const defineBlocksField: <const T extends Omit<
|
|
1631
|
+
declare const defineBlocksField: <const T extends Omit<FieldOfType<"blocks">, "type">>(field: T) => T & {
|
|
1592
1632
|
type: "blocks";
|
|
1593
1633
|
};
|
|
1594
|
-
/** Define an `image` field. */
|
|
1595
|
-
declare const defineImageField: <const T extends Omit<ImageField, "type">>(field: T) => T & {
|
|
1596
|
-
type: "image";
|
|
1597
|
-
};
|
|
1598
1634
|
/** Define an `email` field. */
|
|
1599
1635
|
declare const defineEmailField: <const T extends Omit<EmailField, "type">>(field: T) => T & {
|
|
1600
1636
|
type: "email";
|
|
@@ -1607,14 +1643,92 @@ declare const defineUrlField: <const T extends Omit<UrlField, "type">>(field: T)
|
|
|
1607
1643
|
declare const defineIconField: <const T extends Omit<IconField, "type">>(field: T) => T & {
|
|
1608
1644
|
type: "icon";
|
|
1609
1645
|
};
|
|
1610
|
-
/** Define a `join` field. */
|
|
1611
|
-
declare const defineJoinField: <const T extends Omit<JoinField, "type">>(field: T) => T & {
|
|
1612
|
-
type: "join";
|
|
1613
|
-
};
|
|
1614
1646
|
/** Define a layout-only `row` field. */
|
|
1615
1647
|
declare const defineRowField: <const T extends Omit<RowField, "type">>(field: T) => T & {
|
|
1616
1648
|
type: "row";
|
|
1617
1649
|
};
|
|
1650
|
+
/**
|
|
1651
|
+
* Extract valid collection slugs from a collection config array.
|
|
1652
|
+
* Used to type-safe `relationTo` and `collection` field properties.
|
|
1653
|
+
* @example
|
|
1654
|
+
* ```ts
|
|
1655
|
+
* type ValidSlugs = ExtractCollectionSlugs<typeof collections>;
|
|
1656
|
+
* // ValidSlugs = "posts" | "comments" | "users"
|
|
1657
|
+
* ```
|
|
1658
|
+
*/
|
|
1659
|
+
type ExtractCollectionSlugs<TCollections extends readonly CollectionConfig<any>[]> = Extract<TCollections[number], {
|
|
1660
|
+
slug: string;
|
|
1661
|
+
}>["slug"];
|
|
1662
|
+
/** Base relationship field definer (internal). */
|
|
1663
|
+
declare const _defineRelationshipFieldBase: <const T extends Omit<RelationshipField, "type">>(field: T) => T & {
|
|
1664
|
+
type: "relationship";
|
|
1665
|
+
};
|
|
1666
|
+
/** Base image field definer (internal). */
|
|
1667
|
+
declare const _defineImageFieldBase: <const T extends Omit<ImageField, "type">>(field: T) => T & {
|
|
1668
|
+
type: "image";
|
|
1669
|
+
};
|
|
1670
|
+
/** Base join field definer (internal). */
|
|
1671
|
+
declare const _defineJoinFieldBase: <const T extends Omit<JoinField, "type">>(field: T) => T & {
|
|
1672
|
+
type: "join";
|
|
1673
|
+
};
|
|
1674
|
+
/**
|
|
1675
|
+
* Define a `relationship` field with automatic slug inference from your collection config.
|
|
1676
|
+
* The `relationTo` parameter is type-checked at compile time against available collections.
|
|
1677
|
+
*
|
|
1678
|
+
* @example
|
|
1679
|
+
* ```ts
|
|
1680
|
+
* import { dyrectedSchema } from './schema';
|
|
1681
|
+
* type ValidSlugs = ExtractCollectionSlugs<typeof dyrectedSchema.collections>;
|
|
1682
|
+
*
|
|
1683
|
+
* defineRelationshipField<ValidSlugs>({
|
|
1684
|
+
* name: 'author',
|
|
1685
|
+
* relationTo: 'users', // ✅ TypeScript validates against your collections
|
|
1686
|
+
* })
|
|
1687
|
+
* ```
|
|
1688
|
+
*/
|
|
1689
|
+
declare function defineRelationshipField<TValidSlugs extends string = string>(config: Omit<Omit<Parameters<typeof _defineRelationshipFieldBase>[0], "type">, "relationTo"> & {
|
|
1690
|
+
relationTo: TValidSlugs;
|
|
1691
|
+
}): RelationshipField;
|
|
1692
|
+
declare function defineRelationshipField(config: Parameters<typeof _defineRelationshipFieldBase>[0]): RelationshipField;
|
|
1693
|
+
/**
|
|
1694
|
+
* Define an `image` field with automatic slug inference from your collection config.
|
|
1695
|
+
* The `relationTo` parameter is type-checked at compile time against available collections.
|
|
1696
|
+
*
|
|
1697
|
+
* @example
|
|
1698
|
+
* ```ts
|
|
1699
|
+
* import { dyrectedSchema } from './schema';
|
|
1700
|
+
* type ValidSlugs = ExtractCollectionSlugs<typeof dyrectedSchema.collections>;
|
|
1701
|
+
*
|
|
1702
|
+
* defineImageField<ValidSlugs>({
|
|
1703
|
+
* name: 'cover',
|
|
1704
|
+
* relationTo: 'media', // ✅ TypeScript validates against your collections
|
|
1705
|
+
* })
|
|
1706
|
+
* ```
|
|
1707
|
+
*/
|
|
1708
|
+
declare function defineImageField<TValidSlugs extends string = string>(config: Omit<Omit<Parameters<typeof _defineImageFieldBase>[0], "type">, "relationTo"> & {
|
|
1709
|
+
relationTo: TValidSlugs;
|
|
1710
|
+
}): ImageField;
|
|
1711
|
+
declare function defineImageField(config: Parameters<typeof _defineImageFieldBase>[0]): ImageField;
|
|
1712
|
+
/**
|
|
1713
|
+
* Define a `join` field with automatic slug inference from your collection config.
|
|
1714
|
+
* The `collection` parameter is type-checked at compile time against available collections.
|
|
1715
|
+
*
|
|
1716
|
+
* @example
|
|
1717
|
+
* ```ts
|
|
1718
|
+
* import { dyrectedSchema } from './schema';
|
|
1719
|
+
* type ValidSlugs = ExtractCollectionSlugs<typeof dyrectedSchema.collections>;
|
|
1720
|
+
*
|
|
1721
|
+
* defineJoinField<ValidSlugs>({
|
|
1722
|
+
* name: 'post_comments',
|
|
1723
|
+
* collection: 'posts', // ✅ TypeScript validates against your collections
|
|
1724
|
+
* on: 'comments',
|
|
1725
|
+
* })
|
|
1726
|
+
* ```
|
|
1727
|
+
*/
|
|
1728
|
+
declare function defineJoinField<TValidSlugs extends string = string>(config: Omit<Omit<Parameters<typeof _defineJoinFieldBase>[0], "type">, "collection"> & {
|
|
1729
|
+
collection: TValidSlugs;
|
|
1730
|
+
}): JoinField;
|
|
1731
|
+
declare function defineJoinField(config: Parameters<typeof _defineJoinFieldBase>[0]): JoinField;
|
|
1618
1732
|
/**
|
|
1619
1733
|
* Group fields under a named tab in the Admin edit form. Tabs are presentational
|
|
1620
1734
|
* only: `defineTab` returns the given fields unchanged except that each one's
|
|
@@ -1649,4 +1763,4 @@ declare function defineTab<const T extends readonly Field[]>(args: {
|
|
|
1649
1763
|
fields: T;
|
|
1650
1764
|
}): T;
|
|
1651
1765
|
|
|
1652
|
-
export { AIConfig, type AIErrorCode, AIPIIConfig, type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BUILTIN_JEXL_HELPERS, BaseDocument, Block,
|
|
1766
|
+
export { AIConfig, type AIErrorCode, AIPIIConfig, type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BUILTIN_JEXL_HELPERS, BaseDocument, Block, BooleanField, CollectionConfig, ComputedHandler, type ConfigDiagnostic, ConfigValidationError, DateField, DateTimeField, type DeclarativeAccessSurface, type DeclarativeAccessValidationIssue, type DeclarativeAdminSurface, type DeclarativeAdminValidationIssue, DeclarativeHookExpression, type DeclarativeHookSurface, type DeclarativeHookValidationIssue, type DeclarativePreviewSurface, type DeclarativePreviewValidationIssue, DetailComputed, DetailComputedOptions, DetailCustom, DetailCustomOptions, DetailDivider, DetailDividerOptions, DetailField, DetailGrid, DetailGridOptions, DetailItem, DetailRepeat, DetailRepeatOptions, DetailSchema, DetailSection, DetailSectionOptions, DetailTab, DetailTabOptions, DetailTabs, DetailTabsOptions, DetailText, DetailTextOptions, DisplayFieldOptions, DyrectedAIError, DyrectedConfig, EmailField, type ExprFunction, type ExtractCollectionSlugs, Field, FieldConditionBuilder, FieldType, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MatchBuilder, MultiSelectField, NON_NEGOTIABLE_CREDENTIAL_FIELDS, NumberField, ObjectField, PII_REGEX_PATTERNS, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, type SanitizeDocForAIOptions, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhenFunction, WorkflowConfig, WorkflowTransition, abs, addDays, asCollection, assertValidAdminConditionsInConfig, assertValidDeclarativeAccessInConfig, assertValidDeclarativeHookExpression, assertValidDeclarativeHookResult, assertValidDeclarativeHooksInConfig, assertValidPreviewUrlsInConfig, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, capitalize, ceil, clamp, coalesce, collectAdminConditionValidationIssues, collectConfigDiagnostics, collectDeclarativeAccessValidationIssues, collectDeclarativeHookValidationIssues, collectPreviewUrlValidationIssues, compact, count, createLifecycleEvent, createWorkflowDocument, defaultValue, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, diffDays, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, displayComputed, displayCustom, displayCustomComponent, displayDivider, displayField, displayGrid, displayRepeat, displaySection, displayTab, displayTabs, displayText, endsWith, evaluateDetailComputed, evaluateJexl, evaluateJexlSync, executeFieldAfterRead, executeFieldBeforeChange, expr, first, floor, formatConfigDiagnostics, formatDate, formatJexlValue, generateDefaultDetailSchema, 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, normalizeConfig, normalizeDetailItem, now, numericFieldNames, parseSort, pow, publishedStateName, publishingWorkflow, readingTime, registerJexlHelpers, replace, resolveAdminAuthCollection, resolveAuthorizedSiteId, round, runCollectionHooks, sanitizeDocForAI, saveWorkflowDraft, simplePublishingWorkflow, slugify, sqrt, startsWith, sum, today, transitionWorkflow, trim, truncate, unique, upper, validateAdminConditionExpression, validateDeclarativeAccessExpression, validateDeclarativeHookExpression, validatePreviewUrlExpression, when, wordCount, workflowCapabilities };
|