@ai-matrx/records 0.76.17 → 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.
Files changed (40) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/app-table/index.cjs.map +1 -1
  3. package/dist/app-table/index.d.cts +3 -3
  4. package/dist/app-table/index.d.ts +3 -3
  5. package/dist/app-table/index.js.map +1 -1
  6. package/dist/{client-kVZ54twD.d.ts → client-C8G7zUMQ.d.ts} +1 -1
  7. package/dist/{client-PaKP4Cnd.d.cts → client-EaE4ta6p.d.cts} +1 -1
  8. package/dist/core/index.cjs.map +1 -1
  9. package/dist/core/index.d.cts +3 -3
  10. package/dist/core/index.d.ts +3 -3
  11. package/dist/core/index.js.map +1 -1
  12. package/dist/data/index.cjs.map +1 -1
  13. package/dist/data/index.d.cts +2 -2
  14. package/dist/data/index.d.ts +2 -2
  15. package/dist/data/index.js.map +1 -1
  16. package/dist/{declareTable-4MK51nXs.d.ts → declareTable-3yW8GrJE.d.ts} +1 -1
  17. package/dist/{declareTable-Bv4V8Bjm.d.cts → declareTable-aoFu32Ca.d.cts} +1 -1
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/memory/index.cjs.map +1 -1
  23. package/dist/memory/index.d.cts +2 -2
  24. package/dist/memory/index.d.ts +2 -2
  25. package/dist/memory/index.js.map +1 -1
  26. package/dist/react/index.cjs.map +1 -1
  27. package/dist/react/index.d.cts +7 -1
  28. package/dist/react/index.d.ts +7 -1
  29. package/dist/react/index.js.map +1 -1
  30. package/dist/{subscription-D8OHY3kw.d.ts → subscription-DxtZgyFR.d.ts} +7 -1
  31. package/dist/{subscription-BJgDMerQ.d.cts → subscription-vpnl6GxJ.d.cts} +7 -1
  32. package/dist/templates/index.cjs +13 -3
  33. package/dist/templates/index.cjs.map +1 -1
  34. package/dist/templates/index.d.cts +5 -5
  35. package/dist/templates/index.d.ts +5 -5
  36. package/dist/templates/index.js +13 -3
  37. package/dist/templates/index.js.map +1 -1
  38. package/dist/{types-Mx-Wzm_d.d.cts → types-X9P-cQd0.d.cts} +1 -1
  39. package/dist/{types-C6gdqgsI.d.ts → types-y8GX3-QC.d.ts} +1 -1
  40. package/package.json +3 -3
@@ -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
  /**
@@ -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
  }