@ai-matrx/records 0.76.16 → 0.76.19
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 +13 -0
- package/dist/app-table/index.cjs.map +1 -1
- package/dist/app-table/index.d.cts +3 -3
- package/dist/app-table/index.d.ts +3 -3
- package/dist/app-table/index.js.map +1 -1
- package/dist/{client-kVZ54twD.d.ts → client-C8G7zUMQ.d.ts} +1 -1
- package/dist/{client-PaKP4Cnd.d.cts → client-EaE4ta6p.d.cts} +1 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js.map +1 -1
- package/dist/data/index.cjs.map +1 -1
- package/dist/data/index.d.cts +2 -2
- package/dist/data/index.d.ts +2 -2
- package/dist/data/index.js.map +1 -1
- package/dist/{declareTable-4MK51nXs.d.ts → declareTable-3yW8GrJE.d.ts} +1 -1
- package/dist/{declareTable-Bv4V8Bjm.d.cts → declareTable-aoFu32Ca.d.cts} +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/memory/index.cjs.map +1 -1
- package/dist/memory/index.d.cts +2 -2
- package/dist/memory/index.d.ts +2 -2
- package/dist/memory/index.js.map +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +7 -1
- package/dist/react/index.d.ts +7 -1
- package/dist/react/index.js.map +1 -1
- package/dist/{subscription-D8OHY3kw.d.ts → subscription-DxtZgyFR.d.ts} +7 -1
- package/dist/{subscription-BJgDMerQ.d.cts → subscription-vpnl6GxJ.d.cts} +7 -1
- package/dist/templates/index.cjs +17 -6
- package/dist/templates/index.cjs.map +1 -1
- package/dist/templates/index.d.cts +5 -5
- package/dist/templates/index.d.ts +5 -5
- package/dist/templates/index.js +17 -6
- package/dist/templates/index.js.map +1 -1
- package/dist/{types-Mx-Wzm_d.d.cts → types-X9P-cQd0.d.cts} +1 -1
- package/dist/{types-C6gdqgsI.d.ts → types-y8GX3-QC.d.ts} +1 -1
- package/package.json +1 -1
|
@@ -192,7 +192,13 @@ declare function publicFormPath(formId: string): string;
|
|
|
192
192
|
/** The measures the store offers. Asked of `custom.agg_operations()` at run time too. */
|
|
193
193
|
type AggregateOperation = "count" | "sum" | "avg" | "min" | "max"
|
|
194
194
|
/** GRID-PRIMITIVES G1: the summary bar's other four. Blank = no value, JSON null or "". */
|
|
195
|
-
| "median" | "filled" | "empty" | "unique"
|
|
195
|
+
| "median" | "filled" | "empty" | "unique"
|
|
196
|
+
/**
|
|
197
|
+
* Notion's calculation row (Spaces N6): the share of the rows asked with no value / a value, as a
|
|
198
|
+
* percent 0..100 (NULL over no rows); and the RANGE, largest minus smallest (a date column: the days
|
|
199
|
+
* between its earliest and latest moment).
|
|
200
|
+
*/
|
|
201
|
+
| "percent_empty" | "percent_filled" | "range";
|
|
196
202
|
/** The periods a date Field can be bucketed into (`custom.agg_buckets()`). */
|
|
197
203
|
type AggregateBucket = "day" | "week" | "month" | "quarter" | "year";
|
|
198
204
|
/**
|
|
@@ -192,7 +192,13 @@ declare function publicFormPath(formId: string): string;
|
|
|
192
192
|
/** The measures the store offers. Asked of `custom.agg_operations()` at run time too. */
|
|
193
193
|
type AggregateOperation = "count" | "sum" | "avg" | "min" | "max"
|
|
194
194
|
/** GRID-PRIMITIVES G1: the summary bar's other four. Blank = no value, JSON null or "". */
|
|
195
|
-
| "median" | "filled" | "empty" | "unique"
|
|
195
|
+
| "median" | "filled" | "empty" | "unique"
|
|
196
|
+
/**
|
|
197
|
+
* Notion's calculation row (Spaces N6): the share of the rows asked with no value / a value, as a
|
|
198
|
+
* percent 0..100 (NULL over no rows); and the RANGE, largest minus smallest (a date column: the days
|
|
199
|
+
* between its earliest and latest moment).
|
|
200
|
+
*/
|
|
201
|
+
| "percent_empty" | "percent_filled" | "range";
|
|
196
202
|
/** The periods a date Field can be bucketed into (`custom.agg_buckets()`). */
|
|
197
203
|
type AggregateBucket = "day" | "week" | "month" | "quarter" | "year";
|
|
198
204
|
/**
|
package/dist/templates/index.cjs
CHANGED
|
@@ -3079,6 +3079,12 @@ function storeAggregate(rows, measure, filter, timeZone) {
|
|
|
3079
3079
|
if (op === "filled") return { ok: true, value: present.length, exact: true };
|
|
3080
3080
|
if (op === "empty") return { ok: true, value: live.length - present.length, exact: true };
|
|
3081
3081
|
if (op === "unique") return { ok: true, value: new Set(present).size, exact: true };
|
|
3082
|
+
if (op === "percent_empty" || op === "percent_filled") {
|
|
3083
|
+
if (!live.length) return { ok: true, value: null, exact: true };
|
|
3084
|
+
const share = q(100n * BigInt(op === "percent_filled" ? present.length : live.length - present.length), BigInt(live.length));
|
|
3085
|
+
const pct = qToNumber(share);
|
|
3086
|
+
return pct === null ? { ok: true, value: Number(share.n) / Number(share.d), exact: false } : { ok: true, value: pct, exact: true };
|
|
3087
|
+
}
|
|
3082
3088
|
const nums = [];
|
|
3083
3089
|
for (const t of present) {
|
|
3084
3090
|
const v = parseNumeric(t);
|
|
@@ -3092,6 +3098,10 @@ function storeAggregate(rows, measure, filter, timeZone) {
|
|
|
3092
3098
|
if (op === "avg") result = q(result.n, result.d * BigInt(nums.length));
|
|
3093
3099
|
} else if (op === "min" || op === "max") {
|
|
3094
3100
|
result = nums.reduce((a, b) => (op === "min" ? qCmp(b, a) < 0 : qCmp(b, a) > 0) ? b : a);
|
|
3101
|
+
} else if (op === "range") {
|
|
3102
|
+
const lo = nums.reduce((a, b) => qCmp(b, a) < 0 ? b : a);
|
|
3103
|
+
const hi = nums.reduce((a, b) => qCmp(b, a) > 0 ? b : a);
|
|
3104
|
+
result = qAdd(hi, q(-lo.n, lo.d));
|
|
3095
3105
|
} else if (op === "median") {
|
|
3096
3106
|
const s = [...nums].sort(qCmp);
|
|
3097
3107
|
const mid = Math.floor(s.length / 2);
|
|
@@ -3128,7 +3138,7 @@ var TIME_BOUND_STAGE = /\b(?:no[- ]?show|completed?|done|seen|checked[- ]?in|arr
|
|
|
3128
3138
|
var TERMINAL_STAGE = /^(?:cancell?ed|no[- ]?show|lost|closed[- ]lost|declined|closed|withdrawn|fell off|rejected|void(?:ed)?|skipped|missed)$/i;
|
|
3129
3139
|
var CHART_BLOCK_KINDS = /* @__PURE__ */ new Set(["bar", "column", "line", "donut"]);
|
|
3130
3140
|
var BUCKETS = ["year", "quarter", "month", "week", "day"];
|
|
3131
|
-
var AGG_OPERATIONS = ["count", "sum", "avg", "min", "max", "median", "filled", "empty", "unique"];
|
|
3141
|
+
var AGG_OPERATIONS = ["count", "sum", "avg", "min", "max", "median", "filled", "empty", "unique", "percent_empty", "percent_filled", "range"];
|
|
3132
3142
|
var MEASURE_KEY = /^[a-zA-Z_][a-zA-Z0-9_]{0,62}$/;
|
|
3133
3143
|
var STORE_LIST_RELATION_MAX = 25;
|
|
3134
3144
|
function ruleBreak(field2, v) {
|
|
@@ -4143,7 +4153,7 @@ function validateTemplate(raw, options = {}) {
|
|
|
4143
4153
|
if (!m.op || !AGG_OPERATIONS.includes(m.op) || m.op === "count") say(mat, `The measure "${m.key}" needs one of: ${AGG_OPERATIONS.filter((o) => o !== "count").join(", ")}.`);
|
|
4144
4154
|
const of = m.of ? fieldOf(dim.table, m.of) : void 0;
|
|
4145
4155
|
if (!of) say(mat, `The measure "${m.key}" reads "${m.of ?? "(nothing)"}", which is not a column of "${dim.table}".`);
|
|
4146
|
-
else if (m.op && ["sum", "avg", "min", "max", "median"].includes(m.op) && !(isNumber(of) && !isComputed(of))) say(mat, isComputed(of) ? `"${m.of}" is worked out, and a dimension totals only a number that is typed in; total the stored columns it is made from.` : `"${m.of}" is not a number, so it cannot be added up or averaged.`);
|
|
4156
|
+
else if (m.op && ["sum", "avg", "min", "max", "median", "range"].includes(m.op) && !(isNumber(of) && !isComputed(of))) say(mat, isComputed(of) ? `"${m.of}" is worked out, and a dimension totals only a number that is typed in; total the stored columns it is made from.` : `"${m.of}" is not a number, so it cannot be added up or averaged.`);
|
|
4147
4157
|
if (newMeasures.has(m.key)) say(mat, `Two measures are both called "${m.key}".`);
|
|
4148
4158
|
newMeasures.add(m.key);
|
|
4149
4159
|
});
|
|
@@ -4236,7 +4246,7 @@ function validateTemplate(raw, options = {}) {
|
|
|
4236
4246
|
let honest = true;
|
|
4237
4247
|
for (const m of b.measures ?? []) {
|
|
4238
4248
|
const f = m.key ? fieldOf(table, m.key) : void 0;
|
|
4239
|
-
if (f && ["sum", "avg", "min", "max", "median"].includes(m.op) && !isNumberish(table, f)) {
|
|
4249
|
+
if (f && (["sum", "avg", "min", "max", "median"].includes(m.op) || m.op === "range" && !isDate(f)) && !isNumberish(table, f)) {
|
|
4240
4250
|
honest = false;
|
|
4241
4251
|
say(`${at}.blocks[${bi}]`, `"${b.title}" takes the ${m.op} of "${f.label}", which is not a number.`);
|
|
4242
4252
|
}
|
|
@@ -4565,6 +4575,7 @@ function validateTemplate(raw, options = {}) {
|
|
|
4565
4575
|
}
|
|
4566
4576
|
}
|
|
4567
4577
|
const refWeek = [0, 1, 2, 3, 4, 5, 6].map((i) => shiftDays(TEMPLATE_REFERENCE_DATE, i));
|
|
4578
|
+
const KEY_PART = "";
|
|
4568
4579
|
const crossBreaks = () => {
|
|
4569
4580
|
const out = /* @__PURE__ */ new Map();
|
|
4570
4581
|
const live = (token) => (state.get(token) ?? []).filter((r) => !r.archived);
|
|
@@ -4610,7 +4621,7 @@ function validateTemplate(raw, options = {}) {
|
|
|
4610
4621
|
const linked = Array.isArray(ref2) ? ref2.includes(r.key) : ref2 === r.key;
|
|
4611
4622
|
return linked && (!need.field || (need.in ?? []).includes(storeText(c.values?.[need.field]) ?? ""));
|
|
4612
4623
|
});
|
|
4613
|
-
if (kids.length < (need.min ?? 1)) out.set(
|
|
4624
|
+
if (kids.length < (need.min ?? 1)) out.set(["rc", t.token, r.key, st, kids.length].join(KEY_PART), `"${name(t.token, r)}" is ${st}, which needs ${need.min ?? 1} linked ${byToken.get(need.table)?.labelSingular.toLowerCase() ?? need.table}${need.field ? ` in ${(need.in ?? []).join("/")}` : ""}; it has ${kids.length}.`);
|
|
4614
4625
|
}
|
|
4615
4626
|
for (const f of t.fields.filter((x) => x.eligible)) {
|
|
4616
4627
|
const el = f.eligible;
|
|
@@ -4624,7 +4635,7 @@ function validateTemplate(raw, options = {}) {
|
|
|
4624
4635
|
if (!ok) {
|
|
4625
4636
|
const target = fieldOf(t.token, f.key)?.relationTarget ?? "";
|
|
4626
4637
|
const prow = live(target).find((x) => x.key === who);
|
|
4627
|
-
out.set(
|
|
4638
|
+
out.set(["el", t.token, r.key, f.key, String(who), on].join(KEY_PART), `"${name(t.token, r)}" (${on}) has ${f.label.toLowerCase()} "${prow ? name(target, prow) : String(who)}", who holds no ${byToken.get(el.table)?.labelSingular.toLowerCase() ?? el.table}${el.where ? ` (${Object.values(el.where).join(", ")})` : ""} valid on that day.`);
|
|
4628
4639
|
}
|
|
4629
4640
|
}
|
|
4630
4641
|
}
|
|
@@ -4634,7 +4645,7 @@ function validateTemplate(raw, options = {}) {
|
|
|
4634
4645
|
};
|
|
4635
4646
|
const crossSeen = new Set(crossBreaks().keys());
|
|
4636
4647
|
for (const [k, msg] of crossBreaks()) {
|
|
4637
|
-
const [kind, table, row] = k.split(
|
|
4648
|
+
const [kind, table, row] = k.split(KEY_PART);
|
|
4638
4649
|
if (kind === "rc" || kind === "el") say(`tables (${table}).rows (${row})`, msg);
|
|
4639
4650
|
}
|
|
4640
4651
|
const moveOne = (a, at, rawSet) => {
|