zen-fs-config 0.3.24 → 0.3.25
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -7
- package/dist/index.mjs +19 -7
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -222,7 +222,7 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
222
222
|
private onConflictCallback?;
|
|
223
223
|
private disposed;
|
|
224
224
|
private configCache;
|
|
225
|
-
constructor(appId: string, nodeId: string, cachedFS: MinimalAsyncFS, serializer: PathAwareSerializer, onConflict?: (conflict: ConflictInfo) => Promise<unknown | null>);
|
|
225
|
+
constructor(appId: string, nodeId: string, primaryBackendId: string, cachedFS: MinimalAsyncFS, serializer: PathAwareSerializer, onConflict?: (conflict: ConflictInfo) => Promise<unknown | null>);
|
|
226
226
|
/** Full path to this node's directory on the primary backend. */
|
|
227
227
|
get nodePath(): string;
|
|
228
228
|
load(rawConfig?: string): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -222,7 +222,7 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
222
222
|
private onConflictCallback?;
|
|
223
223
|
private disposed;
|
|
224
224
|
private configCache;
|
|
225
|
-
constructor(appId: string, nodeId: string, cachedFS: MinimalAsyncFS, serializer: PathAwareSerializer, onConflict?: (conflict: ConflictInfo) => Promise<unknown | null>);
|
|
225
|
+
constructor(appId: string, nodeId: string, primaryBackendId: string, cachedFS: MinimalAsyncFS, serializer: PathAwareSerializer, onConflict?: (conflict: ConflictInfo) => Promise<unknown | null>);
|
|
226
226
|
/** Full path to this node's directory on the primary backend. */
|
|
227
227
|
get nodePath(): string;
|
|
228
228
|
load(rawConfig?: string): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -225,8 +225,8 @@ async function ensureParentDir(absolutePath) {
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
// src/adapters.ts
|
|
228
|
-
function backendToSyncableFS(backend) {
|
|
229
|
-
|
|
228
|
+
function backendToSyncableFS(backend, name) {
|
|
229
|
+
const syncable = {
|
|
230
230
|
async readdir(path) {
|
|
231
231
|
return backend.readdir(path);
|
|
232
232
|
},
|
|
@@ -265,9 +265,17 @@ function backendToSyncableFS(backend) {
|
|
|
265
265
|
return backend.exists(path);
|
|
266
266
|
}
|
|
267
267
|
};
|
|
268
|
+
if (name) {
|
|
269
|
+
syncable.backendName = name;
|
|
270
|
+
} else if (backend.backendName) {
|
|
271
|
+
syncable.backendName = backend.backendName;
|
|
272
|
+
} else {
|
|
273
|
+
syncable.backendName = backend.constructor.name || "Backend";
|
|
274
|
+
}
|
|
275
|
+
return syncable;
|
|
268
276
|
}
|
|
269
|
-
function cachedFSToSyncableFS(cached) {
|
|
270
|
-
|
|
277
|
+
function cachedFSToSyncableFS(cached, name) {
|
|
278
|
+
const syncable = {
|
|
271
279
|
async readdir(path) {
|
|
272
280
|
return cached.readdir(path);
|
|
273
281
|
},
|
|
@@ -306,6 +314,8 @@ function cachedFSToSyncableFS(cached) {
|
|
|
306
314
|
return cached.exists(path);
|
|
307
315
|
}
|
|
308
316
|
};
|
|
317
|
+
syncable.backendName = name || "CachedFS";
|
|
318
|
+
return syncable;
|
|
309
319
|
}
|
|
310
320
|
|
|
311
321
|
// src/backend-registry.ts
|
|
@@ -502,7 +512,7 @@ var ConfigRepo = class {
|
|
|
502
512
|
onConflictCallback;
|
|
503
513
|
disposed = false;
|
|
504
514
|
configCache = /* @__PURE__ */ new Map();
|
|
505
|
-
constructor(appId, nodeId, cachedFS, serializer, onConflict) {
|
|
515
|
+
constructor(appId, nodeId, primaryBackendId, cachedFS, serializer, onConflict) {
|
|
506
516
|
this.appId = appId;
|
|
507
517
|
this.nodeId = nodeId;
|
|
508
518
|
this.cachedFS = cachedFS;
|
|
@@ -510,7 +520,7 @@ var ConfigRepo = class {
|
|
|
510
520
|
this.syncEngine = new import_zen_fs_sync.ZenFSSync();
|
|
511
521
|
this.replicaBackends = /* @__PURE__ */ new Map();
|
|
512
522
|
this.onConflictCallback = onConflict;
|
|
513
|
-
this.fullFS = cachedFSToSyncableFS(cachedFS);
|
|
523
|
+
this.fullFS = cachedFSToSyncableFS(cachedFS, `CachedFS(${primaryBackendId})`);
|
|
514
524
|
this.fs = createChrootFS(cachedFS, `/${appId}`);
|
|
515
525
|
this.rootFS = createChrootFS(cachedFS, "/");
|
|
516
526
|
}
|
|
@@ -769,7 +779,7 @@ var ConfigRepo = class {
|
|
|
769
779
|
console.log(`[ConfigRepo] Creating replica backend: id=${desc.id}, type=${desc.type}`);
|
|
770
780
|
try {
|
|
771
781
|
const instance = await createBackend(desc);
|
|
772
|
-
const syncable = backendToSyncableFS(instance);
|
|
782
|
+
const syncable = backendToSyncableFS(instance, `${desc.type}(${desc.id})`);
|
|
773
783
|
this.replicaBackends.set(desc.id, { instance, syncable });
|
|
774
784
|
console.log(`[ConfigRepo] Replica ${desc.id} created successfully`);
|
|
775
785
|
} catch (err) {
|
|
@@ -1015,6 +1025,7 @@ async function createConfigRepo(appId, options) {
|
|
|
1015
1025
|
const tempRepo = new ConfigRepo(
|
|
1016
1026
|
appId,
|
|
1017
1027
|
"",
|
|
1028
|
+
options.primaryBackendId,
|
|
1018
1029
|
cachedFS,
|
|
1019
1030
|
createSerializerChain(),
|
|
1020
1031
|
void 0
|
|
@@ -1071,6 +1082,7 @@ async function createConfigRepo(appId, options) {
|
|
|
1071
1082
|
const repo = new ConfigRepo(
|
|
1072
1083
|
appId,
|
|
1073
1084
|
nodeId,
|
|
1085
|
+
options.primaryBackendId,
|
|
1074
1086
|
cachedFS,
|
|
1075
1087
|
serializer,
|
|
1076
1088
|
options.onConflict
|
package/dist/index.mjs
CHANGED
|
@@ -176,8 +176,8 @@ async function ensureParentDir(absolutePath) {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
// src/adapters.ts
|
|
179
|
-
function backendToSyncableFS(backend) {
|
|
180
|
-
|
|
179
|
+
function backendToSyncableFS(backend, name) {
|
|
180
|
+
const syncable = {
|
|
181
181
|
async readdir(path) {
|
|
182
182
|
return backend.readdir(path);
|
|
183
183
|
},
|
|
@@ -216,9 +216,17 @@ function backendToSyncableFS(backend) {
|
|
|
216
216
|
return backend.exists(path);
|
|
217
217
|
}
|
|
218
218
|
};
|
|
219
|
+
if (name) {
|
|
220
|
+
syncable.backendName = name;
|
|
221
|
+
} else if (backend.backendName) {
|
|
222
|
+
syncable.backendName = backend.backendName;
|
|
223
|
+
} else {
|
|
224
|
+
syncable.backendName = backend.constructor.name || "Backend";
|
|
225
|
+
}
|
|
226
|
+
return syncable;
|
|
219
227
|
}
|
|
220
|
-
function cachedFSToSyncableFS(cached) {
|
|
221
|
-
|
|
228
|
+
function cachedFSToSyncableFS(cached, name) {
|
|
229
|
+
const syncable = {
|
|
222
230
|
async readdir(path) {
|
|
223
231
|
return cached.readdir(path);
|
|
224
232
|
},
|
|
@@ -257,6 +265,8 @@ function cachedFSToSyncableFS(cached) {
|
|
|
257
265
|
return cached.exists(path);
|
|
258
266
|
}
|
|
259
267
|
};
|
|
268
|
+
syncable.backendName = name || "CachedFS";
|
|
269
|
+
return syncable;
|
|
260
270
|
}
|
|
261
271
|
|
|
262
272
|
// src/backend-registry.ts
|
|
@@ -453,7 +463,7 @@ var ConfigRepo = class {
|
|
|
453
463
|
onConflictCallback;
|
|
454
464
|
disposed = false;
|
|
455
465
|
configCache = /* @__PURE__ */ new Map();
|
|
456
|
-
constructor(appId, nodeId, cachedFS, serializer, onConflict) {
|
|
466
|
+
constructor(appId, nodeId, primaryBackendId, cachedFS, serializer, onConflict) {
|
|
457
467
|
this.appId = appId;
|
|
458
468
|
this.nodeId = nodeId;
|
|
459
469
|
this.cachedFS = cachedFS;
|
|
@@ -461,7 +471,7 @@ var ConfigRepo = class {
|
|
|
461
471
|
this.syncEngine = new ZenFSSync();
|
|
462
472
|
this.replicaBackends = /* @__PURE__ */ new Map();
|
|
463
473
|
this.onConflictCallback = onConflict;
|
|
464
|
-
this.fullFS = cachedFSToSyncableFS(cachedFS);
|
|
474
|
+
this.fullFS = cachedFSToSyncableFS(cachedFS, `CachedFS(${primaryBackendId})`);
|
|
465
475
|
this.fs = createChrootFS(cachedFS, `/${appId}`);
|
|
466
476
|
this.rootFS = createChrootFS(cachedFS, "/");
|
|
467
477
|
}
|
|
@@ -720,7 +730,7 @@ var ConfigRepo = class {
|
|
|
720
730
|
console.log(`[ConfigRepo] Creating replica backend: id=${desc.id}, type=${desc.type}`);
|
|
721
731
|
try {
|
|
722
732
|
const instance = await createBackend(desc);
|
|
723
|
-
const syncable = backendToSyncableFS(instance);
|
|
733
|
+
const syncable = backendToSyncableFS(instance, `${desc.type}(${desc.id})`);
|
|
724
734
|
this.replicaBackends.set(desc.id, { instance, syncable });
|
|
725
735
|
console.log(`[ConfigRepo] Replica ${desc.id} created successfully`);
|
|
726
736
|
} catch (err) {
|
|
@@ -966,6 +976,7 @@ async function createConfigRepo(appId, options) {
|
|
|
966
976
|
const tempRepo = new ConfigRepo(
|
|
967
977
|
appId,
|
|
968
978
|
"",
|
|
979
|
+
options.primaryBackendId,
|
|
969
980
|
cachedFS,
|
|
970
981
|
createSerializerChain(),
|
|
971
982
|
void 0
|
|
@@ -1022,6 +1033,7 @@ async function createConfigRepo(appId, options) {
|
|
|
1022
1033
|
const repo = new ConfigRepo(
|
|
1023
1034
|
appId,
|
|
1024
1035
|
nodeId,
|
|
1036
|
+
options.primaryBackendId,
|
|
1025
1037
|
cachedFS,
|
|
1026
1038
|
serializer,
|
|
1027
1039
|
options.onConflict
|