@ai-matrx/records 0.96.4 → 0.96.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.
@@ -3967,7 +3967,7 @@ function validateTemplate(raw, options = {}) {
3967
3967
  const keys = /* @__PURE__ */ new Set([...Object.keys(a.values ?? {}), ...Object.keys(b.values ?? {})]);
3968
3968
  let differ = 0;
3969
3969
  for (const k of keys) if (!sameJson(a.values?.[k] ?? null, b.values?.[k] ?? null)) differ += 1;
3970
- if (differ < 3) say(`tables[0] (${main.token}).rows[${j}] (${b.key})`, `"${storeText(b.values?.[main.titleField])}" differs from "${storeText(a.values?.[main.titleField])}" in only ${differ} field(s); two real ${main.labelPlural.toLowerCase()} differ in at least three.`);
3970
+ if (differ < Math.min(3, keys.size)) say(`tables[0] (${main.token}).rows[${j}] (${b.key})`, `"${storeText(b.values?.[main.titleField])}" differs from "${storeText(a.values?.[main.titleField])}" in only ${differ} field(s); two real ${main.labelPlural.toLowerCase()} differ in at least three.`);
3971
3971
  }
3972
3972
  }
3973
3973
  }
@@ -7682,17 +7682,18 @@ function describeCheck(spec, ctx = {}) {
7682
7682
  for (let round = 0; round < 3; round++) {
7683
7683
  const bad = rowProblemTables(fixed.spec, problems);
7684
7684
  if (!bad.size) break;
7685
- let grew = true;
7686
- while (grew) {
7687
- grew = false;
7688
- for (const t of fixed.spec.tables) {
7689
- if (bad.has(t.token) || !t.rows?.length) continue;
7690
- if (t.fields.some((f) => f.relationTarget && bad.has(f.relationTarget) && t.rows.some((r) => r.values?.[f.key] != null))) {
7691
- bad.add(t.token);
7692
- grew = true;
7693
- }
7685
+ const unlinked = [];
7686
+ for (const t of fixed.spec.tables) {
7687
+ if (bad.has(t.token) || !t.rows?.length) continue;
7688
+ const links = t.fields.filter((f) => f.relationTarget && bad.has(f.relationTarget) && t.rows.some((r) => r.values?.[f.key] != null));
7689
+ if (!links.length) continue;
7690
+ for (const f of links) {
7691
+ for (const r of t.rows) if (r.values) delete r.values[f.key];
7692
+ f.required = false;
7694
7693
  }
7694
+ unlinked.push(`tables.${t.token}.rows: kept without their ${links.map((f) => f.label || f.key).join(" / ")} link (the rows they pointed at were left out)`);
7695
7695
  }
7696
+ fixed.autoFixes.push(...unlinked);
7696
7697
  for (const t of fixed.spec.tables) {
7697
7698
  if (!bad.has(t.token) || !t.rows?.length) continue;
7698
7699
  const why = problems.find((p) => ROW_AT.exec(p.at)?.[1] === t.token)?.says ?? "they did not pass the check";