@kyro-cms/core 0.12.11 → 0.12.15

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.
Files changed (47) hide show
  1. package/package.json +3 -3
  2. package/dist/WebhookService-ByrpAI4d.d.ts +0 -143
  3. package/dist/WebhookService-i-Kl3dvf.d.cts +0 -143
  4. package/dist/api-handler-graphql.d.cts +0 -6
  5. package/dist/api-handler-graphql.d.ts +0 -6
  6. package/dist/api-handler-trpc.d.cts +0 -5
  7. package/dist/api-handler-trpc.d.ts +0 -5
  8. package/dist/api-handler.d.cts +0 -7
  9. package/dist/api-handler.d.ts +0 -7
  10. package/dist/base-iyJTfH-3.d.cts +0 -74
  11. package/dist/base-oUSURe4_.d.ts +0 -74
  12. package/dist/cli/index.d.cts +0 -1
  13. package/dist/cli/index.d.ts +0 -1
  14. package/dist/client.d.cts +0 -12
  15. package/dist/client.d.ts +0 -12
  16. package/dist/drizzle/index.d.cts +0 -169
  17. package/dist/drizzle/index.d.ts +0 -169
  18. package/dist/fields/index.d.cts +0 -7
  19. package/dist/fields/index.d.ts +0 -7
  20. package/dist/graphql/index.d.cts +0 -57
  21. package/dist/graphql/index.d.ts +0 -57
  22. package/dist/index-Bz9JqRGI.d.cts +0 -86
  23. package/dist/index-Bz9JqRGI.d.ts +0 -86
  24. package/dist/index-DNy8jbA2.d.cts +0 -282
  25. package/dist/index-DVDMEql7.d.ts +0 -282
  26. package/dist/index.d.cts +0 -1246
  27. package/dist/index.d.ts +0 -1246
  28. package/dist/integration.d.cts +0 -14
  29. package/dist/integration.d.ts +0 -14
  30. package/dist/mongodb/index.d.cts +0 -134
  31. package/dist/mongodb/index.d.ts +0 -134
  32. package/dist/rest/index.d.cts +0 -56
  33. package/dist/rest/index.d.ts +0 -56
  34. package/dist/richtext-DrhORshE.d.cts +0 -5
  35. package/dist/richtext-DrhORshE.d.ts +0 -5
  36. package/dist/templates/index.d.cts +0 -107
  37. package/dist/templates/index.d.ts +0 -107
  38. package/dist/trpc/index.d.cts +0 -142
  39. package/dist/trpc/index.d.ts +0 -142
  40. package/dist/types-BcZiluXL.d.cts +0 -569
  41. package/dist/types-CpjuXbe7.d.cts +0 -150
  42. package/dist/types-CpjuXbe7.d.ts +0 -150
  43. package/dist/types-Dc8VAPhF.d.ts +0 -569
  44. package/dist/types-euTszc-1.d.cts +0 -294
  45. package/dist/types-euTszc-1.d.ts +0 -294
  46. package/dist/ws/index.d.cts +0 -88
  47. package/dist/ws/index.d.ts +0 -88
@@ -1,569 +0,0 @@
1
- import { F as Field } from './types-euTszc-1.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 PluginHooks {
66
- beforeInit?: Hook[];
67
- afterInit?: Hook[];
68
- beforeRegisterCollections?: Hook[];
69
- afterRegisterCollections?: Hook[];
70
- beforeRegisterGlobals?: Hook[];
71
- afterRegisterGlobals?: Hook[];
72
- beforeServerStart?: Hook[];
73
- afterServerStart?: Hook[];
74
- beforeServerStop?: Hook[];
75
- afterServerStop?: Hook[];
76
- }
77
- interface PluginCollectionExtension {
78
- slug: string;
79
- config: Partial<CollectionConfig>;
80
- }
81
- interface PluginGlobalExtension {
82
- slug: string;
83
- config: Partial<GlobalConfig>;
84
- }
85
- interface PluginFieldExtension {
86
- collectionSlug: string;
87
- field: Field;
88
- }
89
- interface PluginAPI {
90
- registry: {
91
- getCollection: (slug: string) => CollectionConfig | undefined;
92
- getCollections: () => CollectionConfig[];
93
- getGlobal: (slug: string) => GlobalConfig | undefined;
94
- addCollection: (config: CollectionConfig) => void;
95
- addGlobal: (config: GlobalConfig) => void;
96
- extendCollection: (slug: string, extension: Partial<CollectionConfig>) => void;
97
- extendGlobal: (slug: string, extension: Partial<GlobalConfig>) => void;
98
- addField: (collectionSlug: string, field: Field, position?: number) => void;
99
- };
100
- hooks: {
101
- register: (event: string, handler: Hook) => void;
102
- unregister: (event: string, handler: Hook) => void;
103
- };
104
- config: {
105
- get: (key: string) => any;
106
- set: (key: string, value: any) => void;
107
- };
108
- db: any;
109
- }
110
- declare abstract class KyroPlugin {
111
- name: string;
112
- displayName?: string;
113
- adminEntry?: string;
114
- version?: string;
115
- description?: string;
116
- hooks: PluginHooks;
117
- collections: Partial<CollectionConfig>[];
118
- globals: Partial<GlobalConfig>[];
119
- fields: PluginFieldExtension[];
120
- extensions: {
121
- collections: PluginCollectionExtension[];
122
- globals: PluginGlobalExtension[];
123
- };
124
- adminComponents: Record<string, any>;
125
- adminStyles: string[];
126
- serverMiddleware?: (app: any) => void;
127
- clientMiddleware?: (req: any) => any;
128
- constructor(name: string);
129
- init?(api: PluginAPI): Promise<void>;
130
- beforeInit?(api: PluginAPI): Promise<void>;
131
- afterInit?(api: PluginAPI): Promise<void>;
132
- getCollections?(): Partial<CollectionConfig>[];
133
- getGlobals?(): Partial<GlobalConfig>[];
134
- getHooks?(): PluginHooks;
135
- }
136
- declare class PluginManager {
137
- private plugins;
138
- private hooks;
139
- register(plugin: KyroPlugin): void;
140
- unregister(name: string): void;
141
- get(name: string): KyroPlugin | undefined;
142
- getAll(): KyroPlugin[];
143
- has(name: string): boolean;
144
- registerHook(event: string, handler: Hook): void;
145
- unregisterHook(event: string, handler: Hook): void;
146
- executeHook(event: string, args?: any): Promise<any>;
147
- getAllCollections(): Partial<CollectionConfig>[];
148
- getAllGlobals(): Partial<GlobalConfig>[];
149
- getAllFields(): PluginFieldExtension[];
150
- getAdminComponents(): Record<string, any>;
151
- getAdminStyles(): string[];
152
- }
153
- declare class SEOPlugin extends KyroPlugin {
154
- constructor();
155
- }
156
- declare class AnalyticsPlugin extends KyroPlugin {
157
- constructor();
158
- }
159
- declare class CommentsPlugin extends KyroPlugin {
160
- constructor();
161
- }
162
- declare class ReviewsPlugin extends KyroPlugin {
163
- constructor();
164
- }
165
- declare class WishlistPlugin extends KyroPlugin {
166
- constructor();
167
- }
168
- declare const presetPlugins: {
169
- SEO: typeof SEOPlugin;
170
- Analytics: typeof AnalyticsPlugin;
171
- Comments: typeof CommentsPlugin;
172
- Reviews: typeof ReviewsPlugin;
173
- Wishlist: typeof WishlistPlugin;
174
- };
175
-
176
- interface WhereClause {
177
- [field: string]: any;
178
- }
179
- interface AccessArgs {
180
- req: Request;
181
- user?: User;
182
- data?: unknown;
183
- doc?: unknown;
184
- id?: string;
185
- tenantId?: string;
186
- context?: Record<string, unknown>;
187
- }
188
- type AccessControl = boolean | ((args: AccessArgs) => Promise<boolean | WhereClause> | boolean | WhereClause);
189
- interface CollectionAccess {
190
- create?: AccessControl;
191
- read?: AccessControl;
192
- update?: AccessControl;
193
- delete?: AccessControl;
194
- admin?: AccessControl;
195
- unlock?: AccessControl;
196
- readVersions?: AccessControl;
197
- }
198
- interface GlobalAccess {
199
- read?: AccessControl;
200
- update?: AccessControl;
201
- }
202
- interface FieldAccess {
203
- create?: AccessControl;
204
- read?: AccessControl;
205
- update?: AccessControl;
206
- }
207
- declare function evaluateAccess(access: AccessControl, args: AccessArgs): Promise<boolean | WhereClause>;
208
- declare function mergeWhereClauses(...whereClauses: (WhereClause | boolean | undefined)[]): WhereClause;
209
- declare function getWhereClause(access: AccessControl, args: AccessArgs): Promise<WhereClause | undefined>;
210
-
211
- interface TenantContext {
212
- tenantId: string;
213
- userId: string;
214
- role?: string;
215
- roles?: string[];
216
- permissions?: string[];
217
- isSuperAdmin?: boolean;
218
- }
219
-
220
- interface AdminConfig {
221
- useAsTitle?: string;
222
- defaultColumns?: string[];
223
- hidden?: boolean;
224
- description?: string;
225
- hideAPIURL?: boolean;
226
- group?: string;
227
- icon?: string;
228
- order?: number;
229
- preview?: (doc: Record<string, unknown>, options: {
230
- req: unknown;
231
- token?: string;
232
- }) => string | Promise<string>;
233
- disableDuplicate?: boolean;
234
- disablePreview?: boolean;
235
- pagination?: {
236
- defaultLimit?: number;
237
- limits?: number[];
238
- };
239
- layout?: "split" | "single";
240
- }
241
- /**
242
- * Field overrides allow modifying specific field properties by path.
243
- * Path uses dot notation: "fieldName" or "groupField.arrayField.targetField"
244
- * Commonly used to extend relationship fields with additional collections.
245
- */
246
- interface FieldOverrides {
247
- [fieldPath: string]: {
248
- relationTo?: string | string[];
249
- [key: string]: any;
250
- };
251
- }
252
- interface UploadConfig {
253
- staticDir?: string;
254
- staticURL?: string;
255
- mimeTypes?: string[];
256
- fileSize?: number;
257
- imageSizes?: ImageSize[];
258
- crop?: boolean;
259
- focalPoint?: boolean;
260
- formatOptions?: {
261
- format: "webp" | "png" | "jpg";
262
- options?: Record<string, unknown>;
263
- };
264
- resizeOptions?: Record<string, any>;
265
- adminThumbnail?: string;
266
- }
267
- interface ImageSize {
268
- name: string;
269
- width?: number;
270
- height?: number;
271
- crop?: string;
272
- position?: string;
273
- formatOptions?: {
274
- format: "webp" | "png" | "jpg";
275
- };
276
- generateImageName?: (doc: any) => string;
277
- }
278
- interface VersionConfig {
279
- maxPerDoc?: number;
280
- drafts?: boolean;
281
- retainDeleted?: boolean;
282
- }
283
- type DocumentStatus = 'draft' | 'published' | 'archived';
284
- interface AuthConfig {
285
- tokenExpiration?: number;
286
- verify?: boolean | {
287
- generateEmailHTML?: (args: any) => string;
288
- };
289
- maxLoginAttempts?: number;
290
- lockTime?: number;
291
- cookies?: {
292
- secure?: boolean;
293
- sameSite?: "strict" | "lax" | "none";
294
- domain?: string;
295
- };
296
- forgotPassword?: {
297
- generateEmailHTML?: (args: any) => string;
298
- generateEmailSubject?: (args: any) => string;
299
- };
300
- strategies?: Array<{
301
- name: string;
302
- authenticate: (args: any) => Promise<any>;
303
- }>;
304
- }
305
- interface CollectionConfig {
306
- slug: string;
307
- label?: string;
308
- labelPlural?: string;
309
- singularLabel?: string;
310
- admin?: AdminConfig;
311
- fields: Field[];
312
- access?: CollectionAccess;
313
- hooks?: CollectionHooks;
314
- timestamps?: boolean;
315
- tenantScoped?: boolean;
316
- tenantField?: string;
317
- upload?: UploadConfig;
318
- versions?: VersionConfig;
319
- auth?: boolean | AuthConfig;
320
- graphQL?: {
321
- singularName?: string;
322
- pluralName?: string;
323
- };
324
- indexes?: Array<{
325
- fields: Record<string, number | "text">;
326
- options?: Record<string, any>;
327
- }>;
328
- seo?: boolean | Record<string, any>;
329
- custom?: Record<string, any>;
330
- tabs?: Array<{
331
- label: string;
332
- fields: Field[];
333
- name?: string;
334
- }>;
335
- }
336
- interface GlobalConfig {
337
- slug: string;
338
- label?: string;
339
- admin?: AdminConfig;
340
- fields: Field[];
341
- access?: GlobalAccess;
342
- hooks?: GlobalHooks;
343
- versions?: VersionConfig;
344
- graphQL?: {
345
- name?: string;
346
- };
347
- typescript?: {
348
- interface?: string;
349
- };
350
- custom?: Record<string, any>;
351
- tabs?: Array<{
352
- label: string;
353
- fields: Field[];
354
- name?: string;
355
- }>;
356
- }
357
- interface FindArgs {
358
- collection: string;
359
- where?: Record<string, any>;
360
- sort?: string;
361
- limit?: number;
362
- page?: number;
363
- depth?: number;
364
- tenantId?: string;
365
- select?: string[];
366
- user?: any;
367
- context?: Record<string, any>;
368
- overrideAccess?: boolean;
369
- /** If true, returns draft docs (admin view). If false/omitted, only published docs are returned (public API). */
370
- draft?: boolean;
371
- }
372
- interface FindByIDArgs {
373
- collection: string;
374
- id: string;
375
- depth?: number;
376
- tenantId?: string;
377
- select?: string[];
378
- user?: any;
379
- context?: Record<string, any>;
380
- overrideAccess?: boolean;
381
- /** If true, returns document regardless of status (admin view). */
382
- draft?: boolean;
383
- }
384
- interface CreateArgs {
385
- collection: string;
386
- data: Record<string, any>;
387
- depth?: number;
388
- tenantId?: string;
389
- select?: string[];
390
- user?: any;
391
- context?: Record<string, any>;
392
- overrideAccess?: boolean;
393
- }
394
- interface UpdateArgs {
395
- collection: string;
396
- id: string;
397
- data: Record<string, any>;
398
- depth?: number;
399
- tenantId?: string;
400
- select?: string[];
401
- user?: any;
402
- context?: Record<string, any>;
403
- overrideAccess?: boolean;
404
- }
405
- interface DeleteArgs {
406
- collection: string;
407
- id: string;
408
- tenantId?: string;
409
- user?: any;
410
- context?: Record<string, any>;
411
- overrideAccess?: boolean;
412
- }
413
- interface FindResult<T = any> {
414
- docs: T[];
415
- totalDocs: number;
416
- limit: number;
417
- totalPages: number;
418
- page: number;
419
- pagingCounter: number;
420
- hasPrevPage: boolean;
421
- hasNextPage: boolean;
422
- prevPage: number | null;
423
- nextPage: number | null;
424
- }
425
- interface CreateResult<T = any> {
426
- doc: T;
427
- errors?: Array<{
428
- field: string;
429
- message: string;
430
- }>;
431
- }
432
- interface VersionRecord<T = Record<string, any>> {
433
- id: string;
434
- collection: string;
435
- documentId: string;
436
- version: number;
437
- status: DocumentStatus;
438
- data: T;
439
- createdBy?: string;
440
- createdAt: string;
441
- updatedAt: string;
442
- publishedAt?: string | null;
443
- changeDescription?: string;
444
- autosave?: boolean;
445
- }
446
- interface CreateVersionArgs<T = Record<string, any>> {
447
- collection: string;
448
- documentId: string;
449
- data: T;
450
- status: DocumentStatus;
451
- createdBy?: string;
452
- changeDescription?: string;
453
- tenantId?: string;
454
- /** When true, reuses a single version slot (find existing + update) */
455
- autosave?: boolean;
456
- }
457
- interface FindVersionsArgs {
458
- collection: string;
459
- documentId: string;
460
- tenantId?: string;
461
- limit?: number;
462
- page?: number;
463
- sort?: string;
464
- }
465
- interface BaseAdapter {
466
- init(collections: CollectionConfig[], globals: GlobalConfig[]): Promise<void>;
467
- find<T>(args: FindArgs): Promise<FindResult<T>>;
468
- findByID<T>(args: FindByIDArgs): Promise<T | null>;
469
- create<T>(args: CreateArgs): Promise<T>;
470
- update<T>(args: UpdateArgs): Promise<T>;
471
- delete<T>(args: DeleteArgs): Promise<T>;
472
- count(args: {
473
- collection: string;
474
- where?: Record<string, any>;
475
- tenantId?: string;
476
- }): Promise<number>;
477
- findOne(args: {
478
- collection: string;
479
- where: Record<string, any>;
480
- tenantId?: string;
481
- draft?: boolean;
482
- }): Promise<any>;
483
- findVersions(args: FindVersionsArgs): Promise<FindResult<VersionRecord>>;
484
- findVersionByID(args: {
485
- collection: string;
486
- versionId: string;
487
- tenantId?: string;
488
- }): Promise<VersionRecord | null>;
489
- createVersion<T = Record<string, any>>(args: CreateVersionArgs<T>): Promise<VersionRecord<T>>;
490
- deleteVersions(args: {
491
- collection: string;
492
- documentId: string;
493
- keepLatest?: number;
494
- tenantId?: string;
495
- }): Promise<void>;
496
- updateLatestVersion<T = Record<string, any>>(args: CreateVersionArgs<T>): Promise<VersionRecord<T>>;
497
- migrate?(): Promise<void>;
498
- rollback?(): Promise<void>;
499
- connect(): Promise<void>;
500
- disconnect(): Promise<void>;
501
- transaction?<T>(fn: (tx: any) => Promise<T>): Promise<T>;
502
- setTenantContext(context: TenantContext | undefined): void;
503
- getTenantContext(): TenantContext | undefined;
504
- }
505
- interface AdapterConfig {
506
- type: "drizzle" | "mongodb";
507
- client: any;
508
- schema?: any;
509
- connectionOptions?: Record<string, any>;
510
- }
511
- interface KyroConfig {
512
- collections?: CollectionConfig[];
513
- globals?: GlobalConfig[];
514
- adapter: BaseAdapter;
515
- plugins?: KyroPlugin[];
516
- auth?: boolean | {
517
- secret?: string;
518
- tokenExpiration?: number;
519
- cookie?: {
520
- secure?: boolean;
521
- sameSite?: "strict" | "lax" | "none";
522
- domain?: string;
523
- };
524
- checkSession?: boolean;
525
- };
526
- authAdapter?: any;
527
- cors?: {
528
- origins?: string[];
529
- credentials?: boolean;
530
- };
531
- admin?: {
532
- meta?: {
533
- title?: string;
534
- description?: string;
535
- ogImage?: string;
536
- };
537
- dateFormat?: string;
538
- avatar?: "default" | "gravatar";
539
- disable?: boolean;
540
- indexRoute?: string;
541
- components?: Record<string, any>;
542
- collectionOverrides?: Record<string, Partial<AdminConfig> & {
543
- fields?: FieldOverrides;
544
- }>;
545
- };
546
- upload?: {
547
- limits?: {
548
- fileSize?: number;
549
- };
550
- };
551
- graphQL?: {
552
- maxComplexity?: number;
553
- disablePlayground?: boolean;
554
- };
555
- typescript?: {
556
- outputFile?: string;
557
- };
558
- localization?: {
559
- locales: string[];
560
- defaultLocale: string;
561
- };
562
- rateLimit?: {
563
- window?: number;
564
- max?: number;
565
- };
566
- debug?: boolean;
567
- }
568
-
569
- export { type AdminConfig as A, type BaseAdapter as B, type CollectionConfig as C, type DeleteArgs as D, WishlistPlugin as E, type FindArgs as F, type GlobalConfig as G, type Hook as H, type ImageSize as I, evaluateAccess as J, type KyroConfig as K, getWhereClause as L, mergeWhereClauses as M, presetPlugins as N, runFieldHooks as O, PluginManager as P, runHooks as Q, type Request as R, SEOPlugin as S, type TenantContext as T, 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, KyroPlugin as i, type User as j, type AccessArgs as k, type AccessControl as l, type AdapterConfig as m, AnalyticsPlugin as n, type CollectionAccess as o, type CollectionHooks as p, CommentsPlugin as q, type CreateResult as r, type FieldAccess as s, type FieldHooks as t, type GlobalAccess as u, type GlobalHooks as v, type HookArgs as w, type PluginAPI as x, type PluginHooks as y, ReviewsPlugin as z };
@@ -1,150 +0,0 @@
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
- avatar?: string;
41
- tenantId?: string;
42
- emailVerified?: boolean;
43
- locked?: boolean;
44
- lastLogin?: string;
45
- failedLoginAttempts?: number;
46
- createdAt: string;
47
- updatedAt: string;
48
- }
49
- type UserRole = "super_admin" | "admin" | "editor" | "author" | "customer" | "guest";
50
- interface Session {
51
- id: string;
52
- userId: string;
53
- token: string;
54
- refreshToken?: string;
55
- expiresAt: string;
56
- createdAt: string;
57
- ipAddress?: string;
58
- userAgent?: string;
59
- }
60
- interface JWTPayload {
61
- sub: string;
62
- email: string;
63
- role: UserRole;
64
- tenantId?: string;
65
- iat?: number;
66
- exp?: number;
67
- sid?: string;
68
- }
69
- interface AuthTokenConfig {
70
- secret: string;
71
- expiresIn?: string | number;
72
- refreshExpiresIn?: string | number;
73
- issuer?: string;
74
- audience?: string[];
75
- saltRounds?: number;
76
- }
77
- interface LoginCredentials {
78
- email: string;
79
- password: string;
80
- }
81
- interface RegisterData {
82
- email: string;
83
- password: string;
84
- role?: UserRole;
85
- tenantId?: string;
86
- }
87
- interface AuthResult {
88
- success: boolean;
89
- user?: AuthUser;
90
- session?: Session;
91
- token?: string;
92
- error?: string;
93
- }
94
- interface AuthAdapter {
95
- createUser(data: {
96
- email: string;
97
- password: string;
98
- name?: string;
99
- role?: UserRole;
100
- avatar?: string;
101
- tenantId?: string;
102
- }): Promise<AuthUser>;
103
- findUserByEmail(email: string): Promise<AuthUser | null>;
104
- findUserById(id: string): Promise<AuthUser | null>;
105
- updateUser(id: string, data: Partial<AuthUser> & {
106
- password?: string;
107
- }): Promise<AuthUser | null>;
108
- deleteUser(id: string): Promise<boolean>;
109
- verifyPassword(email: string, password: string): Promise<AuthUser | null>;
110
- hashPassword(password: string): Promise<string>;
111
- createSession(userId: string, data?: {
112
- ipAddress?: string;
113
- userAgent?: string;
114
- }): Promise<Session>;
115
- findSessionByToken(token: string): Promise<Session | null>;
116
- findSessionByRefreshToken(refreshToken: string): Promise<Session | null>;
117
- deleteSession(sessionId: string): Promise<boolean>;
118
- deleteUserSessions(userId: string): Promise<number>;
119
- createEmailVerificationToken(userId: string): Promise<{
120
- token: string;
121
- expiresAt: Date;
122
- }>;
123
- verifyEmailToken(token: string): Promise<{
124
- success: boolean;
125
- userId?: string;
126
- error?: string;
127
- }>;
128
- createPasswordResetToken(email: string): Promise<{
129
- token: string;
130
- expiresAt: Date;
131
- error?: string;
132
- }>;
133
- resetPasswordWithToken(token: string, newPassword: string): Promise<{
134
- success: boolean;
135
- error?: string;
136
- }>;
137
- hasAnyUsers?(): Promise<boolean>;
138
- connect?(): Promise<void>;
139
- disconnect?(): Promise<void>;
140
- addPasswordToHistory?(userId: string, passwordHash: string): Promise<void>;
141
- getPasswordHistory?(userId: string, count?: number): Promise<string[]>;
142
- isPasswordInHistory?(password: string, userId: string, historyCount?: number): Promise<boolean>;
143
- findAuditLogs(filter: AuditLogFilter): Promise<{
144
- logs: AuditLog[];
145
- total: number;
146
- }>;
147
- createAuditLog(data: Omit<AuditLog, "id" | "timestamp">): Promise<AuditLog>;
148
- }
149
-
150
- 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, AuditLog as d, AuditLogFilter as e, AuditAction as f };