@haex-space/vault-sdk 2.5.42 → 2.5.45

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/dist/react.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { H as HaexVaultSdk, S as StorageAPI } from './client-BAu3VPE3.mjs';
1
+ import { H as HaexVaultSdk, S as StorageAPI } from './client-BDxVgihp.mjs';
2
2
  import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
3
3
  import { H as HaexHubConfig, a as ExtensionInfo, A as ApplicationContext } from './types-DiXJ5SF6.mjs';
4
4
 
package/dist/react.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { H as HaexVaultSdk, S as StorageAPI } from './client-CF0wJxT2.js';
1
+ import { H as HaexVaultSdk, S as StorageAPI } from './client-Bgu2k1yJ.js';
2
2
  import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
3
3
  import { H as HaexHubConfig, a as ExtensionInfo, A as ApplicationContext } from './types-DiXJ5SF6.js';
4
4
 
package/dist/react.js CHANGED
@@ -400,50 +400,19 @@ var HAEXTENSION_METHODS = {
400
400
  filesystem: {
401
401
  saveFile: "haextension:filesystem:save-file",
402
402
  openFile: "haextension:filesystem:open-file",
403
- showImage: "haextension:filesystem:show-image"
404
- },
405
- filesync: {
406
- // Spaces
407
- listSpaces: "haextension:filesync:list-spaces",
408
- createSpace: "haextension:filesync:create-space",
409
- deleteSpace: "haextension:filesync:delete-space",
410
- // Files
411
- listFiles: "haextension:filesync:list-files",
412
- getFile: "haextension:filesync:get-file",
413
- uploadFile: "haextension:filesync:upload-file",
414
- downloadFile: "haextension:filesync:download-file",
415
- deleteFile: "haextension:filesync:delete-file",
416
- // Backends
417
- listBackends: "haextension:filesync:list-backends",
418
- addBackend: "haextension:filesync:add-backend",
419
- removeBackend: "haextension:filesync:remove-backend",
420
- testBackend: "haextension:filesync:test-backend",
421
- // Sync Rules
422
- listSyncRules: "haextension:filesync:list-sync-rules",
423
- addSyncRule: "haextension:filesync:add-sync-rule",
424
- updateSyncRule: "haextension:filesync:update-sync-rule",
425
- removeSyncRule: "haextension:filesync:remove-sync-rule",
426
- // Sync Operations
427
- getSyncStatus: "haextension:filesync:get-sync-status",
428
- triggerSync: "haextension:filesync:trigger-sync",
429
- pauseSync: "haextension:filesync:pause-sync",
430
- resumeSync: "haextension:filesync:resume-sync",
431
- // Conflict Resolution
432
- resolveConflict: "haextension:filesync:resolve-conflict",
433
- // UI Helpers
434
- selectFolder: "haextension:filesync:select-folder",
435
- scanLocal: "haextension:filesync:scan-local",
436
- // Sync Queue (persistent upload/download queue)
437
- addToQueue: "haextension:filesync:add-to-queue",
438
- getQueue: "haextension:filesync:get-queue",
439
- getQueueSummary: "haextension:filesync:get-queue-summary",
440
- startQueueEntry: "haextension:filesync:start-queue-entry",
441
- completeQueueEntry: "haextension:filesync:complete-queue-entry",
442
- failQueueEntry: "haextension:filesync:fail-queue-entry",
443
- retryFailedQueue: "haextension:filesync:retry-failed-queue",
444
- removeQueueEntry: "haextension:filesync:remove-queue-entry",
445
- clearQueue: "haextension:filesync:clear-queue",
446
- recoverQueue: "haextension:filesync:recover-queue"
403
+ showImage: "haextension:filesystem:show-image",
404
+ // Generic FS operations (Phase 2)
405
+ readFile: "haextension:filesystem:read-file",
406
+ writeFile: "haextension:filesystem:write-file",
407
+ readDir: "haextension:filesystem:read-dir",
408
+ mkdir: "haextension:filesystem:mkdir",
409
+ remove: "haextension:filesystem:remove",
410
+ exists: "haextension:filesystem:exists",
411
+ stat: "haextension:filesystem:stat",
412
+ selectFolder: "haextension:filesystem:select-folder",
413
+ selectFile: "haextension:filesystem:select-file",
414
+ rename: "haextension:filesystem:rename",
415
+ copy: "haextension:filesystem:copy"
447
416
  },
448
417
  storage: {
449
418
  getItem: "haextension:storage:get-item",
@@ -589,364 +558,193 @@ var DatabaseAPI = class {
589
558
  }
590
559
  };
591
560
 
592
- // src/api/filesync.ts
593
- var FileSyncAPI = class {
561
+ // src/api/filesystem.ts
562
+ var FilesystemAPI = class {
594
563
  constructor(client) {
595
564
  this.client = client;
596
565
  }
597
- // --------------------------------------------------------------------------
598
- // Spaces
599
- // --------------------------------------------------------------------------
600
- /**
601
- * List all file spaces
602
- */
603
- async listSpacesAsync() {
604
- return this.client.request(
605
- HAEXTENSION_METHODS.filesync.listSpaces
606
- );
607
- }
608
566
  /**
609
- * Create a new file space
610
- */
611
- async createSpaceAsync(options) {
612
- return this.client.request(
613
- HAEXTENSION_METHODS.filesync.createSpace,
614
- options
615
- );
616
- }
617
- /**
618
- * Delete a file space
619
- */
620
- async deleteSpaceAsync(spaceId) {
621
- await this.client.request(HAEXTENSION_METHODS.filesync.deleteSpace, {
622
- spaceId
623
- });
624
- }
625
- // --------------------------------------------------------------------------
626
- // Files
627
- // --------------------------------------------------------------------------
628
- /**
629
- * List files in a space
567
+ * Opens a save file dialog and saves the provided data to the selected location
568
+ * @param data The file data as Uint8Array
569
+ * @param options Options for the save dialog
570
+ * @returns The path where the file was saved, or null if cancelled
630
571
  */
631
- async listFilesAsync(options) {
632
- return this.client.request(
633
- HAEXTENSION_METHODS.filesync.listFiles,
634
- options
572
+ async saveFileAsync(data, options = {}) {
573
+ const result = await this.client.request(
574
+ HAEXTENSION_METHODS.filesystem.saveFile,
575
+ {
576
+ data: Array.from(data),
577
+ // Convert Uint8Array to regular array for postMessage
578
+ defaultPath: options.defaultPath,
579
+ title: options.title,
580
+ filters: options.filters
581
+ }
635
582
  );
583
+ return result;
636
584
  }
637
585
  /**
638
- * Scan local files in a sync rule folder
639
- * Returns unencrypted local files for display in the UI
586
+ * Opens a file with the system's default viewer
587
+ * @param data The file data as Uint8Array
588
+ * @param options Options for opening the file
589
+ * @returns The result of the operation
640
590
  */
641
- async scanLocalAsync(options) {
642
- return this.client.request(
643
- HAEXTENSION_METHODS.filesync.scanLocal,
644
- options
591
+ async openFileAsync(data, options) {
592
+ const result = await this.client.request(
593
+ HAEXTENSION_METHODS.filesystem.openFile,
594
+ {
595
+ data: Array.from(data),
596
+ // Convert Uint8Array to regular array for postMessage
597
+ fileName: options.fileName,
598
+ mimeType: options.mimeType
599
+ }
645
600
  );
601
+ return result;
646
602
  }
647
603
  /**
648
- * Get file info by ID
604
+ * Shows an image using a data URL (safe, read-only viewing)
605
+ * This is safe to use without special permissions as it only displays images
606
+ * and doesn't execute any code or open files with external applications
607
+ * @param options Options containing the data URL
608
+ * @returns The result of the operation
649
609
  */
650
- async getFileAsync(fileId) {
651
- return this.client.request(
652
- HAEXTENSION_METHODS.filesync.getFile,
653
- { fileId }
610
+ async showImageAsync(options) {
611
+ const result = await this.client.request(
612
+ HAEXTENSION_METHODS.filesystem.showImage,
613
+ {
614
+ dataUrl: options.dataUrl
615
+ }
654
616
  );
617
+ return result;
655
618
  }
619
+ // ==========================================================================
620
+ // Generic Filesystem Operations (Phase 2)
621
+ // ==========================================================================
656
622
  /**
657
- * Upload a file to the sync system
623
+ * Read file contents
624
+ * @param path Absolute path to the file
625
+ * @returns File contents as Uint8Array
658
626
  */
659
- async uploadFileAsync(options) {
660
- return this.client.request(
661
- HAEXTENSION_METHODS.filesync.uploadFile,
662
- options
627
+ async readFile(path) {
628
+ const base64 = await this.client.request(
629
+ HAEXTENSION_METHODS.filesystem.readFile,
630
+ { path }
663
631
  );
632
+ const binary = atob(base64);
633
+ const bytes = new Uint8Array(binary.length);
634
+ for (let i = 0; i < binary.length; i++) {
635
+ bytes[i] = binary.charCodeAt(i);
636
+ }
637
+ return bytes;
664
638
  }
665
639
  /**
666
- * Download a file to local storage
640
+ * Write file contents
641
+ * @param path Absolute path to the file
642
+ * @param data File contents as Uint8Array
667
643
  */
668
- async downloadFileAsync(options) {
644
+ async writeFile(path, data) {
645
+ const base64 = btoa(String.fromCharCode(...data));
669
646
  await this.client.request(
670
- HAEXTENSION_METHODS.filesync.downloadFile,
671
- options
647
+ HAEXTENSION_METHODS.filesystem.writeFile,
648
+ { path, data: base64 }
672
649
  );
673
650
  }
674
651
  /**
675
- * Delete a file from the sync system
652
+ * Read directory contents
653
+ * @param path Absolute path to the directory
654
+ * @returns Array of directory entries
676
655
  */
677
- async deleteFileAsync(fileId) {
678
- await this.client.request(HAEXTENSION_METHODS.filesync.deleteFile, {
679
- fileId
680
- });
681
- }
682
- // --------------------------------------------------------------------------
683
- // Storage Backends
684
- // --------------------------------------------------------------------------
685
- /**
686
- * List configured storage backends
687
- */
688
- async listBackendsAsync() {
689
- return this.client.request(
690
- HAEXTENSION_METHODS.filesync.listBackends
691
- );
692
- }
693
- /**
694
- * Add a new storage backend
695
- */
696
- async addBackendAsync(options) {
656
+ async readDir(path) {
697
657
  return this.client.request(
698
- HAEXTENSION_METHODS.filesync.addBackend,
699
- options
658
+ HAEXTENSION_METHODS.filesystem.readDir,
659
+ { path }
700
660
  );
701
661
  }
702
662
  /**
703
- * Remove a storage backend
704
- */
705
- async removeBackendAsync(backendId) {
706
- await this.client.request(HAEXTENSION_METHODS.filesync.removeBackend, {
707
- backendId
708
- });
709
- }
710
- /**
711
- * Test backend connection
663
+ * Create a directory (and parent directories if needed)
664
+ * @param path Absolute path to create
712
665
  */
713
- async testBackendAsync(backendId) {
714
- return this.client.request(
715
- HAEXTENSION_METHODS.filesync.testBackend,
716
- { backendId }
666
+ async mkdir(path) {
667
+ await this.client.request(
668
+ HAEXTENSION_METHODS.filesystem.mkdir,
669
+ { path }
717
670
  );
718
671
  }
719
- // --------------------------------------------------------------------------
720
- // Sync Rules
721
- // --------------------------------------------------------------------------
722
672
  /**
723
- * List sync rules
673
+ * Remove a file or directory
674
+ * @param path Absolute path to remove
675
+ * @param recursive If true, remove directories recursively
724
676
  */
725
- async listSyncRulesAsync() {
726
- return this.client.request(
727
- HAEXTENSION_METHODS.filesync.listSyncRules
677
+ async remove(path, recursive = false) {
678
+ await this.client.request(
679
+ HAEXTENSION_METHODS.filesystem.remove,
680
+ { path, recursive }
728
681
  );
729
682
  }
730
683
  /**
731
- * Add a sync rule
684
+ * Check if a path exists
685
+ * @param path Absolute path to check
686
+ * @returns True if the path exists
732
687
  */
733
- async addSyncRuleAsync(options) {
688
+ async exists(path) {
734
689
  return this.client.request(
735
- HAEXTENSION_METHODS.filesync.addSyncRule,
736
- options
690
+ HAEXTENSION_METHODS.filesystem.exists,
691
+ { path }
737
692
  );
738
693
  }
739
694
  /**
740
- * Update a sync rule
695
+ * Get file/directory metadata
696
+ * @param path Absolute path
697
+ * @returns File metadata
741
698
  */
742
- async updateSyncRuleAsync(options) {
699
+ async stat(path) {
743
700
  return this.client.request(
744
- HAEXTENSION_METHODS.filesync.updateSyncRule,
745
- options
701
+ HAEXTENSION_METHODS.filesystem.stat,
702
+ { path }
746
703
  );
747
704
  }
748
- /**
749
- * Remove a sync rule
750
- */
751
- async removeSyncRuleAsync(ruleId) {
752
- await this.client.request(HAEXTENSION_METHODS.filesync.removeSyncRule, {
753
- ruleId
754
- });
755
- }
756
- // --------------------------------------------------------------------------
757
- // Sync Operations
758
- // --------------------------------------------------------------------------
759
- /**
760
- * Get current sync status
761
- */
762
- async getSyncStatusAsync() {
763
- return this.client.request(
764
- HAEXTENSION_METHODS.filesync.getSyncStatus
765
- );
766
- }
767
- /**
768
- * Trigger a manual sync
769
- */
770
- async triggerSyncAsync() {
771
- await this.client.request(HAEXTENSION_METHODS.filesync.triggerSync);
772
- }
773
- /**
774
- * Pause syncing
775
- */
776
- async pauseSyncAsync() {
777
- await this.client.request(HAEXTENSION_METHODS.filesync.pauseSync);
778
- }
779
- /**
780
- * Resume syncing
781
- */
782
- async resumeSyncAsync() {
783
- await this.client.request(HAEXTENSION_METHODS.filesync.resumeSync);
784
- }
785
- // --------------------------------------------------------------------------
786
- // Conflict Resolution
787
- // --------------------------------------------------------------------------
788
- /**
789
- * Resolve a file conflict
790
- */
791
- async resolveConflictAsync(fileId, resolution) {
792
- await this.client.request(HAEXTENSION_METHODS.filesync.resolveConflict, {
793
- fileId,
794
- resolution
795
- });
796
- }
797
- // --------------------------------------------------------------------------
798
- // Folder Selection (Native Dialog)
799
- // --------------------------------------------------------------------------
800
705
  /**
801
706
  * Open a folder selection dialog
707
+ * @param options Dialog options
708
+ * @returns Selected folder path, or null if cancelled
802
709
  */
803
- async selectFolderAsync() {
804
- return this.client.request(
805
- HAEXTENSION_METHODS.filesync.selectFolder
806
- );
807
- }
808
- // --------------------------------------------------------------------------
809
- // Sync Queue
810
- // --------------------------------------------------------------------------
811
- /**
812
- * Add files to the sync queue
813
- */
814
- async addToQueueAsync(options) {
710
+ async selectFolder(options = {}) {
815
711
  return this.client.request(
816
- HAEXTENSION_METHODS.filesync.addToQueue,
712
+ HAEXTENSION_METHODS.filesystem.selectFolder,
817
713
  options
818
714
  );
819
715
  }
820
716
  /**
821
- * Get queue entries for the current device
717
+ * Open a file selection dialog
718
+ * @param options Dialog options
719
+ * @returns Selected file paths, or null if cancelled
822
720
  */
823
- async getQueueAsync(options) {
721
+ async selectFile(options = {}) {
824
722
  return this.client.request(
825
- HAEXTENSION_METHODS.filesync.getQueue,
723
+ HAEXTENSION_METHODS.filesystem.selectFile,
826
724
  options
827
725
  );
828
726
  }
829
727
  /**
830
- * Get aggregated queue summary for the current device
831
- */
832
- async getQueueSummaryAsync() {
833
- return this.client.request(
834
- HAEXTENSION_METHODS.filesync.getQueueSummary
835
- );
836
- }
837
- /**
838
- * Mark a queue entry as started (in_progress)
839
- */
840
- async startQueueEntryAsync(entryId) {
841
- await this.client.request(HAEXTENSION_METHODS.filesync.startQueueEntry, {
842
- entryId
843
- });
844
- }
845
- /**
846
- * Mark a queue entry as completed
847
- */
848
- async completeQueueEntryAsync(entryId) {
849
- await this.client.request(HAEXTENSION_METHODS.filesync.completeQueueEntry, {
850
- entryId
851
- });
852
- }
853
- /**
854
- * Mark a queue entry as failed
855
- */
856
- async failQueueEntryAsync(entryId, errorMessage) {
857
- await this.client.request(HAEXTENSION_METHODS.filesync.failQueueEntry, {
858
- entryId,
859
- errorMessage
860
- });
861
- }
862
- /**
863
- * Retry all failed queue entries (reset to pending)
864
- */
865
- async retryFailedQueueAsync() {
866
- await this.client.request(HAEXTENSION_METHODS.filesync.retryFailedQueue);
867
- }
868
- /**
869
- * Remove a queue entry
870
- */
871
- async removeQueueEntryAsync(entryId) {
872
- await this.client.request(HAEXTENSION_METHODS.filesync.removeQueueEntry, {
873
- entryId
874
- });
875
- }
876
- /**
877
- * Clear all queue entries for a sync rule
878
- */
879
- async clearQueueAsync(ruleId) {
880
- await this.client.request(HAEXTENSION_METHODS.filesync.clearQueue, {
881
- ruleId
882
- });
883
- }
884
- /**
885
- * Reset in_progress entries to pending (for recovery after crash)
886
- */
887
- async recoverQueueAsync() {
888
- await this.client.request(HAEXTENSION_METHODS.filesync.recoverQueue);
889
- }
890
- };
891
-
892
- // src/api/filesystem.ts
893
- var FilesystemAPI = class {
894
- constructor(client) {
895
- this.client = client;
896
- this.sync = new FileSyncAPI(client);
897
- }
898
- /**
899
- * Opens a save file dialog and saves the provided data to the selected location
900
- * @param data The file data as Uint8Array
901
- * @param options Options for the save dialog
902
- * @returns The path where the file was saved, or null if cancelled
903
- */
904
- async saveFileAsync(data, options = {}) {
905
- const result = await this.client.request(
906
- HAEXTENSION_METHODS.filesystem.saveFile,
907
- {
908
- data: Array.from(data),
909
- // Convert Uint8Array to regular array for postMessage
910
- defaultPath: options.defaultPath,
911
- title: options.title,
912
- filters: options.filters
913
- }
914
- );
915
- return result;
916
- }
917
- /**
918
- * Opens a file with the system's default viewer
919
- * @param data The file data as Uint8Array
920
- * @param options Options for opening the file
921
- * @returns The result of the operation
728
+ * Rename/move a file or directory
729
+ * @param from Source path
730
+ * @param to Destination path
922
731
  */
923
- async openFileAsync(data, options) {
924
- const result = await this.client.request(
925
- HAEXTENSION_METHODS.filesystem.openFile,
926
- {
927
- data: Array.from(data),
928
- // Convert Uint8Array to regular array for postMessage
929
- fileName: options.fileName,
930
- mimeType: options.mimeType
931
- }
732
+ async rename(from, to) {
733
+ await this.client.request(
734
+ HAEXTENSION_METHODS.filesystem.rename,
735
+ { from, to }
932
736
  );
933
- return result;
934
737
  }
935
738
  /**
936
- * Shows an image using a data URL (safe, read-only viewing)
937
- * This is safe to use without special permissions as it only displays images
938
- * and doesn't execute any code or open files with external applications
939
- * @param options Options containing the data URL
940
- * @returns The result of the operation
739
+ * Copy a file
740
+ * @param from Source path
741
+ * @param to Destination path
941
742
  */
942
- async showImageAsync(options) {
943
- const result = await this.client.request(
944
- HAEXTENSION_METHODS.filesystem.showImage,
945
- {
946
- dataUrl: options.dataUrl
947
- }
743
+ async copy(from, to) {
744
+ await this.client.request(
745
+ HAEXTENSION_METHODS.filesystem.copy,
746
+ { from, to }
948
747
  );
949
- return result;
950
748
  }
951
749
  };
952
750
 
@@ -1442,8 +1240,7 @@ var TAURI_COMMANDS = {
1442
1240
  filesystem: {
1443
1241
  saveFile: "webview_extension_fs_save_file",
1444
1242
  openFile: "webview_extension_fs_open_file",
1445
- showImage: "webview_extension_fs_show_image"
1446
- },
1243
+ showImage: "webview_extension_fs_show_image"},
1447
1244
  external: {
1448
1245
  // Response handling (called by extensions running in WebView)
1449
1246
  respond: "webview_extension_external_respond"},