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