zen-fs-config 0.5.43 → 0.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/index.d.mts +20 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.js +28 -7
- package/dist/index.mjs +28 -7
- package/dist/zen-fs-config.js +28 -7
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -347,6 +347,20 @@ interface AppDataGroupDescriptor {
|
|
|
347
347
|
groupType: 'data-sync';
|
|
348
348
|
backends: AppDataBackendDescriptor[];
|
|
349
349
|
}
|
|
350
|
+
/** Per-backend sync state of a data group. */
|
|
351
|
+
interface BackendSyncState {
|
|
352
|
+
backendId: string;
|
|
353
|
+
/** Pair id when the backend instance was created and paired successfully. */
|
|
354
|
+
pairId?: string;
|
|
355
|
+
/**
|
|
356
|
+
* Present when this descriptor could not be connected (e.g. a required
|
|
357
|
+
* option is missing), so no sync pair exists for it.
|
|
358
|
+
*/
|
|
359
|
+
error?: {
|
|
360
|
+
message: string;
|
|
361
|
+
timestamp: number;
|
|
362
|
+
};
|
|
363
|
+
}
|
|
350
364
|
/** Handle to a data-sync group, providing direct fs access. */
|
|
351
365
|
interface AppDataGroup {
|
|
352
366
|
readonly groupId: string;
|
|
@@ -355,6 +369,11 @@ interface AppDataGroup {
|
|
|
355
369
|
readonly fs: typeof node_fs;
|
|
356
370
|
/** Get sync status for this data group's sync pairs. */
|
|
357
371
|
getSyncStatuses(): Map<string, SyncPairStatus>;
|
|
372
|
+
/**
|
|
373
|
+
* Per-backend sync state, including descriptors that failed to connect and
|
|
374
|
+
* therefore have no pair (they do not appear in getSyncStatuses()).
|
|
375
|
+
*/
|
|
376
|
+
getBackendSyncStates(): Map<string, BackendSyncState>;
|
|
358
377
|
/** Manually flush pending sync. */
|
|
359
378
|
flush(): Promise<SyncResult[]>;
|
|
360
379
|
/** Stop sync and release resources. */
|
|
@@ -1141,4 +1160,4 @@ declare function incrementVersion(fs: SyncableFS, configFilePath: string, newCon
|
|
|
1141
1160
|
*/
|
|
1142
1161
|
declare function verifyOrRepairVersion(fs: SyncableFS, configFilePath: string, author: string): Promise<VersionMeta | null>;
|
|
1143
1162
|
|
|
1144
|
-
export { type AppDataBackendDescriptor, type AppDataGroup, type AppDataGroupDescriptor, type BackendDescriptor, type BackendFactory, type BackendInstance, type BackendMetadata, type BackendParamDef, type BackendsMeta, type CacheOptions, ConfigRepo, type ConfigRepoOptions, type ConfigSerializer, type ConflictArchive, type ConflictInfo, type ConnectOptions, type ConnectResult, FolderStore, type IConfigRepo, type KeepPurgeResult, LOCAL_IDB_BACKEND_ID, type MigrateLocalFS, type MigrateReplicaFS, type MtimePurgeResult, type PurgeKeepOptions, type PurgeMtimeOptions, type PurgeableFS$1 as PurgeableFS, type SyncGroupType, type TombstoneMeta, type VersionMeta, type VersionMigrationOptions, type VersionMigrationResult, configKeyToFilePath, connect, createBackend, createConfigRepo, createSerializerChain, getAccountFields, getBackendMetadata, getExtension, hasBackend, incrementVersion, isBrowserEnv, isKeepFile, isMtimeSidecar, legacyVersionPathFor, listBackendMetadata, listBackends, localPrimaryType, mergeAccountFields, migrateVersionSidecars, purgeKeepFiles, purgeMtimeSidecars, readVersion, registerBackend, registerFolderBackend, resolveLocalPrimary, sha256, unregisterBackend, verifyOrRepairVersion, versionPathFor, wrapZenFSFileSystem, writeVersion };
|
|
1163
|
+
export { type AppDataBackendDescriptor, type AppDataGroup, type AppDataGroupDescriptor, type BackendDescriptor, type BackendFactory, type BackendInstance, type BackendMetadata, type BackendParamDef, type BackendSyncState, type BackendsMeta, type CacheOptions, ConfigRepo, type ConfigRepoOptions, type ConfigSerializer, type ConflictArchive, type ConflictInfo, type ConnectOptions, type ConnectResult, FolderStore, type IConfigRepo, type KeepPurgeResult, LOCAL_IDB_BACKEND_ID, type MigrateLocalFS, type MigrateReplicaFS, type MtimePurgeResult, type PurgeKeepOptions, type PurgeMtimeOptions, type PurgeableFS$1 as PurgeableFS, type SyncGroupType, type TombstoneMeta, type VersionMeta, type VersionMigrationOptions, type VersionMigrationResult, configKeyToFilePath, connect, createBackend, createConfigRepo, createSerializerChain, getAccountFields, getBackendMetadata, getExtension, hasBackend, incrementVersion, isBrowserEnv, isKeepFile, isMtimeSidecar, legacyVersionPathFor, listBackendMetadata, listBackends, localPrimaryType, mergeAccountFields, migrateVersionSidecars, purgeKeepFiles, purgeMtimeSidecars, readVersion, registerBackend, registerFolderBackend, resolveLocalPrimary, sha256, unregisterBackend, verifyOrRepairVersion, versionPathFor, wrapZenFSFileSystem, writeVersion };
|
package/dist/index.d.ts
CHANGED
|
@@ -347,6 +347,20 @@ interface AppDataGroupDescriptor {
|
|
|
347
347
|
groupType: 'data-sync';
|
|
348
348
|
backends: AppDataBackendDescriptor[];
|
|
349
349
|
}
|
|
350
|
+
/** Per-backend sync state of a data group. */
|
|
351
|
+
interface BackendSyncState {
|
|
352
|
+
backendId: string;
|
|
353
|
+
/** Pair id when the backend instance was created and paired successfully. */
|
|
354
|
+
pairId?: string;
|
|
355
|
+
/**
|
|
356
|
+
* Present when this descriptor could not be connected (e.g. a required
|
|
357
|
+
* option is missing), so no sync pair exists for it.
|
|
358
|
+
*/
|
|
359
|
+
error?: {
|
|
360
|
+
message: string;
|
|
361
|
+
timestamp: number;
|
|
362
|
+
};
|
|
363
|
+
}
|
|
350
364
|
/** Handle to a data-sync group, providing direct fs access. */
|
|
351
365
|
interface AppDataGroup {
|
|
352
366
|
readonly groupId: string;
|
|
@@ -355,6 +369,11 @@ interface AppDataGroup {
|
|
|
355
369
|
readonly fs: typeof node_fs;
|
|
356
370
|
/** Get sync status for this data group's sync pairs. */
|
|
357
371
|
getSyncStatuses(): Map<string, SyncPairStatus>;
|
|
372
|
+
/**
|
|
373
|
+
* Per-backend sync state, including descriptors that failed to connect and
|
|
374
|
+
* therefore have no pair (they do not appear in getSyncStatuses()).
|
|
375
|
+
*/
|
|
376
|
+
getBackendSyncStates(): Map<string, BackendSyncState>;
|
|
358
377
|
/** Manually flush pending sync. */
|
|
359
378
|
flush(): Promise<SyncResult[]>;
|
|
360
379
|
/** Stop sync and release resources. */
|
|
@@ -1141,4 +1160,4 @@ declare function incrementVersion(fs: SyncableFS, configFilePath: string, newCon
|
|
|
1141
1160
|
*/
|
|
1142
1161
|
declare function verifyOrRepairVersion(fs: SyncableFS, configFilePath: string, author: string): Promise<VersionMeta | null>;
|
|
1143
1162
|
|
|
1144
|
-
export { type AppDataBackendDescriptor, type AppDataGroup, type AppDataGroupDescriptor, type BackendDescriptor, type BackendFactory, type BackendInstance, type BackendMetadata, type BackendParamDef, type BackendsMeta, type CacheOptions, ConfigRepo, type ConfigRepoOptions, type ConfigSerializer, type ConflictArchive, type ConflictInfo, type ConnectOptions, type ConnectResult, FolderStore, type IConfigRepo, type KeepPurgeResult, LOCAL_IDB_BACKEND_ID, type MigrateLocalFS, type MigrateReplicaFS, type MtimePurgeResult, type PurgeKeepOptions, type PurgeMtimeOptions, type PurgeableFS$1 as PurgeableFS, type SyncGroupType, type TombstoneMeta, type VersionMeta, type VersionMigrationOptions, type VersionMigrationResult, configKeyToFilePath, connect, createBackend, createConfigRepo, createSerializerChain, getAccountFields, getBackendMetadata, getExtension, hasBackend, incrementVersion, isBrowserEnv, isKeepFile, isMtimeSidecar, legacyVersionPathFor, listBackendMetadata, listBackends, localPrimaryType, mergeAccountFields, migrateVersionSidecars, purgeKeepFiles, purgeMtimeSidecars, readVersion, registerBackend, registerFolderBackend, resolveLocalPrimary, sha256, unregisterBackend, verifyOrRepairVersion, versionPathFor, wrapZenFSFileSystem, writeVersion };
|
|
1163
|
+
export { type AppDataBackendDescriptor, type AppDataGroup, type AppDataGroupDescriptor, type BackendDescriptor, type BackendFactory, type BackendInstance, type BackendMetadata, type BackendParamDef, type BackendSyncState, type BackendsMeta, type CacheOptions, ConfigRepo, type ConfigRepoOptions, type ConfigSerializer, type ConflictArchive, type ConflictInfo, type ConnectOptions, type ConnectResult, FolderStore, type IConfigRepo, type KeepPurgeResult, LOCAL_IDB_BACKEND_ID, type MigrateLocalFS, type MigrateReplicaFS, type MtimePurgeResult, type PurgeKeepOptions, type PurgeMtimeOptions, type PurgeableFS$1 as PurgeableFS, type SyncGroupType, type TombstoneMeta, type VersionMeta, type VersionMigrationOptions, type VersionMigrationResult, configKeyToFilePath, connect, createBackend, createConfigRepo, createSerializerChain, getAccountFields, getBackendMetadata, getExtension, hasBackend, incrementVersion, isBrowserEnv, isKeepFile, isMtimeSidecar, legacyVersionPathFor, listBackendMetadata, listBackends, localPrimaryType, mergeAccountFields, migrateVersionSidecars, purgeKeepFiles, purgeMtimeSidecars, readVersion, registerBackend, registerFolderBackend, resolveLocalPrimary, sha256, unregisterBackend, verifyOrRepairVersion, versionPathFor, wrapZenFSFileSystem, writeVersion };
|
package/dist/index.js
CHANGED
|
@@ -2885,6 +2885,7 @@ var AppDataGroupImpl = class {
|
|
|
2885
2885
|
syncEngine;
|
|
2886
2886
|
localFS;
|
|
2887
2887
|
dataBackends = /* @__PURE__ */ new Map();
|
|
2888
|
+
backendStates = /* @__PURE__ */ new Map();
|
|
2888
2889
|
disposed = false;
|
|
2889
2890
|
constructor(groupId, appId, backends, pollIntervalMs, parent) {
|
|
2890
2891
|
this.groupId = groupId;
|
|
@@ -2901,7 +2902,11 @@ var AppDataGroupImpl = class {
|
|
|
2901
2902
|
_pollIntervalMs;
|
|
2902
2903
|
async init() {
|
|
2903
2904
|
try {
|
|
2904
|
-
const localPrimary = await resolveLocalPrimary(
|
|
2905
|
+
const localPrimary = await resolveLocalPrimary(
|
|
2906
|
+
this.appId,
|
|
2907
|
+
"data",
|
|
2908
|
+
this.groupId === "default" ? {} : { idbStoreName: `zen-fs-config-data-${this.appId}-${this.groupId}` }
|
|
2909
|
+
);
|
|
2905
2910
|
this.localFS = await createBackend(localPrimary);
|
|
2906
2911
|
} catch {
|
|
2907
2912
|
throw new Error(`Failed to create local primary for data group "${this.groupId}"`);
|
|
@@ -2953,8 +2958,14 @@ var AppDataGroupImpl = class {
|
|
|
2953
2958
|
"/"
|
|
2954
2959
|
);
|
|
2955
2960
|
this.dataBackends.set(desc.id, { instance, syncable, pairId: pair.pairId, desc });
|
|
2961
|
+
this.backendStates.set(desc.id, { backendId: desc.id, pairId: pair.pairId });
|
|
2956
2962
|
log2.log(`[AppDataGroup:${this.groupId}] backend ${desc.id} (${desc.type}) connected, pair=${pair.pairId}`);
|
|
2957
2963
|
} catch (err) {
|
|
2964
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2965
|
+
this.backendStates.set(desc.id, {
|
|
2966
|
+
backendId: desc.id,
|
|
2967
|
+
error: { message, timestamp: Date.now() }
|
|
2968
|
+
});
|
|
2958
2969
|
log2.error(`[AppDataGroup:${this.groupId}] Failed to create backend ${desc.id} (${desc.type}):`, err);
|
|
2959
2970
|
}
|
|
2960
2971
|
}
|
|
@@ -2979,6 +2990,9 @@ var AppDataGroupImpl = class {
|
|
|
2979
2990
|
const results = await this.syncEngine.syncAll();
|
|
2980
2991
|
return Array.from(results.values());
|
|
2981
2992
|
}
|
|
2993
|
+
getBackendSyncStates() {
|
|
2994
|
+
return new Map(this.backendStates);
|
|
2995
|
+
}
|
|
2982
2996
|
async addBackend(id, type, options, description) {
|
|
2983
2997
|
if (this.disposed) throw new Error("DataSyncGroup has been disposed");
|
|
2984
2998
|
if (this.dataBackends.has(id)) {
|
|
@@ -3001,6 +3015,8 @@ var AppDataGroupImpl = class {
|
|
|
3001
3015
|
);
|
|
3002
3016
|
const desc = { id, type, options, description, createdAt: Date.now() };
|
|
3003
3017
|
this.dataBackends.set(id, { instance, syncable, pairId: pair.pairId, desc });
|
|
3018
|
+
this.backendStates.set(id, { backendId: id, pairId: pair.pairId });
|
|
3019
|
+
this._backends = [...this._backends.filter((b) => b.id !== id), desc];
|
|
3004
3020
|
log2.log(`[AppDataGroup:${this.groupId}] addBackend: ${id} (${type}) connected, pair=${pair.pairId}`);
|
|
3005
3021
|
try {
|
|
3006
3022
|
await this.syncEngine.sync(pair.pairId);
|
|
@@ -3008,18 +3024,23 @@ var AppDataGroupImpl = class {
|
|
|
3008
3024
|
log2.warn(`[AppDataGroup:${this.groupId}] addBackend: initial sync failed for ${id}:`, err);
|
|
3009
3025
|
}
|
|
3010
3026
|
this.syncEngine.watch(pair.pairId);
|
|
3011
|
-
await this.parent.updateAppDataGroupDescriptor(this.groupId, this.
|
|
3027
|
+
await this.parent.updateAppDataGroupDescriptor(this.groupId, this._backends);
|
|
3012
3028
|
}
|
|
3013
3029
|
async removeBackend(id) {
|
|
3014
3030
|
if (this.disposed) throw new Error("DataSyncGroup has been disposed");
|
|
3015
3031
|
const backend = this.dataBackends.get(id);
|
|
3016
|
-
|
|
3032
|
+
const desc = this._backends.find((b) => b.id === id);
|
|
3033
|
+
if (!backend && !desc) {
|
|
3017
3034
|
throw new Error(`Backend "${id}" not found in data group "${this.groupId}"`);
|
|
3018
3035
|
}
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3036
|
+
if (backend) {
|
|
3037
|
+
this.syncEngine.removePair(backend.pairId);
|
|
3038
|
+
this.dataBackends.delete(id);
|
|
3039
|
+
}
|
|
3040
|
+
this.backendStates.delete(id);
|
|
3041
|
+
this._backends = this._backends.filter((b) => b.id !== id);
|
|
3042
|
+
await this.parent.updateAppDataGroupDescriptor(this.groupId, this._backends);
|
|
3043
|
+
if (backend?.instance?.dispose) {
|
|
3023
3044
|
await backend.instance.dispose();
|
|
3024
3045
|
}
|
|
3025
3046
|
log2.log(`[AppDataGroup:${this.groupId}] removeBackend: ${id} removed`);
|
package/dist/index.mjs
CHANGED
|
@@ -2345,6 +2345,7 @@ var AppDataGroupImpl = class {
|
|
|
2345
2345
|
syncEngine;
|
|
2346
2346
|
localFS;
|
|
2347
2347
|
dataBackends = /* @__PURE__ */ new Map();
|
|
2348
|
+
backendStates = /* @__PURE__ */ new Map();
|
|
2348
2349
|
disposed = false;
|
|
2349
2350
|
constructor(groupId, appId, backends, pollIntervalMs, parent) {
|
|
2350
2351
|
this.groupId = groupId;
|
|
@@ -2361,7 +2362,11 @@ var AppDataGroupImpl = class {
|
|
|
2361
2362
|
_pollIntervalMs;
|
|
2362
2363
|
async init() {
|
|
2363
2364
|
try {
|
|
2364
|
-
const localPrimary = await resolveLocalPrimary(
|
|
2365
|
+
const localPrimary = await resolveLocalPrimary(
|
|
2366
|
+
this.appId,
|
|
2367
|
+
"data",
|
|
2368
|
+
this.groupId === "default" ? {} : { idbStoreName: `zen-fs-config-data-${this.appId}-${this.groupId}` }
|
|
2369
|
+
);
|
|
2365
2370
|
this.localFS = await createBackend(localPrimary);
|
|
2366
2371
|
} catch {
|
|
2367
2372
|
throw new Error(`Failed to create local primary for data group "${this.groupId}"`);
|
|
@@ -2413,8 +2418,14 @@ var AppDataGroupImpl = class {
|
|
|
2413
2418
|
"/"
|
|
2414
2419
|
);
|
|
2415
2420
|
this.dataBackends.set(desc.id, { instance, syncable, pairId: pair.pairId, desc });
|
|
2421
|
+
this.backendStates.set(desc.id, { backendId: desc.id, pairId: pair.pairId });
|
|
2416
2422
|
log2.log(`[AppDataGroup:${this.groupId}] backend ${desc.id} (${desc.type}) connected, pair=${pair.pairId}`);
|
|
2417
2423
|
} catch (err) {
|
|
2424
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2425
|
+
this.backendStates.set(desc.id, {
|
|
2426
|
+
backendId: desc.id,
|
|
2427
|
+
error: { message, timestamp: Date.now() }
|
|
2428
|
+
});
|
|
2418
2429
|
log2.error(`[AppDataGroup:${this.groupId}] Failed to create backend ${desc.id} (${desc.type}):`, err);
|
|
2419
2430
|
}
|
|
2420
2431
|
}
|
|
@@ -2439,6 +2450,9 @@ var AppDataGroupImpl = class {
|
|
|
2439
2450
|
const results = await this.syncEngine.syncAll();
|
|
2440
2451
|
return Array.from(results.values());
|
|
2441
2452
|
}
|
|
2453
|
+
getBackendSyncStates() {
|
|
2454
|
+
return new Map(this.backendStates);
|
|
2455
|
+
}
|
|
2442
2456
|
async addBackend(id, type, options, description) {
|
|
2443
2457
|
if (this.disposed) throw new Error("DataSyncGroup has been disposed");
|
|
2444
2458
|
if (this.dataBackends.has(id)) {
|
|
@@ -2461,6 +2475,8 @@ var AppDataGroupImpl = class {
|
|
|
2461
2475
|
);
|
|
2462
2476
|
const desc = { id, type, options, description, createdAt: Date.now() };
|
|
2463
2477
|
this.dataBackends.set(id, { instance, syncable, pairId: pair.pairId, desc });
|
|
2478
|
+
this.backendStates.set(id, { backendId: id, pairId: pair.pairId });
|
|
2479
|
+
this._backends = [...this._backends.filter((b) => b.id !== id), desc];
|
|
2464
2480
|
log2.log(`[AppDataGroup:${this.groupId}] addBackend: ${id} (${type}) connected, pair=${pair.pairId}`);
|
|
2465
2481
|
try {
|
|
2466
2482
|
await this.syncEngine.sync(pair.pairId);
|
|
@@ -2468,18 +2484,23 @@ var AppDataGroupImpl = class {
|
|
|
2468
2484
|
log2.warn(`[AppDataGroup:${this.groupId}] addBackend: initial sync failed for ${id}:`, err);
|
|
2469
2485
|
}
|
|
2470
2486
|
this.syncEngine.watch(pair.pairId);
|
|
2471
|
-
await this.parent.updateAppDataGroupDescriptor(this.groupId, this.
|
|
2487
|
+
await this.parent.updateAppDataGroupDescriptor(this.groupId, this._backends);
|
|
2472
2488
|
}
|
|
2473
2489
|
async removeBackend(id) {
|
|
2474
2490
|
if (this.disposed) throw new Error("DataSyncGroup has been disposed");
|
|
2475
2491
|
const backend = this.dataBackends.get(id);
|
|
2476
|
-
|
|
2492
|
+
const desc = this._backends.find((b) => b.id === id);
|
|
2493
|
+
if (!backend && !desc) {
|
|
2477
2494
|
throw new Error(`Backend "${id}" not found in data group "${this.groupId}"`);
|
|
2478
2495
|
}
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2496
|
+
if (backend) {
|
|
2497
|
+
this.syncEngine.removePair(backend.pairId);
|
|
2498
|
+
this.dataBackends.delete(id);
|
|
2499
|
+
}
|
|
2500
|
+
this.backendStates.delete(id);
|
|
2501
|
+
this._backends = this._backends.filter((b) => b.id !== id);
|
|
2502
|
+
await this.parent.updateAppDataGroupDescriptor(this.groupId, this._backends);
|
|
2503
|
+
if (backend?.instance?.dispose) {
|
|
2483
2504
|
await backend.instance.dispose();
|
|
2484
2505
|
}
|
|
2485
2506
|
log2.log(`[AppDataGroup:${this.groupId}] removeBackend: ${id} removed`);
|
package/dist/zen-fs-config.js
CHANGED
|
@@ -28911,6 +28911,7 @@ var ZenFSConfig = (() => {
|
|
|
28911
28911
|
__publicField(this, "syncEngine");
|
|
28912
28912
|
__publicField(this, "localFS");
|
|
28913
28913
|
__publicField(this, "dataBackends", /* @__PURE__ */ new Map());
|
|
28914
|
+
__publicField(this, "backendStates", /* @__PURE__ */ new Map());
|
|
28914
28915
|
__publicField(this, "disposed", false);
|
|
28915
28916
|
__publicField(this, "parent");
|
|
28916
28917
|
__publicField(this, "_backends");
|
|
@@ -28926,7 +28927,11 @@ var ZenFSConfig = (() => {
|
|
|
28926
28927
|
}
|
|
28927
28928
|
async init() {
|
|
28928
28929
|
try {
|
|
28929
|
-
const localPrimary = await resolveLocalPrimary(
|
|
28930
|
+
const localPrimary = await resolveLocalPrimary(
|
|
28931
|
+
this.appId,
|
|
28932
|
+
"data",
|
|
28933
|
+
this.groupId === "default" ? {} : { idbStoreName: `zen-fs-config-data-${this.appId}-${this.groupId}` }
|
|
28934
|
+
);
|
|
28930
28935
|
this.localFS = await createBackend(localPrimary);
|
|
28931
28936
|
} catch {
|
|
28932
28937
|
throw new Error(`Failed to create local primary for data group "${this.groupId}"`);
|
|
@@ -28978,8 +28983,14 @@ var ZenFSConfig = (() => {
|
|
|
28978
28983
|
"/"
|
|
28979
28984
|
);
|
|
28980
28985
|
this.dataBackends.set(desc.id, { instance, syncable, pairId: pair.pairId, desc });
|
|
28986
|
+
this.backendStates.set(desc.id, { backendId: desc.id, pairId: pair.pairId });
|
|
28981
28987
|
log6.log(`[AppDataGroup:${this.groupId}] backend ${desc.id} (${desc.type}) connected, pair=${pair.pairId}`);
|
|
28982
28988
|
} catch (err2) {
|
|
28989
|
+
const message = err2 instanceof Error ? err2.message : String(err2);
|
|
28990
|
+
this.backendStates.set(desc.id, {
|
|
28991
|
+
backendId: desc.id,
|
|
28992
|
+
error: { message, timestamp: Date.now() }
|
|
28993
|
+
});
|
|
28983
28994
|
log6.error(`[AppDataGroup:${this.groupId}] Failed to create backend ${desc.id} (${desc.type}):`, err2);
|
|
28984
28995
|
}
|
|
28985
28996
|
}
|
|
@@ -29004,6 +29015,9 @@ var ZenFSConfig = (() => {
|
|
|
29004
29015
|
const results = await this.syncEngine.syncAll();
|
|
29005
29016
|
return Array.from(results.values());
|
|
29006
29017
|
}
|
|
29018
|
+
getBackendSyncStates() {
|
|
29019
|
+
return new Map(this.backendStates);
|
|
29020
|
+
}
|
|
29007
29021
|
async addBackend(id, type, options, description) {
|
|
29008
29022
|
if (this.disposed) throw new Error("DataSyncGroup has been disposed");
|
|
29009
29023
|
if (this.dataBackends.has(id)) {
|
|
@@ -29026,6 +29040,8 @@ var ZenFSConfig = (() => {
|
|
|
29026
29040
|
);
|
|
29027
29041
|
const desc = { id, type, options, description, createdAt: Date.now() };
|
|
29028
29042
|
this.dataBackends.set(id, { instance, syncable, pairId: pair.pairId, desc });
|
|
29043
|
+
this.backendStates.set(id, { backendId: id, pairId: pair.pairId });
|
|
29044
|
+
this._backends = [...this._backends.filter((b) => b.id !== id), desc];
|
|
29029
29045
|
log6.log(`[AppDataGroup:${this.groupId}] addBackend: ${id} (${type}) connected, pair=${pair.pairId}`);
|
|
29030
29046
|
try {
|
|
29031
29047
|
await this.syncEngine.sync(pair.pairId);
|
|
@@ -29033,18 +29049,23 @@ var ZenFSConfig = (() => {
|
|
|
29033
29049
|
log6.warn(`[AppDataGroup:${this.groupId}] addBackend: initial sync failed for ${id}:`, err2);
|
|
29034
29050
|
}
|
|
29035
29051
|
this.syncEngine.watch(pair.pairId);
|
|
29036
|
-
await this.parent.updateAppDataGroupDescriptor(this.groupId, this.
|
|
29052
|
+
await this.parent.updateAppDataGroupDescriptor(this.groupId, this._backends);
|
|
29037
29053
|
}
|
|
29038
29054
|
async removeBackend(id) {
|
|
29039
29055
|
if (this.disposed) throw new Error("DataSyncGroup has been disposed");
|
|
29040
29056
|
const backend = this.dataBackends.get(id);
|
|
29041
|
-
|
|
29057
|
+
const desc = this._backends.find((b) => b.id === id);
|
|
29058
|
+
if (!backend && !desc) {
|
|
29042
29059
|
throw new Error(`Backend "${id}" not found in data group "${this.groupId}"`);
|
|
29043
29060
|
}
|
|
29044
|
-
|
|
29045
|
-
|
|
29046
|
-
|
|
29047
|
-
|
|
29061
|
+
if (backend) {
|
|
29062
|
+
this.syncEngine.removePair(backend.pairId);
|
|
29063
|
+
this.dataBackends.delete(id);
|
|
29064
|
+
}
|
|
29065
|
+
this.backendStates.delete(id);
|
|
29066
|
+
this._backends = this._backends.filter((b) => b.id !== id);
|
|
29067
|
+
await this.parent.updateAppDataGroupDescriptor(this.groupId, this._backends);
|
|
29068
|
+
if (backend?.instance?.dispose) {
|
|
29048
29069
|
await backend.instance.dispose();
|
|
29049
29070
|
}
|
|
29050
29071
|
log6.log(`[AppDataGroup:${this.groupId}] removeBackend: ${id} removed`);
|