@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.
@@ -41,412 +41,6 @@ declare class DatabaseAPI {
41
41
  count(tableName: string, where?: string, whereParams?: unknown[]): Promise<number>;
42
42
  }
43
43
 
44
- /** File sync state constants */
45
- declare const FILE_SYNC_STATE: {
46
- readonly SYNCED: "synced";
47
- readonly SYNCING: "syncing";
48
- readonly LOCAL_ONLY: "localOnly";
49
- readonly REMOTE_ONLY: "remoteOnly";
50
- readonly CONFLICT: "conflict";
51
- readonly ERROR: "error";
52
- };
53
- /** Sync direction constants */
54
- declare const SYNC_DIRECTION: {
55
- readonly UP: "up";
56
- readonly DOWN: "down";
57
- readonly BOTH: "both";
58
- };
59
- /** Storage backend type constants */
60
- declare const STORAGE_BACKEND_TYPE: {
61
- readonly S3: "s3";
62
- readonly R2: "r2";
63
- readonly MINIO: "minio";
64
- readonly GDRIVE: "gdrive";
65
- readonly DROPBOX: "dropbox";
66
- };
67
- interface FileSpace {
68
- id: string;
69
- name: string;
70
- isPersonal: boolean;
71
- fileCount: number;
72
- totalSize: number;
73
- createdAt: string;
74
- updatedAt: string;
75
- }
76
- interface FileInfo {
77
- id: string;
78
- spaceId: string;
79
- name: string;
80
- path: string;
81
- mimeType: string | null;
82
- size: number;
83
- contentHash: string;
84
- isDirectory: boolean;
85
- syncState: FileSyncState;
86
- backends: string[];
87
- createdAt: string;
88
- updatedAt: string;
89
- }
90
- /** Local file info (unencrypted, scanned from local filesystem) */
91
- interface LocalFileInfo {
92
- /** Unique ID (hash of rule_id + relative path) */
93
- id: string;
94
- /** File name */
95
- name: string;
96
- /** Full local path */
97
- path: string;
98
- /** Relative path from sync root */
99
- relativePath: string;
100
- /** MIME type (null for directories) */
101
- mimeType: string | null;
102
- /** File size in bytes */
103
- size: number;
104
- /** Whether this is a directory */
105
- isDirectory: boolean;
106
- /** Last modified timestamp (ISO 8601) */
107
- modifiedAt: string | null;
108
- }
109
- type FileSyncState = "synced" | "syncing" | "localOnly" | "remoteOnly" | "conflict" | "error";
110
- interface StorageBackendInfo$1 {
111
- id: string;
112
- type: StorageBackendType;
113
- name: string;
114
- enabled: boolean;
115
- createdAt: string;
116
- }
117
- type StorageBackendType = "s3" | "r2" | "minio" | "gdrive" | "dropbox";
118
- interface S3BackendConfig {
119
- type: "s3" | "r2" | "minio";
120
- endpoint?: string;
121
- region: string;
122
- bucket: string;
123
- accessKeyId: string;
124
- secretAccessKey: string;
125
- }
126
- /** Backend configuration for S3-compatible storage */
127
- type BackendConfig = S3BackendConfig;
128
- interface SyncRule {
129
- id: string;
130
- /** Device ID this sync rule belongs to (local paths are device-specific) */
131
- deviceId: string;
132
- spaceId: string;
133
- localPath: string;
134
- backendIds: string[];
135
- direction: SyncDirection;
136
- enabled: boolean;
137
- /** Gitignore-like patterns for files/folders to exclude from sync */
138
- ignorePatterns: string[];
139
- /** Default conflict resolution strategy for this sync rule */
140
- conflictStrategy: ConflictStrategy;
141
- createdAt: string;
142
- updatedAt: string;
143
- }
144
- type SyncDirection = "up" | "down" | "both";
145
- /** Conflict resolution strategy for sync rules */
146
- type ConflictStrategy = "local" | "remote" | "newer" | "ask" | "keepBoth";
147
- /** Conflict strategy constants */
148
- declare const CONFLICT_STRATEGY: Record<string, ConflictStrategy>;
149
- interface SyncStatus {
150
- isSyncing: boolean;
151
- pendingUploads: number;
152
- pendingDownloads: number;
153
- lastSync: string | null;
154
- errors: SyncError[];
155
- }
156
- interface SyncError {
157
- fileId: string;
158
- fileName: string;
159
- error: string;
160
- timestamp: string;
161
- }
162
- interface SyncProgress {
163
- fileId: string;
164
- fileName: string;
165
- bytesTransferred: number;
166
- totalBytes: number;
167
- direction: "upload" | "download";
168
- }
169
- interface CreateSpaceOptions {
170
- name: string;
171
- }
172
- interface AddBackendOptions {
173
- name: string;
174
- config: BackendConfig;
175
- }
176
- interface AddSyncRuleOptions {
177
- spaceId: string;
178
- localPath: string;
179
- backendIds: string[];
180
- direction?: SyncDirection;
181
- /** Gitignore-like patterns for files/folders to exclude from sync */
182
- ignorePatterns?: string[];
183
- /** Default conflict resolution strategy (defaults to 'ask') */
184
- conflictStrategy?: ConflictStrategy;
185
- }
186
- interface UpdateSyncRuleOptions {
187
- ruleId: string;
188
- backendIds?: string[];
189
- direction?: SyncDirection;
190
- enabled?: boolean;
191
- /** Gitignore-like patterns for files/folders to exclude from sync */
192
- ignorePatterns?: string[];
193
- /** Default conflict resolution strategy */
194
- conflictStrategy?: ConflictStrategy;
195
- }
196
- interface ListFilesOptions {
197
- spaceId: string;
198
- path?: string;
199
- recursive?: boolean;
200
- }
201
- interface ScanLocalOptions {
202
- /** Sync rule ID to scan */
203
- ruleId: string;
204
- /** Optional subpath within the sync root to scan */
205
- subpath?: string;
206
- }
207
- interface UploadFileOptions {
208
- spaceId: string;
209
- localPath: string;
210
- remotePath?: string;
211
- backendIds?: string[];
212
- }
213
- interface DownloadFileOptions {
214
- fileId: string;
215
- localPath: string;
216
- }
217
- /** Queue operation type */
218
- type QueueOperation = 'upload' | 'download';
219
- /** Queue entry status */
220
- type QueueStatus = 'pending' | 'inProgress' | 'completed' | 'failed';
221
- /** Queue operation constants */
222
- declare const QUEUE_OPERATION: {
223
- UPLOAD: "upload";
224
- DOWNLOAD: "download";
225
- };
226
- /** Queue status constants */
227
- declare const QUEUE_STATUS: {
228
- PENDING: "pending";
229
- IN_PROGRESS: "inProgress";
230
- COMPLETED: "completed";
231
- FAILED: "failed";
232
- };
233
- /** A sync queue entry representing a pending or in-progress file operation */
234
- interface SyncQueueEntry {
235
- id: string;
236
- /** Device ID this entry belongs to */
237
- deviceId: string;
238
- /** Sync rule ID */
239
- ruleId: string;
240
- /** Full local path */
241
- localPath: string;
242
- /** Relative path from sync root (used as remote path) */
243
- relativePath: string;
244
- /** Operation type (upload/download) */
245
- operation: QueueOperation;
246
- /** Current status */
247
- status: QueueStatus;
248
- /** Priority (lower = higher priority) */
249
- priority: number;
250
- /** File size in bytes */
251
- fileSize: number;
252
- /** Error message if failed */
253
- errorMessage: string | null;
254
- /** Number of retry attempts */
255
- retryCount: number;
256
- /** When the entry was created */
257
- createdAt: string;
258
- /** When processing started */
259
- startedAt: string | null;
260
- /** When processing completed */
261
- completedAt: string | null;
262
- }
263
- /** Request to add files to the sync queue */
264
- interface AddToQueueOptions {
265
- /** Sync rule ID */
266
- ruleId: string;
267
- /** Files to add */
268
- files: QueueFileEntry[];
269
- /** Operation type */
270
- operation: QueueOperation;
271
- /** Priority (optional, default 100) */
272
- priority?: number;
273
- }
274
- /** A file entry for adding to the queue */
275
- interface QueueFileEntry {
276
- /** Full local path */
277
- localPath: string;
278
- /** Relative path from sync root */
279
- relativePath: string;
280
- /** File size in bytes */
281
- fileSize: number;
282
- }
283
- /** Request to get queue entries */
284
- interface GetQueueOptions {
285
- /** Filter by rule ID (optional) */
286
- ruleId?: string;
287
- /** Filter by status (optional) */
288
- status?: QueueStatus;
289
- /** Include completed entries (default: false) */
290
- includeCompleted?: boolean;
291
- }
292
- /** Aggregated queue status */
293
- interface QueueSummary {
294
- /** Number of pending items */
295
- pendingCount: number;
296
- /** Number of in-progress items */
297
- inProgressCount: number;
298
- /** Number of completed items */
299
- completedCount: number;
300
- /** Number of failed items */
301
- failedCount: number;
302
- /** Total bytes pending (sum of file_size for pending items) */
303
- pendingBytes: number;
304
- /** Currently processing entry (if any) */
305
- currentEntry: SyncQueueEntry | null;
306
- }
307
- /**
308
- * File Sync API for E2E encrypted file synchronization
309
- *
310
- * Access via: client.filesystem.sync.*
311
- */
312
- declare class FileSyncAPI {
313
- private client;
314
- constructor(client: HaexVaultSdk);
315
- /**
316
- * List all file spaces
317
- */
318
- listSpacesAsync(): Promise<FileSpace[]>;
319
- /**
320
- * Create a new file space
321
- */
322
- createSpaceAsync(options: CreateSpaceOptions): Promise<FileSpace>;
323
- /**
324
- * Delete a file space
325
- */
326
- deleteSpaceAsync(spaceId: string): Promise<void>;
327
- /**
328
- * List files in a space
329
- */
330
- listFilesAsync(options: ListFilesOptions): Promise<FileInfo[]>;
331
- /**
332
- * Scan local files in a sync rule folder
333
- * Returns unencrypted local files for display in the UI
334
- */
335
- scanLocalAsync(options: ScanLocalOptions): Promise<LocalFileInfo[]>;
336
- /**
337
- * Get file info by ID
338
- */
339
- getFileAsync(fileId: string): Promise<FileInfo | null>;
340
- /**
341
- * Upload a file to the sync system
342
- */
343
- uploadFileAsync(options: UploadFileOptions): Promise<FileInfo>;
344
- /**
345
- * Download a file to local storage
346
- */
347
- downloadFileAsync(options: DownloadFileOptions): Promise<void>;
348
- /**
349
- * Delete a file from the sync system
350
- */
351
- deleteFileAsync(fileId: string): Promise<void>;
352
- /**
353
- * List configured storage backends
354
- */
355
- listBackendsAsync(): Promise<StorageBackendInfo$1[]>;
356
- /**
357
- * Add a new storage backend
358
- */
359
- addBackendAsync(options: AddBackendOptions): Promise<StorageBackendInfo$1>;
360
- /**
361
- * Remove a storage backend
362
- */
363
- removeBackendAsync(backendId: string): Promise<void>;
364
- /**
365
- * Test backend connection
366
- */
367
- testBackendAsync(backendId: string): Promise<boolean>;
368
- /**
369
- * List sync rules
370
- */
371
- listSyncRulesAsync(): Promise<SyncRule[]>;
372
- /**
373
- * Add a sync rule
374
- */
375
- addSyncRuleAsync(options: AddSyncRuleOptions): Promise<SyncRule>;
376
- /**
377
- * Update a sync rule
378
- */
379
- updateSyncRuleAsync(options: UpdateSyncRuleOptions): Promise<SyncRule>;
380
- /**
381
- * Remove a sync rule
382
- */
383
- removeSyncRuleAsync(ruleId: string): Promise<void>;
384
- /**
385
- * Get current sync status
386
- */
387
- getSyncStatusAsync(): Promise<SyncStatus>;
388
- /**
389
- * Trigger a manual sync
390
- */
391
- triggerSyncAsync(): Promise<void>;
392
- /**
393
- * Pause syncing
394
- */
395
- pauseSyncAsync(): Promise<void>;
396
- /**
397
- * Resume syncing
398
- */
399
- resumeSyncAsync(): Promise<void>;
400
- /**
401
- * Resolve a file conflict
402
- */
403
- resolveConflictAsync(fileId: string, resolution: "local" | "remote" | "keepBoth"): Promise<void>;
404
- /**
405
- * Open a folder selection dialog
406
- */
407
- selectFolderAsync(): Promise<string | null>;
408
- /**
409
- * Add files to the sync queue
410
- */
411
- addToQueueAsync(options: AddToQueueOptions): Promise<SyncQueueEntry[]>;
412
- /**
413
- * Get queue entries for the current device
414
- */
415
- getQueueAsync(options?: GetQueueOptions): Promise<SyncQueueEntry[]>;
416
- /**
417
- * Get aggregated queue summary for the current device
418
- */
419
- getQueueSummaryAsync(): Promise<QueueSummary>;
420
- /**
421
- * Mark a queue entry as started (in_progress)
422
- */
423
- startQueueEntryAsync(entryId: string): Promise<void>;
424
- /**
425
- * Mark a queue entry as completed
426
- */
427
- completeQueueEntryAsync(entryId: string): Promise<void>;
428
- /**
429
- * Mark a queue entry as failed
430
- */
431
- failQueueEntryAsync(entryId: string, errorMessage: string): Promise<void>;
432
- /**
433
- * Retry all failed queue entries (reset to pending)
434
- */
435
- retryFailedQueueAsync(): Promise<void>;
436
- /**
437
- * Remove a queue entry
438
- */
439
- removeQueueEntryAsync(entryId: string): Promise<void>;
440
- /**
441
- * Clear all queue entries for a sync rule
442
- */
443
- clearQueueAsync(ruleId: string): Promise<void>;
444
- /**
445
- * Reset in_progress entries to pending (for recovery after crash)
446
- */
447
- recoverQueueAsync(): Promise<void>;
448
- }
449
-
450
44
  interface SaveFileOptions {
451
45
  /**
452
46
  * The default filename to suggest
@@ -502,9 +96,66 @@ interface ShowImageResult {
502
96
  */
503
97
  success: boolean;
504
98
  }
99
+ /**
100
+ * File/directory metadata
101
+ */
102
+ interface FileStat {
103
+ /** File size in bytes */
104
+ size: number;
105
+ /** True if this is a file */
106
+ isFile: boolean;
107
+ /** True if this is a directory */
108
+ isDirectory: boolean;
109
+ /** True if this is a symbolic link */
110
+ isSymlink: boolean;
111
+ /** Last modified time (Unix timestamp in milliseconds) */
112
+ modified?: number;
113
+ /** Created time (Unix timestamp in milliseconds) */
114
+ created?: number;
115
+ /** Whether the file is read-only */
116
+ readonly: boolean;
117
+ }
118
+ /**
119
+ * Directory entry
120
+ */
121
+ interface DirEntry {
122
+ /** Entry name (not full path) */
123
+ name: string;
124
+ /** Full path */
125
+ path: string;
126
+ /** True if this is a file */
127
+ isFile: boolean;
128
+ /** True if this is a directory */
129
+ isDirectory: boolean;
130
+ /** File size in bytes (0 for directories) */
131
+ size: number;
132
+ /** Last modified time (Unix timestamp in milliseconds) */
133
+ modified?: number;
134
+ }
135
+ /**
136
+ * Options for selecting a folder
137
+ */
138
+ interface SelectFolderOptions {
139
+ /** Dialog title */
140
+ title?: string;
141
+ /** Default path to open */
142
+ defaultPath?: string;
143
+ }
144
+ /**
145
+ * Options for selecting files
146
+ */
147
+ interface SelectFileOptions {
148
+ /** Dialog title */
149
+ title?: string;
150
+ /** Default path to open */
151
+ defaultPath?: string;
152
+ /** File filters (name -> extensions) */
153
+ filters?: Array<[string, string[]]>;
154
+ /** Allow multiple file selection */
155
+ multiple?: boolean;
156
+ }
505
157
  declare class FilesystemAPI {
506
158
  private client;
507
- readonly sync: FileSyncAPI;
508
159
  constructor(client: HaexVaultSdk);
509
160
  /**
510
161
  * Opens a save file dialog and saves the provided data to the selected location
@@ -528,6 +179,71 @@ declare class FilesystemAPI {
528
179
  * @returns The result of the operation
529
180
  */
530
181
  showImageAsync(options: ShowImageOptions): Promise<ShowImageResult>;
182
+ /**
183
+ * Read file contents
184
+ * @param path Absolute path to the file
185
+ * @returns File contents as Uint8Array
186
+ */
187
+ readFile(path: string): Promise<Uint8Array>;
188
+ /**
189
+ * Write file contents
190
+ * @param path Absolute path to the file
191
+ * @param data File contents as Uint8Array
192
+ */
193
+ writeFile(path: string, data: Uint8Array): Promise<void>;
194
+ /**
195
+ * Read directory contents
196
+ * @param path Absolute path to the directory
197
+ * @returns Array of directory entries
198
+ */
199
+ readDir(path: string): Promise<DirEntry[]>;
200
+ /**
201
+ * Create a directory (and parent directories if needed)
202
+ * @param path Absolute path to create
203
+ */
204
+ mkdir(path: string): Promise<void>;
205
+ /**
206
+ * Remove a file or directory
207
+ * @param path Absolute path to remove
208
+ * @param recursive If true, remove directories recursively
209
+ */
210
+ remove(path: string, recursive?: boolean): Promise<void>;
211
+ /**
212
+ * Check if a path exists
213
+ * @param path Absolute path to check
214
+ * @returns True if the path exists
215
+ */
216
+ exists(path: string): Promise<boolean>;
217
+ /**
218
+ * Get file/directory metadata
219
+ * @param path Absolute path
220
+ * @returns File metadata
221
+ */
222
+ stat(path: string): Promise<FileStat>;
223
+ /**
224
+ * Open a folder selection dialog
225
+ * @param options Dialog options
226
+ * @returns Selected folder path, or null if cancelled
227
+ */
228
+ selectFolder(options?: SelectFolderOptions): Promise<string | null>;
229
+ /**
230
+ * Open a file selection dialog
231
+ * @param options Dialog options
232
+ * @returns Selected file paths, or null if cancelled
233
+ */
234
+ selectFile(options?: SelectFileOptions): Promise<string[] | null>;
235
+ /**
236
+ * Rename/move a file or directory
237
+ * @param from Source path
238
+ * @param to Destination path
239
+ */
240
+ rename(from: string, to: string): Promise<void>;
241
+ /**
242
+ * Copy a file
243
+ * @param from Source path
244
+ * @param to Destination path
245
+ */
246
+ copy(from: string, to: string): Promise<void>;
531
247
  }
532
248
 
533
249
  declare class WebAPI {
@@ -791,4 +507,4 @@ declare class HaexVaultSdk {
791
507
  private log;
792
508
  }
793
509
 
794
- export { type AddBackendRequest as A, type BackendConfig as B, type ConflictStrategy as C, DatabaseAPI as D, type QueueSummary as E, FilesystemAPI as F, type GetQueueOptions as G, HaexVaultSdk as H, FILE_SYNC_STATE as I, SYNC_DIRECTION as J, STORAGE_BACKEND_TYPE as K, type ListFilesOptions as L, CONFLICT_STRATEGY as M, QUEUE_OPERATION as N, QUEUE_STATUS as O, PermissionsAPI as P, type QueueOperation as Q, RemoteStorageAPI as R, StorageAPI as S, type UpdateSyncRuleOptions as U, WebAPI as W, FileSyncAPI as a, type StorageBackendInfo as b, type S3Config as c, type StorageObjectInfo as d, type FileSpace as e, type FileInfo as f, type FileSyncState as g, type StorageBackendInfo$1 as h, type StorageBackendType as i, type S3BackendConfig as j, type SyncRule as k, type SyncDirection as l, type SyncStatus as m, type SyncError as n, type SyncProgress as o, type CreateSpaceOptions as p, type AddBackendOptions as q, type AddSyncRuleOptions as r, type ScanLocalOptions as s, type UploadFileOptions as t, type DownloadFileOptions as u, type LocalFileInfo as v, type QueueStatus as w, type SyncQueueEntry as x, type AddToQueueOptions as y, type QueueFileEntry as z };
510
+ export { type AddBackendRequest as A, DatabaseAPI as D, FilesystemAPI as F, HaexVaultSdk as H, PermissionsAPI as P, RemoteStorageAPI as R, StorageAPI as S, WebAPI as W, type FileStat as a, type DirEntry as b, type SelectFolderOptions as c, type SelectFileOptions as d, type StorageBackendInfo as e, type S3Config as f, type StorageObjectInfo as g };