@kyro-cms/core 0.1.6 → 0.1.8
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/README.md +25 -2
- package/dist/WebhookService-CXJ5oz6L.d.ts +112 -0
- package/dist/WebhookService-Dqx9Is7m.d.cts +112 -0
- package/dist/{base-CQkFzqQl.d.ts → base-CciYzoDF.d.ts} +1 -1
- package/dist/{base-DlhVlwnN.d.cts → base-Cfek4fp3.d.cts} +1 -1
- package/dist/bootstrap-BMWVB2T6.cjs +31 -0
- package/dist/{bootstrap-WMWQ4DBX.cjs.map → bootstrap-BMWVB2T6.cjs.map} +1 -1
- package/dist/bootstrap-LL6O7PWO.js +6 -0
- package/dist/{bootstrap-WOVGAKZP.js.map → bootstrap-LL6O7PWO.js.map} +1 -1
- package/dist/{chunk-3VZCX4DF.cjs → chunk-42JPONZU.cjs} +77 -14
- package/dist/chunk-42JPONZU.cjs.map +1 -0
- package/dist/{chunk-3EVLFWH2.cjs → chunk-4M5PHMUE.cjs} +60 -346
- package/dist/chunk-4M5PHMUE.cjs.map +1 -0
- package/dist/chunk-4PWRCMTQ.cjs +15 -0
- package/dist/chunk-4PWRCMTQ.cjs.map +1 -0
- package/dist/chunk-6COM32WF.js +47 -0
- package/dist/chunk-6COM32WF.js.map +1 -0
- package/dist/chunk-6MSSF46R.js +941 -0
- package/dist/chunk-6MSSF46R.js.map +1 -0
- package/dist/{chunk-TZFJMPCH.cjs → chunk-7YITG2US.cjs} +9 -18
- package/dist/chunk-7YITG2US.cjs.map +1 -0
- package/dist/{chunk-A3RQWHKD.cjs → chunk-BLMFBDBG.cjs} +56 -6
- package/dist/chunk-BLMFBDBG.cjs.map +1 -0
- package/dist/{chunk-EINVJPFM.js → chunk-BTOE3VUK.js} +65 -3
- package/dist/chunk-BTOE3VUK.js.map +1 -0
- package/dist/chunk-E5X75WNB.js +497 -0
- package/dist/chunk-E5X75WNB.js.map +1 -0
- package/dist/chunk-E63IF3MD.cjs +951 -0
- package/dist/chunk-E63IF3MD.cjs.map +1 -0
- package/dist/chunk-EWP5AT6A.cjs +268 -0
- package/dist/chunk-EWP5AT6A.cjs.map +1 -0
- package/dist/{chunk-K7QF2QCM.cjs → chunk-FTSSDDZQ.cjs} +7 -3
- package/dist/chunk-FTSSDDZQ.cjs.map +1 -0
- package/dist/chunk-G7VZBCD6.cjs +35 -0
- package/dist/{chunk-5BLDMQED.cjs.map → chunk-G7VZBCD6.cjs.map} +1 -1
- package/dist/{chunk-VMSRTAH7.js → chunk-GLCPGZPM.js} +56 -6
- package/dist/chunk-GLCPGZPM.js.map +1 -0
- package/dist/{chunk-V3B25QOK.cjs → chunk-GVFB5C6O.cjs} +74 -2
- package/dist/chunk-GVFB5C6O.cjs.map +1 -0
- package/dist/chunk-HVSQDZZJ.cjs +765 -0
- package/dist/chunk-HVSQDZZJ.cjs.map +1 -0
- package/dist/chunk-HYC4GNHX.js +758 -0
- package/dist/chunk-HYC4GNHX.js.map +1 -0
- package/dist/chunk-KDVDIZ4Y.cjs +3479 -0
- package/dist/chunk-KDVDIZ4Y.cjs.map +1 -0
- package/dist/{chunk-OG3KX56O.js → chunk-KWGNR4HM.js} +7 -3
- package/dist/chunk-KWGNR4HM.js.map +1 -0
- package/dist/chunk-LIJVWQKU.cjs +256 -0
- package/dist/chunk-LIJVWQKU.cjs.map +1 -0
- package/dist/{chunk-XTZSUDSI.js → chunk-LTRCYJAG.js} +3 -18
- package/dist/chunk-LTRCYJAG.js.map +1 -0
- package/dist/{chunk-UEYC46RL.js → chunk-OUGKLCYF.js} +71 -8
- package/dist/chunk-OUGKLCYF.js.map +1 -0
- package/dist/chunk-QKOFKITP.js +258 -0
- package/dist/chunk-QKOFKITP.js.map +1 -0
- package/dist/chunk-RONAX6UU.js +3456 -0
- package/dist/chunk-RONAX6UU.js.map +1 -0
- package/dist/{chunk-5Y7QGIHD.js → chunk-RRYXQMZG.js} +60 -344
- package/dist/chunk-RRYXQMZG.js.map +1 -0
- package/dist/{chunk-QUJ4OLSC.js → chunk-U74F3YZU.js} +87 -7
- package/dist/chunk-U74F3YZU.js.map +1 -0
- package/dist/chunk-VIONYQ2K.cjs +517 -0
- package/dist/chunk-VIONYQ2K.cjs.map +1 -0
- package/dist/chunk-VSTRLXMQ.cjs +50 -0
- package/dist/chunk-VSTRLXMQ.cjs.map +1 -0
- package/dist/chunk-YT7HXXVN.js +13 -0
- package/dist/chunk-YT7HXXVN.js.map +1 -0
- package/dist/chunk-Z6ZWNWWR.js +30 -0
- package/dist/{chunk-NSBPE2FW.js.map → chunk-Z6ZWNWWR.js.map} +1 -1
- package/dist/cli/index.cjs +11 -7
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +11 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/client.cjs +45 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +11 -0
- package/dist/client.d.ts +11 -0
- package/dist/client.js +4 -0
- package/dist/client.js.map +1 -0
- package/dist/drizzle/index.cjs +20 -17
- package/dist/drizzle/index.d.cts +115 -5
- package/dist/drizzle/index.d.ts +115 -5
- package/dist/drizzle/index.js +4 -5
- package/dist/graphql/index.cjs +4 -4
- package/dist/graphql/index.d.cts +3 -2
- package/dist/graphql/index.d.ts +3 -2
- package/dist/graphql/index.js +2 -2
- package/dist/{index-4fJKLFK2.d.ts → index-BvZ1iWm2.d.ts} +1 -1
- package/dist/{index-DI0DRPNv.d.cts → index-CTLPjpMH.d.cts} +1 -1
- package/dist/index.cjs +3391 -649
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +368 -309
- package/dist/index.d.ts +368 -309
- package/dist/index.js +3253 -599
- package/dist/index.js.map +1 -1
- package/dist/media-HOT3O7RW.js +4 -0
- package/dist/media-HOT3O7RW.js.map +1 -0
- package/dist/media-WKP5AOX2.cjs +17 -0
- package/dist/media-WKP5AOX2.cjs.map +1 -0
- package/dist/mongodb/index.cjs +1 -1
- package/dist/mongodb/index.d.cts +2 -2
- package/dist/mongodb/index.d.ts +2 -2
- package/dist/mongodb/index.js +1 -1
- package/dist/mysql-media-AI6YK767.cjs +48 -0
- package/dist/mysql-media-AI6YK767.cjs.map +1 -0
- package/dist/mysql-media-CDZUS7YX.js +45 -0
- package/dist/mysql-media-CDZUS7YX.js.map +1 -0
- package/dist/postgres-auth-adapter-EVRPO7BQ.cjs +14 -0
- package/dist/{postgres-auth-adapter-VK6GY7LX.cjs.map → postgres-auth-adapter-EVRPO7BQ.cjs.map} +1 -1
- package/dist/postgres-auth-adapter-OTRWSTT5.js +5 -0
- package/dist/{postgres-auth-adapter-REJFUMP7.js.map → postgres-auth-adapter-OTRWSTT5.js.map} +1 -1
- package/dist/rate-limit-BvUAVCzw.d.cts +223 -0
- package/dist/rate-limit-CJnqG1mG.d.ts +223 -0
- package/dist/redis-adapter-2N6VA7BI.cjs +13 -0
- package/dist/{redis-adapter-LBLNKGNS.cjs.map → redis-adapter-2N6VA7BI.cjs.map} +1 -1
- package/dist/redis-adapter-RA24FNCX.js +4 -0
- package/dist/{redis-adapter-4YDY4LWE.js.map → redis-adapter-RA24FNCX.js.map} +1 -1
- package/dist/rest/index.cjs +7 -5
- package/dist/rest/index.d.cts +29 -3
- package/dist/rest/index.d.ts +29 -3
- package/dist/rest/index.js +5 -3
- package/dist/schema-CNB2DDTX.js +6 -0
- package/dist/schema-CNB2DDTX.js.map +1 -0
- package/dist/schema-Y777CQQS.cjs +67 -0
- package/dist/schema-Y777CQQS.cjs.map +1 -0
- package/dist/templates/index.cjs +24 -28
- package/dist/templates/index.d.cts +2 -4
- package/dist/templates/index.d.ts +2 -4
- package/dist/templates/index.js +2 -2
- package/dist/trpc/index.cjs +12 -12
- package/dist/trpc/index.d.cts +19 -14
- package/dist/trpc/index.d.ts +19 -14
- package/dist/trpc/index.js +3 -3
- package/dist/types-BSR91JFN.d.cts +159 -0
- package/dist/types-BSR91JFN.d.ts +159 -0
- package/dist/{types-BGM5MV_K.d.ts → types-Bt1OEk0S.d.cts} +78 -38
- package/dist/{types-BGM5MV_K.d.cts → types-Bt1OEk0S.d.ts} +78 -38
- package/dist/ws/index.cjs +1 -1
- package/dist/ws/index.js +1 -1
- package/package.json +19 -2
- package/dist/bootstrap-WMWQ4DBX.cjs +0 -29
- package/dist/bootstrap-WOVGAKZP.js +0 -4
- package/dist/chunk-3EVLFWH2.cjs.map +0 -1
- package/dist/chunk-3QX6KG2S.js +0 -2125
- package/dist/chunk-3QX6KG2S.js.map +0 -1
- package/dist/chunk-3VZCX4DF.cjs.map +0 -1
- package/dist/chunk-5BLDMQED.cjs +0 -18
- package/dist/chunk-5Y7QGIHD.js.map +0 -1
- package/dist/chunk-7G6EVYCU.cjs +0 -94
- package/dist/chunk-7G6EVYCU.cjs.map +0 -1
- package/dist/chunk-A3RQWHKD.cjs.map +0 -1
- package/dist/chunk-EINVJPFM.js.map +0 -1
- package/dist/chunk-F5B64H5S.cjs +0 -2149
- package/dist/chunk-F5B64H5S.cjs.map +0 -1
- package/dist/chunk-K7QF2QCM.cjs.map +0 -1
- package/dist/chunk-LRTZJJPD.js +0 -86
- package/dist/chunk-LRTZJJPD.js.map +0 -1
- package/dist/chunk-NSBPE2FW.js +0 -15
- package/dist/chunk-OG3KX56O.js.map +0 -1
- package/dist/chunk-QUJ4OLSC.js.map +0 -1
- package/dist/chunk-R3XIBBAW.cjs +0 -34
- package/dist/chunk-R3XIBBAW.cjs.map +0 -1
- package/dist/chunk-SDMNUYVU.js +0 -30
- package/dist/chunk-SDMNUYVU.js.map +0 -1
- package/dist/chunk-TZFJMPCH.cjs.map +0 -1
- package/dist/chunk-UEG7KMKC.cjs +0 -228
- package/dist/chunk-UEG7KMKC.cjs.map +0 -1
- package/dist/chunk-UEYC46RL.js.map +0 -1
- package/dist/chunk-V3B25QOK.cjs.map +0 -1
- package/dist/chunk-VMSRTAH7.js.map +0 -1
- package/dist/chunk-XTZSUDSI.js.map +0 -1
- package/dist/chunk-YD7Y25W7.cjs +0 -176
- package/dist/chunk-YD7Y25W7.cjs.map +0 -1
- package/dist/chunk-YPAFJ7EV.js +0 -225
- package/dist/chunk-YPAFJ7EV.js.map +0 -1
- package/dist/database-7CJOXEZR.js +0 -5
- package/dist/database-7CJOXEZR.js.map +0 -1
- package/dist/database-QOIV44GT.cjs +0 -22
- package/dist/database-QOIV44GT.cjs.map +0 -1
- package/dist/index-BMySjW6o.d.cts +0 -198
- package/dist/index-CMUNCIWQ.d.ts +0 -198
- package/dist/postgres-auth-adapter-REJFUMP7.js +0 -5
- package/dist/postgres-auth-adapter-VK6GY7LX.cjs +0 -14
- package/dist/redis-adapter-4YDY4LWE.js +0 -4
- package/dist/redis-adapter-LBLNKGNS.cjs +0 -13
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import Redis from 'ioredis';
|
|
2
|
+
|
|
3
|
+
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_delete" | "tenant_create" | "tenant_delete";
|
|
4
|
+
interface AuditLog {
|
|
5
|
+
id: string;
|
|
6
|
+
timestamp: Date;
|
|
7
|
+
action: AuditAction;
|
|
8
|
+
userId?: string;
|
|
9
|
+
userEmail?: string;
|
|
10
|
+
role?: string;
|
|
11
|
+
resource: string;
|
|
12
|
+
resourceId?: string;
|
|
13
|
+
changes?: {
|
|
14
|
+
field: string;
|
|
15
|
+
old: any;
|
|
16
|
+
new: any;
|
|
17
|
+
}[];
|
|
18
|
+
ipAddress?: string;
|
|
19
|
+
userAgent?: string;
|
|
20
|
+
success: boolean;
|
|
21
|
+
error?: string;
|
|
22
|
+
metadata?: Record<string, any>;
|
|
23
|
+
}
|
|
24
|
+
interface AuditLogFilter {
|
|
25
|
+
userId?: string;
|
|
26
|
+
action?: AuditAction | AuditAction[];
|
|
27
|
+
resource?: string;
|
|
28
|
+
resourceId?: string;
|
|
29
|
+
success?: boolean;
|
|
30
|
+
startDate?: Date;
|
|
31
|
+
endDate?: Date;
|
|
32
|
+
limit?: number;
|
|
33
|
+
offset?: number;
|
|
34
|
+
}
|
|
35
|
+
declare class AuditLogger {
|
|
36
|
+
private redis;
|
|
37
|
+
private prefix;
|
|
38
|
+
private retentionDays;
|
|
39
|
+
constructor(redis: Redis, retentionDays?: number, prefix?: string);
|
|
40
|
+
log(data: Omit<AuditLog, "id" | "timestamp">): Promise<string>;
|
|
41
|
+
get(id: string): Promise<AuditLog | null>;
|
|
42
|
+
query(filter?: AuditLogFilter): Promise<{
|
|
43
|
+
logs: AuditLog[];
|
|
44
|
+
total: number;
|
|
45
|
+
}>;
|
|
46
|
+
getRecent(limit?: number): Promise<AuditLog[]>;
|
|
47
|
+
getUserActivity(userId: string, limit?: number): Promise<AuditLog[]>;
|
|
48
|
+
getStats(startDate?: Date, endDate?: Date): Promise<{
|
|
49
|
+
totalEvents: number;
|
|
50
|
+
byAction: Record<string, number>;
|
|
51
|
+
successRate: number;
|
|
52
|
+
failedLogins: number;
|
|
53
|
+
uniqueUsers: Set<string>;
|
|
54
|
+
}>;
|
|
55
|
+
cleanup(): Promise<number>;
|
|
56
|
+
private getKeyForDate;
|
|
57
|
+
private getKeysForDateRange;
|
|
58
|
+
private matchesFilter;
|
|
59
|
+
private serializeLog;
|
|
60
|
+
private deserializeLog;
|
|
61
|
+
}
|
|
62
|
+
declare function createAuditContext(req: Request): {
|
|
63
|
+
ipAddress: string;
|
|
64
|
+
userAgent: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
interface AuthUser {
|
|
68
|
+
id: string;
|
|
69
|
+
email: string;
|
|
70
|
+
passwordHash?: string;
|
|
71
|
+
role: UserRole;
|
|
72
|
+
tenantId?: string;
|
|
73
|
+
emailVerified?: boolean;
|
|
74
|
+
locked?: boolean;
|
|
75
|
+
lastLogin?: string;
|
|
76
|
+
failedLoginAttempts?: number;
|
|
77
|
+
createdAt: string;
|
|
78
|
+
updatedAt: string;
|
|
79
|
+
}
|
|
80
|
+
type UserRole = "super_admin" | "admin" | "editor" | "author" | "customer" | "guest";
|
|
81
|
+
interface Session {
|
|
82
|
+
id: string;
|
|
83
|
+
userId: string;
|
|
84
|
+
token: string;
|
|
85
|
+
refreshToken?: string;
|
|
86
|
+
expiresAt: string;
|
|
87
|
+
createdAt: string;
|
|
88
|
+
ipAddress?: string;
|
|
89
|
+
userAgent?: string;
|
|
90
|
+
}
|
|
91
|
+
interface JWTPayload {
|
|
92
|
+
sub: string;
|
|
93
|
+
email: string;
|
|
94
|
+
role: UserRole;
|
|
95
|
+
tenantId?: string;
|
|
96
|
+
iat: number;
|
|
97
|
+
exp: number;
|
|
98
|
+
}
|
|
99
|
+
interface AuthTokenConfig {
|
|
100
|
+
secret: string;
|
|
101
|
+
expiresIn?: string | number;
|
|
102
|
+
refreshExpiresIn?: string | number;
|
|
103
|
+
issuer?: string;
|
|
104
|
+
audience?: string[];
|
|
105
|
+
saltRounds?: number;
|
|
106
|
+
}
|
|
107
|
+
interface LoginCredentials {
|
|
108
|
+
email: string;
|
|
109
|
+
password: string;
|
|
110
|
+
}
|
|
111
|
+
interface RegisterData {
|
|
112
|
+
email: string;
|
|
113
|
+
password: string;
|
|
114
|
+
role?: UserRole;
|
|
115
|
+
tenantId?: string;
|
|
116
|
+
}
|
|
117
|
+
interface AuthResult {
|
|
118
|
+
success: boolean;
|
|
119
|
+
user?: AuthUser;
|
|
120
|
+
session?: Session;
|
|
121
|
+
token?: string;
|
|
122
|
+
error?: string;
|
|
123
|
+
}
|
|
124
|
+
interface AuthAdapter {
|
|
125
|
+
createUser(data: {
|
|
126
|
+
email: string;
|
|
127
|
+
password: string;
|
|
128
|
+
role?: UserRole;
|
|
129
|
+
tenantId?: string;
|
|
130
|
+
}): Promise<AuthUser>;
|
|
131
|
+
findUserByEmail(email: string): Promise<AuthUser | null>;
|
|
132
|
+
findUserById(id: string): Promise<AuthUser | null>;
|
|
133
|
+
updateUser(id: string, data: Partial<AuthUser> & {
|
|
134
|
+
password?: string;
|
|
135
|
+
}): Promise<AuthUser | null>;
|
|
136
|
+
deleteUser(id: string): Promise<boolean>;
|
|
137
|
+
verifyPassword(email: string, password: string): Promise<AuthUser | null>;
|
|
138
|
+
hashPassword(password: string): Promise<string>;
|
|
139
|
+
createSession(userId: string, data?: {
|
|
140
|
+
ipAddress?: string;
|
|
141
|
+
userAgent?: string;
|
|
142
|
+
}): Promise<Session>;
|
|
143
|
+
findSessionByToken(token: string): Promise<Session | null>;
|
|
144
|
+
deleteSession(sessionId: string): Promise<boolean>;
|
|
145
|
+
deleteUserSessions(userId: string): Promise<number>;
|
|
146
|
+
hasAnyUsers?(): Promise<boolean>;
|
|
147
|
+
connect?(): Promise<void>;
|
|
148
|
+
disconnect?(): Promise<void>;
|
|
149
|
+
addPasswordToHistory?(userId: string, passwordHash: string): Promise<void>;
|
|
150
|
+
getPasswordHistory?(userId: string, count?: number): Promise<string[]>;
|
|
151
|
+
isPasswordInHistory?(password: string, userId: string, historyCount?: number): Promise<boolean>;
|
|
152
|
+
findAuditLogs(filter: AuditLogFilter): Promise<{
|
|
153
|
+
logs: AuditLog[];
|
|
154
|
+
total: number;
|
|
155
|
+
}>;
|
|
156
|
+
createAuditLog(data: Omit<AuditLog, "id" | "timestamp">): Promise<AuditLog>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export { type AuditAction as A, type JWTPayload as J, type LoginCredentials as L, type RegisterData as R, type Session as S, type UserRole as U, type AuditLog as a, type AuditLogFilter as b, type AuthAdapter as c, type AuthResult as d, type AuthTokenConfig as e, type AuthUser as f, AuditLogger as g, createAuditContext as h };
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import Redis from 'ioredis';
|
|
2
|
+
|
|
3
|
+
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_delete" | "tenant_create" | "tenant_delete";
|
|
4
|
+
interface AuditLog {
|
|
5
|
+
id: string;
|
|
6
|
+
timestamp: Date;
|
|
7
|
+
action: AuditAction;
|
|
8
|
+
userId?: string;
|
|
9
|
+
userEmail?: string;
|
|
10
|
+
role?: string;
|
|
11
|
+
resource: string;
|
|
12
|
+
resourceId?: string;
|
|
13
|
+
changes?: {
|
|
14
|
+
field: string;
|
|
15
|
+
old: any;
|
|
16
|
+
new: any;
|
|
17
|
+
}[];
|
|
18
|
+
ipAddress?: string;
|
|
19
|
+
userAgent?: string;
|
|
20
|
+
success: boolean;
|
|
21
|
+
error?: string;
|
|
22
|
+
metadata?: Record<string, any>;
|
|
23
|
+
}
|
|
24
|
+
interface AuditLogFilter {
|
|
25
|
+
userId?: string;
|
|
26
|
+
action?: AuditAction | AuditAction[];
|
|
27
|
+
resource?: string;
|
|
28
|
+
resourceId?: string;
|
|
29
|
+
success?: boolean;
|
|
30
|
+
startDate?: Date;
|
|
31
|
+
endDate?: Date;
|
|
32
|
+
limit?: number;
|
|
33
|
+
offset?: number;
|
|
34
|
+
}
|
|
35
|
+
declare class AuditLogger {
|
|
36
|
+
private redis;
|
|
37
|
+
private prefix;
|
|
38
|
+
private retentionDays;
|
|
39
|
+
constructor(redis: Redis, retentionDays?: number, prefix?: string);
|
|
40
|
+
log(data: Omit<AuditLog, "id" | "timestamp">): Promise<string>;
|
|
41
|
+
get(id: string): Promise<AuditLog | null>;
|
|
42
|
+
query(filter?: AuditLogFilter): Promise<{
|
|
43
|
+
logs: AuditLog[];
|
|
44
|
+
total: number;
|
|
45
|
+
}>;
|
|
46
|
+
getRecent(limit?: number): Promise<AuditLog[]>;
|
|
47
|
+
getUserActivity(userId: string, limit?: number): Promise<AuditLog[]>;
|
|
48
|
+
getStats(startDate?: Date, endDate?: Date): Promise<{
|
|
49
|
+
totalEvents: number;
|
|
50
|
+
byAction: Record<string, number>;
|
|
51
|
+
successRate: number;
|
|
52
|
+
failedLogins: number;
|
|
53
|
+
uniqueUsers: Set<string>;
|
|
54
|
+
}>;
|
|
55
|
+
cleanup(): Promise<number>;
|
|
56
|
+
private getKeyForDate;
|
|
57
|
+
private getKeysForDateRange;
|
|
58
|
+
private matchesFilter;
|
|
59
|
+
private serializeLog;
|
|
60
|
+
private deserializeLog;
|
|
61
|
+
}
|
|
62
|
+
declare function createAuditContext(req: Request): {
|
|
63
|
+
ipAddress: string;
|
|
64
|
+
userAgent: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
interface AuthUser {
|
|
68
|
+
id: string;
|
|
69
|
+
email: string;
|
|
70
|
+
passwordHash?: string;
|
|
71
|
+
role: UserRole;
|
|
72
|
+
tenantId?: string;
|
|
73
|
+
emailVerified?: boolean;
|
|
74
|
+
locked?: boolean;
|
|
75
|
+
lastLogin?: string;
|
|
76
|
+
failedLoginAttempts?: number;
|
|
77
|
+
createdAt: string;
|
|
78
|
+
updatedAt: string;
|
|
79
|
+
}
|
|
80
|
+
type UserRole = "super_admin" | "admin" | "editor" | "author" | "customer" | "guest";
|
|
81
|
+
interface Session {
|
|
82
|
+
id: string;
|
|
83
|
+
userId: string;
|
|
84
|
+
token: string;
|
|
85
|
+
refreshToken?: string;
|
|
86
|
+
expiresAt: string;
|
|
87
|
+
createdAt: string;
|
|
88
|
+
ipAddress?: string;
|
|
89
|
+
userAgent?: string;
|
|
90
|
+
}
|
|
91
|
+
interface JWTPayload {
|
|
92
|
+
sub: string;
|
|
93
|
+
email: string;
|
|
94
|
+
role: UserRole;
|
|
95
|
+
tenantId?: string;
|
|
96
|
+
iat: number;
|
|
97
|
+
exp: number;
|
|
98
|
+
}
|
|
99
|
+
interface AuthTokenConfig {
|
|
100
|
+
secret: string;
|
|
101
|
+
expiresIn?: string | number;
|
|
102
|
+
refreshExpiresIn?: string | number;
|
|
103
|
+
issuer?: string;
|
|
104
|
+
audience?: string[];
|
|
105
|
+
saltRounds?: number;
|
|
106
|
+
}
|
|
107
|
+
interface LoginCredentials {
|
|
108
|
+
email: string;
|
|
109
|
+
password: string;
|
|
110
|
+
}
|
|
111
|
+
interface RegisterData {
|
|
112
|
+
email: string;
|
|
113
|
+
password: string;
|
|
114
|
+
role?: UserRole;
|
|
115
|
+
tenantId?: string;
|
|
116
|
+
}
|
|
117
|
+
interface AuthResult {
|
|
118
|
+
success: boolean;
|
|
119
|
+
user?: AuthUser;
|
|
120
|
+
session?: Session;
|
|
121
|
+
token?: string;
|
|
122
|
+
error?: string;
|
|
123
|
+
}
|
|
124
|
+
interface AuthAdapter {
|
|
125
|
+
createUser(data: {
|
|
126
|
+
email: string;
|
|
127
|
+
password: string;
|
|
128
|
+
role?: UserRole;
|
|
129
|
+
tenantId?: string;
|
|
130
|
+
}): Promise<AuthUser>;
|
|
131
|
+
findUserByEmail(email: string): Promise<AuthUser | null>;
|
|
132
|
+
findUserById(id: string): Promise<AuthUser | null>;
|
|
133
|
+
updateUser(id: string, data: Partial<AuthUser> & {
|
|
134
|
+
password?: string;
|
|
135
|
+
}): Promise<AuthUser | null>;
|
|
136
|
+
deleteUser(id: string): Promise<boolean>;
|
|
137
|
+
verifyPassword(email: string, password: string): Promise<AuthUser | null>;
|
|
138
|
+
hashPassword(password: string): Promise<string>;
|
|
139
|
+
createSession(userId: string, data?: {
|
|
140
|
+
ipAddress?: string;
|
|
141
|
+
userAgent?: string;
|
|
142
|
+
}): Promise<Session>;
|
|
143
|
+
findSessionByToken(token: string): Promise<Session | null>;
|
|
144
|
+
deleteSession(sessionId: string): Promise<boolean>;
|
|
145
|
+
deleteUserSessions(userId: string): Promise<number>;
|
|
146
|
+
hasAnyUsers?(): Promise<boolean>;
|
|
147
|
+
connect?(): Promise<void>;
|
|
148
|
+
disconnect?(): Promise<void>;
|
|
149
|
+
addPasswordToHistory?(userId: string, passwordHash: string): Promise<void>;
|
|
150
|
+
getPasswordHistory?(userId: string, count?: number): Promise<string[]>;
|
|
151
|
+
isPasswordInHistory?(password: string, userId: string, historyCount?: number): Promise<boolean>;
|
|
152
|
+
findAuditLogs(filter: AuditLogFilter): Promise<{
|
|
153
|
+
logs: AuditLog[];
|
|
154
|
+
total: number;
|
|
155
|
+
}>;
|
|
156
|
+
createAuditLog(data: Omit<AuditLog, "id" | "timestamp">): Promise<AuditLog>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export { type AuditAction as A, type JWTPayload as J, type LoginCredentials as L, type RegisterData as R, type Session as S, type UserRole as U, type AuditLog as a, type AuditLogFilter as b, type AuthAdapter as c, type AuthResult as d, type AuthTokenConfig as e, type AuthUser as f, AuditLogger as g, createAuditContext as h };
|
|
@@ -4,8 +4,12 @@ interface FieldAdmin {
|
|
|
4
4
|
readOnly?: boolean;
|
|
5
5
|
hidden?: boolean;
|
|
6
6
|
width?: string;
|
|
7
|
+
position?: "sidebar" | "main";
|
|
8
|
+
autoGenerate?: string;
|
|
9
|
+
action?: string;
|
|
10
|
+
method?: string;
|
|
11
|
+
inline?: boolean;
|
|
7
12
|
condition?: (data: Record<string, any>, siblingData: Record<string, any>) => boolean;
|
|
8
|
-
position?: 'sidebar' | 'main';
|
|
9
13
|
}
|
|
10
14
|
interface BaseField {
|
|
11
15
|
name: string;
|
|
@@ -31,9 +35,9 @@ interface ValidateOptions {
|
|
|
31
35
|
required?: boolean;
|
|
32
36
|
}
|
|
33
37
|
type Hook$1 = (args: any) => Promise<any> | any;
|
|
34
|
-
type TextFieldVariant =
|
|
38
|
+
type TextFieldVariant = "text" | "email" | "password" | "url" | "id";
|
|
35
39
|
interface TextField extends BaseField {
|
|
36
|
-
type:
|
|
40
|
+
type: "text";
|
|
37
41
|
variant?: TextFieldVariant;
|
|
38
42
|
minLength?: number;
|
|
39
43
|
maxLength?: number;
|
|
@@ -42,7 +46,7 @@ interface TextField extends BaseField {
|
|
|
42
46
|
localized?: boolean;
|
|
43
47
|
}
|
|
44
48
|
interface NumberField extends BaseField {
|
|
45
|
-
type:
|
|
49
|
+
type: "number";
|
|
46
50
|
min?: number;
|
|
47
51
|
max?: number;
|
|
48
52
|
step?: number;
|
|
@@ -50,29 +54,29 @@ interface NumberField extends BaseField {
|
|
|
50
54
|
hasMany?: boolean;
|
|
51
55
|
}
|
|
52
56
|
interface CheckboxField extends BaseField {
|
|
53
|
-
type:
|
|
57
|
+
type: "checkbox";
|
|
54
58
|
}
|
|
55
59
|
interface DateField extends BaseField {
|
|
56
|
-
type:
|
|
60
|
+
type: "date";
|
|
57
61
|
minDate?: string;
|
|
58
62
|
maxDate?: string;
|
|
59
63
|
time?: boolean;
|
|
60
64
|
}
|
|
61
65
|
interface EmailField extends BaseField {
|
|
62
|
-
type:
|
|
66
|
+
type: "email";
|
|
63
67
|
}
|
|
64
68
|
interface PasswordField extends BaseField {
|
|
65
|
-
type:
|
|
69
|
+
type: "password";
|
|
66
70
|
}
|
|
67
71
|
interface TextareaField extends BaseField {
|
|
68
|
-
type:
|
|
72
|
+
type: "textarea";
|
|
69
73
|
minLength?: number;
|
|
70
74
|
maxLength?: number;
|
|
71
75
|
rows?: number;
|
|
72
76
|
localized?: boolean;
|
|
73
77
|
}
|
|
74
78
|
interface SelectField extends BaseField {
|
|
75
|
-
type:
|
|
79
|
+
type: "select";
|
|
76
80
|
options: Array<{
|
|
77
81
|
label: string;
|
|
78
82
|
value: string;
|
|
@@ -81,7 +85,7 @@ interface SelectField extends BaseField {
|
|
|
81
85
|
defaultValue?: string | string[];
|
|
82
86
|
}
|
|
83
87
|
interface RadioField extends BaseField {
|
|
84
|
-
type:
|
|
88
|
+
type: "radio";
|
|
85
89
|
options: Array<{
|
|
86
90
|
label: string;
|
|
87
91
|
value: string;
|
|
@@ -89,44 +93,52 @@ interface RadioField extends BaseField {
|
|
|
89
93
|
defaultValue?: string;
|
|
90
94
|
}
|
|
91
95
|
interface ColorField extends BaseField {
|
|
92
|
-
type:
|
|
93
|
-
format?:
|
|
96
|
+
type: "color";
|
|
97
|
+
format?: "hex" | "rgb" | "hsl";
|
|
94
98
|
defaultValue?: string;
|
|
95
99
|
}
|
|
100
|
+
interface ImageField extends BaseField {
|
|
101
|
+
type: "image";
|
|
102
|
+
minCount?: number;
|
|
103
|
+
maxCount?: number;
|
|
104
|
+
allowedTypes?: string[];
|
|
105
|
+
maxSize?: number;
|
|
106
|
+
}
|
|
96
107
|
interface RichTextBlock {
|
|
97
108
|
type: string;
|
|
98
109
|
data: Record<string, any>;
|
|
99
110
|
children?: RichTextBlock[];
|
|
100
111
|
}
|
|
101
112
|
interface RichTextField extends BaseField {
|
|
102
|
-
type:
|
|
103
|
-
editor?:
|
|
113
|
+
type: "richtext";
|
|
114
|
+
editor?: "lexical" | "slate" | "blocks";
|
|
115
|
+
hasBlocks?: boolean;
|
|
104
116
|
defaultValue?: RichTextBlock[];
|
|
105
117
|
localized?: boolean;
|
|
106
118
|
}
|
|
107
119
|
interface JSONField extends BaseField {
|
|
108
|
-
type:
|
|
120
|
+
type: "json";
|
|
109
121
|
defaultValue?: Record<string, any>;
|
|
110
122
|
}
|
|
111
123
|
interface CodeField extends BaseField {
|
|
112
|
-
type:
|
|
124
|
+
type: "code";
|
|
113
125
|
language?: string;
|
|
114
126
|
defaultValue?: string;
|
|
115
127
|
}
|
|
116
128
|
interface UploadField extends BaseField {
|
|
117
|
-
type:
|
|
129
|
+
type: "upload";
|
|
118
130
|
relationTo: string;
|
|
119
131
|
hasMany?: boolean;
|
|
120
132
|
maxDepth?: number;
|
|
121
133
|
defaultValue?: string;
|
|
122
134
|
}
|
|
123
135
|
interface MarkdownField extends BaseField {
|
|
124
|
-
type:
|
|
136
|
+
type: "markdown";
|
|
125
137
|
localized?: boolean;
|
|
126
138
|
defaultValue?: string;
|
|
127
139
|
}
|
|
128
140
|
interface RelationshipField extends BaseField {
|
|
129
|
-
type:
|
|
141
|
+
type: "relationship";
|
|
130
142
|
relationTo: string | string[];
|
|
131
143
|
hasMany?: boolean;
|
|
132
144
|
maxDepth?: number;
|
|
@@ -137,7 +149,7 @@ interface RelationshipField extends BaseField {
|
|
|
137
149
|
defaultValue?: string | string[];
|
|
138
150
|
}
|
|
139
151
|
interface ArrayField extends BaseField {
|
|
140
|
-
type:
|
|
152
|
+
type: "array";
|
|
141
153
|
fields: Field[];
|
|
142
154
|
minRows?: number;
|
|
143
155
|
maxRows?: number;
|
|
@@ -148,19 +160,31 @@ interface ArrayField extends BaseField {
|
|
|
148
160
|
defaultValue?: Record<string, any>[];
|
|
149
161
|
}
|
|
150
162
|
interface GroupField extends BaseField {
|
|
151
|
-
type:
|
|
163
|
+
type: "group";
|
|
152
164
|
fields: Field[];
|
|
153
165
|
defaultValue?: Record<string, any>;
|
|
154
166
|
}
|
|
167
|
+
interface BlockImage {
|
|
168
|
+
url: string;
|
|
169
|
+
alt?: string;
|
|
170
|
+
}
|
|
171
|
+
interface BlockAdmin {
|
|
172
|
+
group?: string;
|
|
173
|
+
images?: {
|
|
174
|
+
icon?: BlockImage | string;
|
|
175
|
+
thumbnail?: BlockImage | string;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
155
178
|
interface Block {
|
|
156
179
|
slug: string;
|
|
157
180
|
label: string;
|
|
158
181
|
fields: Field[];
|
|
159
182
|
imageURL?: string;
|
|
183
|
+
admin?: BlockAdmin;
|
|
160
184
|
}
|
|
161
185
|
interface BlocksField extends BaseField {
|
|
162
|
-
type:
|
|
163
|
-
blocks
|
|
186
|
+
type: "blocks";
|
|
187
|
+
blocks?: Block[];
|
|
164
188
|
minRows?: number;
|
|
165
189
|
maxRows?: number;
|
|
166
190
|
defaultValue?: Array<{
|
|
@@ -168,19 +192,19 @@ interface BlocksField extends BaseField {
|
|
|
168
192
|
[key: string]: any;
|
|
169
193
|
}>;
|
|
170
194
|
}
|
|
171
|
-
interface RowField extends Omit<BaseField,
|
|
172
|
-
type:
|
|
195
|
+
interface RowField extends Omit<BaseField, "name"> {
|
|
196
|
+
type: "row";
|
|
173
197
|
fields: Field[];
|
|
174
198
|
name?: string;
|
|
175
199
|
}
|
|
176
|
-
interface CollapsibleField extends Omit<BaseField,
|
|
177
|
-
type:
|
|
200
|
+
interface CollapsibleField extends Omit<BaseField, "name"> {
|
|
201
|
+
type: "collapsible";
|
|
178
202
|
fields: Field[];
|
|
179
203
|
label: string;
|
|
180
204
|
name?: string;
|
|
181
205
|
}
|
|
182
|
-
interface TabsField extends Omit<BaseField,
|
|
183
|
-
type:
|
|
206
|
+
interface TabsField extends Omit<BaseField, "name"> {
|
|
207
|
+
type: "tabs";
|
|
184
208
|
tabs: Array<{
|
|
185
209
|
label: string;
|
|
186
210
|
fields: Field[];
|
|
@@ -188,8 +212,15 @@ interface TabsField extends Omit<BaseField, 'name'> {
|
|
|
188
212
|
}>;
|
|
189
213
|
name?: string;
|
|
190
214
|
}
|
|
191
|
-
|
|
192
|
-
type
|
|
215
|
+
interface ButtonField extends BaseField {
|
|
216
|
+
type: "button";
|
|
217
|
+
label: string;
|
|
218
|
+
action?: string;
|
|
219
|
+
method?: string;
|
|
220
|
+
inline?: boolean;
|
|
221
|
+
}
|
|
222
|
+
type Field = TextField | NumberField | CheckboxField | DateField | EmailField | PasswordField | TextareaField | SelectField | RadioField | ColorField | ImageField | RichTextField | JSONField | CodeField | UploadField | MarkdownField | RelationshipField | ArrayField | GroupField | BlocksField | RowField | CollapsibleField | TabsField | ButtonField;
|
|
223
|
+
type FieldType = Field["type"];
|
|
193
224
|
declare function isTextField(field: Field): field is TextField;
|
|
194
225
|
declare function isNumberField(field: Field): field is NumberField;
|
|
195
226
|
declare function isRelationshipField(field: Field): field is RelationshipField;
|
|
@@ -197,14 +228,15 @@ declare function isArrayField(field: Field): field is ArrayField;
|
|
|
197
228
|
declare function isGroupField(field: Field): field is GroupField;
|
|
198
229
|
declare function isBlocksField(field: Field): field is BlocksField;
|
|
199
230
|
declare function isUploadField(field: Field): field is UploadField;
|
|
231
|
+
declare function isImageField(field: Field): field is ImageField;
|
|
200
232
|
declare function isRichTextField(field: Field): field is RichTextField;
|
|
201
233
|
declare function isSelectField(field: Field): field is SelectField;
|
|
202
234
|
declare function isLayoutField(field: Field): field is RowField | CollapsibleField | TabsField;
|
|
203
235
|
declare const PRIMITIVE_FIELD_TYPES: readonly ["text", "number", "checkbox", "date", "email", "password", "textarea", "select", "radio", "color"];
|
|
204
|
-
declare const COMPLEX_FIELD_TYPES: readonly ["richtext", "json", "code", "upload", "markdown"];
|
|
236
|
+
declare const COMPLEX_FIELD_TYPES: readonly ["richtext", "json", "code", "upload", "image", "markdown"];
|
|
205
237
|
declare const RELATIONAL_FIELD_TYPES: readonly ["relationship", "array", "group", "blocks"];
|
|
206
238
|
declare const LAYOUT_FIELD_TYPES: readonly ["row", "collapsible", "tabs"];
|
|
207
|
-
declare const ALL_FIELD_TYPES: readonly ["text", "number", "checkbox", "date", "email", "password", "textarea", "select", "radio", "color", "richtext", "json", "code", "upload", "markdown", "relationship", "array", "group", "blocks", "row", "collapsible", "tabs"];
|
|
239
|
+
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"];
|
|
208
240
|
|
|
209
241
|
interface Request {
|
|
210
242
|
body?: any;
|
|
@@ -319,6 +351,7 @@ interface AdminConfig {
|
|
|
319
351
|
defaultLimit?: number;
|
|
320
352
|
limits?: number[];
|
|
321
353
|
};
|
|
354
|
+
layout?: 'split' | 'single';
|
|
322
355
|
}
|
|
323
356
|
interface UploadConfig {
|
|
324
357
|
staticDir?: string;
|
|
@@ -395,10 +428,12 @@ interface CollectionConfig {
|
|
|
395
428
|
fields: Record<string, number | 'text'>;
|
|
396
429
|
options?: Record<string, any>;
|
|
397
430
|
}>;
|
|
398
|
-
typescript?: {
|
|
399
|
-
interface?: string;
|
|
400
|
-
};
|
|
401
431
|
custom?: Record<string, any>;
|
|
432
|
+
tabs?: Array<{
|
|
433
|
+
label: string;
|
|
434
|
+
fields: Field[];
|
|
435
|
+
name?: string;
|
|
436
|
+
}>;
|
|
402
437
|
}
|
|
403
438
|
interface GlobalConfig {
|
|
404
439
|
slug: string;
|
|
@@ -415,6 +450,11 @@ interface GlobalConfig {
|
|
|
415
450
|
interface?: string;
|
|
416
451
|
};
|
|
417
452
|
custom?: Record<string, any>;
|
|
453
|
+
tabs?: Array<{
|
|
454
|
+
label: string;
|
|
455
|
+
fields: Field[];
|
|
456
|
+
name?: string;
|
|
457
|
+
}>;
|
|
418
458
|
}
|
|
419
459
|
interface FindArgs {
|
|
420
460
|
collection: string;
|
|
@@ -586,4 +626,4 @@ interface KyroConfig {
|
|
|
586
626
|
debug?: boolean;
|
|
587
627
|
}
|
|
588
628
|
|
|
589
|
-
export { type
|
|
629
|
+
export { type AdapterConfig as $, type AdminConfig as A, type BaseField as B, type CheckboxField as C, type DateField as D, type EmailField as E, type Field as F, type GlobalConfig as G, type CreateArgs as H, type ImageField as I, type JSONField as J, type KyroConfig as K, type UpdateArgs as L, type MarkdownField as M, type NumberField as N, type DeleteArgs as O, type PasswordField as P, type User as Q, type RadioField as R, type SelectField as S, type TabsField as T, type UploadConfig as U, type VersionConfig as V, type Request as W, type Hook as X, ALL_FIELD_TYPES as Y, type AccessArgs as Z, type AccessControl as _, type ArrayField as a, COMPLEX_FIELD_TYPES as a0, type CollectionAccess as a1, type CollectionHooks as a2, type CreateResult as a3, type FieldAccess as a4, type FieldHooks as a5, type GlobalAccess as a6, type GlobalHooks as a7, type HookArgs as a8, LAYOUT_FIELD_TYPES as a9, PRIMITIVE_FIELD_TYPES as aa, RELATIONAL_FIELD_TYPES as ab, type ValidateOptions as ac, type WhereClause as ad, evaluateAccess as ae, getWhereClause as af, isArrayField as ag, isBlocksField as ah, isGroupField as ai, isImageField as aj, isLayoutField as ak, isNumberField as al, isRelationshipField as am, isRichTextField as an, isSelectField as ao, isTextField as ap, isUploadField as aq, mergeWhereClauses as ar, runFieldHooks as as, runHooks as at, type AuthConfig as b, type Block as c, type BlockAdmin as d, type BlockImage as e, type BlocksField as f, type CodeField as g, type CollapsibleField as h, type CollectionConfig as i, type ColorField as j, type FieldAdmin as k, type FieldType as l, type GroupField as m, type ImageSize as n, type RelationshipField as o, type RichTextBlock as p, type RichTextField as q, type RowField as r, type TextField as s, type TextareaField as t, type UploadField as u, type PluginConfig as v, type BaseAdapter as w, type FindArgs as x, type FindResult as y, type FindByIDArgs as z };
|