@yimingliao/cms 0.0.78 → 0.0.79

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.
@@ -0,0 +1,862 @@
1
+ import { T as TocItem, i as AdminRole, y as SingleItem, B as BaseTranslation, e as Admin, g as AdminFull, j as AdminSafe, D as DeviceInfo, h as AdminRefreshToken, p as File, b as FileFull, r as FileType, a as Folder, F as FolderFull, M as MultiItems, m as ExternalLink, o as Faq, t as Post, w as PostType, u as PostListCard, v as PostTranslation, P as PostFull, l as Alternate, S as SuccessResult, R as Result } from './types-BGsFazJr.js';
2
+ import { S as StorageService } from './types-J25u1G6t.js';
3
+ import jwt from 'jsonwebtoken';
4
+ import { BinaryLike } from 'node:crypto';
5
+ import { cookies } from 'next/headers';
6
+ import { PrismaClient } from '@prisma/client';
7
+ import zod__default, { z, ZodType } from 'zod';
8
+ import { Transporter, SentMessageInfo } from 'nodemailer';
9
+ import { Logger } from 'logry';
10
+ import { BaseTranslator, LocaleMessages } from 'intor';
11
+ import Keyv from 'keyv';
12
+ import * as zod_v4_core from 'zod/v4/core';
13
+
14
+ interface CreateJwtServiceParams {
15
+ defaultSecret: string;
16
+ issuer?: string;
17
+ audience?: string;
18
+ }
19
+ declare function createJwtService({ defaultSecret, ...options }: CreateJwtServiceParams): {
20
+ sign: ({ payload, secret, expiresIn, }: {
21
+ payload: object;
22
+ secret: string;
23
+ expiresIn: number;
24
+ }) => string;
25
+ verify: ({ token, secret, }: {
26
+ token: string;
27
+ secret: string;
28
+ }) => jwt.JwtPayload;
29
+ };
30
+
31
+ declare function createArgon2Service(): {
32
+ hash: (password: string) => Promise<string>;
33
+ verify: (digest: string, password: string) => Promise<boolean>;
34
+ };
35
+
36
+ interface CreateCryptoServiceParams {
37
+ defaultSecret: string;
38
+ }
39
+ declare function createCryptoService({ defaultSecret, }: CreateCryptoServiceParams): {
40
+ generateToken: () => string;
41
+ hash: (value: BinaryLike) => string;
42
+ hashBuffer: (value: BinaryLike) => Buffer;
43
+ encrypt: (data: string) => string;
44
+ decrypt: (data: string) => string;
45
+ sign: ({ value, expireSeconds, createdAt, }: {
46
+ value: string;
47
+ expireSeconds: number;
48
+ createdAt?: number;
49
+ }) => {
50
+ signed: string;
51
+ signature: string;
52
+ };
53
+ };
54
+
55
+ declare function createCookieService(nextCookies: () => Promise<Awaited<ReturnType<typeof cookies>>>, cryptoService: ReturnType<typeof createCryptoService>): {
56
+ set: ({ name, value, expireSeconds, }: {
57
+ name: string;
58
+ value: string;
59
+ expireSeconds: number;
60
+ }) => Promise<void>;
61
+ setSignedCookie: ({ name, value, expireSeconds, }: {
62
+ name: string;
63
+ value: string;
64
+ expireSeconds: number;
65
+ }) => Promise<void>;
66
+ get: ({ name }: {
67
+ name: string;
68
+ }) => Promise<string | undefined>;
69
+ getSignedCookie: ({ name }: {
70
+ name: string;
71
+ }) => Promise<string>;
72
+ verifySignedCookie: ({ signed }: {
73
+ signed: string | undefined;
74
+ }) => string;
75
+ delete: ({ name }: {
76
+ name: string;
77
+ }) => Promise<void>;
78
+ };
79
+
80
+ type RawCacheKey = string | Array<string | number | boolean | undefined | null>;
81
+ declare const normalizeCacheKey: (key?: RawCacheKey, delimiter?: string) => string | null;
82
+
83
+ interface CacheResultOptions<T> {
84
+ key: RawCacheKey;
85
+ ttl?: number;
86
+ load: () => Promise<T>;
87
+ }
88
+ declare function createCacheResult(cache: Keyv<unknown>, logger: Logger): <T>({ key: rawKey, ttl, load, }: CacheResultOptions<T>) => Promise<T>;
89
+
90
+ interface RateLimiterOptions {
91
+ key: RawCacheKey;
92
+ maxAttempts?: number;
93
+ timeWindow?: number;
94
+ }
95
+ declare function createIpRateLimiter({ appName, cache, headers, }: {
96
+ cache: Keyv<unknown>;
97
+ appName: string;
98
+ headers: () => Promise<Headers>;
99
+ }): ({ key: rawKey, maxAttempts, timeWindow, }: RateLimiterOptions) => Promise<boolean>;
100
+
101
+ type ExistOptions = {
102
+ table: string;
103
+ column?: string;
104
+ };
105
+ declare function createExist(prisma: PrismaClient): (value: string | number, options: ExistOptions) => Promise<boolean>;
106
+
107
+ type Scope = {
108
+ name: string;
109
+ value: string;
110
+ cast?: string;
111
+ };
112
+ type UniqueOptions = {
113
+ table: string;
114
+ column: string;
115
+ scope?: Scope[];
116
+ excludeSelf?: Scope;
117
+ };
118
+ declare function createUnique(prisma: PrismaClient): (value: string, options: UniqueOptions) => Promise<boolean>;
119
+
120
+ declare module "zod" {
121
+ interface ZodString {
122
+ unique(options: UniqueOptions): this;
123
+ exist(options: ExistOptions): this;
124
+ bcp47(): this;
125
+ ogLocale(): this;
126
+ }
127
+ interface ZodEmail {
128
+ unique(options: UniqueOptions): this;
129
+ }
130
+ }
131
+ declare function createZod({ unique, exist, }: {
132
+ unique: ReturnType<typeof createUnique>;
133
+ exist: ReturnType<typeof createExist>;
134
+ }): typeof z;
135
+
136
+ declare function createSchemas({ z, localeArray, exist, }: {
137
+ z: ReturnType<typeof createZod>;
138
+ localeArray: string[];
139
+ exist: ReturnType<typeof createExist>;
140
+ }): {
141
+ z: typeof zod__default;
142
+ text: () => zod__default.ZodString;
143
+ positiveNumber: () => zod__default.ZodPipe<zod__default.ZodTransform<number | undefined, unknown>, zod__default.ZodNumber>;
144
+ url: () => zod__default.ZodPipe<zod__default.ZodTransform<{} | null | undefined, unknown>, zod__default.ZodNullable<zod__default.ZodURL>>;
145
+ email: () => zod__default.ZodEmail;
146
+ password: () => zod__default.ZodString;
147
+ isoString: () => zod__default.ZodString;
148
+ array: <T extends ZodType>(schema: T) => zod__default.ZodPipe<zod__default.ZodArray<T>, zod__default.ZodTransform<NonNullable<zod__default.core.output<T>>[], zod__default.core.output<T>[]>>;
149
+ id: () => zod__default.ZodString;
150
+ key: () => zod__default.ZodString;
151
+ sha256Hash: () => zod__default.ZodString;
152
+ slug: () => zod__default.ZodString;
153
+ pathSegment: () => zod__default.ZodString;
154
+ locale: () => zod__default.ZodString;
155
+ singleItem: (options: ExistOptions) => zod__default.ZodNullable<zod__default.ZodObject<{
156
+ id: zod__default.ZodString;
157
+ }, zod__default.core.$strip>>;
158
+ multiItems: (options: ExistOptions) => zod__default.ZodPipe<zod__default.ZodArray<zod__default.ZodObject<{
159
+ id: zod__default.ZodString;
160
+ }, zod__default.core.$strip>>, zod__default.ZodTransform<{
161
+ id: string;
162
+ }[], {
163
+ id: string;
164
+ }[]>>;
165
+ };
166
+
167
+ declare function createTocItemSchema({ z, schemas, }: {
168
+ z: ReturnType<typeof createZod>;
169
+ schemas: ReturnType<typeof createSchemas>;
170
+ }): ZodType<TocItem, unknown, zod_v4_core.$ZodTypeInternals<TocItem, unknown>>;
171
+
172
+ interface SendEmailOptions {
173
+ to: string;
174
+ subject: string;
175
+ html: string;
176
+ }
177
+ declare function createSendEmail({ transporter, config, }: {
178
+ transporter: Transporter;
179
+ config: {
180
+ fromName: string;
181
+ fromAddress: string;
182
+ replyToName: string;
183
+ replyToaddress: string;
184
+ };
185
+ }): (options: SendEmailOptions) => Promise<SentMessageInfo>;
186
+
187
+ declare function createRenderEmailTemplate({ siteName, webUrl, logoUrl, logger, }: {
188
+ siteName: string;
189
+ webUrl: string;
190
+ logoUrl: string;
191
+ logger: Logger;
192
+ }): (templateKey: string, replacements?: Record<string, string>) => Promise<string>;
193
+
194
+ interface CreateParams$4 {
195
+ role: AdminRole;
196
+ email: string;
197
+ passwordHash: string;
198
+ socialLinks: string[];
199
+ avatarImage: SingleItem;
200
+ translations: (BaseTranslation & {
201
+ name: string | null;
202
+ authorName: string | null;
203
+ description: string | null;
204
+ jobTitle: string | null;
205
+ url: string | null;
206
+ worksFor: string | null;
207
+ knowsAbout: string[];
208
+ homeLocation: string | null;
209
+ nationality: string | null;
210
+ })[];
211
+ }
212
+ interface UpdateParams$3 {
213
+ id: string;
214
+ role: AdminRole;
215
+ email?: string;
216
+ socialLinks: string[];
217
+ avatarImage: SingleItem;
218
+ translations: (BaseTranslation & {
219
+ name: string | null;
220
+ authorName: string | null;
221
+ description: string | null;
222
+ jobTitle: string | null;
223
+ url: string | null;
224
+ worksFor: string | null;
225
+ knowsAbout: string[];
226
+ homeLocation: string | null;
227
+ nationality: string | null;
228
+ })[];
229
+ emailVerifiedAt: Date | null;
230
+ }
231
+
232
+ declare function createAdminCommandRepository(prisma: PrismaClient): {
233
+ create: ({ role, email, passwordHash, socialLinks, avatarImage, translations, }: CreateParams$4) => Promise<Admin>;
234
+ update: ({ id, role, email, socialLinks, avatarImage, translations, emailVerifiedAt, }: UpdateParams$3) => Promise<Admin>;
235
+ delete: ({ id }: {
236
+ id: string;
237
+ }) => Promise<Admin>;
238
+ };
239
+
240
+ interface FindListCardsParams$3 {
241
+ locale: string;
242
+ searchString?: string;
243
+ role?: AdminRole;
244
+ adminIds?: string[];
245
+ page?: number;
246
+ pageSize?: number;
247
+ }
248
+ interface FindParams$2 {
249
+ id?: string;
250
+ email?: string;
251
+ }
252
+
253
+ declare function createAdminQueryRepository(prisma: PrismaClient): {
254
+ findListCards: ({ locale, searchString, role, adminIds, page, pageSize, }: FindListCardsParams$3) => Promise<{
255
+ items: AdminFull[];
256
+ total: number;
257
+ }>;
258
+ find: (params: FindParams$2) => Promise<AdminSafe | null>;
259
+ findFull: (params: FindParams$2) => Promise<AdminFull | null>;
260
+ findWithPasswordHash: (params: FindParams$2) => Promise<Admin | null>;
261
+ };
262
+
263
+ interface CreateParams$3 {
264
+ tokenHash: string;
265
+ email: string;
266
+ ip: string;
267
+ deviceInfo?: DeviceInfo;
268
+ adminId: string;
269
+ expiresAt: Date;
270
+ }
271
+ interface DeleteParams {
272
+ id?: string;
273
+ tokenHash?: string;
274
+ }
275
+
276
+ declare function createAdminRefreshTokenCommandRepository(prisma: PrismaClient): {
277
+ create: ({ adminId, ...params }: CreateParams$3) => Promise<AdminRefreshToken>;
278
+ delete: ({ id, tokenHash }: DeleteParams) => Promise<void>;
279
+ deleteManyByExpired: () => Promise<number>;
280
+ };
281
+
282
+ declare function createAdminRefreshTokenQueryRepository(prisma: PrismaClient): {
283
+ findManyByAdminId: ({ adminId, }: {
284
+ adminId: string;
285
+ }) => Promise<AdminRefreshToken[]>;
286
+ findByToken: ({ tokenHash, }: {
287
+ tokenHash: string;
288
+ }) => Promise<AdminRefreshToken | null>;
289
+ };
290
+
291
+ interface CreateParams$2 {
292
+ key: string;
293
+ checksum: string;
294
+ fileMeta: {
295
+ type?: string;
296
+ size?: number;
297
+ name?: string;
298
+ };
299
+ width?: number | null;
300
+ height?: number | null;
301
+ duration?: number | null;
302
+ folder?: SingleItem;
303
+ translations: (BaseTranslation & {
304
+ name: string | null;
305
+ alt: string | null;
306
+ })[];
307
+ }
308
+ interface UpdateParams$2 {
309
+ id: string;
310
+ file: File;
311
+ key: string;
312
+ checksum: string;
313
+ fileMeta: {
314
+ type?: string;
315
+ size?: number;
316
+ name?: string;
317
+ };
318
+ width?: number | null;
319
+ height?: number | null;
320
+ duration?: number | null;
321
+ folder?: SingleItem;
322
+ translations: (BaseTranslation & {
323
+ name: string | null;
324
+ alt: string | null;
325
+ })[];
326
+ }
327
+
328
+ declare function createFileCommandRepository(prisma: PrismaClient): {
329
+ create: ({ key, checksum, fileMeta, width, height, duration, folder, translations, }: CreateParams$2) => Promise<FileFull>;
330
+ update: ({ file, id, key, checksum, fileMeta, width, height, duration, folder, translations, }: UpdateParams$2) => Promise<File>;
331
+ softDelete: ({ id }: {
332
+ id: string;
333
+ }) => Promise<File>;
334
+ softDeleteMany: ({ ids }: {
335
+ ids: string[];
336
+ }) => Promise<number>;
337
+ restoreMany: ({ ids }: {
338
+ ids: string[];
339
+ }) => Promise<number>;
340
+ delete: ({ id }: {
341
+ id: string;
342
+ }) => Promise<File>;
343
+ };
344
+
345
+ interface FindListCardsParams$2 {
346
+ locale: string;
347
+ searchString?: string;
348
+ type?: FileType | null;
349
+ isDeleted?: boolean;
350
+ isLocked?: boolean | null;
351
+ folderId?: string;
352
+ fileIds?: string[];
353
+ page?: number;
354
+ pageSize?: number;
355
+ }
356
+
357
+ declare function createFileQueryRepository(prisma: PrismaClient): {
358
+ findListCards: ({ locale, page, pageSize, searchString, type, folderId, isLocked, isDeleted, fileIds, }: FindListCardsParams$2) => Promise<{
359
+ items: FileFull[];
360
+ total: number;
361
+ }>;
362
+ findManyByIds: ({ ids, }: {
363
+ ids: string[];
364
+ }) => Promise<FileFull[]>;
365
+ findFull: ({ id }: {
366
+ id: string;
367
+ }) => Promise<FileFull | null>;
368
+ };
369
+
370
+ interface CreateParams$1 {
371
+ key: string;
372
+ name: string;
373
+ parentFolder: Folder | null;
374
+ }
375
+ interface UpdateParams$1 {
376
+ id: string;
377
+ key: string;
378
+ name: string;
379
+ parentFolder: Folder | null;
380
+ }
381
+
382
+ declare function createFolderCommandRepository(prisma: PrismaClient): {
383
+ create: ({ key, name, parentFolder, }: CreateParams$1) => Promise<Folder>;
384
+ update: ({ id, key, name, parentFolder, }: UpdateParams$1) => Promise<Folder>;
385
+ delete: ({ id }: {
386
+ id: string;
387
+ }) => Promise<Folder>;
388
+ };
389
+
390
+ interface FindListCardsParams$1 {
391
+ searchString?: string;
392
+ parentFolderId?: string;
393
+ folderIds?: string[];
394
+ page?: number;
395
+ pageSize?: number;
396
+ }
397
+ interface FindParams$1 {
398
+ id?: string;
399
+ key?: string;
400
+ }
401
+
402
+ declare function createFolderQueryRepository(prisma: PrismaClient): {
403
+ findListCards: ({ searchString, parentFolderId, folderIds, page, pageSize, }: FindListCardsParams$1) => Promise<{
404
+ items: FolderFull[];
405
+ total: number;
406
+ }>;
407
+ findFull: (params: FindParams$1) => Promise<FolderFull | null>;
408
+ };
409
+
410
+ interface CreateParams {
411
+ type: string;
412
+ isLocked: boolean;
413
+ isActive: boolean;
414
+ isIndexActive: boolean;
415
+ index: number | null;
416
+ isSlugActive: boolean;
417
+ slug: string | null;
418
+ isFeatured: boolean;
419
+ isShownOnHome: boolean;
420
+ author: SingleItem;
421
+ topicId: string | null;
422
+ parents: MultiItems;
423
+ tags: MultiItems;
424
+ relatedPosts: MultiItems;
425
+ coverImage: SingleItem;
426
+ contentImageIds: string[];
427
+ state1: boolean;
428
+ state2: boolean;
429
+ state3: boolean;
430
+ state4: boolean;
431
+ state5: boolean;
432
+ state6: boolean;
433
+ state7: boolean;
434
+ state8: boolean;
435
+ state9: boolean;
436
+ state10: boolean;
437
+ images1: MultiItems;
438
+ images2: MultiItems;
439
+ image1: SingleItem;
440
+ image2: SingleItem;
441
+ image3: SingleItem;
442
+ image4: SingleItem;
443
+ text1: string | null;
444
+ text2: string | null;
445
+ text3: string | null;
446
+ text4: string | null;
447
+ text5: string | null;
448
+ text6: string | null;
449
+ text7: string | null;
450
+ text8: string | null;
451
+ text9: string | null;
452
+ text10: string | null;
453
+ data1: any[];
454
+ data2: any[];
455
+ data3: any[];
456
+ data4: any[];
457
+ translations: (BaseTranslation & {
458
+ title: string | null;
459
+ subtitle: string | null;
460
+ summary: string | null;
461
+ description: string | null;
462
+ content: string | null;
463
+ externalLinks: ExternalLink[];
464
+ faq: Faq[];
465
+ toc: TocItem[];
466
+ readTime: number | null;
467
+ wordCount: number;
468
+ text1: string | null;
469
+ text2: string | null;
470
+ text3: string | null;
471
+ text4: string | null;
472
+ text5: string | null;
473
+ text6: string | null;
474
+ text7: string | null;
475
+ text8: string | null;
476
+ text9: string | null;
477
+ text10: string | null;
478
+ data1: any[];
479
+ data2: any[];
480
+ data3: any[];
481
+ data4: any[];
482
+ })[];
483
+ }
484
+ interface UpdateParams {
485
+ id: string;
486
+ type: string;
487
+ isLocked: boolean;
488
+ isActive: boolean;
489
+ isIndexActive: boolean;
490
+ index: number | null;
491
+ isSlugActive: boolean;
492
+ slug: string | null;
493
+ isFeatured: boolean;
494
+ isShownOnHome: boolean;
495
+ author: SingleItem;
496
+ topicId: string | null;
497
+ parents: MultiItems;
498
+ tags: MultiItems;
499
+ relatedPosts: MultiItems;
500
+ coverImage: SingleItem;
501
+ contentImageIds: string[];
502
+ state1: boolean;
503
+ state2: boolean;
504
+ state3: boolean;
505
+ state4: boolean;
506
+ state5: boolean;
507
+ state6: boolean;
508
+ state7: boolean;
509
+ state8: boolean;
510
+ state9: boolean;
511
+ state10: boolean;
512
+ images1: MultiItems;
513
+ images2: MultiItems;
514
+ image1: SingleItem;
515
+ image2: SingleItem;
516
+ image3: SingleItem;
517
+ image4: SingleItem;
518
+ text1: string | null;
519
+ text2: string | null;
520
+ text3: string | null;
521
+ text4: string | null;
522
+ text5: string | null;
523
+ text6: string | null;
524
+ text7: string | null;
525
+ text8: string | null;
526
+ text9: string | null;
527
+ text10: string | null;
528
+ data1: any[];
529
+ data2: any[];
530
+ data3: any[];
531
+ data4: any[];
532
+ translations: (BaseTranslation & {
533
+ title: string | null;
534
+ subtitle: string | null;
535
+ summary: string | null;
536
+ description: string | null;
537
+ content: string | null;
538
+ externalLinks: ExternalLink[];
539
+ faq: Faq[];
540
+ toc: TocItem[];
541
+ readTime: number | null;
542
+ wordCount: number;
543
+ text1: string | null;
544
+ text2: string | null;
545
+ text3: string | null;
546
+ text4: string | null;
547
+ text5: string | null;
548
+ text6: string | null;
549
+ text7: string | null;
550
+ text8: string | null;
551
+ text9: string | null;
552
+ text10: string | null;
553
+ data1: any[];
554
+ data2: any[];
555
+ data3: any[];
556
+ data4: any[];
557
+ })[];
558
+ }
559
+
560
+ declare function createPostCommandRepository(prisma: PrismaClient): {
561
+ create: ({ slug, type, author, topicId, parents, tags, relatedPosts, coverImage, contentImageIds, images1, images2, image1, image2, image3, image4, translations, ...params }: CreateParams) => Promise<Post>;
562
+ update: ({ id, slug, type, author, topicId, parents, tags, relatedPosts, coverImage, contentImageIds, images1, images2, image1, image2, image3, image4, translations, ...params }: UpdateParams) => Promise<Post>;
563
+ delete: ({ id }: {
564
+ id: string;
565
+ }) => Promise<Post>;
566
+ };
567
+
568
+ interface FindListCardsParams {
569
+ locale: string;
570
+ searchString?: string;
571
+ type: PostType | null;
572
+ isActive?: boolean;
573
+ isIndexActive?: boolean;
574
+ isSlugActive?: boolean;
575
+ isFeatured?: boolean;
576
+ isShownOnHome?: boolean;
577
+ state1?: boolean;
578
+ state2?: boolean;
579
+ state3?: boolean;
580
+ state4?: boolean;
581
+ state5?: boolean;
582
+ state6?: boolean;
583
+ state7?: boolean;
584
+ state8?: boolean;
585
+ state9?: boolean;
586
+ state10?: boolean;
587
+ topicId?: string;
588
+ topicSlug?: string;
589
+ categoryId?: string;
590
+ categorySlug?: string;
591
+ postIds?: string[];
592
+ excludeIds?: string[];
593
+ page?: number;
594
+ pageSize?: number;
595
+ }
596
+ interface FindParams {
597
+ id?: string;
598
+ type?: PostType;
599
+ slug?: string;
600
+ isActive?: boolean;
601
+ topicSlug?: string;
602
+ }
603
+ interface FindManyParams {
604
+ type: PostType;
605
+ topicId?: string;
606
+ }
607
+
608
+ declare function createPostQueryRepository(prisma: PrismaClient): {
609
+ findListCards: ({ locale, searchString, type, isActive, isIndexActive, isSlugActive, isFeatured, isShownOnHome, state1, state2, state3, state4, state5, state6, state7, state8, state9, state10, topicId, topicSlug, categoryId, categorySlug, postIds, excludeIds, page, pageSize, }: FindListCardsParams) => Promise<{
610
+ items: PostListCard[];
611
+ total: number;
612
+ }>;
613
+ findMany: ({ type, topicId, }: FindManyParams) => Promise<(Post & {
614
+ translations: PostTranslation[];
615
+ })[]>;
616
+ find: ({ isActive, ...rest }: FindParams) => Promise<(Post & {
617
+ translations: PostTranslation[];
618
+ }) | null>;
619
+ findFull: ({ isActive, topicSlug, ...rest }: FindParams) => Promise<{
620
+ post: PostFull | undefined;
621
+ prev: PostListCard | undefined;
622
+ next: PostListCard | undefined;
623
+ }>;
624
+ };
625
+
626
+ interface UpsertParams {
627
+ postId: string;
628
+ translations: (BaseTranslation & {
629
+ title: string | null;
630
+ description: string | null;
631
+ author: string | null;
632
+ canonical: string | null;
633
+ alternate: Alternate[];
634
+ robots: string | null;
635
+ ogTitle: string | null;
636
+ ogDescription: string | null;
637
+ ogUrl: string | null;
638
+ ogType: string | null;
639
+ ogSiteName: string | null;
640
+ ogImage: string | null;
641
+ ogImageAlt: string | null;
642
+ ogImageType: string | null;
643
+ ogImageWidth: number | null;
644
+ ogImageHeight: number | null;
645
+ ogLocale: string | null;
646
+ ogLocaleAlternate: string[];
647
+ ogArticlePublishedTime: string | null;
648
+ ogArticleModifiedTime: string | null;
649
+ ogArticleAuthor: string | null;
650
+ ogArticleSection: string | null;
651
+ ogArticleTag: string[];
652
+ twitterCard: string | null;
653
+ twitterSite: string | null;
654
+ twitterCreator: string | null;
655
+ jsonLd: object[];
656
+ })[];
657
+ }
658
+
659
+ declare function createSeoMetadataCommandRepository(prisma: PrismaClient): {
660
+ upsert: ({ postId, translations, }: UpsertParams) => Promise<void>;
661
+ };
662
+
663
+ type Action<D> = (translator: BaseTranslator<LocaleMessages>) => Promise<Omit<SuccessResult<D>, "success"> & {
664
+ i18nKey?: string;
665
+ }>;
666
+ interface CreateExecuteActionParams {
667
+ initI18n: () => Promise<BaseTranslator<LocaleMessages>>;
668
+ cacheResult: <T>({ key, ttl, load }: CacheResultOptions<T>) => Promise<T>;
669
+ cache: Keyv<unknown>;
670
+ logger: Logger;
671
+ }
672
+ interface ServerActionParams {
673
+ type?: "command" | "query";
674
+ key?: RawCacheKey;
675
+ ttl?: number;
676
+ }
677
+ declare function createExecuteAction({ initI18n, cacheResult, cache, logger, }: CreateExecuteActionParams): <D = void>(fn: Action<D>, options?: ServerActionParams) => Promise<Result<D>>;
678
+
679
+ interface CreateVerifyAccessTokenParams {
680
+ adminQueryRepository: ReturnType<typeof createAdminQueryRepository>;
681
+ jwtService: ReturnType<typeof createJwtService>;
682
+ cryptoService: ReturnType<typeof createCryptoService>;
683
+ cookieService: ReturnType<typeof createCookieService>;
684
+ config: {
685
+ accessTokenName: string;
686
+ accessTokenSecret: string;
687
+ };
688
+ }
689
+ declare function createVerifyAccessToken({ adminQueryRepository, jwtService, cryptoService, cookieService, config, }: CreateVerifyAccessTokenParams): () => Promise<{
690
+ admin: AdminFull;
691
+ } | null>;
692
+
693
+ interface CreateVerifyRefreshTokenParams {
694
+ adminQueryRepository: ReturnType<typeof createAdminQueryRepository>;
695
+ adminRefreshTokenQueryRepository: ReturnType<typeof createAdminRefreshTokenQueryRepository>;
696
+ cryptoService: ReturnType<typeof createCryptoService>;
697
+ cookieService: ReturnType<typeof createCookieService>;
698
+ config: {
699
+ refreshTokenName: string;
700
+ };
701
+ }
702
+ declare function createVerifyRefreshToken({ adminQueryRepository, adminRefreshTokenQueryRepository, cryptoService, cookieService, config, }: CreateVerifyRefreshTokenParams): () => Promise<{
703
+ adminRefreshToken: AdminRefreshToken;
704
+ admin: AdminFull;
705
+ } | null>;
706
+
707
+ interface CreateAuthUseCases {
708
+ prisma: PrismaClient;
709
+ adminQueryRepository: ReturnType<typeof createAdminQueryRepository>;
710
+ adminRefreshTokenCommandRepository: ReturnType<typeof createAdminRefreshTokenCommandRepository>;
711
+ jwtService: ReturnType<typeof createJwtService>;
712
+ argon2Service: ReturnType<typeof createArgon2Service>;
713
+ cryptoService: ReturnType<typeof createCryptoService>;
714
+ cookieService: ReturnType<typeof createCookieService>;
715
+ config: {
716
+ refreshTokenName: string;
717
+ refreshTokenTtl: number;
718
+ accessTokenName: string;
719
+ accessTokenSecret: string;
720
+ accessTokenTtl: number;
721
+ resetPasswordSecret: string;
722
+ resetPasswordTtl: number;
723
+ verifyEmailSecret: string;
724
+ verifyEmailTtl: number;
725
+ };
726
+ }
727
+ declare function createAuthUseCases({ prisma, adminQueryRepository, adminRefreshTokenCommandRepository, jwtService, argon2Service, cryptoService, cookieService, config, }: CreateAuthUseCases): {
728
+ verifyCredentials: ({ email, password, }: {
729
+ email: string;
730
+ password: string;
731
+ }) => Promise<Admin>;
732
+ updatePassword: ({ email, password, }: {
733
+ email: string;
734
+ password: string;
735
+ }) => Promise<Admin>;
736
+ createRefreshToken: ({ admin, deviceInfo, ip, }: {
737
+ admin: {
738
+ id: string;
739
+ email: string;
740
+ };
741
+ deviceInfo: DeviceInfo;
742
+ ip: string;
743
+ }) => Promise<string>;
744
+ refreshTokens: ({ admin, deviceInfo, ip, }: {
745
+ admin: {
746
+ id: string;
747
+ email: string;
748
+ };
749
+ deviceInfo: DeviceInfo;
750
+ ip: string;
751
+ }) => Promise<void>;
752
+ signPasswordResetToken: ({ admin }: {
753
+ admin: AdminSafe;
754
+ }) => string;
755
+ verifyPasswordResetToken: ({ token }: {
756
+ token: string;
757
+ }) => {
758
+ email: string;
759
+ };
760
+ signEmailVerificationToken: () => string;
761
+ verifyEmailAndUpdate: ({ token, admin, }: {
762
+ token: string;
763
+ admin: AdminSafe;
764
+ }) => Promise<AdminSafe>;
765
+ };
766
+
767
+ interface SendParams$1 {
768
+ translator: BaseTranslator<LocaleMessages>;
769
+ admin: AdminSafe;
770
+ newEmail?: string;
771
+ }
772
+ declare function createEmailVerificationEmail({ renderEmailTemplate, sendEmail, authUseCases, webUrl, }: {
773
+ renderEmailTemplate: ReturnType<typeof createRenderEmailTemplate>;
774
+ sendEmail: ReturnType<typeof createSendEmail>;
775
+ authUseCases: ReturnType<typeof createAuthUseCases>;
776
+ webUrl: string;
777
+ }): {
778
+ generateHtml: (replacements?: {
779
+ emailVerificationUrl: string;
780
+ }) => Promise<string>;
781
+ send: ({ translator, admin, newEmail }: SendParams$1) => Promise<any>;
782
+ };
783
+
784
+ interface SendParams {
785
+ translator: BaseTranslator<LocaleMessages>;
786
+ admin: AdminSafe;
787
+ }
788
+ declare function createForgotPasswordEmail({ renderEmailTemplate, sendEmail, authUseCases, webUrl, }: {
789
+ renderEmailTemplate: ReturnType<typeof createRenderEmailTemplate>;
790
+ sendEmail: ReturnType<typeof createSendEmail>;
791
+ authUseCases: ReturnType<typeof createAuthUseCases>;
792
+ webUrl: string;
793
+ }): {
794
+ generateHtml: (replacements?: {
795
+ passwordResetUrl: string;
796
+ }) => Promise<string>;
797
+ send: ({ translator, admin }: SendParams) => Promise<any>;
798
+ };
799
+
800
+ interface CreateAuthMiddlewareParams {
801
+ adminRefreshTokenCommandRepository: ReturnType<typeof createAdminRefreshTokenCommandRepository>;
802
+ authUseCases: ReturnType<typeof createAuthUseCases>;
803
+ verifyAccessToken: ReturnType<typeof createVerifyAccessToken>;
804
+ verifyRefreshToken: ReturnType<typeof createVerifyRefreshToken>;
805
+ headers: () => Promise<Headers>;
806
+ }
807
+ declare function createAuthMiddleware({ adminRefreshTokenCommandRepository, authUseCases, verifyAccessToken, verifyRefreshToken, headers, }: CreateAuthMiddlewareParams): {
808
+ authenticate(): Promise<AdminFull>;
809
+ };
810
+
811
+ interface ActionContext {
812
+ services: {
813
+ cryptoService: ReturnType<typeof createCryptoService>;
814
+ argon2Service: ReturnType<typeof createArgon2Service>;
815
+ cookieService: ReturnType<typeof createCookieService>;
816
+ storageService: StorageService;
817
+ };
818
+ repositories: {
819
+ adminQueryRepository: ReturnType<typeof createAdminQueryRepository>;
820
+ adminCommandRepository: ReturnType<typeof createAdminCommandRepository>;
821
+ adminRefreshTokenQueryRepository: ReturnType<typeof createAdminRefreshTokenQueryRepository>;
822
+ adminRefreshTokenCommandRepository: ReturnType<typeof createAdminRefreshTokenCommandRepository>;
823
+ folderQueryRepository: ReturnType<typeof createFolderQueryRepository>;
824
+ folderCommandRepository: ReturnType<typeof createFolderCommandRepository>;
825
+ fileQueryRepository: ReturnType<typeof createFileQueryRepository>;
826
+ fileCommandRepository: ReturnType<typeof createFileCommandRepository>;
827
+ postCommandRepository: ReturnType<typeof createPostCommandRepository>;
828
+ postQueryRepository: ReturnType<typeof createPostQueryRepository>;
829
+ seoMetadataCommandRepository: ReturnType<typeof createSeoMetadataCommandRepository>;
830
+ };
831
+ useCases: {
832
+ authUseCases: ReturnType<typeof createAuthUseCases>;
833
+ };
834
+ middlewares: {
835
+ authMiddleware: ReturnType<typeof createAuthMiddleware>;
836
+ };
837
+ action: {
838
+ executeAction: ReturnType<typeof createExecuteAction>;
839
+ ipRateLimiter: (options: RateLimiterOptions) => Promise<void>;
840
+ };
841
+ emails: {
842
+ emailVerificationEmail: ReturnType<typeof createEmailVerificationEmail>;
843
+ forgotPasswordEmail: ReturnType<typeof createForgotPasswordEmail>;
844
+ };
845
+ http: {
846
+ headers: () => Promise<Headers>;
847
+ };
848
+ schemas: {
849
+ schemas: ReturnType<typeof createSchemas>;
850
+ tocItemSchema: ReturnType<typeof createTocItemSchema>;
851
+ };
852
+ config: {
853
+ accessTokenName: string;
854
+ refreshTokenName: string;
855
+ };
856
+ }
857
+
858
+ declare function createVerifyAction(ctx: ActionContext): () => Promise<Result<{
859
+ admin: AdminFull;
860
+ }>>;
861
+
862
+ export { type ActionContext as A, createRenderEmailTemplate as B, createSendEmail as C, createSeoMetadataCommandRepository as D, createUnique as E, createVerifyAccessToken as F, createVerifyRefreshToken as G, normalizeCacheKey as H, type RawCacheKey as R, createZod as a, createSchemas as b, createVerifyAction as c, createTocItemSchema as d, createAdminCommandRepository as e, createAdminQueryRepository as f, createAdminRefreshTokenCommandRepository as g, createAdminRefreshTokenQueryRepository as h, createArgon2Service as i, createAuthMiddleware as j, createAuthUseCases as k, createCacheResult as l, createCookieService as m, createCryptoService as n, createEmailVerificationEmail as o, createExecuteAction as p, createExist as q, createFileCommandRepository as r, createFileQueryRepository as s, createFolderCommandRepository as t, createFolderQueryRepository as u, createForgotPasswordEmail as v, createIpRateLimiter as w, createJwtService as x, createPostCommandRepository as y, createPostQueryRepository as z };