@dyrected/core 0.0.1 → 1.0.1
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/LICENSE.md +50 -0
- package/README.md +35 -1
- package/dist/chunk-FURYJ254.mjs +33 -0
- package/dist/chunk-GM4WW6IE.js +66 -0
- package/dist/index-D38_E0gf.d.cts +336 -0
- package/dist/index-D38_E0gf.d.ts +336 -0
- package/dist/index-RylhgOwj.d.cts +340 -0
- package/dist/index-RylhgOwj.d.ts +340 -0
- package/dist/index.cjs +413 -0
- package/dist/index.d.cts +33 -0
- package/dist/index.d.mts +163 -11
- package/dist/index.d.ts +15 -247
- package/dist/index.js +298 -366
- package/dist/index.mjs +1692 -77
- package/dist/server.cjs +1827 -0
- package/dist/server.d.cts +243 -0
- package/dist/server.d.ts +243 -0
- package/dist/server.js +1725 -0
- package/dist/token-7QG5DBME.mjs +10 -0
- package/package.json +32 -3
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
type FieldType = "text" | "textarea" | "richText" | "number" | "boolean" | "date" | "select" | "multiSelect" | "relationship" | "array" | "object" | "json" | "blocks" | "image" | "email" | "url";
|
|
2
|
+
interface Block {
|
|
3
|
+
slug: string;
|
|
4
|
+
labels?: {
|
|
5
|
+
singular: string;
|
|
6
|
+
plural: string;
|
|
7
|
+
};
|
|
8
|
+
fields: Field[];
|
|
9
|
+
}
|
|
10
|
+
interface Field {
|
|
11
|
+
name: string;
|
|
12
|
+
type: FieldType;
|
|
13
|
+
label?: string;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
unique?: boolean;
|
|
16
|
+
defaultValue?: any;
|
|
17
|
+
options?: string[] | {
|
|
18
|
+
label: string;
|
|
19
|
+
value: string;
|
|
20
|
+
}[];
|
|
21
|
+
relationTo?: string;
|
|
22
|
+
hasMany?: boolean;
|
|
23
|
+
fields?: Field[];
|
|
24
|
+
blocks?: Block[];
|
|
25
|
+
access?: {
|
|
26
|
+
read?: AccessFunction;
|
|
27
|
+
update?: AccessFunction;
|
|
28
|
+
};
|
|
29
|
+
hooks?: {
|
|
30
|
+
beforeChange?: FieldHook[];
|
|
31
|
+
afterRead?: FieldHook[];
|
|
32
|
+
};
|
|
33
|
+
admin?: {
|
|
34
|
+
placeholder?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
hidden?: boolean;
|
|
37
|
+
readOnly?: boolean;
|
|
38
|
+
condition?: ((data: any, siblingData: any) => boolean) | string;
|
|
39
|
+
layout?: "radio" | "select" | string;
|
|
40
|
+
direction?: "horizontal" | "vertical";
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
type AccessFunction = (args: {
|
|
44
|
+
user: any;
|
|
45
|
+
doc?: any;
|
|
46
|
+
data?: any;
|
|
47
|
+
req: any;
|
|
48
|
+
}) => boolean | object | Promise<boolean | object>;
|
|
49
|
+
type HookFunction = (args: {
|
|
50
|
+
data?: any;
|
|
51
|
+
doc?: any;
|
|
52
|
+
user?: any;
|
|
53
|
+
req?: any;
|
|
54
|
+
/** The operation that triggered this hook. */
|
|
55
|
+
operation?: 'create' | 'update' | 'delete';
|
|
56
|
+
}) => any | Promise<any>;
|
|
57
|
+
type FieldHook = (args: {
|
|
58
|
+
value: any;
|
|
59
|
+
originalDoc?: any;
|
|
60
|
+
data?: any;
|
|
61
|
+
user?: any;
|
|
62
|
+
}) => any | Promise<any>;
|
|
63
|
+
interface CollectionConfig {
|
|
64
|
+
slug: string;
|
|
65
|
+
siteId?: string;
|
|
66
|
+
shared?: boolean;
|
|
67
|
+
labels?: {
|
|
68
|
+
singular: string;
|
|
69
|
+
plural: string;
|
|
70
|
+
};
|
|
71
|
+
auth?: boolean;
|
|
72
|
+
upload?: boolean | UploadConfig;
|
|
73
|
+
fields: Field[];
|
|
74
|
+
timestamps?: boolean;
|
|
75
|
+
/** Enable full activity logging to the __audit collection for this collection. */
|
|
76
|
+
audit?: boolean;
|
|
77
|
+
access?: {
|
|
78
|
+
read?: AccessFunction;
|
|
79
|
+
create?: AccessFunction;
|
|
80
|
+
update?: AccessFunction;
|
|
81
|
+
delete?: AccessFunction;
|
|
82
|
+
};
|
|
83
|
+
hooks?: {
|
|
84
|
+
beforeRead?: HookFunction[];
|
|
85
|
+
afterRead?: HookFunction[];
|
|
86
|
+
beforeChange?: HookFunction[];
|
|
87
|
+
afterChange?: HookFunction[];
|
|
88
|
+
beforeDelete?: HookFunction[];
|
|
89
|
+
afterDelete?: HookFunction[];
|
|
90
|
+
};
|
|
91
|
+
admin?: {
|
|
92
|
+
useAsTitle?: string;
|
|
93
|
+
defaultColumns?: string[];
|
|
94
|
+
group?: string;
|
|
95
|
+
hidden?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* URL to open in the Live Preview pane.
|
|
98
|
+
* Accepts a static string or a function that receives the document and returns a URL.
|
|
99
|
+
*/
|
|
100
|
+
previewUrl?: string | ((doc: any, opts: {
|
|
101
|
+
locale?: string;
|
|
102
|
+
}) => string | null);
|
|
103
|
+
/** Which mode to use for live preview. Defaults to 'postMessage'. */
|
|
104
|
+
previewMode?: 'postMessage' | 'token';
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
interface UploadConfig {
|
|
108
|
+
allowedMimeTypes?: string[];
|
|
109
|
+
maxFileSize?: number;
|
|
110
|
+
/** Local disk path where files are stored. Only used by LocalStorage adapter. */
|
|
111
|
+
staticDir?: string;
|
|
112
|
+
/** Public URL prefix for locally stored files. Only used by LocalStorage adapter. */
|
|
113
|
+
staticURL?: string;
|
|
114
|
+
/** Which imageSizes entry to use as the thumbnail in the Admin media grid. */
|
|
115
|
+
adminThumbnail?: string;
|
|
116
|
+
imageSizes?: {
|
|
117
|
+
name: string;
|
|
118
|
+
width?: number;
|
|
119
|
+
height?: number;
|
|
120
|
+
crop?: string;
|
|
121
|
+
/** sharp fit strategy: 'cover' | 'contain' | 'fill' | 'inside' | 'outside' */
|
|
122
|
+
fit?: string;
|
|
123
|
+
/** Never upscale images smaller than the target size. Default: true. */
|
|
124
|
+
withoutEnlargement?: boolean;
|
|
125
|
+
/** Additional sharp format options. */
|
|
126
|
+
formatOptions?: Record<string, any>;
|
|
127
|
+
}[];
|
|
128
|
+
}
|
|
129
|
+
interface GlobalConfig {
|
|
130
|
+
slug: string;
|
|
131
|
+
siteId?: string;
|
|
132
|
+
shared?: boolean;
|
|
133
|
+
label?: string;
|
|
134
|
+
fields: Field[];
|
|
135
|
+
access?: {
|
|
136
|
+
read?: AccessFunction;
|
|
137
|
+
update?: AccessFunction;
|
|
138
|
+
};
|
|
139
|
+
hooks?: {
|
|
140
|
+
beforeRead?: HookFunction[];
|
|
141
|
+
afterRead?: HookFunction[];
|
|
142
|
+
beforeChange?: HookFunction[];
|
|
143
|
+
afterChange?: HookFunction[];
|
|
144
|
+
};
|
|
145
|
+
admin?: {
|
|
146
|
+
group?: string;
|
|
147
|
+
hidden?: boolean;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
interface PaginatedResult<T = any> {
|
|
151
|
+
docs: T[];
|
|
152
|
+
total: number;
|
|
153
|
+
limit: number;
|
|
154
|
+
page: number;
|
|
155
|
+
/** Total number of pages given the current limit. */
|
|
156
|
+
totalPages: number;
|
|
157
|
+
hasNextPage: boolean;
|
|
158
|
+
hasPrevPage: boolean;
|
|
159
|
+
}
|
|
160
|
+
interface DatabaseAdapter {
|
|
161
|
+
find(args: {
|
|
162
|
+
collection: string;
|
|
163
|
+
where?: any;
|
|
164
|
+
limit?: number;
|
|
165
|
+
page?: number;
|
|
166
|
+
sort?: string;
|
|
167
|
+
}): Promise<PaginatedResult>;
|
|
168
|
+
findOne(args: {
|
|
169
|
+
collection: string;
|
|
170
|
+
id: string;
|
|
171
|
+
}): Promise<any>;
|
|
172
|
+
create(args: {
|
|
173
|
+
collection: string;
|
|
174
|
+
data: any;
|
|
175
|
+
}): Promise<any>;
|
|
176
|
+
update(args: {
|
|
177
|
+
collection: string;
|
|
178
|
+
id: string;
|
|
179
|
+
data: any;
|
|
180
|
+
}): Promise<any>;
|
|
181
|
+
delete(args: {
|
|
182
|
+
collection: string;
|
|
183
|
+
id: string;
|
|
184
|
+
}): Promise<any>;
|
|
185
|
+
getGlobal(args: {
|
|
186
|
+
slug: string;
|
|
187
|
+
}): Promise<any>;
|
|
188
|
+
updateGlobal(args: {
|
|
189
|
+
slug: string;
|
|
190
|
+
data: any;
|
|
191
|
+
}): Promise<any>;
|
|
192
|
+
/**
|
|
193
|
+
* Sync the database schema with the provided collections and globals.
|
|
194
|
+
* Useful for creating tables on startup.
|
|
195
|
+
*/
|
|
196
|
+
sync?(collections: CollectionConfig[], globals: GlobalConfig[]): Promise<void>;
|
|
197
|
+
/**
|
|
198
|
+
* Low-level raw query execution.
|
|
199
|
+
* Optional as not all adapters may support raw SQL/commands.
|
|
200
|
+
*/
|
|
201
|
+
execute?(query: string, params?: any[]): Promise<any>;
|
|
202
|
+
}
|
|
203
|
+
interface FileData {
|
|
204
|
+
filename: string;
|
|
205
|
+
filesize?: number;
|
|
206
|
+
mimeType: string;
|
|
207
|
+
url: string;
|
|
208
|
+
width?: number;
|
|
209
|
+
height?: number;
|
|
210
|
+
focalPoint?: {
|
|
211
|
+
x: number;
|
|
212
|
+
y: number;
|
|
213
|
+
};
|
|
214
|
+
blurhash?: string;
|
|
215
|
+
type?: "upload" | "external";
|
|
216
|
+
provider?: string;
|
|
217
|
+
provider_metadata?: any;
|
|
218
|
+
[key: string]: any;
|
|
219
|
+
}
|
|
220
|
+
interface StorageAdapter {
|
|
221
|
+
upload(args: {
|
|
222
|
+
filename: string;
|
|
223
|
+
buffer: Uint8Array;
|
|
224
|
+
mimeType: string;
|
|
225
|
+
prefix?: string;
|
|
226
|
+
}): Promise<FileData>;
|
|
227
|
+
delete(args: {
|
|
228
|
+
filename: string;
|
|
229
|
+
}): Promise<void>;
|
|
230
|
+
getURL(args: {
|
|
231
|
+
filename: string;
|
|
232
|
+
}): string;
|
|
233
|
+
/** Retrieve file content for serving via API */
|
|
234
|
+
resolve?(args: {
|
|
235
|
+
filename: string;
|
|
236
|
+
}): Promise<{
|
|
237
|
+
buffer: Uint8Array;
|
|
238
|
+
mimeType: string;
|
|
239
|
+
} | null>;
|
|
240
|
+
}
|
|
241
|
+
/** Branding and metadata configuration for the Admin UI. */
|
|
242
|
+
interface AdminConfig {
|
|
243
|
+
branding?: {
|
|
244
|
+
/** URL or imported image for the full logo shown in the sidebar. */
|
|
245
|
+
logo?: string;
|
|
246
|
+
/** URL or imported image for the compact logo mark used in collapsed sidebar. */
|
|
247
|
+
logoMark?: string;
|
|
248
|
+
/** Primary accent colour as a CSS value (e.g. '#6366f1' or 'hsl(240 50% 60%)') */
|
|
249
|
+
primaryColor?: string;
|
|
250
|
+
/** URL for the browser tab favicon. */
|
|
251
|
+
favicon?: string;
|
|
252
|
+
/** Default font family for body and UI elements (sans-serif). */
|
|
253
|
+
fontSans?: string;
|
|
254
|
+
/** Default font family for headings and display elements (serif). */
|
|
255
|
+
fontSerif?: string;
|
|
256
|
+
};
|
|
257
|
+
meta?: {
|
|
258
|
+
/** Appended to every Admin page title. Default: '- Dyrected' */
|
|
259
|
+
titleSuffix?: string;
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
interface ImageService {
|
|
263
|
+
process(args: {
|
|
264
|
+
buffer: Uint8Array;
|
|
265
|
+
mimeType: string;
|
|
266
|
+
config?: CollectionConfig['upload'];
|
|
267
|
+
focalPoint?: {
|
|
268
|
+
x: number;
|
|
269
|
+
y: number;
|
|
270
|
+
};
|
|
271
|
+
}): Promise<{
|
|
272
|
+
metadata: {
|
|
273
|
+
width?: number;
|
|
274
|
+
height?: number;
|
|
275
|
+
blurhash?: string;
|
|
276
|
+
};
|
|
277
|
+
sizes?: Record<string, {
|
|
278
|
+
buffer: Uint8Array;
|
|
279
|
+
width: number;
|
|
280
|
+
height: number;
|
|
281
|
+
filename: string;
|
|
282
|
+
}>;
|
|
283
|
+
}>;
|
|
284
|
+
}
|
|
285
|
+
interface DyrectedConfig {
|
|
286
|
+
collections: CollectionConfig[];
|
|
287
|
+
globals: GlobalConfig[];
|
|
288
|
+
db?: DatabaseAdapter;
|
|
289
|
+
storage?: StorageAdapter;
|
|
290
|
+
image?: ImageService;
|
|
291
|
+
/** Admin UI branding and meta configuration. */
|
|
292
|
+
admin?: AdminConfig;
|
|
293
|
+
email?: {
|
|
294
|
+
from: string;
|
|
295
|
+
send: (args: {
|
|
296
|
+
to: string;
|
|
297
|
+
subject: string;
|
|
298
|
+
html: string;
|
|
299
|
+
}) => Promise<void>;
|
|
300
|
+
templates?: {
|
|
301
|
+
welcome?: (args: {
|
|
302
|
+
email: string;
|
|
303
|
+
}) => {
|
|
304
|
+
subject?: string;
|
|
305
|
+
html: string;
|
|
306
|
+
};
|
|
307
|
+
invite?: (args: {
|
|
308
|
+
token: string;
|
|
309
|
+
invitedByEmail?: string;
|
|
310
|
+
}) => {
|
|
311
|
+
subject?: string;
|
|
312
|
+
html: string;
|
|
313
|
+
};
|
|
314
|
+
resetPassword?: (args: {
|
|
315
|
+
token: string;
|
|
316
|
+
}) => {
|
|
317
|
+
subject?: string;
|
|
318
|
+
html: string;
|
|
319
|
+
};
|
|
320
|
+
passwordChanged?: (args: {
|
|
321
|
+
email: string;
|
|
322
|
+
}) => {
|
|
323
|
+
subject?: string;
|
|
324
|
+
html: string;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
redis?: {
|
|
329
|
+
url: string;
|
|
330
|
+
};
|
|
331
|
+
cors?: {
|
|
332
|
+
origins: string[];
|
|
333
|
+
};
|
|
334
|
+
onSchemaFetch?: (siteId: string) => Promise<{
|
|
335
|
+
collections?: CollectionConfig[];
|
|
336
|
+
globals?: GlobalConfig[];
|
|
337
|
+
}>;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export type { AccessFunction as A, Block as B, CollectionConfig as C, DyrectedConfig as D, Field as F, GlobalConfig as G, HookFunction as H, ImageService as I, PaginatedResult as P, StorageAdapter as S, UploadConfig as U, AdminConfig as a, DatabaseAdapter as b, FieldHook as c, FieldType as d, FileData as e };
|