@emailmaker/filemanager 0.10.16 → 0.10.17
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/constants/errors.d.ts +47 -0
- package/file-manager.d.ts +1 -0
- package/file-manager.esm.js +53 -77712
- package/file-manager.esm.js.map +1 -1
- package/file-manager.js +1 -1
- package/index.d.ts +2 -1
- package/notification.d.ts +123 -2
- package/package.json +1 -1
- package/shared/config.d.ts +1 -1
- package/shared/fileManagerApiError.d.ts +20 -0
- package/types.d.ts +1 -1
- package/utils/errorMessages.d.ts +12 -0
package/index.d.ts
CHANGED
|
@@ -17,5 +17,6 @@ export { FileContent } from './components/FileContent/FileContent';
|
|
|
17
17
|
export { FileModals } from './components/FileModals/FileModals';
|
|
18
18
|
export { FolderSidebar } from './components/FolderSidebar/FolderSidebar';
|
|
19
19
|
export { installResizeObserverErrorHandler, uninstallResizeObserverErrorHandler } from './utils/resizeObserverHandler';
|
|
20
|
-
export { type Folder, type File, type PathItem, type MenuItem, type FileManagerOptions, type FileManagerHookReturn, } from './types';
|
|
20
|
+
export { type Folder, type File, type PathItem, type MenuItem, type FileManagerOptions, type FileManagerHookReturn, type FileManagerErrorCode, type IFileManagerApiError, } from './types';
|
|
21
|
+
export { FileManagerApiError } from './shared/fileManagerApiError';
|
|
21
22
|
export { type InitPixieEditorOptions, type Options as FileManagerInitOptions, type UniversalInitOptions, } from './file-manager';
|
package/notification.d.ts
CHANGED
|
@@ -1,3 +1,118 @@
|
|
|
1
|
+
type FileManagerErrorCode =
|
|
2
|
+
// --- Файлы ---
|
|
3
|
+
| 'FileNotFound'
|
|
4
|
+
| 'FileAlreadyExists'
|
|
5
|
+
| 'FileInvalidName'
|
|
6
|
+
| 'FileAccessDenied'
|
|
7
|
+
| 'FileReadError'
|
|
8
|
+
| 'FileWriteError'
|
|
9
|
+
| 'FileTooLarge'
|
|
10
|
+
| 'FileTypeNotAllowed'
|
|
11
|
+
| 'FileCorrupted'
|
|
12
|
+
| 'FileChecksumMismatch'
|
|
13
|
+
|
|
14
|
+
// --- Папки / каталоги ---
|
|
15
|
+
| 'FolderNotFound'
|
|
16
|
+
| 'FolderAlreadyExists'
|
|
17
|
+
| 'FolderInvalidName'
|
|
18
|
+
| 'FolderAccessDenied'
|
|
19
|
+
| 'FolderReadError'
|
|
20
|
+
| 'FolderWriteError'
|
|
21
|
+
| 'FolderQuotaExceeded'
|
|
22
|
+
| 'FolderNotEmpty'
|
|
23
|
+
| 'FolderBackendError'
|
|
24
|
+
| 'FolderTimeout'
|
|
25
|
+
|
|
26
|
+
// --- Операционные ограничения ---
|
|
27
|
+
| 'RenameNotAllowed'
|
|
28
|
+
| 'MoveNotAllowed'
|
|
29
|
+
| 'CopyNotAllowed'
|
|
30
|
+
| 'DeleteNotAllowed'
|
|
31
|
+
| 'MoveIntoSelf'
|
|
32
|
+
| 'MoveIntoDescendant'
|
|
33
|
+
| 'UnsupportedOperation'
|
|
34
|
+
| 'ConfigError'
|
|
35
|
+
|
|
36
|
+
// --- Загрузка файлов ---
|
|
37
|
+
| 'FileUploadQuotaExceeded'
|
|
38
|
+
| 'FileUploadNetworkError'
|
|
39
|
+
| 'FileUploadTimeout'
|
|
40
|
+
| 'FileUploadBackendError'
|
|
41
|
+
|
|
42
|
+
// --- Загрузка по URL ---
|
|
43
|
+
| 'UploadUrlInvalid'
|
|
44
|
+
| 'UploadUrlNotReachable'
|
|
45
|
+
| 'UploadUrlContentTypeNotAllowed'
|
|
46
|
+
| 'UploadUrlDownloadFailed'
|
|
47
|
+
|
|
48
|
+
// --- Скачивание файлов ---
|
|
49
|
+
| 'FileDownloadNetworkError'
|
|
50
|
+
| 'FileDownloadTimeout'
|
|
51
|
+
| 'FileDownloadBackendError'
|
|
52
|
+
|
|
53
|
+
// --- Батчевые операции ---
|
|
54
|
+
| 'BatchPartialFailure'
|
|
55
|
+
| 'BatchAllFailed'
|
|
56
|
+
| 'BatchConflict'
|
|
57
|
+
| 'BatchValidationFailed'
|
|
58
|
+
|
|
59
|
+
// --- Валидация / данные ---
|
|
60
|
+
| 'ValidationError'
|
|
61
|
+
| 'PayloadTooLarge'
|
|
62
|
+
| 'UnsupportedMediaType'
|
|
63
|
+
|
|
64
|
+
// --- Сеть / сервер / инфраструктура ---
|
|
65
|
+
| 'NetworkError'
|
|
66
|
+
| 'BackendError'
|
|
67
|
+
| 'Timeout'
|
|
68
|
+
| 'AuthenticationFailed'
|
|
69
|
+
| 'AuthorizationFailed'
|
|
70
|
+
| 'RateLimitExceeded'
|
|
71
|
+
| 'ServiceUnavailable'
|
|
72
|
+
|
|
73
|
+
// --- AI / интеграции ---
|
|
74
|
+
| 'AIResponseInvalid'
|
|
75
|
+
| 'AIImageGenerationFailed'
|
|
76
|
+
| 'AIImageGenerationLimitExceeded'
|
|
77
|
+
| 'IntegrationError'
|
|
78
|
+
| 'ThirdPartyError'
|
|
79
|
+
|
|
80
|
+
// --- Общее / запасной вариант ---
|
|
81
|
+
| 'UnknownError';
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Интерфейс ошибки для FileManager API.
|
|
85
|
+
* Реализован классом FileManagerApiError, который также экспортируется.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* // Использование класса
|
|
90
|
+
* throw new FileManagerApiError(
|
|
91
|
+
* 'File not found',
|
|
92
|
+
* 'FileNotFound',
|
|
93
|
+
* 404
|
|
94
|
+
* );
|
|
95
|
+
*
|
|
96
|
+
* // Или создание собственного класса
|
|
97
|
+
* class MyFileManagerError extends Error implements IFileManagerApiError {
|
|
98
|
+
* constructor(
|
|
99
|
+
* message: string,
|
|
100
|
+
* public code: FileManagerErrorCode,
|
|
101
|
+
* public httpStatus?: number,
|
|
102
|
+
* public details?: unknown
|
|
103
|
+
* ) {
|
|
104
|
+
* super(message);
|
|
105
|
+
* this.name = 'MyFileManagerError';
|
|
106
|
+
* }
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
interface IFileManagerApiError extends Error {
|
|
111
|
+
code: FileManagerErrorCode;
|
|
112
|
+
httpStatus?: number;
|
|
113
|
+
details?: unknown;
|
|
114
|
+
}
|
|
115
|
+
|
|
1
116
|
interface FilesQueryParams {
|
|
2
117
|
folderId?: string;
|
|
3
118
|
search?: string;
|
|
@@ -42,8 +157,10 @@ declare namespace Notify {
|
|
|
42
157
|
|
|
43
158
|
export interface OperationErrorDetail {
|
|
44
159
|
itemId?: string;
|
|
45
|
-
|
|
160
|
+
itemName?: string;
|
|
46
161
|
reason?: string;
|
|
162
|
+
code?: FileManagerErrorCode;
|
|
163
|
+
httpStatus?: number;
|
|
47
164
|
}
|
|
48
165
|
|
|
49
166
|
export interface OperationErrorPayload extends ItemContextPayload {
|
|
@@ -69,6 +186,8 @@ declare namespace Notify {
|
|
|
69
186
|
|
|
70
187
|
export interface FileUploadErrorPayload extends FileUploadPayload {
|
|
71
188
|
error?: string;
|
|
189
|
+
errorCode?: FileManagerErrorCode;
|
|
190
|
+
httpStatus?: number;
|
|
72
191
|
}
|
|
73
192
|
|
|
74
193
|
export interface UnsupportedFileTypePayload extends FileUploadErrorPayload {
|
|
@@ -84,11 +203,13 @@ declare namespace Notify {
|
|
|
84
203
|
export interface JsonDataProviderErrorPayload {
|
|
85
204
|
url?: string | null;
|
|
86
205
|
reason?: string;
|
|
206
|
+
errorCode?: FileManagerErrorCode;
|
|
87
207
|
}
|
|
88
208
|
|
|
89
209
|
export interface FileUrlValidationErrorPayload {
|
|
90
210
|
url?: string | null;
|
|
91
211
|
reason?: string;
|
|
212
|
+
errorCode?: FileManagerErrorCode;
|
|
92
213
|
}
|
|
93
214
|
|
|
94
215
|
export interface ImageFilePayload extends SingleItemPayload {
|
|
@@ -244,4 +365,4 @@ declare namespace Notify {
|
|
|
244
365
|
type NotifyEvent = Notify.SuccessEvent | Notify.ErrorEvent | Notify.WarningEvent | Notify.InfoEvent;
|
|
245
366
|
|
|
246
367
|
export { Notify };
|
|
247
|
-
export type { ItemContextPayload, NotifyEvent, NotifyPlacement };
|
|
368
|
+
export type { FileManagerErrorCode, IFileManagerApiError, ItemContextPayload, NotifyEvent, NotifyPlacement };
|
package/package.json
CHANGED
package/shared/config.d.ts
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FileManagerErrorCode, IFileManagerApiError } from '../notification';
|
|
2
|
+
/**
|
|
3
|
+
* Класс ошибки для FileManager API.
|
|
4
|
+
* Реализует интерфейс IFileManagerApiError.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* throw new FileManagerApiError(
|
|
9
|
+
* 'File not found',
|
|
10
|
+
* 'FileNotFound',
|
|
11
|
+
* 404
|
|
12
|
+
* );
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class FileManagerApiError extends Error implements IFileManagerApiError {
|
|
16
|
+
readonly code: FileManagerErrorCode;
|
|
17
|
+
readonly httpStatus?: number;
|
|
18
|
+
readonly details?: unknown;
|
|
19
|
+
constructor(message: string, code: FileManagerErrorCode, httpStatus?: number, details?: unknown);
|
|
20
|
+
}
|
package/types.d.ts
CHANGED
|
@@ -330,7 +330,7 @@ export interface Config {
|
|
|
330
330
|
theme?: 'light' | 'dark' | 'system';
|
|
331
331
|
disableMockServer?: boolean;
|
|
332
332
|
activeTab?: string;
|
|
333
|
-
|
|
333
|
+
showNotifications?: boolean;
|
|
334
334
|
apiEndpoints?: ApiEndpoints;
|
|
335
335
|
REACT_APP_GIPHY_KEY?: string;
|
|
336
336
|
locale?: string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FileManagerErrorCode, IFileManagerApiError } from 'notification';
|
|
2
|
+
type TFunction = (key: string, params?: Record<string, unknown>) => string;
|
|
3
|
+
/**
|
|
4
|
+
* Возвращает локализованное сообщение по коду ошибки, если для него есть i18n-ключ.
|
|
5
|
+
* Если кода нет или он не сопоставлен — вернёт undefined.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getErrorMessageFromCode: (code: FileManagerErrorCode | undefined, t: TFunction) => string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Пытается извлечь IFileManagerApiError из unknown.
|
|
10
|
+
*/
|
|
11
|
+
export declare const asFileManagerApiError: (error: unknown) => IFileManagerApiError | undefined;
|
|
12
|
+
export {};
|