@ai-matrx/records 0.72.11 → 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.
- package/CHANGELOG.md +18 -0
- package/dist/templates/index.cjs +23 -7
- package/dist/templates/index.cjs.map +1 -1
- package/dist/templates/index.js +23 -7
- package/dist/templates/index.js.map +1 -1
- package/package.json +1 -1
package/dist/templates/index.js
CHANGED
|
@@ -3463,9 +3463,23 @@ 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/;
|
|
3475
|
+
for (const e of raw.extras ?? []) {
|
|
3476
|
+
if (e.kind !== "checklist") continue;
|
|
3477
|
+
for (const st of e.steps ?? []) {
|
|
3478
|
+
if (st.dueDays !== void 0 && !(Number.isInteger(st.dueDays) && st.dueDays >= 0 && st.dueDays <= 3650)) {
|
|
3479
|
+
say(`extras (${e.token}).steps (${st.ref ?? "?"}).dueDays`, `A step is due a whole number of days after the checklist starts, from 0 to 3650; ${st.dueDays} is not. Start the checklist earlier instead of counting backwards.`);
|
|
3480
|
+
}
|
|
3481
|
+
}
|
|
3482
|
+
}
|
|
3469
3483
|
for (const table of tablesRaw) {
|
|
3470
3484
|
for (const f of table.fields) {
|
|
3471
3485
|
for (const rule of f.rules ?? []) {
|
|
@@ -3777,7 +3791,7 @@ function validateTemplate(raw, options = {}) {
|
|
|
3777
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.`);
|
|
3778
3792
|
}
|
|
3779
3793
|
});
|
|
3780
|
-
if (!hasLookupOrRollup)
|
|
3794
|
+
if (!hasLookupOrRollup) sayGallery("tables", "At least one relationship has to be read across: add a lookup or a rollup through a relation field.");
|
|
3781
3795
|
if (main) {
|
|
3782
3796
|
const normTitle = (v) => (storeText(v) ?? "").toLowerCase().replace(/\s+/g, " ").trim();
|
|
3783
3797
|
const rows = main.rows;
|
|
@@ -3845,8 +3859,8 @@ function validateTemplate(raw, options = {}) {
|
|
|
3845
3859
|
else surfaces.set(token, { at, ...table ? { table } : {} });
|
|
3846
3860
|
};
|
|
3847
3861
|
const views = spec.views ?? [];
|
|
3848
|
-
if (views.length < 3)
|
|
3849
|
-
if (!views.some((v) => v.kind === "grid"))
|
|
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.");
|
|
3850
3864
|
views.forEach((view, i) => {
|
|
3851
3865
|
const at = `views[${i}] (${view.token})`;
|
|
3852
3866
|
claim(view.token, at, view.table);
|
|
@@ -3972,7 +3986,7 @@ function validateTemplate(raw, options = {}) {
|
|
|
3972
3986
|
}
|
|
3973
3987
|
};
|
|
3974
3988
|
const extras = spec.extras ?? [];
|
|
3975
|
-
if (extras.length < 2)
|
|
3989
|
+
if (extras.length < 2) sayGallery("extras", `A template carries at least two extras; this one has ${extras.length}.`);
|
|
3976
3990
|
const formTokens = new Set(forms.map((f) => f.token));
|
|
3977
3991
|
const viewTokens = new Set(views.map((v) => v.token));
|
|
3978
3992
|
const docTokens = new Set(extras.filter((e) => e.kind === "document").map((e) => e.token));
|
|
@@ -4321,7 +4335,8 @@ function validateTemplate(raw, options = {}) {
|
|
|
4321
4335
|
if (here >= 0 && Number.isFinite(firstWhen) && here < firstWhen && !TERMINAL_STAGE.test(st)) {
|
|
4322
4336
|
for (const k of rule.filled ?? []) {
|
|
4323
4337
|
if (!/^(?:datetime|date|checkbox|signature|attachment)$/.test(fieldOf(table, k)?.parityType ?? "")) continue;
|
|
4324
|
-
|
|
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.`);
|
|
4325
4340
|
}
|
|
4326
4341
|
}
|
|
4327
4342
|
if (!rule.when.includes(st)) continue;
|
|
@@ -4659,6 +4674,7 @@ function validateTemplate(raw, options = {}) {
|
|
|
4659
4674
|
}
|
|
4660
4675
|
}
|
|
4661
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;
|
|
4662
4678
|
const added = { key: `walk-${i}-${ri}`, values };
|
|
4663
4679
|
const landed = rules ? storeText(values[rules.stageField]) : null;
|
|
4664
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.`);
|
|
@@ -5783,7 +5799,7 @@ ${e.body}`.matchAll(MERGE_TOKEN)].map((m) => m[1]));
|
|
|
5783
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>"}.`);
|
|
5784
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.`);
|
|
5785
5801
|
}
|
|
5786
|
-
for (const f of t.fields.filter((x) => isNumber(x) && !isComputed(x) && /(^|_)(count|roster_size|
|
|
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))) {
|
|
5787
5803
|
const linked = own.find((c) => c.fields.some((cf) => isRelation(cf) && cf.relationTarget === t.token));
|
|
5788
5804
|
const declared = (t.countMatches ?? []).find((c) => c.field === f.key);
|
|
5789
5805
|
const linkers = own.filter((c) => c.fields.some((cf) => isRelation(cf) && cf.relationTarget === t.token)).map((c) => c.labelPlural.toLowerCase());
|
|
@@ -5818,7 +5834,7 @@ ${e.body}`.matchAll(MERGE_TOKEN)].map((m) => m[1]));
|
|
|
5818
5834
|
const describeOwes = (p) => {
|
|
5819
5835
|
const root = p.at.split(/[.\s[(]/)[0];
|
|
5820
5836
|
if (GALLERY_ONLY_ROOTS.includes(root)) return false;
|
|
5821
|
-
if (seedLooks.has(p)) return false;
|
|
5837
|
+
if (seedLooks.has(p) || galleryBar.has(p)) return false;
|
|
5822
5838
|
if (/^tables\[\d+\] \([^)]*\)\.rows$/.test(p.at)) return false;
|
|
5823
5839
|
return true;
|
|
5824
5840
|
};
|