@webitel/ui-sdk 24.10.69 → 24.10.70

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-sdk",
3
- "version": "24.10.69",
3
+ "version": "24.10.70",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -150,6 +150,7 @@
150
150
  "postcss-prefix-selector": "^2.1.0",
151
151
  "prismjs": "^1.29.0",
152
152
  "sass": "^1.80.6",
153
+ "tslib": "^2.8.1",
153
154
  "vite": "^5.4.11",
154
155
  "vite-plugin-node-polyfills": "^0.22.0",
155
156
  "vite-plugin-static-copy": "^2.1.0",
@@ -2,6 +2,7 @@ import { saveAs } from 'file-saver-es';
2
2
  import JSZip from 'jszip';
3
3
  import jszipUtils from 'jszip-utils';
4
4
  import path from 'path-browserify';
5
+ import { _wtUiLog } from '../../scripts/logger.js';
5
6
  import generateMediaURL from './scripts/generateMediaURL.js';
6
7
 
7
8
  export default class FilesExport {
@@ -11,16 +12,19 @@ export default class FilesExport {
11
12
 
12
13
  isLoading = false;
13
14
 
15
+ skipFilesWithError = false;
16
+
14
17
  downloadProgress = { count: 0 };
15
18
 
16
19
  zippingProgress = { percent: 0 };
17
20
 
18
21
  filesURL = generateMediaURL;
19
22
 
20
- constructor({ fetchMethod, filename, filesURL }) {
23
+ constructor({ fetchMethod, filename, filesURL, skipFilesWithError = false }) {
21
24
  if (fetchMethod) this.fetchMethod = fetchMethod;
22
25
  if (filename) this.filename = filename;
23
26
  if (filesURL) this.filesURL = filesURL;
27
+ this.skipFilesWithError = skipFilesWithError;
24
28
  }
25
29
 
26
30
  _fetchFileBinary(fileId) {
@@ -46,12 +50,23 @@ export default class FilesExport {
46
50
  if (item.files) {
47
51
  await this._addFilesToZip(item.files, zip);
48
52
  } else {
49
- const binary = await this._fetchFileBinary(item.id);
50
- const ext = item.mimeType.split('/').pop();
51
- // itemName needed to remove extension from item.name https://stackoverflow.com/a/31615711
52
- const itemName = path.parse(item.name).name;
53
- zip.file(`${itemName}.${ext}`, binary);
54
- this.downloadProgress.count += 1;
53
+ try {
54
+ const binary = await this._fetchFileBinary(item.id);
55
+ const ext = item.mimeType.split('/').pop();
56
+ // itemName needed to remove extension from item.name https://stackoverflow.com/a/31615711
57
+ const itemName = path.parse(item.name).name;
58
+ zip.file(`${itemName}.${ext}`, binary);
59
+ this.downloadProgress.count += 1;
60
+ } catch (err) {
61
+ debugger;
62
+ _wtUiLog.error({ entity: 'script', module: 'FilesExport' })(
63
+ `An error occurred while downloading a file id=${item.id}`,
64
+ err,
65
+ );
66
+ if (!this.skipFilesWithError) {
67
+ throw err;
68
+ }
69
+ }
55
70
  }
56
71
  }
57
72
  }
@@ -37,6 +37,7 @@ export default {
37
37
  },
38
38
 
39
39
  async exportFiles(files, reqParams = {}) {
40
+ debugger;
40
41
  if (!this.FilesExport) throw new Error('FilesExport is not initialized');
41
42
  const exportFiles = files || this.getSelectedFiles();
42
43
  try {