denwa-web-shared 1.0.26 → 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.
@@ -77,6 +77,7 @@ const updateTextByTemplate = ({
77
77
  SUBDOMAIN_NAME,
78
78
  SUBDOMAIN_MASK
79
79
  }) => {
80
+ if (!subdomain || !SUBDOMAIN_NAME || !SUBDOMAIN_MASK) return text;
80
81
  const key = SUBDOMAIN_NAME[subdomain];
81
82
  if (!subdomain || !key) return text;
82
83
  const subdomainData = getByKey(SUBDOMAIN_NAME, subdomain);
@@ -6496,25 +6497,68 @@ function refine(fn, _params = {}) {
6496
6497
  function superRefine(fn) {
6497
6498
  return _superRefine(fn);
6498
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
+ });
6499
6530
  const getUploadImageUrl = ({
6500
6531
  name,
6501
6532
  extension,
6502
6533
  entityId,
6503
6534
  prefixe,
6504
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,
6505
6546
  uploadUrl
6506
6547
  }) => {
6507
- return `${uploadUrl}/${bucketFolder}/${entityId}/${name}-${prefixe}.${extension}`;
6548
+ return `${uploadUrl}/${bucketFolder}/${entityId}${folder ? `/${folder}` : ""}/${fullName}`;
6508
6549
  };
6509
- const checkCorrectImageObject = (object$1, getError) => {
6550
+ const checkCorrectImageObject = (object2, getError) => {
6510
6551
  try {
6511
- object({
6512
- altRU: string().optional().nullable(),
6513
- altEN: string().optional().nullable(),
6514
- name: string(),
6515
- originalFileExtension: string(),
6516
- fileExtensions: string().array()
6517
- }).parse(object$1);
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);
6518
6562
  return true;
6519
6563
  } catch (error) {
6520
6564
  getError({ error });
@@ -6677,18 +6721,6 @@ const getImagePrefix = (prefixes, type) => {
6677
6721
  return prefixes[5] ?? "";
6678
6722
  }
6679
6723
  };
6680
- const responseSchema = object({
6681
- statusCode: number().optional(),
6682
- message: string().optional().nullable(),
6683
- messages: string().array().optional().nullable(),
6684
- data: any().optional().nullable(),
6685
- error: object({
6686
- statusCode: number(),
6687
- message: string().optional().nullable(),
6688
- messages: string().array().optional().nullable()
6689
- }).optional().nullable(),
6690
- response: any().optional().nullable()
6691
- });
6692
6724
  const BasePicture = ({
6693
6725
  imgProps,
6694
6726
  data,
@@ -6769,6 +6801,7 @@ exports.BasePicture = BasePicture;
6769
6801
  exports.THEME = THEME;
6770
6802
  exports.TIME = TIME;
6771
6803
  exports.arrayToKeyValueObject = arrayToKeyValueObject;
6804
+ exports.checkCorrectFileObject = checkCorrectFileObject;
6772
6805
  exports.checkCorrectImageObject = checkCorrectImageObject;
6773
6806
  exports.cn = cn;
6774
6807
  exports.convertPhoneMask = convertPhoneMask;
@@ -6777,6 +6810,7 @@ exports.getByKey = getByKey;
6777
6810
  exports.getImagePrefix = getImagePrefix;
6778
6811
  exports.getNumberFormatter = getNumberFormatter;
6779
6812
  exports.getSubdomain = getSubdomain;
6813
+ exports.getUploadFileUrl = getUploadFileUrl;
6780
6814
  exports.getUploadImageUrl = getUploadImageUrl;
6781
6815
  exports.parseStringToKeyValue = parseStringToKeyValue;
6782
6816
  exports.prepareColor = prepareColor;
@@ -6784,4 +6818,6 @@ exports.prepareLocalMetaData = prepareLocalMetaData;
6784
6818
  exports.preparePageParam = preparePageParam;
6785
6819
  exports.prepareServerImages = prepareServerImages;
6786
6820
  exports.responseSchema = responseSchema;
6821
+ exports.serverFileSchema = serverFileSchema;
6822
+ exports.serverImageSchema = serverImageSchema;
6787
6823
  exports.updateTextByTemplate = updateTextByTemplate;
@@ -75,6 +75,7 @@ const updateTextByTemplate = ({
75
75
  SUBDOMAIN_NAME,
76
76
  SUBDOMAIN_MASK
77
77
  }) => {
78
+ if (!subdomain || !SUBDOMAIN_NAME || !SUBDOMAIN_MASK) return text;
78
79
  const key = SUBDOMAIN_NAME[subdomain];
79
80
  if (!subdomain || !key) return text;
80
81
  const subdomainData = getByKey(SUBDOMAIN_NAME, subdomain);
@@ -6494,25 +6495,68 @@ function refine(fn, _params = {}) {
6494
6495
  function superRefine(fn) {
6495
6496
  return _superRefine(fn);
6496
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
+ });
6497
6528
  const getUploadImageUrl = ({
6498
6529
  name,
6499
6530
  extension,
6500
6531
  entityId,
6501
6532
  prefixe,
6502
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,
6503
6544
  uploadUrl
6504
6545
  }) => {
6505
- return `${uploadUrl}/${bucketFolder}/${entityId}/${name}-${prefixe}.${extension}`;
6546
+ return `${uploadUrl}/${bucketFolder}/${entityId}${folder ? `/${folder}` : ""}/${fullName}`;
6506
6547
  };
6507
- const checkCorrectImageObject = (object$1, getError) => {
6548
+ const checkCorrectImageObject = (object2, getError) => {
6508
6549
  try {
6509
- object({
6510
- altRU: string().optional().nullable(),
6511
- altEN: string().optional().nullable(),
6512
- name: string(),
6513
- originalFileExtension: string(),
6514
- fileExtensions: string().array()
6515
- }).parse(object$1);
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);
6516
6560
  return true;
6517
6561
  } catch (error) {
6518
6562
  getError({ error });
@@ -6675,18 +6719,6 @@ const getImagePrefix = (prefixes, type) => {
6675
6719
  return prefixes[5] ?? "";
6676
6720
  }
6677
6721
  };
6678
- const responseSchema = object({
6679
- statusCode: number().optional(),
6680
- message: string().optional().nullable(),
6681
- messages: string().array().optional().nullable(),
6682
- data: any().optional().nullable(),
6683
- error: object({
6684
- statusCode: number(),
6685
- message: string().optional().nullable(),
6686
- messages: string().array().optional().nullable()
6687
- }).optional().nullable(),
6688
- response: any().optional().nullable()
6689
- });
6690
6722
  const BasePicture = ({
6691
6723
  imgProps,
6692
6724
  data,
@@ -6768,6 +6800,7 @@ export {
6768
6800
  THEME,
6769
6801
  TIME,
6770
6802
  arrayToKeyValueObject,
6803
+ checkCorrectFileObject,
6771
6804
  checkCorrectImageObject,
6772
6805
  cn,
6773
6806
  convertPhoneMask,
@@ -6776,6 +6809,7 @@ export {
6776
6809
  getImagePrefix,
6777
6810
  getNumberFormatter,
6778
6811
  getSubdomain,
6812
+ getUploadFileUrl,
6779
6813
  getUploadImageUrl,
6780
6814
  parseStringToKeyValue,
6781
6815
  prepareColor,
@@ -6783,5 +6817,7 @@ export {
6783
6817
  preparePageParam,
6784
6818
  prepareServerImages,
6785
6819
  responseSchema,
6820
+ serverFileSchema,
6821
+ serverImageSchema,
6786
6822
  updateTextByTemplate
6787
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: ({ error }: {
28
- error: unknown;
29
- }) => void) => boolean;
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: ({ error }: {
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;
@@ -1,3 +1,3 @@
1
1
  export * from './utils';
2
2
  export * from './css';
3
- export * from './images';
3
+ export * from './files';
@@ -36,14 +36,14 @@ export declare const getSubdomain: (host: string, SUB_DOMAIN: Record<string, str
36
36
  */
37
37
  export declare const updateTextByTemplate: ({ text, subdomain, SUBDOMAIN_NAME, SUBDOMAIN_MASK, }: {
38
38
  text: string;
39
- subdomain: string;
40
- SUBDOMAIN_NAME: Record<string, {
39
+ subdomain?: string;
40
+ SUBDOMAIN_NAME?: Record<string, {
41
41
  name: string;
42
42
  declination: string;
43
43
  region: string;
44
44
  regionDeclination: string;
45
45
  }>;
46
- SUBDOMAIN_MASK: {
46
+ SUBDOMAIN_MASK?: {
47
47
  CITY: string;
48
48
  CITY_DECL: string;
49
49
  CITY_REGION: string;
@@ -63,7 +63,7 @@ export declare const updateTextByTemplate: ({ text, subdomain, SUBDOMAIN_NAME, S
63
63
  * @return Объект с мета тегами
64
64
  */
65
65
  export declare const prepareLocalMetaData: <T extends object>({ subdomain, metaData, host, lang, isSubdomain, SUBDOMAIN_NAME, SUBDOMAIN_MASK, DEFAULT_SEO_TEXT, }: {
66
- subdomain: string;
66
+ subdomain?: string;
67
67
  metaData: {
68
68
  title: string;
69
69
  description: string;
@@ -79,13 +79,13 @@ export declare const prepareLocalMetaData: <T extends object>({ subdomain, metaD
79
79
  city?: string;
80
80
  };
81
81
  isSubdomain?: boolean;
82
- SUBDOMAIN_NAME: Record<string, {
82
+ SUBDOMAIN_NAME?: Record<string, {
83
83
  name: string;
84
84
  declination: string;
85
85
  region: string;
86
86
  regionDeclination: string;
87
87
  }>;
88
- SUBDOMAIN_MASK: {
88
+ SUBDOMAIN_MASK?: {
89
89
  CITY: string;
90
90
  CITY_DECL: string;
91
91
  CITY_REGION: 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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "denwa-web-shared",
3
3
  "private": false,
4
- "version": "1.0.26",
4
+ "version": "1.0.29",
5
5
  "type": "module",
6
6
  "author": "Denwa",
7
7
  "main": "dist/denwa-web-shared.cjs.js",