@kyro-cms/core 0.5.4 → 0.5.5
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/WebhookService-118ZTFis.d.ts +112 -0
- package/dist/WebhookService-AefJfqX0.d.cts +112 -0
- package/dist/adapter-BSvBudTG.d.cts +65 -0
- package/dist/adapter-CXGB2Elb.d.ts +65 -0
- package/dist/api-handler.cjs +26 -8
- package/dist/api-handler.cjs.map +1 -1
- package/dist/api-handler.d.cts +9 -0
- package/dist/api-handler.d.ts +9 -0
- package/dist/api-handler.js +25 -7
- package/dist/api-handler.js.map +1 -1
- package/dist/base-DvvNqnM-.d.cts +73 -0
- package/dist/base-eVegJ_Pr.d.ts +73 -0
- package/dist/bootstrap-4MH44YKG.js +6 -0
- package/dist/{bootstrap-PBMMLBQC.js.map → bootstrap-4MH44YKG.js.map} +1 -1
- package/dist/bootstrap-EE6BJZWL.cjs +31 -0
- package/dist/{bootstrap-QN77EVI3.cjs.map → bootstrap-EE6BJZWL.cjs.map} +1 -1
- package/dist/chunk-3YELQL7Z.cjs +4 -0
- package/dist/chunk-3YELQL7Z.cjs.map +1 -0
- package/dist/{chunk-AGAIUDAV.cjs → chunk-55BNRTLW.cjs} +7 -7
- package/dist/chunk-55BNRTLW.cjs.map +1 -0
- package/dist/{chunk-XJ2VYR47.cjs → chunk-5HA5OMFH.cjs} +10 -7
- package/dist/chunk-5HA5OMFH.cjs.map +1 -0
- package/dist/{chunk-C4JJEE42.js → chunk-6WXQRYTW.js} +262 -43
- package/dist/chunk-6WXQRYTW.js.map +1 -0
- package/dist/{chunk-SO25EHOE.js → chunk-AM4JKIPP.js} +180 -77
- package/dist/chunk-AM4JKIPP.js.map +1 -0
- package/dist/{chunk-VSTRLXMQ.cjs → chunk-CKVOU6MX.cjs} +4 -2
- package/dist/chunk-CKVOU6MX.cjs.map +1 -0
- package/dist/chunk-GTGRLD4Y.js +3 -0
- package/dist/chunk-GTGRLD4Y.js.map +1 -0
- package/dist/chunk-MTIRYI7F.cjs +4 -0
- package/dist/chunk-MTIRYI7F.cjs.map +1 -0
- package/dist/{chunk-342BJNBI.js → chunk-QKVA2SOG.js} +300 -6
- package/dist/chunk-QKVA2SOG.js.map +1 -0
- package/dist/chunk-QU2RFFH4.js +3 -0
- package/dist/chunk-QU2RFFH4.js.map +1 -0
- package/dist/{chunk-ATVNYGRQ.js → chunk-QYZKIPSD.js} +7 -18
- package/dist/chunk-QYZKIPSD.js.map +1 -0
- package/dist/{chunk-SYRDCLH7.cjs → chunk-R2YHJN6W.cjs} +184 -81
- package/dist/chunk-R2YHJN6W.cjs.map +1 -0
- package/dist/{chunk-IX3ABYKZ.cjs → chunk-RALQO47U.cjs} +170 -2
- package/dist/chunk-RALQO47U.cjs.map +1 -0
- package/dist/{chunk-EVEJC22G.cjs → chunk-RDRJVCL5.cjs} +37 -5
- package/dist/chunk-RDRJVCL5.cjs.map +1 -0
- package/dist/{chunk-6COM32WF.js → chunk-RP7VZUEL.js} +5 -3
- package/dist/chunk-RP7VZUEL.js.map +1 -0
- package/dist/{chunk-XR5EJS3C.js → chunk-S3FG2NY7.js} +7 -4
- package/dist/chunk-S3FG2NY7.js.map +1 -0
- package/dist/{chunk-WH4Y5MT6.js → chunk-TP5YQFIX.js} +36 -4
- package/dist/chunk-TP5YQFIX.js.map +1 -0
- package/dist/{chunk-DBUYB32X.js → chunk-TVVYZ2TH.js} +171 -3
- package/dist/chunk-TVVYZ2TH.js.map +1 -0
- package/dist/{chunk-GBH6DN5C.cjs → chunk-WBCIEYHC.cjs} +8 -18
- package/dist/chunk-WBCIEYHC.cjs.map +1 -0
- package/dist/{chunk-3ZZPZYCM.cjs → chunk-WVPOPOEQ.cjs} +269 -41
- package/dist/chunk-WVPOPOEQ.cjs.map +1 -0
- package/dist/{chunk-W3KPQX7V.cjs → chunk-XAEBVZTI.cjs} +304 -4
- package/dist/chunk-XAEBVZTI.cjs.map +1 -0
- package/dist/{chunk-Q4DNT7FO.js → chunk-XU7AFF6V.js} +6 -6
- package/dist/chunk-XU7AFF6V.js.map +1 -0
- package/dist/cli/index.cjs +6 -4
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +6 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/client.d.cts +12 -0
- package/dist/client.d.ts +12 -0
- package/dist/drizzle/index.cjs +18 -18
- package/dist/drizzle/index.d.cts +152 -0
- package/dist/drizzle/index.d.ts +152 -0
- package/dist/drizzle/index.js +3 -3
- package/dist/fields/index.d.cts +27 -0
- package/dist/fields/index.d.ts +27 -0
- package/dist/graphql/index.d.cts +22 -0
- package/dist/graphql/index.d.ts +22 -0
- package/dist/index-Bz9JqRGI.d.cts +86 -0
- package/dist/index-Bz9JqRGI.d.ts +86 -0
- package/dist/index-CLp-DRKA.d.ts +64 -0
- package/dist/index-DfO7G4kN.d.cts +64 -0
- package/dist/index.cjs +118 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1368 -0
- package/dist/index.d.ts +1368 -0
- package/dist/index.js +48 -14
- package/dist/index.js.map +1 -1
- package/dist/integration.cjs +2 -2
- package/dist/integration.d.cts +27 -0
- package/dist/integration.d.ts +27 -0
- package/dist/integration.js +1 -1
- package/dist/media-GPPTZ43E.js +4 -0
- package/dist/{media-HOT3O7RW.js.map → media-GPPTZ43E.js.map} +1 -1
- package/dist/media-XNTUFJZR.cjs +17 -0
- package/dist/{media-WKP5AOX2.cjs.map → media-XNTUFJZR.cjs.map} +1 -1
- package/dist/mongodb/index.cjs +12 -3
- package/dist/mongodb/index.d.cts +59 -0
- package/dist/mongodb/index.d.ts +59 -0
- package/dist/mongodb/index.js +2 -1
- package/dist/postgres-auth-adapter-6742WDCF.cjs +14 -0
- package/dist/{postgres-auth-adapter-Z463NYJZ.cjs.map → postgres-auth-adapter-6742WDCF.cjs.map} +1 -1
- package/dist/postgres-auth-adapter-B65BULNS.js +5 -0
- package/dist/{postgres-auth-adapter-7F3ECO7I.js.map → postgres-auth-adapter-B65BULNS.js.map} +1 -1
- package/dist/rest/index.cjs +9 -5
- package/dist/rest/index.d.cts +57 -0
- package/dist/rest/index.d.ts +57 -0
- package/dist/rest/index.js +7 -3
- package/dist/{schema-TIYTCIKX.cjs → schema-37SE2F4B.cjs} +5 -5
- package/dist/{schema-TIYTCIKX.cjs.map → schema-37SE2F4B.cjs.map} +1 -1
- package/dist/{schema-6Q4W6AE6.js → schema-5PHL5IVB.js} +3 -3
- package/dist/{schema-6Q4W6AE6.js.map → schema-5PHL5IVB.js.map} +1 -1
- package/dist/templates/index.d.cts +59 -0
- package/dist/templates/index.d.ts +59 -0
- package/dist/trpc/index.d.cts +136 -0
- package/dist/trpc/index.d.ts +136 -0
- package/dist/types-Bs1up4yP.d.ts +461 -0
- package/dist/types-DqN4ckOC.d.cts +130 -0
- package/dist/types-DqN4ckOC.d.ts +130 -0
- package/dist/types-J3R9nVsZ.d.cts +461 -0
- package/dist/types-VtjUxIMp.d.cts +246 -0
- package/dist/types-VtjUxIMp.d.ts +246 -0
- package/dist/ws/index.d.cts +88 -0
- package/dist/ws/index.d.ts +88 -0
- package/package.json +3 -2
- package/dist/bootstrap-PBMMLBQC.js +0 -6
- package/dist/bootstrap-QN77EVI3.cjs +0 -31
- package/dist/chunk-342BJNBI.js.map +0 -1
- package/dist/chunk-3ZZPZYCM.cjs.map +0 -1
- package/dist/chunk-6COM32WF.js.map +0 -1
- package/dist/chunk-7SXPHG3M.cjs +0 -67
- package/dist/chunk-7SXPHG3M.cjs.map +0 -1
- package/dist/chunk-AGAIUDAV.cjs.map +0 -1
- package/dist/chunk-ATVNYGRQ.js.map +0 -1
- package/dist/chunk-C4JJEE42.js.map +0 -1
- package/dist/chunk-DBUYB32X.js.map +0 -1
- package/dist/chunk-EVEJC22G.cjs.map +0 -1
- package/dist/chunk-GBH6DN5C.cjs.map +0 -1
- package/dist/chunk-IX3ABYKZ.cjs.map +0 -1
- package/dist/chunk-L4E76X2K.js +0 -57
- package/dist/chunk-L4E76X2K.js.map +0 -1
- package/dist/chunk-Q4DNT7FO.js.map +0 -1
- package/dist/chunk-SO25EHOE.js.map +0 -1
- package/dist/chunk-SYRDCLH7.cjs.map +0 -1
- package/dist/chunk-VSTRLXMQ.cjs.map +0 -1
- package/dist/chunk-W3KPQX7V.cjs.map +0 -1
- package/dist/chunk-WH4Y5MT6.js.map +0 -1
- package/dist/chunk-XJ2VYR47.cjs.map +0 -1
- package/dist/chunk-XR5EJS3C.js.map +0 -1
- package/dist/media-HOT3O7RW.js +0 -4
- package/dist/media-WKP5AOX2.cjs +0 -17
- package/dist/postgres-auth-adapter-7F3ECO7I.js +0 -5
- package/dist/postgres-auth-adapter-Z463NYJZ.cjs +0 -14
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
import { F as Field } from './types-VtjUxIMp.cjs';
|
|
2
|
+
|
|
3
|
+
interface Request {
|
|
4
|
+
body?: any;
|
|
5
|
+
headers: Record<string, string>;
|
|
6
|
+
method?: string;
|
|
7
|
+
url?: string;
|
|
8
|
+
cookies?: Record<string, string>;
|
|
9
|
+
query?: Record<string, any>;
|
|
10
|
+
}
|
|
11
|
+
interface User {
|
|
12
|
+
id: string;
|
|
13
|
+
email: string;
|
|
14
|
+
role: string;
|
|
15
|
+
tenantID?: string;
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
18
|
+
interface HookArgs<T = any> {
|
|
19
|
+
collection?: string;
|
|
20
|
+
global?: string;
|
|
21
|
+
data?: T;
|
|
22
|
+
originalDoc?: T;
|
|
23
|
+
doc?: T;
|
|
24
|
+
req: Request;
|
|
25
|
+
user?: User;
|
|
26
|
+
operation: 'create' | 'read' | 'update' | 'delete';
|
|
27
|
+
tenantID?: string;
|
|
28
|
+
field?: string;
|
|
29
|
+
siblingData?: Record<string, any>;
|
|
30
|
+
value?: any;
|
|
31
|
+
previousValue?: any;
|
|
32
|
+
context?: Record<string, any>;
|
|
33
|
+
}
|
|
34
|
+
type Hook<T = any> = (args: HookArgs<T>) => Promise<T | void> | T | void;
|
|
35
|
+
interface CollectionHooks {
|
|
36
|
+
beforeValidate?: Hook[];
|
|
37
|
+
beforeChange?: Hook[];
|
|
38
|
+
afterChange?: Hook[];
|
|
39
|
+
beforeRead?: Hook[];
|
|
40
|
+
afterRead?: Hook[];
|
|
41
|
+
beforeDelete?: Hook[];
|
|
42
|
+
afterDelete?: Hook[];
|
|
43
|
+
beforeLogin?: Hook[];
|
|
44
|
+
afterLogin?: Hook[];
|
|
45
|
+
afterLogout?: Hook[];
|
|
46
|
+
afterRefresh?: Hook[];
|
|
47
|
+
afterForgotPassword?: Hook[];
|
|
48
|
+
}
|
|
49
|
+
interface FieldHooks {
|
|
50
|
+
beforeValidate?: Hook[];
|
|
51
|
+
beforeChange?: Hook[];
|
|
52
|
+
afterChange?: Hook[];
|
|
53
|
+
afterRead?: Hook[];
|
|
54
|
+
}
|
|
55
|
+
interface GlobalHooks {
|
|
56
|
+
beforeValidate?: Hook[];
|
|
57
|
+
beforeChange?: Hook[];
|
|
58
|
+
afterChange?: Hook[];
|
|
59
|
+
beforeRead?: Hook[];
|
|
60
|
+
afterRead?: Hook[];
|
|
61
|
+
}
|
|
62
|
+
declare function runHooks(hooks: Hook[], args: HookArgs): Promise<any>;
|
|
63
|
+
declare function runFieldHooks(hooks: Hook[], args: HookArgs): Promise<any>;
|
|
64
|
+
|
|
65
|
+
interface WhereClause {
|
|
66
|
+
[field: string]: any;
|
|
67
|
+
}
|
|
68
|
+
interface AccessArgs {
|
|
69
|
+
req: Request;
|
|
70
|
+
user?: User;
|
|
71
|
+
data?: any;
|
|
72
|
+
doc?: any;
|
|
73
|
+
id?: string;
|
|
74
|
+
tenantID?: string;
|
|
75
|
+
context?: Record<string, any>;
|
|
76
|
+
}
|
|
77
|
+
type AccessControl = boolean | ((args: AccessArgs) => Promise<boolean | WhereClause> | boolean | WhereClause);
|
|
78
|
+
interface CollectionAccess {
|
|
79
|
+
create?: AccessControl;
|
|
80
|
+
read?: AccessControl;
|
|
81
|
+
update?: AccessControl;
|
|
82
|
+
delete?: AccessControl;
|
|
83
|
+
admin?: AccessControl;
|
|
84
|
+
unlock?: AccessControl;
|
|
85
|
+
readVersions?: AccessControl;
|
|
86
|
+
}
|
|
87
|
+
interface GlobalAccess {
|
|
88
|
+
read?: AccessControl;
|
|
89
|
+
update?: AccessControl;
|
|
90
|
+
}
|
|
91
|
+
interface FieldAccess {
|
|
92
|
+
create?: AccessControl;
|
|
93
|
+
read?: AccessControl;
|
|
94
|
+
update?: AccessControl;
|
|
95
|
+
}
|
|
96
|
+
declare function evaluateAccess(access: AccessControl, args: AccessArgs): Promise<boolean | WhereClause>;
|
|
97
|
+
declare function mergeWhereClauses(...whereClauses: (WhereClause | boolean | undefined)[]): WhereClause;
|
|
98
|
+
declare function getWhereClause(access: AccessControl, args: AccessArgs): Promise<WhereClause | undefined>;
|
|
99
|
+
|
|
100
|
+
interface AdminConfig {
|
|
101
|
+
useAsTitle?: string;
|
|
102
|
+
defaultColumns?: string[];
|
|
103
|
+
hidden?: boolean;
|
|
104
|
+
description?: string;
|
|
105
|
+
hideAPIURL?: boolean;
|
|
106
|
+
group?: string;
|
|
107
|
+
icon?: string;
|
|
108
|
+
preview?: (doc: any, options: {
|
|
109
|
+
req: any;
|
|
110
|
+
}) => string;
|
|
111
|
+
disableDuplicate?: boolean;
|
|
112
|
+
pagination?: {
|
|
113
|
+
defaultLimit?: number;
|
|
114
|
+
limits?: number[];
|
|
115
|
+
};
|
|
116
|
+
layout?: "split" | "single";
|
|
117
|
+
}
|
|
118
|
+
interface UploadConfig {
|
|
119
|
+
staticDir?: string;
|
|
120
|
+
staticURL?: string;
|
|
121
|
+
mimeTypes?: string[];
|
|
122
|
+
fileSize?: number;
|
|
123
|
+
imageSizes?: ImageSize[];
|
|
124
|
+
crop?: boolean;
|
|
125
|
+
focalPoint?: boolean;
|
|
126
|
+
formatOptions?: {
|
|
127
|
+
format: "webp" | "png" | "jpg";
|
|
128
|
+
options?: Record<string, any>;
|
|
129
|
+
};
|
|
130
|
+
resizeOptions?: Record<string, any>;
|
|
131
|
+
adminThumbnail?: string;
|
|
132
|
+
}
|
|
133
|
+
interface ImageSize {
|
|
134
|
+
name: string;
|
|
135
|
+
width?: number;
|
|
136
|
+
height?: number;
|
|
137
|
+
crop?: string;
|
|
138
|
+
position?: string;
|
|
139
|
+
formatOptions?: {
|
|
140
|
+
format: "webp" | "png" | "jpg";
|
|
141
|
+
};
|
|
142
|
+
generateImageName?: (doc: any) => string;
|
|
143
|
+
}
|
|
144
|
+
interface VersionConfig {
|
|
145
|
+
maxPerDoc?: number;
|
|
146
|
+
drafts?: boolean;
|
|
147
|
+
retainDeleted?: boolean;
|
|
148
|
+
}
|
|
149
|
+
type DocumentStatus = 'draft' | 'published' | 'archived';
|
|
150
|
+
interface AuthConfig {
|
|
151
|
+
tokenExpiration?: number;
|
|
152
|
+
verify?: boolean | {
|
|
153
|
+
generateEmailHTML?: (args: any) => string;
|
|
154
|
+
};
|
|
155
|
+
maxLoginAttempts?: number;
|
|
156
|
+
lockTime?: number;
|
|
157
|
+
cookies?: {
|
|
158
|
+
secure?: boolean;
|
|
159
|
+
sameSite?: "strict" | "lax" | "none";
|
|
160
|
+
domain?: string;
|
|
161
|
+
};
|
|
162
|
+
forgotPassword?: {
|
|
163
|
+
generateEmailHTML?: (args: any) => string;
|
|
164
|
+
generateEmailSubject?: (args: any) => string;
|
|
165
|
+
};
|
|
166
|
+
strategies?: Array<{
|
|
167
|
+
name: string;
|
|
168
|
+
authenticate: (args: any) => Promise<any>;
|
|
169
|
+
}>;
|
|
170
|
+
}
|
|
171
|
+
interface CollectionConfig {
|
|
172
|
+
slug: string;
|
|
173
|
+
label?: string;
|
|
174
|
+
labelPlural?: string;
|
|
175
|
+
singularLabel?: string;
|
|
176
|
+
admin?: AdminConfig;
|
|
177
|
+
fields: Field[];
|
|
178
|
+
access?: CollectionAccess;
|
|
179
|
+
hooks?: CollectionHooks;
|
|
180
|
+
timestamps?: boolean;
|
|
181
|
+
tenantScoped?: boolean;
|
|
182
|
+
tenantField?: string;
|
|
183
|
+
upload?: UploadConfig;
|
|
184
|
+
versions?: VersionConfig;
|
|
185
|
+
auth?: boolean | AuthConfig;
|
|
186
|
+
graphQL?: {
|
|
187
|
+
singularName?: string;
|
|
188
|
+
pluralName?: string;
|
|
189
|
+
};
|
|
190
|
+
indexes?: Array<{
|
|
191
|
+
fields: Record<string, number | "text">;
|
|
192
|
+
options?: Record<string, any>;
|
|
193
|
+
}>;
|
|
194
|
+
custom?: Record<string, any>;
|
|
195
|
+
tabs?: Array<{
|
|
196
|
+
label: string;
|
|
197
|
+
fields: Field[];
|
|
198
|
+
name?: string;
|
|
199
|
+
}>;
|
|
200
|
+
}
|
|
201
|
+
interface GlobalConfig {
|
|
202
|
+
slug: string;
|
|
203
|
+
label?: string;
|
|
204
|
+
admin?: AdminConfig;
|
|
205
|
+
fields: Field[];
|
|
206
|
+
access?: GlobalAccess;
|
|
207
|
+
hooks?: GlobalHooks;
|
|
208
|
+
versions?: VersionConfig;
|
|
209
|
+
graphQL?: {
|
|
210
|
+
name?: string;
|
|
211
|
+
};
|
|
212
|
+
typescript?: {
|
|
213
|
+
interface?: string;
|
|
214
|
+
};
|
|
215
|
+
custom?: Record<string, any>;
|
|
216
|
+
tabs?: Array<{
|
|
217
|
+
label: string;
|
|
218
|
+
fields: Field[];
|
|
219
|
+
name?: string;
|
|
220
|
+
}>;
|
|
221
|
+
}
|
|
222
|
+
interface FindArgs {
|
|
223
|
+
collection: string;
|
|
224
|
+
where?: Record<string, any>;
|
|
225
|
+
sort?: string;
|
|
226
|
+
limit?: number;
|
|
227
|
+
page?: number;
|
|
228
|
+
depth?: number;
|
|
229
|
+
tenantID?: string;
|
|
230
|
+
select?: string[];
|
|
231
|
+
user?: any;
|
|
232
|
+
context?: Record<string, any>;
|
|
233
|
+
overrideAccess?: boolean;
|
|
234
|
+
/** If true, returns draft docs (admin view). If false/omitted, only published docs are returned (public API). */
|
|
235
|
+
draft?: boolean;
|
|
236
|
+
}
|
|
237
|
+
interface FindByIDArgs {
|
|
238
|
+
collection: string;
|
|
239
|
+
id: string;
|
|
240
|
+
depth?: number;
|
|
241
|
+
tenantID?: string;
|
|
242
|
+
select?: string[];
|
|
243
|
+
user?: any;
|
|
244
|
+
context?: Record<string, any>;
|
|
245
|
+
overrideAccess?: boolean;
|
|
246
|
+
/** If true, returns document regardless of status (admin view). */
|
|
247
|
+
draft?: boolean;
|
|
248
|
+
}
|
|
249
|
+
interface CreateArgs {
|
|
250
|
+
collection: string;
|
|
251
|
+
data: Record<string, any>;
|
|
252
|
+
depth?: number;
|
|
253
|
+
tenantID?: string;
|
|
254
|
+
select?: string[];
|
|
255
|
+
user?: any;
|
|
256
|
+
context?: Record<string, any>;
|
|
257
|
+
overrideAccess?: boolean;
|
|
258
|
+
}
|
|
259
|
+
interface UpdateArgs {
|
|
260
|
+
collection: string;
|
|
261
|
+
id: string;
|
|
262
|
+
data: Record<string, any>;
|
|
263
|
+
depth?: number;
|
|
264
|
+
tenantID?: string;
|
|
265
|
+
select?: string[];
|
|
266
|
+
user?: any;
|
|
267
|
+
context?: Record<string, any>;
|
|
268
|
+
overrideAccess?: boolean;
|
|
269
|
+
}
|
|
270
|
+
interface DeleteArgs {
|
|
271
|
+
collection: string;
|
|
272
|
+
id: string;
|
|
273
|
+
tenantID?: string;
|
|
274
|
+
user?: any;
|
|
275
|
+
context?: Record<string, any>;
|
|
276
|
+
overrideAccess?: boolean;
|
|
277
|
+
}
|
|
278
|
+
interface FindResult<T = any> {
|
|
279
|
+
docs: T[];
|
|
280
|
+
totalDocs: number;
|
|
281
|
+
limit: number;
|
|
282
|
+
totalPages: number;
|
|
283
|
+
page: number;
|
|
284
|
+
pagingCounter: number;
|
|
285
|
+
hasPrevPage: boolean;
|
|
286
|
+
hasNextPage: boolean;
|
|
287
|
+
prevPage: number | null;
|
|
288
|
+
nextPage: number | null;
|
|
289
|
+
}
|
|
290
|
+
interface DraftSnapshot<T = Record<string, any>> {
|
|
291
|
+
id: string;
|
|
292
|
+
collection: string;
|
|
293
|
+
documentId: string;
|
|
294
|
+
tenantID?: string;
|
|
295
|
+
data: T;
|
|
296
|
+
baseUpdatedAt?: string | null;
|
|
297
|
+
draftUpdatedAt: string;
|
|
298
|
+
createdAt: string;
|
|
299
|
+
updatedAt: string;
|
|
300
|
+
}
|
|
301
|
+
interface DraftFindArgs {
|
|
302
|
+
collection: string;
|
|
303
|
+
documentId: string;
|
|
304
|
+
tenantID?: string;
|
|
305
|
+
}
|
|
306
|
+
interface DraftUpsertArgs<T = Record<string, any>> extends DraftFindArgs {
|
|
307
|
+
data: T;
|
|
308
|
+
baseUpdatedAt?: string | null;
|
|
309
|
+
draftUpdatedAt?: string;
|
|
310
|
+
}
|
|
311
|
+
interface DraftDeleteArgs extends DraftFindArgs {
|
|
312
|
+
}
|
|
313
|
+
interface CreateResult<T = any> {
|
|
314
|
+
doc: T;
|
|
315
|
+
errors?: Array<{
|
|
316
|
+
field: string;
|
|
317
|
+
message: string;
|
|
318
|
+
}>;
|
|
319
|
+
}
|
|
320
|
+
interface VersionRecord<T = Record<string, any>> {
|
|
321
|
+
id: string;
|
|
322
|
+
collection: string;
|
|
323
|
+
documentId: string;
|
|
324
|
+
version: number;
|
|
325
|
+
status: DocumentStatus;
|
|
326
|
+
data: T;
|
|
327
|
+
createdBy?: string;
|
|
328
|
+
createdAt: string;
|
|
329
|
+
updatedAt: string;
|
|
330
|
+
publishedAt?: string | null;
|
|
331
|
+
changeDescription?: string;
|
|
332
|
+
}
|
|
333
|
+
interface CreateVersionArgs<T = Record<string, any>> {
|
|
334
|
+
collection: string;
|
|
335
|
+
documentId: string;
|
|
336
|
+
data: T;
|
|
337
|
+
status: DocumentStatus;
|
|
338
|
+
createdBy?: string;
|
|
339
|
+
changeDescription?: string;
|
|
340
|
+
tenantID?: string;
|
|
341
|
+
}
|
|
342
|
+
interface FindVersionsArgs {
|
|
343
|
+
collection: string;
|
|
344
|
+
documentId: string;
|
|
345
|
+
tenantID?: string;
|
|
346
|
+
limit?: number;
|
|
347
|
+
page?: number;
|
|
348
|
+
sort?: string;
|
|
349
|
+
}
|
|
350
|
+
interface BaseAdapter {
|
|
351
|
+
init(collections: CollectionConfig[], globals: GlobalConfig[]): Promise<void>;
|
|
352
|
+
find<T>(args: FindArgs): Promise<FindResult<T>>;
|
|
353
|
+
findByID<T>(args: FindByIDArgs): Promise<T | null>;
|
|
354
|
+
create<T>(args: CreateArgs): Promise<T>;
|
|
355
|
+
update<T>(args: UpdateArgs): Promise<T>;
|
|
356
|
+
delete<T>(args: DeleteArgs): Promise<T>;
|
|
357
|
+
count(args: {
|
|
358
|
+
collection: string;
|
|
359
|
+
where?: Record<string, any>;
|
|
360
|
+
tenantID?: string;
|
|
361
|
+
}): Promise<number>;
|
|
362
|
+
findOne(args: {
|
|
363
|
+
collection: string;
|
|
364
|
+
where: Record<string, any>;
|
|
365
|
+
tenantID?: string;
|
|
366
|
+
draft?: boolean;
|
|
367
|
+
}): Promise<any>;
|
|
368
|
+
findVersions(args: FindVersionsArgs): Promise<FindResult<VersionRecord>>;
|
|
369
|
+
findVersionByID(args: {
|
|
370
|
+
collection: string;
|
|
371
|
+
versionId: string;
|
|
372
|
+
tenantID?: string;
|
|
373
|
+
}): Promise<VersionRecord | null>;
|
|
374
|
+
createVersion<T = Record<string, any>>(args: CreateVersionArgs<T>): Promise<VersionRecord<T>>;
|
|
375
|
+
deleteVersions(args: {
|
|
376
|
+
collection: string;
|
|
377
|
+
documentId: string;
|
|
378
|
+
keepLatest?: number;
|
|
379
|
+
tenantID?: string;
|
|
380
|
+
}): Promise<void>;
|
|
381
|
+
findDraft<T = Record<string, any>>(args: DraftFindArgs): Promise<DraftSnapshot<T> | null>;
|
|
382
|
+
upsertDraft<T = Record<string, any>>(args: DraftUpsertArgs<T>): Promise<DraftSnapshot<T>>;
|
|
383
|
+
deleteDraft(args: DraftDeleteArgs): Promise<void>;
|
|
384
|
+
migrate?(): Promise<void>;
|
|
385
|
+
rollback?(): Promise<void>;
|
|
386
|
+
connect(): Promise<void>;
|
|
387
|
+
disconnect(): Promise<void>;
|
|
388
|
+
transaction?<T>(fn: (tx: any) => Promise<T>): Promise<T>;
|
|
389
|
+
}
|
|
390
|
+
interface AdapterConfig {
|
|
391
|
+
type: "drizzle" | "mongodb";
|
|
392
|
+
client: any;
|
|
393
|
+
schema?: any;
|
|
394
|
+
connectionOptions?: Record<string, any>;
|
|
395
|
+
}
|
|
396
|
+
interface PluginConfig {
|
|
397
|
+
name: string;
|
|
398
|
+
version?: string;
|
|
399
|
+
init?: (kyro: any) => void | Promise<void>;
|
|
400
|
+
extendCollection?: (slug: string, config: CollectionConfig) => CollectionConfig;
|
|
401
|
+
extendGlobal?: (slug: string, config: GlobalConfig) => GlobalConfig;
|
|
402
|
+
hooks?: CollectionHooks;
|
|
403
|
+
fields?: Field[];
|
|
404
|
+
api?: (kyro: any) => any;
|
|
405
|
+
}
|
|
406
|
+
interface KyroConfig {
|
|
407
|
+
collections?: CollectionConfig[];
|
|
408
|
+
globals?: GlobalConfig[];
|
|
409
|
+
adapter: BaseAdapter;
|
|
410
|
+
plugins?: PluginConfig[];
|
|
411
|
+
auth?: boolean | {
|
|
412
|
+
secret?: string;
|
|
413
|
+
tokenExpiration?: number;
|
|
414
|
+
cookie?: {
|
|
415
|
+
secure?: boolean;
|
|
416
|
+
sameSite?: "strict" | "lax" | "none";
|
|
417
|
+
domain?: string;
|
|
418
|
+
};
|
|
419
|
+
checkSession?: boolean;
|
|
420
|
+
};
|
|
421
|
+
authAdapter?: any;
|
|
422
|
+
cors?: {
|
|
423
|
+
origins?: string[];
|
|
424
|
+
credentials?: boolean;
|
|
425
|
+
};
|
|
426
|
+
admin?: {
|
|
427
|
+
meta?: {
|
|
428
|
+
title?: string;
|
|
429
|
+
description?: string;
|
|
430
|
+
ogImage?: string;
|
|
431
|
+
};
|
|
432
|
+
dateFormat?: string;
|
|
433
|
+
avatar?: "default" | "gravatar";
|
|
434
|
+
disable?: boolean;
|
|
435
|
+
indexRoute?: string;
|
|
436
|
+
components?: Record<string, any>;
|
|
437
|
+
};
|
|
438
|
+
upload?: {
|
|
439
|
+
limits?: {
|
|
440
|
+
fileSize?: number;
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
graphQL?: {
|
|
444
|
+
maxComplexity?: number;
|
|
445
|
+
disablePlayground?: boolean;
|
|
446
|
+
};
|
|
447
|
+
typescript?: {
|
|
448
|
+
outputFile?: string;
|
|
449
|
+
};
|
|
450
|
+
localization?: {
|
|
451
|
+
locales: string[];
|
|
452
|
+
defaultLocale: string;
|
|
453
|
+
};
|
|
454
|
+
rateLimit?: {
|
|
455
|
+
window?: number;
|
|
456
|
+
max?: number;
|
|
457
|
+
};
|
|
458
|
+
debug?: boolean;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export { type AdminConfig as A, type BaseAdapter as B, type CollectionConfig as C, type DeleteArgs as D, mergeWhereClauses as E, type FindArgs as F, type GlobalConfig as G, type Hook as H, type ImageSize as I, runFieldHooks as J, type KyroConfig as K, runHooks as L, type PluginConfig as P, type Request as R, type UploadConfig as U, type VersionConfig as V, type WhereClause as W, type AuthConfig as a, type FindResult as b, type FindByIDArgs as c, type CreateArgs as d, type UpdateArgs as e, type FindVersionsArgs as f, type VersionRecord as g, type CreateVersionArgs as h, type DraftFindArgs as i, type DraftSnapshot as j, type DraftUpsertArgs as k, type DraftDeleteArgs as l, type User as m, type AccessArgs as n, type AccessControl as o, type AdapterConfig as p, type CollectionAccess as q, type CollectionHooks as r, type CreateResult as s, type FieldAccess as t, type FieldHooks as u, type GlobalAccess as v, type GlobalHooks as w, type HookArgs as x, evaluateAccess as y, getWhereClause as z };
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
interface FieldAdmin {
|
|
2
|
+
description?: string;
|
|
3
|
+
placeholder?: string;
|
|
4
|
+
readOnly?: boolean;
|
|
5
|
+
hidden?: boolean;
|
|
6
|
+
width?: string;
|
|
7
|
+
position?: "sidebar" | "main";
|
|
8
|
+
autoGenerate?: string;
|
|
9
|
+
action?: string;
|
|
10
|
+
method?: string;
|
|
11
|
+
inline?: boolean;
|
|
12
|
+
condition?: (data: Record<string, any>, siblingData: Record<string, any>) => boolean;
|
|
13
|
+
}
|
|
14
|
+
interface BaseField {
|
|
15
|
+
name: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
unique?: boolean;
|
|
19
|
+
indexed?: boolean;
|
|
20
|
+
defaultValue?: any;
|
|
21
|
+
admin?: FieldAdmin;
|
|
22
|
+
validate?: (value: any, options: ValidateOptions) => string | true | Promise<string | true>;
|
|
23
|
+
hooks?: {
|
|
24
|
+
beforeValidate?: Hook[];
|
|
25
|
+
beforeChange?: Hook[];
|
|
26
|
+
afterChange?: Hook[];
|
|
27
|
+
afterRead?: Hook[];
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
interface ValidateOptions {
|
|
31
|
+
data?: Record<string, any>;
|
|
32
|
+
siblingData?: Record<string, any>;
|
|
33
|
+
user?: any;
|
|
34
|
+
operation?: string;
|
|
35
|
+
required?: boolean;
|
|
36
|
+
}
|
|
37
|
+
type Hook = (args: any) => Promise<any> | any;
|
|
38
|
+
type TextFieldVariant = "text" | "email" | "password" | "url" | "id";
|
|
39
|
+
interface TextField extends BaseField {
|
|
40
|
+
type: "text";
|
|
41
|
+
variant?: TextFieldVariant;
|
|
42
|
+
minLength?: number;
|
|
43
|
+
maxLength?: number;
|
|
44
|
+
pattern?: string;
|
|
45
|
+
hasMany?: boolean;
|
|
46
|
+
localized?: boolean;
|
|
47
|
+
}
|
|
48
|
+
interface NumberField extends BaseField {
|
|
49
|
+
type: "number";
|
|
50
|
+
min?: number;
|
|
51
|
+
max?: number;
|
|
52
|
+
step?: number;
|
|
53
|
+
integer?: boolean;
|
|
54
|
+
hasMany?: boolean;
|
|
55
|
+
}
|
|
56
|
+
interface CheckboxField extends BaseField {
|
|
57
|
+
type: "checkbox";
|
|
58
|
+
}
|
|
59
|
+
interface DateField extends BaseField {
|
|
60
|
+
type: "date";
|
|
61
|
+
minDate?: string;
|
|
62
|
+
maxDate?: string;
|
|
63
|
+
time?: boolean;
|
|
64
|
+
}
|
|
65
|
+
interface EmailField extends BaseField {
|
|
66
|
+
type: "email";
|
|
67
|
+
}
|
|
68
|
+
interface PasswordField extends BaseField {
|
|
69
|
+
type: "password";
|
|
70
|
+
}
|
|
71
|
+
interface TextareaField extends BaseField {
|
|
72
|
+
type: "textarea";
|
|
73
|
+
minLength?: number;
|
|
74
|
+
maxLength?: number;
|
|
75
|
+
rows?: number;
|
|
76
|
+
localized?: boolean;
|
|
77
|
+
}
|
|
78
|
+
interface SelectField extends BaseField {
|
|
79
|
+
type: "select";
|
|
80
|
+
options: Array<{
|
|
81
|
+
label: string;
|
|
82
|
+
value: string;
|
|
83
|
+
}>;
|
|
84
|
+
hasMany?: boolean;
|
|
85
|
+
defaultValue?: string | string[];
|
|
86
|
+
}
|
|
87
|
+
interface RadioField extends BaseField {
|
|
88
|
+
type: "radio";
|
|
89
|
+
options: Array<{
|
|
90
|
+
label: string;
|
|
91
|
+
value: string;
|
|
92
|
+
}>;
|
|
93
|
+
defaultValue?: string;
|
|
94
|
+
}
|
|
95
|
+
interface ColorField extends BaseField {
|
|
96
|
+
type: "color";
|
|
97
|
+
format?: "hex" | "rgb" | "hsl";
|
|
98
|
+
defaultValue?: string;
|
|
99
|
+
}
|
|
100
|
+
interface ImageField extends BaseField {
|
|
101
|
+
type: "image";
|
|
102
|
+
minCount?: number;
|
|
103
|
+
maxCount?: number;
|
|
104
|
+
allowedTypes?: string[];
|
|
105
|
+
maxSize?: number;
|
|
106
|
+
}
|
|
107
|
+
interface RichTextBlock {
|
|
108
|
+
type: string;
|
|
109
|
+
data: Record<string, any>;
|
|
110
|
+
children?: RichTextBlock[];
|
|
111
|
+
}
|
|
112
|
+
interface RichTextField extends BaseField {
|
|
113
|
+
type: "richtext";
|
|
114
|
+
editor?: "lexical" | "slate" | "blocks";
|
|
115
|
+
hasBlocks?: boolean;
|
|
116
|
+
defaultValue?: RichTextBlock[];
|
|
117
|
+
localized?: boolean;
|
|
118
|
+
}
|
|
119
|
+
interface JSONField extends BaseField {
|
|
120
|
+
type: "json";
|
|
121
|
+
defaultValue?: Record<string, any>;
|
|
122
|
+
}
|
|
123
|
+
interface CodeField extends BaseField {
|
|
124
|
+
type: "code";
|
|
125
|
+
language?: string;
|
|
126
|
+
defaultValue?: string;
|
|
127
|
+
}
|
|
128
|
+
interface UploadField extends BaseField {
|
|
129
|
+
type: "upload";
|
|
130
|
+
relationTo: string;
|
|
131
|
+
hasMany?: boolean;
|
|
132
|
+
maxDepth?: number;
|
|
133
|
+
defaultValue?: string;
|
|
134
|
+
}
|
|
135
|
+
interface MarkdownField extends BaseField {
|
|
136
|
+
type: "markdown";
|
|
137
|
+
localized?: boolean;
|
|
138
|
+
defaultValue?: string;
|
|
139
|
+
}
|
|
140
|
+
interface RelationshipField extends BaseField {
|
|
141
|
+
type: "relationship";
|
|
142
|
+
relationTo: string | string[];
|
|
143
|
+
hasMany?: boolean;
|
|
144
|
+
maxDepth?: number;
|
|
145
|
+
filterOptions?: (args: {
|
|
146
|
+
data: any;
|
|
147
|
+
user: any;
|
|
148
|
+
}) => Record<string, any>;
|
|
149
|
+
defaultValue?: string | string[];
|
|
150
|
+
}
|
|
151
|
+
interface ArrayField extends BaseField {
|
|
152
|
+
type: "array";
|
|
153
|
+
fields: Field[];
|
|
154
|
+
minRows?: number;
|
|
155
|
+
maxRows?: number;
|
|
156
|
+
labels?: {
|
|
157
|
+
singular?: string;
|
|
158
|
+
plural?: string;
|
|
159
|
+
};
|
|
160
|
+
defaultValue?: Record<string, any>[];
|
|
161
|
+
}
|
|
162
|
+
interface ListField extends BaseField {
|
|
163
|
+
type: "list";
|
|
164
|
+
defaultValue?: string[];
|
|
165
|
+
}
|
|
166
|
+
interface GroupField extends BaseField {
|
|
167
|
+
type: "group";
|
|
168
|
+
fields: Field[];
|
|
169
|
+
defaultValue?: Record<string, any>;
|
|
170
|
+
}
|
|
171
|
+
interface BlockImage {
|
|
172
|
+
url: string;
|
|
173
|
+
alt?: string;
|
|
174
|
+
}
|
|
175
|
+
interface BlockAdmin {
|
|
176
|
+
group?: string;
|
|
177
|
+
images?: {
|
|
178
|
+
icon?: BlockImage | string;
|
|
179
|
+
thumbnail?: BlockImage | string;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
interface Block {
|
|
183
|
+
slug: string;
|
|
184
|
+
label: string;
|
|
185
|
+
fields: Field[];
|
|
186
|
+
imageURL?: string;
|
|
187
|
+
admin?: BlockAdmin;
|
|
188
|
+
}
|
|
189
|
+
interface BlocksField extends BaseField {
|
|
190
|
+
type: "blocks";
|
|
191
|
+
blocks?: Block[];
|
|
192
|
+
minRows?: number;
|
|
193
|
+
maxRows?: number;
|
|
194
|
+
defaultValue?: Array<{
|
|
195
|
+
blockType: string;
|
|
196
|
+
[key: string]: any;
|
|
197
|
+
}>;
|
|
198
|
+
}
|
|
199
|
+
interface RowField extends Omit<BaseField, "name"> {
|
|
200
|
+
type: "row";
|
|
201
|
+
fields: Field[];
|
|
202
|
+
name?: string;
|
|
203
|
+
}
|
|
204
|
+
interface CollapsibleField extends Omit<BaseField, "name"> {
|
|
205
|
+
type: "collapsible";
|
|
206
|
+
fields: Field[];
|
|
207
|
+
label: string;
|
|
208
|
+
name?: string;
|
|
209
|
+
}
|
|
210
|
+
interface TabsField extends Omit<BaseField, "name"> {
|
|
211
|
+
type: "tabs";
|
|
212
|
+
tabs: Array<{
|
|
213
|
+
label: string;
|
|
214
|
+
fields: Field[];
|
|
215
|
+
name?: string;
|
|
216
|
+
}>;
|
|
217
|
+
name?: string;
|
|
218
|
+
}
|
|
219
|
+
interface ButtonField extends BaseField {
|
|
220
|
+
type: "button";
|
|
221
|
+
label: string;
|
|
222
|
+
action?: string;
|
|
223
|
+
method?: string;
|
|
224
|
+
inline?: boolean;
|
|
225
|
+
}
|
|
226
|
+
type Field = TextField | NumberField | CheckboxField | DateField | EmailField | PasswordField | TextareaField | SelectField | RadioField | ColorField | ImageField | RichTextField | JSONField | CodeField | UploadField | MarkdownField | RelationshipField | ArrayField | ListField | GroupField | BlocksField | RowField | CollapsibleField | TabsField | ButtonField;
|
|
227
|
+
type FieldType = Field["type"];
|
|
228
|
+
declare function isTextField(field: Field): field is TextField;
|
|
229
|
+
declare function isNumberField(field: Field): field is NumberField;
|
|
230
|
+
declare function isRelationshipField(field: Field): field is RelationshipField;
|
|
231
|
+
declare function isArrayField(field: Field): field is ArrayField;
|
|
232
|
+
declare function isGroupField(field: Field): field is GroupField;
|
|
233
|
+
declare function isBlocksField(field: Field): field is BlocksField;
|
|
234
|
+
declare function isUploadField(field: Field): field is UploadField;
|
|
235
|
+
declare function isImageField(field: Field): field is ImageField;
|
|
236
|
+
declare function isRichTextField(field: Field): field is RichTextField;
|
|
237
|
+
declare function isSelectField(field: Field): field is SelectField;
|
|
238
|
+
declare function isLayoutField(field: Field): field is RowField | CollapsibleField | TabsField;
|
|
239
|
+
declare const PRIMITIVE_FIELD_TYPES: readonly ["text", "number", "checkbox", "date", "email", "password", "textarea", "select", "radio", "color"];
|
|
240
|
+
declare const COMPLEX_FIELD_TYPES: readonly ["richtext", "json", "code", "upload", "image", "markdown"];
|
|
241
|
+
declare const RELATIONAL_FIELD_TYPES: readonly ["relationship", "array", "group", "blocks"];
|
|
242
|
+
declare const LAYOUT_FIELD_TYPES: readonly ["row", "collapsible", "tabs"];
|
|
243
|
+
declare const ALL_FIELD_TYPES: readonly ["text", "number", "checkbox", "date", "email", "password", "textarea", "select", "radio", "color", "richtext", "json", "code", "upload", "image", "markdown", "relationship", "array", "group", "blocks", "row", "collapsible", "tabs"];
|
|
244
|
+
declare function createRelationshipFieldConfig(name: string, relationTo: string | string[], options?: Partial<Omit<RelationshipField, "type" | "name" | "relationTo">>): RelationshipField;
|
|
245
|
+
|
|
246
|
+
export { type ArrayField as A, type BaseField as B, type CheckboxField as C, type DateField as D, type EmailField as E, type Field as F, type GroupField as G, isRichTextField as H, type ImageField as I, type JSONField as J, isSelectField as K, LAYOUT_FIELD_TYPES as L, type MarkdownField as M, type NumberField as N, isTextField as O, type PasswordField as P, isUploadField as Q, type RadioField as R, type SelectField as S, type TabsField as T, type UploadField as U, type ValidateOptions as V, type ButtonField as W, type Hook as X, type ListField as Y, type TextFieldVariant as Z, createRelationshipFieldConfig as _, type Block as a, type BlockAdmin as b, type BlockImage as c, type BlocksField as d, type CodeField as e, type CollapsibleField as f, type ColorField as g, type FieldAdmin as h, type FieldType as i, type RelationshipField as j, type RichTextBlock as k, type RichTextField as l, type RowField as m, type TextField as n, type TextareaField as o, ALL_FIELD_TYPES as p, COMPLEX_FIELD_TYPES as q, PRIMITIVE_FIELD_TYPES as r, RELATIONAL_FIELD_TYPES as s, isArrayField as t, isBlocksField as u, isGroupField as v, isImageField as w, isLayoutField as x, isNumberField as y, isRelationshipField as z };
|