zen-fs-config 0.3.3 → 0.3.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.js CHANGED
@@ -1061,20 +1061,35 @@ var ConfigRepo = class {
1061
1061
  // Internal — Setup
1062
1062
  // -----------------------------------------------------------------------
1063
1063
  async setupSync(rules, backends, primaryBackendId) {
1064
+ console.log(`[ConfigRepo] setupSync: ${backends.length} backends, primary=${primaryBackendId}`);
1065
+ console.log(`[ConfigRepo] setupSync: rules=`, JSON.stringify(rules, null, 2));
1064
1066
  for (const desc of backends) {
1065
1067
  if (desc.id === primaryBackendId) continue;
1066
- const instance = await createBackend(desc);
1067
- const syncable = backendToSyncableFS(instance);
1068
- this.replicaBackends.set(desc.id, { instance, syncable });
1068
+ console.log(`[ConfigRepo] Creating replica backend: id=${desc.id}, type=${desc.type}`);
1069
+ try {
1070
+ const instance = await createBackend(desc);
1071
+ const syncable = backendToSyncableFS(instance);
1072
+ this.replicaBackends.set(desc.id, { instance, syncable });
1073
+ console.log(`[ConfigRepo] Replica ${desc.id} created successfully`);
1074
+ } catch (err) {
1075
+ console.error(`[ConfigRepo] Failed to create replica ${desc.id} (${desc.type}):`, err);
1076
+ }
1069
1077
  }
1078
+ console.log(`[ConfigRepo] Available replicas:`, Array.from(this.replicaBackends.keys()));
1070
1079
  for (const rule of rules) {
1071
1080
  if (rule.direction === "none") continue;
1072
- if (!rule.replicas?.length) continue;
1081
+ if (!rule.replicas?.length) {
1082
+ console.log(`[ConfigRepo] Skipping rule ${rule.prefix}: no replicas`);
1083
+ continue;
1084
+ }
1073
1085
  const zenSyncDirection = rule.direction === "bi-directional" ? import_zen_fs_sync.SyncDirection.BiDirectional : import_zen_fs_sync.SyncDirection.OneWay;
1074
1086
  for (const replicaId of rule.replicas) {
1075
1087
  if (replicaId === primaryBackendId) continue;
1076
1088
  const replica = this.replicaBackends.get(replicaId);
1077
- if (!replica) continue;
1089
+ if (!replica) {
1090
+ console.warn(`[ConfigRepo] Skipping pair ${replicaId}: replica not found (available: ${Array.from(this.replicaBackends.keys()).join(", ")})`);
1091
+ continue;
1092
+ }
1078
1093
  const pair = this.syncEngine.addPair(
1079
1094
  this.fullFS,
1080
1095
  replica.syncable,
@@ -1087,6 +1102,7 @@ var ConfigRepo = class {
1087
1102
  },
1088
1103
  "/"
1089
1104
  );
1105
+ console.log(`[ConfigRepo] Sync pair added: pairId=${pair.pairId}, prefix=${rule.prefix}, dir=${rule.direction}, replica=${replicaId}`);
1090
1106
  const conflictHandler = (event) => {
1091
1107
  this.handleConflict(event, rule);
1092
1108
  };
@@ -1094,6 +1110,7 @@ var ConfigRepo = class {
1094
1110
  this.syncEngine.watch(pair.pairId);
1095
1111
  }
1096
1112
  }
1113
+ console.log(`[ConfigRepo] setupSync complete. Sync statuses:`, this.getSyncStatuses());
1097
1114
  }
1098
1115
  // -----------------------------------------------------------------------
1099
1116
  // Internal — Persistence
@@ -1294,11 +1311,12 @@ async function createConfigRepo(appId, options) {
1294
1311
  void 0
1295
1312
  );
1296
1313
  let backendsMeta = await tempRepo.readMetaFile(BACKENDS_FILE);
1297
- if (!backendsMeta && options.bootstrap) {
1314
+ if (options.bootstrap) {
1298
1315
  backendsMeta = {
1299
1316
  version: 1,
1300
1317
  backends: options.bootstrap.backends
1301
1318
  };
1319
+ console.log(`[createConfigRepo] Using bootstrap backends: ${backendsMeta.backends.map((b) => b.id).join(", ")}`);
1302
1320
  }
1303
1321
  if (!backendsMeta) {
1304
1322
  backendsMeta = {
@@ -1324,11 +1342,12 @@ async function createConfigRepo(appId, options) {
1324
1342
  }
1325
1343
  await tempRepo.writeMetaFile(BACKENDS_FILE, backendsMeta);
1326
1344
  let syncRulesMeta = await tempRepo.readMetaFile(SYNC_RULES_FILE);
1327
- if (!syncRulesMeta && options.bootstrap) {
1345
+ if (options.bootstrap) {
1328
1346
  syncRulesMeta = {
1329
1347
  version: 1,
1330
1348
  rules: options.bootstrap.syncRules
1331
1349
  };
1350
+ console.log(`[createConfigRepo] Using bootstrap syncRules: ${syncRulesMeta.rules.length} rules`);
1332
1351
  }
1333
1352
  if (!syncRulesMeta) {
1334
1353
  syncRulesMeta = {
package/dist/index.mjs CHANGED
@@ -1014,20 +1014,35 @@ var ConfigRepo = class {
1014
1014
  // Internal — Setup
1015
1015
  // -----------------------------------------------------------------------
1016
1016
  async setupSync(rules, backends, primaryBackendId) {
1017
+ console.log(`[ConfigRepo] setupSync: ${backends.length} backends, primary=${primaryBackendId}`);
1018
+ console.log(`[ConfigRepo] setupSync: rules=`, JSON.stringify(rules, null, 2));
1017
1019
  for (const desc of backends) {
1018
1020
  if (desc.id === primaryBackendId) continue;
1019
- const instance = await createBackend(desc);
1020
- const syncable = backendToSyncableFS(instance);
1021
- this.replicaBackends.set(desc.id, { instance, syncable });
1021
+ console.log(`[ConfigRepo] Creating replica backend: id=${desc.id}, type=${desc.type}`);
1022
+ try {
1023
+ const instance = await createBackend(desc);
1024
+ const syncable = backendToSyncableFS(instance);
1025
+ this.replicaBackends.set(desc.id, { instance, syncable });
1026
+ console.log(`[ConfigRepo] Replica ${desc.id} created successfully`);
1027
+ } catch (err) {
1028
+ console.error(`[ConfigRepo] Failed to create replica ${desc.id} (${desc.type}):`, err);
1029
+ }
1022
1030
  }
1031
+ console.log(`[ConfigRepo] Available replicas:`, Array.from(this.replicaBackends.keys()));
1023
1032
  for (const rule of rules) {
1024
1033
  if (rule.direction === "none") continue;
1025
- if (!rule.replicas?.length) continue;
1034
+ if (!rule.replicas?.length) {
1035
+ console.log(`[ConfigRepo] Skipping rule ${rule.prefix}: no replicas`);
1036
+ continue;
1037
+ }
1026
1038
  const zenSyncDirection = rule.direction === "bi-directional" ? SyncDirection.BiDirectional : SyncDirection.OneWay;
1027
1039
  for (const replicaId of rule.replicas) {
1028
1040
  if (replicaId === primaryBackendId) continue;
1029
1041
  const replica = this.replicaBackends.get(replicaId);
1030
- if (!replica) continue;
1042
+ if (!replica) {
1043
+ console.warn(`[ConfigRepo] Skipping pair ${replicaId}: replica not found (available: ${Array.from(this.replicaBackends.keys()).join(", ")})`);
1044
+ continue;
1045
+ }
1031
1046
  const pair = this.syncEngine.addPair(
1032
1047
  this.fullFS,
1033
1048
  replica.syncable,
@@ -1040,6 +1055,7 @@ var ConfigRepo = class {
1040
1055
  },
1041
1056
  "/"
1042
1057
  );
1058
+ console.log(`[ConfigRepo] Sync pair added: pairId=${pair.pairId}, prefix=${rule.prefix}, dir=${rule.direction}, replica=${replicaId}`);
1043
1059
  const conflictHandler = (event) => {
1044
1060
  this.handleConflict(event, rule);
1045
1061
  };
@@ -1047,6 +1063,7 @@ var ConfigRepo = class {
1047
1063
  this.syncEngine.watch(pair.pairId);
1048
1064
  }
1049
1065
  }
1066
+ console.log(`[ConfigRepo] setupSync complete. Sync statuses:`, this.getSyncStatuses());
1050
1067
  }
1051
1068
  // -----------------------------------------------------------------------
1052
1069
  // Internal — Persistence
@@ -1247,11 +1264,12 @@ async function createConfigRepo(appId, options) {
1247
1264
  void 0
1248
1265
  );
1249
1266
  let backendsMeta = await tempRepo.readMetaFile(BACKENDS_FILE);
1250
- if (!backendsMeta && options.bootstrap) {
1267
+ if (options.bootstrap) {
1251
1268
  backendsMeta = {
1252
1269
  version: 1,
1253
1270
  backends: options.bootstrap.backends
1254
1271
  };
1272
+ console.log(`[createConfigRepo] Using bootstrap backends: ${backendsMeta.backends.map((b) => b.id).join(", ")}`);
1255
1273
  }
1256
1274
  if (!backendsMeta) {
1257
1275
  backendsMeta = {
@@ -1277,11 +1295,12 @@ async function createConfigRepo(appId, options) {
1277
1295
  }
1278
1296
  await tempRepo.writeMetaFile(BACKENDS_FILE, backendsMeta);
1279
1297
  let syncRulesMeta = await tempRepo.readMetaFile(SYNC_RULES_FILE);
1280
- if (!syncRulesMeta && options.bootstrap) {
1298
+ if (options.bootstrap) {
1281
1299
  syncRulesMeta = {
1282
1300
  version: 1,
1283
1301
  rules: options.bootstrap.syncRules
1284
1302
  };
1303
+ console.log(`[createConfigRepo] Using bootstrap syncRules: ${syncRulesMeta.rules.length} rules`);
1285
1304
  }
1286
1305
  if (!syncRulesMeta) {
1287
1306
  syncRulesMeta = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-fs-config",
3
- "version": "0.3.3",
3
+ "version": "0.3.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",