zen-fs-config 0.3.5 → 0.3.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.js CHANGED
@@ -1311,24 +1311,27 @@ async function createConfigRepo(appId, options) {
1311
1311
  void 0
1312
1312
  );
1313
1313
  let backendsMeta = await tempRepo.readMetaFile(BACKENDS_FILE);
1314
- if (options.bootstrap) {
1315
- backendsMeta = {
1316
- version: 1,
1317
- backends: options.bootstrap.backends
1318
- };
1319
- console.log(`[createConfigRepo] Using bootstrap backends: ${backendsMeta.backends.map((b) => b.id).join(", ")}`);
1320
- }
1321
1314
  if (!backendsMeta) {
1322
- backendsMeta = {
1323
- version: 1,
1324
- backends: [
1325
- {
1326
- id: options.primaryBackendId,
1327
- type: options.backendInfo.type,
1328
- options: options.backendInfo.options
1329
- }
1330
- ]
1331
- };
1315
+ if (options.bootstrap) {
1316
+ backendsMeta = {
1317
+ version: 1,
1318
+ backends: options.bootstrap.backends
1319
+ };
1320
+ console.log(`[createConfigRepo] First init: using bootstrap backends: ${backendsMeta.backends.map((b) => b.id).join(", ")}`);
1321
+ } else {
1322
+ backendsMeta = {
1323
+ version: 1,
1324
+ backends: [
1325
+ {
1326
+ id: options.primaryBackendId,
1327
+ type: options.backendInfo.type,
1328
+ options: options.backendInfo.options
1329
+ }
1330
+ ]
1331
+ };
1332
+ }
1333
+ } else {
1334
+ console.log(`[createConfigRepo] Reconnect: using stored backends: ${backendsMeta.backends.map((b) => b.id).join(", ")}`);
1332
1335
  }
1333
1336
  const hasPrimary = backendsMeta.backends.some(
1334
1337
  (b) => b.id === options.primaryBackendId
@@ -1342,33 +1345,37 @@ async function createConfigRepo(appId, options) {
1342
1345
  }
1343
1346
  await tempRepo.writeMetaFile(BACKENDS_FILE, backendsMeta);
1344
1347
  let syncRulesMeta = await tempRepo.readMetaFile(SYNC_RULES_FILE);
1345
- if (options.bootstrap) {
1346
- syncRulesMeta = {
1347
- version: 1,
1348
- rules: options.bootstrap.syncRules
1349
- };
1350
- console.log(`[createConfigRepo] Using bootstrap syncRules: ${syncRulesMeta.rules.length} rules`);
1351
- }
1352
1348
  if (!syncRulesMeta) {
1353
- syncRulesMeta = {
1354
- version: 1,
1355
- rules: [
1356
- {
1357
- prefix: `/${appId}/`,
1358
- direction: "one-way",
1359
- conflictStrategy: "source-wins",
1360
- replicas: backendsMeta.backends.map((b) => b.id)
1361
- },
1362
- {
1363
- prefix: `${SHARED_DIR}/`,
1364
- direction: "bi-directional",
1365
- conflictStrategy: "merge",
1366
- replicas: backendsMeta.backends.map((b) => b.id)
1367
- },
1368
- { prefix: `${NODES_DIR}/`, direction: "none" },
1369
- { prefix: `${META_DIR}/`, direction: "none" }
1370
- ]
1371
- };
1349
+ if (options.bootstrap) {
1350
+ syncRulesMeta = {
1351
+ version: 1,
1352
+ rules: options.bootstrap.syncRules
1353
+ };
1354
+ console.log(`[createConfigRepo] First init: using bootstrap syncRules: ${syncRulesMeta.rules.length} rules`);
1355
+ } else {
1356
+ syncRulesMeta = {
1357
+ version: 1,
1358
+ rules: [
1359
+ {
1360
+ prefix: `/${appId}/`,
1361
+ direction: "one-way",
1362
+ conflictStrategy: "source-wins",
1363
+ replicas: backendsMeta.backends.map((b) => b.id)
1364
+ },
1365
+ {
1366
+ prefix: `${SHARED_DIR}/`,
1367
+ direction: "bi-directional",
1368
+ conflictStrategy: "merge",
1369
+ replicas: backendsMeta.backends.map((b) => b.id)
1370
+ },
1371
+ { prefix: `${NODES_DIR}/`, direction: "none" },
1372
+ { prefix: `${META_DIR}/`, direction: "none" }
1373
+ ]
1374
+ };
1375
+ }
1376
+ }
1377
+ if (syncRulesMeta) {
1378
+ console.log(`[createConfigRepo] Reconnect: using stored syncRules: ${syncRulesMeta.rules.length} rules`);
1372
1379
  }
1373
1380
  await tempRepo.writeMetaFile(SYNC_RULES_FILE, syncRulesMeta);
1374
1381
  let nodeId = options.nodeId;
package/dist/index.mjs CHANGED
@@ -1264,24 +1264,27 @@ async function createConfigRepo(appId, options) {
1264
1264
  void 0
1265
1265
  );
1266
1266
  let backendsMeta = await tempRepo.readMetaFile(BACKENDS_FILE);
1267
- if (options.bootstrap) {
1268
- backendsMeta = {
1269
- version: 1,
1270
- backends: options.bootstrap.backends
1271
- };
1272
- console.log(`[createConfigRepo] Using bootstrap backends: ${backendsMeta.backends.map((b) => b.id).join(", ")}`);
1273
- }
1274
1267
  if (!backendsMeta) {
1275
- backendsMeta = {
1276
- version: 1,
1277
- backends: [
1278
- {
1279
- id: options.primaryBackendId,
1280
- type: options.backendInfo.type,
1281
- options: options.backendInfo.options
1282
- }
1283
- ]
1284
- };
1268
+ if (options.bootstrap) {
1269
+ backendsMeta = {
1270
+ version: 1,
1271
+ backends: options.bootstrap.backends
1272
+ };
1273
+ console.log(`[createConfigRepo] First init: using bootstrap backends: ${backendsMeta.backends.map((b) => b.id).join(", ")}`);
1274
+ } else {
1275
+ backendsMeta = {
1276
+ version: 1,
1277
+ backends: [
1278
+ {
1279
+ id: options.primaryBackendId,
1280
+ type: options.backendInfo.type,
1281
+ options: options.backendInfo.options
1282
+ }
1283
+ ]
1284
+ };
1285
+ }
1286
+ } else {
1287
+ console.log(`[createConfigRepo] Reconnect: using stored backends: ${backendsMeta.backends.map((b) => b.id).join(", ")}`);
1285
1288
  }
1286
1289
  const hasPrimary = backendsMeta.backends.some(
1287
1290
  (b) => b.id === options.primaryBackendId
@@ -1295,33 +1298,37 @@ async function createConfigRepo(appId, options) {
1295
1298
  }
1296
1299
  await tempRepo.writeMetaFile(BACKENDS_FILE, backendsMeta);
1297
1300
  let syncRulesMeta = await tempRepo.readMetaFile(SYNC_RULES_FILE);
1298
- if (options.bootstrap) {
1299
- syncRulesMeta = {
1300
- version: 1,
1301
- rules: options.bootstrap.syncRules
1302
- };
1303
- console.log(`[createConfigRepo] Using bootstrap syncRules: ${syncRulesMeta.rules.length} rules`);
1304
- }
1305
1301
  if (!syncRulesMeta) {
1306
- syncRulesMeta = {
1307
- version: 1,
1308
- rules: [
1309
- {
1310
- prefix: `/${appId}/`,
1311
- direction: "one-way",
1312
- conflictStrategy: "source-wins",
1313
- replicas: backendsMeta.backends.map((b) => b.id)
1314
- },
1315
- {
1316
- prefix: `${SHARED_DIR}/`,
1317
- direction: "bi-directional",
1318
- conflictStrategy: "merge",
1319
- replicas: backendsMeta.backends.map((b) => b.id)
1320
- },
1321
- { prefix: `${NODES_DIR}/`, direction: "none" },
1322
- { prefix: `${META_DIR}/`, direction: "none" }
1323
- ]
1324
- };
1302
+ if (options.bootstrap) {
1303
+ syncRulesMeta = {
1304
+ version: 1,
1305
+ rules: options.bootstrap.syncRules
1306
+ };
1307
+ console.log(`[createConfigRepo] First init: using bootstrap syncRules: ${syncRulesMeta.rules.length} rules`);
1308
+ } else {
1309
+ syncRulesMeta = {
1310
+ version: 1,
1311
+ rules: [
1312
+ {
1313
+ prefix: `/${appId}/`,
1314
+ direction: "one-way",
1315
+ conflictStrategy: "source-wins",
1316
+ replicas: backendsMeta.backends.map((b) => b.id)
1317
+ },
1318
+ {
1319
+ prefix: `${SHARED_DIR}/`,
1320
+ direction: "bi-directional",
1321
+ conflictStrategy: "merge",
1322
+ replicas: backendsMeta.backends.map((b) => b.id)
1323
+ },
1324
+ { prefix: `${NODES_DIR}/`, direction: "none" },
1325
+ { prefix: `${META_DIR}/`, direction: "none" }
1326
+ ]
1327
+ };
1328
+ }
1329
+ }
1330
+ if (syncRulesMeta) {
1331
+ console.log(`[createConfigRepo] Reconnect: using stored syncRules: ${syncRulesMeta.rules.length} rules`);
1325
1332
  }
1326
1333
  await tempRepo.writeMetaFile(SYNC_RULES_FILE, syncRulesMeta);
1327
1334
  let nodeId = options.nodeId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-fs-config",
3
- "version": "0.3.5",
3
+ "version": "0.3.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",