zen-fs-config 0.5.47 → 0.5.49
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/index.d.mts +260 -34
- package/dist/index.d.ts +260 -34
- package/dist/index.js +1152 -290
- package/dist/index.mjs +1137 -290
- package/dist/zen-fs-config.js +1129 -290
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -347,6 +347,8 @@ interface AppDataGroupDescriptor {
|
|
|
347
347
|
groupType: 'data-sync';
|
|
348
348
|
/** User-editable display name. `id` is the stable identifier. */
|
|
349
349
|
name?: string;
|
|
350
|
+
/** Capability overrides (versions/conflicts are opt-in for data groups). */
|
|
351
|
+
features?: Partial<SyncGroupFeatures>;
|
|
350
352
|
backends: AppDataBackendDescriptor[];
|
|
351
353
|
}
|
|
352
354
|
/** Descriptor for the config-sync group itself (display metadata only). */
|
|
@@ -355,7 +357,7 @@ interface ConfigSyncGroupDescriptor {
|
|
|
355
357
|
/** User-editable display name. The group has no separate id. */
|
|
356
358
|
name?: string;
|
|
357
359
|
}
|
|
358
|
-
/** Per-backend sync state of a
|
|
360
|
+
/** Per-backend sync state of a group. */
|
|
359
361
|
interface BackendSyncState {
|
|
360
362
|
backendId: string;
|
|
361
363
|
/** Pair id when the backend instance was created and paired successfully. */
|
|
@@ -369,40 +371,68 @@ interface BackendSyncState {
|
|
|
369
371
|
timestamp: number;
|
|
370
372
|
};
|
|
371
373
|
}
|
|
372
|
-
/**
|
|
373
|
-
|
|
374
|
+
/** Structural discriminator for a sync group. */
|
|
375
|
+
type SyncGroupKind = 'config' | 'data';
|
|
376
|
+
/** Capability switches, derived from `kind` + the group descriptor. */
|
|
377
|
+
interface SyncGroupFeatures {
|
|
378
|
+
tombstones: boolean;
|
|
379
|
+
versions: boolean;
|
|
380
|
+
conflicts: boolean;
|
|
381
|
+
/** Config payload: app config, node config, group descriptors. */
|
|
382
|
+
configHost: boolean;
|
|
383
|
+
/** Whether the product layer may read/write the group root directly. */
|
|
384
|
+
appData: boolean;
|
|
385
|
+
}
|
|
386
|
+
/** Content of `.meta/group.json` — the unified group descriptor. */
|
|
387
|
+
interface GroupDescriptor {
|
|
388
|
+
schemaVersion: 1;
|
|
389
|
+
kind: SyncGroupKind;
|
|
390
|
+
/** Group id (`config` for the config-sync group, the descriptor id otherwise). */
|
|
391
|
+
id?: string;
|
|
392
|
+
/** User-editable display name. */
|
|
393
|
+
name?: string;
|
|
394
|
+
features?: Partial<SyncGroupFeatures>;
|
|
395
|
+
updatedAt?: number;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Common handle shared by config-sync and data-sync groups.
|
|
399
|
+
* The config group is the capability superset (see ConfigSyncGroupHandle).
|
|
400
|
+
*/
|
|
401
|
+
interface SyncGroupHandle {
|
|
374
402
|
readonly groupId: string;
|
|
375
403
|
readonly appId: string;
|
|
376
|
-
|
|
404
|
+
readonly kind: SyncGroupKind;
|
|
405
|
+
/** Derived, never persisted separately from the descriptor. */
|
|
406
|
+
readonly features: SyncGroupFeatures;
|
|
407
|
+
readonly name?: string;
|
|
408
|
+
/** Direct fs view; metadata paths (`.meta`, `.config`) are hidden. */
|
|
377
409
|
readonly fs: typeof node_fs;
|
|
378
|
-
/** Get sync status for this data group's sync pairs. */
|
|
379
410
|
getSyncStatuses(): Map<string, SyncPairStatus>;
|
|
380
|
-
/**
|
|
381
|
-
* Per-backend sync state, including descriptors that failed to connect and
|
|
382
|
-
* therefore have no pair (they do not appear in getSyncStatuses()).
|
|
383
|
-
*/
|
|
384
411
|
getBackendSyncStates(): Map<string, BackendSyncState>;
|
|
385
|
-
/** Manually flush pending sync. */
|
|
386
412
|
flush(): Promise<SyncResult[]>;
|
|
387
|
-
/** Stop sync and release resources. */
|
|
388
413
|
dispose(): Promise<void>;
|
|
389
|
-
/**
|
|
390
|
-
* Dynamically add a data backend to this group.
|
|
391
|
-
* Creates the backend instance, sets up bi-directional sync, and triggers initial sync.
|
|
392
|
-
* @param id Unique backend ID within this group
|
|
393
|
-
* @param type Backend type name (must be registered)
|
|
394
|
-
* @param options Backend options (storage location fields; account fields can be resolved via accountBackendId in the descriptor)
|
|
395
|
-
* @param description Optional human-readable description
|
|
396
|
-
*/
|
|
397
414
|
addBackend(id: string, type: string, options: Record<string, unknown>, description?: string): Promise<void>;
|
|
398
|
-
/**
|
|
399
|
-
* Dynamically remove a data backend from this group.
|
|
400
|
-
* Tears down the sync pair and disposes the backend instance.
|
|
401
|
-
* @param id Backend ID to remove
|
|
402
|
-
*/
|
|
403
415
|
removeBackend(id: string): Promise<void>;
|
|
404
|
-
/** List all backend descriptors in this group. */
|
|
405
416
|
listBackends(): AppDataBackendDescriptor[];
|
|
417
|
+
/** Update the display name only (descriptor-only). */
|
|
418
|
+
rename(name: string): Promise<void>;
|
|
419
|
+
/** Write a tombstone, delete the file + version record, trigger sync. */
|
|
420
|
+
deleteFile(path: string): Promise<void>;
|
|
421
|
+
listConflicts(): Promise<ConflictArchive[]>;
|
|
422
|
+
resolveConflict(conflictId: string, mergedContent: unknown): Promise<void>;
|
|
423
|
+
readConflictBackup(conflictId: string, fileType: 'source' | 'target' | 'resolved'): Promise<string>;
|
|
424
|
+
purgeMtimeSidecars(options?: {
|
|
425
|
+
root?: string;
|
|
426
|
+
dryRun?: boolean;
|
|
427
|
+
}): Promise<MtimePurgeResult>;
|
|
428
|
+
purgeKeepFiles(options?: {
|
|
429
|
+
root?: string;
|
|
430
|
+
dryRun?: boolean;
|
|
431
|
+
}): Promise<KeepPurgeResult>;
|
|
432
|
+
}
|
|
433
|
+
/** Handle to a data-sync group, providing direct fs access. */
|
|
434
|
+
interface AppDataGroup extends SyncGroupHandle {
|
|
435
|
+
readonly kind: 'data';
|
|
406
436
|
}
|
|
407
437
|
/** Options for the unified connect() entry point. */
|
|
408
438
|
interface ConnectOptions {
|
|
@@ -451,6 +481,10 @@ interface ConnectResult {
|
|
|
451
481
|
* model this is always present — it hosts the data groups' topology.
|
|
452
482
|
*/
|
|
453
483
|
repo?: IConfigRepo;
|
|
484
|
+
/** The config-sync group as a unified handle (same object as `repo`). */
|
|
485
|
+
configGroup?: ConfigSyncGroupHandle;
|
|
486
|
+
/** All groups for this app: config group first, then data groups. */
|
|
487
|
+
groups?: SyncGroupHandle[];
|
|
454
488
|
/**
|
|
455
489
|
* Handle to the default (`default`) app data group. Always owned by `repo`;
|
|
456
490
|
* present on first launch and when a data-sync backend was connected.
|
|
@@ -465,6 +499,14 @@ interface IConfigRepo {
|
|
|
465
499
|
readonly appId: string;
|
|
466
500
|
/** Node ID. */
|
|
467
501
|
readonly nodeId: string;
|
|
502
|
+
/** Fixed group id of the config-sync group (`config`). */
|
|
503
|
+
readonly groupId: string;
|
|
504
|
+
/** Structural discriminator — always `'config'`. */
|
|
505
|
+
readonly kind: 'config';
|
|
506
|
+
/** Capability switches (config group is the superset: all true). */
|
|
507
|
+
readonly features: SyncGroupFeatures;
|
|
508
|
+
/** User-editable display name (from `.config/config-sync-group.json`). */
|
|
509
|
+
readonly name?: string;
|
|
468
510
|
/** ZenFS-compatible fs object, context-isolated to this app's directories. */
|
|
469
511
|
readonly fs: typeof node_fs;
|
|
470
512
|
/** Un-chrooted fs for low-level browsing (includes /.meta/, all app dirs). */
|
|
@@ -489,6 +531,14 @@ interface IConfigRepo {
|
|
|
489
531
|
flush(): Promise<SyncResult[]>;
|
|
490
532
|
/** Get sync status for all registered sync pairs. */
|
|
491
533
|
getSyncStatuses(): Map<string, SyncPairStatus>;
|
|
534
|
+
/**
|
|
535
|
+
* Per-backend sync state, including replica descriptors that failed to
|
|
536
|
+
* connect and therefore have no pair (they do not appear in
|
|
537
|
+
* getSyncStatuses()).
|
|
538
|
+
*/
|
|
539
|
+
getBackendSyncStates(): Map<string, BackendSyncState>;
|
|
540
|
+
/** Update the config-sync group's display name only. */
|
|
541
|
+
rename(name: string): Promise<void>;
|
|
492
542
|
/** Resolve a conflict with custom merged content. */
|
|
493
543
|
resolveConflict(conflictId: string, mergedContent: unknown): Promise<void>;
|
|
494
544
|
/** List all conflict archives. */
|
|
@@ -558,7 +608,10 @@ interface IConfigRepo {
|
|
|
558
608
|
* Each backend can optionally reference a config-sync backend's account
|
|
559
609
|
* via `accountBackendId` to reuse credentials.
|
|
560
610
|
*/
|
|
561
|
-
createAppDataGroup(id: string, backends: AppDataBackendDescriptor[]
|
|
611
|
+
createAppDataGroup(id: string, backends: AppDataBackendDescriptor[], options?: {
|
|
612
|
+
name?: string;
|
|
613
|
+
features?: Partial<SyncGroupFeatures>;
|
|
614
|
+
}): Promise<AppDataGroup>;
|
|
562
615
|
/** Get an existing data-sync group handle. */
|
|
563
616
|
getAppDataGroup(id: string): Promise<AppDataGroup>;
|
|
564
617
|
/** List all data-sync group descriptors for this app. */
|
|
@@ -601,6 +654,11 @@ interface IConfigRepo {
|
|
|
601
654
|
* Excludes the local IndexedDB primary.
|
|
602
655
|
*/
|
|
603
656
|
listAccountBackends(): Promise<BackendDescriptor[]>;
|
|
657
|
+
/**
|
|
658
|
+
* List registered replica backend descriptors (excludes the implicit local
|
|
659
|
+
* primary). Unified handle method shared with data groups.
|
|
660
|
+
*/
|
|
661
|
+
listBackends(): AppDataBackendDescriptor[];
|
|
604
662
|
/** Write the group-type marker file if it doesn't exist. */
|
|
605
663
|
ensureGroupType(type: SyncGroupType): Promise<void>;
|
|
606
664
|
/** Read the group-type marker. Returns null if not set. */
|
|
@@ -608,6 +666,13 @@ interface IConfigRepo {
|
|
|
608
666
|
/** Dispose: stop all sync, release cache FS and resources. */
|
|
609
667
|
dispose(): Promise<void>;
|
|
610
668
|
}
|
|
669
|
+
/**
|
|
670
|
+
* The config-sync group as a unified handle. It is the capability superset:
|
|
671
|
+
* `SyncGroupHandle` + config payload / node config / topology management.
|
|
672
|
+
*/
|
|
673
|
+
interface ConfigSyncGroupHandle extends IConfigRepo, SyncGroupHandle {
|
|
674
|
+
readonly kind: 'config';
|
|
675
|
+
}
|
|
611
676
|
|
|
612
677
|
/**
|
|
613
678
|
* zen-fs-config — Config Serializers
|
|
@@ -839,6 +904,13 @@ interface MinimalAsyncFS extends BackendInstance {
|
|
|
839
904
|
declare class ConfigRepo implements IConfigRepo {
|
|
840
905
|
readonly appId: string;
|
|
841
906
|
readonly nodeId: string;
|
|
907
|
+
/** Fixed id for the unified sync-group model. */
|
|
908
|
+
readonly groupId = "config";
|
|
909
|
+
readonly kind: "config";
|
|
910
|
+
/** Capability switches — the config group is the superset. */
|
|
911
|
+
readonly features: SyncGroupFeatures;
|
|
912
|
+
/** Display name, hydrated from `.config/config-sync-group.json`. */
|
|
913
|
+
name?: string;
|
|
842
914
|
/** Chroot-isolated fs for app-facing API. Typed as `any` to match `typeof import('node:fs')` duck-typically. */
|
|
843
915
|
readonly fs: any;
|
|
844
916
|
/** Un-chrooted fs for low-level browsing. */
|
|
@@ -857,6 +929,10 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
857
929
|
private readonly pollIntervalMs?;
|
|
858
930
|
/** Tombstone cache — avoids redundant reads within a single flush() cycle. */
|
|
859
931
|
private tombstoneCache;
|
|
932
|
+
/** Per-backend sync state (successful pairs + connect failures). */
|
|
933
|
+
private backendStates;
|
|
934
|
+
/** Last known backend descriptors, for the synchronous unified handle API. */
|
|
935
|
+
private backendDescriptorCache;
|
|
860
936
|
/**
|
|
861
937
|
* Tracks the background initial sync started by createConfigRepo().
|
|
862
938
|
* `flush()` and `dispose()` will await this if it hasn't completed yet,
|
|
@@ -988,6 +1064,15 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
988
1064
|
*/
|
|
989
1065
|
syncMetaToReplicas(): Promise<void>;
|
|
990
1066
|
getSyncStatuses(): Map<string, SyncPairStatus>;
|
|
1067
|
+
/**
|
|
1068
|
+
* Per-backend sync state. Includes replica descriptors that failed to connect
|
|
1069
|
+
* (they have no sync pair, so they never show up in getSyncStatuses()).
|
|
1070
|
+
*/
|
|
1071
|
+
getBackendSyncStates(): Map<string, BackendSyncState>;
|
|
1072
|
+
/** Registered replica backend descriptors (excludes the implicit local primary). */
|
|
1073
|
+
listBackends(): AppDataBackendDescriptor[];
|
|
1074
|
+
/** Update the config-sync group's display name only. */
|
|
1075
|
+
rename(name: string): Promise<void>;
|
|
991
1076
|
resolveConflict(conflictId: string, mergedContent: unknown): Promise<void>;
|
|
992
1077
|
listConflicts(): Promise<ConflictArchive[]>;
|
|
993
1078
|
readConflictBackup(conflictId: string, fileType: 'source' | 'target' | 'resolved'): Promise<string>;
|
|
@@ -1006,19 +1091,28 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1006
1091
|
private walkDir;
|
|
1007
1092
|
writeMetaFile(path: string, data: unknown): Promise<void>;
|
|
1008
1093
|
readMetaFile<T>(path: string): Promise<T | null>;
|
|
1009
|
-
/** Path for a single backend descriptor: .
|
|
1094
|
+
/** Path for a single backend descriptor: .config/backends/{id}.json */
|
|
1010
1095
|
backendFilePath(id: string): string;
|
|
1096
|
+
/** Legacy path: .meta/backends/{id}.json (read + dual-write for one cycle). */
|
|
1097
|
+
legacyBackendFilePath(id: string): string;
|
|
1098
|
+
/** Read every parseable descriptor in one directory. */
|
|
1099
|
+
private readBackendDescriptorsFrom;
|
|
1011
1100
|
/**
|
|
1012
|
-
* Read all backend descriptors from
|
|
1101
|
+
* Read all backend descriptors from `.config/backends/*.json` with legacy
|
|
1102
|
+
* `.meta/backends/*.json` as a one-cycle fallback (new layout wins by id).
|
|
1013
1103
|
*
|
|
1014
1104
|
* If duplicate backends are detected (same type + options but different id),
|
|
1015
1105
|
* only the first one (sorted by id) is kept and the rest are removed
|
|
1016
1106
|
* (including their version sidecar files).
|
|
1017
1107
|
*/
|
|
1018
1108
|
readAllBackendDescriptors(): Promise<BackendDescriptor[]>;
|
|
1019
|
-
/**
|
|
1109
|
+
/**
|
|
1110
|
+
* Write a single backend descriptor to `.config/backends/{id}.json`,
|
|
1111
|
+
* mirroring to the legacy `.meta/backends/{id}.json` for one release cycle
|
|
1112
|
+
* so older clients still see the backend.
|
|
1113
|
+
*/
|
|
1020
1114
|
writeBackendDescriptor(desc: BackendDescriptor): Promise<void>;
|
|
1021
|
-
/** Remove a single backend descriptor file + its version sidecar */
|
|
1115
|
+
/** Remove a single backend descriptor file + its version sidecar (both layouts) */
|
|
1022
1116
|
removeBackendDescriptor(id: string): Promise<void>;
|
|
1023
1117
|
getBackends(): Promise<BackendsMeta | null>;
|
|
1024
1118
|
updateBackends(meta: BackendsMeta): Promise<void>;
|
|
@@ -1043,16 +1137,29 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1043
1137
|
replaceBackend(id: string, type: string, options: Record<string, unknown>, description?: string): Promise<void>;
|
|
1044
1138
|
/** Write the group-type marker file if it doesn't exist. */
|
|
1045
1139
|
ensureGroupType(type: SyncGroupType): Promise<void>;
|
|
1046
|
-
/** Read the group-type marker. Returns null if not set. */
|
|
1140
|
+
/** Read the group-type marker. Returns null if not set (new path, then legacy). */
|
|
1047
1141
|
getGroupType(): Promise<SyncGroupType | null>;
|
|
1048
|
-
/** Path for a single app data group descriptor: .
|
|
1142
|
+
/** Path for a single app data group descriptor: .config/app-data-groups/{appId}/{id}.json */
|
|
1049
1143
|
private appDataGroupFilePath;
|
|
1144
|
+
/** Legacy descriptor path: .meta/app-data-groups/{appId}/{id}.json */
|
|
1145
|
+
private legacyAppDataGroupFilePath;
|
|
1146
|
+
/** Write a data-group descriptor to the new path, mirroring to the legacy one. */
|
|
1147
|
+
private writeAppDataGroupDescriptorFile;
|
|
1050
1148
|
/**
|
|
1051
1149
|
* Resolve a backend descriptor's options by merging account fields
|
|
1052
1150
|
* from the referenced config-sync backend (if accountBackendId is set).
|
|
1053
1151
|
*/
|
|
1054
1152
|
private resolveAppDataBackendOptions;
|
|
1055
|
-
|
|
1153
|
+
/**
|
|
1154
|
+
* Reject two groups pointing at the exact same remote endpoint. Two groups
|
|
1155
|
+
* syncing the same files independently would fight over deletions and
|
|
1156
|
+
* tombstones (see SYNC-GROUP-UNIFICATION §4.3).
|
|
1157
|
+
*/
|
|
1158
|
+
private assertNoSharedRemote;
|
|
1159
|
+
createAppDataGroup(id: string, backends: AppDataBackendDescriptor[], options?: {
|
|
1160
|
+
name?: string;
|
|
1161
|
+
features?: Partial<SyncGroupFeatures>;
|
|
1162
|
+
}): Promise<AppDataGroup>;
|
|
1056
1163
|
/**
|
|
1057
1164
|
* Rewrite an app data group's descriptor (e.g. after addBackend/removeBackend)
|
|
1058
1165
|
* into .meta/app-data-groups/{appId}/{id}.json, keeping config-sync as the
|
|
@@ -1238,4 +1345,123 @@ declare function incrementVersion(fs: SyncableFS, configFilePath: string, newCon
|
|
|
1238
1345
|
*/
|
|
1239
1346
|
declare function verifyOrRepairVersion(fs: SyncableFS, configFilePath: string, author: string): Promise<VersionMeta | null>;
|
|
1240
1347
|
|
|
1241
|
-
|
|
1348
|
+
/**
|
|
1349
|
+
* zen-fs-config — Shared Sync-Group Metadata
|
|
1350
|
+
*
|
|
1351
|
+
* Implements the layout agreed in SYNC-GROUP-UNIFICATION.zh-CN.md:
|
|
1352
|
+
*
|
|
1353
|
+
* /.meta/group.json # group descriptor (kind/id/features)
|
|
1354
|
+
* /.meta/tombstones/{encoded}.json # tombstones (legacy: /.meta/.deleted)
|
|
1355
|
+
* /.meta/versions/{encoded}.json # version records for data groups
|
|
1356
|
+
* /.meta/conflicts/{conflictId}/ # conflict archives (legacy: /.meta/.conflicts)
|
|
1357
|
+
* /.config/** # config-sync only (not synced by data groups)
|
|
1358
|
+
*
|
|
1359
|
+
* Both the config-sync group and the data-sync groups use the `.meta/` helpers
|
|
1360
|
+
* below; `.config/` paths stay in config-repo.ts because only that group owns
|
|
1361
|
+
* them.
|
|
1362
|
+
*/
|
|
1363
|
+
|
|
1364
|
+
declare const META_DIR = "/.meta";
|
|
1365
|
+
declare const GROUP_DESCRIPTOR_FILE = "/.meta/group.json";
|
|
1366
|
+
declare const TOMBSTONES_DIR = "/.meta/tombstones";
|
|
1367
|
+
declare const LEGACY_TOMBSTONES_DIR = "/.meta/.deleted";
|
|
1368
|
+
declare const VERSIONS_DIR = "/.meta/versions";
|
|
1369
|
+
declare const CONFLICTS_DIR = "/.meta/conflicts";
|
|
1370
|
+
declare const LEGACY_CONFLICTS_DIR = "/.meta/.conflicts";
|
|
1371
|
+
declare const CONFIG_DIR = "/.config";
|
|
1372
|
+
/** Default features for a data-sync group: tombstones on, versions/conflicts opt-in. */
|
|
1373
|
+
declare const DATA_GROUP_DEFAULT_FEATURES: SyncGroupFeatures;
|
|
1374
|
+
type MetaFS = {
|
|
1375
|
+
readFile(path: string, encoding?: string): Promise<any>;
|
|
1376
|
+
writeFile(path: string, data: any): Promise<void>;
|
|
1377
|
+
readdir(path: string): Promise<string[]>;
|
|
1378
|
+
mkdir(path: string): Promise<any>;
|
|
1379
|
+
unlink(path: string): Promise<void>;
|
|
1380
|
+
exists?(path: string): Promise<boolean>;
|
|
1381
|
+
};
|
|
1382
|
+
/**
|
|
1383
|
+
* Encode a file path into a flat metadata entry name.
|
|
1384
|
+
* `/a/b.json` → `a__b++json`
|
|
1385
|
+
*/
|
|
1386
|
+
declare function encodeMetaPath(filePath: string): string;
|
|
1387
|
+
/** Read `.meta/group.json`. */
|
|
1388
|
+
declare function readGroupDescriptor(fs: MetaFS): Promise<GroupDescriptor | null>;
|
|
1389
|
+
/** Write `.meta/group.json` (idempotent). */
|
|
1390
|
+
declare function writeGroupDescriptor(fs: MetaFS, descriptor: GroupDescriptor): Promise<void>;
|
|
1391
|
+
interface TombstoneTarget {
|
|
1392
|
+
id: string;
|
|
1393
|
+
fs: any;
|
|
1394
|
+
}
|
|
1395
|
+
/**
|
|
1396
|
+
* Tombstone store for a group's local store.
|
|
1397
|
+
*
|
|
1398
|
+
* New writes go to `/.meta/tombstones/`; for one release cycle a mirror copy is
|
|
1399
|
+
* also written to the legacy `/.meta/.deleted/` path so older clients still see
|
|
1400
|
+
* deletions. Reads accept both.
|
|
1401
|
+
*/
|
|
1402
|
+
declare class TombstoneStore {
|
|
1403
|
+
private fs;
|
|
1404
|
+
private author;
|
|
1405
|
+
constructor(fs: MetaFS, author: string);
|
|
1406
|
+
private pathFor;
|
|
1407
|
+
/** All tombstones, new path first, legacy only for paths not already seen. */
|
|
1408
|
+
list(): Promise<TombstoneMeta[]>;
|
|
1409
|
+
/** Write a tombstone (new + legacy mirror). */
|
|
1410
|
+
write(tombstone: TombstoneMeta): Promise<void>;
|
|
1411
|
+
/** Persist an updated tombstone (confirmations) to whichever paths exist. */
|
|
1412
|
+
save(tombstone: TombstoneMeta): Promise<void>;
|
|
1413
|
+
/** Delete a tombstone from both layouts. */
|
|
1414
|
+
remove(tombstone: TombstoneMeta): Promise<void>;
|
|
1415
|
+
/**
|
|
1416
|
+
* Delete every tombstoned file (and its version record) on the local store
|
|
1417
|
+
* and on each target backend, so bi-directional sync cannot resurrect it.
|
|
1418
|
+
*/
|
|
1419
|
+
process(targets?: TombstoneTarget[]): Promise<void>;
|
|
1420
|
+
private deleteEverywhere;
|
|
1421
|
+
/** Add the given backend ids to every tombstone's confirmation set. */
|
|
1422
|
+
confirm(backendIds: string[]): Promise<number>;
|
|
1423
|
+
/** Remove tombstones confirmed by every connected backend (and their mirrors). */
|
|
1424
|
+
gc(allBackendIds: string[], targets?: TombstoneTarget[]): Promise<void>;
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* Version records for data files, stored centrally under `/.meta/versions/`.
|
|
1428
|
+
* Config-sync keeps its historical `<file>.version` sidecars; only data groups
|
|
1429
|
+
* use this store (see SYNC-GROUP-UNIFICATION §4.4 for the migration note).
|
|
1430
|
+
*/
|
|
1431
|
+
declare class VersionStore {
|
|
1432
|
+
private fs;
|
|
1433
|
+
private author;
|
|
1434
|
+
constructor(fs: MetaFS, author: string);
|
|
1435
|
+
/** `null` for metadata paths and version files themselves. */
|
|
1436
|
+
pathFor(filePath: string): string | null;
|
|
1437
|
+
read(filePath: string): Promise<VersionMeta | null>;
|
|
1438
|
+
record(filePath: string, content: Uint8Array): Promise<VersionMeta | null>;
|
|
1439
|
+
remove(filePath: string): Promise<void>;
|
|
1440
|
+
}
|
|
1441
|
+
interface RawConflict {
|
|
1442
|
+
path: string;
|
|
1443
|
+
sourceContent: string;
|
|
1444
|
+
targetContent: string;
|
|
1445
|
+
resolvedWith?: string;
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Conflict archives for data files, stored under `/.meta/conflicts/`.
|
|
1449
|
+
* Legacy `/.meta/.conflicts/` archives stay readable (list/read fallback).
|
|
1450
|
+
*/
|
|
1451
|
+
declare class ConflictStore {
|
|
1452
|
+
private fs;
|
|
1453
|
+
private appId;
|
|
1454
|
+
private nodeId;
|
|
1455
|
+
private versions;
|
|
1456
|
+
constructor(fs: MetaFS, appId: string, nodeId: string, versions: VersionStore);
|
|
1457
|
+
/** Persist source/target backups + meta.json. Returns the archive record. */
|
|
1458
|
+
archive(conflict: RawConflict, timestamp?: number): Promise<ConflictArchive>;
|
|
1459
|
+
/** All archives, new layout first, legacy entries only when not shadowed. */
|
|
1460
|
+
list(): Promise<ConflictArchive[]>;
|
|
1461
|
+
private candidatesFor;
|
|
1462
|
+
readBackup(conflictId: string, fileType: 'source' | 'target' | 'resolved'): Promise<string>;
|
|
1463
|
+
/** Resolve a conflict with raw (already serialized) content. */
|
|
1464
|
+
resolve(conflictId: string, mergedContent: string | Uint8Array): Promise<void>;
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
export { type AppDataBackendDescriptor, type AppDataGroup, type AppDataGroupDescriptor, type BackendDescriptor, type BackendFactory, type BackendInstance, type BackendMetadata, type BackendParamDef, type BackendSyncState, type BackendsMeta, CONFIG_DIR, CONFLICTS_DIR, type CacheOptions, ConfigRepo, type ConfigRepoOptions, type ConfigSerializer, type ConfigSyncGroupDescriptor, type ConfigSyncGroupHandle, type ConflictArchive, type ConflictInfo, ConflictStore, type ConnectOptions, type ConnectResult, DATA_GROUP_DEFAULT_FEATURES, FolderStore, GROUP_DESCRIPTOR_FILE, type GroupDescriptor, type IConfigRepo, type KeepPurgeResult, LEGACY_CONFLICTS_DIR, LEGACY_TOMBSTONES_DIR, LOCAL_IDB_BACKEND_ID, META_DIR, type MigrateLocalFS, type MigrateReplicaFS, type MtimePurgeResult, type PurgeKeepOptions, type PurgeMtimeOptions, type PurgeableFS$1 as PurgeableFS, type SyncGroupFeatures, type SyncGroupHandle, type SyncGroupKind, type SyncGroupType, TOMBSTONES_DIR, type TombstoneMeta, TombstoneStore, VERSIONS_DIR, type VersionMeta, type VersionMigrationOptions, type VersionMigrationResult, VersionStore, configKeyToFilePath, connect, createBackend, createConfigRepo, createSerializerChain, encodeMetaPath, getAccountFields, getBackendMetadata, getExtension, hasBackend, incrementVersion, isBrowserEnv, isKeepFile, isMtimeSidecar, legacyVersionPathFor, listBackendMetadata, listBackends, localPrimaryType, mergeAccountFields, migrateVersionSidecars, purgeKeepFiles, purgeMtimeSidecars, readGroupDescriptor, readVersion, registerBackend, registerFolderBackend, resolveLocalPrimary, sha256, unregisterBackend, verifyOrRepairVersion, versionPathFor, wrapZenFSFileSystem, writeGroupDescriptor, writeVersion };
|