bytex-sdk 1.6.0 → 1.7.1

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 +37 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -35,6 +35,22 @@ export class BytexCloud {
35
35
  this._projectScope = 'production';
36
36
  }
37
37
 
38
+ /**
39
+ * Dynamically update infrastructure settings (BYOC).
40
+ * @param {object} config - { supabaseUrl, supabaseKey, workerUrl, dbProvider }
41
+ */
42
+ configure(config = {}) {
43
+ if (config.workerUrl) this.workerUrl = config.workerUrl;
44
+ if (config.dbProvider) this.provider = config.dbProvider;
45
+
46
+ if (this.provider === 'supabase' && (config.supabaseUrl || config.supabaseKey)) {
47
+ const url = config.supabaseUrl || this.supabase.supabaseUrl;
48
+ const key = config.supabaseKey || this.supabase.supabaseKey;
49
+ this.supabase = createClient(url, key);
50
+ }
51
+ console.log('[ByteX SDK] Configuration updated.');
52
+ }
53
+
38
54
  // ─────────────────────────────────────────────
39
55
  // SECTION 1: AUTHENTICATION
40
56
  // ─────────────────────────────────────────────
@@ -470,22 +486,37 @@ export class BytexCloud {
470
486
  * @param {object} [options] - { JSZip: JSZipConstructor, zipName: 'bytex-export.zip' }
471
487
  * @returns {Blob} ZIP file blob
472
488
  */
489
+ /**
490
+ * Export files as a single ZIP download (browser only).
491
+ * @param {object} [options] - { projectLabel, JSZip, zipName }
492
+ * @returns {Blob} ZIP file blob
493
+ */
473
494
  async exportZip(options = {}) {
474
495
  const JSZipLib = options.JSZip || (typeof globalThis !== 'undefined' && globalThis.JSZip);
475
- if (!JSZipLib) throw new Error('exportZip requires JSZip. Install it: npm install jszip');
496
+ if (!JSZipLib) throw new Error('exportZip requires JSZip.');
476
497
 
477
498
  const zip = new JSZipLib();
478
- const allFiles = await this.downloadAll();
479
- for (const [name, blob] of Object.entries(allFiles)) {
480
- zip.file(name, blob);
499
+ const files = await this.listFiles();
500
+
501
+ // Filter by project label if provided
502
+ const filteredFiles = options.projectLabel
503
+ ? files.filter(f => f.key_label === options.projectLabel)
504
+ : files;
505
+
506
+ for (const file of filteredFiles) {
507
+ try {
508
+ const blob = await this.download(file.file_name || file.path);
509
+ const name = (file.file_name || file.path || 'file').replace(/\.stream\.btx$/i, '');
510
+ zip.file(name, blob);
511
+ } catch (e) { console.warn(`Failed to include ${file.file_name} in ZIP`); }
481
512
  }
513
+
482
514
  const zipBlob = await zip.generateAsync({ type: 'blob' });
483
515
 
484
- // Auto-download in browser
485
516
  if (typeof document !== 'undefined') {
486
517
  const a = document.createElement('a');
487
518
  a.href = URL.createObjectURL(zipBlob);
488
- a.download = options.zipName || 'bytex-export.zip';
519
+ a.download = options.zipName || (options.projectLabel ? `bytex-${options.projectLabel}.zip` : 'bytex-export.zip');
489
520
  a.click();
490
521
  URL.revokeObjectURL(a.href);
491
522
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bytex-sdk",
3
- "version": "1.6.0",
3
+ "version": "1.7.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {