zen-fs-config 0.11.4 → 0.11.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.d.mts CHANGED
@@ -179,6 +179,16 @@ interface TombstoneMeta {
179
179
  confirmedBy: string[];
180
180
  /** 目标类型;缺省视为 `file`(旧版本墓碑没有该字段)。 */
181
181
  type?: TombstoneType;
182
+ /**
183
+ * 人工作废标记:**只能由用户手改墓碑文件**置为 `true`。
184
+ *
185
+ * 为 `true` 时整条墓碑被忽略 —— 不删目标路径、不参与 GC、不进入同步排除表,
186
+ * 也不会被任何自动写入路径改写(`readTombstonesFromFs` 直接把它过滤掉,所有
187
+ * 依赖墓碑列表的逻辑都看不到它)。改回 `false` / 删掉该键即恢复。
188
+ *
189
+ * 只对目录墓碑(`type: "directory"`)生效;文件墓碑上的该字段被忽略。
190
+ */
191
+ obsolete?: boolean;
182
192
  }
183
193
  /** Content of a conflict archive file in `.meta/.conflicts/`. */
184
194
  interface ConflictArchive {
package/dist/index.d.ts CHANGED
@@ -179,6 +179,16 @@ interface TombstoneMeta {
179
179
  confirmedBy: string[];
180
180
  /** 目标类型;缺省视为 `file`(旧版本墓碑没有该字段)。 */
181
181
  type?: TombstoneType;
182
+ /**
183
+ * 人工作废标记:**只能由用户手改墓碑文件**置为 `true`。
184
+ *
185
+ * 为 `true` 时整条墓碑被忽略 —— 不删目标路径、不参与 GC、不进入同步排除表,
186
+ * 也不会被任何自动写入路径改写(`readTombstonesFromFs` 直接把它过滤掉,所有
187
+ * 依赖墓碑列表的逻辑都看不到它)。改回 `false` / 删掉该键即恢复。
188
+ *
189
+ * 只对目录墓碑(`type: "directory"`)生效;文件墓碑上的该字段被忽略。
190
+ */
191
+ obsolete?: boolean;
182
192
  }
183
193
  /** Content of a conflict archive file in `.meta/.conflicts/`. */
184
194
  interface ConflictArchive {
package/dist/index.js CHANGED
@@ -2136,8 +2136,12 @@ function serializeTombstone(tombstone) {
2136
2136
  confirmedBy: tombstone.confirmedBy
2137
2137
  };
2138
2138
  if (tombstone.type) ordered.type = tombstone.type;
2139
+ if (isObsoleteTombstone(tombstone)) ordered.obsolete = true;
2139
2140
  return JSON.stringify(ordered, null, 2);
2140
2141
  }
2142
+ function isObsoleteTombstone(tombstone) {
2143
+ return tombstone.obsolete === true && tombstone.type === "directory";
2144
+ }
2141
2145
  async function purgeTombstonedTree(fs, targetPath) {
2142
2146
  let isDir2 = false;
2143
2147
  try {
@@ -2310,12 +2314,14 @@ function normalizeTombstoneRecord(value, fallbackPath) {
2310
2314
  const path = normalizeTombstonePath(rawPath);
2311
2315
  const confirmedBy = Array.isArray(record.confirmedBy) ? record.confirmedBy.filter((id) => typeof id === "string") : [];
2312
2316
  const type = record.type === "directory" ? "directory" : record.type === "file" ? "file" : void 0;
2317
+ const obsolete = record.obsolete === true && type === "directory";
2313
2318
  return {
2314
2319
  path,
2315
2320
  deletedAt: typeof record.deletedAt === "number" ? record.deletedAt : 0,
2316
2321
  deletedBy: typeof record.deletedBy === "string" ? record.deletedBy : "unknown",
2317
2322
  confirmedBy,
2318
- ...type ? { type } : {}
2323
+ ...type ? { type } : {},
2324
+ ...obsolete ? { obsolete: true } : {}
2319
2325
  };
2320
2326
  }
2321
2327
  function normalizeTombstonePath(rawPath) {
@@ -2403,6 +2409,7 @@ function mergeTombstone(byPath, tombstone) {
2403
2409
  if (!prev.confirmedBy.includes(id)) prev.confirmedBy.push(id);
2404
2410
  }
2405
2411
  if (isDirectoryTombstone(tombstone) && !isDirectoryTombstone(prev)) prev.type = "directory";
2412
+ if (isObsoleteTombstone(tombstone) && prev.type === "directory") prev.obsolete = true;
2406
2413
  }
2407
2414
  async function readTombstonesFromFs(fs, warn) {
2408
2415
  const byPath = /* @__PURE__ */ new Map();
@@ -2434,7 +2441,17 @@ async function readTombstonesFromFs(fs, warn) {
2434
2441
  for (const tombstone of tombstones) mergeTombstone(byPath, tombstone);
2435
2442
  }
2436
2443
  }
2437
- return Array.from(byPath.values());
2444
+ const active = [];
2445
+ for (const tombstone of byPath.values()) {
2446
+ if (isObsoleteTombstone(tombstone)) {
2447
+ log3.log(
2448
+ `[Tombstones] "${tombstone.path}" ignored \u2014 obsolete=true (marked by user)`
2449
+ );
2450
+ continue;
2451
+ }
2452
+ active.push(tombstone);
2453
+ }
2454
+ return active;
2438
2455
  }
2439
2456
  async function readGroupDescriptor(fs) {
2440
2457
  const parsed = await readJson(fs, GROUP_DESCRIPTOR_FILE2);
package/dist/index.mjs CHANGED
@@ -1033,8 +1033,12 @@ function serializeTombstone(tombstone) {
1033
1033
  confirmedBy: tombstone.confirmedBy
1034
1034
  };
1035
1035
  if (tombstone.type) ordered.type = tombstone.type;
1036
+ if (isObsoleteTombstone(tombstone)) ordered.obsolete = true;
1036
1037
  return JSON.stringify(ordered, null, 2);
1037
1038
  }
1039
+ function isObsoleteTombstone(tombstone) {
1040
+ return tombstone.obsolete === true && tombstone.type === "directory";
1041
+ }
1038
1042
  async function purgeTombstonedTree(fs, targetPath) {
1039
1043
  let isDir2 = false;
1040
1044
  try {
@@ -1207,12 +1211,14 @@ function normalizeTombstoneRecord(value, fallbackPath) {
1207
1211
  const path = normalizeTombstonePath(rawPath);
1208
1212
  const confirmedBy = Array.isArray(record.confirmedBy) ? record.confirmedBy.filter((id) => typeof id === "string") : [];
1209
1213
  const type = record.type === "directory" ? "directory" : record.type === "file" ? "file" : void 0;
1214
+ const obsolete = record.obsolete === true && type === "directory";
1210
1215
  return {
1211
1216
  path,
1212
1217
  deletedAt: typeof record.deletedAt === "number" ? record.deletedAt : 0,
1213
1218
  deletedBy: typeof record.deletedBy === "string" ? record.deletedBy : "unknown",
1214
1219
  confirmedBy,
1215
- ...type ? { type } : {}
1220
+ ...type ? { type } : {},
1221
+ ...obsolete ? { obsolete: true } : {}
1216
1222
  };
1217
1223
  }
1218
1224
  function normalizeTombstonePath(rawPath) {
@@ -1300,6 +1306,7 @@ function mergeTombstone(byPath, tombstone) {
1300
1306
  if (!prev.confirmedBy.includes(id)) prev.confirmedBy.push(id);
1301
1307
  }
1302
1308
  if (isDirectoryTombstone(tombstone) && !isDirectoryTombstone(prev)) prev.type = "directory";
1309
+ if (isObsoleteTombstone(tombstone) && prev.type === "directory") prev.obsolete = true;
1303
1310
  }
1304
1311
  async function readTombstonesFromFs(fs, warn) {
1305
1312
  const byPath = /* @__PURE__ */ new Map();
@@ -1331,7 +1338,17 @@ async function readTombstonesFromFs(fs, warn) {
1331
1338
  for (const tombstone of tombstones) mergeTombstone(byPath, tombstone);
1332
1339
  }
1333
1340
  }
1334
- return Array.from(byPath.values());
1341
+ const active = [];
1342
+ for (const tombstone of byPath.values()) {
1343
+ if (isObsoleteTombstone(tombstone)) {
1344
+ log3.log(
1345
+ `[Tombstones] "${tombstone.path}" ignored \u2014 obsolete=true (marked by user)`
1346
+ );
1347
+ continue;
1348
+ }
1349
+ active.push(tombstone);
1350
+ }
1351
+ return active;
1335
1352
  }
1336
1353
  async function readGroupDescriptor(fs) {
1337
1354
  const parsed = await readJson(fs, GROUP_DESCRIPTOR_FILE2);
@@ -28133,8 +28133,12 @@ var ZenFSConfig = (() => {
28133
28133
  confirmedBy: tombstone.confirmedBy
28134
28134
  };
28135
28135
  if (tombstone.type) ordered.type = tombstone.type;
28136
+ if (isObsoleteTombstone(tombstone)) ordered.obsolete = true;
28136
28137
  return JSON.stringify(ordered, null, 2);
28137
28138
  }
28139
+ function isObsoleteTombstone(tombstone) {
28140
+ return tombstone.obsolete === true && tombstone.type === "directory";
28141
+ }
28138
28142
  async function purgeTombstonedTree(fs, targetPath) {
28139
28143
  let isDir2 = false;
28140
28144
  try {
@@ -28307,12 +28311,14 @@ var ZenFSConfig = (() => {
28307
28311
  const path = normalizeTombstonePath(rawPath);
28308
28312
  const confirmedBy = Array.isArray(record.confirmedBy) ? record.confirmedBy.filter((id) => typeof id === "string") : [];
28309
28313
  const type = record.type === "directory" ? "directory" : record.type === "file" ? "file" : void 0;
28314
+ const obsolete = record.obsolete === true && type === "directory";
28310
28315
  return {
28311
28316
  path,
28312
28317
  deletedAt: typeof record.deletedAt === "number" ? record.deletedAt : 0,
28313
28318
  deletedBy: typeof record.deletedBy === "string" ? record.deletedBy : "unknown",
28314
28319
  confirmedBy,
28315
- ...type ? { type } : {}
28320
+ ...type ? { type } : {},
28321
+ ...obsolete ? { obsolete: true } : {}
28316
28322
  };
28317
28323
  }
28318
28324
  function normalizeTombstonePath(rawPath) {
@@ -28400,6 +28406,7 @@ var ZenFSConfig = (() => {
28400
28406
  if (!prev.confirmedBy.includes(id)) prev.confirmedBy.push(id);
28401
28407
  }
28402
28408
  if (isDirectoryTombstone(tombstone) && !isDirectoryTombstone(prev)) prev.type = "directory";
28409
+ if (isObsoleteTombstone(tombstone) && prev.type === "directory") prev.obsolete = true;
28403
28410
  }
28404
28411
  async function readTombstonesFromFs(fs, warn2) {
28405
28412
  const byPath = /* @__PURE__ */ new Map();
@@ -28431,7 +28438,17 @@ var ZenFSConfig = (() => {
28431
28438
  for (const tombstone of tombstones) mergeTombstone(byPath, tombstone);
28432
28439
  }
28433
28440
  }
28434
- return Array.from(byPath.values());
28441
+ const active = [];
28442
+ for (const tombstone of byPath.values()) {
28443
+ if (isObsoleteTombstone(tombstone)) {
28444
+ log7.log(
28445
+ `[Tombstones] "${tombstone.path}" ignored \u2014 obsolete=true (marked by user)`
28446
+ );
28447
+ continue;
28448
+ }
28449
+ active.push(tombstone);
28450
+ }
28451
+ return active;
28435
28452
  }
28436
28453
  async function readGroupDescriptor(fs) {
28437
28454
  const parsed = await readJson(fs, GROUP_DESCRIPTOR_FILE2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-fs-config",
3
- "version": "0.11.4",
3
+ "version": "0.11.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",