@yimingliao/cms 0.0.53 → 0.0.55
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/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ADMIN_ROLES, ROOT_FOLDER_ID } from '../chunk-
|
|
1
|
+
import { ADMIN_ROLES, isFileLocked, ROOT_FOLDER_ID } from '../chunk-FUAJWL2N.js';
|
|
2
2
|
import { SIZE, result, mimeToExtension, classifyFileType } from '../chunk-YAUBKQVA.js';
|
|
3
3
|
import jwt from 'jsonwebtoken';
|
|
4
4
|
import argon2 from 'argon2';
|
|
@@ -721,6 +721,12 @@ function updateMany(items) {
|
|
|
721
721
|
// src/server/infrastructure/database/admin/command/create-admin-command-repository.ts
|
|
722
722
|
function createAdminCommandRepository(prisma) {
|
|
723
723
|
async function create({
|
|
724
|
+
// core
|
|
725
|
+
role,
|
|
726
|
+
email,
|
|
727
|
+
passwordHash,
|
|
728
|
+
// better seo
|
|
729
|
+
socialLinks,
|
|
724
730
|
// ------------------------------------
|
|
725
731
|
// relations
|
|
726
732
|
// ------------------------------------
|
|
@@ -729,13 +735,16 @@ function createAdminCommandRepository(prisma) {
|
|
|
729
735
|
// ------------------------------------
|
|
730
736
|
// translation
|
|
731
737
|
// ------------------------------------
|
|
732
|
-
translations
|
|
733
|
-
// rest
|
|
734
|
-
...params
|
|
738
|
+
translations
|
|
735
739
|
}) {
|
|
736
740
|
const created = await prisma.admin.create({
|
|
737
741
|
data: {
|
|
738
|
-
|
|
742
|
+
// core
|
|
743
|
+
role,
|
|
744
|
+
email,
|
|
745
|
+
passwordHash,
|
|
746
|
+
// better seo
|
|
747
|
+
socialLinks,
|
|
739
748
|
// ------------------------------------------------------------------------
|
|
740
749
|
// relations
|
|
741
750
|
// ------------------------------------------------------------------------
|
|
@@ -751,6 +760,11 @@ function createAdminCommandRepository(prisma) {
|
|
|
751
760
|
}
|
|
752
761
|
async function update({
|
|
753
762
|
id,
|
|
763
|
+
// core
|
|
764
|
+
role,
|
|
765
|
+
email,
|
|
766
|
+
// better seo
|
|
767
|
+
socialLinks,
|
|
754
768
|
// ------------------------------------
|
|
755
769
|
// relations
|
|
756
770
|
// ------------------------------------
|
|
@@ -760,13 +774,19 @@ function createAdminCommandRepository(prisma) {
|
|
|
760
774
|
// translation
|
|
761
775
|
// ------------------------------------
|
|
762
776
|
translations,
|
|
763
|
-
//
|
|
764
|
-
|
|
777
|
+
// ------------------------------------
|
|
778
|
+
// timestamps
|
|
779
|
+
// ------------------------------------
|
|
780
|
+
emailVerifiedAt
|
|
765
781
|
}) {
|
|
766
782
|
const updated = await prisma.admin.update({
|
|
767
783
|
where: { id },
|
|
768
784
|
data: {
|
|
769
|
-
|
|
785
|
+
// core
|
|
786
|
+
role,
|
|
787
|
+
...email !== void 0 ? { email } : {},
|
|
788
|
+
// better seo
|
|
789
|
+
socialLinks,
|
|
770
790
|
// ------------------------------------------------------------------------
|
|
771
791
|
// relations
|
|
772
792
|
// ------------------------------------------------------------------------
|
|
@@ -781,7 +801,11 @@ function createAdminCommandRepository(prisma) {
|
|
|
781
801
|
update: t,
|
|
782
802
|
create: t
|
|
783
803
|
}))
|
|
784
|
-
}
|
|
804
|
+
},
|
|
805
|
+
// ------------------------------------------------------------------------
|
|
806
|
+
// timestamps
|
|
807
|
+
// ------------------------------------------------------------------------
|
|
808
|
+
emailVerifiedAt
|
|
785
809
|
}
|
|
786
810
|
});
|
|
787
811
|
return updated;
|
|
@@ -1041,8 +1065,15 @@ var FILE_FULL_INCLUDE = {
|
|
|
1041
1065
|
// src/server/infrastructure/database/file/command/create-file-command-repository.ts
|
|
1042
1066
|
function createFileCommandRepository(prisma) {
|
|
1043
1067
|
async function create({
|
|
1068
|
+
// core
|
|
1069
|
+
key,
|
|
1070
|
+
checksum,
|
|
1044
1071
|
// meta
|
|
1045
1072
|
fileMeta,
|
|
1073
|
+
// media info
|
|
1074
|
+
width,
|
|
1075
|
+
height,
|
|
1076
|
+
duration,
|
|
1046
1077
|
// ------------------------------------
|
|
1047
1078
|
// relations
|
|
1048
1079
|
// ------------------------------------
|
|
@@ -1051,14 +1082,18 @@ function createFileCommandRepository(prisma) {
|
|
|
1051
1082
|
// ------------------------------------
|
|
1052
1083
|
// translation
|
|
1053
1084
|
// ------------------------------------
|
|
1054
|
-
translations
|
|
1055
|
-
// rest
|
|
1056
|
-
...params
|
|
1085
|
+
translations
|
|
1057
1086
|
}) {
|
|
1058
1087
|
const extension = mimeToExtension(fileMeta.type);
|
|
1059
1088
|
const created = await prisma.file.create({
|
|
1060
1089
|
data: {
|
|
1061
|
-
|
|
1090
|
+
// core
|
|
1091
|
+
key,
|
|
1092
|
+
checksum,
|
|
1093
|
+
// media info
|
|
1094
|
+
...width !== void 0 ? { width } : {},
|
|
1095
|
+
...height !== void 0 ? { height } : {},
|
|
1096
|
+
...duration !== void 0 ? { duration } : {},
|
|
1062
1097
|
// derived
|
|
1063
1098
|
originalName: fileMeta.name || "unknown",
|
|
1064
1099
|
size: fileMeta.size ?? 0,
|
|
@@ -1088,8 +1123,15 @@ function createFileCommandRepository(prisma) {
|
|
|
1088
1123
|
file,
|
|
1089
1124
|
// Original file (File)
|
|
1090
1125
|
id,
|
|
1126
|
+
// core
|
|
1127
|
+
key,
|
|
1128
|
+
checksum,
|
|
1091
1129
|
// meta
|
|
1092
1130
|
fileMeta,
|
|
1131
|
+
// media info
|
|
1132
|
+
width,
|
|
1133
|
+
height,
|
|
1134
|
+
duration,
|
|
1093
1135
|
// ------------------------------------
|
|
1094
1136
|
// relations
|
|
1095
1137
|
// ------------------------------------
|
|
@@ -1098,15 +1140,19 @@ function createFileCommandRepository(prisma) {
|
|
|
1098
1140
|
// ------------------------------------
|
|
1099
1141
|
// translation
|
|
1100
1142
|
// ------------------------------------
|
|
1101
|
-
translations
|
|
1102
|
-
// rest
|
|
1103
|
-
...params
|
|
1143
|
+
translations
|
|
1104
1144
|
}) {
|
|
1105
1145
|
const extension = mimeToExtension(fileMeta.type);
|
|
1106
1146
|
const updated = await prisma.file.update({
|
|
1107
1147
|
where: { id: file.id },
|
|
1108
1148
|
data: {
|
|
1109
|
-
|
|
1149
|
+
// core
|
|
1150
|
+
key,
|
|
1151
|
+
checksum,
|
|
1152
|
+
// media info
|
|
1153
|
+
...width !== void 0 ? { width } : {},
|
|
1154
|
+
...height !== void 0 ? { height } : {},
|
|
1155
|
+
...duration !== void 0 ? { duration } : {},
|
|
1110
1156
|
// derived
|
|
1111
1157
|
size: fileMeta.size ?? file.size,
|
|
1112
1158
|
extension: fileMeta ? extension : file.extension,
|
|
@@ -2310,6 +2356,815 @@ function createResetPasswordAction(ctx) {
|
|
|
2310
2356
|
};
|
|
2311
2357
|
}
|
|
2312
2358
|
|
|
2359
|
+
// src/server/interfaces/actions/resources/admin/commands/create/admin-create-validator.ts
|
|
2360
|
+
var adminCreateValidator = (schemas) => schemas.z.object({
|
|
2361
|
+
// core
|
|
2362
|
+
role: schemas.z.enum(Object.values(ADMIN_ROLES)),
|
|
2363
|
+
email: schemas.email().unique({ table: "admins", column: "email" }),
|
|
2364
|
+
password: schemas.password(),
|
|
2365
|
+
// better seo
|
|
2366
|
+
socialLinks: schemas.array(schemas.url()),
|
|
2367
|
+
// ----------------------------------------------------------------------------
|
|
2368
|
+
// relations
|
|
2369
|
+
// ----------------------------------------------------------------------------
|
|
2370
|
+
// File
|
|
2371
|
+
avatarImage: schemas.z.object({ id: schemas.id().exist({ table: "files" }) }).nullable(),
|
|
2372
|
+
// ----------------------------------------------------------------------------
|
|
2373
|
+
// translation
|
|
2374
|
+
// ----------------------------------------------------------------------------
|
|
2375
|
+
translations: schemas.array(
|
|
2376
|
+
schemas.z.object({
|
|
2377
|
+
// core
|
|
2378
|
+
locale: schemas.locale(),
|
|
2379
|
+
// text
|
|
2380
|
+
name: schemas.text().nullable(),
|
|
2381
|
+
// better seo
|
|
2382
|
+
authorName: schemas.text().nullable(),
|
|
2383
|
+
description: schemas.text().nullable(),
|
|
2384
|
+
jobTitle: schemas.text().nullable(),
|
|
2385
|
+
url: schemas.url().nullable(),
|
|
2386
|
+
worksFor: schemas.text().nullable(),
|
|
2387
|
+
knowsAbout: schemas.array(schemas.text()),
|
|
2388
|
+
homeLocation: schemas.text().nullable(),
|
|
2389
|
+
nationality: schemas.text().nullable()
|
|
2390
|
+
})
|
|
2391
|
+
)
|
|
2392
|
+
});
|
|
2393
|
+
|
|
2394
|
+
// src/server/interfaces/actions/resources/admin/commands/create/create-admin-create-action.ts
|
|
2395
|
+
function createAdminCreateAction(ctx) {
|
|
2396
|
+
const {
|
|
2397
|
+
services: { argon2Service },
|
|
2398
|
+
repositories: { adminCommandRepository },
|
|
2399
|
+
middlewares: { authMiddleware },
|
|
2400
|
+
action: { executeAction },
|
|
2401
|
+
emails: { emailVerificationEmail },
|
|
2402
|
+
schemas
|
|
2403
|
+
} = ctx;
|
|
2404
|
+
return async function adminCreateAction({
|
|
2405
|
+
formData
|
|
2406
|
+
}) {
|
|
2407
|
+
return executeAction(
|
|
2408
|
+
async (translator) => {
|
|
2409
|
+
await authMiddleware.authenticate();
|
|
2410
|
+
const {
|
|
2411
|
+
role,
|
|
2412
|
+
email,
|
|
2413
|
+
password,
|
|
2414
|
+
socialLinks,
|
|
2415
|
+
avatarImage,
|
|
2416
|
+
translations
|
|
2417
|
+
} = await adminCreateValidator(schemas).parseAsync(formData);
|
|
2418
|
+
const passwordHash = await argon2Service.hash(password);
|
|
2419
|
+
const created = await adminCommandRepository.create({
|
|
2420
|
+
role,
|
|
2421
|
+
email,
|
|
2422
|
+
passwordHash,
|
|
2423
|
+
socialLinks,
|
|
2424
|
+
avatarImage,
|
|
2425
|
+
translations
|
|
2426
|
+
});
|
|
2427
|
+
void emailVerificationEmail.send({ translator, admin: created });
|
|
2428
|
+
return {
|
|
2429
|
+
i18nKey: "ok.admins-store-ok",
|
|
2430
|
+
data: { admin: created }
|
|
2431
|
+
};
|
|
2432
|
+
},
|
|
2433
|
+
{ type: "command" }
|
|
2434
|
+
);
|
|
2435
|
+
};
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
// src/server/interfaces/actions/resources/admin/commands/update/admin-update-validator.ts
|
|
2439
|
+
var adminUpdateValidator = (schemas, id) => schemas.z.object({
|
|
2440
|
+
// core
|
|
2441
|
+
role: schemas.z.enum(Object.values(ADMIN_ROLES)),
|
|
2442
|
+
email: schemas.email().unique({
|
|
2443
|
+
table: "admins",
|
|
2444
|
+
column: "email",
|
|
2445
|
+
excludeSelf: { name: "id", value: id }
|
|
2446
|
+
}).optional(),
|
|
2447
|
+
// better seo
|
|
2448
|
+
socialLinks: schemas.array(schemas.url()),
|
|
2449
|
+
// ----------------------------------------------------------------------------
|
|
2450
|
+
// relations
|
|
2451
|
+
// ----------------------------------------------------------------------------
|
|
2452
|
+
// File
|
|
2453
|
+
avatarImage: schemas.z.object({ id: schemas.id().exist({ table: "files" }) }).nullable(),
|
|
2454
|
+
// ----------------------------------------------------------------------------
|
|
2455
|
+
// translation
|
|
2456
|
+
// ----------------------------------------------------------------------------
|
|
2457
|
+
translations: schemas.array(
|
|
2458
|
+
schemas.z.object({
|
|
2459
|
+
// core
|
|
2460
|
+
locale: schemas.locale(),
|
|
2461
|
+
// text
|
|
2462
|
+
name: schemas.text().nullable(),
|
|
2463
|
+
// better seo
|
|
2464
|
+
authorName: schemas.text().nullable(),
|
|
2465
|
+
description: schemas.text().nullable(),
|
|
2466
|
+
jobTitle: schemas.text().nullable(),
|
|
2467
|
+
url: schemas.url().nullable(),
|
|
2468
|
+
worksFor: schemas.text().nullable(),
|
|
2469
|
+
knowsAbout: schemas.array(schemas.text()),
|
|
2470
|
+
homeLocation: schemas.text().nullable(),
|
|
2471
|
+
nationality: schemas.text().nullable()
|
|
2472
|
+
})
|
|
2473
|
+
)
|
|
2474
|
+
});
|
|
2475
|
+
|
|
2476
|
+
// src/server/interfaces/actions/resources/admin/commands/update/create-admin-update-action.ts
|
|
2477
|
+
function createAdminUpdateAction(ctx) {
|
|
2478
|
+
const {
|
|
2479
|
+
repositories: { adminQueryRepository, adminCommandRepository },
|
|
2480
|
+
middlewares: { authMiddleware },
|
|
2481
|
+
action: { executeAction },
|
|
2482
|
+
emails: { emailVerificationEmail },
|
|
2483
|
+
schemas
|
|
2484
|
+
} = ctx;
|
|
2485
|
+
return async function adminUpdateAction({
|
|
2486
|
+
id,
|
|
2487
|
+
formData
|
|
2488
|
+
}) {
|
|
2489
|
+
return executeAction(
|
|
2490
|
+
async (translator) => {
|
|
2491
|
+
const currentAdmin = await authMiddleware.authenticate();
|
|
2492
|
+
const targetAdmin = await adminQueryRepository.findFull({ id });
|
|
2493
|
+
if (!targetAdmin) throw ServerError.notFound();
|
|
2494
|
+
const isSelf = currentAdmin.id === targetAdmin.id;
|
|
2495
|
+
const canModifyOthers = currentAdmin.role === ADMIN_ROLES.SUPER_ADMIN;
|
|
2496
|
+
if (!isSelf && !canModifyOthers) throw ServerError.forbidden();
|
|
2497
|
+
const { role, email, socialLinks, avatarImage, translations } = await adminUpdateValidator(schemas, targetAdmin.id).parseAsync(
|
|
2498
|
+
formData
|
|
2499
|
+
);
|
|
2500
|
+
const isUpdatingEmail = email !== targetAdmin.email;
|
|
2501
|
+
if (isUpdatingEmail) {
|
|
2502
|
+
void emailVerificationEmail.send({
|
|
2503
|
+
translator,
|
|
2504
|
+
admin: targetAdmin,
|
|
2505
|
+
...email ? { newEmail: email } : {}
|
|
2506
|
+
});
|
|
2507
|
+
}
|
|
2508
|
+
const updatedAdmin = await adminCommandRepository.update({
|
|
2509
|
+
id: targetAdmin.id,
|
|
2510
|
+
role,
|
|
2511
|
+
...email !== void 0 ? { email } : {},
|
|
2512
|
+
socialLinks,
|
|
2513
|
+
avatarImage,
|
|
2514
|
+
translations,
|
|
2515
|
+
emailVerifiedAt: !isUpdatingEmail ? targetAdmin.emailVerifiedAt : null
|
|
2516
|
+
// Clear emailVerifiedAt if updating a new email
|
|
2517
|
+
});
|
|
2518
|
+
return {
|
|
2519
|
+
i18nKey: !isUpdatingEmail ? "ok.update-ok" : "ok.admins-update-email-ok",
|
|
2520
|
+
data: { admin: updatedAdmin }
|
|
2521
|
+
};
|
|
2522
|
+
},
|
|
2523
|
+
{ type: "command" }
|
|
2524
|
+
);
|
|
2525
|
+
};
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
// src/server/interfaces/actions/resources/admin/commands/delete/create-admin-delete-action.ts
|
|
2529
|
+
function createAdminDeleteAction(ctx) {
|
|
2530
|
+
const {
|
|
2531
|
+
repositories: { adminQueryRepository, adminCommandRepository },
|
|
2532
|
+
middlewares: { authMiddleware },
|
|
2533
|
+
action: { executeAction }
|
|
2534
|
+
} = ctx;
|
|
2535
|
+
return async function adminDeleteAction({ targetId }) {
|
|
2536
|
+
return executeAction(
|
|
2537
|
+
async () => {
|
|
2538
|
+
await authMiddleware.authenticate();
|
|
2539
|
+
const targetAdmin = await adminQueryRepository.findFull({
|
|
2540
|
+
id: targetId
|
|
2541
|
+
});
|
|
2542
|
+
if (!targetAdmin) throw ServerError.notFound();
|
|
2543
|
+
if (targetAdmin.role === ADMIN_ROLES.SUPER_ADMIN) {
|
|
2544
|
+
throw new ServerError({ i18nKey: "error.admins-destroy-forbidden" });
|
|
2545
|
+
}
|
|
2546
|
+
await adminCommandRepository.delete({ id: targetId });
|
|
2547
|
+
return {
|
|
2548
|
+
i18nKey: "ok.destroy-ok"
|
|
2549
|
+
};
|
|
2550
|
+
},
|
|
2551
|
+
{ type: "command" }
|
|
2552
|
+
);
|
|
2553
|
+
};
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2556
|
+
// src/server/interfaces/actions/resources/admin/queries/create-admin-find-full-action.ts
|
|
2557
|
+
function createAdminFindFullAction(ctx) {
|
|
2558
|
+
const {
|
|
2559
|
+
repositories: { adminQueryRepository },
|
|
2560
|
+
action: { executeAction }
|
|
2561
|
+
} = ctx;
|
|
2562
|
+
return async function adminFindFullAction(params) {
|
|
2563
|
+
return executeAction(
|
|
2564
|
+
async () => {
|
|
2565
|
+
const admin = await adminQueryRepository.findFull(params);
|
|
2566
|
+
if (!admin) throw ServerError.notFound();
|
|
2567
|
+
return {
|
|
2568
|
+
data: { admin }
|
|
2569
|
+
};
|
|
2570
|
+
},
|
|
2571
|
+
{
|
|
2572
|
+
type: "query",
|
|
2573
|
+
key: ["admin", "findFullAction", params.id, params.email]
|
|
2574
|
+
}
|
|
2575
|
+
);
|
|
2576
|
+
};
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
// src/server/interfaces/actions/resources/admin/queries/create-admin-find-list-cards-action.ts
|
|
2580
|
+
function createAdminFindListCardsAction(ctx) {
|
|
2581
|
+
const {
|
|
2582
|
+
repositories: { adminQueryRepository },
|
|
2583
|
+
middlewares: { authMiddleware },
|
|
2584
|
+
action: { executeAction }
|
|
2585
|
+
} = ctx;
|
|
2586
|
+
return async function adminFindFullAction(params) {
|
|
2587
|
+
return executeAction(
|
|
2588
|
+
async ({ locale }) => {
|
|
2589
|
+
const { role } = await authMiddleware.authenticate();
|
|
2590
|
+
const { items, total } = await adminQueryRepository.findListCards({
|
|
2591
|
+
...params,
|
|
2592
|
+
locale,
|
|
2593
|
+
role
|
|
2594
|
+
});
|
|
2595
|
+
return {
|
|
2596
|
+
data: { items, total }
|
|
2597
|
+
};
|
|
2598
|
+
},
|
|
2599
|
+
{
|
|
2600
|
+
type: "query",
|
|
2601
|
+
key: [
|
|
2602
|
+
"admin",
|
|
2603
|
+
"findListCardsAction",
|
|
2604
|
+
params.searchString,
|
|
2605
|
+
...params.adminIds ?? [],
|
|
2606
|
+
params.page,
|
|
2607
|
+
params.pageSize
|
|
2608
|
+
]
|
|
2609
|
+
}
|
|
2610
|
+
);
|
|
2611
|
+
};
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
// src/server/interfaces/actions/resources/admin-refresh-token/commands/delete/create-admin-refresh-token-delete-action.ts
|
|
2615
|
+
function createAdminRefreshTokenDeleteAction(ctx) {
|
|
2616
|
+
const {
|
|
2617
|
+
repositories: {
|
|
2618
|
+
adminRefreshTokenQueryRepository,
|
|
2619
|
+
adminRefreshTokenCommandRepository
|
|
2620
|
+
},
|
|
2621
|
+
middlewares: { authMiddleware },
|
|
2622
|
+
action: { executeAction }
|
|
2623
|
+
} = ctx;
|
|
2624
|
+
return async function adminRefreshTokenDeleteAction(tokenHash) {
|
|
2625
|
+
return executeAction(
|
|
2626
|
+
async () => {
|
|
2627
|
+
const currentAdmin = await authMiddleware.authenticate();
|
|
2628
|
+
const targetAdminRefreshToken = await adminRefreshTokenQueryRepository.findByToken({
|
|
2629
|
+
tokenHash
|
|
2630
|
+
});
|
|
2631
|
+
if (!targetAdminRefreshToken) throw ServerError.notFound();
|
|
2632
|
+
const isSelf = currentAdmin.id === targetAdminRefreshToken.adminId;
|
|
2633
|
+
const canModifyOthers = currentAdmin.role === ADMIN_ROLES.SUPER_ADMIN;
|
|
2634
|
+
if (!isSelf && !canModifyOthers) throw ServerError.forbidden();
|
|
2635
|
+
await adminRefreshTokenCommandRepository.delete({
|
|
2636
|
+
id: targetAdminRefreshToken.id
|
|
2637
|
+
});
|
|
2638
|
+
return {
|
|
2639
|
+
i18nKey: "ok.destroy-ok"
|
|
2640
|
+
};
|
|
2641
|
+
},
|
|
2642
|
+
{ type: "command" }
|
|
2643
|
+
);
|
|
2644
|
+
};
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2647
|
+
// src/server/interfaces/actions/resources/admin-refresh-token/queries/create-admin-refresh-token-find-full-action.ts
|
|
2648
|
+
function createAdminRefreshTokenFindManyAction(ctx) {
|
|
2649
|
+
const {
|
|
2650
|
+
services: { cryptoService, cookieService },
|
|
2651
|
+
repositories: { adminRefreshTokenQueryRepository },
|
|
2652
|
+
middlewares: { authMiddleware },
|
|
2653
|
+
action: { executeAction },
|
|
2654
|
+
config: { refreshTokenName }
|
|
2655
|
+
} = ctx;
|
|
2656
|
+
return async function adminRefreshTokenFindManyAction({
|
|
2657
|
+
adminId
|
|
2658
|
+
}) {
|
|
2659
|
+
return executeAction(
|
|
2660
|
+
async () => {
|
|
2661
|
+
await authMiddleware.authenticate();
|
|
2662
|
+
const token = await cookieService.getSignedCookie({
|
|
2663
|
+
name: refreshTokenName
|
|
2664
|
+
});
|
|
2665
|
+
const currentToken = await adminRefreshTokenQueryRepository.findByToken(
|
|
2666
|
+
{ tokenHash: cryptoService.hash(token) }
|
|
2667
|
+
);
|
|
2668
|
+
if (!currentToken) throw ServerError.notFound();
|
|
2669
|
+
const adminRefreshTokens = await adminRefreshTokenQueryRepository.findManyByAdminId({
|
|
2670
|
+
adminId
|
|
2671
|
+
});
|
|
2672
|
+
return {
|
|
2673
|
+
data: {
|
|
2674
|
+
adminRefreshTokens,
|
|
2675
|
+
currentToken
|
|
2676
|
+
}
|
|
2677
|
+
};
|
|
2678
|
+
},
|
|
2679
|
+
{
|
|
2680
|
+
type: "query",
|
|
2681
|
+
key: ["admin-refresh-token", "findManyAction", adminId]
|
|
2682
|
+
}
|
|
2683
|
+
);
|
|
2684
|
+
};
|
|
2685
|
+
}
|
|
2686
|
+
|
|
2687
|
+
// src/server/interfaces/actions/resources/file/commands/create/file-create-validator.ts
|
|
2688
|
+
var fileCreateValidator = (schemas) => schemas.z.object({
|
|
2689
|
+
key: schemas.key(),
|
|
2690
|
+
checksum: schemas.sha256Hash(),
|
|
2691
|
+
// file meta
|
|
2692
|
+
fileMeta: schemas.z.object({
|
|
2693
|
+
type: schemas.text(),
|
|
2694
|
+
size: schemas.positiveNumber(),
|
|
2695
|
+
name: schemas.text()
|
|
2696
|
+
}),
|
|
2697
|
+
// media info
|
|
2698
|
+
width: schemas.positiveNumber().nullable().optional(),
|
|
2699
|
+
height: schemas.positiveNumber().nullable().optional(),
|
|
2700
|
+
duration: schemas.positiveNumber().nullable().optional(),
|
|
2701
|
+
// ----------------------------------------------------------------------------
|
|
2702
|
+
// relations
|
|
2703
|
+
// ----------------------------------------------------------------------------
|
|
2704
|
+
folder: schemas.z.object({
|
|
2705
|
+
id: schemas.id().exist({ table: "folders", column: "id" })
|
|
2706
|
+
}).nullable().optional(),
|
|
2707
|
+
// Use in [file] pages
|
|
2708
|
+
folderKey: schemas.key().exist({ table: "folders", column: "key" }).optional(),
|
|
2709
|
+
// Use in Simple Upload
|
|
2710
|
+
// ----------------------------------------------------------------------------
|
|
2711
|
+
// translation
|
|
2712
|
+
// ----------------------------------------------------------------------------
|
|
2713
|
+
translations: schemas.array(
|
|
2714
|
+
schemas.z.object({
|
|
2715
|
+
// core
|
|
2716
|
+
locale: schemas.locale(),
|
|
2717
|
+
// text
|
|
2718
|
+
name: schemas.text().nullable(),
|
|
2719
|
+
alt: schemas.text().nullable()
|
|
2720
|
+
})
|
|
2721
|
+
)
|
|
2722
|
+
});
|
|
2723
|
+
|
|
2724
|
+
// src/server/interfaces/actions/resources/file/commands/create/create-file-create-action.ts
|
|
2725
|
+
function createFileCreateAction(ctx) {
|
|
2726
|
+
const {
|
|
2727
|
+
repositories: { folderQueryRepository, fileCommandRepository },
|
|
2728
|
+
middlewares: { authMiddleware },
|
|
2729
|
+
action: { executeAction },
|
|
2730
|
+
schemas
|
|
2731
|
+
} = ctx;
|
|
2732
|
+
return async function fileCreateAction({
|
|
2733
|
+
formData
|
|
2734
|
+
}) {
|
|
2735
|
+
return executeAction(
|
|
2736
|
+
async () => {
|
|
2737
|
+
await authMiddleware.authenticate();
|
|
2738
|
+
const {
|
|
2739
|
+
key,
|
|
2740
|
+
checksum,
|
|
2741
|
+
fileMeta,
|
|
2742
|
+
width,
|
|
2743
|
+
height,
|
|
2744
|
+
duration,
|
|
2745
|
+
folder,
|
|
2746
|
+
folderKey,
|
|
2747
|
+
translations
|
|
2748
|
+
} = await fileCreateValidator(schemas).parseAsync(formData);
|
|
2749
|
+
let finalFolder = folder;
|
|
2750
|
+
if (folderKey && !folder) {
|
|
2751
|
+
finalFolder = await folderQueryRepository.findFull({
|
|
2752
|
+
key: folderKey
|
|
2753
|
+
});
|
|
2754
|
+
}
|
|
2755
|
+
const createdFile = await fileCommandRepository.create({
|
|
2756
|
+
key,
|
|
2757
|
+
checksum,
|
|
2758
|
+
fileMeta,
|
|
2759
|
+
...width ? { width } : {},
|
|
2760
|
+
...height ? { height } : {},
|
|
2761
|
+
...duration ? { duration } : {},
|
|
2762
|
+
...finalFolder ? { folder: finalFolder } : {},
|
|
2763
|
+
translations
|
|
2764
|
+
});
|
|
2765
|
+
return {
|
|
2766
|
+
i18nKey: "ok.store-ok",
|
|
2767
|
+
data: { file: createdFile }
|
|
2768
|
+
};
|
|
2769
|
+
},
|
|
2770
|
+
{ type: "command" }
|
|
2771
|
+
);
|
|
2772
|
+
};
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
// src/server/interfaces/actions/resources/file/commands/create-many/file-create-many-validator.ts
|
|
2776
|
+
var fileCreateManyValidator = (schemas) => schemas.z.object({
|
|
2777
|
+
uploadResults: schemas.array(
|
|
2778
|
+
schemas.z.object({
|
|
2779
|
+
// core
|
|
2780
|
+
key: schemas.key(),
|
|
2781
|
+
checksum: schemas.sha256Hash(),
|
|
2782
|
+
// file meta
|
|
2783
|
+
fileMeta: schemas.z.object({
|
|
2784
|
+
type: schemas.text(),
|
|
2785
|
+
size: schemas.positiveNumber(),
|
|
2786
|
+
name: schemas.text()
|
|
2787
|
+
}),
|
|
2788
|
+
// media info
|
|
2789
|
+
width: schemas.positiveNumber().nullable(),
|
|
2790
|
+
height: schemas.positiveNumber().nullable(),
|
|
2791
|
+
duration: schemas.positiveNumber().nullable(),
|
|
2792
|
+
// ----------------------------------------------------------------------------
|
|
2793
|
+
// translation
|
|
2794
|
+
// ----------------------------------------------------------------------------
|
|
2795
|
+
translations: schemas.array(
|
|
2796
|
+
schemas.z.object({
|
|
2797
|
+
// core
|
|
2798
|
+
locale: schemas.locale(),
|
|
2799
|
+
// text
|
|
2800
|
+
name: schemas.text().nullable(),
|
|
2801
|
+
alt: schemas.text().nullable()
|
|
2802
|
+
})
|
|
2803
|
+
)
|
|
2804
|
+
})
|
|
2805
|
+
),
|
|
2806
|
+
// ----------------------------------------------------------------------------
|
|
2807
|
+
// relations
|
|
2808
|
+
// ----------------------------------------------------------------------------
|
|
2809
|
+
folder: schemas.z.object({ id: schemas.id().exist({ table: "folders", column: "id" }) }).nullable().optional()
|
|
2810
|
+
});
|
|
2811
|
+
|
|
2812
|
+
// node_modules/yocto-queue/index.js
|
|
2813
|
+
var Node = class {
|
|
2814
|
+
value;
|
|
2815
|
+
next;
|
|
2816
|
+
constructor(value) {
|
|
2817
|
+
this.value = value;
|
|
2818
|
+
}
|
|
2819
|
+
};
|
|
2820
|
+
var Queue = class {
|
|
2821
|
+
#head;
|
|
2822
|
+
#tail;
|
|
2823
|
+
#size;
|
|
2824
|
+
constructor() {
|
|
2825
|
+
this.clear();
|
|
2826
|
+
}
|
|
2827
|
+
enqueue(value) {
|
|
2828
|
+
const node = new Node(value);
|
|
2829
|
+
if (this.#head) {
|
|
2830
|
+
this.#tail.next = node;
|
|
2831
|
+
this.#tail = node;
|
|
2832
|
+
} else {
|
|
2833
|
+
this.#head = node;
|
|
2834
|
+
this.#tail = node;
|
|
2835
|
+
}
|
|
2836
|
+
this.#size++;
|
|
2837
|
+
}
|
|
2838
|
+
dequeue() {
|
|
2839
|
+
const current = this.#head;
|
|
2840
|
+
if (!current) {
|
|
2841
|
+
return;
|
|
2842
|
+
}
|
|
2843
|
+
this.#head = this.#head.next;
|
|
2844
|
+
this.#size--;
|
|
2845
|
+
if (!this.#head) {
|
|
2846
|
+
this.#tail = void 0;
|
|
2847
|
+
}
|
|
2848
|
+
return current.value;
|
|
2849
|
+
}
|
|
2850
|
+
peek() {
|
|
2851
|
+
if (!this.#head) {
|
|
2852
|
+
return;
|
|
2853
|
+
}
|
|
2854
|
+
return this.#head.value;
|
|
2855
|
+
}
|
|
2856
|
+
clear() {
|
|
2857
|
+
this.#head = void 0;
|
|
2858
|
+
this.#tail = void 0;
|
|
2859
|
+
this.#size = 0;
|
|
2860
|
+
}
|
|
2861
|
+
get size() {
|
|
2862
|
+
return this.#size;
|
|
2863
|
+
}
|
|
2864
|
+
*[Symbol.iterator]() {
|
|
2865
|
+
let current = this.#head;
|
|
2866
|
+
while (current) {
|
|
2867
|
+
yield current.value;
|
|
2868
|
+
current = current.next;
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
*drain() {
|
|
2872
|
+
while (this.#head) {
|
|
2873
|
+
yield this.dequeue();
|
|
2874
|
+
}
|
|
2875
|
+
}
|
|
2876
|
+
};
|
|
2877
|
+
|
|
2878
|
+
// node_modules/p-limit/index.js
|
|
2879
|
+
function pLimit(concurrency) {
|
|
2880
|
+
validateConcurrency(concurrency);
|
|
2881
|
+
const queue = new Queue();
|
|
2882
|
+
let activeCount = 0;
|
|
2883
|
+
const resumeNext = () => {
|
|
2884
|
+
if (activeCount < concurrency && queue.size > 0) {
|
|
2885
|
+
activeCount++;
|
|
2886
|
+
queue.dequeue()();
|
|
2887
|
+
}
|
|
2888
|
+
};
|
|
2889
|
+
const next = () => {
|
|
2890
|
+
activeCount--;
|
|
2891
|
+
resumeNext();
|
|
2892
|
+
};
|
|
2893
|
+
const run = async (function_, resolve, arguments_) => {
|
|
2894
|
+
const result2 = (async () => function_(...arguments_))();
|
|
2895
|
+
resolve(result2);
|
|
2896
|
+
try {
|
|
2897
|
+
await result2;
|
|
2898
|
+
} catch {
|
|
2899
|
+
}
|
|
2900
|
+
next();
|
|
2901
|
+
};
|
|
2902
|
+
const enqueue = (function_, resolve, arguments_) => {
|
|
2903
|
+
new Promise((internalResolve) => {
|
|
2904
|
+
queue.enqueue(internalResolve);
|
|
2905
|
+
}).then(run.bind(void 0, function_, resolve, arguments_));
|
|
2906
|
+
if (activeCount < concurrency) {
|
|
2907
|
+
resumeNext();
|
|
2908
|
+
}
|
|
2909
|
+
};
|
|
2910
|
+
const generator = (function_, ...arguments_) => new Promise((resolve) => {
|
|
2911
|
+
enqueue(function_, resolve, arguments_);
|
|
2912
|
+
});
|
|
2913
|
+
Object.defineProperties(generator, {
|
|
2914
|
+
activeCount: {
|
|
2915
|
+
get: () => activeCount
|
|
2916
|
+
},
|
|
2917
|
+
pendingCount: {
|
|
2918
|
+
get: () => queue.size
|
|
2919
|
+
},
|
|
2920
|
+
clearQueue: {
|
|
2921
|
+
value() {
|
|
2922
|
+
queue.clear();
|
|
2923
|
+
}
|
|
2924
|
+
},
|
|
2925
|
+
concurrency: {
|
|
2926
|
+
get: () => concurrency,
|
|
2927
|
+
set(newConcurrency) {
|
|
2928
|
+
validateConcurrency(newConcurrency);
|
|
2929
|
+
concurrency = newConcurrency;
|
|
2930
|
+
queueMicrotask(() => {
|
|
2931
|
+
while (activeCount < concurrency && queue.size > 0) {
|
|
2932
|
+
resumeNext();
|
|
2933
|
+
}
|
|
2934
|
+
});
|
|
2935
|
+
}
|
|
2936
|
+
},
|
|
2937
|
+
map: {
|
|
2938
|
+
async value(iterable, function_) {
|
|
2939
|
+
const promises = Array.from(iterable, (value, index) => this(function_, value, index));
|
|
2940
|
+
return Promise.all(promises);
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2943
|
+
});
|
|
2944
|
+
return generator;
|
|
2945
|
+
}
|
|
2946
|
+
function validateConcurrency(concurrency) {
|
|
2947
|
+
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
2948
|
+
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
2949
|
+
}
|
|
2950
|
+
}
|
|
2951
|
+
|
|
2952
|
+
// src/server/interfaces/actions/resources/file/commands/create-many/create-file-create-many-action.ts
|
|
2953
|
+
function createFileCreateManyAction(ctx) {
|
|
2954
|
+
const {
|
|
2955
|
+
repositories: { fileCommandRepository },
|
|
2956
|
+
middlewares: { authMiddleware },
|
|
2957
|
+
action: { executeAction },
|
|
2958
|
+
schemas
|
|
2959
|
+
} = ctx;
|
|
2960
|
+
return async function fileCreateManyAction({
|
|
2961
|
+
formData
|
|
2962
|
+
}) {
|
|
2963
|
+
return executeAction(
|
|
2964
|
+
async () => {
|
|
2965
|
+
await authMiddleware.authenticate();
|
|
2966
|
+
const { uploadResults, folder } = await fileCreateManyValidator(schemas).parseAsync(formData);
|
|
2967
|
+
const limit = pLimit(5);
|
|
2968
|
+
await Promise.all(
|
|
2969
|
+
uploadResults.map(
|
|
2970
|
+
(file) => limit(async () => {
|
|
2971
|
+
await fileCommandRepository.create({
|
|
2972
|
+
key: file.key,
|
|
2973
|
+
fileMeta: file.fileMeta,
|
|
2974
|
+
checksum: file.checksum,
|
|
2975
|
+
width: file.width,
|
|
2976
|
+
height: file.height,
|
|
2977
|
+
duration: file.duration,
|
|
2978
|
+
...folder !== void 0 ? { folder } : {},
|
|
2979
|
+
translations: file.translations
|
|
2980
|
+
});
|
|
2981
|
+
})
|
|
2982
|
+
)
|
|
2983
|
+
);
|
|
2984
|
+
return {
|
|
2985
|
+
i18nKey: "ok.store-ok",
|
|
2986
|
+
data: { count: uploadResults.length }
|
|
2987
|
+
};
|
|
2988
|
+
},
|
|
2989
|
+
{ type: "command" }
|
|
2990
|
+
);
|
|
2991
|
+
};
|
|
2992
|
+
}
|
|
2993
|
+
|
|
2994
|
+
// src/server/interfaces/actions/resources/file/commands/purge-many/file-purge-many-validator.ts
|
|
2995
|
+
var filePurgeManyValidator = (schemas) => schemas.z.object({
|
|
2996
|
+
ids: schemas.array(schemas.id().exist({ table: "files", column: "id" }))
|
|
2997
|
+
});
|
|
2998
|
+
|
|
2999
|
+
// src/server/interfaces/actions/resources/file/commands/purge-many/create-file-purge-many-action.ts
|
|
3000
|
+
function createFilePurgeManyAction(ctx) {
|
|
3001
|
+
const {
|
|
3002
|
+
services: { storageService },
|
|
3003
|
+
repositories: { fileQueryRepository, fileCommandRepository },
|
|
3004
|
+
middlewares: { authMiddleware },
|
|
3005
|
+
action: { executeAction },
|
|
3006
|
+
schemas
|
|
3007
|
+
} = ctx;
|
|
3008
|
+
return async function filePurgeManyAction({
|
|
3009
|
+
formData
|
|
3010
|
+
}) {
|
|
3011
|
+
return executeAction(
|
|
3012
|
+
async () => {
|
|
3013
|
+
await authMiddleware.authenticate();
|
|
3014
|
+
const { ids: ids2 } = await filePurgeManyValidator(schemas).parseAsync(formData);
|
|
3015
|
+
const foundFiles = await fileQueryRepository.findManyByIds({ ids: ids2 });
|
|
3016
|
+
if (foundFiles.length === 0) throw ServerError.notFound();
|
|
3017
|
+
if (foundFiles.some((file) => isFileLocked(file))) {
|
|
3018
|
+
throw new ServerError({ i18nKey: "error.files-destroy-is-locked" });
|
|
3019
|
+
}
|
|
3020
|
+
const keys = foundFiles.map((file) => file.key);
|
|
3021
|
+
await Promise.all(
|
|
3022
|
+
keys.map(async (key) => await storageService.remove({ key }))
|
|
3023
|
+
);
|
|
3024
|
+
await Promise.all(
|
|
3025
|
+
foundFiles.map(
|
|
3026
|
+
async (file) => await fileCommandRepository.delete({ id: file.id })
|
|
3027
|
+
)
|
|
3028
|
+
);
|
|
3029
|
+
return {
|
|
3030
|
+
i18nKey: "ok.destroy-ok"
|
|
3031
|
+
};
|
|
3032
|
+
},
|
|
3033
|
+
{ type: "command" }
|
|
3034
|
+
);
|
|
3035
|
+
};
|
|
3036
|
+
}
|
|
3037
|
+
|
|
3038
|
+
// src/server/interfaces/actions/resources/file/commands/restore-many/file-create-restore-validator.ts
|
|
3039
|
+
var fileRestoreManyValidator = (schemas) => schemas.z.object({
|
|
3040
|
+
ids: schemas.array(schemas.id().exist({ table: "files", column: "id" }))
|
|
3041
|
+
});
|
|
3042
|
+
|
|
3043
|
+
// src/server/interfaces/actions/resources/file/commands/restore-many/create-file-restore-many-action.ts
|
|
3044
|
+
function createFileRestoreManyAction(ctx) {
|
|
3045
|
+
const {
|
|
3046
|
+
repositories: { fileCommandRepository },
|
|
3047
|
+
middlewares: { authMiddleware },
|
|
3048
|
+
action: { executeAction },
|
|
3049
|
+
schemas
|
|
3050
|
+
} = ctx;
|
|
3051
|
+
return async function fileRestoreManyAction({
|
|
3052
|
+
formData
|
|
3053
|
+
}) {
|
|
3054
|
+
return executeAction(
|
|
3055
|
+
async () => {
|
|
3056
|
+
await authMiddleware.authenticate();
|
|
3057
|
+
const { ids: ids2 } = await fileRestoreManyValidator(schemas).parseAsync(formData);
|
|
3058
|
+
await fileCommandRepository.restoreMany({ ids: ids2 });
|
|
3059
|
+
return {
|
|
3060
|
+
i18nKey: "ok.restore-ok"
|
|
3061
|
+
};
|
|
3062
|
+
},
|
|
3063
|
+
{ type: "command" }
|
|
3064
|
+
);
|
|
3065
|
+
};
|
|
3066
|
+
}
|
|
3067
|
+
|
|
3068
|
+
// src/server/interfaces/actions/resources/file/commands/soft-delete-many/file-soft-delete-many-validator.ts
|
|
3069
|
+
var fileSoftDeleteManyValidator = (schemas) => schemas.z.object({
|
|
3070
|
+
ids: schemas.array(schemas.id().exist({ table: "files", column: "id" }))
|
|
3071
|
+
});
|
|
3072
|
+
|
|
3073
|
+
// src/server/interfaces/actions/resources/file/commands/soft-delete-many/create-file-soft-delete-many-action.ts
|
|
3074
|
+
function createFileSoftDeleteManyAction(ctx) {
|
|
3075
|
+
const {
|
|
3076
|
+
repositories: { fileQueryRepository, fileCommandRepository },
|
|
3077
|
+
middlewares: { authMiddleware },
|
|
3078
|
+
action: { executeAction },
|
|
3079
|
+
schemas
|
|
3080
|
+
} = ctx;
|
|
3081
|
+
return async function fileSoftDeleteManyAction({
|
|
3082
|
+
formData
|
|
3083
|
+
}) {
|
|
3084
|
+
return executeAction(
|
|
3085
|
+
async () => {
|
|
3086
|
+
await authMiddleware.authenticate();
|
|
3087
|
+
const { ids: ids2 } = await fileSoftDeleteManyValidator(schemas).parseAsync(formData);
|
|
3088
|
+
const foundFiles = await fileQueryRepository.findManyByIds({ ids: ids2 });
|
|
3089
|
+
if (foundFiles.length === 0) throw ServerError.notFound();
|
|
3090
|
+
const targetIds = foundFiles.filter((f) => !f.isLocked).map((f) => f.id);
|
|
3091
|
+
const hasLockedFile = ids2.length !== targetIds.length;
|
|
3092
|
+
const count = await fileCommandRepository.softDeleteMany({
|
|
3093
|
+
ids: targetIds
|
|
3094
|
+
});
|
|
3095
|
+
if (count === 0) {
|
|
3096
|
+
throw new ServerError({ i18nKey: "error.files-batch-destroy-no" });
|
|
3097
|
+
}
|
|
3098
|
+
return {
|
|
3099
|
+
i18nKey: hasLockedFile ? "ok.destroy-ok" : "ok.files-batch-destroy-has-locked"
|
|
3100
|
+
};
|
|
3101
|
+
},
|
|
3102
|
+
{ type: "command" }
|
|
3103
|
+
);
|
|
3104
|
+
};
|
|
3105
|
+
}
|
|
3106
|
+
|
|
3107
|
+
// src/server/interfaces/actions/resources/file/querires/create-file-find-full-action.ts
|
|
3108
|
+
function createFileFindFullAction(ctx) {
|
|
3109
|
+
const {
|
|
3110
|
+
repositories: { fileQueryRepository },
|
|
3111
|
+
action: { executeAction }
|
|
3112
|
+
} = ctx;
|
|
3113
|
+
return async function FileFindFullAction(params) {
|
|
3114
|
+
return executeAction(
|
|
3115
|
+
async () => {
|
|
3116
|
+
const file = await fileQueryRepository.findFull(params);
|
|
3117
|
+
if (!file) throw ServerError.notFound();
|
|
3118
|
+
return {
|
|
3119
|
+
data: { file }
|
|
3120
|
+
};
|
|
3121
|
+
},
|
|
3122
|
+
{
|
|
3123
|
+
type: "query",
|
|
3124
|
+
key: ["file", "findFullAction", params.id]
|
|
3125
|
+
}
|
|
3126
|
+
);
|
|
3127
|
+
};
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3130
|
+
// src/server/interfaces/actions/resources/file/querires/create-file-find-list-cards-action.ts
|
|
3131
|
+
function createFileFindListCardsAction(ctx) {
|
|
3132
|
+
const {
|
|
3133
|
+
repositories: { fileQueryRepository },
|
|
3134
|
+
middlewares: { authMiddleware },
|
|
3135
|
+
action: { executeAction }
|
|
3136
|
+
} = ctx;
|
|
3137
|
+
return async function fileFindFullAction(params) {
|
|
3138
|
+
return executeAction(
|
|
3139
|
+
async ({ locale }) => {
|
|
3140
|
+
await authMiddleware.authenticate();
|
|
3141
|
+
const { items, total } = await fileQueryRepository.findListCards({
|
|
3142
|
+
...params,
|
|
3143
|
+
locale
|
|
3144
|
+
});
|
|
3145
|
+
return {
|
|
3146
|
+
data: { items, total }
|
|
3147
|
+
};
|
|
3148
|
+
},
|
|
3149
|
+
{
|
|
3150
|
+
type: "query",
|
|
3151
|
+
key: [
|
|
3152
|
+
"file",
|
|
3153
|
+
"findListCardsAction",
|
|
3154
|
+
params.searchString,
|
|
3155
|
+
params.type,
|
|
3156
|
+
params.isDeleted,
|
|
3157
|
+
params.isLocked,
|
|
3158
|
+
params.folderId,
|
|
3159
|
+
...params.fileIds ?? [],
|
|
3160
|
+
params.page,
|
|
3161
|
+
params.pageSize
|
|
3162
|
+
]
|
|
3163
|
+
}
|
|
3164
|
+
);
|
|
3165
|
+
};
|
|
3166
|
+
}
|
|
3167
|
+
|
|
2313
3168
|
// src/server/applications/auth/create-auth-use-cases.ts
|
|
2314
3169
|
function createAuthUseCases({
|
|
2315
3170
|
prisma,
|
|
@@ -2489,4 +3344,4 @@ function createForgotPasswordEmail({
|
|
|
2489
3344
|
};
|
|
2490
3345
|
}
|
|
2491
3346
|
|
|
2492
|
-
export { ADMIN_ORDER_BY, ORDER_BY, POST_ORDER_BY, ServerError, createAdminCommandRepository, createAdminQueryRepository, createAdminRefreshTokenCommandRepository, createAdminRefreshTokenQueryRepository, createArgon2Service, createAuthMiddleware, createAuthUseCases, createCache, createCacheResult, createChangePasswordAction, createCookieService, createCryptoService, createEmailUnverifiedAction, createEmailVerificationEmail, createExecuteAction, createExecuteApi, createExist, createFileCommandRepository, createFileQueryRepository, createFileSchema, createFolderCommandRepository, createFolderQueryRepository, createForgotPasswordAction, createForgotPasswordEmail, createIpRateLimiter, createJwtService, createMultiFileSchema, createPostCommandRepository, createPostQueryRepository, createRenderEmailTemplate, createResetPasswordAction, createSchemas, createSendEmail, createSeoMetadataCommandRepository, createSignInAction, createSignOutAction, createTocItemSchema, createTransporter, createUnique, createVerifyAccessToken, createVerifyAction, createVerifyEmailAction, createVerifyRefreshToken, createZod, normalizeCacheKey };
|
|
3347
|
+
export { ADMIN_ORDER_BY, ORDER_BY, POST_ORDER_BY, ServerError, createAdminCommandRepository, createAdminCreateAction, createAdminDeleteAction, createAdminFindFullAction, createAdminFindListCardsAction, createAdminQueryRepository, createAdminRefreshTokenCommandRepository, createAdminRefreshTokenDeleteAction, createAdminRefreshTokenFindManyAction, createAdminRefreshTokenQueryRepository, createAdminUpdateAction, createArgon2Service, createAuthMiddleware, createAuthUseCases, createCache, createCacheResult, createChangePasswordAction, createCookieService, createCryptoService, createEmailUnverifiedAction, createEmailVerificationEmail, createExecuteAction, createExecuteApi, createExist, createFileCommandRepository, createFileCreateAction, createFileCreateManyAction, createFileFindFullAction, createFileFindListCardsAction, createFilePurgeManyAction, createFileQueryRepository, createFileRestoreManyAction, createFileSchema, createFileSoftDeleteManyAction, createFolderCommandRepository, createFolderQueryRepository, createForgotPasswordAction, createForgotPasswordEmail, createIpRateLimiter, createJwtService, createMultiFileSchema, createPostCommandRepository, createPostQueryRepository, createRenderEmailTemplate, createResetPasswordAction, createSchemas, createSendEmail, createSeoMetadataCommandRepository, createSignInAction, createSignOutAction, createTocItemSchema, createTransporter, createUnique, createVerifyAccessToken, createVerifyAction, createVerifyEmailAction, createVerifyRefreshToken, createZod, normalizeCacheKey };
|