@kyro-cms/core 0.5.3 → 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.js';
|
|
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,130 @@
|
|
|
1
|
+
type AuditAction = "login" | "logout" | "login_failed" | "register" | "verify_email" | "password_change" | "password_reset" | "password_reset_request" | "role_change" | "permission_change" | "document_create" | "document_update" | "document_delete" | "settings_change" | "user_lockout" | "user_unlock" | "user_create" | "user_update" | "user_delete" | "api_request" | "api_key_create" | "api_key_update" | "api_key_rotate" | "api_key_delete" | "tenant_create" | "tenant_delete";
|
|
2
|
+
interface AuditLog {
|
|
3
|
+
id: string;
|
|
4
|
+
timestamp: Date;
|
|
5
|
+
action: AuditAction;
|
|
6
|
+
userId?: string;
|
|
7
|
+
userEmail?: string;
|
|
8
|
+
role?: string;
|
|
9
|
+
resource: string;
|
|
10
|
+
resourceId?: string;
|
|
11
|
+
changes?: {
|
|
12
|
+
field: string;
|
|
13
|
+
old: any;
|
|
14
|
+
new: any;
|
|
15
|
+
}[];
|
|
16
|
+
ipAddress?: string;
|
|
17
|
+
userAgent?: string;
|
|
18
|
+
success: boolean;
|
|
19
|
+
error?: string;
|
|
20
|
+
metadata?: Record<string, any>;
|
|
21
|
+
}
|
|
22
|
+
interface AuditLogFilter {
|
|
23
|
+
userId?: string;
|
|
24
|
+
action?: AuditAction | AuditAction[];
|
|
25
|
+
resource?: string;
|
|
26
|
+
resourceId?: string;
|
|
27
|
+
success?: boolean;
|
|
28
|
+
startDate?: Date;
|
|
29
|
+
endDate?: Date;
|
|
30
|
+
limit?: number;
|
|
31
|
+
offset?: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface AuthUser {
|
|
35
|
+
id: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
email: string;
|
|
38
|
+
passwordHash?: string;
|
|
39
|
+
role: UserRole;
|
|
40
|
+
tenantId?: string;
|
|
41
|
+
emailVerified?: boolean;
|
|
42
|
+
locked?: boolean;
|
|
43
|
+
lastLogin?: string;
|
|
44
|
+
failedLoginAttempts?: number;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
}
|
|
48
|
+
type UserRole = "super_admin" | "admin" | "editor" | "author" | "customer" | "guest";
|
|
49
|
+
interface Session {
|
|
50
|
+
id: string;
|
|
51
|
+
userId: string;
|
|
52
|
+
token: string;
|
|
53
|
+
refreshToken?: string;
|
|
54
|
+
expiresAt: string;
|
|
55
|
+
createdAt: string;
|
|
56
|
+
ipAddress?: string;
|
|
57
|
+
userAgent?: string;
|
|
58
|
+
}
|
|
59
|
+
interface JWTPayload {
|
|
60
|
+
sub: string;
|
|
61
|
+
email: string;
|
|
62
|
+
role: UserRole;
|
|
63
|
+
tenantId?: string;
|
|
64
|
+
iat?: number;
|
|
65
|
+
exp?: number;
|
|
66
|
+
sid?: string;
|
|
67
|
+
}
|
|
68
|
+
interface AuthTokenConfig {
|
|
69
|
+
secret: string;
|
|
70
|
+
expiresIn?: string | number;
|
|
71
|
+
refreshExpiresIn?: string | number;
|
|
72
|
+
issuer?: string;
|
|
73
|
+
audience?: string[];
|
|
74
|
+
saltRounds?: number;
|
|
75
|
+
}
|
|
76
|
+
interface LoginCredentials {
|
|
77
|
+
email: string;
|
|
78
|
+
password: string;
|
|
79
|
+
}
|
|
80
|
+
interface RegisterData {
|
|
81
|
+
email: string;
|
|
82
|
+
password: string;
|
|
83
|
+
role?: UserRole;
|
|
84
|
+
tenantId?: string;
|
|
85
|
+
}
|
|
86
|
+
interface AuthResult {
|
|
87
|
+
success: boolean;
|
|
88
|
+
user?: AuthUser;
|
|
89
|
+
session?: Session;
|
|
90
|
+
token?: string;
|
|
91
|
+
error?: string;
|
|
92
|
+
}
|
|
93
|
+
interface AuthAdapter {
|
|
94
|
+
createUser(data: {
|
|
95
|
+
email: string;
|
|
96
|
+
password: string;
|
|
97
|
+
name?: string;
|
|
98
|
+
role?: UserRole;
|
|
99
|
+
tenantId?: string;
|
|
100
|
+
}): Promise<AuthUser>;
|
|
101
|
+
findUserByEmail(email: string): Promise<AuthUser | null>;
|
|
102
|
+
findUserById(id: string): Promise<AuthUser | null>;
|
|
103
|
+
updateUser(id: string, data: Partial<AuthUser> & {
|
|
104
|
+
password?: string;
|
|
105
|
+
}): Promise<AuthUser | null>;
|
|
106
|
+
deleteUser(id: string): Promise<boolean>;
|
|
107
|
+
verifyPassword(email: string, password: string): Promise<AuthUser | null>;
|
|
108
|
+
hashPassword(password: string): Promise<string>;
|
|
109
|
+
createSession(userId: string, data?: {
|
|
110
|
+
ipAddress?: string;
|
|
111
|
+
userAgent?: string;
|
|
112
|
+
}): Promise<Session>;
|
|
113
|
+
findSessionByToken(token: string): Promise<Session | null>;
|
|
114
|
+
findSessionByRefreshToken(refreshToken: string): Promise<Session | null>;
|
|
115
|
+
deleteSession(sessionId: string): Promise<boolean>;
|
|
116
|
+
deleteUserSessions(userId: string): Promise<number>;
|
|
117
|
+
hasAnyUsers?(): Promise<boolean>;
|
|
118
|
+
connect?(): Promise<void>;
|
|
119
|
+
disconnect?(): Promise<void>;
|
|
120
|
+
addPasswordToHistory?(userId: string, passwordHash: string): Promise<void>;
|
|
121
|
+
getPasswordHistory?(userId: string, count?: number): Promise<string[]>;
|
|
122
|
+
isPasswordInHistory?(password: string, userId: string, historyCount?: number): Promise<boolean>;
|
|
123
|
+
findAuditLogs(filter: AuditLogFilter): Promise<{
|
|
124
|
+
logs: AuditLog[];
|
|
125
|
+
total: number;
|
|
126
|
+
}>;
|
|
127
|
+
createAuditLog(data: Omit<AuditLog, "id" | "timestamp">): Promise<AuditLog>;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export type { AuthAdapter as A, JWTPayload as J, LoginCredentials as L, RegisterData as R, Session as S, UserRole as U, AuthResult as a, AuthTokenConfig as b, AuthUser as c, AuditLogFilter as d, AuditLog as e, AuditAction as f };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
type AuditAction = "login" | "logout" | "login_failed" | "register" | "verify_email" | "password_change" | "password_reset" | "password_reset_request" | "role_change" | "permission_change" | "document_create" | "document_update" | "document_delete" | "settings_change" | "user_lockout" | "user_unlock" | "user_create" | "user_update" | "user_delete" | "api_request" | "api_key_create" | "api_key_update" | "api_key_rotate" | "api_key_delete" | "tenant_create" | "tenant_delete";
|
|
2
|
+
interface AuditLog {
|
|
3
|
+
id: string;
|
|
4
|
+
timestamp: Date;
|
|
5
|
+
action: AuditAction;
|
|
6
|
+
userId?: string;
|
|
7
|
+
userEmail?: string;
|
|
8
|
+
role?: string;
|
|
9
|
+
resource: string;
|
|
10
|
+
resourceId?: string;
|
|
11
|
+
changes?: {
|
|
12
|
+
field: string;
|
|
13
|
+
old: any;
|
|
14
|
+
new: any;
|
|
15
|
+
}[];
|
|
16
|
+
ipAddress?: string;
|
|
17
|
+
userAgent?: string;
|
|
18
|
+
success: boolean;
|
|
19
|
+
error?: string;
|
|
20
|
+
metadata?: Record<string, any>;
|
|
21
|
+
}
|
|
22
|
+
interface AuditLogFilter {
|
|
23
|
+
userId?: string;
|
|
24
|
+
action?: AuditAction | AuditAction[];
|
|
25
|
+
resource?: string;
|
|
26
|
+
resourceId?: string;
|
|
27
|
+
success?: boolean;
|
|
28
|
+
startDate?: Date;
|
|
29
|
+
endDate?: Date;
|
|
30
|
+
limit?: number;
|
|
31
|
+
offset?: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface AuthUser {
|
|
35
|
+
id: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
email: string;
|
|
38
|
+
passwordHash?: string;
|
|
39
|
+
role: UserRole;
|
|
40
|
+
tenantId?: string;
|
|
41
|
+
emailVerified?: boolean;
|
|
42
|
+
locked?: boolean;
|
|
43
|
+
lastLogin?: string;
|
|
44
|
+
failedLoginAttempts?: number;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
}
|
|
48
|
+
type UserRole = "super_admin" | "admin" | "editor" | "author" | "customer" | "guest";
|
|
49
|
+
interface Session {
|
|
50
|
+
id: string;
|
|
51
|
+
userId: string;
|
|
52
|
+
token: string;
|
|
53
|
+
refreshToken?: string;
|
|
54
|
+
expiresAt: string;
|
|
55
|
+
createdAt: string;
|
|
56
|
+
ipAddress?: string;
|
|
57
|
+
userAgent?: string;
|
|
58
|
+
}
|
|
59
|
+
interface JWTPayload {
|
|
60
|
+
sub: string;
|
|
61
|
+
email: string;
|
|
62
|
+
role: UserRole;
|
|
63
|
+
tenantId?: string;
|
|
64
|
+
iat?: number;
|
|
65
|
+
exp?: number;
|
|
66
|
+
sid?: string;
|
|
67
|
+
}
|
|
68
|
+
interface AuthTokenConfig {
|
|
69
|
+
secret: string;
|
|
70
|
+
expiresIn?: string | number;
|
|
71
|
+
refreshExpiresIn?: string | number;
|
|
72
|
+
issuer?: string;
|
|
73
|
+
audience?: string[];
|
|
74
|
+
saltRounds?: number;
|
|
75
|
+
}
|
|
76
|
+
interface LoginCredentials {
|
|
77
|
+
email: string;
|
|
78
|
+
password: string;
|
|
79
|
+
}
|
|
80
|
+
interface RegisterData {
|
|
81
|
+
email: string;
|
|
82
|
+
password: string;
|
|
83
|
+
role?: UserRole;
|
|
84
|
+
tenantId?: string;
|
|
85
|
+
}
|
|
86
|
+
interface AuthResult {
|
|
87
|
+
success: boolean;
|
|
88
|
+
user?: AuthUser;
|
|
89
|
+
session?: Session;
|
|
90
|
+
token?: string;
|
|
91
|
+
error?: string;
|
|
92
|
+
}
|
|
93
|
+
interface AuthAdapter {
|
|
94
|
+
createUser(data: {
|
|
95
|
+
email: string;
|
|
96
|
+
password: string;
|
|
97
|
+
name?: string;
|
|
98
|
+
role?: UserRole;
|
|
99
|
+
tenantId?: string;
|
|
100
|
+
}): Promise<AuthUser>;
|
|
101
|
+
findUserByEmail(email: string): Promise<AuthUser | null>;
|
|
102
|
+
findUserById(id: string): Promise<AuthUser | null>;
|
|
103
|
+
updateUser(id: string, data: Partial<AuthUser> & {
|
|
104
|
+
password?: string;
|
|
105
|
+
}): Promise<AuthUser | null>;
|
|
106
|
+
deleteUser(id: string): Promise<boolean>;
|
|
107
|
+
verifyPassword(email: string, password: string): Promise<AuthUser | null>;
|
|
108
|
+
hashPassword(password: string): Promise<string>;
|
|
109
|
+
createSession(userId: string, data?: {
|
|
110
|
+
ipAddress?: string;
|
|
111
|
+
userAgent?: string;
|
|
112
|
+
}): Promise<Session>;
|
|
113
|
+
findSessionByToken(token: string): Promise<Session | null>;
|
|
114
|
+
findSessionByRefreshToken(refreshToken: string): Promise<Session | null>;
|
|
115
|
+
deleteSession(sessionId: string): Promise<boolean>;
|
|
116
|
+
deleteUserSessions(userId: string): Promise<number>;
|
|
117
|
+
hasAnyUsers?(): Promise<boolean>;
|
|
118
|
+
connect?(): Promise<void>;
|
|
119
|
+
disconnect?(): Promise<void>;
|
|
120
|
+
addPasswordToHistory?(userId: string, passwordHash: string): Promise<void>;
|
|
121
|
+
getPasswordHistory?(userId: string, count?: number): Promise<string[]>;
|
|
122
|
+
isPasswordInHistory?(password: string, userId: string, historyCount?: number): Promise<boolean>;
|
|
123
|
+
findAuditLogs(filter: AuditLogFilter): Promise<{
|
|
124
|
+
logs: AuditLog[];
|
|
125
|
+
total: number;
|
|
126
|
+
}>;
|
|
127
|
+
createAuditLog(data: Omit<AuditLog, "id" | "timestamp">): Promise<AuditLog>;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export type { AuthAdapter as A, JWTPayload as J, LoginCredentials as L, RegisterData as R, Session as S, UserRole as U, AuthResult as a, AuthTokenConfig as b, AuthUser as c, AuditLogFilter as d, AuditLog as e, AuditAction as f };
|