@haex-space/vault-sdk 2.5.40 → 2.5.43

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.
@@ -72,7 +72,19 @@ var HAEXTENSION_METHODS = {
72
72
  filesystem: {
73
73
  saveFile: "haextension:filesystem:save-file",
74
74
  openFile: "haextension:filesystem:open-file",
75
- showImage: "haextension:filesystem:show-image"
75
+ showImage: "haextension:filesystem:show-image",
76
+ // Generic FS operations (Phase 2)
77
+ readFile: "haextension:filesystem:read-file",
78
+ writeFile: "haextension:filesystem:write-file",
79
+ readDir: "haextension:filesystem:read-dir",
80
+ mkdir: "haextension:filesystem:mkdir",
81
+ remove: "haextension:filesystem:remove",
82
+ exists: "haextension:filesystem:exists",
83
+ stat: "haextension:filesystem:stat",
84
+ selectFolder: "haextension:filesystem:select-folder",
85
+ selectFile: "haextension:filesystem:select-file",
86
+ rename: "haextension:filesystem:rename",
87
+ copy: "haextension:filesystem:copy"
76
88
  },
77
89
  filesync: {
78
90
  // Spaces
@@ -124,6 +136,19 @@ var HAEXTENSION_METHODS = {
124
136
  clear: "haextension:storage:clear",
125
137
  keys: "haextension:storage:keys"
126
138
  },
139
+ // Remote Storage API (S3, WebDAV, FTP, etc.)
140
+ remoteStorage: {
141
+ // Backend Management
142
+ listBackends: "haextension:remote-storage:list-backends",
143
+ addBackend: "haextension:remote-storage:add-backend",
144
+ removeBackend: "haextension:remote-storage:remove-backend",
145
+ testBackend: "haextension:remote-storage:test-backend",
146
+ // Storage Operations
147
+ upload: "haextension:remote-storage:upload",
148
+ download: "haextension:remote-storage:download",
149
+ delete: "haextension:remote-storage:delete",
150
+ list: "haextension:remote-storage:list"
151
+ },
127
152
  web: {
128
153
  fetch: "haextension:web:fetch"
129
154
  },
@@ -607,6 +632,136 @@ var FilesystemAPI = class {
607
632
  );
608
633
  return result;
609
634
  }
635
+ // ==========================================================================
636
+ // Generic Filesystem Operations (Phase 2)
637
+ // ==========================================================================
638
+ /**
639
+ * Read file contents
640
+ * @param path Absolute path to the file
641
+ * @returns File contents as Uint8Array
642
+ */
643
+ async readFile(path) {
644
+ const base64 = await this.client.request(
645
+ HAEXTENSION_METHODS.filesystem.readFile,
646
+ { path }
647
+ );
648
+ const binary = atob(base64);
649
+ const bytes = new Uint8Array(binary.length);
650
+ for (let i = 0; i < binary.length; i++) {
651
+ bytes[i] = binary.charCodeAt(i);
652
+ }
653
+ return bytes;
654
+ }
655
+ /**
656
+ * Write file contents
657
+ * @param path Absolute path to the file
658
+ * @param data File contents as Uint8Array
659
+ */
660
+ async writeFile(path, data) {
661
+ const base64 = btoa(String.fromCharCode(...data));
662
+ await this.client.request(
663
+ HAEXTENSION_METHODS.filesystem.writeFile,
664
+ { path, data: base64 }
665
+ );
666
+ }
667
+ /**
668
+ * Read directory contents
669
+ * @param path Absolute path to the directory
670
+ * @returns Array of directory entries
671
+ */
672
+ async readDir(path) {
673
+ return this.client.request(
674
+ HAEXTENSION_METHODS.filesystem.readDir,
675
+ { path }
676
+ );
677
+ }
678
+ /**
679
+ * Create a directory (and parent directories if needed)
680
+ * @param path Absolute path to create
681
+ */
682
+ async mkdir(path) {
683
+ await this.client.request(
684
+ HAEXTENSION_METHODS.filesystem.mkdir,
685
+ { path }
686
+ );
687
+ }
688
+ /**
689
+ * Remove a file or directory
690
+ * @param path Absolute path to remove
691
+ * @param recursive If true, remove directories recursively
692
+ */
693
+ async remove(path, recursive = false) {
694
+ await this.client.request(
695
+ HAEXTENSION_METHODS.filesystem.remove,
696
+ { path, recursive }
697
+ );
698
+ }
699
+ /**
700
+ * Check if a path exists
701
+ * @param path Absolute path to check
702
+ * @returns True if the path exists
703
+ */
704
+ async exists(path) {
705
+ return this.client.request(
706
+ HAEXTENSION_METHODS.filesystem.exists,
707
+ { path }
708
+ );
709
+ }
710
+ /**
711
+ * Get file/directory metadata
712
+ * @param path Absolute path
713
+ * @returns File metadata
714
+ */
715
+ async stat(path) {
716
+ return this.client.request(
717
+ HAEXTENSION_METHODS.filesystem.stat,
718
+ { path }
719
+ );
720
+ }
721
+ /**
722
+ * Open a folder selection dialog
723
+ * @param options Dialog options
724
+ * @returns Selected folder path, or null if cancelled
725
+ */
726
+ async selectFolder(options = {}) {
727
+ return this.client.request(
728
+ HAEXTENSION_METHODS.filesystem.selectFolder,
729
+ options
730
+ );
731
+ }
732
+ /**
733
+ * Open a file selection dialog
734
+ * @param options Dialog options
735
+ * @returns Selected file paths, or null if cancelled
736
+ */
737
+ async selectFile(options = {}) {
738
+ return this.client.request(
739
+ HAEXTENSION_METHODS.filesystem.selectFile,
740
+ options
741
+ );
742
+ }
743
+ /**
744
+ * Rename/move a file or directory
745
+ * @param from Source path
746
+ * @param to Destination path
747
+ */
748
+ async rename(from, to) {
749
+ await this.client.request(
750
+ HAEXTENSION_METHODS.filesystem.rename,
751
+ { from, to }
752
+ );
753
+ }
754
+ /**
755
+ * Copy a file
756
+ * @param from Source path
757
+ * @param to Destination path
758
+ */
759
+ async copy(from, to) {
760
+ await this.client.request(
761
+ HAEXTENSION_METHODS.filesystem.copy,
762
+ { from, to }
763
+ );
764
+ }
610
765
  };
611
766
 
612
767
  // src/api/web.ts
@@ -776,6 +931,111 @@ var PermissionsAPI = class {
776
931
  }
777
932
  };
778
933
 
934
+ // src/api/remoteStorage.ts
935
+ var RemoteStorageAPI = class {
936
+ constructor(client) {
937
+ this.client = client;
938
+ this.backends = new BackendManagement(client);
939
+ }
940
+ /**
941
+ * Upload data to a storage backend
942
+ * @param backendId - Backend ID to upload to
943
+ * @param key - Object key (path in the bucket)
944
+ * @param data - Data to upload
945
+ */
946
+ async upload(backendId, key, data) {
947
+ const base64 = btoa(String.fromCharCode(...data));
948
+ await this.client.request(HAEXTENSION_METHODS.remoteStorage.upload, {
949
+ backendId,
950
+ key,
951
+ data: base64
952
+ });
953
+ }
954
+ /**
955
+ * Download data from a storage backend
956
+ * @param backendId - Backend ID to download from
957
+ * @param key - Object key (path in the bucket)
958
+ * @returns Downloaded data as Uint8Array
959
+ */
960
+ async download(backendId, key) {
961
+ const base64 = await this.client.request(
962
+ HAEXTENSION_METHODS.remoteStorage.download,
963
+ { backendId, key }
964
+ );
965
+ const binary = atob(base64);
966
+ const bytes = new Uint8Array(binary.length);
967
+ for (let i = 0; i < binary.length; i++) {
968
+ bytes[i] = binary.charCodeAt(i);
969
+ }
970
+ return bytes;
971
+ }
972
+ /**
973
+ * Delete an object from a storage backend
974
+ * @param backendId - Backend ID
975
+ * @param key - Object key to delete
976
+ */
977
+ async delete(backendId, key) {
978
+ await this.client.request(HAEXTENSION_METHODS.remoteStorage.delete, {
979
+ backendId,
980
+ key
981
+ });
982
+ }
983
+ /**
984
+ * List objects in a storage backend
985
+ * @param backendId - Backend ID
986
+ * @param prefix - Optional prefix to filter objects
987
+ * @returns List of objects
988
+ */
989
+ async list(backendId, prefix) {
990
+ return this.client.request(
991
+ HAEXTENSION_METHODS.remoteStorage.list,
992
+ { backendId, prefix }
993
+ );
994
+ }
995
+ };
996
+ var BackendManagement = class {
997
+ constructor(client) {
998
+ this.client = client;
999
+ }
1000
+ /**
1001
+ * List all available storage backends
1002
+ */
1003
+ async list() {
1004
+ return this.client.request(
1005
+ HAEXTENSION_METHODS.remoteStorage.listBackends
1006
+ );
1007
+ }
1008
+ /**
1009
+ * Add a new storage backend
1010
+ * @param request - Backend configuration
1011
+ * @returns Created backend info
1012
+ */
1013
+ async add(request) {
1014
+ return this.client.request(
1015
+ HAEXTENSION_METHODS.remoteStorage.addBackend,
1016
+ request
1017
+ );
1018
+ }
1019
+ /**
1020
+ * Remove a storage backend
1021
+ * @param backendId - Backend ID to remove
1022
+ */
1023
+ async remove(backendId) {
1024
+ await this.client.request(HAEXTENSION_METHODS.remoteStorage.removeBackend, {
1025
+ backendId
1026
+ });
1027
+ }
1028
+ /**
1029
+ * Test connection to a storage backend
1030
+ * @param backendId - Backend ID to test
1031
+ */
1032
+ async test(backendId) {
1033
+ await this.client.request(HAEXTENSION_METHODS.remoteStorage.testBackend, {
1034
+ backendId
1035
+ });
1036
+ }
1037
+ };
1038
+
779
1039
  // src/messages.ts
780
1040
  var HAEXSPACE_MESSAGE_TYPES = {
781
1041
  /** Debug message for development/troubleshooting */
@@ -1070,8 +1330,7 @@ var TAURI_COMMANDS = {
1070
1330
  filesystem: {
1071
1331
  saveFile: "webview_extension_fs_save_file",
1072
1332
  openFile: "webview_extension_fs_open_file",
1073
- showImage: "webview_extension_fs_show_image"
1074
- },
1333
+ showImage: "webview_extension_fs_show_image"},
1075
1334
  external: {
1076
1335
  // Response handling (called by extensions running in WebView)
1077
1336
  respond: "webview_extension_external_respond"},
@@ -1695,6 +1954,7 @@ var HaexVaultSdk = class {
1695
1954
  this.filesystem = new FilesystemAPI(this);
1696
1955
  this.web = new WebAPI(this);
1697
1956
  this.permissions = new PermissionsAPI(this);
1957
+ this.remoteStorage = new RemoteStorageAPI(this);
1698
1958
  installConsoleForwarding(this.config.debug);
1699
1959
  this.readyPromise = new Promise((resolve) => {
1700
1960
  this.resolveReady = resolve;