@dyrected/core 2.13.4 → 2.13.6
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-phLVsEOM.d.cts} +221 -63
- package/dist/{app-De-3eNn1.d.ts → app-phLVsEOM.d.ts} +221 -63
- package/dist/index.cjs +59 -16
- package/dist/index.d.cts +139 -25
- package/dist/index.d.ts +139 -25
- package/dist/index.js +53 -16
- package/dist/server.cjs +40 -16
- package/dist/server.d.cts +15 -7
- package/dist/server.d.ts +15 -7
- package/dist/server.js +40 -16
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1801,6 +1801,7 @@ __export(index_exports, {
|
|
|
1801
1801
|
WORKFLOW_HISTORY_COLLECTION: () => WORKFLOW_HISTORY_COLLECTION,
|
|
1802
1802
|
abs: () => abs,
|
|
1803
1803
|
addDays: () => addDays,
|
|
1804
|
+
asCollection: () => asCollection,
|
|
1804
1805
|
assertValidAdminConditionsInConfig: () => assertValidAdminConditionsInConfig,
|
|
1805
1806
|
assertValidDeclarativeAccessInConfig: () => assertValidDeclarativeAccessInConfig,
|
|
1806
1807
|
assertValidDeclarativeHookExpression: () => assertValidDeclarativeHookExpression,
|
|
@@ -1829,17 +1830,21 @@ __export(index_exports, {
|
|
|
1829
1830
|
defineBlock: () => defineBlock,
|
|
1830
1831
|
defineBlocksField: () => defineBlocksField,
|
|
1831
1832
|
defineBooleanField: () => defineBooleanField,
|
|
1833
|
+
defineCalendarView: () => defineCalendarView,
|
|
1834
|
+
defineCardsView: () => defineCardsView,
|
|
1832
1835
|
defineCollection: () => defineCollection,
|
|
1833
1836
|
defineConfig: () => defineConfig,
|
|
1834
1837
|
defineDateField: () => defineDateField,
|
|
1835
1838
|
defineDateTimeField: () => defineDateTimeField,
|
|
1836
1839
|
defineEmailField: () => defineEmailField,
|
|
1837
1840
|
defineField: () => defineField,
|
|
1841
|
+
defineGanttView: () => defineGanttView,
|
|
1838
1842
|
defineGlobal: () => defineGlobal,
|
|
1839
1843
|
defineIconField: () => defineIconField,
|
|
1840
1844
|
defineImageField: () => defineImageField,
|
|
1841
1845
|
defineJoinField: () => defineJoinField,
|
|
1842
1846
|
defineJsonField: () => defineJsonField,
|
|
1847
|
+
defineKanbanView: () => defineKanbanView,
|
|
1843
1848
|
defineMultiSelectField: () => defineMultiSelectField,
|
|
1844
1849
|
defineNumberField: () => defineNumberField,
|
|
1845
1850
|
defineObjectField: () => defineObjectField,
|
|
@@ -1850,6 +1855,7 @@ __export(index_exports, {
|
|
|
1850
1855
|
defineRowField: () => defineRowField,
|
|
1851
1856
|
defineSelectField: () => defineSelectField,
|
|
1852
1857
|
defineTab: () => defineTab,
|
|
1858
|
+
defineTableView: () => defineTableView,
|
|
1853
1859
|
defineTextField: () => defineTextField,
|
|
1854
1860
|
defineTextareaField: () => defineTextareaField,
|
|
1855
1861
|
defineTimeField: () => defineTimeField,
|
|
@@ -1949,6 +1955,11 @@ __export(index_exports, {
|
|
|
1949
1955
|
});
|
|
1950
1956
|
module.exports = __toCommonJS(index_exports);
|
|
1951
1957
|
|
|
1958
|
+
// src/types/readonly-fix.ts
|
|
1959
|
+
function asCollection(config) {
|
|
1960
|
+
return config;
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1952
1963
|
// src/types/workflows.ts
|
|
1953
1964
|
var LIFECYCLE_EVENT_NAMES = [
|
|
1954
1965
|
"revision.created",
|
|
@@ -1961,6 +1972,21 @@ var LIFECYCLE_EVENT_NAMES = [
|
|
|
1961
1972
|
function defineView(config) {
|
|
1962
1973
|
return config;
|
|
1963
1974
|
}
|
|
1975
|
+
function defineTableView(config) {
|
|
1976
|
+
return config;
|
|
1977
|
+
}
|
|
1978
|
+
function defineKanbanView(config) {
|
|
1979
|
+
return config;
|
|
1980
|
+
}
|
|
1981
|
+
function defineCalendarView(config) {
|
|
1982
|
+
return config;
|
|
1983
|
+
}
|
|
1984
|
+
function defineGanttView(config) {
|
|
1985
|
+
return config;
|
|
1986
|
+
}
|
|
1987
|
+
function defineCardsView(config) {
|
|
1988
|
+
return config;
|
|
1989
|
+
}
|
|
1964
1990
|
function defineAction(config) {
|
|
1965
1991
|
return config;
|
|
1966
1992
|
}
|
|
@@ -2085,7 +2111,7 @@ function publicMetadata(meta) {
|
|
|
2085
2111
|
}
|
|
2086
2112
|
function workflowCapabilities(workflow, user) {
|
|
2087
2113
|
const capabilities = new Set(Array.isArray(user?.capabilities) ? user.capabilities : []);
|
|
2088
|
-
const roles = Array.isArray(user?.roles) ? user.roles : [];
|
|
2114
|
+
const roles = Array.isArray(user?.roles) ? user.roles : typeof user?.role === "string" ? [user.role] : [];
|
|
2089
2115
|
for (const mapping of workflow.roles ?? []) {
|
|
2090
2116
|
if (roles.includes(mapping.role)) mapping.capabilities.forEach((capability) => capabilities.add(capability));
|
|
2091
2117
|
}
|
|
@@ -2476,10 +2502,12 @@ function getAdminRoleForCollection(collection) {
|
|
|
2476
2502
|
return "admin";
|
|
2477
2503
|
}
|
|
2478
2504
|
function isUserAdmin(user, collection) {
|
|
2479
|
-
if (!user
|
|
2505
|
+
if (!user) return false;
|
|
2506
|
+
const roles = Array.isArray(user.roles) ? user.roles : typeof user.role === "string" ? [user.role] : [];
|
|
2507
|
+
if (roles.length === 0) return false;
|
|
2480
2508
|
const configuredRole = getAdminRoleForCollection(collection);
|
|
2481
|
-
if (
|
|
2482
|
-
return
|
|
2509
|
+
if (roles.includes(configuredRole)) return true;
|
|
2510
|
+
return roles.includes("admin") || roles.includes("super_admin");
|
|
2483
2511
|
}
|
|
2484
2512
|
|
|
2485
2513
|
// src/utils/block-references.ts
|
|
@@ -3705,21 +3733,21 @@ function normalizeConfig(config) {
|
|
|
3705
3733
|
}
|
|
3706
3734
|
];
|
|
3707
3735
|
}
|
|
3708
|
-
if (!existingFieldNames.has("roles")) {
|
|
3736
|
+
if (!existingFieldNames.has("roles") && !existingFieldNames.has("role")) {
|
|
3709
3737
|
fields = [
|
|
3710
3738
|
...fields,
|
|
3711
3739
|
{
|
|
3712
3740
|
name: "roles",
|
|
3713
3741
|
type: "select",
|
|
3714
3742
|
label: "Roles",
|
|
3715
|
-
defaultValue:
|
|
3743
|
+
defaultValue: "viewer",
|
|
3716
3744
|
options: [
|
|
3717
3745
|
{ value: "admin", label: "Admin" },
|
|
3718
3746
|
{ value: "editor", label: "Editor" },
|
|
3719
3747
|
{ value: "viewer", label: "Viewer" }
|
|
3720
3748
|
],
|
|
3721
3749
|
access: {
|
|
3722
|
-
update: "user.roles && 'admin' in user.roles"
|
|
3750
|
+
update: "user.role == 'admin' || (user.roles != null && 'admin' in user.roles)"
|
|
3723
3751
|
}
|
|
3724
3752
|
}
|
|
3725
3753
|
];
|
|
@@ -3737,10 +3765,10 @@ function normalizeConfig(config) {
|
|
|
3737
3765
|
{ value: "pending", label: "Pending" }
|
|
3738
3766
|
],
|
|
3739
3767
|
access: {
|
|
3740
|
-
update: "user.roles && 'admin' in user.roles && user.id != id"
|
|
3768
|
+
update: "(user.role == 'admin' || (user.roles != null && 'admin' in user.roles)) && user.id != id"
|
|
3741
3769
|
},
|
|
3742
3770
|
admin: {
|
|
3743
|
-
condition: `!(data.roles && "admin" in data.roles)`
|
|
3771
|
+
condition: `!(data.roles && "admin" in data.roles) && data.role != "admin"`
|
|
3744
3772
|
}
|
|
3745
3773
|
}
|
|
3746
3774
|
];
|
|
@@ -3774,13 +3802,13 @@ function normalizeConfig(config) {
|
|
|
3774
3802
|
}
|
|
3775
3803
|
};
|
|
3776
3804
|
}
|
|
3777
|
-
if (field.name === "roles") {
|
|
3805
|
+
if (field.name === "roles" || field.name === "role") {
|
|
3778
3806
|
return {
|
|
3779
3807
|
...field,
|
|
3780
3808
|
access: {
|
|
3781
3809
|
...field.access || {},
|
|
3782
3810
|
// Must be an admin; cannot edit own roles (no self-elevation).
|
|
3783
|
-
update: "user.roles && 'admin' in user.roles && user.id != id"
|
|
3811
|
+
update: "(user.role == 'admin' || (user.roles != null && 'admin' in user.roles)) && user.id != id"
|
|
3784
3812
|
}
|
|
3785
3813
|
};
|
|
3786
3814
|
}
|
|
@@ -3789,7 +3817,7 @@ function normalizeConfig(config) {
|
|
|
3789
3817
|
...field,
|
|
3790
3818
|
access: {
|
|
3791
3819
|
...field.access || {},
|
|
3792
|
-
update: "user.roles && 'admin' in user.roles && user.id != id"
|
|
3820
|
+
update: "(user.role == 'admin' || (user.roles != null && 'admin' in user.roles)) && user.id != id"
|
|
3793
3821
|
}
|
|
3794
3822
|
};
|
|
3795
3823
|
}
|
|
@@ -6472,7 +6500,7 @@ function sanitizeDocForAI(options) {
|
|
|
6472
6500
|
// src/index.ts
|
|
6473
6501
|
var import_zod = require("zod");
|
|
6474
6502
|
function defineCollection(config) {
|
|
6475
|
-
return config;
|
|
6503
|
+
return asCollection(config);
|
|
6476
6504
|
}
|
|
6477
6505
|
function defineGlobal(config) {
|
|
6478
6506
|
return config;
|
|
@@ -6500,17 +6528,26 @@ var defineTimeField = createFieldDefiner("time");
|
|
|
6500
6528
|
var defineSelectField = createFieldDefiner("select");
|
|
6501
6529
|
var defineMultiSelectField = createFieldDefiner("multiSelect");
|
|
6502
6530
|
var defineRadioField = createFieldDefiner("radio");
|
|
6503
|
-
var defineRelationshipField = createFieldDefiner("relationship");
|
|
6504
6531
|
var defineArrayField = createFieldDefiner("array");
|
|
6505
6532
|
var defineObjectField = createFieldDefiner("object");
|
|
6506
6533
|
var defineJsonField = createFieldDefiner("json");
|
|
6507
6534
|
var defineBlocksField = createFieldDefiner("blocks");
|
|
6508
|
-
var defineImageField = createFieldDefiner("image");
|
|
6509
6535
|
var defineEmailField = createFieldDefiner("email");
|
|
6510
6536
|
var defineUrlField = createFieldDefiner("url");
|
|
6511
6537
|
var defineIconField = createFieldDefiner("icon");
|
|
6512
|
-
var defineJoinField = createFieldDefiner("join");
|
|
6513
6538
|
var defineRowField = createFieldDefiner("row");
|
|
6539
|
+
var _defineRelationshipFieldBase = createFieldDefiner("relationship");
|
|
6540
|
+
var _defineImageFieldBase = createFieldDefiner("image");
|
|
6541
|
+
var _defineJoinFieldBase = createFieldDefiner("join");
|
|
6542
|
+
function defineRelationshipField(config) {
|
|
6543
|
+
return _defineRelationshipFieldBase(config);
|
|
6544
|
+
}
|
|
6545
|
+
function defineImageField(config) {
|
|
6546
|
+
return _defineImageFieldBase(config);
|
|
6547
|
+
}
|
|
6548
|
+
function defineJoinField(config) {
|
|
6549
|
+
return _defineJoinFieldBase(config);
|
|
6550
|
+
}
|
|
6514
6551
|
function defineTab(args) {
|
|
6515
6552
|
return args.fields.map((field) => ({
|
|
6516
6553
|
...field,
|
|
@@ -6536,6 +6573,7 @@ function defineTab(args) {
|
|
|
6536
6573
|
WORKFLOW_HISTORY_COLLECTION,
|
|
6537
6574
|
abs,
|
|
6538
6575
|
addDays,
|
|
6576
|
+
asCollection,
|
|
6539
6577
|
assertValidAdminConditionsInConfig,
|
|
6540
6578
|
assertValidDeclarativeAccessInConfig,
|
|
6541
6579
|
assertValidDeclarativeHookExpression,
|
|
@@ -6564,17 +6602,21 @@ function defineTab(args) {
|
|
|
6564
6602
|
defineBlock,
|
|
6565
6603
|
defineBlocksField,
|
|
6566
6604
|
defineBooleanField,
|
|
6605
|
+
defineCalendarView,
|
|
6606
|
+
defineCardsView,
|
|
6567
6607
|
defineCollection,
|
|
6568
6608
|
defineConfig,
|
|
6569
6609
|
defineDateField,
|
|
6570
6610
|
defineDateTimeField,
|
|
6571
6611
|
defineEmailField,
|
|
6572
6612
|
defineField,
|
|
6613
|
+
defineGanttView,
|
|
6573
6614
|
defineGlobal,
|
|
6574
6615
|
defineIconField,
|
|
6575
6616
|
defineImageField,
|
|
6576
6617
|
defineJoinField,
|
|
6577
6618
|
defineJsonField,
|
|
6619
|
+
defineKanbanView,
|
|
6578
6620
|
defineMultiSelectField,
|
|
6579
6621
|
defineNumberField,
|
|
6580
6622
|
defineObjectField,
|
|
@@ -6585,6 +6627,7 @@ function defineTab(args) {
|
|
|
6585
6627
|
defineRowField,
|
|
6586
6628
|
defineSelectField,
|
|
6587
6629
|
defineTab,
|
|
6630
|
+
defineTableView,
|
|
6588
6631
|
defineTextField,
|
|
6589
6632
|
defineTextareaField,
|
|
6590
6633
|
defineTimeField,
|
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-phLVsEOM.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-phLVsEOM.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 };
|