zen-fs-config 0.6.0 → 0.6.1
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 +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +48 -0
- package/dist/index.mjs +48 -0
- package/dist/zen-fs-config.js +48 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1098,6 +1098,16 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1098
1098
|
* (they have no sync pair, so they never show up in getSyncStatuses()).
|
|
1099
1099
|
*/
|
|
1100
1100
|
getBackendSyncStates(): Map<string, BackendSyncState>;
|
|
1101
|
+
/**
|
|
1102
|
+
* Mirror per-pair `sync:error` into `getBackendSyncStates()`.
|
|
1103
|
+
*
|
|
1104
|
+
* `SyncEngine.syncAll()` catches per-pair exceptions and substitutes an empty
|
|
1105
|
+
* result, so a failed replica otherwise only shows up as a missing
|
|
1106
|
+
* `lastResult`. Recording the real error lets callers report the actual
|
|
1107
|
+
* status (401/403/404/timeout) instead of guessing "remote unreachable or
|
|
1108
|
+
* invalid credentials".
|
|
1109
|
+
*/
|
|
1110
|
+
private trackSyncErrors;
|
|
1101
1111
|
/** Registered replica backend descriptors (excludes the implicit local primary). */
|
|
1102
1112
|
listBackends(): AppDataBackendDescriptor[];
|
|
1103
1113
|
/** 配置组的权威后端列表(`.config/backends/`),与 `listBackends()` 相同。 */
|
package/dist/index.d.ts
CHANGED
|
@@ -1098,6 +1098,16 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1098
1098
|
* (they have no sync pair, so they never show up in getSyncStatuses()).
|
|
1099
1099
|
*/
|
|
1100
1100
|
getBackendSyncStates(): Map<string, BackendSyncState>;
|
|
1101
|
+
/**
|
|
1102
|
+
* Mirror per-pair `sync:error` into `getBackendSyncStates()`.
|
|
1103
|
+
*
|
|
1104
|
+
* `SyncEngine.syncAll()` catches per-pair exceptions and substitutes an empty
|
|
1105
|
+
* result, so a failed replica otherwise only shows up as a missing
|
|
1106
|
+
* `lastResult`. Recording the real error lets callers report the actual
|
|
1107
|
+
* status (401/403/404/timeout) instead of guessing "remote unreachable or
|
|
1108
|
+
* invalid credentials".
|
|
1109
|
+
*/
|
|
1110
|
+
private trackSyncErrors;
|
|
1101
1111
|
/** Registered replica backend descriptors (excludes the implicit local primary). */
|
|
1102
1112
|
listBackends(): AppDataBackendDescriptor[];
|
|
1103
1113
|
/** 配置组的权威后端列表(`.config/backends/`),与 `listBackends()` 相同。 */
|
package/dist/index.js
CHANGED
|
@@ -2753,6 +2753,32 @@ var ConfigRepo = class {
|
|
|
2753
2753
|
this.assertNotDisposed();
|
|
2754
2754
|
return new Map(this.backendStates);
|
|
2755
2755
|
}
|
|
2756
|
+
/**
|
|
2757
|
+
* Mirror per-pair `sync:error` into `getBackendSyncStates()`.
|
|
2758
|
+
*
|
|
2759
|
+
* `SyncEngine.syncAll()` catches per-pair exceptions and substitutes an empty
|
|
2760
|
+
* result, so a failed replica otherwise only shows up as a missing
|
|
2761
|
+
* `lastResult`. Recording the real error lets callers report the actual
|
|
2762
|
+
* status (401/403/404/timeout) instead of guessing "remote unreachable or
|
|
2763
|
+
* invalid credentials".
|
|
2764
|
+
*/
|
|
2765
|
+
trackSyncErrors(backendId, pairId) {
|
|
2766
|
+
this.syncEngine.on(pairId, "sync:error", (event) => {
|
|
2767
|
+
const error = event.error;
|
|
2768
|
+
this.backendStates.set(backendId, {
|
|
2769
|
+
backendId,
|
|
2770
|
+
pairId,
|
|
2771
|
+
error: {
|
|
2772
|
+
message: error instanceof Error ? error.message : String(error ?? "sync failed"),
|
|
2773
|
+
timestamp: Date.now()
|
|
2774
|
+
}
|
|
2775
|
+
});
|
|
2776
|
+
});
|
|
2777
|
+
this.syncEngine.on(pairId, "sync:end", () => {
|
|
2778
|
+
const current = this.backendStates.get(backendId);
|
|
2779
|
+
if (current?.error) this.backendStates.set(backendId, { backendId, pairId });
|
|
2780
|
+
});
|
|
2781
|
+
}
|
|
2756
2782
|
/** Registered replica backend descriptors (excludes the implicit local primary). */
|
|
2757
2783
|
listBackends() {
|
|
2758
2784
|
this.assertNotDisposed();
|
|
@@ -2933,6 +2959,7 @@ var ConfigRepo = class {
|
|
|
2933
2959
|
this.handleConflict(event);
|
|
2934
2960
|
};
|
|
2935
2961
|
this.syncEngine.on(pair.pairId, "conflict", conflictHandler);
|
|
2962
|
+
this.trackSyncErrors(desc.id, pair.pairId);
|
|
2936
2963
|
log2.log(`[ConfigRepo] Replica ${desc.id} created, sync pair=${pair.pairId}`);
|
|
2937
2964
|
} catch (err) {
|
|
2938
2965
|
log2.error(`[ConfigRepo] Failed to create replica ${desc.id} (${desc.type}):`, err);
|
|
@@ -3422,6 +3449,7 @@ var ConfigRepo = class {
|
|
|
3422
3449
|
this.handleConflict(event);
|
|
3423
3450
|
};
|
|
3424
3451
|
this.syncEngine.on(pair.pairId, "conflict", conflictHandler);
|
|
3452
|
+
this.trackSyncErrors(id, pair.pairId);
|
|
3425
3453
|
log2.log(`[ConfigRepo] addBackend: ${id} (${type}) added, sync pair=${pair.pairId}`);
|
|
3426
3454
|
await this.syncMetaToReplicas();
|
|
3427
3455
|
this.syncEngine.watch(pair.pairId);
|
|
@@ -4200,6 +4228,7 @@ var AppDataGroupImpl = class {
|
|
|
4200
4228
|
};
|
|
4201
4229
|
this.syncEngine.on(pair.pairId, "conflict", conflictHandler);
|
|
4202
4230
|
}
|
|
4231
|
+
this.trackSyncErrors(desc.id, pair.pairId);
|
|
4203
4232
|
log2.log(`[AppDataGroup:${this.groupId}] backend ${desc.id} (${desc.type}) connected, pair=${pair.pairId}`);
|
|
4204
4233
|
} catch (err) {
|
|
4205
4234
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -4235,6 +4264,24 @@ var AppDataGroupImpl = class {
|
|
|
4235
4264
|
getBackendSyncStates() {
|
|
4236
4265
|
return new Map(this.backendStates);
|
|
4237
4266
|
}
|
|
4267
|
+
/** Mirror per-pair `sync:error` into `getBackendSyncStates()` (see ConfigRepo). */
|
|
4268
|
+
trackSyncErrors(backendId, pairId) {
|
|
4269
|
+
this.syncEngine.on(pairId, "sync:error", (event) => {
|
|
4270
|
+
const error = event.error;
|
|
4271
|
+
this.backendStates.set(backendId, {
|
|
4272
|
+
backendId,
|
|
4273
|
+
pairId,
|
|
4274
|
+
error: {
|
|
4275
|
+
message: error instanceof Error ? error.message : String(error ?? "sync failed"),
|
|
4276
|
+
timestamp: Date.now()
|
|
4277
|
+
}
|
|
4278
|
+
});
|
|
4279
|
+
});
|
|
4280
|
+
this.syncEngine.on(pairId, "sync:end", () => {
|
|
4281
|
+
const current = this.backendStates.get(backendId);
|
|
4282
|
+
if (current?.error) this.backendStates.set(backendId, { backendId, pairId });
|
|
4283
|
+
});
|
|
4284
|
+
}
|
|
4238
4285
|
// -----------------------------------------------------------------------
|
|
4239
4286
|
// Unified SyncGroupHandle — deletion & metadata (data groups)
|
|
4240
4287
|
// -----------------------------------------------------------------------
|
|
@@ -4399,6 +4446,7 @@ var AppDataGroupImpl = class {
|
|
|
4399
4446
|
});
|
|
4400
4447
|
});
|
|
4401
4448
|
}
|
|
4449
|
+
this.trackSyncErrors(id, pair.pairId);
|
|
4402
4450
|
this._backends = [...this._backends.filter((b) => b.id !== id), desc];
|
|
4403
4451
|
log2.log(`[AppDataGroup:${this.groupId}] addBackend: ${id} (${type}) connected, pair=${pair.pairId}`);
|
|
4404
4452
|
try {
|
package/dist/index.mjs
CHANGED
|
@@ -2198,6 +2198,32 @@ var ConfigRepo = class {
|
|
|
2198
2198
|
this.assertNotDisposed();
|
|
2199
2199
|
return new Map(this.backendStates);
|
|
2200
2200
|
}
|
|
2201
|
+
/**
|
|
2202
|
+
* Mirror per-pair `sync:error` into `getBackendSyncStates()`.
|
|
2203
|
+
*
|
|
2204
|
+
* `SyncEngine.syncAll()` catches per-pair exceptions and substitutes an empty
|
|
2205
|
+
* result, so a failed replica otherwise only shows up as a missing
|
|
2206
|
+
* `lastResult`. Recording the real error lets callers report the actual
|
|
2207
|
+
* status (401/403/404/timeout) instead of guessing "remote unreachable or
|
|
2208
|
+
* invalid credentials".
|
|
2209
|
+
*/
|
|
2210
|
+
trackSyncErrors(backendId, pairId) {
|
|
2211
|
+
this.syncEngine.on(pairId, "sync:error", (event) => {
|
|
2212
|
+
const error = event.error;
|
|
2213
|
+
this.backendStates.set(backendId, {
|
|
2214
|
+
backendId,
|
|
2215
|
+
pairId,
|
|
2216
|
+
error: {
|
|
2217
|
+
message: error instanceof Error ? error.message : String(error ?? "sync failed"),
|
|
2218
|
+
timestamp: Date.now()
|
|
2219
|
+
}
|
|
2220
|
+
});
|
|
2221
|
+
});
|
|
2222
|
+
this.syncEngine.on(pairId, "sync:end", () => {
|
|
2223
|
+
const current = this.backendStates.get(backendId);
|
|
2224
|
+
if (current?.error) this.backendStates.set(backendId, { backendId, pairId });
|
|
2225
|
+
});
|
|
2226
|
+
}
|
|
2201
2227
|
/** Registered replica backend descriptors (excludes the implicit local primary). */
|
|
2202
2228
|
listBackends() {
|
|
2203
2229
|
this.assertNotDisposed();
|
|
@@ -2378,6 +2404,7 @@ var ConfigRepo = class {
|
|
|
2378
2404
|
this.handleConflict(event);
|
|
2379
2405
|
};
|
|
2380
2406
|
this.syncEngine.on(pair.pairId, "conflict", conflictHandler);
|
|
2407
|
+
this.trackSyncErrors(desc.id, pair.pairId);
|
|
2381
2408
|
log2.log(`[ConfigRepo] Replica ${desc.id} created, sync pair=${pair.pairId}`);
|
|
2382
2409
|
} catch (err) {
|
|
2383
2410
|
log2.error(`[ConfigRepo] Failed to create replica ${desc.id} (${desc.type}):`, err);
|
|
@@ -2867,6 +2894,7 @@ var ConfigRepo = class {
|
|
|
2867
2894
|
this.handleConflict(event);
|
|
2868
2895
|
};
|
|
2869
2896
|
this.syncEngine.on(pair.pairId, "conflict", conflictHandler);
|
|
2897
|
+
this.trackSyncErrors(id, pair.pairId);
|
|
2870
2898
|
log2.log(`[ConfigRepo] addBackend: ${id} (${type}) added, sync pair=${pair.pairId}`);
|
|
2871
2899
|
await this.syncMetaToReplicas();
|
|
2872
2900
|
this.syncEngine.watch(pair.pairId);
|
|
@@ -3645,6 +3673,7 @@ var AppDataGroupImpl = class {
|
|
|
3645
3673
|
};
|
|
3646
3674
|
this.syncEngine.on(pair.pairId, "conflict", conflictHandler);
|
|
3647
3675
|
}
|
|
3676
|
+
this.trackSyncErrors(desc.id, pair.pairId);
|
|
3648
3677
|
log2.log(`[AppDataGroup:${this.groupId}] backend ${desc.id} (${desc.type}) connected, pair=${pair.pairId}`);
|
|
3649
3678
|
} catch (err) {
|
|
3650
3679
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -3680,6 +3709,24 @@ var AppDataGroupImpl = class {
|
|
|
3680
3709
|
getBackendSyncStates() {
|
|
3681
3710
|
return new Map(this.backendStates);
|
|
3682
3711
|
}
|
|
3712
|
+
/** Mirror per-pair `sync:error` into `getBackendSyncStates()` (see ConfigRepo). */
|
|
3713
|
+
trackSyncErrors(backendId, pairId) {
|
|
3714
|
+
this.syncEngine.on(pairId, "sync:error", (event) => {
|
|
3715
|
+
const error = event.error;
|
|
3716
|
+
this.backendStates.set(backendId, {
|
|
3717
|
+
backendId,
|
|
3718
|
+
pairId,
|
|
3719
|
+
error: {
|
|
3720
|
+
message: error instanceof Error ? error.message : String(error ?? "sync failed"),
|
|
3721
|
+
timestamp: Date.now()
|
|
3722
|
+
}
|
|
3723
|
+
});
|
|
3724
|
+
});
|
|
3725
|
+
this.syncEngine.on(pairId, "sync:end", () => {
|
|
3726
|
+
const current = this.backendStates.get(backendId);
|
|
3727
|
+
if (current?.error) this.backendStates.set(backendId, { backendId, pairId });
|
|
3728
|
+
});
|
|
3729
|
+
}
|
|
3683
3730
|
// -----------------------------------------------------------------------
|
|
3684
3731
|
// Unified SyncGroupHandle — deletion & metadata (data groups)
|
|
3685
3732
|
// -----------------------------------------------------------------------
|
|
@@ -3844,6 +3891,7 @@ var AppDataGroupImpl = class {
|
|
|
3844
3891
|
});
|
|
3845
3892
|
});
|
|
3846
3893
|
}
|
|
3894
|
+
this.trackSyncErrors(id, pair.pairId);
|
|
3847
3895
|
this._backends = [...this._backends.filter((b) => b.id !== id), desc];
|
|
3848
3896
|
log2.log(`[AppDataGroup:${this.groupId}] addBackend: ${id} (${type}) connected, pair=${pair.pairId}`);
|
|
3849
3897
|
try {
|
package/dist/zen-fs-config.js
CHANGED
|
@@ -28770,6 +28770,32 @@ var ZenFSConfig = (() => {
|
|
|
28770
28770
|
this.assertNotDisposed();
|
|
28771
28771
|
return new Map(this.backendStates);
|
|
28772
28772
|
}
|
|
28773
|
+
/**
|
|
28774
|
+
* Mirror per-pair `sync:error` into `getBackendSyncStates()`.
|
|
28775
|
+
*
|
|
28776
|
+
* `SyncEngine.syncAll()` catches per-pair exceptions and substitutes an empty
|
|
28777
|
+
* result, so a failed replica otherwise only shows up as a missing
|
|
28778
|
+
* `lastResult`. Recording the real error lets callers report the actual
|
|
28779
|
+
* status (401/403/404/timeout) instead of guessing "remote unreachable or
|
|
28780
|
+
* invalid credentials".
|
|
28781
|
+
*/
|
|
28782
|
+
trackSyncErrors(backendId, pairId) {
|
|
28783
|
+
this.syncEngine.on(pairId, "sync:error", (event) => {
|
|
28784
|
+
const error = event.error;
|
|
28785
|
+
this.backendStates.set(backendId, {
|
|
28786
|
+
backendId,
|
|
28787
|
+
pairId,
|
|
28788
|
+
error: {
|
|
28789
|
+
message: error instanceof Error ? error.message : String(error ?? "sync failed"),
|
|
28790
|
+
timestamp: Date.now()
|
|
28791
|
+
}
|
|
28792
|
+
});
|
|
28793
|
+
});
|
|
28794
|
+
this.syncEngine.on(pairId, "sync:end", () => {
|
|
28795
|
+
const current = this.backendStates.get(backendId);
|
|
28796
|
+
if (current?.error) this.backendStates.set(backendId, { backendId, pairId });
|
|
28797
|
+
});
|
|
28798
|
+
}
|
|
28773
28799
|
/** Registered replica backend descriptors (excludes the implicit local primary). */
|
|
28774
28800
|
listBackends() {
|
|
28775
28801
|
this.assertNotDisposed();
|
|
@@ -28950,6 +28976,7 @@ var ZenFSConfig = (() => {
|
|
|
28950
28976
|
this.handleConflict(event);
|
|
28951
28977
|
};
|
|
28952
28978
|
this.syncEngine.on(pair.pairId, "conflict", conflictHandler);
|
|
28979
|
+
this.trackSyncErrors(desc.id, pair.pairId);
|
|
28953
28980
|
log6.log(`[ConfigRepo] Replica ${desc.id} created, sync pair=${pair.pairId}`);
|
|
28954
28981
|
} catch (err2) {
|
|
28955
28982
|
log6.error(`[ConfigRepo] Failed to create replica ${desc.id} (${desc.type}):`, err2);
|
|
@@ -29439,6 +29466,7 @@ var ZenFSConfig = (() => {
|
|
|
29439
29466
|
this.handleConflict(event);
|
|
29440
29467
|
};
|
|
29441
29468
|
this.syncEngine.on(pair.pairId, "conflict", conflictHandler);
|
|
29469
|
+
this.trackSyncErrors(id, pair.pairId);
|
|
29442
29470
|
log6.log(`[ConfigRepo] addBackend: ${id} (${type}) added, sync pair=${pair.pairId}`);
|
|
29443
29471
|
await this.syncMetaToReplicas();
|
|
29444
29472
|
this.syncEngine.watch(pair.pairId);
|
|
@@ -30217,6 +30245,7 @@ var ZenFSConfig = (() => {
|
|
|
30217
30245
|
};
|
|
30218
30246
|
this.syncEngine.on(pair.pairId, "conflict", conflictHandler);
|
|
30219
30247
|
}
|
|
30248
|
+
this.trackSyncErrors(desc.id, pair.pairId);
|
|
30220
30249
|
log6.log(`[AppDataGroup:${this.groupId}] backend ${desc.id} (${desc.type}) connected, pair=${pair.pairId}`);
|
|
30221
30250
|
} catch (err2) {
|
|
30222
30251
|
const message = err2 instanceof Error ? err2.message : String(err2);
|
|
@@ -30252,6 +30281,24 @@ var ZenFSConfig = (() => {
|
|
|
30252
30281
|
getBackendSyncStates() {
|
|
30253
30282
|
return new Map(this.backendStates);
|
|
30254
30283
|
}
|
|
30284
|
+
/** Mirror per-pair `sync:error` into `getBackendSyncStates()` (see ConfigRepo). */
|
|
30285
|
+
trackSyncErrors(backendId, pairId) {
|
|
30286
|
+
this.syncEngine.on(pairId, "sync:error", (event) => {
|
|
30287
|
+
const error = event.error;
|
|
30288
|
+
this.backendStates.set(backendId, {
|
|
30289
|
+
backendId,
|
|
30290
|
+
pairId,
|
|
30291
|
+
error: {
|
|
30292
|
+
message: error instanceof Error ? error.message : String(error ?? "sync failed"),
|
|
30293
|
+
timestamp: Date.now()
|
|
30294
|
+
}
|
|
30295
|
+
});
|
|
30296
|
+
});
|
|
30297
|
+
this.syncEngine.on(pairId, "sync:end", () => {
|
|
30298
|
+
const current = this.backendStates.get(backendId);
|
|
30299
|
+
if (current?.error) this.backendStates.set(backendId, { backendId, pairId });
|
|
30300
|
+
});
|
|
30301
|
+
}
|
|
30255
30302
|
// -----------------------------------------------------------------------
|
|
30256
30303
|
// Unified SyncGroupHandle — deletion & metadata (data groups)
|
|
30257
30304
|
// -----------------------------------------------------------------------
|
|
@@ -30416,6 +30463,7 @@ var ZenFSConfig = (() => {
|
|
|
30416
30463
|
});
|
|
30417
30464
|
});
|
|
30418
30465
|
}
|
|
30466
|
+
this.trackSyncErrors(id, pair.pairId);
|
|
30419
30467
|
this._backends = [...this._backends.filter((b) => b.id !== id), desc];
|
|
30420
30468
|
log6.log(`[AppDataGroup:${this.groupId}] addBackend: ${id} (${type}) connected, pair=${pair.pairId}`);
|
|
30421
30469
|
try {
|