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
@@ -1,4 +1,5 @@
1
- import { decimalColumns } from "../model/storage.mjs";
1
+ import { OPERAND_LIMIT } from "../exact/stored.mjs";
2
+ import { decimalColumns, readColumns } from "../model/storage.mjs";
2
3
  import { exprLinearTerms } from "../model/validate/expr.mjs";
3
4
  import { cellOf, divide, exactNum } from "../result/number.mjs";
4
5
  import { exprSql } from "./members.mjs";
@@ -53,18 +54,26 @@ function ratioParts(n, d, rest) {
53
54
  const width = np.aggs.length;
54
55
  return fromParts([...np.aggs, ...dp.aggs], (aggs) => ({ sql: [...np.finish(aggs.slice(0, width)).sql, ...dp.finish(aggs.slice(width)).sql] }), rest);
55
56
  }
57
+ const anyOf = (tests) => tests.length === 0 ? sql`FALSE` : sql`(${join(tests, sql` OR `)})`;
56
58
  /**
57
- * NaN in a decimal column the query's measures read, counted over a group's rows. A level
58
- * reads it as a window over every group, so a NaN in any row is refused, whichever group it
59
- * falls in and whatever a LIMIT keeps, with no statement of its own.
59
+ * The worst stored exact value among a group's rows, as a level that merges by max: 2 for a
60
+ * NaN in a decimal column (refused), 1 for a value that is no operand (`minorUnits` gives none:
61
+ * it is unread, and `sqlUnread` counts it), 0 when every value is one. A level reads it as a
62
+ * window over every group, so a NaN in any row is refused and an unread value noted, whichever
63
+ * group it falls in and whatever a LIMIT keeps, with no statement of its own.
60
64
  */
61
- function nanPart(b, query, alias) {
62
- const columns = decimalColumns(b.model, query);
65
+ function storedPart(b, query, alias) {
66
+ const columns = readColumns(b.model, query).flatMap((c) => c.kind === "exact" ? [c] : []);
63
67
  if (columns.length === 0) return void 0;
64
- const any = join(columns.map((c) => b.dialect.notFinite(ident(alias, c))), sql` OR `);
68
+ const nan = decimalColumns(b.model, query).map((c) => b.dialect.notFinite(ident(alias, c)));
69
+ const unread = columns.map((c) => {
70
+ const column = ident(alias, c.column);
71
+ return sql`(${column} IS NOT NULL AND ${minorUnits(b, column, c.numeric)} IS NULL)`;
72
+ });
73
+ const level = sql`CASE WHEN ${anyOf(nan)} THEN 2 WHEN ${anyOf(unread)} THEN 1 ELSE 0 END`;
65
74
  return {
66
- agg: sql`count(*) FILTER (WHERE ${any})`,
67
- merge: "sum"
75
+ agg: sql`max(${level})`,
76
+ merge: "max"
68
77
  };
69
78
  }
70
79
  /** A count of rows: the sum of the parts' counts. */
@@ -98,12 +107,15 @@ function float(raw) {
98
107
  const value = typeof raw === "number" ? raw : Number(text(raw) ?? NaN);
99
108
  return Number.isFinite(value) ? value : null;
100
109
  }
101
- /** A stored exact value as a whole number of minor units, or null when it is not one. */
110
+ /**
111
+ * A stored exact value as a whole number of minor units below `OPERAND_LIMIT`, as the one
112
+ * reader reads it, or null when it is not one: then it is unread, and `sqlUnread` counts it.
113
+ */
102
114
  function minorUnits(b, column, numeric) {
103
115
  const value = b.dialect.cast(column, "numeric");
104
- if (numeric.stored === "minor_units") return value;
105
- const shift = keyword(`1${"0".repeat(numeric.scale)}`);
106
- return sql`CASE WHEN ${value} = round(${value}, ${keyword(String(numeric.scale))}) THEN trunc(${value} * ${shift}) END`;
116
+ const units = numeric.stored === "minor_units" ? value : sql`(${value} * ${keyword(`1${"0".repeat(numeric.scale)}`)})`;
117
+ const limit = keyword(String(OPERAND_LIMIT));
118
+ return sql`CASE WHEN ${units} = trunc(${units}) AND abs(${units}) < ${limit} THEN trunc(${units}) END`;
107
119
  }
108
120
  function rowExact(b, scope, def) {
109
121
  const terms = exprLinearTerms(def.of).map((t) => sql`${keyword(String(t.coefficient))} * ${minorUnits(b, ident(scope.alias, t.column), def.numeric)}`);
@@ -188,4 +200,4 @@ function floatCols(b, scope, def, where) {
188
200
  sql: [agg]
189
201
  }), { decode });
190
202
  }
191
- export { columnsLess, countCols, exactCols, floatCols, mergeOf, merged, nanPart, ratioParts, text, windowOf };
203
+ export { columnsLess, countCols, exactCols, floatCols, mergeOf, merged, minorUnits, ratioParts, storedPart, text, windowOf };
@@ -25,8 +25,9 @@ const TYPES = {
25
25
  timestamp: "timestamp",
26
26
  timestamptz: "timestamptz"
27
27
  };
28
- const SHAPE_WITH_OFFSET = "^[0-9]{4}-[0-9]{2}-[0-9]{2}[T ][0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,6})?(Z|[+-][0-9]{2}:[0-9]{2})$";
29
- const SHAPE_NAIVE = "^[0-9]{4}-[0-9]{2}-[0-9]{2}[T ][0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,6})?$";
28
+ const SHAPE_WITH_OFFSET = "^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt ][0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]+)?([Zz]|[+-][0-9]{2}(:[0-9]{2})?)$";
29
+ const SHAPE_NAIVE = "^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt ][0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]+)?$";
30
+ const toMicros = (text) => sql`regexp_replace(${text}, ${"([.][0-9]{6})[0-9]+"}, ${"\\1"})`;
30
31
  const digits = (text, from, length) => sql`substr(${text}, ${keyword(String(from))}, ${keyword(String(length))})::int`;
31
32
  /** Field ranges of the grammar, in integer arithmetic, so no cast below can raise. */
32
33
  function fieldsValid(text) {
@@ -44,7 +45,10 @@ function fieldsValid(text) {
44
45
  function offsetValid(text) {
45
46
  const tail = sql`right(${text}, 5)`;
46
47
  const [hours, minutes] = [digits(tail, 1, 2), digits(tail, 4, 2)];
47
- return sql`(right(${text}, 1) = 'Z' OR (${hours} * 60 + ${minutes} <= 840 AND ${minutes} <= 59))`;
48
+ const whole = sql`${digits(sql`right(${text}, 2)`, 1, 2)} <= 14`;
49
+ const full = sql`(${hours} * 60 + ${minutes} <= 840 AND ${minutes} <= 59)`;
50
+ const hoursOnly = sql`left(right(${text}, 3), 1) IN ('+', '-')`;
51
+ return sql`(upper(right(${text}, 1)) = 'Z' OR CASE WHEN ${hoursOnly} THEN ${whole} ELSE ${full} END)`;
48
52
  }
49
53
  const micros = (value) => sql`(extract(epoch FROM ${value}) * 1000000)::bigint`;
50
54
  /** The instant of a naive wall-clock time: both candidate offsets, then the column's rules. */
@@ -112,9 +116,9 @@ const postgres = {
112
116
  contains: (text, part) => sql`strpos(${text}, ${part}) > 0`,
113
117
  startsWith: (text, part) => sql`starts_with(${text}, ${part})`,
114
118
  textMicros: (text) => sql`CASE WHEN ${text} ~ ${SHAPE_WITH_OFFSET} THEN CASE WHEN ${fieldsValid(text)} AND ${offsetValid(text)}
115
- THEN ${micros(sql`CAST(${text} AS timestamptz)`)} END END`,
119
+ THEN ${micros(sql`CAST(${toMicros(text)} AS timestamptz)`)} END END`,
116
120
  naiveMicros: (text, rule) => sql`CASE WHEN ${text} ~ ${SHAPE_NAIVE} THEN CASE WHEN ${fieldsValid(text)}
117
- THEN ${micros(resolveNaive(sql`CAST(${text} AS timestamp)`, rule))} END END`,
121
+ THEN ${micros(resolveNaive(sql`CAST(${toMicros(text)} AS timestamp)`, rule))} END END`,
118
122
  timestamptzMicros: micros,
119
123
  dateMicros: (value, zone) => micros(sql`(CAST(${value} AS timestamp) AT TIME ZONE ${zone})`),
120
124
  dateEpochDay: (value) => sql`(${value} - ${EPOCH_DATE})`,
@@ -2,7 +2,7 @@ import { filterMembers, relation, scopeFrom } from "./build.mjs";
2
2
  import { filterSql, guardSql } from "./filter.mjs";
3
3
  import { bound, measureCols, measureFilters, queryMeasures } from "./measure.mjs";
4
4
  import { memberSql } from "./members.mjs";
5
- import { nanPart } from "./numbers.mjs";
5
+ import { storedPart } from "./numbers.mjs";
6
6
  import { ident, join, sql } from "./sql.mjs";
7
7
  import { bucketSql } from "./bucket.mjs";
8
8
  import { instantOnce, queryTime, rangeSql } from "./time.mjs";
@@ -108,7 +108,7 @@ function prepareTwoStep(b, query, span, nanOf) {
108
108
  const dims = (query.dimensions ?? []).map((d) => memberSql(b, rows.scope, d.member));
109
109
  const measures = queryMeasures(b, query).map((m) => measureCols(b, rows.scope, m.def, m.line));
110
110
  if (!measures.every((m) => m.parts !== void 0)) return void 0;
111
- const nan = nanPart(b, nanOf, rows.scope.alias);
111
+ const nan = storedPart(b, nanOf, rows.scope.alias);
112
112
  return twoStep(b, rows, dims, {
113
113
  measures,
114
114
  nan,
@@ -125,9 +125,9 @@ function prepare(b, query, span) {
125
125
  const dims = (query.dimensions ?? []).map((d) => memberSql(b, rows.scope, d.member));
126
126
  const parts = {
127
127
  measures: queryMeasures(b, query).map((m) => measureCols(b, rows.scope, m.def, m.line)),
128
- nan: nanPart(b, query, rows.scope.alias),
128
+ nan: storedPart(b, query, rows.scope.alias),
129
129
  bucket: bucketOf(b, query, rows, span)
130
130
  };
131
131
  return dims.some((m) => isCi(m)) && parts.measures.every((m) => m.parts !== void 0) ? twoStep(b, rows, dims, parts) : oneStep(b, rows, dims, parts);
132
132
  }
133
- export { prepare, prepareTwoStep };
133
+ export { factRows, prepare, prepareTwoStep };
@@ -111,7 +111,7 @@ function keptOf(rows, ranks, cap) {
111
111
  const own = rows.filter((row) => Number(row[0]) === setOf(i, n)).toSorted((a, b) => Number(a[1 + n + i]) - Number(b[1 + n + i]));
112
112
  const { want } = counts(r.limit, cap);
113
113
  truncated ||= cap !== void 0 && own.length > cap && r.limit + 1 > cap;
114
- return [r.index, own.slice(0, want).map((row) => primitive(row[1 + i]))];
114
+ return [r.index, own.slice(0, want).map((row) => primitive(row[1 + i], `dimension ${i + 1}`))];
115
115
  })),
116
116
  truncated
117
117
  };
@@ -1,6 +1,6 @@
1
1
  import { assertPlan } from "./assert.mjs";
2
2
  import { withClause } from "./build.mjs";
3
- import { refuseNaN } from "./nan.mjs";
3
+ import { checkStored } from "./nan.mjs";
4
4
  import { seriesGroups, seriesRows } from "./series.mjs";
5
5
  import { decodeCells, decodeRow } from "./shape.mjs";
6
6
  import { sql } from "./sql.mjs";
@@ -13,12 +13,13 @@ async function read(pass, body) {
13
13
  return (await pass.session.run(b.dialect.compile(sql`${withClause(b)}${body}`))).rows;
14
14
  }
15
15
  /**
16
- * Runs a statement whose rows end with a NaN count when `counted` (a window over every group,
17
- * before any LIMIT), and refuses when a decimal column the measures read holds NaN in any row.
16
+ * Runs a statement whose rows end with the worst stored exact value's level when `counted` (a
17
+ * window over every group, before any LIMIT): refuses when a decimal column the measures read
18
+ * holds NaN in any row, and notes a value that is no operand.
18
19
  */
19
20
  async function readCounted(pass, body, counted) {
20
21
  const rows = await read(pass, body);
21
- if (counted) refuseNaN(rows[0]?.at(-1));
22
+ if (counted) checkStored(rows[0]?.at(-1), pass.seen);
22
23
  return rows;
23
24
  }
24
25
  /** How a level's measure columns become cells. */
@@ -3,6 +3,7 @@ import { Kept } from "../query/segments.mjs";
3
3
  import { WireQuery } from "../query/types.mjs";
4
4
  import { Span } from "../time/range.mjs";
5
5
  import { Primitive, SourceName } from "../types/primitives.mjs";
6
+ import { Unread } from "../value/stored.mjs";
6
7
  import { AccessPlan } from "./plan.mjs";
7
8
  import { RecordPage } from "./record-layout.mjs";
8
9
  import { Decoded } from "./shape.mjs";
@@ -102,6 +103,11 @@ export type Store = {
102
103
  sources(): SourceName[];
103
104
  /** The rows of a records page, `limit` and one more, as cells by column. */
104
105
  records(ask: RecordsAsk): Promise<RecordRows>;
106
+ /**
107
+ * The stored values a query's answer leaves out because they do not read as their column's
108
+ * storage, by column (`readColumns`): what the oracle's `unread` counts on the same rows.
109
+ */
110
+ unread(query: WireQuery): Promise<Unread[]>;
105
111
  /** Every limited dimension's kept values in one read, when the store can rank them so. */
106
112
  keptBySets?(query: WireQuery): Promise<{
107
113
  kept: Kept;
@@ -1,5 +1,5 @@
1
1
  import { recordDimensions } from "../model/member.mjs";
2
- import { formatTextTime } from "../time/instant.mjs";
2
+ import { formatTextTime, wholeMicros } from "../time/instant.mjs";
3
3
  import { sourceDef } from "./access.mjs";
4
4
  // src/engine/record-layout.ts
5
5
  /** The columns a records view shows, from the model's one rule (`recordDimensions`), or the caller's. */
@@ -17,9 +17,9 @@ function orderOf(def) {
17
17
  if (def.records?.order !== void 0) return def.records.order;
18
18
  return def.time === void 0 ? [] : [[def.time, "desc"]];
19
19
  }
20
- function decode(dim, raw) {
20
+ function decode({ id, dim }, raw) {
21
21
  if (raw === null || raw === void 0) return null;
22
- if (dim.kind === "time") return formatTextTime(Number(raw));
22
+ if (dim.kind === "time") return formatTextTime(wholeMicros(raw, id));
23
23
  if (typeof raw === "bigint") return raw.toString();
24
24
  if (typeof raw === "string" || typeof raw === "number" || typeof raw === "boolean") return raw;
25
25
  return raw instanceof Date ? raw.toISOString() : JSON.stringify(raw);
@@ -1,3 +1,4 @@
1
+ import { answersWhole, withoutGrain } from "../query/fold.mjs";
1
2
  import { readsPrevious } from "../result/calc.mjs";
2
3
  import { comparisonQuery } from "../time/compare.mjs";
3
4
  import { formatTextTime } from "../time/instant.mjs";
@@ -58,8 +59,78 @@ async function periods(first, before) {
58
59
  })];
59
60
  }
60
61
  /**
62
+ * A pass of the query without its grain (`withoutGrain`), over the same span, through the same
63
+ * base: the same access plan, store and session, so `assertPlan` checks each of its statements
64
+ * as it does the query's own. Its totals read the uncut query without its grain, as the
65
+ * query's own read the uncut query.
66
+ */
67
+ function folded(base, pass) {
68
+ const own = passFor(base, withoutGrain(pass.query));
69
+ return pass.whole === void 0 ? own : {
70
+ ...own,
71
+ whole: passFor(base, withoutGrain(pass.whole.query))
72
+ };
73
+ }
74
+ const periodsOf = ([now, before]) => ({
75
+ now: now.answer,
76
+ before: before?.answer
77
+ });
78
+ /** Rows cut to the groups `kept` has, by their dimension cells after `offset`. */
79
+ function cutTo(rows, kept, offset, width) {
80
+ const dimsOf = (row) => canonical(row.slice(offset, offset + width));
81
+ const keys = new Set(kept.map((row) => dimsOf(row)));
82
+ return rows.filter((row) => keys.has(dimsOf(row)));
83
+ }
84
+ /** A fold's answer as the whole of another: its rows, Other and totals; a cut says the answer is cut. */
85
+ function wholeOf(answer, fold) {
86
+ if (fold === void 0) return answer;
87
+ const { rows, other, totals, truncated } = fold;
88
+ return {
89
+ ...answer,
90
+ whole: {
91
+ rows,
92
+ ...other === void 0 ? {} : { other },
93
+ ...totals === void 0 ? {} : { totals }
94
+ },
95
+ ...truncated === true ? { truncated } : {}
96
+ };
97
+ }
98
+ /**
99
+ * The answer with its comparison period's rows cut to its groups and, with the fold, its whole
100
+ * and its comparison's whole cut to the whole's groups.
101
+ */
102
+ function joined(query, own, fold, range) {
103
+ const main = wholeOf(own.now, fold?.now);
104
+ if (own.before === void 0 || range === void 0) return main;
105
+ const offset = query.time?.grain === void 0 ? 0 : 1;
106
+ const width = (query.dimensions ?? []).length;
107
+ const then = fold && wholeBefore(fold, width);
108
+ return {
109
+ ...main,
110
+ compare: {
111
+ ...cutPeriod(own.before, own.now, offset, width),
112
+ range,
113
+ ...then === void 0 ? {} : { whole: then }
114
+ }
115
+ };
116
+ }
117
+ /** A comparison period's rows cut to the groups `now` has, and its totals. */
118
+ function cutPeriod(before, now, offset, width) {
119
+ const rows = cutTo(before.rows, now.rows, offset, width);
120
+ return before.totals === void 0 ? { rows } : {
121
+ rows,
122
+ totals: before.totals
123
+ };
124
+ }
125
+ /** The comparison's whole: its rows cut to the groups the main whole has, and its totals. */
126
+ const wholeBefore = (fold, width) => fold.before && cutPeriod(fold.before, fold.now, 0, width);
127
+ /**
61
128
  * `whole`: the query whose rows the totals and `total` refs read, when not `input.query`
62
- * (the uncut query, for a query whose dimensions have cuts).
129
+ * (the uncut query, for a query whose dimensions have cuts). With `time.whole`, the query
130
+ * without its grain is read after it in the same session, and so is its comparison period.
131
+ * Those reads are separate statements: the engine already reads each kept group over the whole
132
+ * range to rank it and, for a calc that reads the total, the whole itself, but this answer does
133
+ * not reuse them yet (a known gap: one or two more statements per answer that asks for its whole).
63
134
  */
64
135
  async function runPlain(input, reader, whole) {
65
136
  const base = startBase(input, reader);
@@ -74,29 +145,15 @@ async function runPlain(input, reader, whole) {
74
145
  ...input,
75
146
  query: whole
76
147
  }));
77
- const [{ answer: main }, earlier] = await periods(first, before);
78
- const previous = earlier?.answer;
79
- const ran = (a) => ({
80
- answer: a,
148
+ const own = periodsOf(await periods(first, before));
149
+ const fold = answersWhole(input.query) ? periodsOf(await periods(folded(base, first), before && folded(base, before))) : void 0;
150
+ return {
151
+ answer: joined(input.query, own, fold, second?.range),
81
152
  sources: base.store.sources(),
82
153
  ...first.span === void 0 ? {} : { range: {
83
154
  from: formatTextTime(first.span.from),
84
155
  to: formatTextTime(first.span.to)
85
156
  } }
86
- });
87
- if (second === void 0 || previous === void 0) return ran(main);
88
- const offset = input.query.time?.grain === void 0 ? 0 : 1;
89
- const width = (input.query.dimensions ?? []).length;
90
- const dimsOf = (row) => canonical(row.slice(offset, offset + width));
91
- const keys = new Set(main.rows.map((row) => dimsOf(row)));
92
- const totals = previous.totals === void 0 ? {} : { totals: previous.totals };
93
- return ran({
94
- ...main,
95
- compare: {
96
- rows: previous.rows.filter((row) => keys.has(dimsOf(row))),
97
- ...totals,
98
- range: second.range
99
- }
100
- });
157
+ };
101
158
  }
102
159
  export { runPlain };
@@ -6,6 +6,7 @@ import { EngineInput, Ran } from "./types.mjs";
6
6
  export declare function runQuery(input: EngineInput, session: ReadSession, dialect?: Dialect): Promise<Ran>;
7
7
  /**
8
8
  * Answers a query through a reader with the answer the oracle gives on the same rows. A
9
- * dimension with a limit of its own runs as the queries `query/segments` defines.
9
+ * dimension with a limit of its own runs as the queries `query/segments` defines. Stored
10
+ * values that do not read as their column's storage are left out and counted (`unread`).
10
11
  */
11
12
  export declare function readQuery(input: EngineInput, reader: Reader): Promise<Ran>;
@@ -1,4 +1,4 @@
1
- import { hasSegments, keptQuery, limitedDimensions, rankQuery, segmentCuts, segmentOtherQuery, segmentOthers, segmentSplit, uncutQuery } from "../query/segments.mjs";
1
+ import { hasSegments, keptQuery, limitedDimensions, rankQuery, segmentCuts, segmentOtherQuery, segmentSplit, uncutQuery, withSegmentOthers } from "../query/segments.mjs";
2
2
  import { startBase } from "./context.mjs";
3
3
  import { postgres } from "./postgres.mjs";
4
4
  import { each } from "./reader.mjs";
@@ -35,9 +35,22 @@ function splitting(query, kept, reader, queries) {
35
35
  }
36
36
  /**
37
37
  * Answers a query through a reader with the answer the oracle gives on the same rows. A
38
- * dimension with a limit of its own runs as the queries `query/segments` defines.
38
+ * dimension with a limit of its own runs as the queries `query/segments` defines. Stored
39
+ * values that do not read as their column's storage are left out and counted (`unread`).
39
40
  */
40
41
  async function readQuery(input, reader) {
42
+ const ran = await readRows(input, reader);
43
+ if (ran.answer.unreadable === true) return ran;
44
+ const unread = await startBase(input, reader).store.unread(input.query);
45
+ return unread.length === 0 ? ran : {
46
+ ...ran,
47
+ answer: {
48
+ ...ran.answer,
49
+ unread
50
+ }
51
+ };
52
+ }
53
+ async function readRows(input, reader) {
41
54
  if (!hasSegments(input.query)) return runPlain(input, reader);
42
55
  const { query } = input;
43
56
  const rank = (q) => runPlain({
@@ -63,20 +76,14 @@ async function readQuery(input, reader) {
63
76
  cuts: segmentCuts(query, kept)
64
77
  };
65
78
  }
66
- /** The kept query's answer with Other's rows, now and in the comparison period. */
79
+ /** The kept query's answer with Other's rows, now and in the comparison period, and each whole's. */
67
80
  function withSegmentOther(query, main, folded, truncated) {
68
- const { now, before } = segmentOthers(query, folded?.answer);
69
- const { compare } = main.answer;
81
+ const answer = withSegmentOthers(query, main.answer, folded?.answer);
70
82
  return {
71
83
  ...main,
72
84
  answer: {
73
- ...main.answer,
74
- ...truncated ? { truncated: true } : {},
75
- ...now === void 0 ? {} : { segmentOther: now },
76
- ...compare === void 0 || before === void 0 ? {} : { compare: {
77
- ...compare,
78
- segmentOther: before
79
- } }
85
+ ...answer,
86
+ ...truncated ? { truncated: true } : {}
80
87
  }
81
88
  };
82
89
  }
@@ -78,7 +78,7 @@ function seriesRows(shape, rows) {
78
78
  const start = 1 + group + groupOrder(series, p.keys.length).length;
79
79
  const after = labelled(p).length + parts(p).length + extra;
80
80
  return rows.map((raw) => ({
81
- rank: Number(primitive(raw[0])),
81
+ rank: Number(primitive(raw[0], "rank")),
82
82
  row: decodeRow(layout, raw.slice(start, raw.length - after)),
83
83
  group: raw.slice(1, 1 + group)
84
84
  }));
@@ -1,21 +1,21 @@
1
+ import { answerInvalid } from "../error/refusal.mjs";
1
2
  import { valueRow } from "../result/calc.mjs";
2
3
  import { comparator, compareKeys } from "../result/order.mjs";
3
4
  import { zeroValues } from "../result/zero.mjs";
4
5
  import { bucketLabels, epochDayLabel } from "../time/bucket.mjs";
5
- import { formatTextTime } from "../time/instant.mjs";
6
+ import { formatTextTime, wholeMicros } from "../time/instant.mjs";
6
7
  import { canonical } from "../value/canonical.mjs";
7
8
  // src/engine/shape.ts
8
9
  /** A value from the driver as a plain primitive; big integers arrive as text. */
9
- function primitive(raw) {
10
+ function primitive(raw, column) {
10
11
  if (raw === null || raw === void 0) return null;
11
12
  if (typeof raw === "string" || typeof raw === "number" || typeof raw === "boolean") return raw;
12
13
  if (typeof raw === "bigint") return raw.toString();
13
- throw new TypeError(`The driver returned a ${typeof raw} where a plain value was expected.`);
14
+ throw answerInvalid(column, `the driver returned a ${typeof raw} where a plain value was expected.`);
14
15
  }
15
16
  function bucketLabel(raw, grain) {
16
- const value = primitive(raw);
17
- if (value === null || grain === void 0) return null;
18
- return grain === "hour" ? formatTextTime(Number(value)) : epochDayLabel(Number(value));
17
+ if (raw === null || raw === void 0 || grain === void 0) return null;
18
+ return grain === "hour" ? formatTextTime(wholeMicros(raw, "bucket")) : epochDayLabel(Number(primitive(raw, "bucket")));
19
19
  }
20
20
  function decodeRow(layout, raw) {
21
21
  let rest = raw;
@@ -25,8 +25,8 @@ function decodeRow(layout, raw) {
25
25
  return part;
26
26
  };
27
27
  const bucket = layout.bucket ? bucketLabel(next(1)[0], layout.grain) : null;
28
- const key = next(layout.keys).map((v) => primitive(v));
29
- const labels = next(layout.labelled.filter(Boolean).length).map((v) => primitive(v));
28
+ const key = next(layout.keys).map((v, i) => primitive(v, `dimension ${i + 1}`));
29
+ const labels = next(layout.labelled.filter(Boolean).length).map((v, i) => primitive(v, `label ${i + 1}`));
30
30
  return {
31
31
  bucket,
32
32
  key,
@@ -1,4 +1,4 @@
1
- import { refuseNaN } from "./nan.mjs";
1
+ import { checkStored } from "./nan.mjs";
2
2
  import { layoutOf, read } from "./read.mjs";
3
3
  import { decodeRow } from "./shape.mjs";
4
4
  import { ident, join, sql } from "./sql.mjs";
@@ -34,7 +34,7 @@ async function readPartition(pass, order, limit) {
34
34
  bucket: false
35
35
  });
36
36
  for (const raw of await read(pass, partitionSql(pass, order, limit))) {
37
- if (pass.p.nan !== void 0) refuseNaN(raw.at(-1));
37
+ if (pass.p.nan !== void 0) checkStored(raw.at(-1), pass.seen);
38
38
  const group = decodeRow(layout, raw.slice(2, pass.p.nan === void 0 ? void 0 : -1));
39
39
  if (Number(raw[0]) === 1) result.total = group;
40
40
  else if (raw[1] === null) result.other = group;
@@ -1,7 +1,7 @@
1
1
  import { relationBody } from "./filter.mjs";
2
2
  // src/engine/sql-pass.ts
3
3
  /** One request's statement build, empty, and what the plan check is told. */
4
- function sqlBase(input, plan, session, dialect) {
4
+ function sqlBase(input, plan, { session, seen }, dialect) {
5
5
  return {
6
6
  b: {
7
7
  model: input.model,
@@ -18,7 +18,8 @@ function sqlBase(input, plan, session, dialect) {
18
18
  principal: input.principal,
19
19
  expectedLocks: input.locks ?? [],
20
20
  expectedRequired: input.required ?? []
21
- }
21
+ },
22
+ seen
22
23
  };
23
24
  }
24
25
  export { sqlBase };
@@ -4,6 +4,7 @@ import { keptBySets } from "./rank-sets.mjs";
4
4
  import { sqlBase } from "./sql-pass.mjs";
5
5
  import { sqlRecords } from "./sql-records.mjs";
6
6
  import { readsOf, splitState } from "./sql-split.mjs";
7
+ import { sqlUnread } from "./sql-unread.mjs";
7
8
  // src/engine/sql-reader.ts
8
9
  const keyOf = (s) => JSON.stringify([s.text, s.params.map((p) => p instanceof Uint8Array ? { bytes: [...p] } : p)]);
9
10
  /**
@@ -23,20 +24,27 @@ function once(session) {
23
24
  }
24
25
  };
25
26
  }
26
- /** The reader on a session that already runs each statement once: a split's is its parent's. */
27
- function readerOn(session, dialect, split) {
27
+ /**
28
+ * The reader on a session that already runs each statement once: a split's is its parent's,
29
+ * and so is what its statements have seen of the stored values.
30
+ */
31
+ function readerOn(session, dialect, seen, split) {
28
32
  return {
29
33
  ...session.concurrent === true ? { concurrent: true } : {},
30
34
  open(input, plan) {
31
- const base = sqlBase(input, plan, session, dialect);
35
+ const base = sqlBase(input, plan, {
36
+ session,
37
+ seen
38
+ }, dialect);
32
39
  return {
33
40
  reads: (query, span) => readsOf(base, query, span, split),
34
41
  sources: () => [...base.b.relations.keys()].toSorted(),
35
42
  records: (ask) => sqlRecords(base, ask),
43
+ unread: (query) => sqlUnread(base, query),
36
44
  keptBySets: (query) => keptBySets(base, query, spanOf(input, query))
37
45
  };
38
46
  },
39
- split: (s) => readerOn(session, dialect, splitState(s))
47
+ split: (s) => readerOn(session, dialect, seen, splitState(s))
40
48
  };
41
49
  }
42
50
  /**
@@ -46,6 +54,6 @@ function readerOn(session, dialect, split) {
46
54
  * statement per level, in the period asked and in its comparison period.
47
55
  */
48
56
  function sqlReader(given, dialect = postgres) {
49
- return readerOn(once(given), dialect);
57
+ return readerOn(once(given), dialect, { unread: false });
50
58
  }
51
59
  export { sqlReader };
@@ -1,3 +1,4 @@
1
+ import { decimalColumns } from "../model/storage.mjs";
1
2
  import { columnsLess } from "./numbers.mjs";
2
3
  import { measureLayout, readLevel } from "./read.mjs";
3
4
  import { decodeCells } from "./shape.mjs";
@@ -24,7 +25,7 @@ function sqlReads(pass) {
24
25
  ranks: (index) => p.measures[index]?.order !== void 0,
25
26
  windowTotals: p.measures.every((m) => m.parts !== void 0),
26
27
  ...pass.b.dialect.groupingSets === true && p.staged === void 0 && !additive ? { partition: (order, limit) => readPartition(pass, order, limit) } : {},
27
- narrows: p.nan === void 0,
28
+ narrows: decimalColumns(pass.b.model, pass.query).length === 0,
28
29
  ...additive ? { lessKept } : {}
29
30
  };
30
31
  }
@@ -94,8 +94,8 @@ async function sqlRecords(base, ask) {
94
94
  raw.push(...await read(pass, statement(test, want - raw.length)));
95
95
  }
96
96
  return {
97
- rows: raw.map((r) => columns.map((c, i) => decode(c.dim, r[i]))),
98
- at: raw.map((r) => r.slice(columns.length).map((v) => primitive(v)))
97
+ rows: raw.map((r) => columns.map((c, i) => decode(c, r[i]))),
98
+ at: raw.map((r) => r.slice(columns.length).map((v, i) => primitive(v, `order ${i + 1}`)))
99
99
  };
100
100
  }
101
101
  export { sqlRecords };
@@ -28,7 +28,7 @@ const splitState = (split) => ({
28
28
  stash: /* @__PURE__ */ new Map()
29
29
  });
30
30
  /** A level of one period as a key: the whole level, in its canonical form. */
31
- const levelKey = (span, l) => canonical([span ?? null, l]);
31
+ const levelKey = (span, l) => canonical([span === void 0 ? null : [String(span.from), String(span.to)], l]);
32
32
  /** A grouped level of every row, ranked or not: one the split reads for both queries. */
33
33
  const splits = (l) => l.keys && l.restrict === void 0 && l.totals !== true && l.nonEmpty !== true && !(l.bucket && l.take !== void 0);
34
34
  /** Other's order: the kept query's without the folded dimension, later dimensions one down. */
@@ -0,0 +1,70 @@
1
+ import { readColumns } from "../model/storage.mjs";
2
+ import { INSTANTS } from "../time/text-time.mjs";
3
+ import { spanOf } from "./checks.mjs";
4
+ import { instantSql } from "./members.mjs";
5
+ import { minorUnits } from "./numbers.mjs";
6
+ import { factRows } from "./prepare.mjs";
7
+ import { read } from "./read.mjs";
8
+ import { ident, join, sql } from "./sql.mjs";
9
+ import { queryTime } from "./time.mjs";
10
+ // src/engine/sql-unread.ts
11
+ /** Whether the database's own type reads a storage: then every stored value is an instant. */
12
+ const typed = (storage) => storage === "timestamptz" || storage === "date";
13
+ /** A row whose time is set but is no instant: it does not parse, its rule excludes it, or it is out of range. */
14
+ function unreadSql(column, instant) {
15
+ const [from, last] = [String(INSTANTS.from), String(INSTANTS.to - INSTANTS.from - 1n)];
16
+ const known = sql`(${instant} - CAST(${from} AS bigint)) BETWEEN 0 AND CAST(${last} AS bigint)`;
17
+ return sql`${column} IS NOT NULL AND NOT COALESCE(${known}, FALSE)`;
18
+ }
19
+ /**
20
+ * The time values that do not read, over the rows the query reads without its range (an
21
+ * unread time is in no range). A `timestamptz` or `date` column is read by the database's own
22
+ * type, so it has none.
23
+ */
24
+ async function timeUnread(base, query) {
25
+ const time = queryTime(base.b, query);
26
+ if (time === void 0 || typed(time.storage)) return [];
27
+ const rows = factRows(base.b, query);
28
+ const test = unreadSql(ident("f", time.column), instantSql(base.b, "f", time));
29
+ const body = sql`SELECT count(*) FROM ${rows.from} WHERE ${rows.where} AND ${test}`;
30
+ const [row] = await read(base, body);
31
+ const count = Number(row?.[0] ?? 0);
32
+ return count === 0 ? [] : [{
33
+ source: query.source,
34
+ column: time.column,
35
+ count
36
+ }];
37
+ }
38
+ /**
39
+ * The exact values that are set but are no operand (`minorUnits` gives none: past the scale or
40
+ * the operand bound), over the rows the query aggregates, in one statement. Only when a read
41
+ * noted one (`storedPart`): an answer whose values all read runs no statement for this.
42
+ */
43
+ async function exactUnread(base, query) {
44
+ const columns = readColumns(base.b.model, query).flatMap((c) => c.kind === "exact" ? [c] : []);
45
+ if (columns.length === 0 || !base.seen.unread) return [];
46
+ const rows = factRows(base.b, query, spanOf(base.input, query));
47
+ const counts = columns.map((c) => {
48
+ const column = ident("f", c.column);
49
+ const units = minorUnits(base.b, column, c.numeric);
50
+ return sql`count(*) FILTER (WHERE ${column} IS NOT NULL AND ${units} IS NULL)`;
51
+ });
52
+ const [row] = await read(base, sql`SELECT ${join(counts)} FROM ${rows.from} WHERE ${rows.where}`);
53
+ return columns.flatMap((c, i) => {
54
+ const count = Number(row?.[i] ?? 0);
55
+ return count === 0 ? [] : [{
56
+ source: query.source,
57
+ column: c.column,
58
+ count
59
+ }];
60
+ });
61
+ }
62
+ /**
63
+ * The values a query's answer leaves out because they do not read as their column's storage,
64
+ * by column, in the order every engine counts them (`readColumns`): its time, then its exact
65
+ * columns.
66
+ */
67
+ async function sqlUnread(base, query) {
68
+ return [...await timeUnread(base, query), ...await exactUnread(base, query)];
69
+ }
70
+ export { sqlUnread };
@@ -47,6 +47,7 @@ function rangeSql(b, dim, span, at) {
47
47
  return sql`${column} >= CAST(${from} AS timestamptz) AND ${column} < CAST(${to} AS timestamptz)`;
48
48
  }
49
49
  const instant = at ?? instantSql(b, alias, dim);
50
- return sql`${instant} >= ${span.from} AND ${instant} < ${span.to}`;
50
+ const [from, to] = [String(span.from), String(span.to)];
51
+ return sql`${instant} >= CAST(${from} AS bigint) AND ${instant} < CAST(${to} AS bigint)`;
51
52
  }
52
53
  export { bucketSql, instantOnce, queryTime, rangeSql };