bytex-sdk 1.6.0 → 1.7.0

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.
Files changed (2) hide show
  1. package/index.js +21 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -470,22 +470,37 @@ export class BytexCloud {
470
470
  * @param {object} [options] - { JSZip: JSZipConstructor, zipName: 'bytex-export.zip' }
471
471
  * @returns {Blob} ZIP file blob
472
472
  */
473
+ /**
474
+ * Export files as a single ZIP download (browser only).
475
+ * @param {object} [options] - { projectLabel, JSZip, zipName }
476
+ * @returns {Blob} ZIP file blob
477
+ */
473
478
  async exportZip(options = {}) {
474
479
  const JSZipLib = options.JSZip || (typeof globalThis !== 'undefined' && globalThis.JSZip);
475
- if (!JSZipLib) throw new Error('exportZip requires JSZip. Install it: npm install jszip');
480
+ if (!JSZipLib) throw new Error('exportZip requires JSZip.');
476
481
 
477
482
  const zip = new JSZipLib();
478
- const allFiles = await this.downloadAll();
479
- for (const [name, blob] of Object.entries(allFiles)) {
480
- zip.file(name, blob);
483
+ const files = await this.listFiles();
484
+
485
+ // Filter by project label if provided
486
+ const filteredFiles = options.projectLabel
487
+ ? files.filter(f => f.key_label === options.projectLabel)
488
+ : files;
489
+
490
+ for (const file of filteredFiles) {
491
+ try {
492
+ const blob = await this.download(file.file_name || file.path);
493
+ const name = (file.file_name || file.path || 'file').replace(/\.stream\.btx$/i, '');
494
+ zip.file(name, blob);
495
+ } catch (e) { console.warn(`Failed to include ${file.file_name} in ZIP`); }
481
496
  }
497
+
482
498
  const zipBlob = await zip.generateAsync({ type: 'blob' });
483
499
 
484
- // Auto-download in browser
485
500
  if (typeof document !== 'undefined') {
486
501
  const a = document.createElement('a');
487
502
  a.href = URL.createObjectURL(zipBlob);
488
- a.download = options.zipName || 'bytex-export.zip';
503
+ a.download = options.zipName || (options.projectLabel ? `bytex-${options.projectLabel}.zip` : 'bytex-export.zip');
489
504
  a.click();
490
505
  URL.revokeObjectURL(a.href);
491
506
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bytex-sdk",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {