@yimingliao/cms 0.0.54 → 0.0.56
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.
|
@@ -338,4 +338,4 @@ type AdminCard = AdminSafe & {
|
|
|
338
338
|
translations: AdminTranslation[];
|
|
339
339
|
};
|
|
340
340
|
|
|
341
|
-
export { ADMIN_ROLES as A, type BaseTranslation as B, type DeviceInfo as D, type ExternalLink as E, type FolderFull as F, type MultiItems as M, type PostFull as P, type SeoMetadata as S, type TocItem as T, type
|
|
341
|
+
export { ADMIN_ROLES as A, type BaseTranslation as B, type DeviceInfo as D, type ExternalLink as E, type FolderFull as F, type MultiItems as M, type PostFull as P, type SeoMetadata as S, type TocItem as T, type Folder as a, type FileFull as b, type FileCard as c, type Admin as d, type AdminCard as e, type AdminFull as f, type AdminRefreshToken as g, type AdminRole as h, type AdminSafe as i, type AdminTranslation as j, type Alternate as k, FILE_TYPES as l, type Faq as m, type File as n, type FileTranslation as o, type FileType as p, POST_TYPES as q, type Post as r, type PostListCard as s, type PostTranslation as t, type PostType as u, type SingleItem as v, type Translation as w };
|
|
@@ -5,6 +5,24 @@ var ADMIN_ROLES = {
|
|
|
5
5
|
EDITOR: "EDITOR"
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
+
// src/domain/resources/file/utils/is-file-locked.ts
|
|
9
|
+
var isFileLocked = (file) => {
|
|
10
|
+
if (!file) return false;
|
|
11
|
+
if (!("adminAsAvatarImage" in file && "postsAsCoverImage" in file && "postsAsContentImage" in file && "postsAsImages1" in file && "postsAsImages2" in file && "postsAsImage1" in file && "postsAsImage2" in file && "postsAsImage3" in file && "postsAsImage4" in file)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const locked = file.adminAsAvatarImage.length > 0 || file.postsAsCoverImage.length > 0 || file.postsAsContentImage.length > 0 || file.postsAsImages1.length > 0 || file.postsAsImages2.length > 0 || file.postsAsImage1.length > 0 || file.postsAsImage2.length > 0 || file.postsAsImage3.length > 0 || file.postsAsImage4.length > 0;
|
|
15
|
+
return locked;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/domain/resources/folder/utils/is-folder-locked.ts
|
|
19
|
+
var isFolderLocked = (folder) => {
|
|
20
|
+
if (!folder) return true;
|
|
21
|
+
if (!("subFolders" in folder)) return false;
|
|
22
|
+
const locked = folder.subFolders?.length > 0 || folder.files?.length > 0;
|
|
23
|
+
return locked;
|
|
24
|
+
};
|
|
25
|
+
|
|
8
26
|
// src/domain/resources/post/props.ts
|
|
9
27
|
var POST_TYPES = {
|
|
10
28
|
TOPIC: "TOPIC",
|
|
@@ -43,4 +61,4 @@ var ROOT_FOLDER = {
|
|
|
43
61
|
var SIMPLE_UPLOAD_FOLDER_NAME = "simple-upload";
|
|
44
62
|
var SIMPLE_UPLOAD_FOLDER_KEY = `${SIMPLE_UPLOAD_FOLDER_NAME}`;
|
|
45
63
|
|
|
46
|
-
export { ADMIN_ROLES, POST_TYPES, ROOT_FOLDER, ROOT_FOLDER_ID, ROOT_FOLDER_NAME, SIMPLE_UPLOAD_FOLDER_KEY, SIMPLE_UPLOAD_FOLDER_NAME };
|
|
64
|
+
export { ADMIN_ROLES, POST_TYPES, ROOT_FOLDER, ROOT_FOLDER_ID, ROOT_FOLDER_NAME, SIMPLE_UPLOAD_FOLDER_KEY, SIMPLE_UPLOAD_FOLDER_NAME, isFileLocked, isFolderLocked };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { F as FolderFull, P as PostFull, B as BaseTranslation } from './card-
|
|
2
|
-
export { A as ADMIN_ROLES,
|
|
1
|
+
import { F as FolderFull, a as Folder, b as FileFull, c as FileCard, P as PostFull, B as BaseTranslation } from './card-BG2vtuIz.js';
|
|
2
|
+
export { A as ADMIN_ROLES, d as Admin, e as AdminCard, f as AdminFull, g as AdminRefreshToken, h as AdminRole, i as AdminSafe, j as AdminTranslation, k as Alternate, D as DeviceInfo, E as ExternalLink, l as FILE_TYPES, m as Faq, n as File, o as FileTranslation, p as FileType, M as MultiItems, q as POST_TYPES, r as Post, s as PostListCard, t as PostTranslation, u as PostType, S as SeoMetadata, v as SingleItem, T as TocItem, w as Translation } from './card-BG2vtuIz.js';
|
|
3
3
|
export { B as BlobFile } from './types-0oS1A2K5.js';
|
|
4
4
|
import { E as ErrorDetail, S as SuccessResult, a as ErrorResult } from './types-DHlRoJwv.js';
|
|
5
5
|
export { R as Result } from './types-DHlRoJwv.js';
|
|
6
6
|
import { Metadata } from 'next';
|
|
7
7
|
import { Robots } from 'next/dist/lib/metadata/types/metadata-types';
|
|
8
8
|
|
|
9
|
+
declare const isFolderLocked: (folder?: FolderFull | Folder) => boolean;
|
|
10
|
+
|
|
11
|
+
declare const isFileLocked: (file?: FileFull | FileCard | null) => boolean;
|
|
12
|
+
|
|
9
13
|
declare const ROOT_FOLDER_ID = "01ARZ3NDEKTSV4RRFFQ69G5FAV";
|
|
10
14
|
declare const ROOT_FOLDER_NAME = "ROOT";
|
|
11
15
|
declare const ROOT_FOLDER: FolderFull;
|
|
@@ -94,4 +98,4 @@ declare const SIZE: {
|
|
|
94
98
|
};
|
|
95
99
|
type SizeUnit = keyof typeof SIZE;
|
|
96
100
|
|
|
97
|
-
export { BaseTranslation, ErrorDetail, ErrorResult, type ErrorResultParams, FolderFull, OG_TYPE_ARRAY, type OgType, PostFull, ROOT_FOLDER, ROOT_FOLDER_ID, ROOT_FOLDER_NAME, SIMPLE_UPLOAD_FOLDER_KEY, SIMPLE_UPLOAD_FOLDER_NAME, SIZE, type SizeUnit, SuccessResult, type SuccessResultParams, TWITTER_CARD_ARRAY, type TwitterCard, classifyFileType, createBuildArticleMetadata, createBuildTranslations, createBuildWebsiteMetadata, findTranslation, formatFileSize, getMediaInfo, mimeToExtension, result, serializeJsonLd };
|
|
101
|
+
export { BaseTranslation, ErrorDetail, ErrorResult, type ErrorResultParams, FileCard, FileFull, Folder, FolderFull, OG_TYPE_ARRAY, type OgType, PostFull, ROOT_FOLDER, ROOT_FOLDER_ID, ROOT_FOLDER_NAME, SIMPLE_UPLOAD_FOLDER_KEY, SIMPLE_UPLOAD_FOLDER_NAME, SIZE, type SizeUnit, SuccessResult, type SuccessResultParams, TWITTER_CARD_ARRAY, type TwitterCard, classifyFileType, createBuildArticleMetadata, createBuildTranslations, createBuildWebsiteMetadata, findTranslation, formatFileSize, getMediaInfo, isFileLocked, isFolderLocked, mimeToExtension, result, serializeJsonLd };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ADMIN_ROLES, POST_TYPES, ROOT_FOLDER, ROOT_FOLDER_ID, ROOT_FOLDER_NAME, SIMPLE_UPLOAD_FOLDER_KEY, SIMPLE_UPLOAD_FOLDER_NAME } from './chunk-
|
|
1
|
+
export { ADMIN_ROLES, POST_TYPES, ROOT_FOLDER, ROOT_FOLDER_ID, ROOT_FOLDER_NAME, SIMPLE_UPLOAD_FOLDER_KEY, SIMPLE_UPLOAD_FOLDER_NAME, isFileLocked, isFolderLocked } from './chunk-FUAJWL2N.js';
|
|
2
2
|
export { FILE_TYPES, OG_TYPE_ARRAY, SIZE, TWITTER_CARD_ARRAY, classifyFileType, createBuildArticleMetadata, createBuildTranslations, createBuildWebsiteMetadata, findTranslation, formatFileSize, getMediaInfo, mimeToExtension, result, serializeJsonLd } from './chunk-YAUBKQVA.js';
|
package/dist/server/index.d.ts
CHANGED
|
@@ -7,12 +7,13 @@ import * as zod from 'zod';
|
|
|
7
7
|
import zod__default, { z, ZodType } from 'zod';
|
|
8
8
|
import { B as BlobFile } from '../types-0oS1A2K5.js';
|
|
9
9
|
import * as zod_v4_core from 'zod/v4/core';
|
|
10
|
-
import { T as TocItem,
|
|
10
|
+
import { T as TocItem, h as AdminRole, v as SingleItem, B as BaseTranslation, d as Admin, f as AdminFull, i as AdminSafe, D as DeviceInfo, g as AdminRefreshToken, n as File$1, b as FileFull, p as FileType, a as Folder, F as FolderFull, u as PostType, M as MultiItems, E as ExternalLink, m as Faq, r as Post, s as PostListCard, t as PostTranslation, P as PostFull, k as Alternate } from '../card-BG2vtuIz.js';
|
|
11
11
|
import * as nodemailer_lib_smtp_transport from 'nodemailer/lib/smtp-transport';
|
|
12
12
|
import nodemailer, { Transporter } from 'nodemailer';
|
|
13
13
|
import { BaseTranslator, LocaleMessages } from 'intor';
|
|
14
14
|
import { S as SuccessResult, R as Result } from '../types-DHlRoJwv.js';
|
|
15
15
|
import { NextResponse } from 'next/server';
|
|
16
|
+
import { S as StorageService } from '../types-J25u1G6t.js';
|
|
16
17
|
|
|
17
18
|
interface CreateJwtServiceParams {
|
|
18
19
|
defaultSecret: string;
|
|
@@ -225,8 +226,8 @@ declare function createRenderEmailTemplate({ siteName, webUrl, logoUrl, logger,
|
|
|
225
226
|
}): (templateKey: string, replacements?: Record<string, string>) => Promise<string>;
|
|
226
227
|
|
|
227
228
|
interface CreateParams$4 {
|
|
228
|
-
email: string;
|
|
229
229
|
role: AdminRole;
|
|
230
|
+
email: string;
|
|
230
231
|
passwordHash: string;
|
|
231
232
|
socialLinks: string[];
|
|
232
233
|
avatarImage: SingleItem;
|
|
@@ -244,11 +245,10 @@ interface CreateParams$4 {
|
|
|
244
245
|
}
|
|
245
246
|
interface UpdateParams$3 {
|
|
246
247
|
id: string;
|
|
247
|
-
email?: string;
|
|
248
248
|
role: AdminRole;
|
|
249
|
+
email?: string;
|
|
249
250
|
socialLinks: string[];
|
|
250
251
|
avatarImage: SingleItem;
|
|
251
|
-
emailVerifiedAt: Date | null;
|
|
252
252
|
translations: (BaseTranslation & {
|
|
253
253
|
name: string | null;
|
|
254
254
|
authorName: string | null;
|
|
@@ -260,11 +260,12 @@ interface UpdateParams$3 {
|
|
|
260
260
|
homeLocation: string | null;
|
|
261
261
|
nationality: string | null;
|
|
262
262
|
})[];
|
|
263
|
+
emailVerifiedAt: Date | null;
|
|
263
264
|
}
|
|
264
265
|
|
|
265
266
|
declare function createAdminCommandRepository(prisma: any): {
|
|
266
|
-
create: ({ avatarImage, translations,
|
|
267
|
-
update: ({ id, avatarImage, translations,
|
|
267
|
+
create: ({ role, email, passwordHash, socialLinks, avatarImage, translations, }: CreateParams$4) => Promise<Admin>;
|
|
268
|
+
update: ({ id, role, email, socialLinks, avatarImage, translations, emailVerifiedAt, }: UpdateParams$3) => Promise<Admin>;
|
|
268
269
|
delete: ({ id }: {
|
|
269
270
|
id: string;
|
|
270
271
|
}) => Promise<Admin>;
|
|
@@ -359,8 +360,8 @@ interface UpdateParams$2 {
|
|
|
359
360
|
}
|
|
360
361
|
|
|
361
362
|
declare function createFileCommandRepository(prisma: any): {
|
|
362
|
-
create: ({ fileMeta, folder, translations,
|
|
363
|
-
update: ({ file, id, fileMeta, folder, translations,
|
|
363
|
+
create: ({ key, checksum, fileMeta, width, height, duration, folder, translations, }: CreateParams$2) => Promise<FileFull>;
|
|
364
|
+
update: ({ file, id, key, checksum, fileMeta, width, height, duration, folder, translations, }: UpdateParams$2) => Promise<File$1>;
|
|
364
365
|
softDelete: ({ id }: {
|
|
365
366
|
id: string;
|
|
366
367
|
}) => Promise<File$1>;
|
|
@@ -875,12 +876,17 @@ interface ActionContext {
|
|
|
875
876
|
cryptoService: ReturnType<typeof createCryptoService>;
|
|
876
877
|
argon2Service: ReturnType<typeof createArgon2Service>;
|
|
877
878
|
cookieService: ReturnType<typeof createCookieService>;
|
|
879
|
+
storageService: StorageService;
|
|
878
880
|
};
|
|
879
881
|
repositories: {
|
|
880
882
|
adminQueryRepository: ReturnType<typeof createAdminQueryRepository>;
|
|
881
883
|
adminCommandRepository: ReturnType<typeof createAdminCommandRepository>;
|
|
882
884
|
adminRefreshTokenQueryRepository: ReturnType<typeof createAdminRefreshTokenQueryRepository>;
|
|
883
885
|
adminRefreshTokenCommandRepository: ReturnType<typeof createAdminRefreshTokenCommandRepository>;
|
|
886
|
+
folderQueryRepository: ReturnType<typeof createFolderQueryRepository>;
|
|
887
|
+
folderCommandRepository: ReturnType<typeof createFolderCommandRepository>;
|
|
888
|
+
fileQueryRepository: ReturnType<typeof createFileQueryRepository>;
|
|
889
|
+
fileCommandRepository: ReturnType<typeof createFileCommandRepository>;
|
|
884
890
|
};
|
|
885
891
|
useCases: {
|
|
886
892
|
authUseCases: ReturnType<typeof createAuthUseCases>;
|
|
@@ -985,10 +991,10 @@ declare const adminCreateValidator: (schemas: ReturnType<typeof createSchemas>)
|
|
|
985
991
|
}>;
|
|
986
992
|
email: zod.ZodEmail;
|
|
987
993
|
password: zod.ZodString;
|
|
994
|
+
socialLinks: zod.ZodPipe<zod.ZodArray<zod.ZodPipe<zod.ZodTransform<{} | null | undefined, unknown>, zod.ZodNullable<zod.ZodURL>>>, zod.ZodTransform<string[], (string | null)[]>>;
|
|
988
995
|
avatarImage: zod.ZodNullable<zod.ZodObject<{
|
|
989
996
|
id: zod.ZodString;
|
|
990
997
|
}, zod_v4_core.$strip>>;
|
|
991
|
-
socialLinks: zod.ZodPipe<zod.ZodArray<zod.ZodPipe<zod.ZodTransform<{} | null | undefined, unknown>, zod.ZodNullable<zod.ZodURL>>>, zod.ZodTransform<string[], (string | null)[]>>;
|
|
992
998
|
translations: zod.ZodPipe<zod.ZodArray<zod.ZodObject<{
|
|
993
999
|
locale: zod.ZodString;
|
|
994
1000
|
name: zod.ZodNullable<zod.ZodString>;
|
|
@@ -1039,10 +1045,10 @@ declare const adminUpdateValidator: (schemas: ReturnType<typeof createSchemas>,
|
|
|
1039
1045
|
EDITOR: "EDITOR";
|
|
1040
1046
|
}>;
|
|
1041
1047
|
email: zod.ZodOptional<zod.ZodEmail>;
|
|
1048
|
+
socialLinks: zod.ZodPipe<zod.ZodArray<zod.ZodPipe<zod.ZodTransform<{} | null | undefined, unknown>, zod.ZodNullable<zod.ZodURL>>>, zod.ZodTransform<string[], (string | null)[]>>;
|
|
1042
1049
|
avatarImage: zod.ZodNullable<zod.ZodObject<{
|
|
1043
1050
|
id: zod.ZodString;
|
|
1044
1051
|
}, zod_v4_core.$strip>>;
|
|
1045
|
-
socialLinks: zod.ZodPipe<zod.ZodArray<zod.ZodPipe<zod.ZodTransform<{} | null | undefined, unknown>, zod.ZodNullable<zod.ZodURL>>>, zod.ZodTransform<string[], (string | null)[]>>;
|
|
1046
1052
|
translations: zod.ZodPipe<zod.ZodArray<zod.ZodObject<{
|
|
1047
1053
|
locale: zod.ZodString;
|
|
1048
1054
|
name: zod.ZodNullable<zod.ZodString>;
|
|
@@ -1117,6 +1123,155 @@ declare function createAdminRefreshTokenFindManyAction(ctx: ActionContext): ({ a
|
|
|
1117
1123
|
currentToken: AdminRefreshToken;
|
|
1118
1124
|
}>>;
|
|
1119
1125
|
|
|
1126
|
+
declare const fileCreateValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
|
|
1127
|
+
key: zod.ZodString;
|
|
1128
|
+
checksum: zod.ZodString;
|
|
1129
|
+
fileMeta: zod.ZodObject<{
|
|
1130
|
+
type: zod.ZodString;
|
|
1131
|
+
size: zod.ZodPipe<zod.ZodTransform<number | undefined, unknown>, zod.ZodNumber>;
|
|
1132
|
+
name: zod.ZodString;
|
|
1133
|
+
}, zod_v4_core.$strip>;
|
|
1134
|
+
width: zod.ZodOptional<zod.ZodNullable<zod.ZodPipe<zod.ZodTransform<number | undefined, unknown>, zod.ZodNumber>>>;
|
|
1135
|
+
height: zod.ZodOptional<zod.ZodNullable<zod.ZodPipe<zod.ZodTransform<number | undefined, unknown>, zod.ZodNumber>>>;
|
|
1136
|
+
duration: zod.ZodOptional<zod.ZodNullable<zod.ZodPipe<zod.ZodTransform<number | undefined, unknown>, zod.ZodNumber>>>;
|
|
1137
|
+
folder: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
|
|
1138
|
+
id: zod.ZodString;
|
|
1139
|
+
}, zod_v4_core.$strip>>>;
|
|
1140
|
+
folderKey: zod.ZodOptional<zod.ZodString>;
|
|
1141
|
+
translations: zod.ZodPipe<zod.ZodArray<zod.ZodObject<{
|
|
1142
|
+
locale: zod.ZodString;
|
|
1143
|
+
name: zod.ZodNullable<zod.ZodString>;
|
|
1144
|
+
alt: zod.ZodNullable<zod.ZodString>;
|
|
1145
|
+
}, zod_v4_core.$strip>>, zod.ZodTransform<{
|
|
1146
|
+
locale: string;
|
|
1147
|
+
name: string | null;
|
|
1148
|
+
alt: string | null;
|
|
1149
|
+
}[], {
|
|
1150
|
+
locale: string;
|
|
1151
|
+
name: string | null;
|
|
1152
|
+
alt: string | null;
|
|
1153
|
+
}[]>>;
|
|
1154
|
+
}, zod_v4_core.$strip>;
|
|
1155
|
+
|
|
1156
|
+
type FileCreateFormData = zod__default.infer<ReturnType<typeof fileCreateValidator>>;
|
|
1157
|
+
declare function createFileCreateAction(ctx: ActionContext): ({ formData, }: {
|
|
1158
|
+
formData: FileCreateFormData;
|
|
1159
|
+
}) => Promise<Result<{
|
|
1160
|
+
file: FileFull;
|
|
1161
|
+
}>>;
|
|
1162
|
+
|
|
1163
|
+
declare const fileCreateManyValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
|
|
1164
|
+
uploadResults: zod.ZodPipe<zod.ZodArray<zod.ZodObject<{
|
|
1165
|
+
key: zod.ZodString;
|
|
1166
|
+
checksum: zod.ZodString;
|
|
1167
|
+
fileMeta: zod.ZodObject<{
|
|
1168
|
+
type: zod.ZodString;
|
|
1169
|
+
size: zod.ZodPipe<zod.ZodTransform<number | undefined, unknown>, zod.ZodNumber>;
|
|
1170
|
+
name: zod.ZodString;
|
|
1171
|
+
}, zod_v4_core.$strip>;
|
|
1172
|
+
width: zod.ZodNullable<zod.ZodPipe<zod.ZodTransform<number | undefined, unknown>, zod.ZodNumber>>;
|
|
1173
|
+
height: zod.ZodNullable<zod.ZodPipe<zod.ZodTransform<number | undefined, unknown>, zod.ZodNumber>>;
|
|
1174
|
+
duration: zod.ZodNullable<zod.ZodPipe<zod.ZodTransform<number | undefined, unknown>, zod.ZodNumber>>;
|
|
1175
|
+
translations: zod.ZodPipe<zod.ZodArray<zod.ZodObject<{
|
|
1176
|
+
locale: zod.ZodString;
|
|
1177
|
+
name: zod.ZodNullable<zod.ZodString>;
|
|
1178
|
+
alt: zod.ZodNullable<zod.ZodString>;
|
|
1179
|
+
}, zod_v4_core.$strip>>, zod.ZodTransform<{
|
|
1180
|
+
locale: string;
|
|
1181
|
+
name: string | null;
|
|
1182
|
+
alt: string | null;
|
|
1183
|
+
}[], {
|
|
1184
|
+
locale: string;
|
|
1185
|
+
name: string | null;
|
|
1186
|
+
alt: string | null;
|
|
1187
|
+
}[]>>;
|
|
1188
|
+
}, zod_v4_core.$strip>>, zod.ZodTransform<{
|
|
1189
|
+
key: string;
|
|
1190
|
+
checksum: string;
|
|
1191
|
+
fileMeta: {
|
|
1192
|
+
type: string;
|
|
1193
|
+
size: number;
|
|
1194
|
+
name: string;
|
|
1195
|
+
};
|
|
1196
|
+
width: number | null;
|
|
1197
|
+
height: number | null;
|
|
1198
|
+
duration: number | null;
|
|
1199
|
+
translations: {
|
|
1200
|
+
locale: string;
|
|
1201
|
+
name: string | null;
|
|
1202
|
+
alt: string | null;
|
|
1203
|
+
}[];
|
|
1204
|
+
}[], {
|
|
1205
|
+
key: string;
|
|
1206
|
+
checksum: string;
|
|
1207
|
+
fileMeta: {
|
|
1208
|
+
type: string;
|
|
1209
|
+
size: number;
|
|
1210
|
+
name: string;
|
|
1211
|
+
};
|
|
1212
|
+
width: number | null;
|
|
1213
|
+
height: number | null;
|
|
1214
|
+
duration: number | null;
|
|
1215
|
+
translations: {
|
|
1216
|
+
locale: string;
|
|
1217
|
+
name: string | null;
|
|
1218
|
+
alt: string | null;
|
|
1219
|
+
}[];
|
|
1220
|
+
}[]>>;
|
|
1221
|
+
folder: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
|
|
1222
|
+
id: zod.ZodString;
|
|
1223
|
+
}, zod_v4_core.$strip>>>;
|
|
1224
|
+
}, zod_v4_core.$strip>;
|
|
1225
|
+
|
|
1226
|
+
type FileCreateManyFormData = zod__default.infer<ReturnType<typeof fileCreateManyValidator>>;
|
|
1227
|
+
declare function createFileCreateManyAction(ctx: ActionContext): ({ formData, }: {
|
|
1228
|
+
formData: FileCreateManyFormData;
|
|
1229
|
+
}) => Promise<Result<{
|
|
1230
|
+
count: number;
|
|
1231
|
+
}>>;
|
|
1232
|
+
|
|
1233
|
+
declare function createFilePurgeManyAction(ctx: ActionContext): ({ formData, }: {
|
|
1234
|
+
formData: {
|
|
1235
|
+
ids: string[];
|
|
1236
|
+
};
|
|
1237
|
+
}) => Promise<Result<void>>;
|
|
1238
|
+
|
|
1239
|
+
declare function createFileRestoreManyAction(ctx: ActionContext): ({ formData, }: {
|
|
1240
|
+
formData: {
|
|
1241
|
+
ids: string[];
|
|
1242
|
+
};
|
|
1243
|
+
}) => Promise<Result<void>>;
|
|
1244
|
+
|
|
1245
|
+
declare function createFileSoftDeleteAction(ctx: ActionContext): ({ id }: {
|
|
1246
|
+
id: string;
|
|
1247
|
+
}) => Promise<Result<void>>;
|
|
1248
|
+
|
|
1249
|
+
declare function createFileSoftDeleteManyAction(ctx: ActionContext): ({ formData, }: {
|
|
1250
|
+
formData: {
|
|
1251
|
+
ids: string[];
|
|
1252
|
+
};
|
|
1253
|
+
}) => Promise<Result<void>>;
|
|
1254
|
+
|
|
1255
|
+
declare function createFileFindFullAction(ctx: ActionContext): (params: {
|
|
1256
|
+
id: string;
|
|
1257
|
+
}) => Promise<Result<{
|
|
1258
|
+
file: FileFull;
|
|
1259
|
+
}>>;
|
|
1260
|
+
|
|
1261
|
+
declare function createFileFindListCardsAction(ctx: ActionContext): (params: {
|
|
1262
|
+
searchString?: string;
|
|
1263
|
+
type: FileType | null;
|
|
1264
|
+
isDeleted?: boolean;
|
|
1265
|
+
isLocked?: boolean | null;
|
|
1266
|
+
folderId?: string;
|
|
1267
|
+
fileIds?: string[];
|
|
1268
|
+
page: number;
|
|
1269
|
+
pageSize: number;
|
|
1270
|
+
}) => Promise<Result<{
|
|
1271
|
+
items: FileFull[];
|
|
1272
|
+
total: number;
|
|
1273
|
+
}>>;
|
|
1274
|
+
|
|
1120
1275
|
declare class ServerError extends Error {
|
|
1121
1276
|
readonly i18nKey?: string;
|
|
1122
1277
|
readonly statusCode?: number;
|
|
@@ -1135,4 +1290,4 @@ declare class ServerError extends Error {
|
|
|
1135
1290
|
static internalServerError(): ServerError;
|
|
1136
1291
|
}
|
|
1137
1292
|
|
|
1138
|
-
export { ADMIN_ORDER_BY, type ActionContext, type AdminCreateFormData, type AdminUpdateFormData, type ChangePasswordFormData, type EmailUnverifiedFormData, type ForgotPasswordFormData, ORDER_BY, POST_ORDER_BY, type RawCacheKey, type ResetPasswordFormData, ServerError, type SignInFormData, type VerifyEmailFormData, 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, 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 };
|
|
1293
|
+
export { ADMIN_ORDER_BY, type ActionContext, type AdminCreateFormData, type AdminUpdateFormData, type ChangePasswordFormData, type EmailUnverifiedFormData, type FileCreateFormData, type FileCreateManyFormData, type ForgotPasswordFormData, ORDER_BY, POST_ORDER_BY, type RawCacheKey, type ResetPasswordFormData, ServerError, type SignInFormData, type VerifyEmailFormData, 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, createFileSoftDeleteAction, 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 };
|
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,
|
|
@@ -2316,13 +2362,13 @@ var adminCreateValidator = (schemas) => schemas.z.object({
|
|
|
2316
2362
|
role: schemas.z.enum(Object.values(ADMIN_ROLES)),
|
|
2317
2363
|
email: schemas.email().unique({ table: "admins", column: "email" }),
|
|
2318
2364
|
password: schemas.password(),
|
|
2365
|
+
// better seo
|
|
2366
|
+
socialLinks: schemas.array(schemas.url()),
|
|
2319
2367
|
// ----------------------------------------------------------------------------
|
|
2320
2368
|
// relations
|
|
2321
2369
|
// ----------------------------------------------------------------------------
|
|
2322
2370
|
// File
|
|
2323
2371
|
avatarImage: schemas.z.object({ id: schemas.id().exist({ table: "files" }) }).nullable(),
|
|
2324
|
-
// better seo
|
|
2325
|
-
socialLinks: schemas.array(schemas.url()),
|
|
2326
2372
|
// ----------------------------------------------------------------------------
|
|
2327
2373
|
// translation
|
|
2328
2374
|
// ----------------------------------------------------------------------------
|
|
@@ -2361,11 +2407,22 @@ function createAdminCreateAction(ctx) {
|
|
|
2361
2407
|
return executeAction(
|
|
2362
2408
|
async (translator) => {
|
|
2363
2409
|
await authMiddleware.authenticate();
|
|
2364
|
-
const {
|
|
2410
|
+
const {
|
|
2411
|
+
role,
|
|
2412
|
+
email,
|
|
2413
|
+
password,
|
|
2414
|
+
socialLinks,
|
|
2415
|
+
avatarImage,
|
|
2416
|
+
translations
|
|
2417
|
+
} = await adminCreateValidator(schemas).parseAsync(formData);
|
|
2365
2418
|
const passwordHash = await argon2Service.hash(password);
|
|
2366
2419
|
const created = await adminCommandRepository.create({
|
|
2367
|
-
|
|
2368
|
-
|
|
2420
|
+
role,
|
|
2421
|
+
email,
|
|
2422
|
+
passwordHash,
|
|
2423
|
+
socialLinks,
|
|
2424
|
+
avatarImage,
|
|
2425
|
+
translations
|
|
2369
2426
|
});
|
|
2370
2427
|
void emailVerificationEmail.send({ translator, admin: created });
|
|
2371
2428
|
return {
|
|
@@ -2387,13 +2444,13 @@ var adminUpdateValidator = (schemas, id) => schemas.z.object({
|
|
|
2387
2444
|
column: "email",
|
|
2388
2445
|
excludeSelf: { name: "id", value: id }
|
|
2389
2446
|
}).optional(),
|
|
2447
|
+
// better seo
|
|
2448
|
+
socialLinks: schemas.array(schemas.url()),
|
|
2390
2449
|
// ----------------------------------------------------------------------------
|
|
2391
2450
|
// relations
|
|
2392
2451
|
// ----------------------------------------------------------------------------
|
|
2393
2452
|
// File
|
|
2394
2453
|
avatarImage: schemas.z.object({ id: schemas.id().exist({ table: "files" }) }).nullable(),
|
|
2395
|
-
// better seo
|
|
2396
|
-
socialLinks: schemas.array(schemas.url()),
|
|
2397
2454
|
// ----------------------------------------------------------------------------
|
|
2398
2455
|
// translation
|
|
2399
2456
|
// ----------------------------------------------------------------------------
|
|
@@ -2437,10 +2494,9 @@ function createAdminUpdateAction(ctx) {
|
|
|
2437
2494
|
const isSelf = currentAdmin.id === targetAdmin.id;
|
|
2438
2495
|
const canModifyOthers = currentAdmin.role === ADMIN_ROLES.SUPER_ADMIN;
|
|
2439
2496
|
if (!isSelf && !canModifyOthers) throw ServerError.forbidden();
|
|
2440
|
-
const { email,
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
).parseAsync(formData);
|
|
2497
|
+
const { role, email, socialLinks, avatarImage, translations } = await adminUpdateValidator(schemas, targetAdmin.id).parseAsync(
|
|
2498
|
+
formData
|
|
2499
|
+
);
|
|
2444
2500
|
const isUpdatingEmail = email !== targetAdmin.email;
|
|
2445
2501
|
if (isUpdatingEmail) {
|
|
2446
2502
|
void emailVerificationEmail.send({
|
|
@@ -2451,8 +2507,11 @@ function createAdminUpdateAction(ctx) {
|
|
|
2451
2507
|
}
|
|
2452
2508
|
const updatedAdmin = await adminCommandRepository.update({
|
|
2453
2509
|
id: targetAdmin.id,
|
|
2454
|
-
|
|
2455
|
-
...email ? { email } : {},
|
|
2510
|
+
role,
|
|
2511
|
+
...email !== void 0 ? { email } : {},
|
|
2512
|
+
socialLinks,
|
|
2513
|
+
avatarImage,
|
|
2514
|
+
translations,
|
|
2456
2515
|
emailVerifiedAt: !isUpdatingEmail ? targetAdmin.emailVerifiedAt : null
|
|
2457
2516
|
// Clear emailVerifiedAt if updating a new email
|
|
2458
2517
|
});
|
|
@@ -2625,6 +2684,513 @@ function createAdminRefreshTokenFindManyAction(ctx) {
|
|
|
2625
2684
|
};
|
|
2626
2685
|
}
|
|
2627
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/create-file-soft-delete-action.ts
|
|
3069
|
+
function createFileSoftDeleteAction(ctx) {
|
|
3070
|
+
const {
|
|
3071
|
+
repositories: { fileQueryRepository, fileCommandRepository },
|
|
3072
|
+
middlewares: { authMiddleware },
|
|
3073
|
+
action: { executeAction }
|
|
3074
|
+
} = ctx;
|
|
3075
|
+
return async function fileSoftDeleteAction({ id }) {
|
|
3076
|
+
return executeAction(
|
|
3077
|
+
async () => {
|
|
3078
|
+
await authMiddleware.authenticate();
|
|
3079
|
+
const foundFile = await fileQueryRepository.findFull({ id });
|
|
3080
|
+
if (!foundFile) throw ServerError.notFound();
|
|
3081
|
+
if (isFileLocked(foundFile)) {
|
|
3082
|
+
throw new ServerError({ i18nKey: "error.files-destroy-is-locked" });
|
|
3083
|
+
}
|
|
3084
|
+
await fileCommandRepository.softDelete({ id });
|
|
3085
|
+
return {
|
|
3086
|
+
i18nKey: "ok.destroy-ok"
|
|
3087
|
+
};
|
|
3088
|
+
},
|
|
3089
|
+
{ type: "command" }
|
|
3090
|
+
);
|
|
3091
|
+
};
|
|
3092
|
+
}
|
|
3093
|
+
|
|
3094
|
+
// src/server/interfaces/actions/resources/file/commands/soft-delete-many/file-soft-delete-many-validator.ts
|
|
3095
|
+
var fileSoftDeleteManyValidator = (schemas) => schemas.z.object({
|
|
3096
|
+
ids: schemas.array(schemas.id().exist({ table: "files", column: "id" }))
|
|
3097
|
+
});
|
|
3098
|
+
|
|
3099
|
+
// src/server/interfaces/actions/resources/file/commands/soft-delete-many/create-file-soft-delete-many-action.ts
|
|
3100
|
+
function createFileSoftDeleteManyAction(ctx) {
|
|
3101
|
+
const {
|
|
3102
|
+
repositories: { fileQueryRepository, fileCommandRepository },
|
|
3103
|
+
middlewares: { authMiddleware },
|
|
3104
|
+
action: { executeAction },
|
|
3105
|
+
schemas
|
|
3106
|
+
} = ctx;
|
|
3107
|
+
return async function fileSoftDeleteManyAction({
|
|
3108
|
+
formData
|
|
3109
|
+
}) {
|
|
3110
|
+
return executeAction(
|
|
3111
|
+
async () => {
|
|
3112
|
+
await authMiddleware.authenticate();
|
|
3113
|
+
const { ids: ids2 } = await fileSoftDeleteManyValidator(schemas).parseAsync(formData);
|
|
3114
|
+
const foundFiles = await fileQueryRepository.findManyByIds({ ids: ids2 });
|
|
3115
|
+
if (foundFiles.length === 0) throw ServerError.notFound();
|
|
3116
|
+
const targetIds = foundFiles.filter((f) => !f.isLocked).map((f) => f.id);
|
|
3117
|
+
const hasLockedFile = ids2.length !== targetIds.length;
|
|
3118
|
+
const count = await fileCommandRepository.softDeleteMany({
|
|
3119
|
+
ids: targetIds
|
|
3120
|
+
});
|
|
3121
|
+
if (count === 0) {
|
|
3122
|
+
throw new ServerError({ i18nKey: "error.files-batch-destroy-no" });
|
|
3123
|
+
}
|
|
3124
|
+
return {
|
|
3125
|
+
i18nKey: hasLockedFile ? "ok.destroy-ok" : "ok.files-batch-destroy-has-locked"
|
|
3126
|
+
};
|
|
3127
|
+
},
|
|
3128
|
+
{ type: "command" }
|
|
3129
|
+
);
|
|
3130
|
+
};
|
|
3131
|
+
}
|
|
3132
|
+
|
|
3133
|
+
// src/server/interfaces/actions/resources/file/querires/create-file-find-full-action.ts
|
|
3134
|
+
function createFileFindFullAction(ctx) {
|
|
3135
|
+
const {
|
|
3136
|
+
repositories: { fileQueryRepository },
|
|
3137
|
+
action: { executeAction }
|
|
3138
|
+
} = ctx;
|
|
3139
|
+
return async function FileFindFullAction(params) {
|
|
3140
|
+
return executeAction(
|
|
3141
|
+
async () => {
|
|
3142
|
+
const file = await fileQueryRepository.findFull(params);
|
|
3143
|
+
if (!file) throw ServerError.notFound();
|
|
3144
|
+
return {
|
|
3145
|
+
data: { file }
|
|
3146
|
+
};
|
|
3147
|
+
},
|
|
3148
|
+
{
|
|
3149
|
+
type: "query",
|
|
3150
|
+
key: ["file", "findFullAction", params.id]
|
|
3151
|
+
}
|
|
3152
|
+
);
|
|
3153
|
+
};
|
|
3154
|
+
}
|
|
3155
|
+
|
|
3156
|
+
// src/server/interfaces/actions/resources/file/querires/create-file-find-list-cards-action.ts
|
|
3157
|
+
function createFileFindListCardsAction(ctx) {
|
|
3158
|
+
const {
|
|
3159
|
+
repositories: { fileQueryRepository },
|
|
3160
|
+
middlewares: { authMiddleware },
|
|
3161
|
+
action: { executeAction }
|
|
3162
|
+
} = ctx;
|
|
3163
|
+
return async function fileFindFullAction(params) {
|
|
3164
|
+
return executeAction(
|
|
3165
|
+
async ({ locale }) => {
|
|
3166
|
+
await authMiddleware.authenticate();
|
|
3167
|
+
const { items, total } = await fileQueryRepository.findListCards({
|
|
3168
|
+
...params,
|
|
3169
|
+
locale
|
|
3170
|
+
});
|
|
3171
|
+
return {
|
|
3172
|
+
data: { items, total }
|
|
3173
|
+
};
|
|
3174
|
+
},
|
|
3175
|
+
{
|
|
3176
|
+
type: "query",
|
|
3177
|
+
key: [
|
|
3178
|
+
"file",
|
|
3179
|
+
"findListCardsAction",
|
|
3180
|
+
params.searchString,
|
|
3181
|
+
params.type,
|
|
3182
|
+
params.isDeleted,
|
|
3183
|
+
params.isLocked,
|
|
3184
|
+
params.folderId,
|
|
3185
|
+
...params.fileIds ?? [],
|
|
3186
|
+
params.page,
|
|
3187
|
+
params.pageSize
|
|
3188
|
+
]
|
|
3189
|
+
}
|
|
3190
|
+
);
|
|
3191
|
+
};
|
|
3192
|
+
}
|
|
3193
|
+
|
|
2628
3194
|
// src/server/applications/auth/create-auth-use-cases.ts
|
|
2629
3195
|
function createAuthUseCases({
|
|
2630
3196
|
prisma,
|
|
@@ -2804,4 +3370,4 @@ function createForgotPasswordEmail({
|
|
|
2804
3370
|
};
|
|
2805
3371
|
}
|
|
2806
3372
|
|
|
2807
|
-
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, 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 };
|
|
3373
|
+
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, createFileSoftDeleteAction, 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 };
|