@ai-matrx/records 0.83.0 → 0.83.2

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.
@@ -7013,13 +7013,15 @@ function fixFictionalPhones(spec, fixes) {
7013
7013
  Object.assign(spec, next);
7014
7014
  fixes.push(`phones: ${n} number(s) that could reach a real phone replaced with fictional ones (555-0100\u20260199, UK Ofcom drama range)`);
7015
7015
  }
7016
- function fixTeamBlockCopy(spec, fixes) {
7016
+ function fixTeamBlockCopy(spec, fixes, existing = []) {
7017
7017
  const block = SHARED_BLOCKS.team_member;
7018
7018
  const used = /* @__PURE__ */ new Set();
7019
7019
  for (const v of spec.views ?? []) for (const k of ["groupBy", "dateField", "startField", "endField", "coverField", "swimlaneBy", "measure"]) if (v.table && v[k]) used.add(`${v.table}.${v[k]}`);
7020
7020
  for (const fm of spec.forms ?? []) for (const q2 of fm.fields ?? []) used.add(`${fm.table}.${q2.fieldKey}`);
7021
7021
  for (const e of spec.extras ?? []) for (const q2 of e.questions ?? []) used.add(`${e.table}.${q2.fieldKey}`);
7022
7022
  for (const t of spec.tables) {
7023
+ const keys = t.fields.map((f) => f.key).sort().join("|");
7024
+ if (existing.some((e) => e.fields.map((f) => f.key).sort().join("|") === keys)) continue;
7023
7025
  const meaning = (f) => block.fields.find((bf) => bf.parityType === f.parityType && bf.sameAs.some((w) => same3(w, f.label) || same3(w, f.key)));
7024
7026
  const hits = t.fields.map((f) => ({ f, bf: meaning(f) })).filter((x) => x.bf);
7025
7027
  if (hits.length < block.copyThreshold) continue;
@@ -7373,7 +7375,7 @@ function autofixDescribeSpec(input, ctx = {}) {
7373
7375
  dropDuplicateViews(spec, autoFixes);
7374
7376
  fixInverseKeys(spec, autoFixes);
7375
7377
  fixRollupFilters(spec, autoFixes);
7376
- fixTeamBlockCopy(spec, autoFixes);
7378
+ fixTeamBlockCopy(spec, autoFixes, ctx.existingTables ?? []);
7377
7379
  fixFictionalPhones(spec, autoFixes);
7378
7380
  fixMissingQuestionFields(spec, autoFixes);
7379
7381
  raiseSensitivity(spec, autoFixes);
@@ -7390,7 +7392,10 @@ function autofixDescribeSpec(input, ctx = {}) {
7390
7392
  function describeCheck(spec, ctx = {}) {
7391
7393
  const fixed = autofixDescribeSpec(spec, ctx);
7392
7394
  const v = validateTemplate(fixed.spec, { profile: "describe" });
7393
- return { ...fixed, problems: v.problems.map((p) => ({ at: p.at, says: p.says })) };
7395
+ const sameFields = (t) => (ctx.existingTables ?? []).some((e) => e.fields.map((f) => f.key).sort().join("|") === t.fields.map((f) => f.key).sort().join("|"));
7396
+ const reused = new Set(fixed.spec.tables.filter(sameFields).map((t) => t.token));
7397
+ const problems = v.problems.filter((p) => !(/^This table copies the shared /.test(p.says) && reused.has(/\((\w+)\)/.exec(p.at)?.[1] ?? "")));
7398
+ return { ...fixed, problems: problems.map((p) => ({ at: p.at, says: p.says })) };
7394
7399
  }
7395
7400
 
7396
7401
  // src/templates/describe/repair.ts