derive-dashboards 0.8.0 → 0.9.0

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 (585) hide show
  1. package/CHANGELOG.md +513 -0
  2. package/README.md +8 -2
  3. package/dist/adapter/statement.mjs +9 -7
  4. package/dist/authorize.mjs +27 -6
  5. package/dist/body.mjs +28 -25
  6. package/dist/cache.d.mts +2 -2
  7. package/dist/charts/data/buckets.d.mts +25 -7
  8. package/dist/charts/data/buckets.mjs +92 -15
  9. package/dist/charts/data/clean.mjs +254 -12
  10. package/dist/charts/data/format.d.mts +7 -2
  11. package/dist/charts/data/format.mjs +68 -70
  12. package/dist/charts/data/input-error.d.mts +2 -0
  13. package/dist/charts/data/input-error.mjs +2 -0
  14. package/dist/charts/data/rows.d.mts +3 -1
  15. package/dist/charts/data/rows.mjs +4 -2
  16. package/dist/charts/data/types.d.mts +50 -7
  17. package/dist/charts/data/words.d.mts +13 -0
  18. package/dist/charts/data/words.mjs +8 -1
  19. package/dist/charts/describe.mjs +6 -6
  20. package/dist/charts/index.d.mts +14 -14
  21. package/dist/charts/index.mjs +4 -1
  22. package/dist/charts/kinds/area-marks.mjs +67 -26
  23. package/dist/charts/kinds/area.d.mts +3 -3
  24. package/dist/charts/kinds/area.mjs +32 -11
  25. package/dist/charts/kinds/bars-data.d.mts +3 -3
  26. package/dist/charts/kinds/bars-data.mjs +12 -6
  27. package/dist/charts/kinds/bars-layout.mjs +60 -6
  28. package/dist/charts/kinds/bars-marks.mjs +6 -6
  29. package/dist/charts/kinds/bars.d.mts +5 -3
  30. package/dist/charts/kinds/bars.mjs +39 -6
  31. package/dist/charts/kinds/columns-data.mjs +14 -5
  32. package/dist/charts/kinds/columns-marks.mjs +52 -23
  33. package/dist/charts/kinds/columns.d.mts +2 -2
  34. package/dist/charts/kinds/columns.mjs +36 -10
  35. package/dist/charts/kinds/course-data.mjs +44 -0
  36. package/dist/charts/kinds/course-layout.mjs +77 -0
  37. package/dist/charts/kinds/course-marks.mjs +52 -0
  38. package/dist/charts/kinds/course-words.mjs +64 -0
  39. package/dist/charts/kinds/course.d.mts +10 -0
  40. package/dist/charts/kinds/course.mjs +55 -0
  41. package/dist/charts/kinds/dumbbell-data.d.mts +4 -4
  42. package/dist/charts/kinds/dumbbell-data.mjs +3 -3
  43. package/dist/charts/kinds/dumbbell-layout.mjs +17 -8
  44. package/dist/charts/kinds/dumbbell.d.mts +5 -3
  45. package/dist/charts/kinds/dumbbell.mjs +35 -4
  46. package/dist/charts/kinds/funnel-data.d.mts +3 -3
  47. package/dist/charts/kinds/funnel-data.mjs +11 -16
  48. package/dist/charts/kinds/funnel-layout.mjs +7 -6
  49. package/dist/charts/kinds/funnel.d.mts +5 -4
  50. package/dist/charts/kinds/funnel.mjs +33 -6
  51. package/dist/charts/kinds/grid-data.d.mts +3 -3
  52. package/dist/charts/kinds/grid-data.mjs +55 -13
  53. package/dist/charts/kinds/grid-layout.mjs +88 -13
  54. package/dist/charts/kinds/grid-legend.mjs +60 -0
  55. package/dist/charts/kinds/grid-marks.mjs +81 -30
  56. package/dist/charts/kinds/grid-time.mjs +19 -5
  57. package/dist/charts/kinds/grid-words.mjs +57 -35
  58. package/dist/charts/kinds/grid.d.mts +7 -4
  59. package/dist/charts/kinds/grid.mjs +49 -8
  60. package/dist/charts/kinds/histogram-data.mjs +68 -26
  61. package/dist/charts/kinds/histogram-layout.mjs +4 -3
  62. package/dist/charts/kinds/histogram-words.mjs +2 -3
  63. package/dist/charts/kinds/histogram.d.mts +2 -2
  64. package/dist/charts/kinds/histogram.mjs +17 -1
  65. package/dist/charts/kinds/line-marks.mjs +19 -11
  66. package/dist/charts/kinds/line.d.mts +2 -2
  67. package/dist/charts/kinds/line.mjs +21 -3
  68. package/dist/charts/kinds/multiples-grid.mjs +57 -27
  69. package/dist/charts/kinds/multiples-head.mjs +52 -22
  70. package/dist/charts/kinds/multiples-layout.mjs +106 -52
  71. package/dist/charts/kinds/multiples-marks.mjs +6 -5
  72. package/dist/charts/kinds/multiples-words.mjs +53 -38
  73. package/dist/charts/kinds/multiples.d.mts +2 -2
  74. package/dist/charts/kinds/multiples.mjs +35 -7
  75. package/dist/charts/kinds/row-chart.d.mts +7 -0
  76. package/dist/charts/kinds/row-chart.mjs +47 -10
  77. package/dist/charts/kinds/row-marks.mjs +5 -5
  78. package/dist/charts/kinds/scatter-data.d.mts +5 -5
  79. package/dist/charts/kinds/scatter-data.mjs +6 -6
  80. package/dist/charts/kinds/scatter-marks.mjs +46 -19
  81. package/dist/charts/kinds/scatter-words.mjs +8 -8
  82. package/dist/charts/kinds/scatter.d.mts +5 -3
  83. package/dist/charts/kinds/scatter.mjs +18 -0
  84. package/dist/charts/kinds/stat-data.mjs +7 -7
  85. package/dist/charts/kinds/stat-marks.mjs +2 -2
  86. package/dist/charts/kinds/stat.d.mts +4 -4
  87. package/dist/charts/kinds/stat.mjs +19 -0
  88. package/dist/charts/kinds/time-chart.mjs +13 -4
  89. package/dist/charts/kinds/time-frame.mjs +50 -19
  90. package/dist/charts/kinds/time-plan.mjs +29 -2
  91. package/dist/charts/kinds/time-plot.mjs +1 -1
  92. package/dist/charts/kinds/time-stops.mjs +58 -29
  93. package/dist/charts/kinds/waterfall-data.d.mts +3 -3
  94. package/dist/charts/kinds/waterfall-data.mjs +2 -2
  95. package/dist/charts/kinds/waterfall.d.mts +5 -4
  96. package/dist/charts/kinds/waterfall.mjs +29 -2
  97. package/dist/charts/layout/frame.mjs +5 -3
  98. package/dist/charts/layout/stack.mjs +43 -22
  99. package/dist/charts/marks/axes.mjs +10 -5
  100. package/dist/charts/marks/budget.mjs +14 -0
  101. package/dist/charts/marks/end-labels.mjs +24 -10
  102. package/dist/charts/marks/legend.mjs +19 -8
  103. package/dist/charts/marks/lines.mjs +3 -3
  104. package/dist/charts/marks/more.mjs +79 -13
  105. package/dist/charts/marks/notes.mjs +12 -6
  106. package/dist/charts/marks/series-line.mjs +14 -10
  107. package/dist/charts/marks/thin.mjs +16 -33
  108. package/dist/charts/scale/calendar.mjs +41 -26
  109. package/dist/charts/scale/linear.mjs +58 -0
  110. package/dist/charts/scale/value.d.mts +21 -0
  111. package/dist/charts/scale/value.mjs +67 -9
  112. package/dist/charts/scene/lazy.mjs +27 -0
  113. package/dist/charts/scene/markup.mjs +2 -1
  114. package/dist/charts/scene/svg.mjs +20 -8
  115. package/dist/charts/scene/types.d.mts +34 -0
  116. package/dist/charts/text/measure.mjs +33 -3
  117. package/dist/charts/theme.mjs +13 -4
  118. package/dist/charts-react/Chart.d.mts +20 -0
  119. package/dist/charts-react/Chart.mjs +9 -67
  120. package/dist/charts-react/Reader.mjs +50 -96
  121. package/dist/charts-react/box.mjs +106 -0
  122. package/dist/charts-react/bucket-names.mjs +9 -24
  123. package/dist/charts-react/columns-picture.mjs +12 -0
  124. package/dist/charts-react/exact-sum.mjs +4 -7
  125. package/dist/charts-react/from-answer.mjs +9 -4
  126. package/dist/charts-react/index.d.mts +9 -2
  127. package/dist/charts-react/index.mjs +9 -2
  128. package/dist/charts-react/kinds/area.d.mts +4 -0
  129. package/dist/charts-react/kinds/area.mjs +38 -0
  130. package/dist/charts-react/kinds/bar.d.mts +4 -0
  131. package/dist/charts-react/kinds/bar.mjs +15 -0
  132. package/dist/charts-react/kinds/funnel.d.mts +4 -0
  133. package/dist/charts-react/kinds/funnel.mjs +13 -0
  134. package/dist/charts-react/kinds/heatmap.d.mts +4 -0
  135. package/dist/charts-react/kinds/heatmap.mjs +13 -0
  136. package/dist/charts-react/kinds/line.d.mts +4 -0
  137. package/dist/charts-react/kinds/line.mjs +20 -0
  138. package/dist/charts-react/kinds/multiples.d.mts +4 -0
  139. package/dist/charts-react/kinds/multiples.mjs +33 -0
  140. package/dist/charts-react/kinds/number.d.mts +5 -0
  141. package/dist/charts-react/kinds/number.mjs +86 -0
  142. package/dist/charts-react/plan-bars.mjs +15 -8
  143. package/dist/charts-react/plan-funnel.mjs +3 -1
  144. package/dist/charts-react/plan-grid.mjs +14 -5
  145. package/dist/charts-react/plan-of.mjs +17 -0
  146. package/dist/charts-react/plan-parts.mjs +16 -5
  147. package/dist/charts-react/plan-time.mjs +4 -53
  148. package/dist/charts-react/reader-page.d.mts +1 -1
  149. package/dist/charts-react/reader-page.mjs +19 -9
  150. package/dist/charts-react/renderers.d.mts +14 -0
  151. package/dist/charts-react/renderers.mjs +22 -0
  152. package/dist/charts-react/table.d.mts +1 -0
  153. package/dist/charts-react/table.mjs +108 -0
  154. package/dist/charts-react/tiles.mjs +21 -49
  155. package/dist/charts-react/useScene.mjs +45 -17
  156. package/dist/charts-react/words.mjs +19 -0
  157. package/dist/checks.mjs +97 -19
  158. package/dist/cli/add.mjs +4 -3
  159. package/dist/cli/doctor.mjs +2 -2
  160. package/dist/core/conformance/index.d.mts +5 -2
  161. package/dist/core/conformance/index.mjs +5 -2
  162. package/dist/core/conformance/memory/aggregate.mjs +11 -6
  163. package/dist/core/conformance/memory/rows.d.mts +7 -3
  164. package/dist/core/conformance/memory/rows.mjs +19 -13
  165. package/dist/core/conformance/memory/source.mjs +4 -4
  166. package/dist/core/document/control-fields.d.mts +20 -0
  167. package/dist/core/document/control-fields.mjs +117 -0
  168. package/dist/core/document/display-comparisons.d.mts +17 -0
  169. package/dist/core/document/display-comparisons.mjs +15 -4
  170. package/dist/core/document/display-entries.d.mts +14 -0
  171. package/dist/core/document/display-entries.mjs +25 -9
  172. package/dist/core/document/display-validation.d.mts +5 -1
  173. package/dist/core/document/display-validation.mjs +14 -7
  174. package/dist/core/document/display.d.mts +10 -8
  175. package/dist/core/document/display.mjs +25 -4
  176. package/dist/core/document/layout.d.mts +8 -9
  177. package/dist/core/document/layout.mjs +23 -6
  178. package/dist/core/document/stacked.d.mts +0 -7
  179. package/dist/core/document/types.mjs +8 -6
  180. package/dist/core/document/upgrade.d.mts +1 -0
  181. package/dist/core/document/upgrade.mjs +4 -2
  182. package/dist/core/engine/access.mjs +3 -3
  183. package/dist/core/engine/assert.mjs +4 -2
  184. package/dist/core/engine/bucket.mjs +2 -2
  185. package/dist/core/engine/checks.mjs +6 -7
  186. package/dist/core/engine/custom/ask.mjs +22 -2
  187. package/dist/core/engine/custom/cells.mjs +22 -22
  188. package/dist/core/engine/custom/level.mjs +12 -13
  189. package/dist/core/engine/custom/measures.mjs +12 -9
  190. package/dist/core/engine/custom/reader.mjs +3 -1
  191. package/dist/core/engine/custom/records.mjs +8 -7
  192. package/dist/core/engine/custom/unread.mjs +78 -0
  193. package/dist/core/engine/custom/where.mjs +15 -10
  194. package/dist/core/engine/index.d.mts +2 -13
  195. package/dist/core/engine/index.mjs +2 -12
  196. package/dist/core/engine/measure.mjs +1 -0
  197. package/dist/core/engine/members.mjs +7 -3
  198. package/dist/core/engine/nan.mjs +10 -1
  199. package/dist/core/engine/native.mjs +2 -20
  200. package/dist/core/engine/numbers.mjs +26 -14
  201. package/dist/core/engine/postgres.mjs +9 -5
  202. package/dist/core/engine/prepare.mjs +4 -4
  203. package/dist/core/engine/rank-sets.mjs +1 -1
  204. package/dist/core/engine/read.mjs +5 -4
  205. package/dist/core/engine/reader.d.mts +6 -0
  206. package/dist/core/engine/record-layout.mjs +3 -3
  207. package/dist/core/engine/run.mjs +77 -20
  208. package/dist/core/engine/segmented.d.mts +2 -1
  209. package/dist/core/engine/segmented.mjs +19 -12
  210. package/dist/core/engine/series.mjs +1 -1
  211. package/dist/core/engine/shape.mjs +8 -8
  212. package/dist/core/engine/sql-partition.mjs +2 -2
  213. package/dist/core/engine/sql-pass.mjs +3 -2
  214. package/dist/core/engine/sql-reader.mjs +13 -5
  215. package/dist/core/engine/sql-reads.mjs +2 -1
  216. package/dist/core/engine/sql-records.mjs +2 -2
  217. package/dist/core/engine/sql-split.mjs +1 -1
  218. package/dist/core/engine/sql-unread.mjs +70 -0
  219. package/dist/core/engine/time.mjs +2 -1
  220. package/dist/core/engine/types.d.mts +17 -0
  221. package/dist/core/engine/version.d.mts +1 -1
  222. package/dist/core/engine/version.mjs +1 -1
  223. package/dist/core/error/codes.d.mts +24 -1
  224. package/dist/core/error/codes.mjs +23 -3
  225. package/dist/core/error/refusal.d.mts +8 -3
  226. package/dist/core/error/refusal.mjs +6 -1
  227. package/dist/core/exact/decimal.d.mts +1 -14
  228. package/dist/core/exact/decimal.mjs +9 -19
  229. package/dist/core/exact/stored.d.mts +9 -0
  230. package/dist/core/exact/stored.mjs +38 -0
  231. package/dist/core/exact/text.d.mts +16 -1
  232. package/dist/core/exact/text.mjs +50 -1
  233. package/dist/core/format/digits.mjs +55 -0
  234. package/dist/core/format/index.d.mts +16 -0
  235. package/dist/core/format/index.mjs +27 -0
  236. package/dist/core/format/number.d.mts +27 -0
  237. package/dist/core/format/number.mjs +158 -0
  238. package/dist/core/format/write.d.mts +6 -0
  239. package/dist/core/format/write.mjs +57 -0
  240. package/dist/core/index.d.mts +43 -33
  241. package/dist/core/index.mjs +31 -28
  242. package/dist/core/model/defaults.d.mts +18 -1
  243. package/dist/core/model/defaults.mjs +19 -1
  244. package/dist/core/model/define.d.mts +17 -8
  245. package/dist/core/model/define.mjs +2 -0
  246. package/dist/core/model/member.d.mts +5 -3
  247. package/dist/core/model/member.mjs +33 -6
  248. package/dist/core/model/storage.mjs +40 -12
  249. package/dist/core/model/types.d.mts +17 -1
  250. package/dist/core/model/types.mjs +5 -0
  251. package/dist/core/model/validate/expr.d.mts +1 -7
  252. package/dist/core/model/validate/fields.d.mts +2 -0
  253. package/dist/core/model/validate/fields.mjs +14 -7
  254. package/dist/core/model/validate/issues.mjs +5 -1
  255. package/dist/core/model/validate/known-members.mjs +6 -5
  256. package/dist/core/model/validate/shape.mjs +36 -3
  257. package/dist/core/model/validate/source.mjs +2 -2
  258. package/dist/core/oracle/data.d.mts +4 -2
  259. package/dist/core/oracle/evaluate.d.mts +19 -1
  260. package/dist/core/oracle/evaluate.mjs +56 -10
  261. package/dist/core/oracle/expr.mjs +1 -1
  262. package/dist/core/oracle/facts.mjs +12 -5
  263. package/dist/core/oracle/measure.mjs +1 -1
  264. package/dist/core/oracle/request.mjs +39 -4
  265. package/dist/core/oracle/segmented.d.mts +3 -1
  266. package/dist/core/oracle/segmented.mjs +19 -13
  267. package/dist/core/oracle/unread.mjs +32 -0
  268. package/dist/core/oracle/visibility.mjs +4 -3
  269. package/dist/core/policy/bind.d.mts +2 -11
  270. package/dist/core/policy/bind.mjs +1 -1
  271. package/dist/core/policy/match.mjs +1 -1
  272. package/dist/core/query/closure.d.mts +7 -2
  273. package/dist/core/query/closure.mjs +29 -12
  274. package/dist/core/query/compose-tile.d.mts +3 -2
  275. package/dist/core/query/compose-tile.mjs +32 -13
  276. package/dist/core/query/compose.d.mts +0 -5
  277. package/dist/core/query/drill/internal.d.mts +5 -5
  278. package/dist/core/query/drill/internal.mjs +11 -0
  279. package/dist/core/query/drill/links.d.mts +2 -3
  280. package/dist/core/query/drill/links.mjs +18 -4
  281. package/dist/core/query/drill/selection.d.mts +8 -2
  282. package/dist/core/query/drill/selection.mjs +14 -3
  283. package/dist/core/query/drill/synthetic.mjs +1 -1
  284. package/dist/core/query/drill/time.mjs +11 -10
  285. package/dist/core/query/filter.d.mts +1 -6
  286. package/dist/core/query/filter.mjs +1 -4
  287. package/dist/core/query/fold.mjs +23 -0
  288. package/dist/core/query/segments.mjs +42 -3
  289. package/dist/core/query/to-wire.d.mts +7 -0
  290. package/dist/core/query/to-wire.mjs +14 -2
  291. package/dist/core/query/types.d.mts +30 -13
  292. package/dist/core/result/columns.mjs +23 -13
  293. package/dist/core/result/number.mjs +3 -3
  294. package/dist/core/result/status.d.mts +13 -0
  295. package/dist/core/result/status.mjs +18 -0
  296. package/dist/core/result/time-axis.d.mts +14 -13
  297. package/dist/core/result/time-axis.mjs +20 -2
  298. package/dist/core/result/types.d.mts +33 -3
  299. package/dist/core/result/whole.d.mts +23 -0
  300. package/dist/core/result/whole.mjs +27 -0
  301. package/dist/core/schema/agent-query.d.mts +89 -0
  302. package/dist/core/schema/agent-query.mjs +115 -0
  303. package/dist/core/schema/aliases.mjs +1 -52
  304. package/dist/core/schema/answer-parts.mjs +17 -13
  305. package/dist/core/schema/answers.d.mts +787 -319
  306. package/dist/core/schema/commands.d.mts +33 -23
  307. package/dist/core/schema/commands.mjs +26 -18
  308. package/dist/core/schema/custom.mjs +46 -45
  309. package/dist/core/schema/document.d.mts +32 -27
  310. package/dist/core/schema/document.mjs +61 -81
  311. package/dist/core/schema/drill-answers.mjs +4 -1
  312. package/dist/core/schema/drill.d.mts +14 -9
  313. package/dist/core/schema/drill.mjs +23 -22
  314. package/dist/core/schema/index.d.mts +5 -3
  315. package/dist/core/schema/index.mjs +5 -3
  316. package/dist/core/schema/options.d.mts +92 -0
  317. package/dist/core/schema/options.mjs +104 -0
  318. package/dist/core/schema/picks.d.mts +2 -2
  319. package/dist/core/schema/picks.mjs +7 -6
  320. package/dist/core/schema/query.d.mts +9 -83
  321. package/dist/core/schema/query.mjs +49 -73
  322. package/dist/core/schema/strict.d.mts +3 -0
  323. package/dist/core/schema/strict.mjs +91 -0
  324. package/dist/core/schema/union-error.mjs +30 -7
  325. package/dist/core/schema/view.d.mts +4 -3
  326. package/dist/core/schema/view.mjs +16 -11
  327. package/dist/core/store/ddl.d.mts +0 -2
  328. package/dist/core/store/ddl.mjs +1 -5
  329. package/dist/core/time/bucket.d.mts +1 -19
  330. package/dist/core/time/bucket.mjs +6 -6
  331. package/dist/core/time/compare.mjs +3 -2
  332. package/dist/core/time/index.d.mts +7 -8
  333. package/dist/core/time/instant.d.mts +15 -9
  334. package/dist/core/time/instant.mjs +23 -9
  335. package/dist/core/time/range.d.mts +3 -15
  336. package/dist/core/time/range.mjs +17 -7
  337. package/dist/core/time/stored.d.mts +8 -5
  338. package/dist/core/time/stored.mjs +51 -15
  339. package/dist/core/time/temporal.d.mts +1 -5
  340. package/dist/core/time/temporal.mjs +9 -4
  341. package/dist/core/time/text-time.d.mts +31 -2
  342. package/dist/core/time/text-time.mjs +139 -22
  343. package/dist/core/time/zone.mjs +2 -2
  344. package/dist/core/types/api.d.mts +1 -1
  345. package/dist/core/types/api.mjs +1 -1
  346. package/dist/core/types/dashboard.d.mts +185 -0
  347. package/dist/core/types/dashboard.mjs +26 -0
  348. package/dist/core/types/drill-api.d.mts +14 -2
  349. package/dist/core/types/infer.d.mts +0 -4
  350. package/dist/core/types/options-check.d.mts +42 -0
  351. package/dist/core/types/options-check.mjs +90 -0
  352. package/dist/core/types/options.d.mts +14 -8
  353. package/dist/core/value/casefold.d.mts +1 -3
  354. package/dist/core/value/stored.d.mts +26 -0
  355. package/dist/core/value/stored.mjs +28 -0
  356. package/dist/cursor-seal.mjs +37 -9
  357. package/dist/dashboard-documents.d.mts +14 -6
  358. package/dist/dashboard-documents.mjs +32 -12
  359. package/dist/dashboards.mjs +10 -9
  360. package/dist/drill-access.mjs +6 -6
  361. package/dist/drill-change.mjs +18 -20
  362. package/dist/drill-comparison.mjs +2 -1
  363. package/dist/drill-crumbs.mjs +63 -28
  364. package/dist/drill-distinct.mjs +2 -1
  365. package/dist/drill-explain.mjs +1 -1
  366. package/dist/drill-items.mjs +1 -1
  367. package/dist/drill-open.mjs +39 -23
  368. package/dist/drill-seal.mjs +41 -13
  369. package/dist/drill-share.mjs +1 -1
  370. package/dist/drill-summary.mjs +2 -1
  371. package/dist/drill-targets.mjs +4 -4
  372. package/dist/drill-views.mjs +4 -3
  373. package/dist/drill.mjs +1 -1
  374. package/dist/editing.mjs +5 -3
  375. package/dist/endpoints/index.d.mts +29 -8
  376. package/dist/endpoints/index.mjs +4 -1
  377. package/dist/endpoints/meta.mjs +4 -3
  378. package/dist/endpoints/query.mjs +5 -2
  379. package/dist/endpoints/read.mjs +7 -6
  380. package/dist/endpoints/versions.mjs +2 -1
  381. package/dist/execute.d.mts +3 -0
  382. package/dist/execute.mjs +23 -12
  383. package/dist/grant.d.mts +9 -0
  384. package/dist/grant.mjs +43 -0
  385. package/dist/handler.mjs +8 -13
  386. package/dist/http.d.mts +6 -2
  387. package/dist/http.mjs +6 -2
  388. package/dist/index.d.mts +25 -4
  389. package/dist/index.mjs +91 -40
  390. package/dist/llms.txt +3 -3
  391. package/dist/mcp/api.mjs +2 -1
  392. package/dist/mcp/query.mjs +3 -8
  393. package/dist/mcp/resolve.mjs +9 -2
  394. package/dist/node/index.d.mts +36 -0
  395. package/dist/node/index.mjs +89 -0
  396. package/dist/node/request.d.mts +12 -0
  397. package/dist/node/request.mjs +119 -0
  398. package/dist/node/response.mjs +58 -0
  399. package/dist/principal.mjs +15 -7
  400. package/dist/react/Canvas.mjs +88 -67
  401. package/dist/react/Cell.mjs +2 -1
  402. package/dist/react/Dashboard.d.mts +9 -1
  403. package/dist/react/Dashboard.mjs +42 -42
  404. package/dist/react/DashboardList.mjs +9 -4
  405. package/dist/react/Editing.d.mts +9 -0
  406. package/dist/react/Editing.mjs +8 -3
  407. package/dist/react/Grid.mjs +1 -1
  408. package/dist/react/Header.mjs +4 -35
  409. package/dist/react/History.mjs +3 -2
  410. package/dist/react/LoadFailed.mjs +59 -0
  411. package/dist/react/Panel.d.mts +1 -1
  412. package/dist/react/Panel.mjs +1 -1
  413. package/dist/react/Parts.d.mts +34 -0
  414. package/dist/react/Parts.mjs +9 -6
  415. package/dist/react/ReviewPanel.mjs +1 -1
  416. package/dist/react/RowBody.d.mts +2 -0
  417. package/dist/react/RowBody.mjs +5 -1
  418. package/dist/react/Share.mjs +153 -0
  419. package/dist/react/TabStrip.mjs +37 -0
  420. package/dist/react/Tile.d.mts +3 -1
  421. package/dist/react/Tile.mjs +89 -92
  422. package/dist/react/TileState.mjs +117 -0
  423. package/dist/react/ago.mjs +45 -0
  424. package/dist/react/arrange.mjs +1 -1
  425. package/dist/react/board.mjs +2 -2
  426. package/dist/react/bucket-name.d.mts +8 -0
  427. package/dist/react/bucket-name.mjs +13 -0
  428. package/dist/react/builder/DisplayOptions.mjs +219 -0
  429. package/dist/react/builder/Preview.mjs +13 -13
  430. package/dist/react/builder/RangeEditor.mjs +4 -3
  431. package/dist/react/builder/WidgetBuilder.d.mts +1 -7
  432. package/dist/react/builder/WidgetBuilder.mjs +12 -3
  433. package/dist/react/builder/base.d.mts +13 -2
  434. package/dist/react/builder/base.mjs +70 -12
  435. package/dist/react/builder/display.d.mts +3 -0
  436. package/dist/react/builder/display.mjs +256 -0
  437. package/dist/react/builder/labels.mjs +19 -5
  438. package/dist/react/builder/options.mjs +11 -6
  439. package/dist/react/builder/state.mjs +25 -3
  440. package/dist/react/builder/useBuilder.d.mts +7 -1
  441. package/dist/react/builder/useBuilder.mjs +6 -9
  442. package/dist/react/builder/usePreview.mjs +3 -2
  443. package/dist/react/builder/words.d.mts +16 -1
  444. package/dist/react/builder/words.mjs +41 -1
  445. package/dist/react/change-text.mjs +149 -0
  446. package/dist/react/client.d.mts +9 -0
  447. package/dist/react/client.mjs +105 -14
  448. package/dist/react/context.d.mts +24 -3
  449. package/dist/react/context.mjs +23 -7
  450. package/dist/react/dates-shown.mjs +76 -0
  451. package/dist/react/draft.mjs +3 -2
  452. package/dist/react/drill/Bars.mjs +12 -16
  453. package/dist/react/drill/Comparison.mjs +1 -1
  454. package/dist/react/drill/DrillPanel.d.mts +1 -1
  455. package/dist/react/drill/DrillPanel.mjs +2 -1
  456. package/dist/react/drill/Header.mjs +65 -12
  457. package/dist/react/drill/Items.d.mts +1 -1
  458. package/dist/react/drill/Notes.mjs +10 -7
  459. package/dist/react/drill/PanelStates.mjs +8 -1
  460. package/dist/react/drill/Trend.mjs +10 -5
  461. package/dist/react/drill/board.d.mts +1 -1
  462. package/dist/react/drill/host.mjs +4 -1
  463. package/dist/react/drill/lazy.mjs +2 -27
  464. package/dist/react/drill/props.d.mts +17 -7
  465. package/dist/react/drill/props.mjs +55 -14
  466. package/dist/react/drill/state.d.mts +15 -5
  467. package/dist/react/drill/state.mjs +12 -3
  468. package/dist/react/drill/words.d.mts +46 -3
  469. package/dist/react/drill/words.mjs +30 -5
  470. package/dist/react/english.mjs +33 -8
  471. package/dist/react/export/ExportButton.mjs +4 -1
  472. package/dist/react/export/csv.d.mts +7 -2
  473. package/dist/react/export/csv.mjs +24 -7
  474. package/dist/react/failure-words.mjs +60 -0
  475. package/dist/react/filters/bar.d.mts +1 -1
  476. package/dist/react/filters/bar.mjs +4 -1
  477. package/dist/react/filters/calendar.mjs +23 -8
  478. package/dist/react/filters/chip.mjs +7 -3
  479. package/dist/react/filters/context.d.mts +13 -1
  480. package/dist/react/filters/context.mjs +1 -1
  481. package/dist/react/filters/dates-said.mjs +57 -0
  482. package/dist/react/filters/days.d.mts +3 -4
  483. package/dist/react/filters/days.mjs +10 -17
  484. package/dist/react/filters/hooks.d.mts +11 -0
  485. package/dist/react/filters/hooks.mjs +10 -6
  486. package/dist/react/filters/menu-search.mjs +17 -9
  487. package/dist/react/filters/menu.mjs +10 -8
  488. package/dist/react/filters/phone.mjs +41 -16
  489. package/dist/react/filters/place.mjs +40 -0
  490. package/dist/react/filters/popover.mjs +18 -13
  491. package/dist/react/filters/rules.d.mts +4 -3
  492. package/dist/react/filters/rules.mjs +3 -3
  493. package/dist/react/filters/sheet.mjs +7 -3
  494. package/dist/react/filters/state.mjs +6 -1
  495. package/dist/react/filters/values.mjs +24 -7
  496. package/dist/react/filters/words.d.mts +13 -0
  497. package/dist/react/filters/words.mjs +5 -0
  498. package/dist/react/format-time.d.mts +17 -6
  499. package/dist/react/format-time.mjs +152 -33
  500. package/dist/react/format.d.mts +3 -3
  501. package/dist/react/format.mjs +27 -133
  502. package/dist/react/headline.d.mts +6 -3
  503. package/dist/react/headline.mjs +81 -25
  504. package/dist/react/index.d.mts +19 -17
  505. package/dist/react/index.mjs +12 -10
  506. package/dist/react/lazy.mjs +38 -0
  507. package/dist/react/messages.d.mts +78 -2
  508. package/dist/react/now.mjs +38 -0
  509. package/dist/react/read.d.mts +1 -0
  510. package/dist/react/read.mjs +140 -9
  511. package/dist/react/renderers/exact.mjs +31 -59
  512. package/dist/react/renderers/index.d.mts +27 -6
  513. package/dist/react/renderers/index.mjs +141 -102
  514. package/dist/react/renderers/list-parts.mjs +24 -0
  515. package/dist/react/renderers/list.d.mts +1 -0
  516. package/dist/react/renderers/list.mjs +99 -43
  517. package/dist/react/renderers/more-rows.mjs +75 -0
  518. package/dist/react/renderers/number-before.mjs +320 -0
  519. package/dist/react/renderers/number-period.mjs +54 -0
  520. package/dist/react/renderers/number-whole.mjs +29 -0
  521. package/dist/react/renderers/props.d.mts +24 -1
  522. package/dist/react/renderers/props.mjs +8 -0
  523. package/dist/react/renderers/table-cells.mjs +137 -31
  524. package/dist/react/renderers/table-fit.mjs +55 -10
  525. package/dist/react/renderers/table-measure.mjs +29 -9
  526. package/dist/react/renderers/table-row.mjs +14 -9
  527. package/dist/react/renderers/table-scale.mjs +2 -3
  528. package/dist/react/renderers/table-sort.mjs +3 -2
  529. package/dist/react/renderers/table-whole.mjs +37 -0
  530. package/dist/react/renderers/table.mjs +73 -53
  531. package/dist/react/review.d.mts +7 -0
  532. package/dist/react/review.mjs +35 -8
  533. package/dist/react/roving.d.mts +6 -0
  534. package/dist/react/roving.mjs +123 -0
  535. package/dist/react/says-dates.d.mts +7 -0
  536. package/dist/react/says-dates.mjs +51 -0
  537. package/dist/react/series.mjs +5 -6
  538. package/dist/react/stable.mjs +1 -1
  539. package/dist/react/tabs/EditTabs.mjs +125 -0
  540. package/dist/react/tabs/NameField.mjs +72 -0
  541. package/dist/react/tabs/TabMenu.mjs +175 -0
  542. package/dist/react/tabs/actions.mjs +37 -0
  543. package/dist/react/tabs/commands.mjs +76 -0
  544. package/dist/react/tabs/focus.mjs +22 -0
  545. package/dist/react/tabs/keys.mjs +28 -0
  546. package/dist/react/theme-unlayered.css +1 -1
  547. package/dist/react/theme.css +1 -1
  548. package/dist/react/tile-store.d.mts +4 -0
  549. package/dist/react/tile-store.mjs +93 -13
  550. package/dist/react/touch.d.mts +16 -0
  551. package/dist/react/touch.mjs +39 -0
  552. package/dist/react/useBoard.d.mts +6 -0
  553. package/dist/react/useBoard.mjs +1 -0
  554. package/dist/react/useDashboard.d.mts +2 -0
  555. package/dist/react/useDashboard.mjs +5 -2
  556. package/dist/react/useTiles.d.mts +3 -0
  557. package/dist/react/useTiles.mjs +73 -17
  558. package/dist/react/view-grid.mjs +2 -2
  559. package/dist/react/view.mjs +1 -1
  560. package/dist/recharts/axes.mjs +1 -1
  561. package/dist/recharts/axis.mjs +23 -73
  562. package/dist/recharts/bar.d.mts +2 -1
  563. package/dist/recharts/bar.mjs +140 -64
  564. package/dist/recharts/fit.mjs +33 -0
  565. package/dist/recharts/line.mjs +21 -15
  566. package/dist/recharts/marks.mjs +2 -1
  567. package/dist/recharts/parts.mjs +16 -13
  568. package/dist/recharts/table.mjs +8 -3
  569. package/dist/refusal.mjs +46 -0
  570. package/dist/registry/filter-bar.json +1 -1
  571. package/dist/skills/derive-dashboards/SKILL.md +23 -8
  572. package/dist/tile-doc.mjs +1 -1
  573. package/package.json +21 -6
  574. package/dist/charts-react/plan.d.mts +0 -3
  575. package/dist/charts-react/plan.mjs +0 -37
  576. package/dist/charts-react/tiles.d.mts +0 -24
  577. package/dist/core/policy/match.d.mts +0 -16
  578. package/dist/core/schema/aliases.d.mts +0 -7
  579. package/dist/core/time/compare.d.mts +0 -30
  580. package/dist/react/EditBar.d.mts +0 -16
  581. package/dist/react/History.d.mts +0 -30
  582. package/dist/react/ReviewPanel.d.mts +0 -15
  583. package/dist/react/digits.mjs +0 -46
  584. package/dist/react/drill/trend-touch.mjs +0 -33
  585. package/dist/react/renderers/exact.d.mts +0 -6
@@ -14,17 +14,34 @@ function parseMemberId(id) {
14
14
  name: third
15
15
  };
16
16
  }
17
+ /** The id of a source's own member: the one place a member id is written from its parts. */
18
+ const memberIdOf = (source, name) => `${source}.${name}`;
19
+ /**
20
+ * Whether a member id is on `source`: it starts with the source's name and a point. It says
21
+ * nothing of whether the member exists; it only spares parsing an id that cannot be the
22
+ * source's, where one is sought among many.
23
+ */
24
+ const isOnSource = (id, source) => id.startsWith(source) && id.charAt(source.length) === ".";
25
+ /**
26
+ * The entry a name from outside the model names in one of its maps: only the map's own, so
27
+ * `toString`, `constructor` or `__proto__` never reads what every object inherits.
28
+ */
29
+ function ownEntry(map, name) {
30
+ return map !== void 0 && Object.hasOwn(map, name) ? map[name] : void 0;
31
+ }
32
+ /** The source a name from outside the model names; none for a name the model does not have. */
33
+ const sourceOf = (model, name) => ownEntry(model.sources, name);
17
34
  function ownDimension(model, source, name) {
18
- const dimension = model.sources[source]?.dimensions[name];
35
+ const dimension = ownEntry(sourceOf(model, source)?.dimensions, name);
19
36
  return dimension === void 0 ? void 0 : {
20
37
  source,
21
38
  dimension
22
39
  };
23
40
  }
24
41
  function joinedDimension(model, source, join, name) {
25
- const def = model.sources[source]?.joins?.[join];
42
+ const def = ownEntry(sourceOf(model, source)?.joins, join);
26
43
  if (def === void 0 || def.relationship === "one_to_many") return void 0;
27
- const dimension = model.sources[def.to]?.dimensions[name];
44
+ const dimension = ownEntry(sourceOf(model, def.to)?.dimensions, name);
28
45
  return dimension === void 0 ? void 0 : {
29
46
  source: def.to,
30
47
  join,
@@ -32,6 +49,16 @@ function joinedDimension(model, source, join, name) {
32
49
  };
33
50
  }
34
51
  /**
52
+ * The type of value a dimension holds, the one owner of it: a number, a boolean or a time as
53
+ * declared, an expression as its `type`, and text for the rest (a string, a ref to a joined
54
+ * label, a bucket's labels).
55
+ */
56
+ function dimensionValueType(def) {
57
+ if (def.kind === "number" || def.kind === "boolean" || def.kind === "time") return def.kind;
58
+ if (def.kind === "expr") return def.type;
59
+ return "string";
60
+ }
61
+ /**
35
62
  * The dimension a member id names, seen from `sourceName`: own, or one hop through a join
36
63
  * that reaches at most one row. Undefined when it does not exist.
37
64
  */
@@ -44,7 +71,7 @@ function resolveDimension(model, sourceName, id) {
44
71
  function resolveMeasure(model, sourceName, id) {
45
72
  const ref = parseMemberId(id);
46
73
  if (ref === void 0 || ref.source !== sourceName || ref.join !== void 0) return void 0;
47
- return model.sources[sourceName]?.measures[ref.name];
74
+ return ownEntry(sourceOf(model, sourceName)?.measures, ref.name);
48
75
  }
49
76
  /** A dimension's place in a default records view: text first, then time, then the rest. */
50
77
  function shownRank(def, isTime) {
@@ -61,7 +88,7 @@ const DEFAULT_RECORD_COLUMNS = 12;
61
88
  * records endpoint and a drill's Items.
62
89
  */
63
90
  function recordDimensions(model, sourceName) {
64
- const def = model.sources[sourceName];
91
+ const def = sourceOf(model, sourceName);
65
92
  if (def === void 0) return [];
66
93
  const title = def.records?.title;
67
94
  const named = title !== void 0 && def.dimensions[title] !== void 0 ? title : void 0;
@@ -76,4 +103,4 @@ function recordDimensions(model, sourceName) {
76
103
  * check holds a merge to the measure's kind, so this is true only of a count or a sum.
77
104
  */
78
105
  const mergesBySum = (def) => def.merge === "sum";
79
- export { mergesBySum, parseMemberId, recordDimensions, resolveDimension, resolveMeasure };
106
+ export { dimensionValueType, isOnSource, memberIdOf, mergesBySum, ownEntry, parseMemberId, recordDimensions, resolveDimension, resolveMeasure, sourceOf };
@@ -1,17 +1,49 @@
1
- import { resolveMeasure } from "./member.mjs";
1
+ import { resolveDimension, resolveMeasure } from "./member.mjs";
2
2
  import { exprLinearTerms } from "./validate/expr.mjs";
3
3
  // src/model/storage.ts
4
- function decimalOf(model, source, def) {
4
+ function exactOf(model, source, def) {
5
5
  if (def.kind === "ratio") {
6
6
  const measures = model.sources[source]?.measures ?? {};
7
7
  return [def.numerator, def.denominator].flatMap((name) => {
8
8
  const operand = measures[name];
9
- return operand === void 0 ? [] : decimalOf(model, source, operand);
9
+ return operand === void 0 ? [] : exactOf(model, source, operand);
10
10
  });
11
11
  }
12
- if (def.kind === "count" || def.kind === "percentile") return [];
13
- if (def.numeric === "float" || def.numeric.stored !== "decimal") return [];
14
- return exprLinearTerms(def.of).map((t) => t.column);
12
+ if (def.kind === "count" || def.kind === "percentile" || def.numeric === "float") return [];
13
+ const numeric = def.numeric;
14
+ return exprLinearTerms(def.of).map((t) => ({
15
+ kind: "exact",
16
+ column: t.column,
17
+ numeric
18
+ }));
19
+ }
20
+ function timeOf(model, query) {
21
+ if (query.time === void 0) return [];
22
+ const resolved = resolveDimension(model, query.source, query.time.dimension);
23
+ if (resolved?.join !== void 0 || resolved?.dimension.kind !== "time") return [];
24
+ return [{
25
+ kind: "time",
26
+ column: resolved.dimension.column,
27
+ storage: resolved.dimension.storage
28
+ }];
29
+ }
30
+ /**
31
+ * The stored columns a query reads by their storage, each once, in the one order every engine
32
+ * counts them in: its time dimension's column, then each exact measure's columns. A value of
33
+ * one of them that does not read is left out of the answer and counted (`Unread`).
34
+ */
35
+ function readColumns(model, query) {
36
+ const exact = query.measures.flatMap((m) => {
37
+ const def = resolveMeasure(model, query.source, m.measure);
38
+ return def === void 0 ? [] : exactOf(model, query.source, def);
39
+ });
40
+ const seen = /* @__PURE__ */ new Set();
41
+ return [...timeOf(model, query), ...exact].filter((c) => {
42
+ const id = `${c.kind} ${c.column}`;
43
+ if (seen.has(id)) return false;
44
+ seen.add(id);
45
+ return true;
46
+ });
15
47
  }
16
48
  /**
17
49
  * The `decimal` columns a query's exact measures read. A Postgres `numeric` column can hold
@@ -19,10 +51,6 @@ function decimalOf(model, source, def) {
19
51
  * filtered rows and refuses with NUMERIC_STORAGE before any answer is returned.
20
52
  */
21
53
  function decimalColumns(model, query) {
22
- const columns = query.measures.flatMap((m) => {
23
- const def = resolveMeasure(model, query.source, m.measure);
24
- return def === void 0 ? [] : decimalOf(model, query.source, def);
25
- });
26
- return [...new Set(columns)];
54
+ return readColumns(model, query).flatMap((c) => c.kind === "exact" && c.numeric.stored === "decimal" ? [c.column] : []);
27
55
  }
28
- export { decimalColumns };
56
+ export { decimalColumns, readColumns };
@@ -140,6 +140,8 @@ export type SourceDef = SourceRelation & {
140
140
  prefer: readonly string[];
141
141
  };
142
142
  };
143
+ /** Which way a measure's or a calc's change is for the better. */
144
+ export type Better = "higher" | "lower";
143
145
  export type MemberMeta = {
144
146
  label?: string;
145
147
  description?: string;
@@ -161,7 +163,10 @@ export type Numeric = "float" | {
161
163
  type OverColumn = {
162
164
  of: Column | Expr;
163
165
  where?: WireFilter;
164
- /** `duration`: the values are seconds, shown as "3.7 days", "2 h". */
166
+ /**
167
+ * `duration`: the values are seconds, shown as "3.7 days", "2 h". A measure over an `elapsed`
168
+ * alone is a duration without saying so, read in the microseconds it counts.
169
+ */
165
170
  format?: "duration";
166
171
  /** Reserved for snapshot measures (the last value per partition). Refused by the model check until computed. */
167
172
  partitionBy?: DimensionName;
@@ -170,6 +175,12 @@ type OverColumn = {
170
175
  export type MeasureDef = MemberMeta & {
171
176
  /** How partial results combine. `none` means they cannot be combined. */
172
177
  merge: "sum" | "min" | "max" | "none";
178
+ /**
179
+ * Which way a change of it is for the better: more revenue is better, more churn is worse.
180
+ * A change is coloured only where this is said; the library never guesses it. A ratio's is
181
+ * its own, never its numerator's.
182
+ */
183
+ better?: Better;
173
184
  } & ({
174
185
  kind: "count";
175
186
  distinct?: Column;
@@ -234,6 +245,11 @@ export type DimensionDef = MemberMeta & DimensionHints & ({
234
245
  expr: Expr;
235
246
  type: "string" | "number" | "boolean";
236
247
  });
248
+ /**
249
+ * `round` is to the nearest whole number, a half toward +∞ (JavaScript's `Math.round`): it is
250
+ * `floor(x)`, or `ceil(x)` when `x - floor(x) >= 0.5`, a difference that is exact in a double.
251
+ * Every engine writes it so; `floor(x + 0.5)` is not it, as that sum is itself rounded.
252
+ */
237
253
  export declare const EXPR_FUNCTIONS: readonly ["coalesce", "abs", "round", "length", "lower_fold"];
238
254
  export type ExprFunction = (typeof EXPR_FUNCTIONS)[number];
239
255
  export type DatePart = "year" | "quarter" | "month" | "week" | "day" | "hour" | "dow";
@@ -1,4 +1,9 @@
1
1
  // src/model/types.ts
2
+ /**
3
+ * `round` is to the nearest whole number, a half toward +∞ (JavaScript's `Math.round`): it is
4
+ * `floor(x)`, or `ceil(x)` when `x - floor(x) >= 0.5`, a difference that is exact in a double.
5
+ * Every engine writes it so; `floor(x + 0.5)` is not it, as that sum is itself rounded.
6
+ */
2
7
  const EXPR_FUNCTIONS = [
3
8
  "coalesce",
4
9
  "abs",
@@ -1,10 +1,4 @@
1
- import { Expr } from "../types.mjs";
2
1
  export type LinearTerm = {
3
2
  coefficient: number;
4
3
  column: string;
5
- };
6
- /**
7
- * Reads an expression as c1*x1 + c2*x2 + ... with whole-number coefficients. Returns
8
- * undefined when it is anything else.
9
- */
10
- export declare function linearTerms(expr: Expr): LinearTerm[] | undefined;
4
+ };
@@ -0,0 +1,2 @@
1
+ /** The offer for a mistyped name: the known name it most likely meant, in `meant`'s words. */
2
+ export declare const didYouMean: (key: string, known: readonly string[]) => string;
@@ -17,17 +17,24 @@ function distance(a, b) {
17
17
  }
18
18
  return row[across.length] ?? 0;
19
19
  }
20
- /** The known field a misspelled one most likely meant: at most two edits away, and under half its letters. */
21
- function nearest(key, known) {
22
- const [best] = known.map((name) => ({
20
+ /**
21
+ * The known fields a misspelled one may have meant, the likeliest first: each at most two edits
22
+ * away, and under half its letters.
23
+ */
24
+ function nearTo(key, known) {
25
+ return known.map((name) => ({
23
26
  name,
24
27
  edits: distance(key.toLowerCase(), name.toLowerCase())
25
- })).toSorted((x, y) => x.edits - y.edits);
26
- return best !== void 0 && best.edits <= 2 && best.edits * 2 <= key.length ? best.name : void 0;
28
+ })).filter(({ edits }) => edits <= 2 && edits * 2 <= key.length).toSorted((x, y) => x.edits - y.edits).map(({ name }) => name);
27
29
  }
30
+ /** The known field a misspelled one most likely meant (`nearTo`); none when none is near. */
31
+ const nearest = (key, known) => nearTo(key, known)[0];
32
+ /** The one way a message offers a name: ` Did you mean "x"?`, or nothing when there is none. */
28
33
  const meant = (near) => near === void 0 ? "" : ` Did you mean "${near}"?`;
34
+ /** The offer for a mistyped name: the known name it most likely meant, in `meant`'s words. */
35
+ const didYouMean = (key, known) => meant(nearest(key, known));
29
36
  function unknownField(what, key, known) {
30
- return `"${key}" is not a field of ${what}.${meant(nearest(key, known))} Its fields are ${known.join(", ")}.`;
37
+ return `"${key}" is not a field of ${what}.${didYouMean(key, known)} Its fields are ${known.join(", ")}.`;
31
38
  }
32
39
  /** What a value is, in a word, for a message that says what it should have been. */
33
40
  function kindOf(value) {
@@ -127,4 +134,4 @@ function lacking(what, keys) {
127
134
  return [issue("MODEL_SHAPE", path, `${what} holds one of ${keys.join(", ")}.${meant(near)}`)];
128
135
  };
129
136
  }
130
- export { byKey, byKind, fields, lacking, listOf, mapOf, nearest, orFalse, orWord, orWords, wordOrList };
137
+ export { byKey, byKind, didYouMean, fields, lacking, listOf, mapOf, meant, nearTo, nearest, orFalse, orWord, orWords, wordOrList };
@@ -11,7 +11,11 @@ function when(condition, code, path, message) {
11
11
  return condition ? [issue(code, path, message)] : [];
12
12
  }
13
13
  const IDENTIFIER = /^[a-z][a-z0-9_]*$/iu;
14
+ /** Names JavaScript objects reserve: as a key they would set or shadow an object's prototype. */
15
+ const RESERVED_KEY = /^(?:__proto__|constructor|prototype)$/u;
16
+ /** A model name: an identifier, and never a name objects reserve (input map keys share the list). */
14
17
  function nameIssues(name, path) {
18
+ if (RESERVED_KEY.test(name)) return [issue("NAME_INVALID", path, `"${name}" is reserved and cannot be a name; pick another.`)];
15
19
  return when(!IDENTIFIER.test(name), "NAME_INVALID", path, `"${name}" is not a valid name.`);
16
20
  }
17
- export { issue, nameIssues, when };
21
+ export { RESERVED_KEY, issue, nameIssues, when };
@@ -7,6 +7,7 @@ const META = [
7
7
  "sensitive",
8
8
  "hidden"
9
9
  ];
10
+ const MEASURE_META = [...META, "better"];
10
11
  const HINTS = [
11
12
  "drill",
12
13
  "format",
@@ -31,7 +32,7 @@ const SUMMED = fields("a sum, min or max measure", fieldsOf()([
31
32
  "numeric",
32
33
  "unit",
33
34
  ...OVER,
34
- ...META
35
+ ...MEASURE_META
35
36
  ]), over);
36
37
  const MEASURE = byKind("a measure", {
37
38
  count: fields("a count measure", fieldsOf()([
@@ -39,7 +40,7 @@ const MEASURE = byKind("a measure", {
39
40
  "merge",
40
41
  "distinct",
41
42
  "where",
42
- ...META
43
+ ...MEASURE_META
43
44
  ]), { where: filter }),
44
45
  sum: SUMMED,
45
46
  min: SUMMED,
@@ -50,7 +51,7 @@ const MEASURE = byKind("a measure", {
50
51
  "numeric",
51
52
  "unit",
52
53
  ...OVER,
53
- ...META
54
+ ...MEASURE_META
54
55
  ]), over),
55
56
  percentile: fields("a percentile measure", fieldsOf()([
56
57
  "kind",
@@ -58,7 +59,7 @@ const MEASURE = byKind("a measure", {
58
59
  "p",
59
60
  "unit",
60
61
  ...OVER,
61
- ...META
62
+ ...MEASURE_META
62
63
  ]), over),
63
64
  ratio: fields("a ratio measure", fieldsOf()([
64
65
  "kind",
@@ -66,7 +67,7 @@ const MEASURE = byKind("a measure", {
66
67
  "numerator",
67
68
  "denominator",
68
69
  "format",
69
- ...META
70
+ ...MEASURE_META
70
71
  ]))
71
72
  });
72
73
  const STORAGE = byKey("a time storage", {
@@ -42,6 +42,28 @@ const isObject = (v) => typeof v === "object" && v !== null;
42
42
  const known = (list, value) => list.includes(value);
43
43
  const shape = (path, message) => issue("MODEL_SHAPE", path, message);
44
44
  const oneOf = (list) => list.map((v) => JSON.stringify(v)).join(", ");
45
+ const MEASURE_KIND = {
46
+ field: "kind",
47
+ what: "measure kind",
48
+ list: MEASURE_KINDS
49
+ };
50
+ const MERGE = {
51
+ field: "merge",
52
+ what: "merge",
53
+ list: MERGES
54
+ };
55
+ const DIMENSION_KIND = {
56
+ field: "kind",
57
+ what: "dimension kind",
58
+ list: DIMENSION_KINDS
59
+ };
60
+ /** A field that is one of a list: named as missing when it is, else its value is named. */
61
+ function oneOfField(m, { field, what, list }, path) {
62
+ const value = m[field];
63
+ if (known(list, value)) return [];
64
+ const message = value === void 0 ? `"${field}" is missing: one of ${oneOf(list)}.` : `${JSON.stringify(value)} is not a ${what}: ${oneOf(list)}.`;
65
+ return [shape([...path, field], message)];
66
+ }
45
67
  /** Fields a kind needs, each named when missing. */
46
68
  function needs(m, fields, path) {
47
69
  return fields.flatMap((f) => m[f] === void 0 ? [shape([...path, f], `A ${String(m["kind"])} needs "${f}".`)] : []);
@@ -49,11 +71,21 @@ function needs(m, fields, path) {
49
71
  function unitShape(unit, path) {
50
72
  return unit === void 0 || typeof unit === "string" ? [] : [shape([...path, "unit"], "A measure unit is a string, such as \"USD\".")];
51
73
  }
74
+ const BETTER = ["higher", "lower"];
75
+ /** Which way is better, when a measure says: a renderer colours a change by it, so it must be one it reads. */
76
+ function betterShape(better, path) {
77
+ return better === void 0 || known(BETTER, better) ? [] : [shape([...path, "better"], "A measure's better is \"higher\" or \"lower\".")];
78
+ }
52
79
  function measureShape(m, path) {
53
80
  if (!isObject(m)) return [shape(path, "A measure is an object.")];
54
- if (!known(MEASURE_KINDS, m["kind"])) return [shape([...path, "kind"], `"${String(m["kind"])}" is not a measure kind: ${oneOf(MEASURE_KINDS)}.`)];
81
+ const kind = oneOfField(m, MEASURE_KIND, path);
82
+ if (kind.length > 0) return kind;
83
+ return [...kindShape(m, path), ...betterShape(m["better"], path)];
84
+ }
85
+ /** The fields a measure's kind needs, and the values they may take. */
86
+ function kindShape(m, path) {
55
87
  if (m["kind"] === "ratio") return needs(m, ["numerator", "denominator"], path);
56
- const merge = known(MERGES, m["merge"]) ? [] : [shape([...path, "merge"], `"${String(m["merge"])}" is not a merge: ${oneOf(MERGES)}.`)];
88
+ const merge = oneOfField(m, MERGE, path);
57
89
  if (m["kind"] === "count") return merge;
58
90
  const fields = m["kind"] === "percentile" ? ["of", "p"] : ["of", "numeric"];
59
91
  const p = m["kind"] === "percentile" && m["p"] !== void 0 && !known(PERCENTILES, m["p"]) ? [shape([...path, "p"], `A percentile is one of ${oneOf(PERCENTILES)}.`)] : [];
@@ -85,7 +117,8 @@ const DIMENSION_NEEDS = {
85
117
  function dimensionShape(d, path) {
86
118
  if (!isObject(d)) return [shape(path, "A dimension is an object.")];
87
119
  const kind = d["kind"];
88
- if (typeof kind !== "string" || !known(DIMENSION_KINDS, kind)) return [shape([...path, "kind"], `"${String(kind)}" is not a dimension kind: ${oneOf(DIMENSION_KINDS)}.`)];
120
+ const unknown = oneOfField(d, DIMENSION_KIND, path);
121
+ if (typeof kind !== "string" || unknown.length > 0) return unknown;
89
122
  const missing = needs(d, DIMENSION_NEEDS[kind] ?? [], path);
90
123
  if (missing.length > 0) return missing;
91
124
  if (kind === "time") return storageShape(d["storage"], [...path, "storage"]);
@@ -1,4 +1,4 @@
1
- import { tenantKeys } from "../defaults.mjs";
1
+ import { tenantEntry, tenantKeys } from "../defaults.mjs";
2
2
  import { drillIssues } from "./drill.mjs";
3
3
  import { modelFilterIssues } from "./filter.mjs";
4
4
  import { issue, nameIssues, when } from "./issues.mjs";
@@ -61,7 +61,7 @@ function tenantIssues(model, source, path) {
61
61
  if (tenant === void 0) return when(keys.length > 0, "TENANT_BINDING_MISSING", path, "The model has tenant keys, so every source must say how it is tied to them (or that it is shared).");
62
62
  if ("via" in tenant) return viaJoinIssues(source, tenant.via, [...path, "via"]);
63
63
  if (!("columns" in tenant)) return sharedIssues(tenant, path);
64
- return [...keys.flatMap((key) => when((tenant.columns[key] ?? "") === "", "TENANT_COLUMN_MISSING", [
64
+ return [...keys.flatMap((key) => when((tenantEntry(tenant.columns, key) ?? "") === "", "TENANT_COLUMN_MISSING", [
65
65
  ...path,
66
66
  "columns",
67
67
  key
@@ -1,5 +1,6 @@
1
1
  import { QueryRefusalCode } from "../error/codes.mjs";
2
2
  import { Model } from "../model/types.mjs";
3
+ import { Unread } from "../value/stored.mjs";
3
4
  import { LockEntry } from "../query/compose.mjs";
4
5
  import { BoundFilter } from "../query/filter.mjs";
5
6
  import { Calendar, WireQuery } from "../query/types.mjs";
@@ -32,6 +33,7 @@ export type OracleInput = {
32
33
  calendar: Calendar;
33
34
  };
34
35
  export declare class OracleError extends Error {
35
- readonly code: QueryRefusalCode | "NUMERIC_STORAGE" | "PLAN_ASSERTION";
36
+ readonly code: QueryRefusalCode | "NUMERIC_STORAGE" | "PLAN_ASSERTION" | "QUERY_INVALID";
36
37
  constructor(code: OracleError["code"], message: string);
37
- }
38
+ }
39
+ export type { Unread };
@@ -1,5 +1,16 @@
1
+ import { Unread } from "../value/stored.mjs";
1
2
  import { Cell } from "../query/types.mjs";
2
3
  import "./data.mjs";
4
+ /**
5
+ * With `time.whole`: the answer of the query without its grain (`withoutGrain`), its rows in
6
+ * the layout `[...dimensions, ...measures, ...calcs]`, Other and totals one row each.
7
+ */
8
+ type OracleWhole = {
9
+ rows: Cell[][];
10
+ other?: Cell[][];
11
+ totals?: Cell[][];
12
+ segmentOther?: Cell[][];
13
+ };
3
14
  /** Rows are `[bucket?, ...dimensions, ...measures, ...calcs]`; Other and totals have one row per bucket. */
4
15
  export type OracleResult = {
5
16
  columns: string[];
@@ -8,6 +19,8 @@ export type OracleResult = {
8
19
  totals?: Cell[][];
9
20
  /** With a dimension's `other`: the values its limit left out. */
10
21
  segmentOther?: Cell[][];
22
+ /** With `time.whole`: the answer of the query without its grain. */
23
+ whole?: OracleWhole;
11
24
  /** The comparison period, restricted to the groups the main result has. */
12
25
  compare?: {
13
26
  rows: Cell[][];
@@ -17,7 +30,12 @@ export type OracleResult = {
17
30
  from: string;
18
31
  to: string;
19
32
  };
33
+ /** With `time.whole`: the comparison's whole, restricted to the groups the main whole has. */
34
+ whole?: Omit<OracleWhole, "other">;
20
35
  };
21
36
  /** Set when the principal can read no row of the fact source: no rows, not zeros. */
22
37
  unreadable?: true;
23
- };
38
+ /** Stored values left out because they do not read as their column's storage, by column. */
39
+ unread?: readonly Unread[];
40
+ };
41
+ export {};
@@ -1,3 +1,4 @@
1
+ import { answersWhole, withoutGrain } from "../query/fold.mjs";
1
2
  import { readsPrevious } from "../result/calc.mjs";
2
3
  import { comparator } from "../result/order.mjs";
3
4
  import { canonical } from "../value/canonical.mjs";
@@ -76,7 +77,9 @@ function secondOf(input) {
76
77
  }
77
78
  /**
78
79
  * `whole`: the query whose rows the totals and `total` refs read, when not `input.query`
79
- * (the uncut query, for a query whose dimensions have cuts).
80
+ * (the uncut query, for a query whose dimensions have cuts). With `time.whole`, the answer also
81
+ * holds the query without its grain, read from the same rows, and so does its comparison: the
82
+ * comparison query without its grain, so it reads the span the comparison's rows read.
80
83
  */
81
84
  function evaluatePlain(input, whole) {
82
85
  if (unreadable(input)) return {
@@ -88,29 +91,72 @@ function evaluatePlain(input, whole) {
88
91
  ...input,
89
92
  query: whole
90
93
  };
91
- const main = answer(input, readOf(input), wholeInput && readOf(wholeInput));
94
+ const reads = {
95
+ own: readOf(input),
96
+ whole: wholeInput && readOf(wholeInput)
97
+ };
98
+ const main = withWhole(answer(input, reads.own, reads.whole), foldOf(input, reads));
92
99
  const second = comparisonQuery(input);
93
100
  if (second === void 0) return main;
94
- return withCompare(input, main, answer({
101
+ const before = {
102
+ own: { rows: factRows({
103
+ ...input,
104
+ query: second.query
105
+ }) },
106
+ whole: wholeInput && secondOf(wholeInput)
107
+ };
108
+ const previous = answer({
95
109
  ...input,
96
110
  query: second.query
97
- }, { rows: factRows({
111
+ }, before.own, before.whole);
112
+ const folded = foldOf({
98
113
  ...input,
99
114
  query: second.query
100
- }) }, wholeInput && secondOf(wholeInput)), second.range);
115
+ }, before, answersWhole(input.query));
116
+ return withCompare(input, main, withWhole(previous, folded), second.range);
101
117
  }
102
- /** The comparison period's answer beside the main one, cut to the groups the main one has. */
118
+ /**
119
+ * The answer of the query without its grain over the same rows, when the query asks for its
120
+ * whole (`asked`, by default its own `time.whole`). A comparison query has no `time.whole` of
121
+ * its own: the query it compares for asks.
122
+ */
123
+ function foldOf(input, reads, asked = answersWhole(input.query)) {
124
+ if (!asked) return void 0;
125
+ const { columns: _columns, ...fold } = answer({
126
+ ...input,
127
+ query: withoutGrain(input.query)
128
+ }, reads.own, reads.whole);
129
+ return fold;
130
+ }
131
+ const withWhole = (result, whole) => whole === void 0 ? result : {
132
+ ...result,
133
+ whole
134
+ };
135
+ /** A comparison's rows cut to the groups `keys` holds, by their dimension cells after `offset`. */
136
+ function cutTo(rows, keys, offset, width) {
137
+ return rows.filter((row) => keys.has(canonical(row.slice(offset, offset + width))));
138
+ }
139
+ /** The groups of an answer's rows, by their dimension cells after `offset`. */
140
+ const groupKeys = (rows, offset, width) => new Set(rows.map((row) => canonical(row.slice(offset, offset + width))));
141
+ /**
142
+ * The comparison period's answer beside the main one, cut to the groups the main one has, and
143
+ * its whole cut to the groups the main whole has.
144
+ */
103
145
  function withCompare(input, main, previous, range) {
104
146
  const offset = input.query.time?.grain === void 0 ? 0 : 1;
105
147
  const width = (input.query.dimensions ?? []).length;
106
- const dimsOf = (row) => canonical(row.slice(offset, offset + width));
107
- const keys = new Set(main.rows.map((row) => dimsOf(row)));
148
+ const kept = groupKeys(main.rows, offset, width);
149
+ const whole = previous.whole === void 0 || main.whole === void 0 ? {} : { whole: {
150
+ rows: cutTo(previous.whole.rows, groupKeys(main.whole.rows, 0, width), 0, width),
151
+ ...previous.whole.totals === void 0 ? {} : { totals: previous.whole.totals }
152
+ } };
108
153
  return {
109
154
  ...main,
110
155
  compare: {
111
- rows: previous.rows.filter((row) => keys.has(dimsOf(row))),
156
+ rows: cutTo(previous.rows, kept, offset, width),
112
157
  ...previous.totals === void 0 ? {} : { totals: previous.totals },
113
- range
158
+ range,
159
+ ...whole
114
160
  }
115
161
  };
116
162
  }
@@ -60,7 +60,7 @@ function timeExpr(ctx, expr) {
60
60
  }
61
61
  const start = instantOf(ctx, expr.elapsed.start);
62
62
  const end = instantOf(ctx, expr.elapsed.end);
63
- return start === null || end === null ? null : end - start;
63
+ return start === null || end === null ? null : Number(end - start);
64
64
  }
65
65
  /** The value of a model expression on one row. Null in, null out, as in SQL. */
66
66
  function evalExpr(ctx, expr) {
@@ -41,6 +41,15 @@ function inRange(input, row) {
41
41
  * in any of those rows refuses the query (NUMERIC_STORAGE).
42
42
  */
43
43
  function factRows(input) {
44
+ const facts = scopedRows(input, true);
45
+ checkStorage(input, facts);
46
+ return facts;
47
+ }
48
+ /**
49
+ * The fact rows a query reads, by the same tests, with or without its range: without it, the
50
+ * rows whose time could not be placed in or out of the range are among them.
51
+ */
52
+ function scopedRows(input, ranged) {
44
53
  checkRequest(input);
45
54
  const filters = input.query.filters;
46
55
  if (filters !== void 0 && !isBound(filters)) throw new OracleError("FILTER_UNBOUND", "Resolve viewer values and variables before asking the oracle.");
@@ -53,20 +62,18 @@ function factRows(input) {
53
62
  policy: (row) => allowed(input, row),
54
63
  locks: (input.locks ?? []).map((e) => entry(e)),
55
64
  required: [...where, ...(input.required ?? []).map((e) => entry(e))],
56
- query: (row) => (filters === void 0 || evaluateFilter(filters, row, reader)) && inRange(input, row),
65
+ query: (row) => (filters === void 0 || evaluateFilter(filters, row, reader)) && (!ranged || inRange(input, row)),
57
66
  deltas: []
58
67
  };
59
68
  const tests = effectiveFilter(parts).all;
60
- const facts = (input.data[source] ?? []).map((data) => ({
69
+ return (input.data[source] ?? []).map((data) => ({
61
70
  source,
62
71
  data
63
72
  })).filter((row) => tests.every((test) => test(row)));
64
- checkStorage(input, facts);
65
- return facts;
66
73
  }
67
74
  /** Checks the request like `factRows`, then says whether the principal can read no row of the fact. */
68
75
  function unreadable(input) {
69
76
  factRows(input);
70
77
  return !readable(input, input.query.source);
71
78
  }
72
- export { factRows, unreadable };
79
+ export { factRows, scopedRows, unreadable };
@@ -1,4 +1,4 @@
1
- import { storedExact } from "../exact/decimal.mjs";
1
+ import { storedExact } from "../exact/stored.mjs";
2
2
  import { sumLinear } from "../exact/sum.mjs";
3
3
  import { exprLinearTerms } from "../model/validate/expr.mjs";
4
4
  import { cellOf, divide, exactNum, numOf } from "../result/number.mjs";