@dyrected/core 2.5.65 → 2.6.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-config-DbK2Tv6i.d.cts +2080 -0
- package/dist/app-config-DbK2Tv6i.d.ts +2080 -0
- package/dist/app-config-Dms6kvE-.d.cts +2072 -0
- package/dist/app-config-Dms6kvE-.d.ts +2072 -0
- package/dist/app-config-x-CnipcA.d.cts +2072 -0
- package/dist/app-config-x-CnipcA.d.ts +2072 -0
- package/dist/chunk-K3ASMUKV.js +2601 -0
- package/dist/chunk-ROECUARS.js +2615 -0
- package/dist/index.cjs +6 -14
- package/dist/index.d.cts +193 -21
- package/dist/index.d.ts +193 -21
- package/dist/index.js +1 -1
- package/dist/server.cjs +212 -20
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +207 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1557,6 +1557,12 @@ function generateOpenApi(config) {
|
|
|
1557
1557
|
schema: { type: "string" },
|
|
1558
1558
|
description: "JSON filter"
|
|
1559
1559
|
},
|
|
1560
|
+
{
|
|
1561
|
+
name: "search",
|
|
1562
|
+
in: "query",
|
|
1563
|
+
schema: { type: "string" },
|
|
1564
|
+
description: "Free-text search across configured searchable fields"
|
|
1565
|
+
},
|
|
1560
1566
|
{
|
|
1561
1567
|
name: "sort",
|
|
1562
1568
|
in: "query",
|
|
@@ -1753,13 +1759,6 @@ function generateOpenApi(config) {
|
|
|
1753
1759
|
}
|
|
1754
1760
|
};
|
|
1755
1761
|
}
|
|
1756
|
-
spec.paths[`${path}/seed`] = {
|
|
1757
|
-
post: {
|
|
1758
|
-
tags: [collectionTag],
|
|
1759
|
-
summary: `Seed initial ${labels.plural}`,
|
|
1760
|
-
responses: { 200: { description: "Seeded documents" } }
|
|
1761
|
-
}
|
|
1762
|
-
};
|
|
1763
1762
|
if (collection.upload) {
|
|
1764
1763
|
spec.paths[`${path}/media`] = {
|
|
1765
1764
|
get: {
|
|
@@ -2061,13 +2060,6 @@ function generateOpenApi(config) {
|
|
|
2061
2060
|
}
|
|
2062
2061
|
}
|
|
2063
2062
|
};
|
|
2064
|
-
spec.paths[`${path}/seed`] = {
|
|
2065
|
-
post: {
|
|
2066
|
-
tags: [globalTag],
|
|
2067
|
-
summary: `Seed ${global.label || slug}`,
|
|
2068
|
-
responses: { 200: { description: "Seeded global" } }
|
|
2069
|
-
}
|
|
2070
|
-
};
|
|
2071
2063
|
}
|
|
2072
2064
|
if (config.storage) {
|
|
2073
2065
|
spec.paths["/api/media/{filename}"] = {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as Field, B as Block, D as DyrectedConfig, C as CollectionConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, W as WorkflowConfig, a as AuthenticatedUser, b as WorkflowTransition, L as LifecycleEventName, c as LifecycleEvent, d as BaseDocument, H as HookRequestContext, e as ArrayField, f as BlocksField, g as BooleanField, h as AuthConfig, i as
|
|
2
|
-
export {
|
|
1
|
+
import { F as Field, B as Block, D as DyrectedConfig, C as CollectionConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, W as WorkflowConfig, a as AuthenticatedUser, b as WorkflowTransition, L as LifecycleEventName, c as LifecycleEvent, d as BaseDocument, H as HookRequestContext, e as ArrayField, f as BlocksField, g as BooleanField, h as AuthConfig, G as GlobalConfig, i as AccessPolicyResolver, j as DateField, k as DateTimeField, E as EmailField, I as IconField, l as ImageField, J as JoinField, m as JsonField, M as MultiSelectField, N as NumberField, O as ObjectField, R as RadioField, n as RelationshipField, o as RichTextField, p as RowField, S as SelectField, T as TextField, q as TextareaField, r as TimeField, U as UrlField } from './app-config-DbK2Tv6i.cjs';
|
|
2
|
+
export { s as AccessFunction, t as AccessFunctionArgs, u as AccessResult, v as AccessRule, w as AdminAuthAccessResolution, x as AdminAuthClaimMapping, y as AdminAuthMember, z as AdminAuthProvider, K as AdminAuthProviderMembersConfig, Q as AdminAuthProvisioningMode, V as AdminAuthResolveAccessArgs, X as AdminAuthResolvedIdentity, Y as AdminConfig, Z as AdminDashboardComponentSlots, _ as AdminIconName, $ as BaseAdminAuthProvider, a0 as BaseFieldAdmin, a1 as BlockVariant, a2 as BooleanFieldAdmin, a3 as BooleanFormat, a4 as CharacterLimitFieldAdmin, a5 as CharacterLimitFieldConfig, a6 as CollectionAfterChangeHook, a7 as CollectionAfterDeleteHook, a8 as CollectionAfterReadHook, a9 as CollectionAfterTransitionHook, aa as CollectionBeforeChangeHook, ab as CollectionBeforeDeleteHook, ac as CollectionBeforeReadHook, ad as CollectionBeforeTransitionHook, ae as CollectionListComponentSlots, af as CustomAdminAuthProvider, ag as DatabaseAdapter, ah as DateFieldAdmin, ai as DateFormat, aj as DisplayTone, ak as DynamicOptionItem, al as DynamicOptionsConfig, am as DynamicOptionsResolver, an as DynamicOptionsResolverArgs, ao as DyrectedLoggerConfig, ap as DyrectedObservabilityConfig, aq as EmailFieldAdmin, ar as FieldAdminHooks, as as FieldAdminOnChangeHook, at as FieldAdminOnChangeHookArgs, au as FieldAdminOptionsHook, av as FieldAdminOptionsHookArgs, aw as FieldAdminOptionsHookResult, ax as FieldAfterReadHook, ay as FieldAfterReadHookArgs, az as FieldBase, aA as FieldBeforeChangeHook, aB as FieldBeforeChangeHookArgs, aC as FieldHook, aD as FieldHooks, aE as FieldType, aF as FileData, aG as GlobalAfterChangeHook, aH as GlobalAfterReadHook, aI as GlobalBeforeChangeHook, aJ as GlobalBeforeReadHook, aK as HeadingLevel, aL as HookFunction, aM as IconFieldAdmin, aN as ImageService, aO as JoinFieldAdmin, aP as JsonFieldAdmin, aQ as JsonFormat, aR as LIFECYCLE_EVENT_NAMES, aS as LifecycleEventHandler, aT as LinkFormat, aU as MultiSelectFieldAdmin, aV as NamedAccessPolicy, aW as NumberFieldAdmin, aX as NumberFormat, aY as NumberLimitFieldAdmin, aZ as NumberLimitFieldConfig, a_ as OIDCAdminAuthProvider, a$ as OptionFormat, b0 as PaginatedResult, b1 as PublicAdminAuthProvider, b2 as RadioFieldAdmin, b3 as RateLimitConfig, b4 as ReadonlyDatabaseAdapter, b5 as RichTextFeature, b6 as RichTextFieldConfig, b7 as SelectFieldAdmin, b8 as StorageAdapter, b9 as TextFieldAdmin, ba as TextFormat, bb as TextareaFieldAdmin, bc as TrustProxyConfig, bd as TypedField, be as UploadConfig, bf as UrlFieldAdmin, bg as UrlLinkValue, bh as WordLimitFieldAdmin, bi as WordLimitFieldConfig, bj as WorkflowMetadata, bk as WorkflowRole, bl as WorkflowState, bm as WorkflowTransitionContext } from './app-config-DbK2Tv6i.cjs';
|
|
3
3
|
import 'lucide-react';
|
|
4
4
|
import 'pino';
|
|
5
5
|
|
|
@@ -325,6 +325,159 @@ declare function transitionWorkflow(args: {
|
|
|
325
325
|
req: HookRequestContext;
|
|
326
326
|
}): Promise<BaseDocument>;
|
|
327
327
|
|
|
328
|
+
type TopLevelFieldName<TFields extends readonly Field[]> = Extract<TFields[number], {
|
|
329
|
+
name: string;
|
|
330
|
+
}>["name"];
|
|
331
|
+
type InvalidReference<TLabel extends string, TReceived, TExpected extends string> = {
|
|
332
|
+
__dyrected_error__: `Invalid ${TLabel}`;
|
|
333
|
+
__dyrected_received__: TReceived;
|
|
334
|
+
__dyrected_expected__: TExpected;
|
|
335
|
+
};
|
|
336
|
+
type TypedReference<TValue, TExpected extends string, TLabel extends string> = TValue extends undefined ? undefined : TValue extends TExpected ? TValue : InvalidReference<TLabel, TValue, TExpected>;
|
|
337
|
+
type TypedReferenceList<TValue, TExpected extends string, TLabel extends string> = TValue extends readonly unknown[] ? {
|
|
338
|
+
[K in keyof TValue]: TypedReference<TValue[K], TExpected, TLabel>;
|
|
339
|
+
} : InvalidReference<`${TLabel} list`, TValue, TExpected>;
|
|
340
|
+
type TypedCollectionAdmin<TFields extends readonly Field[], TDoc extends object, TAdmin extends NonNullable<CollectionConfig<TDoc>["admin"]> | undefined> = Omit<NonNullable<CollectionConfig<TDoc>["admin"]>, "useAsTitle" | "defaultColumns" | "searchableFields"> & {
|
|
341
|
+
useAsTitle?: TypedReference<PropertyType<NonNullable<TAdmin>, "useAsTitle">, TopLevelFieldName<TFields>, "field name">;
|
|
342
|
+
defaultColumns?: TypedReferenceList<PropertyType<NonNullable<TAdmin>, "defaultColumns">, TopLevelFieldName<TFields>, "field name">;
|
|
343
|
+
searchableFields?: TypedReferenceList<PropertyType<NonNullable<TAdmin>, "searchableFields">, TopLevelFieldName<TFields>, "field name">;
|
|
344
|
+
};
|
|
345
|
+
type TypedNestedFieldAdmin<TFields extends readonly Field[], TAdmin extends NonNullable<Field["admin"]> | undefined> = Omit<NonNullable<Field["admin"]>, "useAsTitle"> & {
|
|
346
|
+
useAsTitle?: TypedReference<PropertyType<NonNullable<TAdmin>, "useAsTitle">, TopLevelFieldName<TFields>, "field name">;
|
|
347
|
+
};
|
|
348
|
+
type PropertyType<T, K extends PropertyKey> = T extends {
|
|
349
|
+
[P in K]?: infer V;
|
|
350
|
+
} ? V : never;
|
|
351
|
+
type PolicyNames<TPolicies> = Extract<keyof NonNullable<TPolicies>, string>;
|
|
352
|
+
type TypedPolicyReference<TPolicyNames extends string, TPolicy extends string | undefined> = {
|
|
353
|
+
policy: TypedReference<TPolicy, TPolicyNames, "policy name">;
|
|
354
|
+
params?: Record<string, unknown>;
|
|
355
|
+
};
|
|
356
|
+
type TypedAccessRule<TRule, TPolicyNames extends string> = Exclude<TRule, {
|
|
357
|
+
policy: string;
|
|
358
|
+
}> | TypedPolicyReference<TPolicyNames, Extract<PropertyType<TRule, "policy">, string>>;
|
|
359
|
+
type RetypeAccessObject<TAccess, TKeys extends PropertyKey, TPolicyNames extends string> = TAccess extends object ? Omit<TAccess, Extract<TKeys, keyof TAccess>> & {
|
|
360
|
+
[K in Extract<TKeys, keyof TAccess>]?: TypedAccessRule<PropertyType<TAccess, K>, TPolicyNames>;
|
|
361
|
+
} : TAccess;
|
|
362
|
+
type TypedFieldAccess<TAccess, TPolicyNames extends string> = RetypeAccessObject<TAccess, "read" | "create" | "update", TPolicyNames>;
|
|
363
|
+
type TypedCollectionAccess<TAccess, TPolicyNames extends string> = RetypeAccessObject<TAccess, "read" | "create" | "update" | "delete" | "readAudit", TPolicyNames>;
|
|
364
|
+
type TypedGlobalAccess<TAccess, TPolicyNames extends string> = RetypeAccessObject<TAccess, "read" | "update", TPolicyNames>;
|
|
365
|
+
type SlugOf<T> = T extends {
|
|
366
|
+
slug: infer TSlug extends string;
|
|
367
|
+
} ? TSlug : never;
|
|
368
|
+
type CollectionSlug<TCollections extends readonly unknown[]> = SlugOf<TCollections[number]>;
|
|
369
|
+
type BlockSlug<TBlocks extends readonly unknown[]> = SlugOf<TBlocks[number]>;
|
|
370
|
+
type UploadCollectionSlug<TCollections extends readonly unknown[]> = SlugOf<Extract<TCollections[number], {
|
|
371
|
+
upload: unknown;
|
|
372
|
+
}>>;
|
|
373
|
+
type AuthCollectionSlug<TCollections extends readonly unknown[]> = SlugOf<Extract<TCollections[number], {
|
|
374
|
+
auth: unknown;
|
|
375
|
+
}>>;
|
|
376
|
+
type CollectionBySlug<TCollections extends readonly unknown[], TSlug extends string> = Extract<TCollections[number], {
|
|
377
|
+
slug: TSlug;
|
|
378
|
+
}>;
|
|
379
|
+
type CollectionFieldNamesBySlug<TCollections extends readonly unknown[], TSlug extends string> = CollectionBySlug<TCollections, TSlug> extends {
|
|
380
|
+
fields: infer TFields extends readonly Field[];
|
|
381
|
+
} ? TopLevelFieldName<TFields> : never;
|
|
382
|
+
type WorkflowStateName<TWorkflow> = TWorkflow extends {
|
|
383
|
+
states: infer TStates extends readonly unknown[];
|
|
384
|
+
} ? Extract<TStates[number], {
|
|
385
|
+
name: string;
|
|
386
|
+
}>["name"] : never;
|
|
387
|
+
type TypedWorkflowStateValue<TValue, TWorkflow> = TValue extends readonly unknown[] ? {
|
|
388
|
+
[K in keyof TValue]: TypedReference<TValue[K], WorkflowStateName<TWorkflow>, "workflow state name">;
|
|
389
|
+
} : TypedReference<TValue, WorkflowStateName<TWorkflow>, "workflow state name">;
|
|
390
|
+
type TypedWorkflowTransition<TTransition, TWorkflow> = Omit<TTransition, "from" | "to"> & {
|
|
391
|
+
from: TypedWorkflowStateValue<PropertyType<TTransition, "from">, TWorkflow>;
|
|
392
|
+
to: TypedReference<PropertyType<TTransition, "to">, WorkflowStateName<TWorkflow>, "workflow state name">;
|
|
393
|
+
};
|
|
394
|
+
type TypedWorkflow<TWorkflow> = TWorkflow extends {
|
|
395
|
+
transitions: infer TTransitions extends readonly unknown[];
|
|
396
|
+
} ? Omit<TWorkflow, "initialState" | "draftState" | "transitions"> & {
|
|
397
|
+
initialState: TypedReference<PropertyType<TWorkflow, "initialState">, WorkflowStateName<TWorkflow>, "workflow state name">;
|
|
398
|
+
draftState?: TypedReference<PropertyType<TWorkflow, "draftState">, WorkflowStateName<TWorkflow>, "workflow state name">;
|
|
399
|
+
transitions: {
|
|
400
|
+
[K in keyof TTransitions]: TypedWorkflowTransition<TTransitions[K], TWorkflow>;
|
|
401
|
+
};
|
|
402
|
+
} : TWorkflow;
|
|
403
|
+
type TypedBlockForConfig<TBlock extends Block, TCollections extends readonly unknown[], TRootBlocks extends readonly Block[], TPolicyNames extends string> = Omit<TBlock, "fields"> & {
|
|
404
|
+
fields: TBlock["fields"] extends readonly Field[] ? TypedFields<TBlock["fields"], TCollections, TRootBlocks, TPolicyNames> : TBlock["fields"];
|
|
405
|
+
};
|
|
406
|
+
type TypedBlocksForConfig<TBlocks extends readonly Block[], TCollections extends readonly unknown[], TRootBlocks extends readonly Block[], TPolicyNames extends string> = {
|
|
407
|
+
[K in keyof TBlocks]: TBlocks[K] extends Block ? TypedBlockForConfig<TBlocks[K], TCollections, TRootBlocks, TPolicyNames> : TBlocks[K];
|
|
408
|
+
};
|
|
409
|
+
type TypedFieldForConfig<TField extends Field, TCollections extends readonly unknown[], TBlocks extends readonly Block[], TPolicyNames extends string> = TField extends {
|
|
410
|
+
type: "relationship";
|
|
411
|
+
} ? Omit<TField, "relationTo" | "access"> & {
|
|
412
|
+
relationTo?: TypedReference<PropertyType<TField, "relationTo">, CollectionSlug<TCollections>, "collection slug">;
|
|
413
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
414
|
+
} : TField extends {
|
|
415
|
+
type: "image";
|
|
416
|
+
} ? Omit<TField, "relationTo" | "access"> & {
|
|
417
|
+
relationTo?: TypedReference<PropertyType<TField, "relationTo">, UploadCollectionSlug<TCollections>, "upload collection slug">;
|
|
418
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
419
|
+
} : TField extends {
|
|
420
|
+
type: "richText";
|
|
421
|
+
} ? Omit<TField, "uploadCollection" | "access"> & {
|
|
422
|
+
uploadCollection?: TypedReference<PropertyType<TField, "uploadCollection">, UploadCollectionSlug<TCollections>, "upload collection slug">;
|
|
423
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
424
|
+
} : TField extends {
|
|
425
|
+
type: "join";
|
|
426
|
+
} ? Omit<TField, "collection" | "on" | "access"> & {
|
|
427
|
+
collection?: TypedReference<PropertyType<TField, "collection">, CollectionSlug<TCollections>, "collection slug">;
|
|
428
|
+
on?: TypedReference<PropertyType<TField, "on">, CollectionFieldNamesBySlug<TCollections, Extract<PropertyType<TField, "collection">, string>> | TopLevelFieldName<Extract<CollectionBySlug<TCollections, CollectionSlug<TCollections>>, {
|
|
429
|
+
fields: readonly Field[];
|
|
430
|
+
}>["fields"]>, "field name">;
|
|
431
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
432
|
+
} : TField extends {
|
|
433
|
+
type: "blocks";
|
|
434
|
+
} ? Omit<TField, "blocks" | "blockReferences" | "access"> & {
|
|
435
|
+
blocks?: TField["blocks"] extends readonly Block[] ? TypedBlocksForConfig<TField["blocks"], TCollections, TBlocks, TPolicyNames> : TField["blocks"];
|
|
436
|
+
blockReferences?: TypedReferenceList<PropertyType<TField, "blockReferences">, BlockSlug<TBlocks>, "block slug">;
|
|
437
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
438
|
+
} : TField extends {
|
|
439
|
+
type: "array";
|
|
440
|
+
fields: infer TSubFields extends readonly Field[];
|
|
441
|
+
} ? Omit<TField, "fields" | "access" | "admin"> & {
|
|
442
|
+
fields: TypedFields<TSubFields, TCollections, TBlocks, TPolicyNames>;
|
|
443
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
444
|
+
admin?: TypedNestedFieldAdmin<TSubFields, PropertyType<TField, "admin">>;
|
|
445
|
+
} : TField extends {
|
|
446
|
+
type: "object";
|
|
447
|
+
fields: infer TSubFields extends readonly Field[];
|
|
448
|
+
} ? Omit<TField, "fields" | "access" | "admin"> & {
|
|
449
|
+
fields: TypedFields<TSubFields, TCollections, TBlocks, TPolicyNames>;
|
|
450
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
451
|
+
admin?: TypedNestedFieldAdmin<TSubFields, PropertyType<TField, "admin">>;
|
|
452
|
+
} : TField extends {
|
|
453
|
+
fields: infer TSubFields extends readonly Field[];
|
|
454
|
+
} ? Omit<TField, "fields" | "access"> & {
|
|
455
|
+
fields: TypedFields<TSubFields, TCollections, TBlocks, TPolicyNames>;
|
|
456
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
457
|
+
} : Omit<TField, "access"> & {
|
|
458
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
459
|
+
};
|
|
460
|
+
type TypedFields<TFields extends readonly Field[], TCollections extends readonly unknown[], TBlocks extends readonly Block[], TPolicyNames extends string> = {
|
|
461
|
+
[K in keyof TFields]: TFields[K] extends Field ? TypedFieldForConfig<TFields[K], TCollections, TBlocks, TPolicyNames> : TFields[K];
|
|
462
|
+
};
|
|
463
|
+
type TypedCollectionForConfig<TCollection extends CollectionConfig<any>, TCollections extends readonly CollectionConfig<any>[], TBlocks extends readonly Block[], TPolicyNames extends string> = Omit<TCollection, "fields" | "access" | "workflow"> & {
|
|
464
|
+
fields: TCollection["fields"] extends readonly Field[] ? TypedFields<TCollection["fields"], TCollections, TBlocks, TPolicyNames> : TCollection["fields"];
|
|
465
|
+
access?: TypedCollectionAccess<NonNullable<TCollection["access"]>, TPolicyNames>;
|
|
466
|
+
workflow?: TypedWorkflow<NonNullable<TCollection["workflow"]>>;
|
|
467
|
+
};
|
|
468
|
+
type TypedCollections<TCollections extends readonly CollectionConfig<any>[], TAllCollections extends readonly CollectionConfig<any>[], TBlocks extends readonly Block[], TPolicyNames extends string> = {
|
|
469
|
+
[K in keyof TCollections]: TCollections[K] extends CollectionConfig<any> ? TypedCollectionForConfig<TCollections[K], TAllCollections, TBlocks, TPolicyNames> : TCollections[K];
|
|
470
|
+
};
|
|
471
|
+
type TypedGlobalForConfig<TGlobal extends GlobalConfig<any>, TCollections extends readonly CollectionConfig<any>[], TBlocks extends readonly Block[], TPolicyNames extends string> = Omit<TGlobal, "fields" | "access"> & {
|
|
472
|
+
fields: TGlobal["fields"] extends readonly Field[] ? TypedFields<TGlobal["fields"], TCollections, TBlocks, TPolicyNames> : TGlobal["fields"];
|
|
473
|
+
access?: TypedGlobalAccess<NonNullable<TGlobal["access"]>, TPolicyNames>;
|
|
474
|
+
};
|
|
475
|
+
type TypedGlobals<TGlobals extends readonly GlobalConfig<any>[], TCollections extends readonly CollectionConfig<any>[], TBlocks extends readonly Block[], TPolicyNames extends string> = {
|
|
476
|
+
[K in keyof TGlobals]: TGlobals[K] extends GlobalConfig<any> ? TypedGlobalForConfig<TGlobals[K], TCollections, TBlocks, TPolicyNames> : TGlobals[K];
|
|
477
|
+
};
|
|
478
|
+
type TypedAdminAuthConfig<TAdminAuth, TCollections extends readonly CollectionConfig<any>[]> = TAdminAuth extends object ? Omit<TAdminAuth, "collectionSlug"> & {
|
|
479
|
+
collectionSlug?: TypedReference<PropertyType<TAdminAuth, "collectionSlug">, AuthCollectionSlug<TCollections>, "auth collection slug">;
|
|
480
|
+
} : TAdminAuth;
|
|
328
481
|
/**
|
|
329
482
|
* Define a collection. When called without an explicit type argument, TypeScript
|
|
330
483
|
* automatically infers the document shape from the `fields` array you provide —
|
|
@@ -354,30 +507,42 @@ declare function transitionWorkflow(args: {
|
|
|
354
507
|
* export const Posts = defineCollection<Post>({ ... })
|
|
355
508
|
* ```
|
|
356
509
|
*/
|
|
357
|
-
declare function defineCollection<const TFields extends Field[]
|
|
510
|
+
declare function defineCollection<const TSlug extends string, const TFields extends Field[], const TAdmin extends NonNullable<CollectionConfig<Prettify<{
|
|
511
|
+
id: string;
|
|
512
|
+
} & InferDocShape<TFields> & SystemDocFields & AuthDocFields>>["admin"]> | undefined, const TConfig extends Omit<CollectionConfig<Prettify<{
|
|
358
513
|
id: string;
|
|
359
|
-
} & InferDocShape<TFields> & SystemDocFields & AuthDocFields>>, "fields" | "auth"> & {
|
|
514
|
+
} & InferDocShape<TFields> & SystemDocFields & AuthDocFields>>, "fields" | "auth" | "admin"> & {
|
|
515
|
+
slug: TSlug;
|
|
360
516
|
fields: TFields;
|
|
361
517
|
auth: true | AuthConfig;
|
|
362
|
-
|
|
518
|
+
admin?: TypedCollectionAdmin<TFields, Prettify<{
|
|
519
|
+
id: string;
|
|
520
|
+
} & InferDocShape<TFields> & SystemDocFields & AuthDocFields>, TAdmin>;
|
|
521
|
+
}>(config: TConfig): TConfig;
|
|
522
|
+
declare function defineCollection<const TSlug extends string, const TFields extends Field[], const TAdmin extends NonNullable<CollectionConfig<Prettify<{
|
|
363
523
|
id: string;
|
|
364
|
-
} & InferDocShape<TFields> & SystemDocFields &
|
|
365
|
-
declare function defineCollection<const TFields extends Field[]>(config: Omit<CollectionConfig<Prettify<{
|
|
524
|
+
} & InferDocShape<TFields> & SystemDocFields & UploadDocFields>>["admin"]> | undefined, const TConfig extends Omit<CollectionConfig<Prettify<{
|
|
366
525
|
id: string;
|
|
367
|
-
} & InferDocShape<TFields> & SystemDocFields & UploadDocFields>>, "fields" | "upload"> & {
|
|
526
|
+
} & InferDocShape<TFields> & SystemDocFields & UploadDocFields>>, "fields" | "upload" | "admin"> & {
|
|
527
|
+
slug: TSlug;
|
|
368
528
|
fields: TFields;
|
|
369
529
|
upload: true;
|
|
370
|
-
|
|
530
|
+
admin?: TypedCollectionAdmin<TFields, Prettify<{
|
|
531
|
+
id: string;
|
|
532
|
+
} & InferDocShape<TFields> & SystemDocFields & UploadDocFields>, TAdmin>;
|
|
533
|
+
}>(config: TConfig): TConfig;
|
|
534
|
+
declare function defineCollection<const TSlug extends string, const TFields extends Field[], const TAdmin extends NonNullable<CollectionConfig<Prettify<{
|
|
371
535
|
id: string;
|
|
372
|
-
} & InferDocShape<TFields> & SystemDocFields
|
|
373
|
-
declare function defineCollection<const TFields extends Field[]>(config: Omit<CollectionConfig<Prettify<{
|
|
536
|
+
} & InferDocShape<TFields> & SystemDocFields>>["admin"]> | undefined, const TConfig extends Omit<CollectionConfig<Prettify<{
|
|
374
537
|
id: string;
|
|
375
|
-
} & InferDocShape<TFields> & SystemDocFields>>, "fields"> & {
|
|
538
|
+
} & InferDocShape<TFields> & SystemDocFields>>, "fields" | "admin"> & {
|
|
539
|
+
slug: TSlug;
|
|
376
540
|
fields: TFields;
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
} & InferDocShape<TFields> & SystemDocFields
|
|
380
|
-
|
|
541
|
+
admin?: TypedCollectionAdmin<TFields, Prettify<{
|
|
542
|
+
id: string;
|
|
543
|
+
} & InferDocShape<TFields> & SystemDocFields>, TAdmin>;
|
|
544
|
+
}>(config: TConfig): TConfig;
|
|
545
|
+
declare function defineCollection<TDoc extends object, const TConfig extends CollectionConfig<TDoc>>(config: TConfig): TConfig;
|
|
381
546
|
/**
|
|
382
547
|
* Define a global (singleton document). TypeScript automatically infers the
|
|
383
548
|
* document shape from the `fields` array, or you can pass an explicit type:
|
|
@@ -403,10 +568,11 @@ declare function defineCollection<TDoc extends object>(config: CollectionConfig<
|
|
|
403
568
|
* export const Settings = defineGlobal<SiteSettings>({ ... })
|
|
404
569
|
* ```
|
|
405
570
|
*/
|
|
406
|
-
declare function defineGlobal<const TFields extends Field[]
|
|
571
|
+
declare function defineGlobal<const TSlug extends string, const TFields extends Field[], const TConfig extends Omit<GlobalConfig<Prettify<InferDocShape<TFields>>>, "fields"> & {
|
|
572
|
+
slug: TSlug;
|
|
407
573
|
fields: TFields;
|
|
408
|
-
}):
|
|
409
|
-
declare function defineGlobal<TDoc extends object
|
|
574
|
+
}>(config: TConfig): TConfig;
|
|
575
|
+
declare function defineGlobal<TDoc extends object, const TConfig extends GlobalConfig<TDoc>>(config: TConfig): TConfig;
|
|
410
576
|
/**
|
|
411
577
|
* Define the root Dyrected configuration.
|
|
412
578
|
*
|
|
@@ -414,7 +580,13 @@ declare function defineGlobal<TDoc extends object>(config: GlobalConfig<TDoc>):
|
|
|
414
580
|
* the database adapter, collections, globals, storage, email, and all other
|
|
415
581
|
* server-level configuration.
|
|
416
582
|
*/
|
|
417
|
-
declare function defineConfig<TUser extends AuthenticatedUser = AuthenticatedUser>
|
|
583
|
+
declare function defineConfig<TUser extends AuthenticatedUser = AuthenticatedUser, const TBlocks extends readonly Block[] = [], const TCollections extends readonly CollectionConfig<any>[] = [], const TGlobals extends readonly GlobalConfig<any>[] = [], const TAdminAuth extends DyrectedConfig<TUser>["adminAuth"] | undefined = undefined, const TPolicies extends Record<string, AccessPolicyResolver<Record<string, unknown>, TUser> | string | boolean> | undefined = undefined>(config: Omit<DyrectedConfig<TUser>, "blocks" | "collections" | "globals" | "accessPolicies" | "adminAuth"> & {
|
|
584
|
+
blocks?: TypedBlocksForConfig<TBlocks, TCollections, TBlocks, PolicyNames<TPolicies>>;
|
|
585
|
+
collections: TypedCollections<TCollections, TCollections, TBlocks, PolicyNames<TPolicies>>;
|
|
586
|
+
globals: TypedGlobals<TGlobals, TCollections, TBlocks, PolicyNames<TPolicies>>;
|
|
587
|
+
accessPolicies?: TPolicies;
|
|
588
|
+
adminAuth?: TypedAdminAuthConfig<TAdminAuth, TCollections>;
|
|
589
|
+
}): typeof config;
|
|
418
590
|
/**
|
|
419
591
|
* Define a single field of any type. This is an identity helper: it returns the
|
|
420
592
|
* field unchanged at runtime but preserves the exact literal type, so document
|
|
@@ -571,4 +743,4 @@ declare function defineTab<const T extends readonly Field[]>(args: {
|
|
|
571
743
|
fields: T;
|
|
572
744
|
}): T;
|
|
573
745
|
|
|
574
|
-
export { AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, BlocksField, BooleanField, CollectionConfig, DateField, DateTimeField, DyrectedConfig, EmailField, Field, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MultiSelectField, NumberField, ObjectField, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SqlWhereResult, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, 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, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, numericFieldNames, parseMongoWhere, parseSort, parseSqlWhere, publishedStateName, publishingWorkflow, resolveAdminAuthCollection, runCollectionHooks, saveWorkflowDraft, simplePublishingWorkflow, transitionWorkflow, workflowCapabilities };
|
|
746
|
+
export { AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, BlocksField, BooleanField, CollectionConfig, DateField, DateTimeField, DyrectedConfig, EmailField, Field, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MultiSelectField, NumberField, ObjectField, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SqlWhereResult, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, 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, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, numericFieldNames, parseMongoWhere, parseSort, parseSqlWhere, publishedStateName, publishingWorkflow, resolveAdminAuthCollection, runCollectionHooks, saveWorkflowDraft, simplePublishingWorkflow, transitionWorkflow, workflowCapabilities };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as Field, B as Block, D as DyrectedConfig, C as CollectionConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, W as WorkflowConfig, a as AuthenticatedUser, b as WorkflowTransition, L as LifecycleEventName, c as LifecycleEvent, d as BaseDocument, H as HookRequestContext, e as ArrayField, f as BlocksField, g as BooleanField, h as AuthConfig, i as
|
|
2
|
-
export {
|
|
1
|
+
import { F as Field, B as Block, D as DyrectedConfig, C as CollectionConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, W as WorkflowConfig, a as AuthenticatedUser, b as WorkflowTransition, L as LifecycleEventName, c as LifecycleEvent, d as BaseDocument, H as HookRequestContext, e as ArrayField, f as BlocksField, g as BooleanField, h as AuthConfig, G as GlobalConfig, i as AccessPolicyResolver, j as DateField, k as DateTimeField, E as EmailField, I as IconField, l as ImageField, J as JoinField, m as JsonField, M as MultiSelectField, N as NumberField, O as ObjectField, R as RadioField, n as RelationshipField, o as RichTextField, p as RowField, S as SelectField, T as TextField, q as TextareaField, r as TimeField, U as UrlField } from './app-config-DbK2Tv6i.js';
|
|
2
|
+
export { s as AccessFunction, t as AccessFunctionArgs, u as AccessResult, v as AccessRule, w as AdminAuthAccessResolution, x as AdminAuthClaimMapping, y as AdminAuthMember, z as AdminAuthProvider, K as AdminAuthProviderMembersConfig, Q as AdminAuthProvisioningMode, V as AdminAuthResolveAccessArgs, X as AdminAuthResolvedIdentity, Y as AdminConfig, Z as AdminDashboardComponentSlots, _ as AdminIconName, $ as BaseAdminAuthProvider, a0 as BaseFieldAdmin, a1 as BlockVariant, a2 as BooleanFieldAdmin, a3 as BooleanFormat, a4 as CharacterLimitFieldAdmin, a5 as CharacterLimitFieldConfig, a6 as CollectionAfterChangeHook, a7 as CollectionAfterDeleteHook, a8 as CollectionAfterReadHook, a9 as CollectionAfterTransitionHook, aa as CollectionBeforeChangeHook, ab as CollectionBeforeDeleteHook, ac as CollectionBeforeReadHook, ad as CollectionBeforeTransitionHook, ae as CollectionListComponentSlots, af as CustomAdminAuthProvider, ag as DatabaseAdapter, ah as DateFieldAdmin, ai as DateFormat, aj as DisplayTone, ak as DynamicOptionItem, al as DynamicOptionsConfig, am as DynamicOptionsResolver, an as DynamicOptionsResolverArgs, ao as DyrectedLoggerConfig, ap as DyrectedObservabilityConfig, aq as EmailFieldAdmin, ar as FieldAdminHooks, as as FieldAdminOnChangeHook, at as FieldAdminOnChangeHookArgs, au as FieldAdminOptionsHook, av as FieldAdminOptionsHookArgs, aw as FieldAdminOptionsHookResult, ax as FieldAfterReadHook, ay as FieldAfterReadHookArgs, az as FieldBase, aA as FieldBeforeChangeHook, aB as FieldBeforeChangeHookArgs, aC as FieldHook, aD as FieldHooks, aE as FieldType, aF as FileData, aG as GlobalAfterChangeHook, aH as GlobalAfterReadHook, aI as GlobalBeforeChangeHook, aJ as GlobalBeforeReadHook, aK as HeadingLevel, aL as HookFunction, aM as IconFieldAdmin, aN as ImageService, aO as JoinFieldAdmin, aP as JsonFieldAdmin, aQ as JsonFormat, aR as LIFECYCLE_EVENT_NAMES, aS as LifecycleEventHandler, aT as LinkFormat, aU as MultiSelectFieldAdmin, aV as NamedAccessPolicy, aW as NumberFieldAdmin, aX as NumberFormat, aY as NumberLimitFieldAdmin, aZ as NumberLimitFieldConfig, a_ as OIDCAdminAuthProvider, a$ as OptionFormat, b0 as PaginatedResult, b1 as PublicAdminAuthProvider, b2 as RadioFieldAdmin, b3 as RateLimitConfig, b4 as ReadonlyDatabaseAdapter, b5 as RichTextFeature, b6 as RichTextFieldConfig, b7 as SelectFieldAdmin, b8 as StorageAdapter, b9 as TextFieldAdmin, ba as TextFormat, bb as TextareaFieldAdmin, bc as TrustProxyConfig, bd as TypedField, be as UploadConfig, bf as UrlFieldAdmin, bg as UrlLinkValue, bh as WordLimitFieldAdmin, bi as WordLimitFieldConfig, bj as WorkflowMetadata, bk as WorkflowRole, bl as WorkflowState, bm as WorkflowTransitionContext } from './app-config-DbK2Tv6i.js';
|
|
3
3
|
import 'lucide-react';
|
|
4
4
|
import 'pino';
|
|
5
5
|
|
|
@@ -325,6 +325,159 @@ declare function transitionWorkflow(args: {
|
|
|
325
325
|
req: HookRequestContext;
|
|
326
326
|
}): Promise<BaseDocument>;
|
|
327
327
|
|
|
328
|
+
type TopLevelFieldName<TFields extends readonly Field[]> = Extract<TFields[number], {
|
|
329
|
+
name: string;
|
|
330
|
+
}>["name"];
|
|
331
|
+
type InvalidReference<TLabel extends string, TReceived, TExpected extends string> = {
|
|
332
|
+
__dyrected_error__: `Invalid ${TLabel}`;
|
|
333
|
+
__dyrected_received__: TReceived;
|
|
334
|
+
__dyrected_expected__: TExpected;
|
|
335
|
+
};
|
|
336
|
+
type TypedReference<TValue, TExpected extends string, TLabel extends string> = TValue extends undefined ? undefined : TValue extends TExpected ? TValue : InvalidReference<TLabel, TValue, TExpected>;
|
|
337
|
+
type TypedReferenceList<TValue, TExpected extends string, TLabel extends string> = TValue extends readonly unknown[] ? {
|
|
338
|
+
[K in keyof TValue]: TypedReference<TValue[K], TExpected, TLabel>;
|
|
339
|
+
} : InvalidReference<`${TLabel} list`, TValue, TExpected>;
|
|
340
|
+
type TypedCollectionAdmin<TFields extends readonly Field[], TDoc extends object, TAdmin extends NonNullable<CollectionConfig<TDoc>["admin"]> | undefined> = Omit<NonNullable<CollectionConfig<TDoc>["admin"]>, "useAsTitle" | "defaultColumns" | "searchableFields"> & {
|
|
341
|
+
useAsTitle?: TypedReference<PropertyType<NonNullable<TAdmin>, "useAsTitle">, TopLevelFieldName<TFields>, "field name">;
|
|
342
|
+
defaultColumns?: TypedReferenceList<PropertyType<NonNullable<TAdmin>, "defaultColumns">, TopLevelFieldName<TFields>, "field name">;
|
|
343
|
+
searchableFields?: TypedReferenceList<PropertyType<NonNullable<TAdmin>, "searchableFields">, TopLevelFieldName<TFields>, "field name">;
|
|
344
|
+
};
|
|
345
|
+
type TypedNestedFieldAdmin<TFields extends readonly Field[], TAdmin extends NonNullable<Field["admin"]> | undefined> = Omit<NonNullable<Field["admin"]>, "useAsTitle"> & {
|
|
346
|
+
useAsTitle?: TypedReference<PropertyType<NonNullable<TAdmin>, "useAsTitle">, TopLevelFieldName<TFields>, "field name">;
|
|
347
|
+
};
|
|
348
|
+
type PropertyType<T, K extends PropertyKey> = T extends {
|
|
349
|
+
[P in K]?: infer V;
|
|
350
|
+
} ? V : never;
|
|
351
|
+
type PolicyNames<TPolicies> = Extract<keyof NonNullable<TPolicies>, string>;
|
|
352
|
+
type TypedPolicyReference<TPolicyNames extends string, TPolicy extends string | undefined> = {
|
|
353
|
+
policy: TypedReference<TPolicy, TPolicyNames, "policy name">;
|
|
354
|
+
params?: Record<string, unknown>;
|
|
355
|
+
};
|
|
356
|
+
type TypedAccessRule<TRule, TPolicyNames extends string> = Exclude<TRule, {
|
|
357
|
+
policy: string;
|
|
358
|
+
}> | TypedPolicyReference<TPolicyNames, Extract<PropertyType<TRule, "policy">, string>>;
|
|
359
|
+
type RetypeAccessObject<TAccess, TKeys extends PropertyKey, TPolicyNames extends string> = TAccess extends object ? Omit<TAccess, Extract<TKeys, keyof TAccess>> & {
|
|
360
|
+
[K in Extract<TKeys, keyof TAccess>]?: TypedAccessRule<PropertyType<TAccess, K>, TPolicyNames>;
|
|
361
|
+
} : TAccess;
|
|
362
|
+
type TypedFieldAccess<TAccess, TPolicyNames extends string> = RetypeAccessObject<TAccess, "read" | "create" | "update", TPolicyNames>;
|
|
363
|
+
type TypedCollectionAccess<TAccess, TPolicyNames extends string> = RetypeAccessObject<TAccess, "read" | "create" | "update" | "delete" | "readAudit", TPolicyNames>;
|
|
364
|
+
type TypedGlobalAccess<TAccess, TPolicyNames extends string> = RetypeAccessObject<TAccess, "read" | "update", TPolicyNames>;
|
|
365
|
+
type SlugOf<T> = T extends {
|
|
366
|
+
slug: infer TSlug extends string;
|
|
367
|
+
} ? TSlug : never;
|
|
368
|
+
type CollectionSlug<TCollections extends readonly unknown[]> = SlugOf<TCollections[number]>;
|
|
369
|
+
type BlockSlug<TBlocks extends readonly unknown[]> = SlugOf<TBlocks[number]>;
|
|
370
|
+
type UploadCollectionSlug<TCollections extends readonly unknown[]> = SlugOf<Extract<TCollections[number], {
|
|
371
|
+
upload: unknown;
|
|
372
|
+
}>>;
|
|
373
|
+
type AuthCollectionSlug<TCollections extends readonly unknown[]> = SlugOf<Extract<TCollections[number], {
|
|
374
|
+
auth: unknown;
|
|
375
|
+
}>>;
|
|
376
|
+
type CollectionBySlug<TCollections extends readonly unknown[], TSlug extends string> = Extract<TCollections[number], {
|
|
377
|
+
slug: TSlug;
|
|
378
|
+
}>;
|
|
379
|
+
type CollectionFieldNamesBySlug<TCollections extends readonly unknown[], TSlug extends string> = CollectionBySlug<TCollections, TSlug> extends {
|
|
380
|
+
fields: infer TFields extends readonly Field[];
|
|
381
|
+
} ? TopLevelFieldName<TFields> : never;
|
|
382
|
+
type WorkflowStateName<TWorkflow> = TWorkflow extends {
|
|
383
|
+
states: infer TStates extends readonly unknown[];
|
|
384
|
+
} ? Extract<TStates[number], {
|
|
385
|
+
name: string;
|
|
386
|
+
}>["name"] : never;
|
|
387
|
+
type TypedWorkflowStateValue<TValue, TWorkflow> = TValue extends readonly unknown[] ? {
|
|
388
|
+
[K in keyof TValue]: TypedReference<TValue[K], WorkflowStateName<TWorkflow>, "workflow state name">;
|
|
389
|
+
} : TypedReference<TValue, WorkflowStateName<TWorkflow>, "workflow state name">;
|
|
390
|
+
type TypedWorkflowTransition<TTransition, TWorkflow> = Omit<TTransition, "from" | "to"> & {
|
|
391
|
+
from: TypedWorkflowStateValue<PropertyType<TTransition, "from">, TWorkflow>;
|
|
392
|
+
to: TypedReference<PropertyType<TTransition, "to">, WorkflowStateName<TWorkflow>, "workflow state name">;
|
|
393
|
+
};
|
|
394
|
+
type TypedWorkflow<TWorkflow> = TWorkflow extends {
|
|
395
|
+
transitions: infer TTransitions extends readonly unknown[];
|
|
396
|
+
} ? Omit<TWorkflow, "initialState" | "draftState" | "transitions"> & {
|
|
397
|
+
initialState: TypedReference<PropertyType<TWorkflow, "initialState">, WorkflowStateName<TWorkflow>, "workflow state name">;
|
|
398
|
+
draftState?: TypedReference<PropertyType<TWorkflow, "draftState">, WorkflowStateName<TWorkflow>, "workflow state name">;
|
|
399
|
+
transitions: {
|
|
400
|
+
[K in keyof TTransitions]: TypedWorkflowTransition<TTransitions[K], TWorkflow>;
|
|
401
|
+
};
|
|
402
|
+
} : TWorkflow;
|
|
403
|
+
type TypedBlockForConfig<TBlock extends Block, TCollections extends readonly unknown[], TRootBlocks extends readonly Block[], TPolicyNames extends string> = Omit<TBlock, "fields"> & {
|
|
404
|
+
fields: TBlock["fields"] extends readonly Field[] ? TypedFields<TBlock["fields"], TCollections, TRootBlocks, TPolicyNames> : TBlock["fields"];
|
|
405
|
+
};
|
|
406
|
+
type TypedBlocksForConfig<TBlocks extends readonly Block[], TCollections extends readonly unknown[], TRootBlocks extends readonly Block[], TPolicyNames extends string> = {
|
|
407
|
+
[K in keyof TBlocks]: TBlocks[K] extends Block ? TypedBlockForConfig<TBlocks[K], TCollections, TRootBlocks, TPolicyNames> : TBlocks[K];
|
|
408
|
+
};
|
|
409
|
+
type TypedFieldForConfig<TField extends Field, TCollections extends readonly unknown[], TBlocks extends readonly Block[], TPolicyNames extends string> = TField extends {
|
|
410
|
+
type: "relationship";
|
|
411
|
+
} ? Omit<TField, "relationTo" | "access"> & {
|
|
412
|
+
relationTo?: TypedReference<PropertyType<TField, "relationTo">, CollectionSlug<TCollections>, "collection slug">;
|
|
413
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
414
|
+
} : TField extends {
|
|
415
|
+
type: "image";
|
|
416
|
+
} ? Omit<TField, "relationTo" | "access"> & {
|
|
417
|
+
relationTo?: TypedReference<PropertyType<TField, "relationTo">, UploadCollectionSlug<TCollections>, "upload collection slug">;
|
|
418
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
419
|
+
} : TField extends {
|
|
420
|
+
type: "richText";
|
|
421
|
+
} ? Omit<TField, "uploadCollection" | "access"> & {
|
|
422
|
+
uploadCollection?: TypedReference<PropertyType<TField, "uploadCollection">, UploadCollectionSlug<TCollections>, "upload collection slug">;
|
|
423
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
424
|
+
} : TField extends {
|
|
425
|
+
type: "join";
|
|
426
|
+
} ? Omit<TField, "collection" | "on" | "access"> & {
|
|
427
|
+
collection?: TypedReference<PropertyType<TField, "collection">, CollectionSlug<TCollections>, "collection slug">;
|
|
428
|
+
on?: TypedReference<PropertyType<TField, "on">, CollectionFieldNamesBySlug<TCollections, Extract<PropertyType<TField, "collection">, string>> | TopLevelFieldName<Extract<CollectionBySlug<TCollections, CollectionSlug<TCollections>>, {
|
|
429
|
+
fields: readonly Field[];
|
|
430
|
+
}>["fields"]>, "field name">;
|
|
431
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
432
|
+
} : TField extends {
|
|
433
|
+
type: "blocks";
|
|
434
|
+
} ? Omit<TField, "blocks" | "blockReferences" | "access"> & {
|
|
435
|
+
blocks?: TField["blocks"] extends readonly Block[] ? TypedBlocksForConfig<TField["blocks"], TCollections, TBlocks, TPolicyNames> : TField["blocks"];
|
|
436
|
+
blockReferences?: TypedReferenceList<PropertyType<TField, "blockReferences">, BlockSlug<TBlocks>, "block slug">;
|
|
437
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
438
|
+
} : TField extends {
|
|
439
|
+
type: "array";
|
|
440
|
+
fields: infer TSubFields extends readonly Field[];
|
|
441
|
+
} ? Omit<TField, "fields" | "access" | "admin"> & {
|
|
442
|
+
fields: TypedFields<TSubFields, TCollections, TBlocks, TPolicyNames>;
|
|
443
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
444
|
+
admin?: TypedNestedFieldAdmin<TSubFields, PropertyType<TField, "admin">>;
|
|
445
|
+
} : TField extends {
|
|
446
|
+
type: "object";
|
|
447
|
+
fields: infer TSubFields extends readonly Field[];
|
|
448
|
+
} ? Omit<TField, "fields" | "access" | "admin"> & {
|
|
449
|
+
fields: TypedFields<TSubFields, TCollections, TBlocks, TPolicyNames>;
|
|
450
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
451
|
+
admin?: TypedNestedFieldAdmin<TSubFields, PropertyType<TField, "admin">>;
|
|
452
|
+
} : TField extends {
|
|
453
|
+
fields: infer TSubFields extends readonly Field[];
|
|
454
|
+
} ? Omit<TField, "fields" | "access"> & {
|
|
455
|
+
fields: TypedFields<TSubFields, TCollections, TBlocks, TPolicyNames>;
|
|
456
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
457
|
+
} : Omit<TField, "access"> & {
|
|
458
|
+
access?: TypedFieldAccess<NonNullable<TField["access"]>, TPolicyNames>;
|
|
459
|
+
};
|
|
460
|
+
type TypedFields<TFields extends readonly Field[], TCollections extends readonly unknown[], TBlocks extends readonly Block[], TPolicyNames extends string> = {
|
|
461
|
+
[K in keyof TFields]: TFields[K] extends Field ? TypedFieldForConfig<TFields[K], TCollections, TBlocks, TPolicyNames> : TFields[K];
|
|
462
|
+
};
|
|
463
|
+
type TypedCollectionForConfig<TCollection extends CollectionConfig<any>, TCollections extends readonly CollectionConfig<any>[], TBlocks extends readonly Block[], TPolicyNames extends string> = Omit<TCollection, "fields" | "access" | "workflow"> & {
|
|
464
|
+
fields: TCollection["fields"] extends readonly Field[] ? TypedFields<TCollection["fields"], TCollections, TBlocks, TPolicyNames> : TCollection["fields"];
|
|
465
|
+
access?: TypedCollectionAccess<NonNullable<TCollection["access"]>, TPolicyNames>;
|
|
466
|
+
workflow?: TypedWorkflow<NonNullable<TCollection["workflow"]>>;
|
|
467
|
+
};
|
|
468
|
+
type TypedCollections<TCollections extends readonly CollectionConfig<any>[], TAllCollections extends readonly CollectionConfig<any>[], TBlocks extends readonly Block[], TPolicyNames extends string> = {
|
|
469
|
+
[K in keyof TCollections]: TCollections[K] extends CollectionConfig<any> ? TypedCollectionForConfig<TCollections[K], TAllCollections, TBlocks, TPolicyNames> : TCollections[K];
|
|
470
|
+
};
|
|
471
|
+
type TypedGlobalForConfig<TGlobal extends GlobalConfig<any>, TCollections extends readonly CollectionConfig<any>[], TBlocks extends readonly Block[], TPolicyNames extends string> = Omit<TGlobal, "fields" | "access"> & {
|
|
472
|
+
fields: TGlobal["fields"] extends readonly Field[] ? TypedFields<TGlobal["fields"], TCollections, TBlocks, TPolicyNames> : TGlobal["fields"];
|
|
473
|
+
access?: TypedGlobalAccess<NonNullable<TGlobal["access"]>, TPolicyNames>;
|
|
474
|
+
};
|
|
475
|
+
type TypedGlobals<TGlobals extends readonly GlobalConfig<any>[], TCollections extends readonly CollectionConfig<any>[], TBlocks extends readonly Block[], TPolicyNames extends string> = {
|
|
476
|
+
[K in keyof TGlobals]: TGlobals[K] extends GlobalConfig<any> ? TypedGlobalForConfig<TGlobals[K], TCollections, TBlocks, TPolicyNames> : TGlobals[K];
|
|
477
|
+
};
|
|
478
|
+
type TypedAdminAuthConfig<TAdminAuth, TCollections extends readonly CollectionConfig<any>[]> = TAdminAuth extends object ? Omit<TAdminAuth, "collectionSlug"> & {
|
|
479
|
+
collectionSlug?: TypedReference<PropertyType<TAdminAuth, "collectionSlug">, AuthCollectionSlug<TCollections>, "auth collection slug">;
|
|
480
|
+
} : TAdminAuth;
|
|
328
481
|
/**
|
|
329
482
|
* Define a collection. When called without an explicit type argument, TypeScript
|
|
330
483
|
* automatically infers the document shape from the `fields` array you provide —
|
|
@@ -354,30 +507,42 @@ declare function transitionWorkflow(args: {
|
|
|
354
507
|
* export const Posts = defineCollection<Post>({ ... })
|
|
355
508
|
* ```
|
|
356
509
|
*/
|
|
357
|
-
declare function defineCollection<const TFields extends Field[]
|
|
510
|
+
declare function defineCollection<const TSlug extends string, const TFields extends Field[], const TAdmin extends NonNullable<CollectionConfig<Prettify<{
|
|
511
|
+
id: string;
|
|
512
|
+
} & InferDocShape<TFields> & SystemDocFields & AuthDocFields>>["admin"]> | undefined, const TConfig extends Omit<CollectionConfig<Prettify<{
|
|
358
513
|
id: string;
|
|
359
|
-
} & InferDocShape<TFields> & SystemDocFields & AuthDocFields>>, "fields" | "auth"> & {
|
|
514
|
+
} & InferDocShape<TFields> & SystemDocFields & AuthDocFields>>, "fields" | "auth" | "admin"> & {
|
|
515
|
+
slug: TSlug;
|
|
360
516
|
fields: TFields;
|
|
361
517
|
auth: true | AuthConfig;
|
|
362
|
-
|
|
518
|
+
admin?: TypedCollectionAdmin<TFields, Prettify<{
|
|
519
|
+
id: string;
|
|
520
|
+
} & InferDocShape<TFields> & SystemDocFields & AuthDocFields>, TAdmin>;
|
|
521
|
+
}>(config: TConfig): TConfig;
|
|
522
|
+
declare function defineCollection<const TSlug extends string, const TFields extends Field[], const TAdmin extends NonNullable<CollectionConfig<Prettify<{
|
|
363
523
|
id: string;
|
|
364
|
-
} & InferDocShape<TFields> & SystemDocFields &
|
|
365
|
-
declare function defineCollection<const TFields extends Field[]>(config: Omit<CollectionConfig<Prettify<{
|
|
524
|
+
} & InferDocShape<TFields> & SystemDocFields & UploadDocFields>>["admin"]> | undefined, const TConfig extends Omit<CollectionConfig<Prettify<{
|
|
366
525
|
id: string;
|
|
367
|
-
} & InferDocShape<TFields> & SystemDocFields & UploadDocFields>>, "fields" | "upload"> & {
|
|
526
|
+
} & InferDocShape<TFields> & SystemDocFields & UploadDocFields>>, "fields" | "upload" | "admin"> & {
|
|
527
|
+
slug: TSlug;
|
|
368
528
|
fields: TFields;
|
|
369
529
|
upload: true;
|
|
370
|
-
|
|
530
|
+
admin?: TypedCollectionAdmin<TFields, Prettify<{
|
|
531
|
+
id: string;
|
|
532
|
+
} & InferDocShape<TFields> & SystemDocFields & UploadDocFields>, TAdmin>;
|
|
533
|
+
}>(config: TConfig): TConfig;
|
|
534
|
+
declare function defineCollection<const TSlug extends string, const TFields extends Field[], const TAdmin extends NonNullable<CollectionConfig<Prettify<{
|
|
371
535
|
id: string;
|
|
372
|
-
} & InferDocShape<TFields> & SystemDocFields
|
|
373
|
-
declare function defineCollection<const TFields extends Field[]>(config: Omit<CollectionConfig<Prettify<{
|
|
536
|
+
} & InferDocShape<TFields> & SystemDocFields>>["admin"]> | undefined, const TConfig extends Omit<CollectionConfig<Prettify<{
|
|
374
537
|
id: string;
|
|
375
|
-
} & InferDocShape<TFields> & SystemDocFields>>, "fields"> & {
|
|
538
|
+
} & InferDocShape<TFields> & SystemDocFields>>, "fields" | "admin"> & {
|
|
539
|
+
slug: TSlug;
|
|
376
540
|
fields: TFields;
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
} & InferDocShape<TFields> & SystemDocFields
|
|
380
|
-
|
|
541
|
+
admin?: TypedCollectionAdmin<TFields, Prettify<{
|
|
542
|
+
id: string;
|
|
543
|
+
} & InferDocShape<TFields> & SystemDocFields>, TAdmin>;
|
|
544
|
+
}>(config: TConfig): TConfig;
|
|
545
|
+
declare function defineCollection<TDoc extends object, const TConfig extends CollectionConfig<TDoc>>(config: TConfig): TConfig;
|
|
381
546
|
/**
|
|
382
547
|
* Define a global (singleton document). TypeScript automatically infers the
|
|
383
548
|
* document shape from the `fields` array, or you can pass an explicit type:
|
|
@@ -403,10 +568,11 @@ declare function defineCollection<TDoc extends object>(config: CollectionConfig<
|
|
|
403
568
|
* export const Settings = defineGlobal<SiteSettings>({ ... })
|
|
404
569
|
* ```
|
|
405
570
|
*/
|
|
406
|
-
declare function defineGlobal<const TFields extends Field[]
|
|
571
|
+
declare function defineGlobal<const TSlug extends string, const TFields extends Field[], const TConfig extends Omit<GlobalConfig<Prettify<InferDocShape<TFields>>>, "fields"> & {
|
|
572
|
+
slug: TSlug;
|
|
407
573
|
fields: TFields;
|
|
408
|
-
}):
|
|
409
|
-
declare function defineGlobal<TDoc extends object
|
|
574
|
+
}>(config: TConfig): TConfig;
|
|
575
|
+
declare function defineGlobal<TDoc extends object, const TConfig extends GlobalConfig<TDoc>>(config: TConfig): TConfig;
|
|
410
576
|
/**
|
|
411
577
|
* Define the root Dyrected configuration.
|
|
412
578
|
*
|
|
@@ -414,7 +580,13 @@ declare function defineGlobal<TDoc extends object>(config: GlobalConfig<TDoc>):
|
|
|
414
580
|
* the database adapter, collections, globals, storage, email, and all other
|
|
415
581
|
* server-level configuration.
|
|
416
582
|
*/
|
|
417
|
-
declare function defineConfig<TUser extends AuthenticatedUser = AuthenticatedUser>
|
|
583
|
+
declare function defineConfig<TUser extends AuthenticatedUser = AuthenticatedUser, const TBlocks extends readonly Block[] = [], const TCollections extends readonly CollectionConfig<any>[] = [], const TGlobals extends readonly GlobalConfig<any>[] = [], const TAdminAuth extends DyrectedConfig<TUser>["adminAuth"] | undefined = undefined, const TPolicies extends Record<string, AccessPolicyResolver<Record<string, unknown>, TUser> | string | boolean> | undefined = undefined>(config: Omit<DyrectedConfig<TUser>, "blocks" | "collections" | "globals" | "accessPolicies" | "adminAuth"> & {
|
|
584
|
+
blocks?: TypedBlocksForConfig<TBlocks, TCollections, TBlocks, PolicyNames<TPolicies>>;
|
|
585
|
+
collections: TypedCollections<TCollections, TCollections, TBlocks, PolicyNames<TPolicies>>;
|
|
586
|
+
globals: TypedGlobals<TGlobals, TCollections, TBlocks, PolicyNames<TPolicies>>;
|
|
587
|
+
accessPolicies?: TPolicies;
|
|
588
|
+
adminAuth?: TypedAdminAuthConfig<TAdminAuth, TCollections>;
|
|
589
|
+
}): typeof config;
|
|
418
590
|
/**
|
|
419
591
|
* Define a single field of any type. This is an identity helper: it returns the
|
|
420
592
|
* field unchanged at runtime but preserves the exact literal type, so document
|
|
@@ -571,4 +743,4 @@ declare function defineTab<const T extends readonly Field[]>(args: {
|
|
|
571
743
|
fields: T;
|
|
572
744
|
}): T;
|
|
573
745
|
|
|
574
|
-
export { AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, BlocksField, BooleanField, CollectionConfig, DateField, DateTimeField, DyrectedConfig, EmailField, Field, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MultiSelectField, NumberField, ObjectField, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SqlWhereResult, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, 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, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, numericFieldNames, parseMongoWhere, parseSort, parseSqlWhere, publishedStateName, publishingWorkflow, resolveAdminAuthCollection, runCollectionHooks, saveWorkflowDraft, simplePublishingWorkflow, transitionWorkflow, workflowCapabilities };
|
|
746
|
+
export { AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, BlocksField, BooleanField, CollectionConfig, DateField, DateTimeField, DyrectedConfig, EmailField, Field, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MultiSelectField, NumberField, ObjectField, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SqlWhereResult, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, 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, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, numericFieldNames, parseMongoWhere, parseSort, parseSqlWhere, publishedStateName, publishingWorkflow, resolveAdminAuthCollection, runCollectionHooks, saveWorkflowDraft, simplePublishingWorkflow, transitionWorkflow, workflowCapabilities };
|