zen-fs-config 0.4.4 → 0.4.5
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 +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +8 -4
- package/dist/index.mjs +8 -4
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -125,6 +125,12 @@ interface ConfigRepoOptions {
|
|
|
125
125
|
serializer?: ConfigSerializer;
|
|
126
126
|
/** Custom conflict handler. Called before auto-resolution. */
|
|
127
127
|
onConflict?: (conflict: ConflictInfo) => Promise<unknown | null>;
|
|
128
|
+
/**
|
|
129
|
+
* Sync polling interval in milliseconds.
|
|
130
|
+
* Controls how often the sync engine checks for remote changes.
|
|
131
|
+
* Default: 1800000 (30 minutes).
|
|
132
|
+
*/
|
|
133
|
+
syncPollIntervalMs?: number;
|
|
128
134
|
}
|
|
129
135
|
/** The main configuration repository interface. */
|
|
130
136
|
interface IConfigRepo {
|
|
@@ -389,7 +395,7 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
389
395
|
listConflicts(): Promise<ConflictArchive[]>;
|
|
390
396
|
readConflictBackup(conflictId: string, fileType: 'source' | 'target' | 'resolved'): Promise<string>;
|
|
391
397
|
dispose(): Promise<void>;
|
|
392
|
-
setupSync(backends: BackendDescriptor[], primaryBackendId: string): Promise<void>;
|
|
398
|
+
setupSync(backends: BackendDescriptor[], primaryBackendId: string, pollIntervalMs?: number): Promise<void>;
|
|
393
399
|
private persistConfig;
|
|
394
400
|
private reloadConfigCache;
|
|
395
401
|
private handleConflict;
|
package/dist/index.d.ts
CHANGED
|
@@ -125,6 +125,12 @@ interface ConfigRepoOptions {
|
|
|
125
125
|
serializer?: ConfigSerializer;
|
|
126
126
|
/** Custom conflict handler. Called before auto-resolution. */
|
|
127
127
|
onConflict?: (conflict: ConflictInfo) => Promise<unknown | null>;
|
|
128
|
+
/**
|
|
129
|
+
* Sync polling interval in milliseconds.
|
|
130
|
+
* Controls how often the sync engine checks for remote changes.
|
|
131
|
+
* Default: 1800000 (30 minutes).
|
|
132
|
+
*/
|
|
133
|
+
syncPollIntervalMs?: number;
|
|
128
134
|
}
|
|
129
135
|
/** The main configuration repository interface. */
|
|
130
136
|
interface IConfigRepo {
|
|
@@ -389,7 +395,7 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
389
395
|
listConflicts(): Promise<ConflictArchive[]>;
|
|
390
396
|
readConflictBackup(conflictId: string, fileType: 'source' | 'target' | 'resolved'): Promise<string>;
|
|
391
397
|
dispose(): Promise<void>;
|
|
392
|
-
setupSync(backends: BackendDescriptor[], primaryBackendId: string): Promise<void>;
|
|
398
|
+
setupSync(backends: BackendDescriptor[], primaryBackendId: string, pollIntervalMs?: number): Promise<void>;
|
|
393
399
|
private persistConfig;
|
|
394
400
|
private reloadConfigCache;
|
|
395
401
|
private handleConflict;
|
package/dist/index.js
CHANGED
|
@@ -263,6 +263,9 @@ function backendToSyncableFS(backend, name) {
|
|
|
263
263
|
return backend.exists(path);
|
|
264
264
|
}
|
|
265
265
|
};
|
|
266
|
+
if (typeof backend.checkForUpdates === "function") {
|
|
267
|
+
syncable.checkForUpdates = () => backend.checkForUpdates();
|
|
268
|
+
}
|
|
266
269
|
if (name) {
|
|
267
270
|
syncable.backendName = name;
|
|
268
271
|
} else if (backend.backendName) {
|
|
@@ -894,8 +897,8 @@ var ConfigRepo = class {
|
|
|
894
897
|
// -----------------------------------------------------------------------
|
|
895
898
|
// Internal — Setup
|
|
896
899
|
// -----------------------------------------------------------------------
|
|
897
|
-
async setupSync(backends, primaryBackendId) {
|
|
898
|
-
console.log(`[ConfigRepo] setupSync: ${backends.length} backends, primary=${primaryBackendId}`);
|
|
900
|
+
async setupSync(backends, primaryBackendId, pollIntervalMs) {
|
|
901
|
+
console.log(`[ConfigRepo] setupSync: ${backends.length} backends, primary=${primaryBackendId} pollInterval=${pollIntervalMs ?? "default"}ms`);
|
|
899
902
|
for (const desc of backends) {
|
|
900
903
|
if (desc.id === primaryBackendId) continue;
|
|
901
904
|
if (desc.enabled === false) {
|
|
@@ -911,7 +914,8 @@ var ConfigRepo = class {
|
|
|
911
914
|
syncable,
|
|
912
915
|
{
|
|
913
916
|
direction: import_zen_fs_sync.SyncDirection.BiDirectional,
|
|
914
|
-
conflictStrategy: "source-wins"
|
|
917
|
+
conflictStrategy: "source-wins",
|
|
918
|
+
pollIntervalMs
|
|
915
919
|
},
|
|
916
920
|
"/"
|
|
917
921
|
);
|
|
@@ -1343,7 +1347,7 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
1343
1347
|
serializer,
|
|
1344
1348
|
options.onConflict
|
|
1345
1349
|
);
|
|
1346
|
-
await repo.setupSync(allBackends, LOCAL_IDB_BACKEND_ID);
|
|
1350
|
+
await repo.setupSync(allBackends, LOCAL_IDB_BACKEND_ID, options.syncPollIntervalMs);
|
|
1347
1351
|
await repo.load();
|
|
1348
1352
|
repo.syncMetaToReplicas().catch((err) => {
|
|
1349
1353
|
console.error("[createConfigRepo] background syncMetaToReplicas failed:", err);
|
package/dist/index.mjs
CHANGED
|
@@ -211,6 +211,9 @@ function backendToSyncableFS(backend, name) {
|
|
|
211
211
|
return backend.exists(path);
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
|
+
if (typeof backend.checkForUpdates === "function") {
|
|
215
|
+
syncable.checkForUpdates = () => backend.checkForUpdates();
|
|
216
|
+
}
|
|
214
217
|
if (name) {
|
|
215
218
|
syncable.backendName = name;
|
|
216
219
|
} else if (backend.backendName) {
|
|
@@ -842,8 +845,8 @@ var ConfigRepo = class {
|
|
|
842
845
|
// -----------------------------------------------------------------------
|
|
843
846
|
// Internal — Setup
|
|
844
847
|
// -----------------------------------------------------------------------
|
|
845
|
-
async setupSync(backends, primaryBackendId) {
|
|
846
|
-
console.log(`[ConfigRepo] setupSync: ${backends.length} backends, primary=${primaryBackendId}`);
|
|
848
|
+
async setupSync(backends, primaryBackendId, pollIntervalMs) {
|
|
849
|
+
console.log(`[ConfigRepo] setupSync: ${backends.length} backends, primary=${primaryBackendId} pollInterval=${pollIntervalMs ?? "default"}ms`);
|
|
847
850
|
for (const desc of backends) {
|
|
848
851
|
if (desc.id === primaryBackendId) continue;
|
|
849
852
|
if (desc.enabled === false) {
|
|
@@ -859,7 +862,8 @@ var ConfigRepo = class {
|
|
|
859
862
|
syncable,
|
|
860
863
|
{
|
|
861
864
|
direction: SyncDirection.BiDirectional,
|
|
862
|
-
conflictStrategy: "source-wins"
|
|
865
|
+
conflictStrategy: "source-wins",
|
|
866
|
+
pollIntervalMs
|
|
863
867
|
},
|
|
864
868
|
"/"
|
|
865
869
|
);
|
|
@@ -1291,7 +1295,7 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
1291
1295
|
serializer,
|
|
1292
1296
|
options.onConflict
|
|
1293
1297
|
);
|
|
1294
|
-
await repo.setupSync(allBackends, LOCAL_IDB_BACKEND_ID);
|
|
1298
|
+
await repo.setupSync(allBackends, LOCAL_IDB_BACKEND_ID, options.syncPollIntervalMs);
|
|
1295
1299
|
await repo.load();
|
|
1296
1300
|
repo.syncMetaToReplicas().catch((err) => {
|
|
1297
1301
|
console.error("[createConfigRepo] background syncMetaToReplicas failed:", err);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zen-fs-config",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "Distributed config management library built on ZenFS, zen-fs-cache, and zen-fs-sync",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
"typescript": "^5.9.3",
|
|
62
62
|
"vitest": "^1.6.1",
|
|
63
63
|
"zen-fs-cache": "^1.0.1",
|
|
64
|
-
"zen-fs-sync": "^0.4.
|
|
64
|
+
"zen-fs-sync": "^0.4.3"
|
|
65
65
|
}
|
|
66
66
|
}
|