derive-dashboards 0.7.1 → 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 (591) 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 +86 -44
  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 -32
  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 +51 -9
  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 +12 -6
  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/marks/x-axis.mjs +3 -2
  109. package/dist/charts/scale/calendar.mjs +41 -26
  110. package/dist/charts/scale/linear.mjs +58 -0
  111. package/dist/charts/scale/value.d.mts +21 -0
  112. package/dist/charts/scale/value.mjs +67 -9
  113. package/dist/charts/scene/lazy.mjs +27 -0
  114. package/dist/charts/scene/markup.mjs +2 -1
  115. package/dist/charts/scene/svg.mjs +20 -8
  116. package/dist/charts/scene/types.d.mts +34 -0
  117. package/dist/charts/text/measure.mjs +33 -3
  118. package/dist/charts/theme.d.mts +25 -25
  119. package/dist/charts/theme.mjs +47 -30
  120. package/dist/charts-react/Chart.d.mts +20 -0
  121. package/dist/charts-react/Chart.mjs +9 -67
  122. package/dist/charts-react/Reader.mjs +50 -96
  123. package/dist/charts-react/box.mjs +106 -0
  124. package/dist/charts-react/bucket-names.mjs +9 -24
  125. package/dist/charts-react/columns-picture.mjs +12 -0
  126. package/dist/charts-react/exact-sum.mjs +4 -7
  127. package/dist/charts-react/from-answer.mjs +9 -4
  128. package/dist/charts-react/index.d.mts +9 -2
  129. package/dist/charts-react/index.mjs +9 -2
  130. package/dist/charts-react/kinds/area.d.mts +4 -0
  131. package/dist/charts-react/kinds/area.mjs +38 -0
  132. package/dist/charts-react/kinds/bar.d.mts +4 -0
  133. package/dist/charts-react/kinds/bar.mjs +15 -0
  134. package/dist/charts-react/kinds/funnel.d.mts +4 -0
  135. package/dist/charts-react/kinds/funnel.mjs +13 -0
  136. package/dist/charts-react/kinds/heatmap.d.mts +4 -0
  137. package/dist/charts-react/kinds/heatmap.mjs +13 -0
  138. package/dist/charts-react/kinds/line.d.mts +4 -0
  139. package/dist/charts-react/kinds/line.mjs +20 -0
  140. package/dist/charts-react/kinds/multiples.d.mts +4 -0
  141. package/dist/charts-react/kinds/multiples.mjs +33 -0
  142. package/dist/charts-react/kinds/number.d.mts +5 -0
  143. package/dist/charts-react/kinds/number.mjs +86 -0
  144. package/dist/charts-react/plan-bars.mjs +15 -8
  145. package/dist/charts-react/plan-funnel.mjs +3 -1
  146. package/dist/charts-react/plan-grid.mjs +14 -5
  147. package/dist/charts-react/plan-of.mjs +17 -0
  148. package/dist/charts-react/plan-parts.mjs +16 -5
  149. package/dist/charts-react/plan-time.mjs +4 -53
  150. package/dist/charts-react/reader-page.d.mts +1 -1
  151. package/dist/charts-react/reader-page.mjs +19 -9
  152. package/dist/charts-react/renderers.d.mts +14 -0
  153. package/dist/charts-react/renderers.mjs +22 -0
  154. package/dist/charts-react/table.d.mts +1 -0
  155. package/dist/charts-react/table.mjs +108 -0
  156. package/dist/charts-react/tiles.mjs +21 -49
  157. package/dist/charts-react/useScene.mjs +45 -17
  158. package/dist/charts-react/words.mjs +19 -0
  159. package/dist/checks.mjs +97 -19
  160. package/dist/cli/add.mjs +4 -3
  161. package/dist/cli/doctor.mjs +2 -2
  162. package/dist/core/conformance/index.d.mts +5 -2
  163. package/dist/core/conformance/index.mjs +5 -2
  164. package/dist/core/conformance/memory/aggregate.mjs +11 -6
  165. package/dist/core/conformance/memory/rows.d.mts +7 -3
  166. package/dist/core/conformance/memory/rows.mjs +19 -13
  167. package/dist/core/conformance/memory/source.mjs +4 -4
  168. package/dist/core/document/control-fields.d.mts +20 -0
  169. package/dist/core/document/control-fields.mjs +117 -0
  170. package/dist/core/document/display-comparisons.d.mts +17 -0
  171. package/dist/core/document/display-comparisons.mjs +15 -4
  172. package/dist/core/document/display-entries.d.mts +14 -0
  173. package/dist/core/document/display-entries.mjs +25 -9
  174. package/dist/core/document/display-validation.d.mts +5 -1
  175. package/dist/core/document/display-validation.mjs +14 -7
  176. package/dist/core/document/display.d.mts +11 -8
  177. package/dist/core/document/display.mjs +26 -3
  178. package/dist/core/document/layout.d.mts +8 -9
  179. package/dist/core/document/layout.mjs +23 -6
  180. package/dist/core/document/stacked.d.mts +0 -7
  181. package/dist/core/document/types.mjs +8 -6
  182. package/dist/core/document/upgrade.d.mts +1 -0
  183. package/dist/core/document/upgrade.mjs +4 -2
  184. package/dist/core/engine/access.mjs +3 -3
  185. package/dist/core/engine/assert.mjs +4 -2
  186. package/dist/core/engine/bucket.mjs +2 -2
  187. package/dist/core/engine/checks.mjs +6 -7
  188. package/dist/core/engine/custom/ask.mjs +22 -2
  189. package/dist/core/engine/custom/cells.mjs +22 -22
  190. package/dist/core/engine/custom/level.mjs +12 -13
  191. package/dist/core/engine/custom/measures.mjs +12 -9
  192. package/dist/core/engine/custom/reader.mjs +3 -1
  193. package/dist/core/engine/custom/records.mjs +8 -7
  194. package/dist/core/engine/custom/unread.mjs +78 -0
  195. package/dist/core/engine/custom/where.mjs +15 -10
  196. package/dist/core/engine/index.d.mts +2 -13
  197. package/dist/core/engine/index.mjs +2 -12
  198. package/dist/core/engine/measure.mjs +1 -0
  199. package/dist/core/engine/members.mjs +7 -3
  200. package/dist/core/engine/nan.mjs +10 -1
  201. package/dist/core/engine/native.mjs +2 -20
  202. package/dist/core/engine/numbers.mjs +26 -14
  203. package/dist/core/engine/postgres.mjs +9 -5
  204. package/dist/core/engine/prepare.mjs +4 -4
  205. package/dist/core/engine/rank-sets.mjs +1 -1
  206. package/dist/core/engine/read.mjs +5 -4
  207. package/dist/core/engine/reader.d.mts +6 -0
  208. package/dist/core/engine/record-layout.mjs +3 -3
  209. package/dist/core/engine/run.mjs +77 -20
  210. package/dist/core/engine/segmented.d.mts +2 -1
  211. package/dist/core/engine/segmented.mjs +19 -12
  212. package/dist/core/engine/series.mjs +1 -1
  213. package/dist/core/engine/shape.mjs +8 -8
  214. package/dist/core/engine/sql-partition.mjs +2 -2
  215. package/dist/core/engine/sql-pass.mjs +3 -2
  216. package/dist/core/engine/sql-reader.mjs +13 -5
  217. package/dist/core/engine/sql-reads.mjs +2 -1
  218. package/dist/core/engine/sql-records.mjs +2 -2
  219. package/dist/core/engine/sql-split.mjs +1 -1
  220. package/dist/core/engine/sql-unread.mjs +70 -0
  221. package/dist/core/engine/time.mjs +2 -1
  222. package/dist/core/engine/types.d.mts +17 -0
  223. package/dist/core/engine/version.d.mts +1 -1
  224. package/dist/core/engine/version.mjs +1 -1
  225. package/dist/core/error/codes.d.mts +24 -1
  226. package/dist/core/error/codes.mjs +23 -3
  227. package/dist/core/error/refusal.d.mts +8 -3
  228. package/dist/core/error/refusal.mjs +6 -1
  229. package/dist/core/exact/decimal.d.mts +1 -14
  230. package/dist/core/exact/decimal.mjs +9 -19
  231. package/dist/core/exact/stored.d.mts +9 -0
  232. package/dist/core/exact/stored.mjs +38 -0
  233. package/dist/core/exact/text.d.mts +16 -1
  234. package/dist/core/exact/text.mjs +50 -1
  235. package/dist/core/format/digits.mjs +55 -0
  236. package/dist/core/format/index.d.mts +16 -0
  237. package/dist/core/format/index.mjs +27 -0
  238. package/dist/core/format/number.d.mts +27 -0
  239. package/dist/core/format/number.mjs +158 -0
  240. package/dist/core/format/write.d.mts +6 -0
  241. package/dist/core/format/write.mjs +57 -0
  242. package/dist/core/index.d.mts +43 -33
  243. package/dist/core/index.mjs +31 -28
  244. package/dist/core/model/defaults.d.mts +18 -1
  245. package/dist/core/model/defaults.mjs +19 -1
  246. package/dist/core/model/define.d.mts +17 -8
  247. package/dist/core/model/define.mjs +2 -0
  248. package/dist/core/model/member.d.mts +5 -3
  249. package/dist/core/model/member.mjs +33 -6
  250. package/dist/core/model/storage.mjs +40 -12
  251. package/dist/core/model/types.d.mts +17 -1
  252. package/dist/core/model/types.mjs +5 -0
  253. package/dist/core/model/validate/expr.d.mts +1 -7
  254. package/dist/core/model/validate/fields.d.mts +2 -0
  255. package/dist/core/model/validate/fields.mjs +14 -7
  256. package/dist/core/model/validate/issues.mjs +5 -1
  257. package/dist/core/model/validate/known-members.mjs +6 -5
  258. package/dist/core/model/validate/shape.mjs +36 -3
  259. package/dist/core/model/validate/source.mjs +2 -2
  260. package/dist/core/oracle/data.d.mts +4 -2
  261. package/dist/core/oracle/evaluate.d.mts +19 -1
  262. package/dist/core/oracle/evaluate.mjs +56 -10
  263. package/dist/core/oracle/expr.mjs +1 -1
  264. package/dist/core/oracle/facts.mjs +12 -5
  265. package/dist/core/oracle/measure.mjs +1 -1
  266. package/dist/core/oracle/request.mjs +39 -4
  267. package/dist/core/oracle/segmented.d.mts +3 -1
  268. package/dist/core/oracle/segmented.mjs +19 -13
  269. package/dist/core/oracle/unread.mjs +32 -0
  270. package/dist/core/oracle/visibility.mjs +4 -3
  271. package/dist/core/policy/bind.d.mts +2 -11
  272. package/dist/core/policy/bind.mjs +1 -1
  273. package/dist/core/policy/match.mjs +1 -1
  274. package/dist/core/query/closure.d.mts +7 -2
  275. package/dist/core/query/closure.mjs +29 -12
  276. package/dist/core/query/compose-tile.d.mts +3 -2
  277. package/dist/core/query/compose-tile.mjs +32 -13
  278. package/dist/core/query/compose.d.mts +0 -5
  279. package/dist/core/query/drill/internal.d.mts +5 -5
  280. package/dist/core/query/drill/internal.mjs +11 -0
  281. package/dist/core/query/drill/links.d.mts +2 -3
  282. package/dist/core/query/drill/links.mjs +18 -4
  283. package/dist/core/query/drill/selection.d.mts +8 -2
  284. package/dist/core/query/drill/selection.mjs +14 -3
  285. package/dist/core/query/drill/synthetic.mjs +1 -1
  286. package/dist/core/query/drill/time.mjs +11 -10
  287. package/dist/core/query/filter.d.mts +1 -6
  288. package/dist/core/query/filter.mjs +1 -4
  289. package/dist/core/query/fold.mjs +23 -0
  290. package/dist/core/query/segments.mjs +42 -3
  291. package/dist/core/query/to-wire.d.mts +7 -0
  292. package/dist/core/query/to-wire.mjs +14 -2
  293. package/dist/core/query/types.d.mts +30 -13
  294. package/dist/core/result/columns.mjs +23 -13
  295. package/dist/core/result/number.mjs +3 -3
  296. package/dist/core/result/status.d.mts +13 -0
  297. package/dist/core/result/status.mjs +18 -0
  298. package/dist/core/result/time-axis.d.mts +14 -13
  299. package/dist/core/result/time-axis.mjs +20 -2
  300. package/dist/core/result/types.d.mts +33 -3
  301. package/dist/core/result/whole.d.mts +23 -0
  302. package/dist/core/result/whole.mjs +27 -0
  303. package/dist/core/schema/agent-query.d.mts +89 -0
  304. package/dist/core/schema/agent-query.mjs +115 -0
  305. package/dist/core/schema/aliases.mjs +1 -52
  306. package/dist/core/schema/answer-parts.mjs +17 -13
  307. package/dist/core/schema/answers.d.mts +787 -319
  308. package/dist/core/schema/commands.d.mts +33 -23
  309. package/dist/core/schema/commands.mjs +26 -18
  310. package/dist/core/schema/custom.mjs +46 -45
  311. package/dist/core/schema/document.d.mts +32 -27
  312. package/dist/core/schema/document.mjs +61 -81
  313. package/dist/core/schema/drill-answers.mjs +4 -1
  314. package/dist/core/schema/drill.d.mts +14 -9
  315. package/dist/core/schema/drill.mjs +23 -22
  316. package/dist/core/schema/index.d.mts +5 -3
  317. package/dist/core/schema/index.mjs +5 -3
  318. package/dist/core/schema/options.d.mts +92 -0
  319. package/dist/core/schema/options.mjs +104 -0
  320. package/dist/core/schema/picks.d.mts +2 -2
  321. package/dist/core/schema/picks.mjs +7 -6
  322. package/dist/core/schema/query.d.mts +9 -83
  323. package/dist/core/schema/query.mjs +49 -73
  324. package/dist/core/schema/strict.d.mts +3 -0
  325. package/dist/core/schema/strict.mjs +91 -0
  326. package/dist/core/schema/union-error.mjs +30 -7
  327. package/dist/core/schema/view.d.mts +4 -3
  328. package/dist/core/schema/view.mjs +16 -11
  329. package/dist/core/store/ddl.d.mts +0 -2
  330. package/dist/core/store/ddl.mjs +1 -5
  331. package/dist/core/time/bucket.d.mts +1 -18
  332. package/dist/core/time/bucket.mjs +12 -8
  333. package/dist/core/time/compare.mjs +3 -2
  334. package/dist/core/time/index.d.mts +7 -8
  335. package/dist/core/time/instant.d.mts +15 -9
  336. package/dist/core/time/instant.mjs +23 -9
  337. package/dist/core/time/range.d.mts +3 -15
  338. package/dist/core/time/range.mjs +17 -7
  339. package/dist/core/time/stored.d.mts +8 -5
  340. package/dist/core/time/stored.mjs +51 -15
  341. package/dist/core/time/temporal.d.mts +1 -5
  342. package/dist/core/time/temporal.mjs +9 -4
  343. package/dist/core/time/text-time.d.mts +31 -2
  344. package/dist/core/time/text-time.mjs +139 -22
  345. package/dist/core/time/zone.d.mts +6 -1
  346. package/dist/core/time/zone.mjs +13 -4
  347. package/dist/core/types/api.d.mts +1 -1
  348. package/dist/core/types/api.mjs +1 -1
  349. package/dist/core/types/dashboard.d.mts +185 -0
  350. package/dist/core/types/dashboard.mjs +26 -0
  351. package/dist/core/types/drill-api.d.mts +14 -2
  352. package/dist/core/types/infer.d.mts +0 -4
  353. package/dist/core/types/options-check.d.mts +42 -0
  354. package/dist/core/types/options-check.mjs +90 -0
  355. package/dist/core/types/options.d.mts +14 -8
  356. package/dist/core/value/casefold.d.mts +1 -3
  357. package/dist/core/value/stored.d.mts +26 -0
  358. package/dist/core/value/stored.mjs +28 -0
  359. package/dist/cursor-seal.mjs +37 -9
  360. package/dist/dashboard-documents.d.mts +14 -6
  361. package/dist/dashboard-documents.mjs +32 -12
  362. package/dist/dashboards.mjs +10 -9
  363. package/dist/drill-access.mjs +6 -6
  364. package/dist/drill-change.mjs +18 -20
  365. package/dist/drill-comparison.mjs +2 -1
  366. package/dist/drill-crumbs.mjs +63 -28
  367. package/dist/drill-distinct.mjs +2 -1
  368. package/dist/drill-explain.mjs +1 -1
  369. package/dist/drill-items.mjs +1 -1
  370. package/dist/drill-open.mjs +39 -23
  371. package/dist/drill-seal.mjs +41 -13
  372. package/dist/drill-share.mjs +1 -1
  373. package/dist/drill-summary.mjs +2 -1
  374. package/dist/drill-targets.mjs +4 -4
  375. package/dist/drill-views.mjs +4 -3
  376. package/dist/drill.mjs +1 -1
  377. package/dist/editing.mjs +5 -3
  378. package/dist/endpoints/index.d.mts +29 -8
  379. package/dist/endpoints/index.mjs +4 -1
  380. package/dist/endpoints/meta.mjs +4 -3
  381. package/dist/endpoints/query.mjs +5 -2
  382. package/dist/endpoints/read.mjs +7 -6
  383. package/dist/endpoints/versions.mjs +2 -1
  384. package/dist/execute.d.mts +3 -0
  385. package/dist/execute.mjs +23 -12
  386. package/dist/grant.d.mts +9 -0
  387. package/dist/grant.mjs +43 -0
  388. package/dist/handler.mjs +8 -13
  389. package/dist/http.d.mts +6 -2
  390. package/dist/http.mjs +6 -2
  391. package/dist/index.d.mts +25 -4
  392. package/dist/index.mjs +91 -40
  393. package/dist/llms.txt +3 -3
  394. package/dist/mcp/api.mjs +2 -1
  395. package/dist/mcp/query.mjs +3 -8
  396. package/dist/mcp/resolve.mjs +9 -2
  397. package/dist/node/index.d.mts +36 -0
  398. package/dist/node/index.mjs +89 -0
  399. package/dist/node/request.d.mts +12 -0
  400. package/dist/node/request.mjs +119 -0
  401. package/dist/node/response.mjs +58 -0
  402. package/dist/principal.mjs +15 -7
  403. package/dist/react/Canvas.mjs +90 -69
  404. package/dist/react/Cell.mjs +2 -1
  405. package/dist/react/Dashboard.d.mts +15 -1
  406. package/dist/react/Dashboard.mjs +43 -42
  407. package/dist/react/DashboardList.mjs +9 -4
  408. package/dist/react/Editing.d.mts +9 -0
  409. package/dist/react/Editing.mjs +8 -3
  410. package/dist/react/Grid.mjs +1 -1
  411. package/dist/react/Header.mjs +25 -52
  412. package/dist/react/History.mjs +3 -2
  413. package/dist/react/LoadFailed.mjs +59 -0
  414. package/dist/react/Panel.d.mts +1 -1
  415. package/dist/react/Panel.mjs +1 -1
  416. package/dist/react/Parts.d.mts +34 -0
  417. package/dist/react/Parts.mjs +9 -6
  418. package/dist/react/ReviewPanel.mjs +1 -1
  419. package/dist/react/RowBody.d.mts +2 -0
  420. package/dist/react/RowBody.mjs +5 -1
  421. package/dist/react/Share.mjs +153 -0
  422. package/dist/react/TabStrip.mjs +37 -0
  423. package/dist/react/Tile.d.mts +3 -1
  424. package/dist/react/Tile.mjs +89 -92
  425. package/dist/react/TileState.mjs +117 -0
  426. package/dist/react/ago.mjs +45 -0
  427. package/dist/react/arrange.mjs +1 -1
  428. package/dist/react/board.mjs +2 -2
  429. package/dist/react/bucket-name.d.mts +8 -0
  430. package/dist/react/bucket-name.mjs +13 -0
  431. package/dist/react/builder/DisplayOptions.mjs +219 -0
  432. package/dist/react/builder/Preview.mjs +13 -13
  433. package/dist/react/builder/RangeEditor.mjs +4 -3
  434. package/dist/react/builder/WidgetBuilder.d.mts +1 -7
  435. package/dist/react/builder/WidgetBuilder.mjs +12 -3
  436. package/dist/react/builder/base.d.mts +13 -2
  437. package/dist/react/builder/base.mjs +70 -12
  438. package/dist/react/builder/display.d.mts +3 -0
  439. package/dist/react/builder/display.mjs +256 -0
  440. package/dist/react/builder/labels.mjs +19 -5
  441. package/dist/react/builder/options.mjs +11 -6
  442. package/dist/react/builder/state.mjs +25 -3
  443. package/dist/react/builder/useBuilder.d.mts +7 -1
  444. package/dist/react/builder/useBuilder.mjs +6 -9
  445. package/dist/react/builder/usePreview.mjs +3 -2
  446. package/dist/react/builder/words.d.mts +16 -1
  447. package/dist/react/builder/words.mjs +41 -1
  448. package/dist/react/change-text.mjs +149 -0
  449. package/dist/react/client.d.mts +9 -0
  450. package/dist/react/client.mjs +105 -14
  451. package/dist/react/columns.mjs +9 -1
  452. package/dist/react/context.d.mts +24 -3
  453. package/dist/react/context.mjs +23 -7
  454. package/dist/react/dates-shown.mjs +76 -0
  455. package/dist/react/draft.mjs +3 -2
  456. package/dist/react/drill/Bars.mjs +12 -16
  457. package/dist/react/drill/Comparison.mjs +1 -1
  458. package/dist/react/drill/DrillPanel.d.mts +1 -1
  459. package/dist/react/drill/DrillPanel.mjs +2 -1
  460. package/dist/react/drill/Header.mjs +65 -12
  461. package/dist/react/drill/Items.d.mts +1 -1
  462. package/dist/react/drill/Notes.mjs +10 -7
  463. package/dist/react/drill/PanelStates.mjs +8 -1
  464. package/dist/react/drill/Trend.mjs +10 -5
  465. package/dist/react/drill/board.d.mts +1 -1
  466. package/dist/react/drill/board.mjs +1 -0
  467. package/dist/react/drill/host.mjs +4 -1
  468. package/dist/react/drill/lazy.mjs +2 -27
  469. package/dist/react/drill/props.d.mts +19 -8
  470. package/dist/react/drill/props.mjs +62 -18
  471. package/dist/react/drill/state.d.mts +15 -5
  472. package/dist/react/drill/state.mjs +12 -3
  473. package/dist/react/drill/words.d.mts +46 -3
  474. package/dist/react/drill/words.mjs +30 -5
  475. package/dist/react/english.mjs +33 -8
  476. package/dist/react/export/ExportButton.mjs +4 -1
  477. package/dist/react/export/csv.d.mts +7 -2
  478. package/dist/react/export/csv.mjs +24 -7
  479. package/dist/react/failure-words.mjs +60 -0
  480. package/dist/react/filters/bar.d.mts +1 -1
  481. package/dist/react/filters/bar.mjs +4 -1
  482. package/dist/react/filters/calendar.mjs +23 -8
  483. package/dist/react/filters/chip.mjs +7 -3
  484. package/dist/react/filters/context.d.mts +13 -1
  485. package/dist/react/filters/context.mjs +1 -1
  486. package/dist/react/filters/dates-said.mjs +57 -0
  487. package/dist/react/filters/days.d.mts +3 -4
  488. package/dist/react/filters/days.mjs +10 -17
  489. package/dist/react/filters/hooks.d.mts +11 -0
  490. package/dist/react/filters/hooks.mjs +10 -6
  491. package/dist/react/filters/menu-search.mjs +17 -9
  492. package/dist/react/filters/menu.mjs +10 -8
  493. package/dist/react/filters/phone.mjs +41 -16
  494. package/dist/react/filters/place.mjs +40 -0
  495. package/dist/react/filters/popover.mjs +18 -13
  496. package/dist/react/filters/rules.d.mts +4 -3
  497. package/dist/react/filters/rules.mjs +3 -3
  498. package/dist/react/filters/sheet.mjs +7 -3
  499. package/dist/react/filters/state.mjs +6 -1
  500. package/dist/react/filters/values.mjs +24 -7
  501. package/dist/react/filters/words.d.mts +13 -0
  502. package/dist/react/filters/words.mjs +5 -0
  503. package/dist/react/format-time.d.mts +17 -6
  504. package/dist/react/format-time.mjs +152 -33
  505. package/dist/react/format.d.mts +3 -3
  506. package/dist/react/format.mjs +35 -122
  507. package/dist/react/headline.d.mts +12 -0
  508. package/dist/react/headline.mjs +107 -0
  509. package/dist/react/index.d.mts +20 -17
  510. package/dist/react/index.mjs +13 -10
  511. package/dist/react/lazy.mjs +38 -0
  512. package/dist/react/messages.d.mts +78 -2
  513. package/dist/react/now.mjs +38 -0
  514. package/dist/react/place.mjs +4 -2
  515. package/dist/react/read.d.mts +1 -0
  516. package/dist/react/read.mjs +140 -9
  517. package/dist/react/renderers/exact.mjs +31 -59
  518. package/dist/react/renderers/index.d.mts +27 -6
  519. package/dist/react/renderers/index.mjs +154 -92
  520. package/dist/react/renderers/list-parts.mjs +24 -0
  521. package/dist/react/renderers/list.d.mts +1 -0
  522. package/dist/react/renderers/list.mjs +99 -43
  523. package/dist/react/renderers/more-rows.mjs +75 -0
  524. package/dist/react/renderers/number-before.mjs +320 -0
  525. package/dist/react/renderers/number-period.mjs +54 -0
  526. package/dist/react/renderers/number-whole.mjs +29 -0
  527. package/dist/react/renderers/props.d.mts +24 -1
  528. package/dist/react/renderers/props.mjs +8 -0
  529. package/dist/react/renderers/table-cells.mjs +137 -31
  530. package/dist/react/renderers/table-fit.mjs +55 -10
  531. package/dist/react/renderers/table-measure.mjs +29 -9
  532. package/dist/react/renderers/table-row.mjs +14 -9
  533. package/dist/react/renderers/table-scale.mjs +2 -3
  534. package/dist/react/renderers/table-sort.mjs +3 -2
  535. package/dist/react/renderers/table-whole.mjs +37 -0
  536. package/dist/react/renderers/table.mjs +73 -53
  537. package/dist/react/review.d.mts +7 -0
  538. package/dist/react/review.mjs +35 -8
  539. package/dist/react/roving.d.mts +6 -0
  540. package/dist/react/roving.mjs +123 -0
  541. package/dist/react/says-dates.d.mts +7 -0
  542. package/dist/react/says-dates.mjs +51 -0
  543. package/dist/react/series.mjs +5 -6
  544. package/dist/react/stable.mjs +1 -1
  545. package/dist/react/tabs/EditTabs.mjs +125 -0
  546. package/dist/react/tabs/NameField.mjs +72 -0
  547. package/dist/react/tabs/TabMenu.mjs +175 -0
  548. package/dist/react/tabs/actions.mjs +37 -0
  549. package/dist/react/tabs/commands.mjs +76 -0
  550. package/dist/react/tabs/focus.mjs +22 -0
  551. package/dist/react/tabs/keys.mjs +28 -0
  552. package/dist/react/theme-unlayered.css +1 -1
  553. package/dist/react/theme.css +1 -1
  554. package/dist/react/tile-store.d.mts +4 -0
  555. package/dist/react/tile-store.mjs +93 -13
  556. package/dist/react/touch.d.mts +16 -0
  557. package/dist/react/touch.mjs +39 -0
  558. package/dist/react/useBoard.d.mts +6 -0
  559. package/dist/react/useBoard.mjs +1 -0
  560. package/dist/react/useDashboard.d.mts +2 -0
  561. package/dist/react/useDashboard.mjs +5 -2
  562. package/dist/react/useTiles.d.mts +3 -0
  563. package/dist/react/useTiles.mjs +73 -17
  564. package/dist/react/view-grid.mjs +2 -2
  565. package/dist/react/view.mjs +1 -1
  566. package/dist/recharts/axes.mjs +1 -1
  567. package/dist/recharts/axis.mjs +23 -73
  568. package/dist/recharts/bar.d.mts +2 -1
  569. package/dist/recharts/bar.mjs +140 -64
  570. package/dist/recharts/fit.mjs +33 -0
  571. package/dist/recharts/line.mjs +23 -17
  572. package/dist/recharts/marks.mjs +2 -1
  573. package/dist/recharts/parts.mjs +19 -14
  574. package/dist/recharts/table.mjs +8 -3
  575. package/dist/refusal.mjs +46 -0
  576. package/dist/registry/filter-bar.json +1 -1
  577. package/dist/skills/derive-dashboards/SKILL.md +25 -9
  578. package/dist/tile-doc.mjs +1 -1
  579. package/package.json +21 -6
  580. package/dist/charts-react/plan.d.mts +0 -3
  581. package/dist/charts-react/plan.mjs +0 -37
  582. package/dist/charts-react/tiles.d.mts +0 -24
  583. package/dist/core/policy/match.d.mts +0 -16
  584. package/dist/core/schema/aliases.d.mts +0 -7
  585. package/dist/core/time/compare.d.mts +0 -30
  586. package/dist/react/EditBar.d.mts +0 -16
  587. package/dist/react/History.d.mts +0 -30
  588. package/dist/react/ReviewPanel.d.mts +0 -15
  589. package/dist/react/digits.mjs +0 -46
  590. package/dist/react/drill/trend-touch.mjs +0 -33
  591. package/dist/react/renderers/exact.d.mts +0 -6
@@ -7,8 +7,6 @@ export type PositiveOp = (typeof POSITIVE_OPS)[number];
7
7
  export type NegativeOp = (typeof NEGATIVE_OPS)[number];
8
8
  export type NullOp = (typeof NULL_OPS)[number];
9
9
  export type Op = PositiveOp | NegativeOp | NullOp;
10
- /** Each negative operator is exactly NOT of one positive operator. */
11
- export declare const NEGATION_OF: Record<NegativeOp, PositiveOp>;
12
10
  /** A value taken from the viewer at request time. Legal only on the "user" channel. */
13
11
  export type ViewerRef = "id" | "roles" | `attributes.${string}`;
14
12
  export type ValueLeaf<Member extends string = string> = {
@@ -98,8 +96,5 @@ export type BoundFilter = {
98
96
  where: BoundFilter;
99
97
  };
100
98
  };
101
- export declare function isLeaf(node: WireFilter): node is Leaf;
102
99
  /** Proves that no viewer reference and no variable is left anywhere in the tree. */
103
- export declare function isBound(filter: WireFilter): filter is BoundFilter;
104
- /** Drops every node id, giving the form that runs. */
105
- export declare function stripIds(filter: StoredFilter): WireFilter;
100
+ export declare function isBound(filter: WireFilter): filter is BoundFilter;
@@ -35,9 +35,6 @@ function isOp(op) {
35
35
  function isViewerRef(ref) {
36
36
  return ref === "id" || ref === "roles" || typeof ref === "string" && ref.startsWith("attributes.") && ref.length > 11;
37
37
  }
38
- function isLeaf(node) {
39
- return "member" in node;
40
- }
41
38
  /** Proves that no viewer reference and no variable is left anywhere in the tree. */
42
39
  function isBound(filter) {
43
40
  if ("all" in filter) return filter.all.every(isBound);
@@ -76,4 +73,4 @@ function stripIds(filter) {
76
73
  variable: filter.variable
77
74
  };
78
75
  }
79
- export { NEGATION_OF, NEGATIVE_OPS, NULL_OPS, POSITIVE_OPS, isBound, isLeaf, isOp, isViewerRef, stripIds };
76
+ export { NEGATION_OF, NEGATIVE_OPS, NULL_OPS, POSITIVE_OPS, isBound, isOp, isViewerRef, stripIds };
@@ -0,0 +1,23 @@
1
+ // src/query/fold.ts
2
+ /**
3
+ * A fold of a query is the same query with one axis taken away, answered beside it in the same
4
+ * read. The time fold is the query without its grain: each group over the whole range. Its
5
+ * answer is defined as exactly that query's answer, so every law that holds an engine to the
6
+ * oracle holds the fold too, and what a fold may read is what its query may: only the query
7
+ * changes, never the access bound beside it.
8
+ */
9
+ /** Whether a query also answers itself without its grain (`time.whole` with a grain). */
10
+ const answersWhole = (query) => query.time?.whole === true && query.time.grain !== void 0;
11
+ /**
12
+ * The query without its grain, over the same range: the rows a ranking reads, and the query
13
+ * whose answer is `whole`. It has no `whole` of its own, which needs a grain.
14
+ */
15
+ function withoutGrain(query) {
16
+ if (query.time === void 0) return query;
17
+ const { grain: _grain, whole: _whole, ...time } = query.time;
18
+ return {
19
+ ...query,
20
+ time
21
+ };
22
+ }
23
+ export { answersWhole, withoutGrain };
@@ -1,4 +1,5 @@
1
1
  import { aliasPart } from "./alias.mjs";
2
+ import { withoutGrain } from "./fold.mjs";
2
3
  import { formulaRefs } from "./formulas.mjs";
3
4
  // src/query/segments.ts
4
5
  /** The values a dimension keeps: its ranked values up to its limit. */
@@ -21,8 +22,9 @@ const plain = ({ id, member }) => ({
21
22
  * period (`previous`), which a ranking by it needs and which needs the comparison.
22
23
  */
23
24
  function rankTime(query) {
24
- if (query.time === void 0) return void 0;
25
- const { grain: _grain, compare, ...rest } = query.time;
25
+ const time = withoutGrain(query).time;
26
+ if (time === void 0) return void 0;
27
+ const { compare, ...rest } = time;
26
28
  return (query.calc ?? []).some((c) => formulaRefs(c.formula).some((r) => r.of === "previous")) && compare !== void 0 ? {
27
29
  ...rest,
28
30
  compare
@@ -170,6 +172,43 @@ function segmentOtherRow(query, row) {
170
172
  ...row.slice(at)
171
173
  ];
172
174
  }
175
+ const segmentOf = (rows) => rows === void 0 ? {} : { segmentOther: rows };
176
+ /** The answer to `segmentOtherQuery`'s whole, as an answer of its own. */
177
+ function foldedWhole(folded) {
178
+ if (folded?.whole === void 0) return void 0;
179
+ const before = folded.compare?.whole;
180
+ return {
181
+ rows: folded.whole.rows,
182
+ ...before === void 0 ? {} : { compare: before }
183
+ };
184
+ }
185
+ /**
186
+ * The kept query's answer with Other's rows (`folded`, the answer to `segmentOtherQuery`), now
187
+ * and in the comparison period, and with `time.whole` in each whole, in its own layout: the
188
+ * query without its grain. A level the answer does not have gets none.
189
+ */
190
+ function withSegmentOthers(query, answer, folded) {
191
+ const rows = segmentOthers(query, folded);
192
+ const wholes = segmentOthers(withoutGrain(query), foldedWhole(folded));
193
+ const { whole, compare } = answer;
194
+ const before = compare?.whole;
195
+ return {
196
+ ...answer,
197
+ ...segmentOf(rows.now),
198
+ ...whole === void 0 ? {} : { whole: {
199
+ ...whole,
200
+ ...segmentOf(wholes.now)
201
+ } },
202
+ ...compare === void 0 ? {} : { compare: {
203
+ ...compare,
204
+ ...segmentOf(rows.before),
205
+ ...before === void 0 ? {} : { whole: {
206
+ ...before,
207
+ ...segmentOf(wholes.before)
208
+ } }
209
+ } }
210
+ };
211
+ }
173
212
  /**
174
213
  * The segment-Other rows of an answer and of its comparison period, in the query's layout,
175
214
  * from the answer to `segmentOtherQuery`. Each is absent when it has no row.
@@ -182,4 +221,4 @@ function segmentOthers(query, folded) {
182
221
  ...before === void 0 ? {} : { before }
183
222
  };
184
223
  }
185
- export { foldedColumn, hasSegments, keptQuery, limitedDimensions, rankQuery, segmentCuts, segmentOtherQuery, segmentOthers, segmentSplit, uncutQuery };
224
+ export { foldedColumn, hasSegments, keptQuery, limitedDimensions, rankQuery, segmentCuts, segmentOtherQuery, segmentSplit, uncutQuery, withSegmentOthers };
@@ -11,6 +11,13 @@ export declare class QueryReferenceError extends Error {
11
11
  * (which `toWire` refuses) the later is kept.
12
12
  */
13
13
  export declare function entryAliases(stored: StoredQuery): ReadonlyMap<EntryId, Alias>;
14
+ /**
15
+ * The entry of a stored query a name means, by the entry's own id. A name is read as a renderer
16
+ * and the display's check read it: as an entry's own id first, so a group whose own id is "m1"
17
+ * is that group, else as the id an entry's column has in an answer (m1, d1, c1). None when the
18
+ * query has no such entry.
19
+ */
20
+ export declare function entryNamed(stored: StoredQuery, name: string): EntryId | undefined;
14
21
  /**
15
22
  * Turns a stored query into the query that runs.
16
23
  *
@@ -37,6 +37,17 @@ const aliasPairs = (stored) => [
37
37
  function entryAliases(stored) {
38
38
  return new Map(aliasPairs(stored));
39
39
  }
40
+ /**
41
+ * The entry of a stored query a name means, by the entry's own id. A name is read as a renderer
42
+ * and the display's check read it: as an entry's own id first, so a group whose own id is "m1"
43
+ * is that group, else as the id an entry's column has in an answer (m1, d1, c1). None when the
44
+ * query has no such entry.
45
+ */
46
+ function entryNamed(stored, name) {
47
+ const aliases = entryAliases(stored);
48
+ if (aliases.has(name)) return name;
49
+ return [...aliases].find(([, alias]) => alias === name)?.[0];
50
+ }
40
51
  /** The aliases of a query that runs: as `entryAliases`, refusing two entries with one id. */
41
52
  function assignAliases(stored) {
42
53
  const pairs = aliasPairs(stored);
@@ -121,7 +132,8 @@ function toWire(stored) {
121
132
  id: `c${i + 1}`,
122
133
  formula: rewriteFormula(entry.formula, aliases, i, `Calc "${entry.id}"`),
123
134
  format: entry.format,
124
- label: entry.label
135
+ label: entry.label,
136
+ better: entry.better
125
137
  })),
126
138
  order: orderOf(stored, aliases),
127
139
  limit: stored.limit,
@@ -132,4 +144,4 @@ function toWire(stored) {
132
144
  aliasToId: Object.fromEntries([...aliases].map(([id, name]) => [name, id]))
133
145
  };
134
146
  }
135
- export { QueryReferenceError, entryAliases, toWire };
147
+ export { QueryReferenceError, entryAliases, entryNamed, toWire };
@@ -1,5 +1,5 @@
1
1
  import { DimensionId, MeasureId, OwnDimensionId, SourceNameOf } from "../model/define.mjs";
2
- import { Model } from "../model/types.mjs";
2
+ import { Better, Model } from "../model/types.mjs";
3
3
  import { IanaZone, IsoInstant, JoinName, Primitive, SourceName, WeekStart } from "../types/primitives.mjs";
4
4
  import { Leaf, NodeId, Op, StoredFilter, WireFilter } from "./filter.mjs";
5
5
  export type Grain = "hour" | "day" | "week" | "month" | "quarter" | "year";
@@ -54,6 +54,18 @@ export type FormulaNode = Formula<MeasureAlias | CalcAlias>;
54
54
  * seconds, `currency` in the one unit its measures share.
55
55
  */
56
56
  export type Format = "number" | "percent" | "currency" | "duration";
57
+ /**
58
+ * A calc: its formula, how its value reads, its label, and which way a change of it is for the
59
+ * better. A calc's `better` is its own, never read from the measures it uses: a formula can turn
60
+ * the sign around (previous minus current).
61
+ */
62
+ export type CalcEntry<Id extends string, F> = {
63
+ id: Id;
64
+ formula: F;
65
+ format?: Format;
66
+ label?: string;
67
+ better?: Better;
68
+ };
57
69
  /**
58
70
  * A dimension's own top N (a chart's segments), ranked alone over the whole range by `rankBy`
59
71
  * (default: the first measure, descending); with `other`, the rest return marked Other.
@@ -92,14 +104,15 @@ export type WireQuery = {
92
104
  grain?: Grain;
93
105
  range: DateRange;
94
106
  compare?: "previous_period" | "previous_year";
107
+ /**
108
+ * With a grain: also answer the query without its grain, over the same range and in the
109
+ * same read, beside the rows (`Result.whole`): each group over the whole range, as a
110
+ * headline beside its weeks. Refused without a grain.
111
+ */
112
+ whole?: true;
95
113
  };
96
114
  filters?: WireFilter;
97
- calc?: readonly {
98
- id: CalcAlias;
99
- formula: FormulaNode;
100
- format?: Format;
101
- label?: string;
102
- }[];
115
+ calc?: readonly CalcEntry<CalcAlias, FormulaNode>[];
103
116
  /** With a limit and no order, the default is the first measure descending, then the keys. */
104
117
  order?: readonly {
105
118
  by: MeasureAlias | CalcAlias | DimensionAlias;
@@ -147,6 +160,7 @@ export type TypedQuery<M extends Model> = { [S in SourceNameOf<M>]: Omit<WireQue
147
160
  grain?: Grain;
148
161
  range: DateRange;
149
162
  compare?: "previous_period" | "previous_year";
163
+ whole?: true;
150
164
  };
151
165
  filters?: TypedFilter<M, S>;
152
166
  }; }[SourceNameOf<M>];
@@ -170,12 +184,7 @@ export type StoredQuery = {
170
184
  } & DimensionCut<EntryId>)[];
171
185
  time?: WireQuery["time"];
172
186
  filters?: StoredFilter;
173
- calc?: readonly {
174
- id: EntryId;
175
- formula: StoredFormulaNode;
176
- format?: Format;
177
- label?: string;
178
- }[];
187
+ calc?: readonly CalcEntry<EntryId, StoredFormulaNode>[];
179
188
  order?: readonly {
180
189
  id: EntryId;
181
190
  by: EntryId;
@@ -195,6 +204,14 @@ export type Control = {
195
204
  } & ({
196
205
  kind: "filter";
197
206
  member: string;
207
+ /**
208
+ * The same field on other sources, where several each carry their own (a plan on
209
+ * sessions, on invoices, on saves). A pick narrows a tile through the first of
210
+ * `member` and these that the tile's source can read, so one control reaches the
211
+ * tiles of every source that has the field, and is dropped only where none does.
212
+ * The control's values, its type and its label are `member`'s.
213
+ */
214
+ also?: readonly string[];
198
215
  ops: readonly Op[];
199
216
  values?: "lookup" | readonly Primitive[];
200
217
  multi: boolean;
@@ -1,4 +1,4 @@
1
- import { mergesBySum, resolveDimension, resolveMeasure } from "../model/member.mjs";
1
+ import { dimensionValueType, mergesBySum, parseMemberId, resolveDimension, resolveMeasure } from "../model/member.mjs";
2
2
  import { idRole } from "../query/alias.mjs";
3
3
  import { formulaRefs } from "../query/formulas.mjs";
4
4
  import { calcAddsUp } from "./additive.mjs";
@@ -8,24 +8,37 @@ const words = (name) => {
8
8
  const spaced = name.replaceAll(/([a-z0-9])([A-Z])/gu, (_, a, b) => `${a} ${b.toLowerCase()}`);
9
9
  return spaced.charAt(0).toUpperCase() + spaced.slice(1);
10
10
  };
11
- const lastPart = (id) => id.split(".").at(-1) ?? id;
12
11
  /** A member's label: the model's, or its name in words. */
13
12
  function memberLabel(id, label) {
14
- return label ?? words(lastPart(id));
13
+ return label ?? words(parseMemberId(id)?.name ?? id);
15
14
  }
16
- /** How a measure's values read: its unit, a ratio the model reads as a percent of one, a duration in seconds. */
15
+ /** Which way is better, as its owner says it: a measure's definition or a calc's own entry. */
16
+ const betterOf = (said) => said?.better === void 0 ? {} : { better: said.better };
17
+ /** Whether a measure is over an `elapsed` alone: its values are the microseconds between two times. */
18
+ const overElapsed = (def) => def !== void 0 && "of" in def && typeof def.of === "object" && "elapsed" in def.of;
19
+ /** What a measure's values count: an elapsed's microseconds, or the model's unit. */
20
+ function unitOf(def) {
21
+ if (overElapsed(def)) return "microsecond";
22
+ return def !== void 0 && "unit" in def ? def.unit : void 0;
23
+ }
24
+ /**
25
+ * How a measure's values read: its unit, a ratio the model reads as a percent of one, a
26
+ * duration in seconds, or, over an `elapsed` alone, a duration in the microseconds it counts,
27
+ * whether or not the model says so.
28
+ */
17
29
  function readsAs(def) {
18
- const unit = def !== void 0 && "unit" in def ? def.unit : void 0;
30
+ const unit = unitOf(def);
19
31
  const format = def !== void 0 && "format" in def ? def.format : void 0;
20
32
  const percent = def?.kind === "ratio" && format === "percent";
21
- const duration = format === "duration";
33
+ const duration = format === "duration" || overElapsed(def);
22
34
  return {
23
35
  ...unit === void 0 ? {} : { unit },
24
36
  ...percent ? {
25
37
  format: "percent",
26
38
  fraction: true
27
39
  } : {},
28
- ...duration ? { format: "duration" } : {}
40
+ ...duration ? { format: "duration" } : {},
41
+ ...betterOf(def)
29
42
  };
30
43
  }
31
44
  /** A measure's cell type: counts are integers, percentiles float, the rest as declared. */
@@ -35,12 +48,8 @@ function measureType(model, source, def) {
35
48
  if (def.kind === "ratio") return [def.numerator, def.denominator].map((name) => model.sources[source]?.measures[name]).some((m) => m === void 0 || measureType(model, source, m) === "float") ? "float" : "decimal";
36
49
  return def.numeric === "float" ? "float" : "decimal";
37
50
  }
38
- function dimensionType(def) {
39
- if (def === void 0) return "string";
40
- if (def.kind === "number" || def.kind === "boolean" || def.kind === "time") return def.kind;
41
- if (def.kind === "expr") return def.type;
42
- return "string";
43
- }
51
+ /** A dimension column's type: the value type its dimension holds (`dimensionValueType`). */
52
+ const dimensionType = (def) => def === void 0 ? "string" : dimensionValueType(def);
44
53
  /** A calc is exact only when every operand is exact (any float operand makes it float). */
45
54
  function formulaType(node, types) {
46
55
  if ("lit" in node) return "decimal";
@@ -134,6 +143,7 @@ function resultColumns(model, query) {
134
143
  type,
135
144
  additive,
136
145
  ...c.format === void 0 ? {} : { format: c.format },
146
+ ...betterOf(c),
137
147
  ...formulaRefs(c.formula).some((r) => r.of === "previous") ? { signed: true } : {},
138
148
  ...unit === void 0 ? {} : { unit }
139
149
  };
@@ -1,5 +1,5 @@
1
- import { formatExact, parseExact } from "../exact/text.mjs";
2
1
  import { EXACT_LIMIT, divideExact } from "../exact/decimal.mjs";
2
+ import { decimalPlaces, formatExact, parseExact } from "../exact/text.mjs";
3
3
  // src/result/number.ts
4
4
  const exactNum = (minor, scale) => ({
5
5
  exact: true,
@@ -14,7 +14,7 @@ function numOf(cell) {
14
14
  exact: false,
15
15
  x: cell
16
16
  };
17
- const scale = cell.v.split(".")[1]?.length ?? 0;
17
+ const scale = decimalPlaces(cell.v);
18
18
  const minor = parseExact(cell.v, scale);
19
19
  return minor === void 0 ? null : exactNum(minor, scale);
20
20
  }
@@ -60,7 +60,7 @@ function divide(a, b) {
60
60
  };
61
61
  }
62
62
  /**
63
- * The cell for a computed number. Exact values are rounded once, half to even, to
63
+ * The cell for a computed number. Exact values are rounded once, half away from zero, to
64
64
  * `max(scale, 6)` places for a quotient or their own scale otherwise. A value at or past
65
65
  * 10^100 is null: it is outside the exact domain.
66
66
  */
@@ -0,0 +1,13 @@
1
+ import { Issue } from "../types/primitives.mjs";
2
+ import { Unread } from "../value/stored.mjs";
3
+ import { Result } from "./types.mjs";
4
+ /** One warning per column whose stored values did not read, naming the column and the count. */
5
+ export declare function unreadWarnings(unread: readonly Unread[] | undefined): Issue[];
6
+ /**
7
+ * An answer's status: `truncated` when cut at the row cap, else `partial` when stored values
8
+ * did not read and were read as no value, else `complete`.
9
+ */
10
+ export declare function answerStatus(answer: {
11
+ truncated?: true;
12
+ unread?: readonly Unread[];
13
+ }): Result["status"];
@@ -0,0 +1,18 @@
1
+ // src/result/status.ts
2
+ /** One warning per column whose stored values did not read, naming the column and the count. */
3
+ function unreadWarnings(unread) {
4
+ return (unread ?? []).map((u) => ({
5
+ code: "VALUE_UNREAD",
6
+ message: `${u.count} ${u.count === 1 ? "value" : "values"} of "${u.source}.${u.column}" did not read as its storage and ${u.count === 1 ? "is" : "are"} read as no value.`,
7
+ path: [u.source, u.column]
8
+ }));
9
+ }
10
+ /**
11
+ * An answer's status: `truncated` when cut at the row cap, else `partial` when stored values
12
+ * did not read and were read as no value, else `complete`.
13
+ */
14
+ function answerStatus(answer) {
15
+ if (answer.truncated === true) return "truncated";
16
+ return (answer.unread ?? []).length > 0 ? "partial" : "complete";
17
+ }
18
+ export { answerStatus, unreadWarnings };
@@ -1,18 +1,18 @@
1
1
  import { Calendar, ResolvedRange } from "../query/types.mjs";
2
- import { ResultColumn, ResultRows, TimeAxis } from "./types.mjs";
2
+ import { ResultColumn, ResultRows, TimeAxis, TimeBucket } from "./types.mjs";
3
3
  /**
4
- * The time buckets an answer's rows name, as instants, in time order. Each runs from its first
5
- * instant to the next bucket's by the answer's calendar, so a day is 23 or 25 hours across a
6
- * clock change and a week starts on the calendar's day. A bucket the answer's range covers only
7
- * part of is marked: the week still running, or a first month the range starts inside. The
8
- * engine's own calendar decides both, so no client works a bucket's end out again.
9
- *
10
- * None for an answer with no time bucket column.
4
+ * The part of one bucket a range reads, marked as `timeAxis` marks it: "Nov 9 to Nov 11" and
5
+ * running for the week of Nov 9 read through Nov 11. Its own instants when no range reads.
11
6
  */
12
- export declare function timeAxis(answer: {
13
- columns: readonly ResultColumn[];
14
- rows: ResultRows;
15
- }, range: ResolvedRange | undefined, calendar: Calendar): TimeAxis | undefined;
7
+ export declare function bucketWithin(bucket: ResolvedRange, range: ResolvedRange | undefined): ResolvedRange & Pick<TimeBucket, "partial">;
8
+ /** A bucket as far as its wholeness goes: the answer's, or one a chart made of its own. */
9
+ type Partial = {
10
+ partial?: TimeBucket["partial"] | undefined;
11
+ } | undefined;
12
+ /** Whether a bucket is still running: its value stops part of the way through, "so far". */
13
+ export declare const isRunning: (bucket: Partial) => boolean;
14
+ /** Whether a bucket's value starts part of the way into it: the range begins inside it. */
15
+ export declare const isStarting: (bucket: Partial) => boolean;
16
16
  /** Rows with the time buckets they name, when their answer has a time bucket column. */
17
17
  export declare function withTime(columns: readonly ResultColumn[], rows: ResultRows, at: {
18
18
  range: ResolvedRange | undefined;
@@ -20,4 +20,5 @@ export declare function withTime(columns: readonly ResultColumn[], rows: ResultR
20
20
  }): {
21
21
  rows: ResultRows;
22
22
  time?: TimeAxis;
23
- };
23
+ };
24
+ export {};
@@ -20,6 +20,24 @@ function partialOf(bucket, range) {
20
20
  if (start) return { partial: "start" };
21
21
  return end ? { partial: "end" } : {};
22
22
  }
23
+ /**
24
+ * The part of one bucket a range reads, marked as `timeAxis` marks it: "Nov 9 to Nov 11" and
25
+ * running for the week of Nov 9 read through Nov 11. Its own instants when no range reads.
26
+ */
27
+ function bucketWithin(bucket, range) {
28
+ const own = spanOf(bucket);
29
+ const span = spanOf(range);
30
+ if (range === void 0 || own === void 0 || span === void 0) return bucket;
31
+ return {
32
+ from: span.from > own.from ? range.from : bucket.from,
33
+ to: span.to < own.to ? range.to : bucket.to,
34
+ ...partialOf(own, span)
35
+ };
36
+ }
37
+ /** Whether a bucket is still running: its value stops part of the way through, "so far". */
38
+ const isRunning = (bucket) => bucket?.partial === "end" || bucket?.partial === "both";
39
+ /** Whether a bucket's value starts part of the way into it: the range begins inside it. */
40
+ const isStarting = (bucket) => bucket?.partial === "start" || bucket?.partial === "both";
23
41
  /** The bucket labels the rows name, each once, in the order they first appear. */
24
42
  function labelsOf(rows, at) {
25
43
  const cells = rows.flatMap((row) => {
@@ -51,7 +69,7 @@ function timeAxis(answer, range, calendar) {
51
69
  from,
52
70
  to: nextBucketStart(from, grain, calendar)
53
71
  }];
54
- }).toSorted((a, b) => a.from - b.from).map((b) => ({
72
+ }).toSorted((a, b) => Number(a.from > b.from) - Number(a.from < b.from)).map((b) => ({
55
73
  label: b.label,
56
74
  from: formatTextTime(b.from),
57
75
  to: formatTextTime(b.to),
@@ -70,4 +88,4 @@ function withTime(columns, rows, at) {
70
88
  time
71
89
  };
72
90
  }
73
- export { timeAxis, withTime };
91
+ export { bucketWithin, isRunning, isStarting, timeAxis, withTime };
@@ -1,4 +1,4 @@
1
- import { Unit } from "../model/types.mjs";
1
+ import { Better, Unit } from "../model/types.mjs";
2
2
  import { BoundFilter } from "../query/filter.mjs";
3
3
  import { Calendar, Cell, Format, Grain, ResolvedRange, ScopeCoverage } from "../query/types.mjs";
4
4
  import { IsoInstant, Issue, SourceName } from "../types/primitives.mjs";
@@ -26,6 +26,12 @@ export type ResultColumn = {
26
26
  format?: Format;
27
27
  /** On a calc that reads the comparison period: a change, shown with its sign (+3.2%). */
28
28
  signed?: true;
29
+ /**
30
+ * On a measure or a calc that says which way is better: whether a rise is for the better
31
+ * (`higher`) or the worse (`lower`). A measure's comes from the model, a calc's from the calc
32
+ * itself; absent, a change of it is never coloured.
33
+ */
34
+ better?: Better;
29
35
  /** On a ratio read as a percent: its values are fractions of one (0.55 reads 55%), not points. */
30
36
  fraction?: true;
31
37
  /**
@@ -61,6 +67,10 @@ export type Receipt = {
61
67
  computedAt: IsoInstant;
62
68
  consistency: "snapshot" | "statement" | "mixed";
63
69
  durationMs: number;
70
+ /**
71
+ * The groups the answer returns: its rows less Other and totals, and with `time.whole` its
72
+ * whole's groups too. The comparison period's rows are not counted.
73
+ */
64
74
  rowsReturned: number;
65
75
  filter: BoundFilter;
66
76
  coverage: ScopeCoverage;
@@ -106,12 +116,32 @@ export type Result = {
106
116
  columns: readonly ResultColumn[];
107
117
  /** With a time grain: the buckets the rows name, as instants. */
108
118
  time?: TimeAxis;
109
- /** The comparison period's rows, in the same layout, and with a time grain its own buckets. */
119
+ /**
120
+ * With `time.whole`: the answer of this query without its grain, over the same range and
121
+ * read in the same session, in the layout of the columns without the time column: each
122
+ * group over the whole range, then a dimension's Other, then Other, then totals. A headline
123
+ * beside its weeks reads it, never a sum or an average of the buckets. Read it with
124
+ * `wholeAnswer`. Complete even when the rows are cut at the row cap.
125
+ */
126
+ whole?: {
127
+ rows: ResultRows;
128
+ };
129
+ /**
130
+ * The comparison period's rows, in the same layout, and with a time grain its own buckets.
131
+ * With `time.whole`, its whole too, cut to the groups the answer's whole has.
132
+ */
110
133
  compare?: {
111
134
  rows: ResultRows;
112
135
  range: ResolvedRange;
113
136
  time?: TimeAxis;
137
+ whole?: {
138
+ rows: ResultRows;
139
+ };
114
140
  };
115
- status: "complete" | "truncated";
141
+ /**
142
+ * `truncated`: cut at the row cap (`ROW_CAP`). `partial`: every row read, but some stored
143
+ * values did not read as their column's storage and are read as no value (`VALUE_UNREAD`).
144
+ */
145
+ status: "complete" | "truncated" | "partial";
116
146
  receipt: Receipt;
117
147
  };
@@ -0,0 +1,23 @@
1
+ import { WireQuery } from "../query/types.mjs";
2
+ import { Levels } from "./marks.mjs";
3
+ import { Result, ResultColumn, ResultRows } from "./types.mjs";
4
+ /**
5
+ * The one owner of the whole's layout. An answer to a query with `time.whole` holds, beside its
6
+ * rows, the answer of the same query without its grain: its rows in the layout of the answer's
7
+ * columns without the time column, groups then a dimension's Other then Other then totals, as
8
+ * `markedRows` places them for that query.
9
+ */
10
+ /** A whole as an answer carries it: marked as the rows of the query without its grain are. */
11
+ export declare function markedWhole(query: WireQuery, whole: Levels | undefined): ResultRows | undefined;
12
+ /**
13
+ * An answer's whole as a table of its own: the answer's columns without the time column, and
14
+ * the whole's rows. Undefined when the answer has no whole. The comparison's whole is in the
15
+ * same columns: `wholeAnswer({ columns, whole: answer.compare?.whole })`.
16
+ */
17
+ export declare function wholeAnswer(answer: {
18
+ columns: Result["columns"];
19
+ whole?: Result["whole"] | undefined;
20
+ }): {
21
+ columns: readonly ResultColumn[];
22
+ rows: ResultRows;
23
+ } | undefined;
@@ -0,0 +1,27 @@
1
+ import { withoutGrain } from "../query/fold.mjs";
2
+ import { roleOf } from "./columns.mjs";
3
+ import { markedRows } from "./marks.mjs";
4
+ // src/result/whole.ts
5
+ /**
6
+ * The one owner of the whole's layout. An answer to a query with `time.whole` holds, beside its
7
+ * rows, the answer of the same query without its grain: its rows in the layout of the answer's
8
+ * columns without the time column, groups then a dimension's Other then Other then totals, as
9
+ * `markedRows` places them for that query.
10
+ */
11
+ /** A whole as an answer carries it: marked as the rows of the query without its grain are. */
12
+ function markedWhole(query, whole) {
13
+ return whole === void 0 ? void 0 : markedRows(withoutGrain(query), whole);
14
+ }
15
+ /**
16
+ * An answer's whole as a table of its own: the answer's columns without the time column, and
17
+ * the whole's rows. Undefined when the answer has no whole. The comparison's whole is in the
18
+ * same columns: `wholeAnswer({ columns, whole: answer.compare?.whole })`.
19
+ */
20
+ function wholeAnswer(answer) {
21
+ if (answer.whole === void 0) return void 0;
22
+ return {
23
+ columns: answer.columns.filter((c) => roleOf(c) !== "time"),
24
+ rows: answer.whole.rows
25
+ };
26
+ }
27
+ export { markedWhole, wholeAnswer };