denwa-web-shared 1.0.27 → 1.0.29
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.cjs.js
CHANGED
|
@@ -6497,25 +6497,68 @@ function refine(fn, _params = {}) {
|
|
|
6497
6497
|
function superRefine(fn) {
|
|
6498
6498
|
return _superRefine(fn);
|
|
6499
6499
|
}
|
|
6500
|
+
const responseSchema = object({
|
|
6501
|
+
statusCode: number().optional(),
|
|
6502
|
+
message: string().optional().nullable(),
|
|
6503
|
+
messages: string().array().optional().nullable(),
|
|
6504
|
+
data: any().optional().nullable(),
|
|
6505
|
+
error: object({
|
|
6506
|
+
statusCode: number(),
|
|
6507
|
+
message: string().optional().nullable(),
|
|
6508
|
+
messages: string().array().optional().nullable()
|
|
6509
|
+
}).optional().nullable(),
|
|
6510
|
+
response: any().optional().nullable()
|
|
6511
|
+
});
|
|
6512
|
+
const serverImageSchema = object({
|
|
6513
|
+
altRU: string().optional().nullable(),
|
|
6514
|
+
altEN: string().optional().nullable(),
|
|
6515
|
+
altAR: string().optional().nullable(),
|
|
6516
|
+
name: string(),
|
|
6517
|
+
originalFileExtension: string(),
|
|
6518
|
+
fileExtensions: string().array(),
|
|
6519
|
+
prefixes: string().array(),
|
|
6520
|
+
folder: string().optional()
|
|
6521
|
+
});
|
|
6522
|
+
const serverFileSchema = object({
|
|
6523
|
+
name: string(),
|
|
6524
|
+
fullName: string(),
|
|
6525
|
+
extension: string(),
|
|
6526
|
+
entityId: string().uuid(),
|
|
6527
|
+
fullPathExample: string(),
|
|
6528
|
+
folder: string().optional()
|
|
6529
|
+
});
|
|
6500
6530
|
const getUploadImageUrl = ({
|
|
6501
6531
|
name,
|
|
6502
6532
|
extension,
|
|
6503
6533
|
entityId,
|
|
6504
6534
|
prefixe,
|
|
6505
6535
|
bucketFolder,
|
|
6536
|
+
folder,
|
|
6537
|
+
uploadUrl
|
|
6538
|
+
}) => {
|
|
6539
|
+
return `${uploadUrl}/${bucketFolder}/${entityId}${folder ? `/${folder}` : ""}/${name}-${prefixe}.${extension}`;
|
|
6540
|
+
};
|
|
6541
|
+
const getUploadFileUrl = ({
|
|
6542
|
+
fullName,
|
|
6543
|
+
entityId,
|
|
6544
|
+
folder,
|
|
6545
|
+
bucketFolder,
|
|
6506
6546
|
uploadUrl
|
|
6507
6547
|
}) => {
|
|
6508
|
-
return `${uploadUrl}/${bucketFolder}/${entityId}
|
|
6548
|
+
return `${uploadUrl}/${bucketFolder}/${entityId}${folder ? `/${folder}` : ""}/${fullName}`;
|
|
6509
6549
|
};
|
|
6510
|
-
const checkCorrectImageObject = (
|
|
6550
|
+
const checkCorrectImageObject = (object2, getError) => {
|
|
6511
6551
|
try {
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6552
|
+
serverImageSchema.parse(object2);
|
|
6553
|
+
return true;
|
|
6554
|
+
} catch (error) {
|
|
6555
|
+
getError({ error });
|
|
6556
|
+
return false;
|
|
6557
|
+
}
|
|
6558
|
+
};
|
|
6559
|
+
const checkCorrectFileObject = (object2, getError) => {
|
|
6560
|
+
try {
|
|
6561
|
+
serverFileSchema.parse(object2);
|
|
6519
6562
|
return true;
|
|
6520
6563
|
} catch (error) {
|
|
6521
6564
|
getError({ error });
|
|
@@ -6678,18 +6721,6 @@ const getImagePrefix = (prefixes, type) => {
|
|
|
6678
6721
|
return prefixes[5] ?? "";
|
|
6679
6722
|
}
|
|
6680
6723
|
};
|
|
6681
|
-
const responseSchema = object({
|
|
6682
|
-
statusCode: number().optional(),
|
|
6683
|
-
message: string().optional().nullable(),
|
|
6684
|
-
messages: string().array().optional().nullable(),
|
|
6685
|
-
data: any().optional().nullable(),
|
|
6686
|
-
error: object({
|
|
6687
|
-
statusCode: number(),
|
|
6688
|
-
message: string().optional().nullable(),
|
|
6689
|
-
messages: string().array().optional().nullable()
|
|
6690
|
-
}).optional().nullable(),
|
|
6691
|
-
response: any().optional().nullable()
|
|
6692
|
-
});
|
|
6693
6724
|
const BasePicture = ({
|
|
6694
6725
|
imgProps,
|
|
6695
6726
|
data,
|
|
@@ -6770,6 +6801,7 @@ exports.BasePicture = BasePicture;
|
|
|
6770
6801
|
exports.THEME = THEME;
|
|
6771
6802
|
exports.TIME = TIME;
|
|
6772
6803
|
exports.arrayToKeyValueObject = arrayToKeyValueObject;
|
|
6804
|
+
exports.checkCorrectFileObject = checkCorrectFileObject;
|
|
6773
6805
|
exports.checkCorrectImageObject = checkCorrectImageObject;
|
|
6774
6806
|
exports.cn = cn;
|
|
6775
6807
|
exports.convertPhoneMask = convertPhoneMask;
|
|
@@ -6778,6 +6810,7 @@ exports.getByKey = getByKey;
|
|
|
6778
6810
|
exports.getImagePrefix = getImagePrefix;
|
|
6779
6811
|
exports.getNumberFormatter = getNumberFormatter;
|
|
6780
6812
|
exports.getSubdomain = getSubdomain;
|
|
6813
|
+
exports.getUploadFileUrl = getUploadFileUrl;
|
|
6781
6814
|
exports.getUploadImageUrl = getUploadImageUrl;
|
|
6782
6815
|
exports.parseStringToKeyValue = parseStringToKeyValue;
|
|
6783
6816
|
exports.prepareColor = prepareColor;
|
|
@@ -6785,4 +6818,6 @@ exports.prepareLocalMetaData = prepareLocalMetaData;
|
|
|
6785
6818
|
exports.preparePageParam = preparePageParam;
|
|
6786
6819
|
exports.prepareServerImages = prepareServerImages;
|
|
6787
6820
|
exports.responseSchema = responseSchema;
|
|
6821
|
+
exports.serverFileSchema = serverFileSchema;
|
|
6822
|
+
exports.serverImageSchema = serverImageSchema;
|
|
6788
6823
|
exports.updateTextByTemplate = updateTextByTemplate;
|
package/dist/server/index.es.js
CHANGED
|
@@ -6495,25 +6495,68 @@ function refine(fn, _params = {}) {
|
|
|
6495
6495
|
function superRefine(fn) {
|
|
6496
6496
|
return _superRefine(fn);
|
|
6497
6497
|
}
|
|
6498
|
+
const responseSchema = object({
|
|
6499
|
+
statusCode: number().optional(),
|
|
6500
|
+
message: string().optional().nullable(),
|
|
6501
|
+
messages: string().array().optional().nullable(),
|
|
6502
|
+
data: any().optional().nullable(),
|
|
6503
|
+
error: object({
|
|
6504
|
+
statusCode: number(),
|
|
6505
|
+
message: string().optional().nullable(),
|
|
6506
|
+
messages: string().array().optional().nullable()
|
|
6507
|
+
}).optional().nullable(),
|
|
6508
|
+
response: any().optional().nullable()
|
|
6509
|
+
});
|
|
6510
|
+
const serverImageSchema = object({
|
|
6511
|
+
altRU: string().optional().nullable(),
|
|
6512
|
+
altEN: string().optional().nullable(),
|
|
6513
|
+
altAR: string().optional().nullable(),
|
|
6514
|
+
name: string(),
|
|
6515
|
+
originalFileExtension: string(),
|
|
6516
|
+
fileExtensions: string().array(),
|
|
6517
|
+
prefixes: string().array(),
|
|
6518
|
+
folder: string().optional()
|
|
6519
|
+
});
|
|
6520
|
+
const serverFileSchema = object({
|
|
6521
|
+
name: string(),
|
|
6522
|
+
fullName: string(),
|
|
6523
|
+
extension: string(),
|
|
6524
|
+
entityId: string().uuid(),
|
|
6525
|
+
fullPathExample: string(),
|
|
6526
|
+
folder: string().optional()
|
|
6527
|
+
});
|
|
6498
6528
|
const getUploadImageUrl = ({
|
|
6499
6529
|
name,
|
|
6500
6530
|
extension,
|
|
6501
6531
|
entityId,
|
|
6502
6532
|
prefixe,
|
|
6503
6533
|
bucketFolder,
|
|
6534
|
+
folder,
|
|
6535
|
+
uploadUrl
|
|
6536
|
+
}) => {
|
|
6537
|
+
return `${uploadUrl}/${bucketFolder}/${entityId}${folder ? `/${folder}` : ""}/${name}-${prefixe}.${extension}`;
|
|
6538
|
+
};
|
|
6539
|
+
const getUploadFileUrl = ({
|
|
6540
|
+
fullName,
|
|
6541
|
+
entityId,
|
|
6542
|
+
folder,
|
|
6543
|
+
bucketFolder,
|
|
6504
6544
|
uploadUrl
|
|
6505
6545
|
}) => {
|
|
6506
|
-
return `${uploadUrl}/${bucketFolder}/${entityId}
|
|
6546
|
+
return `${uploadUrl}/${bucketFolder}/${entityId}${folder ? `/${folder}` : ""}/${fullName}`;
|
|
6507
6547
|
};
|
|
6508
|
-
const checkCorrectImageObject = (
|
|
6548
|
+
const checkCorrectImageObject = (object2, getError) => {
|
|
6509
6549
|
try {
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6550
|
+
serverImageSchema.parse(object2);
|
|
6551
|
+
return true;
|
|
6552
|
+
} catch (error) {
|
|
6553
|
+
getError({ error });
|
|
6554
|
+
return false;
|
|
6555
|
+
}
|
|
6556
|
+
};
|
|
6557
|
+
const checkCorrectFileObject = (object2, getError) => {
|
|
6558
|
+
try {
|
|
6559
|
+
serverFileSchema.parse(object2);
|
|
6517
6560
|
return true;
|
|
6518
6561
|
} catch (error) {
|
|
6519
6562
|
getError({ error });
|
|
@@ -6676,18 +6719,6 @@ const getImagePrefix = (prefixes, type) => {
|
|
|
6676
6719
|
return prefixes[5] ?? "";
|
|
6677
6720
|
}
|
|
6678
6721
|
};
|
|
6679
|
-
const responseSchema = object({
|
|
6680
|
-
statusCode: number().optional(),
|
|
6681
|
-
message: string().optional().nullable(),
|
|
6682
|
-
messages: string().array().optional().nullable(),
|
|
6683
|
-
data: any().optional().nullable(),
|
|
6684
|
-
error: object({
|
|
6685
|
-
statusCode: number(),
|
|
6686
|
-
message: string().optional().nullable(),
|
|
6687
|
-
messages: string().array().optional().nullable()
|
|
6688
|
-
}).optional().nullable(),
|
|
6689
|
-
response: any().optional().nullable()
|
|
6690
|
-
});
|
|
6691
6722
|
const BasePicture = ({
|
|
6692
6723
|
imgProps,
|
|
6693
6724
|
data,
|
|
@@ -6769,6 +6800,7 @@ export {
|
|
|
6769
6800
|
THEME,
|
|
6770
6801
|
TIME,
|
|
6771
6802
|
arrayToKeyValueObject,
|
|
6803
|
+
checkCorrectFileObject,
|
|
6772
6804
|
checkCorrectImageObject,
|
|
6773
6805
|
cn,
|
|
6774
6806
|
convertPhoneMask,
|
|
@@ -6777,6 +6809,7 @@ export {
|
|
|
6777
6809
|
getImagePrefix,
|
|
6778
6810
|
getNumberFormatter,
|
|
6779
6811
|
getSubdomain,
|
|
6812
|
+
getUploadFileUrl,
|
|
6780
6813
|
getUploadImageUrl,
|
|
6781
6814
|
parseStringToKeyValue,
|
|
6782
6815
|
prepareColor,
|
|
@@ -6784,5 +6817,7 @@ export {
|
|
|
6784
6817
|
preparePageParam,
|
|
6785
6818
|
prepareServerImages,
|
|
6786
6819
|
responseSchema,
|
|
6820
|
+
serverFileSchema,
|
|
6821
|
+
serverImageSchema,
|
|
6787
6822
|
updateTextByTemplate
|
|
6788
6823
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IPreparedServerImage, IServerImage } from '../types';
|
|
1
|
+
import { GetErrorType, IPreparedServerImage, IServerFile, IServerImage } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* @description Создает url картинки
|
|
4
4
|
* @param {string} name - название картинки
|
|
@@ -7,26 +7,47 @@ import { IPreparedServerImage, IServerImage } from '../types';
|
|
|
7
7
|
* @param {string} bucketName - название бакета картинки
|
|
8
8
|
* @param {string} prefixe - префикс файла
|
|
9
9
|
* @param {string} uploadUrl - url бакета
|
|
10
|
+
* @param {string | undefined} folder - подпапка
|
|
10
11
|
* @param bucketFolder - enum с папкой бакета
|
|
11
12
|
* @response Возвращает url
|
|
12
13
|
*/
|
|
13
|
-
export declare const getUploadImageUrl: <T>({ name, extension, entityId, prefixe, bucketFolder, uploadUrl, }: {
|
|
14
|
+
export declare const getUploadImageUrl: <T>({ name, extension, entityId, prefixe, bucketFolder, folder, uploadUrl, }: {
|
|
14
15
|
name: string;
|
|
15
16
|
extension: string;
|
|
16
17
|
entityId: string;
|
|
17
18
|
prefixe: string;
|
|
18
19
|
uploadUrl: string;
|
|
20
|
+
folder?: string;
|
|
21
|
+
bucketFolder: T;
|
|
22
|
+
}) => string;
|
|
23
|
+
/**
|
|
24
|
+
* @description Создает url файла
|
|
25
|
+
* @param { string } fullName - название файла
|
|
26
|
+
* @param { string } entityId - id сущности
|
|
27
|
+
* @param { string | undefined } folder - название подпапки
|
|
28
|
+
* @param { string } uploadUrl - url бакета
|
|
29
|
+
* @param bucketFolder - enum с папкой бакета
|
|
30
|
+
* @response Возвращает url
|
|
31
|
+
*/
|
|
32
|
+
export declare const getUploadFileUrl: <T>({ fullName, entityId, folder, bucketFolder, uploadUrl, }: {
|
|
33
|
+
fullName: string;
|
|
34
|
+
entityId: string;
|
|
35
|
+
folder?: string;
|
|
36
|
+
uploadUrl: string;
|
|
19
37
|
bucketFolder: T;
|
|
20
38
|
}) => string;
|
|
21
39
|
/**
|
|
22
40
|
* @description Проверяет валидность объекта картинки по схеме
|
|
23
41
|
* @param {object} object - объект с информацией о картинке
|
|
24
|
-
* @param getError - функция обработки ошибок
|
|
25
42
|
* @response Возвращает true/false
|
|
26
43
|
*/
|
|
27
|
-
export declare const checkCorrectImageObject: (object: IServerImage, getError:
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
export declare const checkCorrectImageObject: (object: IServerImage, getError: GetErrorType) => boolean;
|
|
45
|
+
/**
|
|
46
|
+
* @description Проверяет валидность объекта файла по схеме
|
|
47
|
+
* @param {object} object - объект с информацией о файле
|
|
48
|
+
* @response Возвращает true/false
|
|
49
|
+
*/
|
|
50
|
+
export declare const checkCorrectFileObject: (object: IServerFile, getError: GetErrorType) => boolean;
|
|
30
51
|
/**
|
|
31
52
|
* @description Преобразует фотографии с сервера в формат для работы
|
|
32
53
|
* @param {string | undefined | null} images - json stringify строка с информацией
|
|
@@ -39,8 +60,6 @@ export declare const prepareServerImages: <T>({ images, bucketFolder, uploadUrl,
|
|
|
39
60
|
images: string | undefined | null;
|
|
40
61
|
bucketFolder: T;
|
|
41
62
|
uploadUrl: string;
|
|
42
|
-
getError:
|
|
43
|
-
error: unknown;
|
|
44
|
-
}) => void;
|
|
63
|
+
getError: GetErrorType;
|
|
45
64
|
}) => IPreparedServerImage[];
|
|
46
65
|
export declare const getImagePrefix: (prefixes: string[], type: "original" | "0.25hd" | "0.5hd" | "1hd" | "2hd" | "4hd") => string;
|
|
@@ -11,3 +11,21 @@ export declare const responseSchema: z.ZodObject<{
|
|
|
11
11
|
}, z.core.$strip>>>;
|
|
12
12
|
response: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
|
|
13
13
|
}, z.core.$strip>;
|
|
14
|
+
export declare const serverImageSchema: z.ZodObject<{
|
|
15
|
+
altRU: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
16
|
+
altEN: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
17
|
+
altAR: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
18
|
+
name: z.ZodString;
|
|
19
|
+
originalFileExtension: z.ZodString;
|
|
20
|
+
fileExtensions: z.ZodArray<z.ZodString>;
|
|
21
|
+
prefixes: z.ZodArray<z.ZodString>;
|
|
22
|
+
folder: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export declare const serverFileSchema: z.ZodObject<{
|
|
25
|
+
name: z.ZodString;
|
|
26
|
+
fullName: z.ZodString;
|
|
27
|
+
extension: z.ZodString;
|
|
28
|
+
entityId: z.ZodString;
|
|
29
|
+
fullPathExample: z.ZodString;
|
|
30
|
+
folder: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>;
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
export interface IServerImage {
|
|
2
2
|
altRU?: string;
|
|
3
3
|
altEN?: string;
|
|
4
|
+
altAR?: string;
|
|
4
5
|
name: string;
|
|
5
6
|
originalFileExtension: string;
|
|
6
7
|
entityId: string;
|
|
7
8
|
fullPathExample: string;
|
|
9
|
+
folder?: string;
|
|
8
10
|
prefixes: string[];
|
|
9
11
|
fileExtensions: string[];
|
|
10
12
|
}
|
|
13
|
+
export interface IServerFile {
|
|
14
|
+
name: string;
|
|
15
|
+
fullName: string;
|
|
16
|
+
extension: string;
|
|
17
|
+
entityId: string;
|
|
18
|
+
fullPathExample: string;
|
|
19
|
+
folder?: string;
|
|
20
|
+
}
|
|
11
21
|
export interface IPreparedServerImage {
|
|
12
22
|
image1x: string;
|
|
13
23
|
image2x: string;
|
|
@@ -23,6 +33,7 @@ export interface IPreparedServerImage {
|
|
|
23
33
|
mobileImage2xAvif?: string;
|
|
24
34
|
altRU?: string;
|
|
25
35
|
altEN?: string;
|
|
36
|
+
altAR?: string;
|
|
26
37
|
type: ImageType;
|
|
27
38
|
}
|
|
28
39
|
export type ImageType = 'image/png' | 'image/jpeg';
|
|
@@ -44,3 +55,7 @@ export interface PaginationResult {
|
|
|
44
55
|
firstPage?: PaginationButton;
|
|
45
56
|
lastPage?: PaginationButton;
|
|
46
57
|
}
|
|
58
|
+
export type GetErrorType = ({ error, message }: {
|
|
59
|
+
error?: unknown;
|
|
60
|
+
message?: string;
|
|
61
|
+
}) => void;
|