@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.
@@ -1,6 +1,6 @@
1
1
  import * as nuxt_app from 'nuxt/app';
2
2
  import { ShallowRef } from 'vue';
3
- import { H as HaexVaultSdk } from '../client-BAu3VPE3.mjs';
3
+ import { H as HaexVaultSdk } from '../client-BDxVgihp.mjs';
4
4
  import { A as ApplicationContext } from '../types-DiXJ5SF6.mjs';
5
5
  import 'drizzle-orm/sqlite-proxy';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import * as nuxt_app from 'nuxt/app';
2
2
  import { ShallowRef } from 'vue';
3
- import { H as HaexVaultSdk } from '../client-CF0wJxT2.js';
3
+ import { H as HaexVaultSdk } from '../client-Bgu2k1yJ.js';
4
4
  import { A as ApplicationContext } from '../types-DiXJ5SF6.js';
5
5
  import 'drizzle-orm/sqlite-proxy';
6
6
 
@@ -74,50 +74,19 @@ var HAEXTENSION_METHODS = {
74
74
  filesystem: {
75
75
  saveFile: "haextension:filesystem:save-file",
76
76
  openFile: "haextension:filesystem:open-file",
77
- showImage: "haextension:filesystem:show-image"
78
- },
79
- filesync: {
80
- // Spaces
81
- listSpaces: "haextension:filesync:list-spaces",
82
- createSpace: "haextension:filesync:create-space",
83
- deleteSpace: "haextension:filesync:delete-space",
84
- // Files
85
- listFiles: "haextension:filesync:list-files",
86
- getFile: "haextension:filesync:get-file",
87
- uploadFile: "haextension:filesync:upload-file",
88
- downloadFile: "haextension:filesync:download-file",
89
- deleteFile: "haextension:filesync:delete-file",
90
- // Backends
91
- listBackends: "haextension:filesync:list-backends",
92
- addBackend: "haextension:filesync:add-backend",
93
- removeBackend: "haextension:filesync:remove-backend",
94
- testBackend: "haextension:filesync:test-backend",
95
- // Sync Rules
96
- listSyncRules: "haextension:filesync:list-sync-rules",
97
- addSyncRule: "haextension:filesync:add-sync-rule",
98
- updateSyncRule: "haextension:filesync:update-sync-rule",
99
- removeSyncRule: "haextension:filesync:remove-sync-rule",
100
- // Sync Operations
101
- getSyncStatus: "haextension:filesync:get-sync-status",
102
- triggerSync: "haextension:filesync:trigger-sync",
103
- pauseSync: "haextension:filesync:pause-sync",
104
- resumeSync: "haextension:filesync:resume-sync",
105
- // Conflict Resolution
106
- resolveConflict: "haextension:filesync:resolve-conflict",
107
- // UI Helpers
108
- selectFolder: "haextension:filesync:select-folder",
109
- scanLocal: "haextension:filesync:scan-local",
110
- // Sync Queue (persistent upload/download queue)
111
- addToQueue: "haextension:filesync:add-to-queue",
112
- getQueue: "haextension:filesync:get-queue",
113
- getQueueSummary: "haextension:filesync:get-queue-summary",
114
- startQueueEntry: "haextension:filesync:start-queue-entry",
115
- completeQueueEntry: "haextension:filesync:complete-queue-entry",
116
- failQueueEntry: "haextension:filesync:fail-queue-entry",
117
- retryFailedQueue: "haextension:filesync:retry-failed-queue",
118
- removeQueueEntry: "haextension:filesync:remove-queue-entry",
119
- clearQueue: "haextension:filesync:clear-queue",
120
- recoverQueue: "haextension:filesync:recover-queue"
77
+ showImage: "haextension:filesystem:show-image",
78
+ // Generic FS operations (Phase 2)
79
+ readFile: "haextension:filesystem:read-file",
80
+ writeFile: "haextension:filesystem:write-file",
81
+ readDir: "haextension:filesystem:read-dir",
82
+ mkdir: "haextension:filesystem:mkdir",
83
+ remove: "haextension:filesystem:remove",
84
+ exists: "haextension:filesystem:exists",
85
+ stat: "haextension:filesystem:stat",
86
+ selectFolder: "haextension:filesystem:select-folder",
87
+ selectFile: "haextension:filesystem:select-file",
88
+ rename: "haextension:filesystem:rename",
89
+ copy: "haextension:filesystem:copy"
121
90
  },
122
91
  storage: {
123
92
  getItem: "haextension:storage:get-item",
@@ -263,364 +232,193 @@ var DatabaseAPI = class {
263
232
  }
264
233
  };
265
234
 
266
- // src/api/filesync.ts
267
- var FileSyncAPI = class {
235
+ // src/api/filesystem.ts
236
+ var FilesystemAPI = class {
268
237
  constructor(client) {
269
238
  this.client = client;
270
239
  }
271
- // --------------------------------------------------------------------------
272
- // Spaces
273
- // --------------------------------------------------------------------------
274
- /**
275
- * List all file spaces
276
- */
277
- async listSpacesAsync() {
278
- return this.client.request(
279
- HAEXTENSION_METHODS.filesync.listSpaces
280
- );
281
- }
282
240
  /**
283
- * Create a new file space
284
- */
285
- async createSpaceAsync(options) {
286
- return this.client.request(
287
- HAEXTENSION_METHODS.filesync.createSpace,
288
- options
289
- );
290
- }
291
- /**
292
- * Delete a file space
293
- */
294
- async deleteSpaceAsync(spaceId) {
295
- await this.client.request(HAEXTENSION_METHODS.filesync.deleteSpace, {
296
- spaceId
297
- });
298
- }
299
- // --------------------------------------------------------------------------
300
- // Files
301
- // --------------------------------------------------------------------------
302
- /**
303
- * List files in a space
241
+ * Opens a save file dialog and saves the provided data to the selected location
242
+ * @param data The file data as Uint8Array
243
+ * @param options Options for the save dialog
244
+ * @returns The path where the file was saved, or null if cancelled
304
245
  */
305
- async listFilesAsync(options) {
306
- return this.client.request(
307
- HAEXTENSION_METHODS.filesync.listFiles,
308
- options
246
+ async saveFileAsync(data, options = {}) {
247
+ const result = await this.client.request(
248
+ HAEXTENSION_METHODS.filesystem.saveFile,
249
+ {
250
+ data: Array.from(data),
251
+ // Convert Uint8Array to regular array for postMessage
252
+ defaultPath: options.defaultPath,
253
+ title: options.title,
254
+ filters: options.filters
255
+ }
309
256
  );
257
+ return result;
310
258
  }
311
259
  /**
312
- * Scan local files in a sync rule folder
313
- * Returns unencrypted local files for display in the UI
260
+ * Opens a file with the system's default viewer
261
+ * @param data The file data as Uint8Array
262
+ * @param options Options for opening the file
263
+ * @returns The result of the operation
314
264
  */
315
- async scanLocalAsync(options) {
316
- return this.client.request(
317
- HAEXTENSION_METHODS.filesync.scanLocal,
318
- options
265
+ async openFileAsync(data, options) {
266
+ const result = await this.client.request(
267
+ HAEXTENSION_METHODS.filesystem.openFile,
268
+ {
269
+ data: Array.from(data),
270
+ // Convert Uint8Array to regular array for postMessage
271
+ fileName: options.fileName,
272
+ mimeType: options.mimeType
273
+ }
319
274
  );
275
+ return result;
320
276
  }
321
277
  /**
322
- * Get file info by ID
278
+ * Shows an image using a data URL (safe, read-only viewing)
279
+ * This is safe to use without special permissions as it only displays images
280
+ * and doesn't execute any code or open files with external applications
281
+ * @param options Options containing the data URL
282
+ * @returns The result of the operation
323
283
  */
324
- async getFileAsync(fileId) {
325
- return this.client.request(
326
- HAEXTENSION_METHODS.filesync.getFile,
327
- { fileId }
284
+ async showImageAsync(options) {
285
+ const result = await this.client.request(
286
+ HAEXTENSION_METHODS.filesystem.showImage,
287
+ {
288
+ dataUrl: options.dataUrl
289
+ }
328
290
  );
291
+ return result;
329
292
  }
293
+ // ==========================================================================
294
+ // Generic Filesystem Operations (Phase 2)
295
+ // ==========================================================================
330
296
  /**
331
- * Upload a file to the sync system
297
+ * Read file contents
298
+ * @param path Absolute path to the file
299
+ * @returns File contents as Uint8Array
332
300
  */
333
- async uploadFileAsync(options) {
334
- return this.client.request(
335
- HAEXTENSION_METHODS.filesync.uploadFile,
336
- options
301
+ async readFile(path) {
302
+ const base64 = await this.client.request(
303
+ HAEXTENSION_METHODS.filesystem.readFile,
304
+ { path }
337
305
  );
306
+ const binary = atob(base64);
307
+ const bytes = new Uint8Array(binary.length);
308
+ for (let i = 0; i < binary.length; i++) {
309
+ bytes[i] = binary.charCodeAt(i);
310
+ }
311
+ return bytes;
338
312
  }
339
313
  /**
340
- * Download a file to local storage
314
+ * Write file contents
315
+ * @param path Absolute path to the file
316
+ * @param data File contents as Uint8Array
341
317
  */
342
- async downloadFileAsync(options) {
318
+ async writeFile(path, data) {
319
+ const base64 = btoa(String.fromCharCode(...data));
343
320
  await this.client.request(
344
- HAEXTENSION_METHODS.filesync.downloadFile,
345
- options
321
+ HAEXTENSION_METHODS.filesystem.writeFile,
322
+ { path, data: base64 }
346
323
  );
347
324
  }
348
325
  /**
349
- * Delete a file from the sync system
326
+ * Read directory contents
327
+ * @param path Absolute path to the directory
328
+ * @returns Array of directory entries
350
329
  */
351
- async deleteFileAsync(fileId) {
352
- await this.client.request(HAEXTENSION_METHODS.filesync.deleteFile, {
353
- fileId
354
- });
355
- }
356
- // --------------------------------------------------------------------------
357
- // Storage Backends
358
- // --------------------------------------------------------------------------
359
- /**
360
- * List configured storage backends
361
- */
362
- async listBackendsAsync() {
363
- return this.client.request(
364
- HAEXTENSION_METHODS.filesync.listBackends
365
- );
366
- }
367
- /**
368
- * Add a new storage backend
369
- */
370
- async addBackendAsync(options) {
330
+ async readDir(path) {
371
331
  return this.client.request(
372
- HAEXTENSION_METHODS.filesync.addBackend,
373
- options
332
+ HAEXTENSION_METHODS.filesystem.readDir,
333
+ { path }
374
334
  );
375
335
  }
376
336
  /**
377
- * Remove a storage backend
378
- */
379
- async removeBackendAsync(backendId) {
380
- await this.client.request(HAEXTENSION_METHODS.filesync.removeBackend, {
381
- backendId
382
- });
383
- }
384
- /**
385
- * Test backend connection
337
+ * Create a directory (and parent directories if needed)
338
+ * @param path Absolute path to create
386
339
  */
387
- async testBackendAsync(backendId) {
388
- return this.client.request(
389
- HAEXTENSION_METHODS.filesync.testBackend,
390
- { backendId }
340
+ async mkdir(path) {
341
+ await this.client.request(
342
+ HAEXTENSION_METHODS.filesystem.mkdir,
343
+ { path }
391
344
  );
392
345
  }
393
- // --------------------------------------------------------------------------
394
- // Sync Rules
395
- // --------------------------------------------------------------------------
396
346
  /**
397
- * List sync rules
347
+ * Remove a file or directory
348
+ * @param path Absolute path to remove
349
+ * @param recursive If true, remove directories recursively
398
350
  */
399
- async listSyncRulesAsync() {
400
- return this.client.request(
401
- HAEXTENSION_METHODS.filesync.listSyncRules
351
+ async remove(path, recursive = false) {
352
+ await this.client.request(
353
+ HAEXTENSION_METHODS.filesystem.remove,
354
+ { path, recursive }
402
355
  );
403
356
  }
404
357
  /**
405
- * Add a sync rule
358
+ * Check if a path exists
359
+ * @param path Absolute path to check
360
+ * @returns True if the path exists
406
361
  */
407
- async addSyncRuleAsync(options) {
362
+ async exists(path) {
408
363
  return this.client.request(
409
- HAEXTENSION_METHODS.filesync.addSyncRule,
410
- options
364
+ HAEXTENSION_METHODS.filesystem.exists,
365
+ { path }
411
366
  );
412
367
  }
413
368
  /**
414
- * Update a sync rule
369
+ * Get file/directory metadata
370
+ * @param path Absolute path
371
+ * @returns File metadata
415
372
  */
416
- async updateSyncRuleAsync(options) {
373
+ async stat(path) {
417
374
  return this.client.request(
418
- HAEXTENSION_METHODS.filesync.updateSyncRule,
419
- options
375
+ HAEXTENSION_METHODS.filesystem.stat,
376
+ { path }
420
377
  );
421
378
  }
422
- /**
423
- * Remove a sync rule
424
- */
425
- async removeSyncRuleAsync(ruleId) {
426
- await this.client.request(HAEXTENSION_METHODS.filesync.removeSyncRule, {
427
- ruleId
428
- });
429
- }
430
- // --------------------------------------------------------------------------
431
- // Sync Operations
432
- // --------------------------------------------------------------------------
433
- /**
434
- * Get current sync status
435
- */
436
- async getSyncStatusAsync() {
437
- return this.client.request(
438
- HAEXTENSION_METHODS.filesync.getSyncStatus
439
- );
440
- }
441
- /**
442
- * Trigger a manual sync
443
- */
444
- async triggerSyncAsync() {
445
- await this.client.request(HAEXTENSION_METHODS.filesync.triggerSync);
446
- }
447
- /**
448
- * Pause syncing
449
- */
450
- async pauseSyncAsync() {
451
- await this.client.request(HAEXTENSION_METHODS.filesync.pauseSync);
452
- }
453
- /**
454
- * Resume syncing
455
- */
456
- async resumeSyncAsync() {
457
- await this.client.request(HAEXTENSION_METHODS.filesync.resumeSync);
458
- }
459
- // --------------------------------------------------------------------------
460
- // Conflict Resolution
461
- // --------------------------------------------------------------------------
462
- /**
463
- * Resolve a file conflict
464
- */
465
- async resolveConflictAsync(fileId, resolution) {
466
- await this.client.request(HAEXTENSION_METHODS.filesync.resolveConflict, {
467
- fileId,
468
- resolution
469
- });
470
- }
471
- // --------------------------------------------------------------------------
472
- // Folder Selection (Native Dialog)
473
- // --------------------------------------------------------------------------
474
379
  /**
475
380
  * Open a folder selection dialog
381
+ * @param options Dialog options
382
+ * @returns Selected folder path, or null if cancelled
476
383
  */
477
- async selectFolderAsync() {
478
- return this.client.request(
479
- HAEXTENSION_METHODS.filesync.selectFolder
480
- );
481
- }
482
- // --------------------------------------------------------------------------
483
- // Sync Queue
484
- // --------------------------------------------------------------------------
485
- /**
486
- * Add files to the sync queue
487
- */
488
- async addToQueueAsync(options) {
384
+ async selectFolder(options = {}) {
489
385
  return this.client.request(
490
- HAEXTENSION_METHODS.filesync.addToQueue,
386
+ HAEXTENSION_METHODS.filesystem.selectFolder,
491
387
  options
492
388
  );
493
389
  }
494
390
  /**
495
- * Get queue entries for the current device
391
+ * Open a file selection dialog
392
+ * @param options Dialog options
393
+ * @returns Selected file paths, or null if cancelled
496
394
  */
497
- async getQueueAsync(options) {
395
+ async selectFile(options = {}) {
498
396
  return this.client.request(
499
- HAEXTENSION_METHODS.filesync.getQueue,
397
+ HAEXTENSION_METHODS.filesystem.selectFile,
500
398
  options
501
399
  );
502
400
  }
503
401
  /**
504
- * Get aggregated queue summary for the current device
505
- */
506
- async getQueueSummaryAsync() {
507
- return this.client.request(
508
- HAEXTENSION_METHODS.filesync.getQueueSummary
509
- );
510
- }
511
- /**
512
- * Mark a queue entry as started (in_progress)
513
- */
514
- async startQueueEntryAsync(entryId) {
515
- await this.client.request(HAEXTENSION_METHODS.filesync.startQueueEntry, {
516
- entryId
517
- });
518
- }
519
- /**
520
- * Mark a queue entry as completed
521
- */
522
- async completeQueueEntryAsync(entryId) {
523
- await this.client.request(HAEXTENSION_METHODS.filesync.completeQueueEntry, {
524
- entryId
525
- });
526
- }
527
- /**
528
- * Mark a queue entry as failed
529
- */
530
- async failQueueEntryAsync(entryId, errorMessage) {
531
- await this.client.request(HAEXTENSION_METHODS.filesync.failQueueEntry, {
532
- entryId,
533
- errorMessage
534
- });
535
- }
536
- /**
537
- * Retry all failed queue entries (reset to pending)
538
- */
539
- async retryFailedQueueAsync() {
540
- await this.client.request(HAEXTENSION_METHODS.filesync.retryFailedQueue);
541
- }
542
- /**
543
- * Remove a queue entry
544
- */
545
- async removeQueueEntryAsync(entryId) {
546
- await this.client.request(HAEXTENSION_METHODS.filesync.removeQueueEntry, {
547
- entryId
548
- });
549
- }
550
- /**
551
- * Clear all queue entries for a sync rule
552
- */
553
- async clearQueueAsync(ruleId) {
554
- await this.client.request(HAEXTENSION_METHODS.filesync.clearQueue, {
555
- ruleId
556
- });
557
- }
558
- /**
559
- * Reset in_progress entries to pending (for recovery after crash)
560
- */
561
- async recoverQueueAsync() {
562
- await this.client.request(HAEXTENSION_METHODS.filesync.recoverQueue);
563
- }
564
- };
565
-
566
- // src/api/filesystem.ts
567
- var FilesystemAPI = class {
568
- constructor(client) {
569
- this.client = client;
570
- this.sync = new FileSyncAPI(client);
571
- }
572
- /**
573
- * Opens a save file dialog and saves the provided data to the selected location
574
- * @param data The file data as Uint8Array
575
- * @param options Options for the save dialog
576
- * @returns The path where the file was saved, or null if cancelled
577
- */
578
- async saveFileAsync(data, options = {}) {
579
- const result = await this.client.request(
580
- HAEXTENSION_METHODS.filesystem.saveFile,
581
- {
582
- data: Array.from(data),
583
- // Convert Uint8Array to regular array for postMessage
584
- defaultPath: options.defaultPath,
585
- title: options.title,
586
- filters: options.filters
587
- }
588
- );
589
- return result;
590
- }
591
- /**
592
- * Opens a file with the system's default viewer
593
- * @param data The file data as Uint8Array
594
- * @param options Options for opening the file
595
- * @returns The result of the operation
402
+ * Rename/move a file or directory
403
+ * @param from Source path
404
+ * @param to Destination path
596
405
  */
597
- async openFileAsync(data, options) {
598
- const result = await this.client.request(
599
- HAEXTENSION_METHODS.filesystem.openFile,
600
- {
601
- data: Array.from(data),
602
- // Convert Uint8Array to regular array for postMessage
603
- fileName: options.fileName,
604
- mimeType: options.mimeType
605
- }
406
+ async rename(from, to) {
407
+ await this.client.request(
408
+ HAEXTENSION_METHODS.filesystem.rename,
409
+ { from, to }
606
410
  );
607
- return result;
608
411
  }
609
412
  /**
610
- * Shows an image using a data URL (safe, read-only viewing)
611
- * This is safe to use without special permissions as it only displays images
612
- * and doesn't execute any code or open files with external applications
613
- * @param options Options containing the data URL
614
- * @returns The result of the operation
413
+ * Copy a file
414
+ * @param from Source path
415
+ * @param to Destination path
615
416
  */
616
- async showImageAsync(options) {
617
- const result = await this.client.request(
618
- HAEXTENSION_METHODS.filesystem.showImage,
619
- {
620
- dataUrl: options.dataUrl
621
- }
417
+ async copy(from, to) {
418
+ await this.client.request(
419
+ HAEXTENSION_METHODS.filesystem.copy,
420
+ { from, to }
622
421
  );
623
- return result;
624
422
  }
625
423
  };
626
424
 
@@ -1190,8 +988,7 @@ var TAURI_COMMANDS = {
1190
988
  filesystem: {
1191
989
  saveFile: "webview_extension_fs_save_file",
1192
990
  openFile: "webview_extension_fs_open_file",
1193
- showImage: "webview_extension_fs_show_image"
1194
- },
991
+ showImage: "webview_extension_fs_show_image"},
1195
992
  external: {
1196
993
  // Response handling (called by extensions running in WebView)
1197
994
  respond: "webview_extension_external_respond"},