@ai-matrx/records 0.72.12 → 0.72.14

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.
@@ -3463,6 +3463,12 @@ function validateTemplate(raw, options = {}) {
3463
3463
  seedLooks.add(p);
3464
3464
  problems.push(p);
3465
3465
  };
3466
+ const galleryBar = /* @__PURE__ */ new WeakSet();
3467
+ const sayGallery = (at, says) => {
3468
+ const p = { at, says };
3469
+ galleryBar.add(p);
3470
+ problems.push(p);
3471
+ };
3466
3472
  const tz = raw.business?.timezone || "UTC";
3467
3473
  const tablesRaw = allTables(raw);
3468
3474
  const ISO_DAY = /\b\d{4}-\d{2}-\d{2}\b/;
@@ -3785,7 +3791,7 @@ function validateTemplate(raw, options = {}) {
3785
3791
  say(`${tat}.rows`, `Only ${titles.size} of ${table.rows.length} rows have a title of their own; a list of look-alike names reads as generated.`);
3786
3792
  }
3787
3793
  });
3788
- if (!hasLookupOrRollup) say("tables", "At least one relationship has to be read across: add a lookup or a rollup through a relation field.");
3794
+ if (!hasLookupOrRollup) sayGallery("tables", "At least one relationship has to be read across: add a lookup or a rollup through a relation field.");
3789
3795
  if (main) {
3790
3796
  const normTitle = (v) => (storeText(v) ?? "").toLowerCase().replace(/\s+/g, " ").trim();
3791
3797
  const rows = main.rows;
@@ -3853,8 +3859,8 @@ function validateTemplate(raw, options = {}) {
3853
3859
  else surfaces.set(token, { at, ...table ? { table } : {} });
3854
3860
  };
3855
3861
  const views = spec.views ?? [];
3856
- if (views.length < 3) say("views", `A template shows at least three views; this one has ${views.length}.`);
3857
- if (!views.some((v) => v.kind === "grid")) say("views", "One of the views is a grid \u2014 the table everyone recognises.");
3862
+ if (views.length < 3) sayGallery("views", `A template shows at least three views; this one has ${views.length}.`);
3863
+ if (!views.some((v) => v.kind === "grid")) sayGallery("views", "One of the views is a grid \u2014 the table everyone recognises.");
3858
3864
  views.forEach((view, i) => {
3859
3865
  const at = `views[${i}] (${view.token})`;
3860
3866
  claim(view.token, at, view.table);
@@ -3980,7 +3986,7 @@ function validateTemplate(raw, options = {}) {
3980
3986
  }
3981
3987
  };
3982
3988
  const extras = spec.extras ?? [];
3983
- if (extras.length < 2) say("extras", `A template carries at least two extras; this one has ${extras.length}.`);
3989
+ if (extras.length < 2) sayGallery("extras", `A template carries at least two extras; this one has ${extras.length}.`);
3984
3990
  const formTokens = new Set(forms.map((f) => f.token));
3985
3991
  const viewTokens = new Set(views.map((v) => v.token));
3986
3992
  const docTokens = new Set(extras.filter((e) => e.kind === "document").map((e) => e.token));
@@ -4329,7 +4335,8 @@ function validateTemplate(raw, options = {}) {
4329
4335
  if (here >= 0 && Number.isFinite(firstWhen) && here < firstWhen && !TERMINAL_STAGE.test(st)) {
4330
4336
  for (const k of rule.filled ?? []) {
4331
4337
  if (!/^(?:datetime|date|checkbox|signature|attachment)$/.test(fieldOf(table, k)?.parityType ?? "")) continue;
4332
- if (filled(row.values?.[k])) say(at, `"${row.key}" is ${st}, but already has "${fieldOf(table, k)?.label ?? k}", which only a ${rule.when.join("/")} record carries. Leave it empty until the record gets there.`);
4338
+ const v = row.values?.[k];
4339
+ if (fieldOf(table, k)?.parityType === "checkbox" ? v === true || v === "true" : filled(v)) say(at, `"${row.key}" is ${st}, but already has "${fieldOf(table, k)?.label ?? k}", which only a ${rule.when.join("/")} record carries. Leave it empty until the record gets there.`);
4333
4340
  }
4334
4341
  }
4335
4342
  if (!rule.when.includes(st)) continue;
@@ -4667,6 +4674,7 @@ function validateTemplate(raw, options = {}) {
4667
4674
  }
4668
4675
  }
4669
4676
  adds += 1;
4677
+ for (const f of table.fields) if (f.default !== void 0 && !isComputed(f) && values[f.key] === void 0) values[f.key] = f.default;
4670
4678
  const added = { key: `walk-${i}-${ri}`, values };
4671
4679
  const landed = rules ? storeText(values[rules.stageField]) : null;
4672
4680
  for (const k of landed ? rules?.requires?.[landed] ?? [] : []) if (!filled(values[k])) say(`${at}.action.rows[${ri}]`, `The new row "${keyValue}" lands in "${landed}", which needs "${k}" filled; the store would refuse it.`);
@@ -5791,7 +5799,7 @@ ${e.body}`.matchAll(MERGE_TOKEN)].map((m) => m[1]));
5791
5799
  if (bothDates && !datesStated) say(`${at}.childDates`, `"${t.token}" and its ${rel.label.toLowerCase()} ("${parent.token}") both carry dates; say how they agree, e.g. {"relation": "${rel.key}", "field": "<this table's date>", "parentField": "<${parent.token}'s date>"} or say why they are independent in independentOf {"${rel.key}": "<reason>"}.`);
5792
5800
  if (bothStatus && !statusStated) say(`${at}.statusAgrees`, `"${t.token}" and its ${rel.label.toLowerCase()} ("${parent.token}") both carry a status; say which child statuses need which parent status (statusAgrees), e.g. a Closed deal means a Sold listing.`);
5793
5801
  }
5794
- for (const f of t.fields.filter((x) => isNumber(x) && !isComputed(x) && /(^|_)(count|roster_size|size|number_of|enrolled|headcount|players|members)($|_)/.test(x.key))) {
5802
+ for (const f of t.fields.filter((x) => isNumber(x) && !isComputed(x) && /(^|_)(count|roster_size|team_size|class_size|number_of|enrolled|headcount|players|members)($|_)/.test(x.key))) {
5795
5803
  const linked = own.find((c) => c.fields.some((cf) => isRelation(cf) && cf.relationTarget === t.token));
5796
5804
  const declared = (t.countMatches ?? []).find((c) => c.field === f.key);
5797
5805
  const linkers = own.filter((c) => c.fields.some((cf) => isRelation(cf) && cf.relationTarget === t.token)).map((c) => c.labelPlural.toLowerCase());
@@ -5826,7 +5834,7 @@ ${e.body}`.matchAll(MERGE_TOKEN)].map((m) => m[1]));
5826
5834
  const describeOwes = (p) => {
5827
5835
  const root = p.at.split(/[.\s[(]/)[0];
5828
5836
  if (GALLERY_ONLY_ROOTS.includes(root)) return false;
5829
- if (seedLooks.has(p)) return false;
5837
+ if (seedLooks.has(p) || galleryBar.has(p)) return false;
5830
5838
  if (/^tables\[\d+\] \([^)]*\)\.rows$/.test(p.at)) return false;
5831
5839
  return true;
5832
5840
  };