zen-fs-config 0.3.3 → 0.3.4

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
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
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.4",
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",