@dyrected/core 2.5.40 → 2.5.42
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-BLMX-9MN.d.cts +1045 -0
- package/dist/app-config-BLMX-9MN.d.ts +1045 -0
- package/dist/chunk-4C4L6SD2.js +1524 -0
- package/dist/chunk-FCXE5CVC.js +1528 -0
- package/dist/index-BKYugiYp.d.cts +1988 -0
- package/dist/index-BKYugiYp.d.ts +1988 -0
- package/dist/index-BSWCiAen.d.cts +1983 -0
- package/dist/index-BSWCiAen.d.ts +1983 -0
- package/dist/index-BfLDb3b0.d.cts +1467 -0
- package/dist/index-BfLDb3b0.d.ts +1467 -0
- package/dist/index-Bi4sX_eC.d.cts +1491 -0
- package/dist/index-Bi4sX_eC.d.ts +1491 -0
- package/dist/index-C9Vp1DCT.d.cts +1563 -0
- package/dist/index-C9Vp1DCT.d.ts +1563 -0
- package/dist/index-CFezd8p1.d.cts +1986 -0
- package/dist/index-CFezd8p1.d.ts +1986 -0
- package/dist/index-DR2z1rrf.d.cts +1503 -0
- package/dist/index-DR2z1rrf.d.ts +1503 -0
- package/dist/index-DfkPT4NR.d.cts +1584 -0
- package/dist/index-DfkPT4NR.d.ts +1584 -0
- package/dist/index-xB1lMg79.d.cts +1456 -0
- package/dist/index-xB1lMg79.d.ts +1456 -0
- package/dist/index.cjs +78 -5
- package/dist/index.d.cts +77 -3
- package/dist/index.d.ts +77 -3
- package/dist/index.js +6 -2
- package/dist/server.cjs +462 -10
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +395 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -35,6 +35,8 @@ __export(index_exports, {
|
|
|
35
35
|
executeFieldAfterRead: () => executeFieldAfterRead,
|
|
36
36
|
executeFieldBeforeChange: () => executeFieldBeforeChange,
|
|
37
37
|
generateOpenApi: () => generateOpenApi,
|
|
38
|
+
getAdminAuthCollection: () => getAdminAuthCollection,
|
|
39
|
+
getPublicAdminAuthConfig: () => getPublicAdminAuthConfig,
|
|
38
40
|
initializeWorkflowDocument: () => initializeWorkflowDocument,
|
|
39
41
|
materializeWorkflowDocument: () => materializeWorkflowDocument,
|
|
40
42
|
normalizeConfig: () => normalizeConfig,
|
|
@@ -49,7 +51,7 @@ __export(index_exports, {
|
|
|
49
51
|
});
|
|
50
52
|
module.exports = __toCommonJS(index_exports);
|
|
51
53
|
|
|
52
|
-
// src/types/
|
|
54
|
+
// src/types/workflows.ts
|
|
53
55
|
var LIFECYCLE_EVENT_NAMES = [
|
|
54
56
|
"revision.created",
|
|
55
57
|
"workflow.transitioned",
|
|
@@ -318,6 +320,34 @@ async function transitionWorkflow(args) {
|
|
|
318
320
|
return updated;
|
|
319
321
|
}
|
|
320
322
|
|
|
323
|
+
// src/utils/admin-auth.ts
|
|
324
|
+
function getAdminAuthCollection(config) {
|
|
325
|
+
const requestedSlug = config.adminAuth?.collectionSlug;
|
|
326
|
+
if (requestedSlug) {
|
|
327
|
+
return config.collections.find((collection) => collection.slug === requestedSlug) ?? null;
|
|
328
|
+
}
|
|
329
|
+
return config.collections.find((collection) => collection.slug === "__admins") ?? config.collections.find((collection) => collection.auth) ?? null;
|
|
330
|
+
}
|
|
331
|
+
function getPublicAdminAuthConfig(adminAuth) {
|
|
332
|
+
const providers = (adminAuth?.providers ?? []).map((provider) => ({
|
|
333
|
+
id: provider.id,
|
|
334
|
+
type: provider.type,
|
|
335
|
+
displayName: provider.displayName || humanizeProviderName(provider.id, provider.type),
|
|
336
|
+
autoRedirect: provider.autoRedirect
|
|
337
|
+
}));
|
|
338
|
+
return {
|
|
339
|
+
mode: adminAuth?.mode ?? "local",
|
|
340
|
+
collectionSlug: adminAuth?.collectionSlug,
|
|
341
|
+
provisioningMode: adminAuth?.provisioningMode,
|
|
342
|
+
providers
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function humanizeProviderName(id, type) {
|
|
346
|
+
const cleaned = id.replace(/[-_]+/g, " ").trim();
|
|
347
|
+
if (!cleaned) return type.toUpperCase();
|
|
348
|
+
return cleaned.replace(/\b\w/g, (char) => char.toUpperCase());
|
|
349
|
+
}
|
|
350
|
+
|
|
321
351
|
// src/utils/config.ts
|
|
322
352
|
var AUDIT_COLLECTION_SLUG = "__audit";
|
|
323
353
|
var SYSTEM_FIELDS = [
|
|
@@ -400,6 +430,10 @@ function normalizeConfig(config) {
|
|
|
400
430
|
const globals = config?.globals || [];
|
|
401
431
|
const needsAudit = collections.some((col) => col.audit);
|
|
402
432
|
const needsWorkflow = collections.some((col) => col.workflow);
|
|
433
|
+
const adminAuthCollectionSlug = getAdminAuthCollection({
|
|
434
|
+
collections,
|
|
435
|
+
adminAuth: config.adminAuth
|
|
436
|
+
})?.slug;
|
|
403
437
|
const normalizedCollections = collections.map((col) => {
|
|
404
438
|
let fields = col.fields || [];
|
|
405
439
|
const existingFieldNames = new Set(fields.map((f) => f.name));
|
|
@@ -486,6 +520,39 @@ function normalizeConfig(config) {
|
|
|
486
520
|
return field;
|
|
487
521
|
});
|
|
488
522
|
}
|
|
523
|
+
if (adminAuthCollectionSlug && col.slug === adminAuthCollectionSlug && config.adminAuth?.mode === "external") {
|
|
524
|
+
const externalAdminFields = [
|
|
525
|
+
{
|
|
526
|
+
name: "authProvider",
|
|
527
|
+
type: "text",
|
|
528
|
+
label: "Auth Provider",
|
|
529
|
+
admin: { readOnly: true, hidden: true }
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
name: "externalSubject",
|
|
533
|
+
type: "text",
|
|
534
|
+
label: "External Subject",
|
|
535
|
+
admin: { readOnly: true, hidden: true }
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
name: "authSource",
|
|
539
|
+
type: "text",
|
|
540
|
+
label: "Auth Source",
|
|
541
|
+
admin: { readOnly: true, hidden: true }
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
name: "lastLoginAt",
|
|
545
|
+
type: "date",
|
|
546
|
+
label: "Last Login At",
|
|
547
|
+
admin: { readOnly: true, hidden: true }
|
|
548
|
+
}
|
|
549
|
+
];
|
|
550
|
+
for (const field of externalAdminFields) {
|
|
551
|
+
if (!existingFieldNames.has(field.name)) {
|
|
552
|
+
fields = [...fields, field];
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
489
556
|
const updatedFieldNames = new Set(fields.map((f) => f.name));
|
|
490
557
|
const fieldsToInject = SYSTEM_FIELDS.filter((f) => !updatedFieldNames.has(f.name));
|
|
491
558
|
return {
|
|
@@ -720,13 +787,15 @@ async function executeFieldBeforeChange(fields, data, originalDoc, user, db) {
|
|
|
720
787
|
let updatedValue = value;
|
|
721
788
|
if (field.hooks?.beforeChange) {
|
|
722
789
|
for (const hook of field.hooks.beforeChange) {
|
|
723
|
-
|
|
790
|
+
const typedHook = hook;
|
|
791
|
+
const hookArgs = {
|
|
724
792
|
value: updatedValue,
|
|
725
793
|
originalDoc: originalDoc ?? void 0,
|
|
726
794
|
data: result,
|
|
727
795
|
user,
|
|
728
796
|
db
|
|
729
|
-
}
|
|
797
|
+
};
|
|
798
|
+
updatedValue = await typedHook(hookArgs);
|
|
730
799
|
}
|
|
731
800
|
result[field.name] = updatedValue;
|
|
732
801
|
}
|
|
@@ -786,12 +855,14 @@ async function executeFieldAfterRead(fields, doc, user, db) {
|
|
|
786
855
|
let updatedValue = value;
|
|
787
856
|
if (field.hooks?.afterRead) {
|
|
788
857
|
for (const hook of field.hooks.afterRead) {
|
|
789
|
-
|
|
858
|
+
const typedHook = hook;
|
|
859
|
+
const hookArgs = {
|
|
790
860
|
value: updatedValue,
|
|
791
861
|
doc: result,
|
|
792
862
|
user,
|
|
793
863
|
db
|
|
794
|
-
}
|
|
864
|
+
};
|
|
865
|
+
updatedValue = await typedHook(hookArgs);
|
|
795
866
|
}
|
|
796
867
|
result[field.name] = updatedValue;
|
|
797
868
|
}
|
|
@@ -1695,6 +1766,8 @@ function defineConfig(config) {
|
|
|
1695
1766
|
executeFieldAfterRead,
|
|
1696
1767
|
executeFieldBeforeChange,
|
|
1697
1768
|
generateOpenApi,
|
|
1769
|
+
getAdminAuthCollection,
|
|
1770
|
+
getPublicAdminAuthConfig,
|
|
1698
1771
|
initializeWorkflowDocument,
|
|
1699
1772
|
materializeWorkflowDocument,
|
|
1700
1773
|
normalizeConfig,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,78 @@
|
|
|
1
|
-
import {
|
|
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, G as GlobalConfig } from './app-config-BLMX-9MN.cjs';
|
|
2
|
+
export { e as AccessFunction, f as AdminAuthAccessResolution, g as AdminAuthClaimMapping, h as AdminAuthProvider, i as AdminAuthProvisioningMode, j as AdminAuthResolveAccessArgs, k as AdminAuthResolvedIdentity, l as AdminConfig, m as AdminDashboardComponentSlots, n as AdminIconName, o as ArrayField, p as BaseAdminAuthProvider, q as BlocksField, r as BooleanField, s as CharacterLimitFieldConfig, t as CollectionAfterChangeHook, u as CollectionAfterDeleteHook, v as CollectionAfterReadHook, w as CollectionAfterTransitionHook, x as CollectionBeforeChangeHook, y as CollectionBeforeDeleteHook, z as CollectionBeforeReadHook, E as CollectionBeforeTransitionHook, I as CollectionListComponentSlots, J as CustomAdminAuthProvider, K as DatabaseAdapter, M as DateField, N as DateTimeField, O as DynamicOptionItem, Q as DynamicOptionsConfig, R as DynamicOptionsResolver, S as DynamicOptionsResolverArgs, T as EmailField, U as FieldAdminOnChangeHook, V as FieldAdminOnChangeHookArgs, X as FieldAdminOptionsHook, Y as FieldAdminOptionsHookArgs, Z as FieldAdminOptionsHookResult, _ as FieldAfterReadHook, $ as FieldAfterReadHookArgs, a0 as FieldBeforeChangeHook, a1 as FieldBeforeChangeHookArgs, a2 as FieldHook, a3 as FieldType, a4 as FileData, a5 as GlobalAfterChangeHook, a6 as GlobalAfterReadHook, a7 as GlobalBeforeChangeHook, a8 as GlobalBeforeReadHook, a9 as HookFunction, aa as IconField, ab as ImageField, ac as ImageService, ad as JoinField, ae as JsonField, af as LIFECYCLE_EVENT_NAMES, ag as LifecycleEventHandler, ah as MultiSelectField, ai as NumberField, aj as OIDCAdminAuthProvider, ak as ObjectField, al as PaginatedResult, am as PublicAdminAuthProvider, an as RadioField, ao as ReadonlyDatabaseAdapter, ap as RelationshipField, aq as RichTextField, ar as RowField, as as SelectField, at as StorageAdapter, au as TextField, av as TextareaField, aw as TimeField, ax as UploadConfig, ay as UrlField, az as WordLimitFieldConfig, aA as WorkflowMetadata, aB as WorkflowRole, aC as WorkflowState, aD as WorkflowTransitionContext } from './app-config-BLMX-9MN.cjs';
|
|
3
3
|
import 'lucide-react';
|
|
4
4
|
|
|
5
|
+
type Prettify<T> = {
|
|
6
|
+
[K in keyof T]: T[K];
|
|
7
|
+
};
|
|
8
|
+
type FieldValueType<F extends Field> = F["type"] extends "text" | "textarea" | "email" | "url" | "icon" | "date" | "datetime" | "time" | "select" | "radio" ? string : F["type"] extends "number" ? number : F["type"] extends "boolean" ? boolean : F["type"] extends "multiSelect" ? string[] : F["type"] extends "relationship" ? F extends {
|
|
9
|
+
hasMany: true;
|
|
10
|
+
} ? string[] : string : F["type"] extends "image" ? F extends {
|
|
11
|
+
hasMany: true;
|
|
12
|
+
} ? string[] : string : F["type"] extends "richText" | "json" ? Record<string, unknown> : F["type"] extends "object" ? F extends {
|
|
13
|
+
fields: infer SF extends readonly Field[];
|
|
14
|
+
} ? Prettify<InferDocShape<SF>> : Record<string, unknown> : F["type"] extends "array" ? F extends {
|
|
15
|
+
fields: infer SF extends readonly Field[];
|
|
16
|
+
} ? Array<Prettify<InferDocShape<SF>>> : unknown[] : F["type"] extends "blocks" ? F extends {
|
|
17
|
+
blocks: infer B extends readonly Block[];
|
|
18
|
+
} ? Array<InferBlocksUnion<B>> : Array<{
|
|
19
|
+
blockType: string;
|
|
20
|
+
} & Record<string, unknown>> : unknown;
|
|
21
|
+
type InferBlocksUnion<Blocks extends readonly Block[]> = Blocks extends readonly [
|
|
22
|
+
infer B extends Block,
|
|
23
|
+
...infer Rest extends readonly Block[]
|
|
24
|
+
] ? B["fields"] extends readonly Field[] ? ({
|
|
25
|
+
blockType: B["slug"];
|
|
26
|
+
} & Prettify<InferDocShape<B["fields"]>>) | InferBlocksUnion<Rest> : ({
|
|
27
|
+
blockType: B["slug"];
|
|
28
|
+
} & Record<string, unknown>) | InferBlocksUnion<Rest> : never;
|
|
29
|
+
type InferFieldEntry<F extends Field> = F extends {
|
|
30
|
+
type: "row";
|
|
31
|
+
fields: infer SF extends readonly Field[];
|
|
32
|
+
} ? InferDocShape<SF> : F extends {
|
|
33
|
+
type: "join";
|
|
34
|
+
} ? Record<never, never> : F extends {
|
|
35
|
+
name: infer N extends string;
|
|
36
|
+
required: true;
|
|
37
|
+
} ? {
|
|
38
|
+
[K in N]: FieldValueType<F>;
|
|
39
|
+
} : F extends {
|
|
40
|
+
name: infer N extends string;
|
|
41
|
+
} ? {
|
|
42
|
+
[K in N]?: FieldValueType<F>;
|
|
43
|
+
} : Record<never, never>;
|
|
44
|
+
type InferDocShape<Fields extends readonly Field[]> = Fields extends readonly [] ? Record<never, never> : Fields extends readonly [infer Head extends Field, ...infer Tail extends readonly Field[]] ? InferFieldEntry<Head> & InferDocShape<Tail> : Record<string, unknown>;
|
|
45
|
+
type SystemDocFields = {
|
|
46
|
+
createdAt?: string;
|
|
47
|
+
updatedAt?: string;
|
|
48
|
+
createdBy?: string;
|
|
49
|
+
updatedBy?: string;
|
|
50
|
+
};
|
|
51
|
+
type AuthDocFields = {
|
|
52
|
+
email: string;
|
|
53
|
+
password?: string;
|
|
54
|
+
roles?: string[];
|
|
55
|
+
};
|
|
56
|
+
type UploadDocFields = {
|
|
57
|
+
filename: string;
|
|
58
|
+
filesize?: number;
|
|
59
|
+
mimeType: string;
|
|
60
|
+
url: string;
|
|
61
|
+
width?: number;
|
|
62
|
+
height?: number;
|
|
63
|
+
focalPoint?: {
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
66
|
+
};
|
|
67
|
+
blurhash?: string;
|
|
68
|
+
sizes?: Record<string, {
|
|
69
|
+
filename?: string;
|
|
70
|
+
url?: string;
|
|
71
|
+
width?: number;
|
|
72
|
+
height?: number;
|
|
73
|
+
}>;
|
|
74
|
+
};
|
|
75
|
+
|
|
5
76
|
/**
|
|
6
77
|
* Normalizes the Dyrected configuration by injecting system fields
|
|
7
78
|
* (createdAt, updatedAt, createdBy, updatedBy) into every collection and
|
|
@@ -9,6 +80,9 @@ import 'lucide-react';
|
|
|
9
80
|
*/
|
|
10
81
|
declare function normalizeConfig(config: DyrectedConfig): DyrectedConfig;
|
|
11
82
|
|
|
83
|
+
declare function getAdminAuthCollection(config: Pick<DyrectedConfig, "collections" | "adminAuth">): CollectionConfig | null;
|
|
84
|
+
declare function getPublicAdminAuthConfig(adminAuth?: AdminAuthConfig): PublicAdminAuthConfig;
|
|
85
|
+
|
|
12
86
|
/**
|
|
13
87
|
* Dyrected Where Clause DSL — shared query language across all database adapters.
|
|
14
88
|
*
|
|
@@ -267,4 +341,4 @@ declare function defineGlobal<TDoc extends object>(config: GlobalConfig<TDoc>):
|
|
|
267
341
|
*/
|
|
268
342
|
declare function defineConfig(config: DyrectedConfig): DyrectedConfig;
|
|
269
343
|
|
|
270
|
-
export { AuthDocFields, AuthenticatedUser, BaseDocument, CollectionConfig, DyrectedConfig, Field, GlobalConfig, HookRequestContext, InferDocShape, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, Prettify, type SortClause, type SortDirection, type SqlWhereResult, SystemDocFields, UploadDocFields, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, defineCollection, defineConfig, defineGlobal, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, parseMongoWhere, parseSort, parseSqlWhere, publishingWorkflow, runCollectionHooks, saveWorkflowDraft, transitionWorkflow, workflowCapabilities };
|
|
344
|
+
export { AdminAuthConfig, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, CollectionConfig, DyrectedConfig, Field, GlobalConfig, HookRequestContext, type InferDocShape, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, type Prettify, PublicAdminAuthConfig, type SortClause, type SortDirection, type SqlWhereResult, type SystemDocFields, type UploadDocFields, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, defineCollection, defineConfig, defineGlobal, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, parseMongoWhere, parseSort, parseSqlWhere, publishingWorkflow, runCollectionHooks, saveWorkflowDraft, transitionWorkflow, workflowCapabilities };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,78 @@
|
|
|
1
|
-
import {
|
|
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, G as GlobalConfig } from './app-config-BLMX-9MN.js';
|
|
2
|
+
export { e as AccessFunction, f as AdminAuthAccessResolution, g as AdminAuthClaimMapping, h as AdminAuthProvider, i as AdminAuthProvisioningMode, j as AdminAuthResolveAccessArgs, k as AdminAuthResolvedIdentity, l as AdminConfig, m as AdminDashboardComponentSlots, n as AdminIconName, o as ArrayField, p as BaseAdminAuthProvider, q as BlocksField, r as BooleanField, s as CharacterLimitFieldConfig, t as CollectionAfterChangeHook, u as CollectionAfterDeleteHook, v as CollectionAfterReadHook, w as CollectionAfterTransitionHook, x as CollectionBeforeChangeHook, y as CollectionBeforeDeleteHook, z as CollectionBeforeReadHook, E as CollectionBeforeTransitionHook, I as CollectionListComponentSlots, J as CustomAdminAuthProvider, K as DatabaseAdapter, M as DateField, N as DateTimeField, O as DynamicOptionItem, Q as DynamicOptionsConfig, R as DynamicOptionsResolver, S as DynamicOptionsResolverArgs, T as EmailField, U as FieldAdminOnChangeHook, V as FieldAdminOnChangeHookArgs, X as FieldAdminOptionsHook, Y as FieldAdminOptionsHookArgs, Z as FieldAdminOptionsHookResult, _ as FieldAfterReadHook, $ as FieldAfterReadHookArgs, a0 as FieldBeforeChangeHook, a1 as FieldBeforeChangeHookArgs, a2 as FieldHook, a3 as FieldType, a4 as FileData, a5 as GlobalAfterChangeHook, a6 as GlobalAfterReadHook, a7 as GlobalBeforeChangeHook, a8 as GlobalBeforeReadHook, a9 as HookFunction, aa as IconField, ab as ImageField, ac as ImageService, ad as JoinField, ae as JsonField, af as LIFECYCLE_EVENT_NAMES, ag as LifecycleEventHandler, ah as MultiSelectField, ai as NumberField, aj as OIDCAdminAuthProvider, ak as ObjectField, al as PaginatedResult, am as PublicAdminAuthProvider, an as RadioField, ao as ReadonlyDatabaseAdapter, ap as RelationshipField, aq as RichTextField, ar as RowField, as as SelectField, at as StorageAdapter, au as TextField, av as TextareaField, aw as TimeField, ax as UploadConfig, ay as UrlField, az as WordLimitFieldConfig, aA as WorkflowMetadata, aB as WorkflowRole, aC as WorkflowState, aD as WorkflowTransitionContext } from './app-config-BLMX-9MN.js';
|
|
3
3
|
import 'lucide-react';
|
|
4
4
|
|
|
5
|
+
type Prettify<T> = {
|
|
6
|
+
[K in keyof T]: T[K];
|
|
7
|
+
};
|
|
8
|
+
type FieldValueType<F extends Field> = F["type"] extends "text" | "textarea" | "email" | "url" | "icon" | "date" | "datetime" | "time" | "select" | "radio" ? string : F["type"] extends "number" ? number : F["type"] extends "boolean" ? boolean : F["type"] extends "multiSelect" ? string[] : F["type"] extends "relationship" ? F extends {
|
|
9
|
+
hasMany: true;
|
|
10
|
+
} ? string[] : string : F["type"] extends "image" ? F extends {
|
|
11
|
+
hasMany: true;
|
|
12
|
+
} ? string[] : string : F["type"] extends "richText" | "json" ? Record<string, unknown> : F["type"] extends "object" ? F extends {
|
|
13
|
+
fields: infer SF extends readonly Field[];
|
|
14
|
+
} ? Prettify<InferDocShape<SF>> : Record<string, unknown> : F["type"] extends "array" ? F extends {
|
|
15
|
+
fields: infer SF extends readonly Field[];
|
|
16
|
+
} ? Array<Prettify<InferDocShape<SF>>> : unknown[] : F["type"] extends "blocks" ? F extends {
|
|
17
|
+
blocks: infer B extends readonly Block[];
|
|
18
|
+
} ? Array<InferBlocksUnion<B>> : Array<{
|
|
19
|
+
blockType: string;
|
|
20
|
+
} & Record<string, unknown>> : unknown;
|
|
21
|
+
type InferBlocksUnion<Blocks extends readonly Block[]> = Blocks extends readonly [
|
|
22
|
+
infer B extends Block,
|
|
23
|
+
...infer Rest extends readonly Block[]
|
|
24
|
+
] ? B["fields"] extends readonly Field[] ? ({
|
|
25
|
+
blockType: B["slug"];
|
|
26
|
+
} & Prettify<InferDocShape<B["fields"]>>) | InferBlocksUnion<Rest> : ({
|
|
27
|
+
blockType: B["slug"];
|
|
28
|
+
} & Record<string, unknown>) | InferBlocksUnion<Rest> : never;
|
|
29
|
+
type InferFieldEntry<F extends Field> = F extends {
|
|
30
|
+
type: "row";
|
|
31
|
+
fields: infer SF extends readonly Field[];
|
|
32
|
+
} ? InferDocShape<SF> : F extends {
|
|
33
|
+
type: "join";
|
|
34
|
+
} ? Record<never, never> : F extends {
|
|
35
|
+
name: infer N extends string;
|
|
36
|
+
required: true;
|
|
37
|
+
} ? {
|
|
38
|
+
[K in N]: FieldValueType<F>;
|
|
39
|
+
} : F extends {
|
|
40
|
+
name: infer N extends string;
|
|
41
|
+
} ? {
|
|
42
|
+
[K in N]?: FieldValueType<F>;
|
|
43
|
+
} : Record<never, never>;
|
|
44
|
+
type InferDocShape<Fields extends readonly Field[]> = Fields extends readonly [] ? Record<never, never> : Fields extends readonly [infer Head extends Field, ...infer Tail extends readonly Field[]] ? InferFieldEntry<Head> & InferDocShape<Tail> : Record<string, unknown>;
|
|
45
|
+
type SystemDocFields = {
|
|
46
|
+
createdAt?: string;
|
|
47
|
+
updatedAt?: string;
|
|
48
|
+
createdBy?: string;
|
|
49
|
+
updatedBy?: string;
|
|
50
|
+
};
|
|
51
|
+
type AuthDocFields = {
|
|
52
|
+
email: string;
|
|
53
|
+
password?: string;
|
|
54
|
+
roles?: string[];
|
|
55
|
+
};
|
|
56
|
+
type UploadDocFields = {
|
|
57
|
+
filename: string;
|
|
58
|
+
filesize?: number;
|
|
59
|
+
mimeType: string;
|
|
60
|
+
url: string;
|
|
61
|
+
width?: number;
|
|
62
|
+
height?: number;
|
|
63
|
+
focalPoint?: {
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
66
|
+
};
|
|
67
|
+
blurhash?: string;
|
|
68
|
+
sizes?: Record<string, {
|
|
69
|
+
filename?: string;
|
|
70
|
+
url?: string;
|
|
71
|
+
width?: number;
|
|
72
|
+
height?: number;
|
|
73
|
+
}>;
|
|
74
|
+
};
|
|
75
|
+
|
|
5
76
|
/**
|
|
6
77
|
* Normalizes the Dyrected configuration by injecting system fields
|
|
7
78
|
* (createdAt, updatedAt, createdBy, updatedBy) into every collection and
|
|
@@ -9,6 +80,9 @@ import 'lucide-react';
|
|
|
9
80
|
*/
|
|
10
81
|
declare function normalizeConfig(config: DyrectedConfig): DyrectedConfig;
|
|
11
82
|
|
|
83
|
+
declare function getAdminAuthCollection(config: Pick<DyrectedConfig, "collections" | "adminAuth">): CollectionConfig | null;
|
|
84
|
+
declare function getPublicAdminAuthConfig(adminAuth?: AdminAuthConfig): PublicAdminAuthConfig;
|
|
85
|
+
|
|
12
86
|
/**
|
|
13
87
|
* Dyrected Where Clause DSL — shared query language across all database adapters.
|
|
14
88
|
*
|
|
@@ -267,4 +341,4 @@ declare function defineGlobal<TDoc extends object>(config: GlobalConfig<TDoc>):
|
|
|
267
341
|
*/
|
|
268
342
|
declare function defineConfig(config: DyrectedConfig): DyrectedConfig;
|
|
269
343
|
|
|
270
|
-
export { AuthDocFields, AuthenticatedUser, BaseDocument, CollectionConfig, DyrectedConfig, Field, GlobalConfig, HookRequestContext, InferDocShape, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, Prettify, type SortClause, type SortDirection, type SqlWhereResult, SystemDocFields, UploadDocFields, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, defineCollection, defineConfig, defineGlobal, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, parseMongoWhere, parseSort, parseSqlWhere, publishingWorkflow, runCollectionHooks, saveWorkflowDraft, transitionWorkflow, workflowCapabilities };
|
|
344
|
+
export { AdminAuthConfig, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, CollectionConfig, DyrectedConfig, Field, GlobalConfig, HookRequestContext, type InferDocShape, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, type Prettify, PublicAdminAuthConfig, type SortClause, type SortDirection, type SqlWhereResult, type SystemDocFields, type UploadDocFields, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, defineCollection, defineConfig, defineGlobal, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, parseMongoWhere, parseSort, parseSqlWhere, publishingWorkflow, runCollectionHooks, saveWorkflowDraft, transitionWorkflow, workflowCapabilities };
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
executeFieldAfterRead,
|
|
11
11
|
executeFieldBeforeChange,
|
|
12
12
|
generateOpenApi,
|
|
13
|
+
getAdminAuthCollection,
|
|
14
|
+
getPublicAdminAuthConfig,
|
|
13
15
|
initializeWorkflowDocument,
|
|
14
16
|
materializeWorkflowDocument,
|
|
15
17
|
normalizeConfig,
|
|
@@ -18,9 +20,9 @@ import {
|
|
|
18
20
|
saveWorkflowDraft,
|
|
19
21
|
transitionWorkflow,
|
|
20
22
|
workflowCapabilities
|
|
21
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-FCXE5CVC.js";
|
|
22
24
|
|
|
23
|
-
// src/types/
|
|
25
|
+
// src/types/workflows.ts
|
|
24
26
|
var LIFECYCLE_EVENT_NAMES = [
|
|
25
27
|
"revision.created",
|
|
26
28
|
"workflow.transitioned",
|
|
@@ -229,6 +231,8 @@ export {
|
|
|
229
231
|
executeFieldAfterRead,
|
|
230
232
|
executeFieldBeforeChange,
|
|
231
233
|
generateOpenApi,
|
|
234
|
+
getAdminAuthCollection,
|
|
235
|
+
getPublicAdminAuthConfig,
|
|
232
236
|
initializeWorkflowDocument,
|
|
233
237
|
materializeWorkflowDocument,
|
|
234
238
|
normalizeConfig,
|