@emailmaker/filemanager 0.10.30 → 0.10.32

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/notification.d.ts CHANGED
@@ -1,5 +1,17 @@
1
+ interface FileManageErrorInfo {
2
+ message?: string;
3
+ code?: FileManagerErrorCode;
4
+ status?: number;
5
+ raw?: any;
6
+ stack?: string;
7
+ }
8
+
9
+
10
+ /**
11
+ * Error codes for FileManager API operations.
12
+ */
1
13
  type FileManagerErrorCode =
2
- // --- Файлы ---
14
+ // --- Files ---
3
15
  | 'FileNotFound'
4
16
  | 'FileAlreadyExists'
5
17
  | 'FileInvalidName'
@@ -10,8 +22,11 @@ type FileManagerErrorCode =
10
22
  | 'FileTypeNotAllowed'
11
23
  | 'FileCorrupted'
12
24
  | 'FileChecksumMismatch'
25
+ | 'FileStorageQuotaExceeded'
26
+ | 'FileLocked'
27
+ | 'FileVersionConflict'
13
28
 
14
- // --- Папки / каталоги ---
29
+ // --- Folders / directories ---
15
30
  | 'FolderNotFound'
16
31
  | 'FolderAlreadyExists'
17
32
  | 'FolderInvalidName'
@@ -23,45 +38,47 @@ type FileManagerErrorCode =
23
38
  | 'FolderBackendError'
24
39
  | 'FolderTimeout'
25
40
 
26
- // --- Операционные ограничения ---
41
+ // --- Operational restrictions ---
27
42
  | 'RenameNotAllowed'
28
43
  | 'MoveNotAllowed'
29
44
  | 'CopyNotAllowed'
30
45
  | 'DeleteNotAllowed'
31
46
  | 'MoveIntoSelf'
32
47
  | 'MoveIntoDescendant'
48
+ | 'CopyIntoSelf'
33
49
  | 'UnsupportedOperation'
34
50
  | 'ConfigError'
35
51
 
36
- // --- Загрузка файлов ---
52
+ // --- File upload ---
37
53
  | 'FileUploadQuotaExceeded'
38
54
  | 'FileUploadNetworkError'
39
55
  | 'FileUploadTimeout'
40
56
  | 'FileUploadBackendError'
41
57
 
42
- // --- Загрузка по URL ---
58
+ // --- URL upload ---
43
59
  | 'UploadUrlInvalid'
44
60
  | 'UploadUrlNotReachable'
45
61
  | 'UploadUrlContentTypeNotAllowed'
46
62
  | 'UploadUrlDownloadFailed'
47
63
 
48
- // --- Скачивание файлов ---
64
+ // --- File download ---
49
65
  | 'FileDownloadNetworkError'
50
66
  | 'FileDownloadTimeout'
51
67
  | 'FileDownloadBackendError'
52
68
 
53
- // --- Батчевые операции ---
69
+ // --- Batch operations ---
54
70
  | 'BatchPartialFailure'
55
71
  | 'BatchAllFailed'
56
72
  | 'BatchConflict'
57
73
  | 'BatchValidationFailed'
74
+ | 'BatchItemLimitExceeded'
58
75
 
59
- // --- Валидация / данные ---
76
+ // --- Validation / data ---
60
77
  | 'ValidationError'
61
78
  | 'PayloadTooLarge'
62
79
  | 'UnsupportedMediaType'
63
80
 
64
- // --- Сеть / сервер / инфраструктура ---
81
+ // --- Network / server / infrastructure ---
65
82
  | 'NetworkError'
66
83
  | 'BackendError'
67
84
  | 'Timeout'
@@ -70,35 +87,35 @@ type FileManagerErrorCode =
70
87
  | 'RateLimitExceeded'
71
88
  | 'ServiceUnavailable'
72
89
 
73
- // --- AI / интеграции ---
90
+ // --- AI / integrations ---
74
91
  | 'AIResponseInvalid'
75
92
  | 'AIImageGenerationFailed'
76
93
  | 'AIImageGenerationLimitExceeded'
77
94
  | 'IntegrationError'
78
95
  | 'ThirdPartyError'
79
96
 
80
- // --- Общее / запасной вариант ---
97
+ // --- General / fallback ---
81
98
  | 'UnknownError';
82
99
 
83
100
  /**
84
- * Интерфейс ошибки для FileManager API.
85
- * Реализован классом FileManagerApiError, который также экспортируется.
101
+ * Error interface for FileManager API.
102
+ * Implemented by FileManagerApiError class which is also exported.
86
103
  *
87
104
  * @example
88
105
  * ```typescript
89
- * // Использование класса
106
+ * // Using the class
90
107
  * throw new FileManagerApiError(
91
108
  * 'File not found',
92
109
  * 'FileNotFound',
93
110
  * 404
94
111
  * );
95
112
  *
96
- * // Или создание собственного класса
113
+ * // Or creating a custom class
97
114
  * class MyFileManagerError extends Error implements IFileManagerApiError {
98
115
  * constructor(
99
116
  * message: string,
100
117
  * public code: FileManagerErrorCode,
101
- * public httpStatus?: number,
118
+ * public status?: number,
102
119
  * public details?: unknown
103
120
  * ) {
104
121
  * super(message);
@@ -109,10 +126,13 @@ type FileManagerErrorCode =
109
126
  */
110
127
  interface IFileManagerApiError extends Error {
111
128
  code: FileManagerErrorCode;
112
- httpStatus?: number;
129
+ status?: number;
113
130
  details?: unknown;
114
131
  }
115
132
 
133
+ /**
134
+ * Parameters for file query operations.
135
+ */
116
136
  interface FilesQueryParams {
117
137
  folderId?: string;
118
138
  search?: string;
@@ -123,6 +143,9 @@ interface FilesQueryParams {
123
143
  itemType?: 'file' | 'folder' | 'all';
124
144
  }
125
145
 
146
+ /**
147
+ * Context payload for operations involving items (files/folders).
148
+ */
126
149
  interface ItemContextPayload {
127
150
  itemIds?: string[];
128
151
  itemNames?: string[];
@@ -130,6 +153,9 @@ interface ItemContextPayload {
130
153
  folderName?: string | null;
131
154
  }
132
155
 
156
+ /**
157
+ * Placement options for notification display.
158
+ */
133
159
  type NotifyPlacement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight';
134
160
 
135
161
  type Notify = {
@@ -150,25 +176,90 @@ type Notify = {
150
176
  };
151
177
 
152
178
  declare namespace Notify {
179
+ /**
180
+ * Payload for successful batch operations.
181
+ */
153
182
  export interface OperationSuccessPayload extends ItemContextPayload {
154
183
  successCount: number;
155
184
  totalCount: number;
156
185
  }
157
186
 
187
+ /**
188
+ * Details of an error for a single item in a batch operation.
189
+ */
158
190
  export interface OperationErrorDetail {
159
191
  itemId?: string;
160
192
  itemName?: string;
161
- reason?: string;
162
- code?: FileManagerErrorCode;
163
- httpStatus?: number;
193
+ error: FileManageErrorInfo;
164
194
  }
165
195
 
196
+ /**
197
+ * Payload for batch operation errors.
198
+ * Extends ItemContextPayload with error-specific fields.
199
+ */
166
200
  export interface OperationErrorPayload extends ItemContextPayload {
167
201
  failCount: number;
168
202
  totalCount: number;
169
203
  errors?: OperationErrorDetail[];
204
+ /**
205
+ * Flag indicating if this is a move-to-trash operation (true) or permanent delete (false).
206
+ * Used to differentiate between soft delete (trash) and hard delete operations.
207
+ */
208
+ isTrashMove?: boolean;
209
+ }
210
+
211
+ /**
212
+ * Details of a single item in batch operation results.
213
+ * Used in the `detailed` array for batch operations (deleteItems, moveItems, copyItems, uploadFiles).
214
+ *
215
+ * @template T - Type of successful operation result data
216
+ */
217
+ export interface BatchOperationDetail<T = unknown> {
218
+ /** Correlation identifier for the request item (preferred) */
219
+ requestId?: string;
220
+ /** Item identifier (for backward compatibility) */
221
+ id?: string;
222
+ /** Success flag for the operation */
223
+ success: boolean;
224
+ /** Successful operation result data */
225
+ data?: T;
226
+ /** Error for failed operation */
227
+ error?: FileManageErrorInfo;
170
228
  }
171
229
 
230
+ /**
231
+ * Result of a batch operation with support for detailed results.
232
+ * Unified type for all batch operations in the file manager.
233
+ *
234
+ * @template T - Type of successful operation result data
235
+ */
236
+ export interface BatchOperationResult<T = unknown> {
237
+ /** Overall success flag (true if all items succeeded) */
238
+ success: boolean;
239
+ /** Overall operation error (if the entire operation failed) */
240
+ error?: string | unknown;
241
+ /** Detailed results for each item */
242
+ detailed?: BatchOperationDetail<T>[];
243
+ }
244
+
245
+ /**
246
+ * Summary of batch operation results for notifications.
247
+ * Used for aggregated error and success notifications.
248
+ */
249
+ export interface BatchOperationSummary {
250
+ /** Number of successfully processed items */
251
+ successCount: number;
252
+ /** Number of items with errors */
253
+ failCount: number;
254
+ /** Total number of items */
255
+ totalCount: number;
256
+ /** Error details for each item */
257
+ errors: OperationErrorDetail[];
258
+ }
259
+
260
+ /**
261
+ * Payload for operations involving a single item (file or folder).
262
+ */
172
263
  export interface SingleItemPayload {
173
264
  itemId?: string;
174
265
  itemName?: string;
@@ -176,24 +267,37 @@ declare namespace Notify {
176
267
  folderName?: string | null;
177
268
  }
178
269
 
270
+ /**
271
+ * Payload for rename operation errors.
272
+ */
179
273
  export interface RenameErrorPayload extends SingleItemPayload {
180
- reason?: string;
274
+ error: FileManageErrorInfo;
181
275
  }
182
276
 
277
+ /**
278
+ * Payload for file upload operations.
279
+ */
183
280
  export interface FileUploadPayload extends SingleItemPayload {
184
281
  uploadId?: string;
185
282
  }
186
283
 
284
+ /**
285
+ * Payload for file upload errors.
286
+ */
187
287
  export interface FileUploadErrorPayload extends FileUploadPayload {
188
- error?: string;
189
- errorCode?: FileManagerErrorCode;
190
- httpStatus?: number;
288
+ error?: FileManageErrorInfo;
191
289
  }
192
290
 
291
+ /**
292
+ * Payload for unsupported file type errors.
293
+ */
193
294
  export interface UnsupportedFileTypePayload extends FileUploadErrorPayload {
194
295
  fileType: string;
195
296
  }
196
297
 
298
+ /**
299
+ * Payload for folder operation errors and successes.
300
+ */
197
301
  export interface FolderOperationPayload extends ItemContextPayload {
198
302
  folderId?: string | null;
199
303
  folderName?: string;
@@ -201,65 +305,177 @@ declare namespace Notify {
201
305
  is_force_create?: boolean;
202
306
  }
203
307
 
204
- export interface JsonDataProviderErrorPayload {
205
- url?: string | null;
206
- reason?: string;
207
- errorCode?: FileManagerErrorCode;
208
- }
209
-
308
+ /**
309
+ * Payload for file URL validation errors.
310
+ */
210
311
  export interface FileUrlValidationErrorPayload {
211
312
  url?: string | null;
212
- reason?: string;
213
- errorCode?: FileManagerErrorCode;
313
+ error: FileManageErrorInfo;
214
314
  }
215
315
 
316
+ /**
317
+ * Payload for image file operations.
318
+ */
216
319
  export interface ImageFilePayload extends SingleItemPayload {
217
320
  thumbnail?: string | null;
218
321
  }
219
322
 
323
+ /**
324
+ * Payload for URL upload operations.
325
+ */
220
326
  export interface UrlUploadPayload {
221
327
  url?: string | null;
222
328
  folderId?: string | null;
223
329
  folderName?: string | null;
224
330
  }
225
331
 
332
+ /**
333
+ * Payload for URL upload errors.
334
+ */
226
335
  export interface UrlUploadErrorPayload extends UrlUploadPayload {
227
- reason?: string;
336
+ error: FileManageErrorInfo;
228
337
  }
229
338
 
339
+ /**
340
+ * Payload for file fetch errors.
341
+ */
230
342
  export interface FetchFilesErrorPayload {
231
343
  params?: FilesQueryParams;
232
344
  }
233
345
 
346
+ /**
347
+ * Base payload for AI image generation operations.
348
+ */
234
349
  interface AIImageGenerationBasePayload {
235
350
  request: string;
236
351
  taskId?: string | null;
237
352
  }
238
353
 
354
+ /**
355
+ * Payload for AI image generation started event.
356
+ */
239
357
  export interface AIImageGenerationStartedPayload extends AIImageGenerationBasePayload {
240
358
  response?: unknown;
241
359
  }
242
360
 
361
+ /**
362
+ * Payload for successful AI image generation.
363
+ */
243
364
  export interface AIImageGenerationSuccessPayload extends AIImageGenerationBasePayload {
244
365
  images: string[];
245
366
  }
246
367
 
368
+ /**
369
+ * Payload for failed AI image generation.
370
+ */
247
371
  export interface AIImageGenerationFailedPayload extends AIImageGenerationBasePayload {
248
372
  response?: unknown;
249
- error?: unknown;
373
+ error?: FileManageErrorInfo;
250
374
  }
251
375
 
252
- export type EventBase<TId extends string, TData> = {
376
+ /**
377
+ * Base type for error notification events.
378
+ * Includes innerException field for error details.
379
+ *
380
+ * @template TId - Notification event ID type
381
+ * @template TData - Payload data type
382
+ */
383
+ export type ErrorEventBase<TId extends string, TData> = {
253
384
  id: TId;
254
385
  data?: TData;
255
386
  innerException?: unknown;
256
387
  message: string;
257
388
  placement?: NotifyPlacement;
258
389
  description?: string;
390
+ /**
391
+ * Visibility flag for the notification.
392
+ * If true, notification will be shown; if false, it will be silent.
393
+ * Derived from the `silent` parameter (visibility = !silent).
394
+ * Can be modified by event interceptors.
395
+ */
396
+ visibility?: boolean;
397
+ /**
398
+ * Level of the operation: 'item' for single item operations, 'batch' for batch operations.
399
+ */
400
+ level?: 'item' | 'batch';
401
+ };
259
402
 
403
+ /**
404
+ * Base type for success, warning, and info notification events.
405
+ * Does not include innerException field.
406
+ *
407
+ * @template TId - Notification event ID type
408
+ * @template TData - Payload data type
409
+ */
410
+ export type NotificationEventBase<TId extends string, TData> = {
411
+ id: TId;
412
+ data?: TData;
413
+ message: string;
414
+ placement?: NotifyPlacement;
415
+ description?: string;
416
+ /**
417
+ * Visibility flag for the notification.
418
+ * If true, notification will be shown; if false, it will be silent.
419
+ * Derived from the `silent` parameter (visibility = !silent).
420
+ * Can be modified by event interceptors.
421
+ */
422
+ visibility?: boolean;
423
+ /**
424
+ * Level of the operation: 'item' for single item operations, 'batch' for batch operations.
425
+ */
426
+ level?: 'item' | 'batch';
260
427
  };
261
428
 
262
- export interface ErrorMap {
429
+ /**
430
+ * Map of error notification IDs to their payload types for single item operations.
431
+ * All item operation errors extend OperationErrorPayload with failCount: 1 and totalCount: 1.
432
+ */
433
+ export interface ItemErrorMap {
434
+ FILE_DELETE_ERROR: OperationErrorPayload;
435
+ FILE_MOVE_ERROR: OperationErrorPayload;
436
+ FILE_COPY_ERROR: OperationErrorPayload;
437
+ }
438
+
439
+ /**
440
+ * Map of error notification IDs to their payload types for batch operations.
441
+ * All batch operation errors extend OperationErrorPayload.
442
+ */
443
+ export interface BatchErrorMap {
444
+ FILES_DELETE_ERROR: OperationErrorPayload;
445
+ FOLDER_DELETE_ERROR: OperationErrorPayload;
446
+ FILES_UPLOAD_BATCH_FAILED: OperationErrorPayload;
447
+ FILES_MOVE_ERROR: OperationErrorPayload;
448
+ FILES_COPY_ERROR: OperationErrorPayload;
449
+ }
450
+
451
+ /**
452
+ * Map of success notification IDs to their payload types for single item operations.
453
+ * All item operation successes extend OperationSuccessPayload with successCount: 1 and totalCount: 1.
454
+ */
455
+ export interface ItemSuccessMap {
456
+ FILE_DELETE_SUCCESS: OperationSuccessPayload;
457
+ FILE_MOVE_SUCCESS: OperationSuccessPayload;
458
+ FILE_COPY_SUCCESS: OperationSuccessPayload;
459
+ }
460
+
461
+ /**
462
+ * Map of success notification IDs to their payload types for batch operations.
463
+ * All batch operation successes extend OperationSuccessPayload.
464
+ */
465
+ export interface BatchSuccessMap {
466
+ FILES_DELETE_SUCCESS: OperationSuccessPayload;
467
+ FILES_MOVE_SUCCESS: OperationSuccessPayload;
468
+ FILES_COPY_SUCCESS: OperationSuccessPayload;
469
+ FOLDER_DELETE_SUCCESS: OperationSuccessPayload;
470
+ FILES_UPLOAD_BATCH_SUCCESS: OperationSuccessPayload;
471
+ }
472
+
473
+ /**
474
+ * Map of all error notification IDs to their payload types.
475
+ * Extends ItemErrorMap for single item operations and BatchErrorMap for batch operations.
476
+ */
477
+ export interface ErrorMap extends ItemErrorMap, BatchErrorMap {
478
+
263
479
  FILE_DOWNLOAD_FAILED: ImageFilePayload;
264
480
  IMAGE_DOWNLOAD_FAILED: ImageFilePayload;
265
481
  IMAGE_SAVE_FAILED: ImageFilePayload;
@@ -271,10 +487,6 @@ declare namespace Notify {
271
487
 
272
488
  FILES_FETCH_FAILED: FetchFilesErrorPayload;
273
489
 
274
- FILES_DELETE_ERROR: OperationErrorPayload;
275
-
276
- FOLDER_DELETE_ERROR: OperationErrorPayload;
277
-
278
490
  FILE_RENAME_DISABLED_BY_CONFIG: SingleItemPayload;
279
491
  FILE_RENAME_FAILED: RenameErrorPayload;
280
492
 
@@ -285,8 +497,6 @@ declare namespace Notify {
285
497
 
286
498
  FILE_UPLOAD_ITEM_FAILED: FileUploadErrorPayload;
287
499
 
288
- FILES_UPLOAD_BATCH_FAILED: OperationErrorPayload;
289
-
290
500
  FILES_UPLOAD_URL_VALIDATION_FAILED: UrlUploadPayload;
291
501
 
292
502
  FILES_UPLOAD_URL_NOT_SUPPORTED: UrlUploadPayload;
@@ -295,75 +505,101 @@ declare namespace Notify {
295
505
  FILES_UPLOAD_PROVIDER_NOT_CONFIGURED: never;
296
506
 
297
507
  FILES_MOVE_DIRECTORY_NOT_SELECTED: never;
298
- FILES_MOVE_ERROR: OperationErrorPayload;
299
508
 
300
509
  FILES_COPY_DIRECTORY_NOT_SELECTED: never;
301
- FILES_COPY_ERROR: OperationErrorPayload;
302
-
303
- FILES_MOVE_TO_TRASH_ERROR: OperationErrorPayload;
304
510
 
305
511
  FOLDERS_FETCH_FAILED: FolderOperationPayload;
306
512
  FOLDER_CREATE_PROVIDER_NOT_CONFIGURED: FolderOperationPayload;
307
513
  FOLDER_CREATE_FAILED: FolderOperationPayload;
308
514
  FOLDER_CHILDREN_COUNT_FAILED: FolderOperationPayload;
309
515
  FOLDER_CHILDREN_FETCH_FAILED: FolderOperationPayload;
310
-
311
- JSON_DATA_PROVIDER_LOAD_FAILED: JsonDataProviderErrorPayload;
312
516
  FILE_URL_VALIDATION_FAILED: FileUrlValidationErrorPayload;
313
517
  }
314
518
 
519
+ /**
520
+ * Union type of all error events.
521
+ */
315
522
  export type Error = {
316
- [K in keyof ErrorMap]: EventBase<K, ErrorMap[K]>;
523
+ [K in keyof ErrorMap]: ErrorEventBase<K, ErrorMap[K]>;
317
524
  }[keyof ErrorMap];
318
525
 
526
+ /**
527
+ * Error notification event type.
528
+ */
319
529
  export type ErrorEvent = { type: 'error' } & Error;
320
530
 
321
- export interface SuccessMap {
531
+ /**
532
+ * Map of all success notification IDs to their payload types.
533
+ * Extends ItemSuccessMap for single item operations and BatchSuccessMap for batch operations.
534
+ */
535
+ export interface SuccessMap extends ItemSuccessMap, BatchSuccessMap {
322
536
  AI_IMAGE_GENERATION_STARTED: AIImageGenerationStartedPayload;
323
537
  AI_IMAGE_GENERERATION_SUCCESS: AIImageGenerationSuccessPayload;
324
538
 
325
539
  // EDITOR_IMAGE_DOWNLOAD_SUCCESS: ImageFilePayload;
326
540
  IMAGE_UPDATE_SUCCESS: ImageFilePayload;
327
541
 
328
- FILES_DELETE_SUCCESS: OperationSuccessPayload;
329
- FILES_MOVE_SUCCESS: OperationSuccessPayload;
330
- FILES_COPY_SUCCESS: OperationSuccessPayload;
331
542
  FILE_RENAME_SUCCESS: SingleItemPayload;
332
543
  FOLDER_RENAME_SUCCESS: SingleItemPayload;
333
- FOLDER_DELETE_SUCCESS: OperationSuccessPayload;
334
544
  FOLDER_CREATE_SUCCESS: FolderOperationPayload;
335
- FILES_UPLOAD_BATCH_SUCCESS: OperationSuccessPayload;
336
545
 
337
546
  FILE_UPLOAD_ITEM_SUCCESS: FileUploadPayload;
338
547
  }
339
548
 
549
+ /**
550
+ * Union type of all success events.
551
+ */
340
552
  export type Success = {
341
- [K in keyof SuccessMap]: EventBase<K, SuccessMap[K]>;
553
+ [K in keyof SuccessMap]: NotificationEventBase<K, SuccessMap[K]>;
342
554
  }[keyof SuccessMap];
343
555
 
556
+ /**
557
+ * Success notification event type.
558
+ */
344
559
  export type SuccessEvent = { type: 'success' } & Success;
345
560
 
561
+ /**
562
+ * Map of warning notification IDs to their payload types.
563
+ */
346
564
  export interface WarningMap {
347
565
  FILES_UPLOAD_UNSUPPORTED_TYPE: UnsupportedFileTypePayload;
348
566
  FOLDER_OPERATION_VALIDATION_FAILED: FolderOperationPayload;
349
567
  }
350
568
 
569
+ /**
570
+ * Union type of all warning events.
571
+ */
351
572
  export type Warning = {
352
- [K in keyof WarningMap]: EventBase<K, WarningMap[K]>;
573
+ [K in keyof WarningMap]: NotificationEventBase<K, WarningMap[K]>;
353
574
  }[keyof WarningMap];
354
575
 
576
+ /**
577
+ * Warning notification event type.
578
+ */
355
579
  export type WarningEvent = { type: 'warning' } & Warning;
356
580
 
581
+ /**
582
+ * Map of info notification IDs to their payload types.
583
+ */
357
584
  export interface InfoMap {}
358
585
 
586
+ /**
587
+ * Union type of all info events.
588
+ */
359
589
  export type Info = {
360
- [K in keyof InfoMap]: EventBase<K, InfoMap[K]>;
590
+ [K in keyof InfoMap]: NotificationEventBase<K, InfoMap[K]>;
361
591
  }[keyof InfoMap];
362
592
 
593
+ /**
594
+ * Info notification event type.
595
+ */
363
596
  export type InfoEvent = { type: 'info' } & Info;
364
597
  }
365
598
 
599
+ /**
600
+ * Union type of all notification events (error, success, warning, info).
601
+ */
366
602
  type NotifyEvent = Notify.SuccessEvent | Notify.ErrorEvent | Notify.WarningEvent | Notify.InfoEvent;
367
603
 
368
604
  export { Notify };
369
- export type { FileManagerErrorCode, IFileManagerApiError, ItemContextPayload, NotifyEvent, NotifyPlacement };
605
+ export type { FileManageErrorInfo, FileManagerErrorCode, FilesQueryParams, IFileManagerApiError, ItemContextPayload, NotifyEvent, NotifyPlacement };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emailmaker/filemanager",
3
- "version": "0.10.30",
3
+ "version": "0.10.32",
4
4
  "main": "./file-manager.js",
5
5
  "module": "./file-manager.esm.js",
6
6
  "types": "./index.d.ts",
@@ -14,7 +14,7 @@ import type { FileManagerErrorCode, IFileManagerApiError } from '../notification
14
14
  */
15
15
  export declare class FileManagerApiError extends Error implements IFileManagerApiError {
16
16
  readonly code: FileManagerErrorCode;
17
- readonly httpStatus?: number;
18
- readonly details?: unknown;
19
- constructor(message: string, code: FileManagerErrorCode, httpStatus?: number, details?: unknown);
17
+ readonly status?: number | undefined;
18
+ readonly details?: unknown | undefined;
19
+ constructor(message: string, code: FileManagerErrorCode, status?: number | undefined, details?: unknown | undefined);
20
20
  }
@@ -0,0 +1,5 @@
1
+ import { FileManagerErrorCode } from "types";
2
+ /**
3
+ * Преобразует HTTP статус-код в код ошибки FileManager
4
+ */
5
+ export declare function mapHttpStatusToErrorCode(status: number, defaultCode?: FileManagerErrorCode): FileManagerErrorCode;
package/types.d.ts CHANGED
@@ -2,7 +2,7 @@ import React, { ReactNode, RefObject } from 'react';
2
2
  import { FormInstance } from 'antd/es/form';
3
3
  import { MY_FILES, GIF, STOCK_IMAGES, AI, EDITOR, IMAGE_EXTENSIONS } from './constants';
4
4
  import type { InputRef } from 'antd';
5
- import type { Notify, NotifyEvent } from 'notification';
5
+ import type { FileManageErrorInfo, Notify, NotifyEvent } from 'notification';
6
6
  export * from 'notification';
7
7
  export interface Folder {
8
8
  id: string;
@@ -150,14 +150,14 @@ export interface OperationResult<T = void> {
150
150
  requestId?: string;
151
151
  success?: boolean;
152
152
  data?: T;
153
- error?: string;
153
+ error?: FileManageErrorInfo;
154
154
  }
155
155
  /**
156
156
  * Результат групповой операции
157
157
  */
158
158
  export type BatchResult<T> = {
159
159
  success: boolean;
160
- error?: string;
160
+ error?: FileManageErrorInfo;
161
161
  detailed?: OperationResult<T>[];
162
162
  };
163
163
  export type UploadBinary = Blob | globalThis.File;
@@ -235,16 +235,10 @@ export interface FileManagerDataProviders {
235
235
  folderId?: string | null;
236
236
  noFolder?: boolean;
237
237
  }) => Promise<File>;
238
- deleteFile: (fileId: string) => Promise<boolean>;
239
238
  deleteItems?: (items: string[], options?: {
240
239
  permanent?: boolean;
241
240
  }) => Promise<BatchResult<unknown>>;
242
241
  renameFile?: (fileId: string, newName: string) => Promise<File>;
243
- moveItem?: (options: {
244
- itemId: string;
245
- targetFolderId: string;
246
- isFolder: boolean;
247
- }) => Promise<boolean>;
248
242
  moveItems?: (targetFolderId: string, files: string[]) => Promise<BatchResult<unknown>>;
249
243
  copyItem?: (options: {
250
244
  itemId: string;