zen-fs-config 0.4.4 → 0.4.6
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 +12 -5
- package/dist/index.mjs +12 -5
- 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) {
|
|
@@ -334,7 +337,10 @@ async function wrapZenFSFileSystem(config) {
|
|
|
334
337
|
await isolatedFS.createFile(path, { uid: 0, gid: 0, mode: 420 });
|
|
335
338
|
}
|
|
336
339
|
await isolatedFS.write(path, bytes, 0);
|
|
337
|
-
|
|
340
|
+
try {
|
|
341
|
+
await isolatedFS.touch(path, { size: bytes.byteLength, mtimeMs: Date.now() });
|
|
342
|
+
} catch {
|
|
343
|
+
}
|
|
338
344
|
},
|
|
339
345
|
async readdir(path) {
|
|
340
346
|
return isolatedFS.readdir(path);
|
|
@@ -894,8 +900,8 @@ var ConfigRepo = class {
|
|
|
894
900
|
// -----------------------------------------------------------------------
|
|
895
901
|
// Internal — Setup
|
|
896
902
|
// -----------------------------------------------------------------------
|
|
897
|
-
async setupSync(backends, primaryBackendId) {
|
|
898
|
-
console.log(`[ConfigRepo] setupSync: ${backends.length} backends, primary=${primaryBackendId}`);
|
|
903
|
+
async setupSync(backends, primaryBackendId, pollIntervalMs) {
|
|
904
|
+
console.log(`[ConfigRepo] setupSync: ${backends.length} backends, primary=${primaryBackendId} pollInterval=${pollIntervalMs ?? "default"}ms`);
|
|
899
905
|
for (const desc of backends) {
|
|
900
906
|
if (desc.id === primaryBackendId) continue;
|
|
901
907
|
if (desc.enabled === false) {
|
|
@@ -911,7 +917,8 @@ var ConfigRepo = class {
|
|
|
911
917
|
syncable,
|
|
912
918
|
{
|
|
913
919
|
direction: import_zen_fs_sync.SyncDirection.BiDirectional,
|
|
914
|
-
conflictStrategy: "source-wins"
|
|
920
|
+
conflictStrategy: "source-wins",
|
|
921
|
+
pollIntervalMs
|
|
915
922
|
},
|
|
916
923
|
"/"
|
|
917
924
|
);
|
|
@@ -1343,7 +1350,7 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
1343
1350
|
serializer,
|
|
1344
1351
|
options.onConflict
|
|
1345
1352
|
);
|
|
1346
|
-
await repo.setupSync(allBackends, LOCAL_IDB_BACKEND_ID);
|
|
1353
|
+
await repo.setupSync(allBackends, LOCAL_IDB_BACKEND_ID, options.syncPollIntervalMs);
|
|
1347
1354
|
await repo.load();
|
|
1348
1355
|
repo.syncMetaToReplicas().catch((err) => {
|
|
1349
1356
|
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) {
|
|
@@ -282,7 +285,10 @@ async function wrapZenFSFileSystem(config) {
|
|
|
282
285
|
await isolatedFS.createFile(path, { uid: 0, gid: 0, mode: 420 });
|
|
283
286
|
}
|
|
284
287
|
await isolatedFS.write(path, bytes, 0);
|
|
285
|
-
|
|
288
|
+
try {
|
|
289
|
+
await isolatedFS.touch(path, { size: bytes.byteLength, mtimeMs: Date.now() });
|
|
290
|
+
} catch {
|
|
291
|
+
}
|
|
286
292
|
},
|
|
287
293
|
async readdir(path) {
|
|
288
294
|
return isolatedFS.readdir(path);
|
|
@@ -842,8 +848,8 @@ var ConfigRepo = class {
|
|
|
842
848
|
// -----------------------------------------------------------------------
|
|
843
849
|
// Internal — Setup
|
|
844
850
|
// -----------------------------------------------------------------------
|
|
845
|
-
async setupSync(backends, primaryBackendId) {
|
|
846
|
-
console.log(`[ConfigRepo] setupSync: ${backends.length} backends, primary=${primaryBackendId}`);
|
|
851
|
+
async setupSync(backends, primaryBackendId, pollIntervalMs) {
|
|
852
|
+
console.log(`[ConfigRepo] setupSync: ${backends.length} backends, primary=${primaryBackendId} pollInterval=${pollIntervalMs ?? "default"}ms`);
|
|
847
853
|
for (const desc of backends) {
|
|
848
854
|
if (desc.id === primaryBackendId) continue;
|
|
849
855
|
if (desc.enabled === false) {
|
|
@@ -859,7 +865,8 @@ var ConfigRepo = class {
|
|
|
859
865
|
syncable,
|
|
860
866
|
{
|
|
861
867
|
direction: SyncDirection.BiDirectional,
|
|
862
|
-
conflictStrategy: "source-wins"
|
|
868
|
+
conflictStrategy: "source-wins",
|
|
869
|
+
pollIntervalMs
|
|
863
870
|
},
|
|
864
871
|
"/"
|
|
865
872
|
);
|
|
@@ -1291,7 +1298,7 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
1291
1298
|
serializer,
|
|
1292
1299
|
options.onConflict
|
|
1293
1300
|
);
|
|
1294
|
-
await repo.setupSync(allBackends, LOCAL_IDB_BACKEND_ID);
|
|
1301
|
+
await repo.setupSync(allBackends, LOCAL_IDB_BACKEND_ID, options.syncPollIntervalMs);
|
|
1295
1302
|
await repo.load();
|
|
1296
1303
|
repo.syncMetaToReplicas().catch((err) => {
|
|
1297
1304
|
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.6",
|
|
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
|
}
|