@bino-bi/bn-template-engine 1.0.0-next.26 → 1.0.0-next.28

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 (420) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/p-5075771a.entry.js +1 -0
  3. package/dist/bn-template-engine/p-5d516435.entry.js +1 -0
  4. package/dist/bn-template-engine/p-5e90e728.entry.js +1 -0
  5. package/dist/bn-template-engine/p-9ef7e132.entry.js +1 -0
  6. package/dist/bn-template-engine/{p-f06c3703.entry.js → p-9f7a1980.entry.js} +1 -1
  7. package/dist/bn-template-engine/p-BeXgxHkW.js +1 -0
  8. package/dist/bn-template-engine/p-CH0bpt_k.js +1 -0
  9. package/dist/bn-template-engine/p-ClruFZD_.js +1 -0
  10. package/dist/bn-template-engine/{p-CTrNbSXN.js → p-DFmSrSnf.js} +1 -1
  11. package/dist/bn-template-engine/{p-BcLsoDrW.js → p-DI3efDSV.js} +1 -1
  12. package/dist/bn-template-engine/p-DXLTTILG.js +1 -0
  13. package/dist/bn-template-engine/p-DtP4jqG5.js +1 -0
  14. package/dist/bn-template-engine/p-a8281b71.entry.js +1 -0
  15. package/dist/bn-template-engine/p-b31277e7.entry.js +1 -0
  16. package/dist/bn-template-engine/p-b396ac84.entry.js +1 -0
  17. package/dist/cjs/{bn-asset_21.cjs.entry.js → bn-asset_28.cjs.entry.js} +21358 -6528
  18. package/dist/cjs/bn-grid.cjs.entry.js +4 -6
  19. package/dist/cjs/bn-image.cjs.entry.js +3 -5
  20. package/dist/cjs/bn-internationalization.cjs.entry.js +17 -6
  21. package/dist/cjs/bn-ruleset.cjs.entry.js +5 -5
  22. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  23. package/dist/cjs/bn-template.cjs.entry.js +2 -2
  24. package/dist/cjs/bn-text.cjs.entry.js +115 -43
  25. package/dist/cjs/{context-protocol-DcTEh1rq.js → context-protocol-C0rKepqu.js} +108 -22
  26. package/dist/cjs/{diagnostics-CTgbq_Gc.js → diagnostics-Cq-qDtXq.js} +1 -1
  27. package/dist/cjs/editor-companion.cjs.entry.js +2 -2
  28. package/dist/cjs/loader.cjs.js +1 -1
  29. package/dist/cjs/queryError-BZjnIW_w.js +16 -0
  30. package/dist/cjs/{scaling-Dsb5_NXy.js → sanitizeHtml-Yx1xn6i_.js} +467 -287
  31. package/dist/cjs/{withBodyObserver-DJO98AJ-.js → withBodyObserver-CaPUjuC5.js} +1 -1
  32. package/dist/cjs/withHasError-qGW_yqIv.js +426 -0
  33. package/dist/cjs/{withStyled-D0jLwCib.js → withStyled-vSfogp9J.js} +543 -42
  34. package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.css +37 -0
  35. package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.js +53 -28
  36. package/dist/collection/components/bn-chart-bubble/ibcs-chart-bubble.css +37 -5
  37. package/dist/collection/components/bn-chart-bubble/ibcs-chart-bubble.js +16 -7
  38. package/dist/collection/components/bn-chart-bubble/utils/BubbleChart.js +67 -30
  39. package/dist/collection/components/bn-chart-bullet/bn-chart-bullet.css +37 -0
  40. package/dist/collection/components/bn-chart-bullet/bn-chart-bullet.js +49 -29
  41. package/dist/collection/components/bn-chart-bullet/ibcs-chart-bullet.css +37 -5
  42. package/dist/collection/components/bn-chart-bullet/ibcs-chart-bullet.js +17 -7
  43. package/dist/collection/components/bn-chart-bullet/utils/BulletChart.js +34 -18
  44. package/dist/collection/components/bn-chart-bullet/utils/model/BulletChartStyle.js +2 -0
  45. package/dist/collection/components/bn-chart-bullet/utils/model/BulletConfig.js +1 -1
  46. package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.css +37 -0
  47. package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.js +52 -27
  48. package/dist/collection/components/bn-chart-scatter/ibcs-chart-scatter.css +37 -5
  49. package/dist/collection/components/bn-chart-scatter/ibcs-chart-scatter.js +16 -7
  50. package/dist/collection/components/bn-chart-scatter/utils/ScatterChart.js +52 -18
  51. package/dist/collection/components/bn-chart-structure/bn-chart-structure.css +37 -5
  52. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +74 -44
  53. package/dist/collection/components/bn-chart-structure/ibcs-chart-structure.js +60 -19
  54. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +218 -262
  55. package/dist/collection/components/bn-chart-structure/utils/elements/Label.js +1 -1
  56. package/dist/collection/components/bn-chart-structure/utils/elements/Needle.js +11 -4
  57. package/dist/collection/components/bn-chart-structure/utils/elements/StackedBar.js +16 -25
  58. package/dist/collection/components/bn-chart-structure/utils/model/StructureChartComponentConfig.js +3 -2
  59. package/dist/collection/components/bn-chart-structure/utils/model/styles/StructureChartStyle.js +2 -0
  60. package/dist/collection/components/bn-chart-time/bn-chart-time.css +37 -0
  61. package/dist/collection/components/bn-chart-time/bn-chart-time.js +122 -52
  62. package/dist/collection/components/bn-chart-time/ibcs-chart-time.css +37 -0
  63. package/dist/collection/components/bn-chart-time/ibcs-chart-time.js +60 -19
  64. package/dist/collection/components/bn-chart-time/utils/TimeChart.js +245 -250
  65. package/dist/collection/components/bn-chart-time/utils/elements/AreaFill.js +1 -1
  66. package/dist/collection/components/bn-chart-time/utils/elements/Label.js +1 -1
  67. package/dist/collection/components/bn-chart-time/utils/elements/LineSeries.js +1 -1
  68. package/dist/collection/components/bn-chart-time/utils/elements/Needle.js +11 -4
  69. package/dist/collection/components/bn-chart-time/utils/elements/StackedColumn.js +22 -34
  70. package/dist/collection/components/bn-chart-time/utils/helper/LabelCollisionManager.js +3 -3
  71. package/dist/collection/components/bn-chart-time/utils/model/TimeChartComponentConfig.js +4 -3
  72. package/dist/collection/components/bn-chart-time/utils/model/TimeChartDataRow.js +2 -2
  73. package/dist/collection/components/bn-chart-time/utils/model/styles/TimeChartStyle.js +2 -0
  74. package/dist/collection/components/bn-component-style/bn-component-style.js +14 -2
  75. package/dist/collection/components/bn-context/bn-context.js +92 -22
  76. package/dist/collection/components/bn-dataset/bn-dataset.js +246 -90
  77. package/dist/collection/components/bn-datasource/bn-datasource.js +169 -77
  78. package/dist/collection/components/bn-footer/bn-footer.js +6 -6
  79. package/dist/collection/components/bn-internationalization/bn-internationalization.js +14 -3
  80. package/dist/collection/components/bn-layout-card/bn-layout-card.js +25 -74
  81. package/dist/collection/components/bn-layout-page/bn-layout-page.js +59 -71
  82. package/dist/collection/components/bn-message/bn-message.js +2 -2
  83. package/dist/collection/components/bn-page/bn-page.css +0 -240
  84. package/dist/collection/components/bn-page/bn-page.js +14 -4
  85. package/dist/collection/components/bn-page/pageFormats.js +69 -0
  86. package/dist/collection/components/bn-ruleset/bn-ruleset.js +2 -2
  87. package/dist/collection/components/bn-scaling-group/bn-scaling-group.js +7 -7
  88. package/dist/collection/components/bn-table/bn-table.css +38 -1
  89. package/dist/collection/components/bn-table/bn-table.js +96 -59
  90. package/dist/collection/components/bn-table/ibcs-table.css +39 -1
  91. package/dist/collection/components/bn-table/ibcs-table.js +89 -30
  92. package/dist/collection/components/bn-table/utils/Table.js +12 -13
  93. package/dist/collection/components/bn-table/utils/elements/Cell.js +9 -3
  94. package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +38 -34
  95. package/dist/collection/components/bn-table/utils/elements/TableRow.js +2 -1
  96. package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +4 -4
  97. package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +17 -4
  98. package/dist/collection/components/bn-table/utils/helper/DataQuery.js +128 -98
  99. package/dist/collection/components/bn-table/utils/helper/IntervalColumns.js +6 -20
  100. package/dist/collection/components/bn-table/utils/helper/QueryGroup.js +9 -2
  101. package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +2 -2
  102. package/dist/collection/components/bn-table/utils/model/TableAttribute.js +2 -2
  103. package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +3 -2
  104. package/dist/collection/components/bn-template/bn-template.js +1 -1
  105. package/dist/collection/components/bn-text/bn-text.js +36 -39
  106. package/dist/collection/components/bn-text/utils/template.js +79 -0
  107. package/dist/collection/components/bn-title/bn-title.js +10 -4
  108. package/dist/collection/components/bn-title/ibcs-title/ibcs-title.js +3 -1
  109. package/dist/collection/components/bn-tree/bn-tree.js +119 -23
  110. package/dist/collection/components/bn-tree/utils/EdgeRenderer.js +59 -51
  111. package/dist/collection/components/bn-tree/utils/TreeLayout.js +30 -5
  112. package/dist/collection/components/bn-tree/utils/TreeParser.js +35 -0
  113. package/dist/collection/components/editor-companion/editor-companion.js +1 -1
  114. package/dist/collection/context/context-protocol.js +1 -1
  115. package/dist/collection/context/scopedDb.js +47 -4
  116. package/dist/collection/stores/componentStyles.js +39 -0
  117. package/dist/collection/stores/internationalization.js +15 -13
  118. package/dist/collection/utils/DateStringFactory.js +17 -15
  119. package/dist/collection/utils/autoFit.js +2 -2
  120. package/dist/collection/utils/componentRegister.js +60 -16
  121. package/dist/collection/utils/constants.js +2 -2
  122. package/dist/collection/utils/dataAnalyzer.js +9 -12
  123. package/dist/collection/utils/emptyState.js +21 -0
  124. package/dist/collection/utils/formatter.js +29 -20
  125. package/dist/collection/utils/layoutObserver.js +1 -1
  126. package/dist/collection/utils/layoutState/generic.js +1 -1
  127. package/dist/collection/utils/layoutState/svgChartElements.js +2 -2
  128. package/dist/collection/utils/layoutTemplate.js +81 -0
  129. package/dist/collection/utils/measurementHost.js +2 -2
  130. package/dist/collection/utils/model/Order.js +1 -1
  131. package/dist/collection/utils/model/styles/SVGStyle.js +12 -4
  132. package/dist/collection/utils/parentDimensions.js +35 -3
  133. package/dist/collection/utils/queryError.js +11 -0
  134. package/dist/collection/utils/relativeVariance.js +14 -0
  135. package/dist/collection/utils/sanitizeHtml.js +30 -16
  136. package/dist/collection/utils/scaling.js +2 -2
  137. package/dist/collection/utils/stackColors.js +27 -5
  138. package/dist/collection/utils/stackLayout.js +71 -0
  139. package/dist/collection/utils/styled/attributes.js +16 -3
  140. package/dist/collection/utils/styled/style-sheet.js +1 -1
  141. package/dist/collection/utils/styled/withStyled.js +1 -1
  142. package/dist/collection/utils/testing/fakeGroup.js +21 -0
  143. package/dist/collection/utils/testing/mutationObserver.js +44 -0
  144. package/dist/collection/utils/testing/structureChart.js +26 -0
  145. package/dist/collection/utils/testing/timeChart.js +28 -0
  146. package/dist/collection/utils/validate.js +1 -1
  147. package/dist/collection/utils/withComponentStatus.js +137 -12
  148. package/dist/collection/utils/withInheritedProps.js +113 -64
  149. package/dist/collection/utils/withRuleSet.js +10 -7
  150. package/dist/collection/utils/withTranslation.js +3 -3
  151. package/dist/collection/utils/xy/FacetGrid.js +1 -1
  152. package/dist/collection/utils/xy/IsoCurves.js +1 -1
  153. package/dist/collection/utils/xy/NumericScale.js +46 -15
  154. package/dist/collection/utils/xy/PointLabeler.js +2 -2
  155. package/dist/collection/utils/xy/RadiusScale.js +2 -2
  156. package/dist/collection/utils/xy/SeriesPalette.js +3 -3
  157. package/dist/collection/utils/xy/VarianceMeasure.js +22 -4
  158. package/dist/collection/utils/xy/XYFrame.js +4 -4
  159. package/dist/collection/utils/xy/XYLegend.js +5 -7
  160. package/dist/collection/utils/xy/checkXYOverflow.js +32 -0
  161. package/dist/collection/utils/xy/formatXYValue.js +13 -0
  162. package/dist/collection/utils/xy/model/XYChartDataRow.js +0 -0
  163. package/dist/collection/utils/xy/model/XYChartStyle.js +2 -0
  164. package/dist/components/DataFormatDigits.js +1 -1
  165. package/dist/components/DateStringFactory.js +1 -1
  166. package/dist/components/LabelCollisionManager.js +1 -1
  167. package/dist/components/NumericScale.js +1 -1
  168. package/dist/components/Order.js +1 -1
  169. package/dist/components/SVGStyle.js +1 -0
  170. package/dist/components/TableAttribute.js +1 -0
  171. package/dist/components/VarianceMeasure.js +1 -1
  172. package/dist/components/XYChartDataRow.js +1 -1
  173. package/dist/components/bn-asset.js +1 -1
  174. package/dist/components/bn-body2.js +1 -1
  175. package/dist/components/bn-card2.js +1 -1
  176. package/dist/components/bn-chart-bubble.js +1 -1
  177. package/dist/components/bn-chart-bullet.js +1 -1
  178. package/dist/components/bn-chart-scatter.js +1 -1
  179. package/dist/components/bn-chart-structure.js +1 -1
  180. package/dist/components/bn-chart-time.js +1 -1
  181. package/dist/components/bn-component-style.js +1 -1
  182. package/dist/components/bn-context.js +1 -1
  183. package/dist/components/bn-dataset.js +1 -1
  184. package/dist/components/bn-datasource.js +1 -1
  185. package/dist/components/bn-footer2.js +1 -1
  186. package/dist/components/bn-grid.js +1 -1
  187. package/dist/components/bn-image.js +1 -1
  188. package/dist/components/bn-internationalization.js +1 -1
  189. package/dist/components/bn-layout-card.js +1 -1
  190. package/dist/components/bn-layout-page.js +1 -1
  191. package/dist/components/bn-message2.js +1 -1
  192. package/dist/components/bn-page2.js +1 -1
  193. package/dist/components/bn-ruleset.js +1 -1
  194. package/dist/components/bn-scaling-group.js +1 -1
  195. package/dist/components/bn-table.js +1 -1
  196. package/dist/components/bn-template.js +1 -1
  197. package/dist/components/bn-text.js +1 -1
  198. package/dist/components/bn-title2.js +1 -1
  199. package/dist/components/bn-tree.js +1 -1
  200. package/dist/components/checkXYOverflow.js +1 -0
  201. package/dist/components/context-protocol.js +1 -1
  202. package/dist/components/editor-companion.js +1 -1
  203. package/dist/components/emptyState.js +1 -0
  204. package/dist/components/formatter.js +1 -1
  205. package/dist/components/ibcs-chart-bubble2.js +1 -1
  206. package/dist/components/ibcs-chart-bullet2.js +1 -1
  207. package/dist/components/ibcs-chart-scatter2.js +1 -1
  208. package/dist/components/ibcs-chart-structure2.js +1 -1
  209. package/dist/components/ibcs-chart-time2.js +1 -1
  210. package/dist/components/ibcs-table2.js +1 -1
  211. package/dist/components/ibcs-title2.js +1 -1
  212. package/dist/components/layoutTemplate.js +1 -0
  213. package/dist/components/pageFormats.js +1 -0
  214. package/dist/components/parentDimensions.js +1 -0
  215. package/dist/components/queryError.js +1 -0
  216. package/dist/components/relativeVariance.js +1 -0
  217. package/dist/components/sanitizeHtml.js +1 -1
  218. package/dist/components/stackColors.js +1 -1
  219. package/dist/components/stackLayout.js +1 -0
  220. package/dist/components/svg.esm.js +1 -0
  221. package/dist/components/validate.js +1 -1
  222. package/dist/components/withBodyObserver.js +1 -1
  223. package/dist/components/withComponentStatus.js +1 -0
  224. package/dist/components/withComponentStyle.js +1 -1
  225. package/dist/components/withDataset.js +1 -1
  226. package/dist/components/withHasError.js +1 -1
  227. package/dist/components/withRuleSet.js +1 -1
  228. package/dist/components/withScalingGroup.js +1 -1
  229. package/dist/components/withStyled.js +1 -1
  230. package/dist/components/withTranslation.js +1 -1
  231. package/dist/esm/{bn-asset_21.entry.js → bn-asset_28.entry.js} +20948 -6125
  232. package/dist/esm/bn-grid.entry.js +4 -6
  233. package/dist/esm/bn-image.entry.js +3 -5
  234. package/dist/esm/bn-internationalization.entry.js +17 -6
  235. package/dist/esm/bn-ruleset.entry.js +5 -5
  236. package/dist/esm/bn-template-engine.js +1 -1
  237. package/dist/esm/bn-template.entry.js +2 -2
  238. package/dist/esm/bn-text.entry.js +111 -39
  239. package/dist/esm/{context-protocol-B-vdGKeG.js → context-protocol-CdTp19uA.js} +106 -22
  240. package/dist/esm/{diagnostics-CiquIw8B.js → diagnostics-vw6TKMiT.js} +1 -1
  241. package/dist/esm/editor-companion.entry.js +2 -2
  242. package/dist/esm/loader.js +1 -1
  243. package/dist/esm/queryError-ClruFZD_.js +13 -0
  244. package/dist/esm/{scaling-Dggyeqts.js → sanitizeHtml-C5bFtARM.js} +464 -287
  245. package/dist/esm/{withBodyObserver-Cb9ZC5_J.js → withBodyObserver-DD_-r04o.js} +1 -1
  246. package/dist/esm/withHasError-73WV2SP5.js +422 -0
  247. package/dist/esm/{withStyled-DoNsbwS3.js → withStyled-BDEyKd_H.js} +513 -27
  248. package/dist/types/components/bn-chart-bubble/bn-chart-bubble.d.ts +8 -4
  249. package/dist/types/components/bn-chart-bubble/ibcs-chart-bubble.d.ts +2 -1
  250. package/dist/types/components/bn-chart-bubble/utils/BubbleChart.d.ts +14 -2
  251. package/dist/types/components/bn-chart-bullet/bn-chart-bullet.d.ts +12 -11
  252. package/dist/types/components/bn-chart-bullet/ibcs-chart-bullet.d.ts +2 -1
  253. package/dist/types/components/bn-chart-bullet/utils/BulletChart.d.ts +8 -5
  254. package/dist/types/components/bn-chart-bullet/utils/model/BulletChartStyle.d.ts +2 -0
  255. package/dist/types/components/bn-chart-bullet/utils/model/BulletConfig.d.ts +1 -1
  256. package/dist/types/components/bn-chart-scatter/bn-chart-scatter.d.ts +8 -4
  257. package/dist/types/components/bn-chart-scatter/ibcs-chart-scatter.d.ts +2 -1
  258. package/dist/types/components/bn-chart-scatter/utils/ScatterChart.d.ts +11 -1
  259. package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +13 -12
  260. package/dist/types/components/bn-chart-structure/ibcs-chart-structure.d.ts +8 -1
  261. package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +29 -6
  262. package/dist/types/components/bn-chart-structure/utils/elements/StackedBar.d.ts +4 -3
  263. package/dist/types/components/bn-chart-structure/utils/model/DataPoint.d.ts +3 -2
  264. package/dist/types/components/bn-chart-structure/utils/model/StructureChartComponentConfig.d.ts +2 -1
  265. package/dist/types/components/bn-chart-structure/utils/model/styles/StructureChartStyle.d.ts +2 -0
  266. package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +19 -15
  267. package/dist/types/components/bn-chart-time/ibcs-chart-time.d.ts +8 -1
  268. package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +63 -5
  269. package/dist/types/components/bn-chart-time/utils/elements/AreaFill.d.ts +1 -1
  270. package/dist/types/components/bn-chart-time/utils/elements/StackedColumn.d.ts +9 -8
  271. package/dist/types/components/bn-chart-time/utils/model/DataPoint.d.ts +3 -2
  272. package/dist/types/components/bn-chart-time/utils/model/TimeChartComponentConfig.d.ts +3 -2
  273. package/dist/types/components/bn-chart-time/utils/model/styles/TimeChartStyle.d.ts +2 -0
  274. package/dist/types/components/bn-context/bn-context.d.ts +15 -3
  275. package/dist/types/components/bn-dataset/bn-dataset.d.ts +41 -20
  276. package/dist/types/components/bn-datasource/bn-datasource.d.ts +34 -18
  277. package/dist/types/components/bn-footer/bn-footer.d.ts +2 -2
  278. package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +3 -10
  279. package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +13 -6
  280. package/dist/types/components/bn-message/bn-message.d.ts +2 -1
  281. package/dist/types/components/bn-page/bn-page.d.ts +2 -1
  282. package/dist/types/components/bn-page/pageFormats.d.ts +40 -0
  283. package/dist/types/components/bn-scaling-group/bn-scaling-group.d.ts +2 -2
  284. package/dist/types/components/bn-table/bn-table.d.ts +11 -10
  285. package/dist/types/components/bn-table/ibcs-table.d.ts +8 -5
  286. package/dist/types/components/bn-table/utils/Table.d.ts +3 -1
  287. package/dist/types/components/bn-table/utils/elements/Cell.d.ts +2 -2
  288. package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +6 -4
  289. package/dist/types/components/bn-table/utils/elements/WaterfallBar.d.ts +1 -1
  290. package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +2 -0
  291. package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +14 -5
  292. package/dist/types/components/bn-table/utils/helper/IntervalColumns.d.ts +2 -2
  293. package/dist/types/components/bn-table/utils/helper/QueryGroup.d.ts +6 -1
  294. package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +2 -2
  295. package/dist/types/components/bn-table/utils/model/TableAttribute.d.ts +2 -0
  296. package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +2 -1
  297. package/dist/types/components/bn-text/bn-text.d.ts +20 -13
  298. package/dist/types/components/bn-text/utils/template.d.ts +10 -0
  299. package/dist/types/components/bn-title/ibcs-title/ibcs-title.d.ts +1 -0
  300. package/dist/types/components/bn-tree/bn-tree.d.ts +8 -1
  301. package/dist/types/components/bn-tree/utils/EdgeRenderer.d.ts +18 -5
  302. package/dist/types/components/bn-tree/utils/TreeLayout.d.ts +5 -0
  303. package/dist/types/components.d.ts +226 -184
  304. package/dist/types/context/scopedDb.d.ts +20 -0
  305. package/dist/types/stores/componentStyles.d.ts +6 -0
  306. package/dist/types/utils/DateStringFactory.d.ts +3 -2
  307. package/dist/types/utils/autoFit.d.ts +2 -2
  308. package/dist/types/utils/componentRegister.d.ts +21 -5
  309. package/dist/types/utils/constants.d.ts +2 -2
  310. package/dist/types/utils/dataAnalyzer.d.ts +1 -1
  311. package/dist/types/utils/emptyState.d.ts +10 -0
  312. package/dist/types/utils/formatter.d.ts +7 -9
  313. package/dist/types/utils/layoutState/generic.d.ts +1 -1
  314. package/dist/types/utils/layoutState/svgChartElements.d.ts +2 -2
  315. package/dist/types/utils/layoutTemplate.d.ts +16 -0
  316. package/dist/types/utils/model/ChartStyles.d.ts +1 -1
  317. package/dist/types/utils/model/DataQueryResultRow.d.ts +2 -2
  318. package/dist/types/utils/model/Order.d.ts +1 -1
  319. package/dist/types/utils/model/styles/SVGStyle.d.ts +5 -1
  320. package/dist/types/utils/parentDimensions.d.ts +9 -0
  321. package/dist/types/utils/queryError.d.ts +5 -0
  322. package/dist/types/utils/relativeVariance.d.ts +9 -0
  323. package/dist/types/utils/sanitizeHtml.d.ts +2 -2
  324. package/dist/types/utils/scaling.d.ts +1 -1
  325. package/dist/types/utils/stackColors.d.ts +3 -2
  326. package/dist/types/utils/stackLayout.d.ts +49 -0
  327. package/dist/types/utils/testing/fakeGroup.d.ts +8 -0
  328. package/dist/types/utils/testing/mutationObserver.d.ts +5 -0
  329. package/dist/types/utils/testing/structureChart.d.ts +5 -0
  330. package/dist/types/utils/testing/timeChart.d.ts +5 -0
  331. package/dist/types/utils/validate.d.ts +1 -1
  332. package/dist/types/utils/withComponentStatus.d.ts +11 -3
  333. package/dist/types/utils/withInheritedProps.d.ts +42 -15
  334. package/dist/types/utils/withRuleSet.d.ts +2 -1
  335. package/dist/types/utils/withTranslation.d.ts +2 -2
  336. package/dist/types/utils/xy/FacetGrid.d.ts +1 -1
  337. package/dist/types/utils/xy/IsoCurves.d.ts +1 -1
  338. package/dist/types/utils/xy/NumericScale.d.ts +9 -4
  339. package/dist/types/utils/xy/PointLabeler.d.ts +2 -2
  340. package/dist/types/utils/xy/RadiusScale.d.ts +2 -2
  341. package/dist/types/utils/xy/SeriesPalette.d.ts +3 -3
  342. package/dist/types/utils/xy/VarianceMeasure.d.ts +10 -2
  343. package/dist/types/utils/xy/XYFrame.d.ts +4 -1
  344. package/dist/types/utils/xy/XYLegend.d.ts +3 -1
  345. package/dist/types/utils/xy/checkXYOverflow.d.ts +8 -0
  346. package/dist/types/utils/xy/formatXYValue.d.ts +7 -0
  347. package/dist/types/utils/xy/model/AxisConfig.d.ts +1 -1
  348. package/dist/types/utils/xy/model/XYChartStyle.d.ts +2 -0
  349. package/package.json +4 -2
  350. package/readme.md +11 -11
  351. package/dist/bn-template-engine/p-03304284.entry.js +0 -1
  352. package/dist/bn-template-engine/p-0fb02c57.entry.js +0 -1
  353. package/dist/bn-template-engine/p-4419db8f.entry.js +0 -1
  354. package/dist/bn-template-engine/p-45508f1b.entry.js +0 -1
  355. package/dist/bn-template-engine/p-461fdffa.entry.js +0 -1
  356. package/dist/bn-template-engine/p-5d7a3a77.entry.js +0 -1
  357. package/dist/bn-template-engine/p-62cc95b7.entry.js +0 -1
  358. package/dist/bn-template-engine/p-686d8e44.entry.js +0 -1
  359. package/dist/bn-template-engine/p-829212c3.entry.js +0 -1
  360. package/dist/bn-template-engine/p-B5Jd_eCX.js +0 -1
  361. package/dist/bn-template-engine/p-BA48JiHe.js +0 -1
  362. package/dist/bn-template-engine/p-BbmobTg0.js +0 -1
  363. package/dist/bn-template-engine/p-BcaI745G.js +0 -1
  364. package/dist/bn-template-engine/p-CG_Bcm6V.js +0 -1
  365. package/dist/bn-template-engine/p-CWWWM-XC.js +0 -1
  366. package/dist/bn-template-engine/p-CsJ84YRk.js +0 -1
  367. package/dist/bn-template-engine/p-D5e8I9Qe.js +0 -1
  368. package/dist/bn-template-engine/p-DVrDYxlh.js +0 -1
  369. package/dist/bn-template-engine/p-DjPXefnq.js +0 -1
  370. package/dist/bn-template-engine/p-DsTzlzxQ.js +0 -1
  371. package/dist/bn-template-engine/p-DtLI_CzV.js +0 -1
  372. package/dist/bn-template-engine/p-EtT29btN.js +0 -1
  373. package/dist/bn-template-engine/p-TuLpbB5O.js +0 -1
  374. package/dist/bn-template-engine/p-a5867a4c.entry.js +0 -1
  375. package/dist/bn-template-engine/p-b27009eb.entry.js +0 -1
  376. package/dist/bn-template-engine/p-bfa87b07.entry.js +0 -1
  377. package/dist/bn-template-engine/p-ceb80db3.entry.js +0 -1
  378. package/dist/bn-template-engine/p-fcfbb329.entry.js +0 -1
  379. package/dist/bn-template-engine/p-qRZrT-U3.js +0 -1
  380. package/dist/cjs/AxisConfig-DwiNUyYG.js +0 -233
  381. package/dist/cjs/LabelCollisionManager-Bv-xkeXw.js +0 -415
  382. package/dist/cjs/NumericScale-BAyYXpKL.js +0 -107
  383. package/dist/cjs/Order-2wRydarc.js +0 -87
  384. package/dist/cjs/SVGStyle-DoxylrEQ.js +0 -8219
  385. package/dist/cjs/SVGVariancesStyleGroup-CiI4GeWe.js +0 -50
  386. package/dist/cjs/VarianceMeasure-CQlSRzlp.js +0 -372
  387. package/dist/cjs/XYChartDataRow-C2FdL58s.js +0 -829
  388. package/dist/cjs/bn-chart-bubble.cjs.entry.js +0 -792
  389. package/dist/cjs/bn-chart-bullet.cjs.entry.js +0 -805
  390. package/dist/cjs/bn-chart-scatter.cjs.entry.js +0 -678
  391. package/dist/cjs/bn-tree.cjs.entry.js +0 -1042
  392. package/dist/cjs/ibcs-chart-bubble.cjs.entry.js +0 -624
  393. package/dist/cjs/ibcs-chart-bullet.cjs.entry.js +0 -673
  394. package/dist/cjs/ibcs-chart-scatter.cjs.entry.js +0 -667
  395. package/dist/cjs/sanitizeHtml-LuZr1IMd.js +0 -85
  396. package/dist/cjs/svgChartElements-tDA43aYj.js +0 -400
  397. package/dist/cjs/withHasError-BdDmiOXM.js +0 -258
  398. package/dist/cjs/withScalingGroup-CFIc5-6s.js +0 -73
  399. package/dist/components/autoFit.js +0 -1
  400. package/dist/components/main.js +0 -1
  401. package/dist/components/utils.js +0 -1
  402. package/dist/esm/AxisConfig-KqzWQbML.js +0 -224
  403. package/dist/esm/LabelCollisionManager-585bQMtP.js +0 -407
  404. package/dist/esm/NumericScale-DsTzlzxQ.js +0 -105
  405. package/dist/esm/Order-DZVWjEL_.js +0 -83
  406. package/dist/esm/SVGStyle-OrPkzjcb.js +0 -8209
  407. package/dist/esm/SVGVariancesStyleGroup-DO5QJfRQ.js +0 -48
  408. package/dist/esm/VarianceMeasure-DDjChp8C.js +0 -364
  409. package/dist/esm/XYChartDataRow-Dn83Tqh9.js +0 -820
  410. package/dist/esm/bn-chart-bubble.entry.js +0 -790
  411. package/dist/esm/bn-chart-bullet.entry.js +0 -803
  412. package/dist/esm/bn-chart-scatter.entry.js +0 -676
  413. package/dist/esm/bn-tree.entry.js +0 -1040
  414. package/dist/esm/ibcs-chart-bubble.entry.js +0 -622
  415. package/dist/esm/ibcs-chart-bullet.entry.js +0 -671
  416. package/dist/esm/ibcs-chart-scatter.entry.js +0 -665
  417. package/dist/esm/sanitizeHtml-BA48JiHe.js +0 -83
  418. package/dist/esm/svgChartElements-B3YClivG.js +0 -395
  419. package/dist/esm/withHasError-Bh1Viz52.js +0 -254
  420. package/dist/esm/withScalingGroup-DNBSqRC0.js +0 -71
@@ -1,7 +1,10 @@
1
1
  import { OrderDirection, TableType } from "../model";
2
- import { QueryGroups } from "./QueryGroup";
3
- import { coerceBucketKey, INTERVAL_NONE, intervalBucketSQL } from "./IntervalColumns";
2
+ import { BLANK_SAFE_ROWGROUP, QueryGroups } from "./QueryGroup";
3
+ import { BLANK_BUCKET_LABEL, coerceBucketKey, INTERVAL_NONE, intervalBucketSQL } from "./IntervalColumns";
4
+ import { FIELD_IDENTIFIER_REGEX } from "../model/TableAttribute";
5
+ import { Scenarios } from "../../../../utils/constants";
4
6
  import { QueryColumnNames, VarianceScenario } from "../../../../utils/model";
7
+ import { NOT_AVAILABLE, relativeVariance } from "../../../../utils/relativeVariance";
5
8
  /**
6
9
  * AlaSQL-based query builder that produces the complete table result set for bn-table.
7
10
  *
@@ -13,6 +16,10 @@ import { QueryColumnNames, VarianceScenario } from "../../../../utils/model";
13
16
  export class DataQuery {
14
17
  constructor(config, i18n) {
15
18
  this.hasPartOf = false;
19
+ /** Values bound as AlaSQL parameters ($0, $1, ...): row values and free-text config never become SQL text. */
20
+ this.params = [];
21
+ /** Set by execute: the grouped table has rows with a blank rowGroup (null, '' or missing). */
22
+ this.hasBlankRowGroup = false;
16
23
  this.config = config;
17
24
  this.i18n = i18n;
18
25
  }
@@ -38,6 +45,12 @@ export class DataQuery {
38
45
  var _a;
39
46
  this.db = db;
40
47
  this.fromExpr = fromExpr;
48
+ // these names are written into the SQL text as column names
49
+ for (const name of [...this.config.scenarios, ...this.config.categoryThereOf.keys()]) {
50
+ if (!FIELD_IDENTIFIER_REGEX.test(name)) {
51
+ throw new Error(`invalid identifier "${name}"`);
52
+ }
53
+ }
41
54
  const queries = [];
42
55
  const sumGroupQueries = [];
43
56
  const res = [];
@@ -50,7 +63,6 @@ export class DataQuery {
50
63
  const relativeScenarios = this.getRelativeScenarios();
51
64
  const attributesSQL = this.config.attributes.map((attribute) => this.translateAttributeSQL(attribute)).toString();
52
65
  const groups = new QueryGroups(this.config);
53
- const groupsAggregated = this.config.grouped ? [QueryColumnNames.ROWGROUP, QueryColumnNames.ROWGROUPINDEX] : [];
54
66
  let order = ["", ""];
55
67
  if (this.config.sortOrder.hierarchy.length > 0) {
56
68
  order = this.createOrderString(this.config.sortOrder);
@@ -58,27 +70,34 @@ export class DataQuery {
58
70
  this.hasPartOf = this.checkConfigForPartOf();
59
71
  // meta defines groups and the number detail rows in each group
60
72
  // Bsp: 0: Object { totalrowcnt: 7, rowgroup: "Umsatz" }
61
- let meta;
62
- try {
63
- meta = db.exec(`SELECT COUNT(DISTINCT ${QueryColumnNames.CATEGORY}) as ${QueryColumnNames.TOTALROWCOUNT} ${groupsAggregated.length > 0 ? "," + groupsAggregated : ""}
64
- FROM ${fromExpr} ${groupsAggregated.length > 0 ? "GROUP BY " + groupsAggregated : ""}
65
- ORDER BY ${order[0]}`);
66
- }
67
- catch (e) {
68
- console.error("DataQuery: meta query failed", e);
69
- return [];
70
- }
73
+ // groups follow the order entries that exist per group (rowGroup, rowGroupIndex, scenario sum), else rowGroupIndex
74
+ const { hierarchy, direction } = this.config.sortOrder;
75
+ const groupOrderColumns = hierarchy.filter((column) => column === QueryColumnNames.ROWGROUP ||
76
+ column === QueryColumnNames.ROWGROUPINDEX ||
77
+ column.toUpperCase() in Scenarios);
78
+ const groupSums = groupOrderColumns
79
+ .filter((column) => column.toUpperCase() in Scenarios)
80
+ .map((column) => `, SUM(${column} * transformOperator(operation)) as ${column}`)
81
+ .join("");
82
+ const groupOrder = groupOrderColumns.length > 0
83
+ ? groupOrderColumns.map((column) => `${column} ${direction}`).toString()
84
+ : `${QueryColumnNames.ROWGROUPINDEX} asc`;
85
+ const meta = db.exec(`SELECT COUNT(DISTINCT ${QueryColumnNames.CATEGORY}) as ${QueryColumnNames.TOTALROWCOUNT} ${this.config.grouped ? `, ${BLANK_SAFE_ROWGROUP} as ${QueryColumnNames.ROWGROUP}, FIRST(${QueryColumnNames.ROWGROUPINDEX}) as ${QueryColumnNames.ROWGROUPINDEX}${groupSums}` : ""}
86
+ FROM ${fromExpr} ${this.config.grouped ? `GROUP BY ${BLANK_SAFE_ROWGROUP} ORDER BY ${groupOrder}` : ""}`);
71
87
  if (meta.length === 0 ||
72
- (meta.length === 1 && ((_a = meta[0][QueryColumnNames.TOTALROWCOUNT]) !== null && _a !== void 0 ? _a : 0) === 0 && groupsAggregated.length === 0)) {
88
+ (meta.length === 1 && ((_a = meta[0][QueryColumnNames.TOTALROWCOUNT]) !== null && _a !== void 0 ? _a : 0) === 0 && !this.config.grouped)) {
73
89
  return [];
74
90
  }
91
+ this.hasBlankRowGroup = this.config.grouped && meta.some((row) => row.rowGroup === "");
75
92
  // Creates DataSelection for LIST
76
93
  meta.forEach((rowGroupEntry) => {
77
94
  // the following variables are 'helper sections' which are used to constuct dynamicly the sql statement depending of the given config
78
95
  // is grouping active?
79
- const queryWhereSection = rowGroupEntry.rowGroup && rowGroupEntry.rowGroup.length > 0
80
- ? `WHERE ${QueryColumnNames.ROWGROUP} = '${rowGroupEntry.rowGroup}'`
81
- : ``;
96
+ const queryWhereSection = !this.config.grouped
97
+ ? ``
98
+ : rowGroupEntry.rowGroup === ""
99
+ ? `WHERE (${QueryColumnNames.ROWGROUP} IS NULL OR ${QueryColumnNames.ROWGROUP} = '')`
100
+ : `WHERE ${QueryColumnNames.ROWGROUP} = ${this.bind(rowGroupEntry.rowGroup)}`;
82
101
  // is limit active?
83
102
  let queryLimitSection = "";
84
103
  if (this.config.limit) {
@@ -87,18 +106,11 @@ export class DataQuery {
87
106
  this.createGroupHeaderRow(rowGroupEntry, queries);
88
107
  this.createDataRow(queries, rowGroupEntry, groups, scenarios, attributesSQL, queryWhereSection, order, queryLimitSection);
89
108
  this.createRestRow(rowGroupEntry, queries, groups, scenarios, queryWhereSection, order);
90
- this.createGroupSumRow(queries, sumGroupQueries, rowGroupEntry, scenariosSUMQuery, order);
109
+ this.createGroupSumRow(queries, sumGroupQueries, rowGroupEntry, scenariosSUMQuery, queryWhereSection, order);
91
110
  });
92
111
  this.createTotalSumRow(queries, sumGroupQueries, scenariosSUMQuery);
93
112
  // executes main queries
94
- queries.forEach((query) => {
95
- try {
96
- res.push(db.exec(query));
97
- }
98
- catch (err) {
99
- console.error("DataQuery: SQL query execution failed", query, err);
100
- }
101
- });
113
+ queries.forEach((query) => res.push(this.exec(query)));
102
114
  this.detectNaNCells(this.config.scenarios, res);
103
115
  this.createThereOfDrillRows(scenarios, attributesSQL, order, res);
104
116
  this.createPartOfDrillRows(scenarios, order, sumGroupQueries, res);
@@ -149,13 +161,14 @@ export class DataQuery {
149
161
  const drillQueries = this.createPartOfQuery(scenarios, order);
150
162
  let resDrill = []; // set of drill (subquery result injected into resultset)
151
163
  const db = this.db;
152
- drillQueries.forEach(function (query) {
153
- resDrill.push(...db.exec(query));
164
+ const params = this.params;
165
+ drillQueries.forEach((query) => {
166
+ resDrill.push(...this.exec(query));
154
167
  });
155
168
  const scenarioNames = this.exctractScenarioNames(scenarios);
156
169
  const rowGroupSumResultRows = [];
157
170
  sumGroupQueries.forEach(function (query) {
158
- rowGroupSumResultRows.push(...db.exec(query));
171
+ rowGroupSumResultRows.push(...db.exec(query, params));
159
172
  });
160
173
  const rowGroupSumResultMap = new Map();
161
174
  rowGroupSumResultRows.forEach((row) => rowGroupSumResultMap.set(row[QueryColumnNames.ROWGROUP], row));
@@ -187,7 +200,7 @@ export class DataQuery {
187
200
  .map((name) => `SUM(${name}) as ${name}`)
188
201
  .join(", ");
189
202
  querys.push(`SELECT ${QueryColumnNames.ROWNR}, 1 as ${QueryColumnNames.ROWGROUPINDEX} , 'ENTRY' as ${QueryColumnNames.TYPE}, 'NO_GROUP' as ${QueryColumnNames.ROWGROUP}, 'REST' as ${QueryColumnNames.CATEGORY} ${restScenarios.length > 0 ? ", " + restScenarios : ""} FROM` +
190
- ` (SELECT ROWNUM() AS ${QueryColumnNames.ROWNR}, ${querys.length} as ${QueryColumnNames.ROWGROUPINDEX} , 'ENTRY' as ${QueryColumnNames.TYPE}, '${rowGroupEntry.rowGroup || "NO_GROUP"}' as ${QueryColumnNames.ROWGROUP}, ${groups} ${scenarios.length > 0 ? ",".concat(scenarios) : ""} FROM ${this.fromExpr} ${queryWhereSection} GROUP BY ${groups} ORDER BY ${order[0]})` +
203
+ ` (SELECT ROWNUM() AS ${QueryColumnNames.ROWNR}, ${querys.length} as ${QueryColumnNames.ROWGROUPINDEX} , 'ENTRY' as ${QueryColumnNames.TYPE}, ${this.bind(String(rowGroupEntry.rowGroup || "NO_GROUP"))} as ${QueryColumnNames.ROWGROUP}, ${groups.select()} ${scenarios.length > 0 ? ",".concat(scenarios) : ""} FROM ${this.fromExpr} ${queryWhereSection} GROUP BY ${groups} ORDER BY ${order[0]})` +
191
204
  ` t WHERE t.rowNr > ${this.config.limit}`);
192
205
  }
193
206
  }
@@ -197,9 +210,9 @@ export class DataQuery {
197
210
  querys.push(`SELECT ROWNUM() AS ${QueryColumnNames.ROWNR},
198
211
  ${querys.length} as ${QueryColumnNames.ROWGROUPINDEX},
199
212
  'ENTRY' as ${QueryColumnNames.TYPE},
200
- '${rowGroupEntry.rowGroup || "NO_GROUP"}' as ${QueryColumnNames.ROWGROUP},
213
+ ${this.bind(String(rowGroupEntry.rowGroup || "NO_GROUP"))} as ${QueryColumnNames.ROWGROUP},
201
214
  '${QueryColumnNames.CATEGORYINDEX}',
202
- ${groups} ${scenarios.length > 0 ? ",".concat(scenarios) : ""} ${attributes.length > 0 ? ",".concat(attributes) : ""}
215
+ ${groups.select()} ${scenarios.length > 0 ? ",".concat(scenarios) : ""} ${attributes.length > 0 ? ",".concat(attributes) : ""}
203
216
  FROM ${this.fromExpr} ${queryWhereSection}
204
217
  GROUP BY ${groups}
205
218
  ORDER BY ${order[0]} ${queryLimitSection}`);
@@ -208,40 +221,39 @@ export class DataQuery {
208
221
  createGroupHeaderRow(rowGroupEntry, querys) {
209
222
  // Generates GroupHeader Row
210
223
  if (true === this.config.grouped) {
211
- const groupTitle = this.config.showGroupTitle
212
- ? `,'${rowGroupEntry.rowGroup}' as ${QueryColumnNames.CATEGORY}`
213
- : "";
224
+ const rowGroup = this.bind(String(rowGroupEntry.rowGroup));
225
+ const title = rowGroupEntry.rowGroup === "" ? this.bind(BLANK_BUCKET_LABEL) : rowGroup;
226
+ const groupTitle = this.config.showGroupTitle ? `,${title} as ${QueryColumnNames.CATEGORY}` : "";
214
227
  querys.push(`SELECT ROWNUM() AS ${QueryColumnNames.ROWNR},
215
228
  ${querys.length} as ${QueryColumnNames.ROWGROUPINDEX},
216
229
  'GROUPHEAD' as ${QueryColumnNames.TYPE},
217
- '${rowGroupEntry.rowGroup}' as ${QueryColumnNames.ROWGROUP} ${groupTitle}
230
+ ${rowGroup} as ${QueryColumnNames.ROWGROUP} ${groupTitle}
218
231
  FROM ${this.fromExpr}
219
232
  GROUP BY '1'`);
220
233
  }
221
234
  }
222
235
  /** Generates a GROUP_SUM row that aggregates all entries within a single row group. */
223
- createGroupSumRow(querys, groupSumQuery, rowGroupEntry, scenariosSUMQuery, order) {
236
+ createGroupSumRow(querys, groupSumQuery, rowGroupEntry, scenariosSUMQuery, queryWhereSection, order) {
224
237
  // Generates SUM Row; sumsup all rows of group
225
238
  if (true === this.config.grouped &&
226
239
  (TableType.SUM === this.config.type ||
227
240
  TableType.SUMNOTOTAL === this.config.type ||
228
241
  TableType.OPT === this.config.type ||
229
242
  TableType.OPTNOTOTAL === this.config.type)) {
243
+ const rowGroup = this.bind(String(rowGroupEntry.rowGroup));
230
244
  querys.push(`SELECT ${querys.length} as ${QueryColumnNames.ROWGROUPINDEX},
231
245
  '=' as ${QueryColumnNames.OPERATION},
232
- '${rowGroupEntry.rowGroup}' as ${QueryColumnNames.ROWGROUP},
246
+ ${rowGroup} as ${QueryColumnNames.ROWGROUP},
233
247
  ROWNUM() AS ${QueryColumnNames.ROWNR},
234
248
  'GROUP_SUM' as ${QueryColumnNames.TYPE} ${scenariosSUMQuery.length > 0 ? ",".concat(scenariosSUMQuery) : ""}
235
- FROM ${this.fromExpr}
236
- WHERE ${QueryColumnNames.ROWGROUP} = '${rowGroupEntry.rowGroup}'
249
+ FROM ${this.fromExpr} ${queryWhereSection}
237
250
  ORDER BY ${order[0]} `);
238
251
  groupSumQuery.push(`SELECT ${querys.length} as ${QueryColumnNames.ROWGROUPINDEX},
239
252
  '=' as ${QueryColumnNames.OPERATION},
240
- '${rowGroupEntry.rowGroup}' as ${QueryColumnNames.ROWGROUP},
253
+ ${rowGroup} as ${QueryColumnNames.ROWGROUP},
241
254
  ROWNUM() AS ${QueryColumnNames.ROWNR},
242
255
  'GROUP_SUM' as ${QueryColumnNames.TYPE} ${scenariosSUMQuery.length > 0 ? ",".concat(scenariosSUMQuery) : ""}
243
- FROM ${this.fromExpr}
244
- WHERE ${QueryColumnNames.ROWGROUP} = '${rowGroupEntry.rowGroup}'
256
+ FROM ${this.fromExpr} ${queryWhereSection}
245
257
  ORDER BY ${order[0]} `);
246
258
  }
247
259
  }
@@ -254,12 +266,12 @@ export class DataQuery {
254
266
  const label = ((_a = this.config.title) === null || _a === void 0 ? void 0 : _a.trim()) || "SUM_TOTAL";
255
267
  // In an ungrouped partof table the total row is what the "in % of ❖" rows
256
268
  // refer to, so a custom label gets the symbol prepended. The default label
257
- // already IS that symbol — prefixing it would yield the literal
269
+ // already IS that symbol - prefixing it would yield the literal
258
270
  // "❖ SUM_TOTAL", which no longer matches the key and stays untranslated.
259
271
  const prefixSymbol = this.hasPartOf && this.config.grouped === false && label !== "SUM_TOTAL";
260
272
  const title = prefixSymbol ? `${this.i18n.get("SUM_TOTAL") || "SUM_TOTAL"} ${label}` : label;
261
273
  querys.push(`SELECT ${querys.length} as ${QueryColumnNames.ROWGROUPINDEX},
262
- '${title}' as ${QueryColumnNames.ROWGROUP},
274
+ ${this.bind(title)} as ${QueryColumnNames.ROWGROUP},
263
275
  '=' as ${QueryColumnNames.OPERATION},
264
276
  'SUM' as ${QueryColumnNames.TYPE} ${scenariosSUMQuery.length > 0 ? ",".concat(scenariosSUMQuery) : ""}
265
277
  FROM ${this.fromExpr} `);
@@ -337,10 +349,10 @@ export class DataQuery {
337
349
  else {
338
350
  numberOfElement.set(`${drillItem.category}`, 1);
339
351
  }
340
- if (drillItem[QueryColumnNames.ROWNR] === 1) {
341
- drillItem.subCategory = `${drillItem.subCategory} (${drillItem.rowGroup})`;
342
- }
343
- else if (duplicateSubCategoriesList.includes(drillItem.subCategory)) {
352
+ // the rowGroup only tells duplicate names under one parent apart, and a blank rowGroup tells nothing
353
+ if (drillItem.rowGroup != null &&
354
+ drillItem.rowGroup !== "" &&
355
+ duplicateSubCategoriesList.includes(`${drillItem.category}##${drillItem.subCategory}`)) {
344
356
  drillItem.subCategory = `${drillItem.subCategory} (${drillItem.rowGroup})`;
345
357
  }
346
358
  resSegment.splice(index + drillItem[QueryColumnNames.ROWNR], 0, drillItem);
@@ -370,17 +382,17 @@ export class DataQuery {
370
382
  let fromString = "1 <> 1 OR ( "; // helper for strin concat 1<>1 OR ... OR ...
371
383
  if (!(null == element.category || 0 === element.category.length || !element.category.trim())) {
372
384
  // if not empty
373
- fromString += ` ${QueryColumnNames.CATEGORY} = '${element.category}'`;
385
+ fromString += ` ${QueryColumnNames.CATEGORY} = ${this.bind(element.category)}`;
374
386
  isFirst = false;
375
387
  }
376
388
  if (!(null == element.rowGroup || 0 === element.rowGroup.length || !element.rowGroup.trim())) {
377
389
  // if not empty
378
- fromString += ` ${isFirst ? "" : "AND"} ${QueryColumnNames.ROWGROUP} = '${element.rowGroup}'`;
390
+ fromString += ` ${isFirst ? "" : "AND"} ${QueryColumnNames.ROWGROUP} = ${this.bind(element.rowGroup)}`;
379
391
  isFirst = false;
380
392
  }
381
393
  if (!(null == element.subCategory || 0 === element.subCategory.length || !element.subCategory.trim())) {
382
394
  // if not empty
383
- fromString += ` ${isFirst ? "" : "AND"} ${QueryColumnNames.SUBCATEGORY} = '${element.subCategory}'`;
395
+ fromString += ` ${isFirst ? "" : "AND"} ${QueryColumnNames.SUBCATEGORY} = ${this.bind(element.subCategory)}`;
384
396
  }
385
397
  fromString += `)`;
386
398
  drillQueries.push(`SELECT ROWNUM() AS ${QueryColumnNames.ROWNR},
@@ -388,29 +400,30 @@ export class DataQuery {
388
400
  'DRILLELEMENT' as ${QueryColumnNames.TYPE},
389
401
  ${QueryColumnNames.CATEGORY},
390
402
  ${QueryColumnNames.SUBCATEGORY},
391
- ${QueryColumnNames.ROWGROUP} as ${QueryColumnNames.ROWGROUP},
403
+ ${this.drillRowGroup} as ${QueryColumnNames.ROWGROUP},
392
404
  ${scenarios} ${attributes.length > 0 ? ",".concat(attributes) : ""}
393
405
  FROM ${this.fromExpr}
394
406
  WHERE ${fromString}
395
- GROUP BY ${QueryColumnNames.ROWGROUP}, ${QueryColumnNames.CATEGORY}, ${QueryColumnNames.SUBCATEGORY}
407
+ GROUP BY ${this.drillRowGroup}, ${QueryColumnNames.CATEGORY}, ${QueryColumnNames.SUBCATEGORY}
396
408
  ORDER BY ${order[1]}`);
397
409
  });
398
- const db = this.db;
399
- drillQueries.forEach(function (query) {
400
- resDrill.push(...db.exec(query));
410
+ drillQueries.forEach((query) => {
411
+ resDrill.push(...this.exec(query));
401
412
  });
402
413
  this.injectDrillRowsToResultRows(resDrill, res);
403
414
  }
404
415
  /**
405
416
  * Converts absolute variance columns into relative (percentage) variances by dividing
406
- * each `dr_*` cell by its denominator column (the delta scenario's aggregated value).
417
+ * each `dr_*` cell by the absolute value of its denominator column (the delta scenario's
418
+ * aggregated value). A denominator of 0 gives NOT_AVAILABLE.
407
419
  */
408
420
  calculateRelativeVariances(res, relativeScenarios) {
409
421
  res.forEach((group) => {
410
422
  group.forEach((row) => {
411
423
  if (row[QueryColumnNames.TYPE] !== "GROUPHEAD") {
412
424
  relativeScenarios.forEach((value, key) => {
413
- row[key] = row[key] / row[value];
425
+ var _a;
426
+ row[key] = (_a = relativeVariance(row[key], row[value])) !== null && _a !== void 0 ? _a : NOT_AVAILABLE;
414
427
  });
415
428
  }
416
429
  });
@@ -471,7 +484,7 @@ export class DataQuery {
471
484
  * bucket (`normalizeDate(date, …)` for date intervals, setname otherwise) at
472
485
  * every row level (ENTRY, GROUP_SUM, SUM, DRILLELEMENT, PARTELEMENT) and the
473
486
  * results are stored on the existing rows as composite keys
474
- * `<scenario>##<bucketKey>` — the same convention as the columnthereof drill
487
+ * `<scenario>##<bucketKey>` - the same convention as the columnthereof drill
475
488
  * columns (which are mutually exclusive with interval).
476
489
  *
477
490
  * Row selection (ORDER BY / LIMIT) stays anchored on the un-bucketed base
@@ -494,7 +507,8 @@ export class DataQuery {
494
507
  const scenariosSUMQuery = this.config.scenarios
495
508
  .map((s) => this.translateScenarioSQL(s, true, this.config.type))
496
509
  .toString();
497
- const entryAliases = this.exctractScenarioNames(scenarios);
510
+ // two relative variances on one reference name its dr_* alias twice, it must be summed once
511
+ const entryAliases = [...new Set(this.exctractScenarioNames(scenarios))];
498
512
  const relativeScenarios = this.getRelativeScenarios();
499
513
  const groups = new QueryGroups(this.config);
500
514
  const isOpt = TableType.OPT === this.config.type || TableType.OPTNOTOTAL === this.config.type;
@@ -504,15 +518,7 @@ export class DataQuery {
504
518
  TableType.OPT === this.config.type ||
505
519
  TableType.OPTNOTOTAL === this.config.type);
506
520
  const hasPartOfActive = this.checkConfigForPartOf() && this.config.type !== TableType.LIST;
507
- const exec = (query) => {
508
- try {
509
- return this.db.exec(query);
510
- }
511
- catch (err) {
512
- console.error("DataQuery: interval query failed", query, err);
513
- return [];
514
- }
515
- };
521
+ const exec = (query) => this.exec(query);
516
522
  // mirrors detectNaNCells + calculateRelativeVariances for a single bucket row
517
523
  const finalizeBucketRow = (row) => {
518
524
  this.config.scenarios.forEach((scenario) => {
@@ -527,7 +533,8 @@ export class DataQuery {
527
533
  }
528
534
  });
529
535
  relativeScenarios.forEach((value, key) => {
530
- row[key] = row[key] / row[value];
536
+ var _a;
537
+ row[key] = (_a = relativeVariance(row[key], row[value])) !== null && _a !== void 0 ? _a : NOT_AVAILABLE;
531
538
  });
532
539
  return row;
533
540
  };
@@ -536,7 +543,7 @@ export class DataQuery {
536
543
  target[scenario + separator + bucketKey] = source[scenario];
537
544
  }
538
545
  };
539
- const entryRowsRaw = exec(`SELECT ${groups}, __interval ${scenarios.length > 0 ? ",".concat(scenarios) : ""}
546
+ const entryRowsRaw = exec(`SELECT ${groups.select()}, __interval ${scenarios.length > 0 ? ",".concat(scenarios) : ""}
540
547
  FROM ${bucketSource}
541
548
  GROUP BY ${groups}, __interval`);
542
549
  // REST rows first: the math needs the raw (not yet finalized) entry aliases
@@ -601,9 +608,9 @@ export class DataQuery {
601
608
  }
602
609
  }
603
610
  const groupTotalRowsRaw = isSumTypeGrouped || (hasPartOfActive && this.config.grouped)
604
- ? exec(`SELECT ${QueryColumnNames.ROWGROUP}, __interval ${scenariosSUMQuery.length > 0 ? ",".concat(scenariosSUMQuery) : ""}
611
+ ? exec(`SELECT ${BLANK_SAFE_ROWGROUP} as ${QueryColumnNames.ROWGROUP}, __interval ${scenariosSUMQuery.length > 0 ? ",".concat(scenariosSUMQuery) : ""}
605
612
  FROM ${bucketSource}
606
- GROUP BY ${QueryColumnNames.ROWGROUP}, __interval`)
613
+ GROUP BY ${BLANK_SAFE_ROWGROUP}, __interval`)
607
614
  : [];
608
615
  const groupTotalsByKey = new Map();
609
616
  groupTotalRowsRaw.forEach((row) => groupTotalsByKey.set(`${row.rowGroup}${separator}${coerceBucketKey(row.__interval)}`, row));
@@ -644,17 +651,19 @@ export class DataQuery {
644
651
  if (this.config.thereOf != null && this.config.thereOf.length > 0) {
645
652
  const drillRows = [];
646
653
  this.config.thereOf.forEach((element) => {
647
- drillRows.push(...exec(`SELECT ${QueryColumnNames.ROWGROUP}, ${QueryColumnNames.CATEGORY}, ${QueryColumnNames.SUBCATEGORY}, __interval ${scenarios.length > 0 ? ",".concat(scenarios) : ""}
654
+ drillRows.push(...exec(`SELECT ${this.drillRowGroup} as ${QueryColumnNames.ROWGROUP}, ${QueryColumnNames.CATEGORY}, ${QueryColumnNames.SUBCATEGORY}, __interval ${scenarios.length > 0 ? ",".concat(scenarios) : ""}
648
655
  FROM ${bucketSource}
649
656
  WHERE ${this.createThereOfWhereClause(element)}
650
- GROUP BY ${QueryColumnNames.ROWGROUP}, ${QueryColumnNames.CATEGORY}, ${QueryColumnNames.SUBCATEGORY}, __interval`));
657
+ GROUP BY ${this.drillRowGroup}, ${QueryColumnNames.CATEGORY}, ${QueryColumnNames.SUBCATEGORY}, __interval`));
651
658
  });
652
659
  for (const drillRow of drillRows) {
653
660
  const bucketKey = coerceBucketKey(drillRow.__interval);
654
661
  finalizeBucketRow(drillRow);
655
662
  for (const segment of res) {
656
663
  for (const row of segment) {
657
- if (row.type !== "DRILLELEMENT" || row.category !== drillRow.category) {
664
+ if (row.type !== "DRILLELEMENT" ||
665
+ row.category !== drillRow.category ||
666
+ row.rowGroup !== drillRow.rowGroup) {
658
667
  continue;
659
668
  }
660
669
  if (row.subCategory !== drillRow.subCategory &&
@@ -669,9 +678,9 @@ export class DataQuery {
669
678
  if (hasPartOfActive) {
670
679
  let partWhere = "1 <> 1 ";
671
680
  (_c = this.config.partOf) === null || _c === void 0 ? void 0 : _c.forEach((element) => {
672
- partWhere += `OR (${QueryColumnNames.CATEGORY} = '${element.category}'`;
681
+ partWhere += `OR (${QueryColumnNames.CATEGORY} = ${this.bind(element.category)}`;
673
682
  if (!(null == element.rowGroup || 0 === element.rowGroup.length || !element.rowGroup.trim())) {
674
- partWhere += `and ${QueryColumnNames.ROWGROUP} = '${element.rowGroup}'`;
683
+ partWhere += `and ${QueryColumnNames.ROWGROUP} = ${this.bind(element.rowGroup)}`;
675
684
  }
676
685
  partWhere += `)`;
677
686
  });
@@ -682,7 +691,7 @@ export class DataQuery {
682
691
  FROM ${bucketSource}
683
692
  WHERE ${partWhere}
684
693
  GROUP BY ${QueryColumnNames.ROWGROUP}, ${QueryColumnNames.CATEGORY}, __interval`);
685
- // merge rows sharing (rowGroup, category, bucket) — mirrors reduceResDrillByCategoryGroups
694
+ // merge rows sharing (rowGroup, category, bucket) - mirrors reduceResDrillByCategoryGroups
686
695
  const partByKey = new Map();
687
696
  for (const partRow of partRowsRaw) {
688
697
  const key = `${partRow.rowGroup}${separator}${partRow.category}${separator}${coerceBucketKey(partRow.__interval)}`;
@@ -720,15 +729,15 @@ export class DataQuery {
720
729
  let isFirst = true;
721
730
  let whereClause = "1 <> 1 OR ( ";
722
731
  if (!(null == element.category || 0 === element.category.length || !element.category.trim())) {
723
- whereClause += ` ${QueryColumnNames.CATEGORY} = '${element.category}'`;
732
+ whereClause += ` ${QueryColumnNames.CATEGORY} = ${this.bind(element.category)}`;
724
733
  isFirst = false;
725
734
  }
726
735
  if (!(null == element.rowGroup || 0 === element.rowGroup.length || !element.rowGroup.trim())) {
727
- whereClause += ` ${isFirst ? "" : "AND"} ${QueryColumnNames.ROWGROUP} = '${element.rowGroup}'`;
736
+ whereClause += ` ${isFirst ? "" : "AND"} ${QueryColumnNames.ROWGROUP} = ${this.bind(element.rowGroup)}`;
728
737
  isFirst = false;
729
738
  }
730
739
  if (!(null == element.subCategory || 0 === element.subCategory.length || !element.subCategory.trim())) {
731
- whereClause += ` ${isFirst ? "" : "AND"} ${QueryColumnNames.SUBCATEGORY} = '${element.subCategory}'`;
740
+ whereClause += ` ${isFirst ? "" : "AND"} ${QueryColumnNames.SUBCATEGORY} = ${this.bind(element.subCategory)}`;
732
741
  }
733
742
  return whereClause + `)`;
734
743
  }
@@ -813,13 +822,29 @@ export class DataQuery {
813
822
  return useOperator
814
823
  ? `SUM(${field} * transformOperator(operation)) as ${attribute.alias}`
815
824
  : `SUM(${field}) as ${attribute.alias}`;
816
- case "lit":
817
- return `${this.sqlLiteral(attribute.arg)} as ${attribute.alias}`;
825
+ case "lit": {
826
+ // numeric when parseable, string otherwise
827
+ const arg = attribute.arg;
828
+ return `${this.bind(arg !== "" && !Number.isNaN(Number(arg)) ? Number(arg) : arg)} as ${attribute.alias}`;
829
+ }
818
830
  }
819
831
  }
820
- /** Emits a raw lit() argument as a SQL literal: numeric when parseable, quoted string otherwise. */
821
- sqlLiteral(raw) {
822
- return raw !== "" && !Number.isNaN(Number(raw)) ? raw : `'${raw.replace(/'/g, "''")}'`;
832
+ /** rowGroup of the drill queries: a grouped table merges the blank variants, an ungrouped one keeps them apart. */
833
+ get drillRowGroup() {
834
+ return this.config.grouped ? BLANK_SAFE_ROWGROUP : QueryColumnNames.ROWGROUP;
835
+ }
836
+ /** Grouped result rows carry the rowGroup as text, like the GROUPHEAD and GROUP_SUM rows: '' for null and a missing one. */
837
+ exec(query) {
838
+ const rows = this.db.exec(query, this.params);
839
+ if (this.config.grouped) {
840
+ rows.forEach((row) => (row.rowGroup = row.rowGroup == null ? "" : String(row.rowGroup)));
841
+ }
842
+ return rows;
843
+ }
844
+ /** Binds a value as an AlaSQL parameter and returns its placeholder. */
845
+ bind(value) {
846
+ // trailing space: "$4and" does not parse
847
+ return `$${this.params.push(value) - 1} `;
823
848
  }
824
849
  /**
825
850
  * generates Tuple
@@ -828,8 +853,9 @@ export class DataQuery {
828
853
  * @param orderComponent
829
854
  */
830
855
  createOrderString(orderComponent) {
831
- const base = `${orderComponent.hierarchy.toString()} ${orderComponent.direction}`;
832
- const inverted = `${orderComponent.hierarchy.toString()} ${OrderDirection.ASC === orderComponent.direction ? OrderDirection.DESC : OrderDirection.ASC}`;
856
+ const inverse = OrderDirection.ASC === orderComponent.direction ? OrderDirection.DESC : OrderDirection.ASC;
857
+ const base = orderComponent.hierarchy.map((column) => `${column} ${orderComponent.direction}`).toString();
858
+ const inverted = orderComponent.hierarchy.map((column) => `${column} ${inverse}`).toString();
833
859
  return [base, inverted];
834
860
  }
835
861
  /** Returns a key/value pair mapping a relative variance column to its denominator, or null for non-relative scenarios. */
@@ -846,13 +872,13 @@ export class DataQuery {
846
872
  scenarios.split(",").forEach((item) => (item.length >= 2 ? scenarioNames.push(item.split("as")[1].trim()) : null));
847
873
  return scenarioNames;
848
874
  }
849
- /** Identifies subCategory values that appear more than once in the drill set, requiring disambiguation. */
875
+ /** Returns the `category##subCategory` keys of subCategory values that appear more than once under one parent category. */
850
876
  findDuplicateSubCategories(resDrill) {
851
877
  const uniq = resDrill
852
878
  .map((element) => {
853
879
  return {
854
880
  count: 1,
855
- subCategory: element.subCategory,
881
+ subCategory: `${element.category}##${element.subCategory}`,
856
882
  };
857
883
  })
858
884
  .reduce((a, b) => {
@@ -866,13 +892,13 @@ export class DataQuery {
866
892
  var _a;
867
893
  const drillQueries = [];
868
894
  let fromString = "1 <> 1 "; // helper for strin concat 1<>1 OR ... OR ...
869
- let groupName = ` ${QueryColumnNames.ROWGROUP}`;
895
+ let groupName = ` ${this.drillRowGroup} as ${QueryColumnNames.ROWGROUP}`;
870
896
  let rowNum = "ROWNUM()";
871
897
  (_a = this.config.partOf) === null || _a === void 0 ? void 0 : _a.forEach((element) => {
872
- fromString += `OR (${QueryColumnNames.CATEGORY} = '${element.category}'`;
898
+ fromString += `OR (${QueryColumnNames.CATEGORY} = ${this.bind(element.category)}`;
873
899
  if (!(null == element.rowGroup || 0 === element.rowGroup.length || !element.rowGroup.trim())) {
874
900
  // if not empty
875
- fromString += `and ${QueryColumnNames.ROWGROUP} = '${element.rowGroup}'`;
901
+ fromString += `and ${QueryColumnNames.ROWGROUP} = ${this.bind(element.rowGroup)}`;
876
902
  }
877
903
  if (this.config.grouped === false) {
878
904
  groupName = ` 'SUM_TOTAL' as ${QueryColumnNames.ROWGROUP} `;
@@ -889,7 +915,7 @@ export class DataQuery {
889
915
  ${scenarios}
890
916
  FROM ${this.fromExpr}
891
917
  WHERE ${fromString}
892
- GROUP BY ${QueryColumnNames.ROWGROUP}, ${QueryColumnNames.CATEGORY}, ${QueryColumnNames.TYPE}
918
+ GROUP BY ${this.drillRowGroup}, ${QueryColumnNames.CATEGORY}, ${QueryColumnNames.TYPE}
893
919
  ORDER BY ${order[1]}`);
894
920
  return drillQueries;
895
921
  }
@@ -918,7 +944,7 @@ export class DataQuery {
918
944
  categoryThereOf.forEach((value, key) => {
919
945
  let whereClause = "1 <> 1 ";
920
946
  value.forEach((drillColumn) => {
921
- whereClause += ` or columnGroup = '${drillColumn.name}' `;
947
+ whereClause += ` or columnGroup = ${this.bind(String(drillColumn.name))} `;
922
948
  });
923
949
  drillQueries.push(`SELECT 'ENTRY' as rowlevel,
924
950
  'COLUMNGROUP' as columnlevel,
@@ -1002,7 +1028,7 @@ export class DataQuery {
1002
1028
  GROUP BY rowlevel, columnGroup, columnSubGroup, scenario`);
1003
1029
  });
1004
1030
  for (const query of drillQueries) {
1005
- resDrill.push(...this.db.exec(query));
1031
+ resDrill.push(...this.db.exec(query, this.params));
1006
1032
  }
1007
1033
  this.injectDrillColumnsToResultRows(resDrill, res);
1008
1034
  }
@@ -1028,6 +1054,10 @@ export class DataQuery {
1028
1054
  }
1029
1055
  }
1030
1056
  else if ("DRILLELEMENT" === drillElement.rowlevel) {
1057
+ // ungrouped thereof rows keep their rowGroup, the same name can exist in another one
1058
+ if (!this.config.grouped && row.rowGroup !== drillElement.rowGroup) {
1059
+ continue;
1060
+ }
1031
1061
  if (drillElement.columnlevel === "COLUMNGROUP" &&
1032
1062
  row.category === drillElement.category &&
1033
1063
  row.subCategory === drillElement.subCategory) {
@@ -5,7 +5,7 @@ export const INTERVAL_NONE = "none";
5
5
  /** `interval` value grouping by the dataset's `setname` column. */
6
6
  export const INTERVAL_SETNAME = "setname";
7
7
  /** Label rendered for the bucket collecting rows with a blank setname. */
8
- export const BLANK_BUCKET_LABEL = "—";
8
+ export const BLANK_BUCKET_LABEL = "-";
9
9
  /** True for all date-based interval values (everything except none/setname). */
10
10
  export function isDateInterval(interval) {
11
11
  return interval !== INTERVAL_NONE && interval !== INTERVAL_SETNAME;
@@ -47,14 +47,7 @@ export function resolveIntervalGranularity(db, fromExpr, interval) {
47
47
  if (interval !== DateDistance.AUTO) {
48
48
  return interval;
49
49
  }
50
- let rows;
51
- try {
52
- rows = db.exec(`SELECT [date] as d FROM ${fromExpr}`);
53
- }
54
- catch (e) {
55
- console.error("IntervalColumns: date query failed", e);
56
- return DateDistance.DAY;
57
- }
50
+ const rows = db.exec(`SELECT [date] as d FROM ${fromExpr}`);
58
51
  let min;
59
52
  let max;
60
53
  for (const row of rows) {
@@ -74,17 +67,10 @@ export function resolveIntervalGranularity(db, fromExpr, interval) {
74
67
  * Queries the distinct interval buckets of the source data.
75
68
  * Date buckets are sorted chronologically ascending and labeled locale-aware;
76
69
  * setname buckets keep their order of first appearance in the data, blank
77
- * setnames are collected in a trailing-position "—" bucket where they occur.
70
+ * setnames are collected in a trailing-position "-" bucket where they occur.
78
71
  */
79
72
  export function queryIntervalBuckets(db, fromExpr, interval, locale) {
80
- let rows;
81
- try {
82
- rows = db.exec(`SELECT ${intervalBucketSQL(interval)} as __interval FROM ${fromExpr}`);
83
- }
84
- catch (e) {
85
- console.error("IntervalColumns: bucket query failed", e);
86
- return [];
87
- }
73
+ const rows = db.exec(`SELECT ${intervalBucketSQL(interval)} as __interval FROM ${fromExpr}`);
88
74
  if (interval === INTERVAL_SETNAME) {
89
75
  const seen = new Set();
90
76
  const buckets = [];
@@ -125,11 +111,11 @@ function toDateTime(value) {
125
111
  return undefined;
126
112
  }
127
113
  if (typeof value === "string") {
128
- const dt = DateTime.fromISO(value);
114
+ const dt = DateTime.fromISO(value, { zone: "utc" });
129
115
  return dt.isValid ? dt : undefined;
130
116
  }
131
117
  if (typeof value === "number") {
132
- const dt = DateTime.fromMillis(value);
118
+ const dt = DateTime.fromMillis(value, { zone: "utc" });
133
119
  return dt.isValid ? dt : undefined;
134
120
  }
135
121
  if (typeof value.isValid === "boolean") {
@@ -1,11 +1,13 @@
1
1
  import { TableType } from "../model";
2
2
  import { QueryColumnNames } from "../../../../utils/model";
3
+ /** '', null and a missing rowGroup are one group. */
4
+ export const BLANK_SAFE_ROWGROUP = `IFNULL(${QueryColumnNames.ROWGROUP}, '')`;
3
5
  /**
4
6
  * Manages the GROUP BY column list for DataQuery's SQL statements.
5
7
  *
6
8
  * The `transformOperator` AlaSQL UDF (which maps `"+"`/`"-"` to +1/-1 for
7
9
  * sign-aware SUMs) is registered globally by `scopedDb.ts` when the shared
8
- * database is created — no per-component registration is needed here.
10
+ * database is created - no per-component registration is needed here.
9
11
  *
10
12
  * The GROUP BY columns are composed dynamically: always category + categoryIndex,
11
13
  * plus operation for OPT types, plus rowGroup/rowGroupIndex when grouping is active.
@@ -21,8 +23,13 @@ export class QueryGroups {
21
23
  this.groups.push(QueryColumnNames.ROWGROUPINDEX);
22
24
  }
23
25
  }
26
+ /** GROUP BY list. */
24
27
  toString() {
25
- return this.groups.map((s) => `${s}`).toString();
28
+ return this.groups.map((s) => (s === QueryColumnNames.ROWGROUP ? BLANK_SAFE_ROWGROUP : s)).toString();
29
+ }
30
+ /** SELECT list for the GROUP BY columns. */
31
+ select() {
32
+ return this.groups.map((s) => (s === QueryColumnNames.ROWGROUP ? `${BLANK_SAFE_ROWGROUP} as ${s}` : s)).toString();
26
33
  }
27
34
  noCategory() {
28
35
  return this.groups.filter((element) => element !== QueryColumnNames.CATEGORY);