@finos/legend-cube-builder 0.0.4 → 0.0.5

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 (609) hide show
  1. package/README.md +9 -3
  2. package/docs/adding-an-operation.md +22 -12
  3. package/docs/demo/DEMO-FAST-NOTES.md +67 -0
  4. package/docs/demo/README.md +102 -0
  5. package/docs/demo/specs/duckdb-sales-pivot.cube.json +110 -0
  6. package/docs/demo/specs/trades-desks-1-joined.cube.json +123 -0
  7. package/docs/demo/specs/trades-desks-2-grouped.cube.json +140 -0
  8. package/docs/demo/specs/trades-desks-3-ranked.cube.json +158 -0
  9. package/docs/demo/specs/trades-desks-4-extended.cube.json +208 -0
  10. package/docs/demo/specs/trades-desks-5-final.cube.json +248 -0
  11. package/docs/hosting.md +50 -3
  12. package/docs/testing.md +32 -0
  13. package/lib/__lib__/LegendCubeCommand.d.ts +2 -0
  14. package/lib/__lib__/LegendCubeCommand.d.ts.map +1 -1
  15. package/lib/__lib__/LegendCubeCommand.js +7 -0
  16. package/lib/__lib__/LegendCubeCommand.js.map +1 -1
  17. package/lib/__lib__/LegendCubeFunctionLabels.d.ts +29 -0
  18. package/lib/__lib__/LegendCubeFunctionLabels.d.ts.map +1 -0
  19. package/lib/__lib__/LegendCubeFunctionLabels.js +31 -0
  20. package/lib/__lib__/LegendCubeFunctionLabels.js.map +1 -0
  21. package/lib/__lib__/LegendCubeHelpText.d.ts +5 -1
  22. package/lib/__lib__/LegendCubeHelpText.d.ts.map +1 -1
  23. package/lib/__lib__/LegendCubeHelpText.js +14 -2
  24. package/lib/__lib__/LegendCubeHelpText.js.map +1 -1
  25. package/lib/__lib__/LegendCubeLabels.d.ts +100 -8
  26. package/lib/__lib__/LegendCubeLabels.d.ts.map +1 -1
  27. package/lib/__lib__/LegendCubeLabels.js +129 -14
  28. package/lib/__lib__/LegendCubeLabels.js.map +1 -1
  29. package/lib/__lib__/LegendCubeProjectSourceLabels.d.ts +26 -0
  30. package/lib/__lib__/LegendCubeProjectSourceLabels.d.ts.map +1 -0
  31. package/lib/__lib__/LegendCubeProjectSourceLabels.js +26 -0
  32. package/lib/__lib__/LegendCubeProjectSourceLabels.js.map +1 -0
  33. package/lib/__lib__/LegendCubeServiceLabels.d.ts +27 -0
  34. package/lib/__lib__/LegendCubeServiceLabels.d.ts.map +1 -0
  35. package/lib/__lib__/LegendCubeServiceLabels.js +32 -0
  36. package/lib/__lib__/LegendCubeServiceLabels.js.map +1 -0
  37. package/lib/__lib__/LegendCubeTesting.d.ts +7 -0
  38. package/lib/__lib__/LegendCubeTesting.d.ts.map +1 -1
  39. package/lib/__lib__/LegendCubeTesting.js +7 -0
  40. package/lib/__lib__/LegendCubeTesting.js.map +1 -1
  41. package/lib/__test-utils__/CubeEngineTestSupport.d.ts +1 -1
  42. package/lib/__test-utils__/CubeEngineTestSupport.d.ts.map +1 -1
  43. package/lib/__test-utils__/CubeEngineTestSupport.js +2 -2
  44. package/lib/__test-utils__/CubeEngineTestSupport.js.map +1 -1
  45. package/lib/__test-utils__/CubeExpressionTestUtils.d.ts +8 -1
  46. package/lib/__test-utils__/CubeExpressionTestUtils.d.ts.map +1 -1
  47. package/lib/__test-utils__/CubeExpressionTestUtils.js +20 -3
  48. package/lib/__test-utils__/CubeExpressionTestUtils.js.map +1 -1
  49. package/lib/__test-utils__/CubeFunctionTestOutline.d.ts +26 -0
  50. package/lib/__test-utils__/CubeFunctionTestOutline.d.ts.map +1 -0
  51. package/lib/__test-utils__/CubeFunctionTestOutline.js +56 -0
  52. package/lib/__test-utils__/CubeFunctionTestOutline.js.map +1 -0
  53. package/lib/__test-utils__/CubeLambdaCorpus.d.ts +36 -0
  54. package/lib/__test-utils__/CubeLambdaCorpus.d.ts.map +1 -0
  55. package/lib/__test-utils__/CubeLambdaCorpus.js +83 -0
  56. package/lib/__test-utils__/CubeLambdaCorpus.js.map +1 -0
  57. package/lib/__test-utils__/CubePageTestUtils.d.ts +6 -0
  58. package/lib/__test-utils__/CubePageTestUtils.d.ts.map +1 -1
  59. package/lib/__test-utils__/CubePageTestUtils.js +21 -0
  60. package/lib/__test-utils__/CubePageTestUtils.js.map +1 -1
  61. package/lib/__test-utils__/CubeTestApplication.d.ts +9 -0
  62. package/lib/__test-utils__/CubeTestApplication.d.ts.map +1 -1
  63. package/lib/__test-utils__/CubeTestApplication.js +16 -0
  64. package/lib/__test-utils__/CubeTestApplication.js.map +1 -1
  65. package/lib/__test-utils__/FakeCubeEngine.d.ts +5 -0
  66. package/lib/__test-utils__/FakeCubeEngine.d.ts.map +1 -1
  67. package/lib/__test-utils__/FakeCubeEngine.js +17 -0
  68. package/lib/__test-utils__/FakeCubeEngine.js.map +1 -1
  69. package/lib/__test-utils__/FakeCubeIngestCatalog.d.ts +7 -1
  70. package/lib/__test-utils__/FakeCubeIngestCatalog.d.ts.map +1 -1
  71. package/lib/__test-utils__/FakeCubeIngestCatalog.js +16 -0
  72. package/lib/__test-utils__/FakeCubeIngestCatalog.js.map +1 -1
  73. package/lib/__test-utils__/FakeCubeServiceCatalog.d.ts +26 -0
  74. package/lib/__test-utils__/FakeCubeServiceCatalog.d.ts.map +1 -0
  75. package/lib/__test-utils__/FakeCubeServiceCatalog.js +40 -0
  76. package/lib/__test-utils__/FakeCubeServiceCatalog.js.map +1 -0
  77. package/lib/components/CubeAddItems.d.ts.map +1 -1
  78. package/lib/components/CubeAddItems.js +9 -6
  79. package/lib/components/CubeAddItems.js.map +1 -1
  80. package/lib/components/CubeDialogTheme.d.ts +25 -0
  81. package/lib/components/CubeDialogTheme.d.ts.map +1 -0
  82. package/lib/components/CubeDialogTheme.js +25 -0
  83. package/lib/components/CubeDialogTheme.js.map +1 -0
  84. package/lib/components/CubeEditor.d.ts +12 -1
  85. package/lib/components/CubeEditor.d.ts.map +1 -1
  86. package/lib/components/CubeEditor.js +16 -14
  87. package/lib/components/CubeEditor.js.map +1 -1
  88. package/lib/components/CubeFileMenu.d.ts +28 -0
  89. package/lib/components/CubeFileMenu.d.ts.map +1 -0
  90. package/lib/components/CubeFileMenu.js +77 -0
  91. package/lib/components/CubeFileMenu.js.map +1 -0
  92. package/lib/components/CubeLambdaImportBanner.d.ts +26 -0
  93. package/lib/components/CubeLambdaImportBanner.d.ts.map +1 -0
  94. package/lib/components/CubeLambdaImportBanner.js +47 -0
  95. package/lib/components/CubeLambdaImportBanner.js.map +1 -0
  96. package/lib/components/CubeNodeIcon.d.ts.map +1 -1
  97. package/lib/components/CubeNodeIcon.js +5 -1
  98. package/lib/components/CubeNodeIcon.js.map +1 -1
  99. package/lib/components/CubeSchemaColumnsTable.d.ts.map +1 -1
  100. package/lib/components/CubeSchemaColumnsTable.js +2 -2
  101. package/lib/components/CubeSchemaColumnsTable.js.map +1 -1
  102. package/lib/components/canvas/CubeCanvas.d.ts.map +1 -1
  103. package/lib/components/canvas/CubeCanvas.js +38 -5
  104. package/lib/components/canvas/CubeCanvas.js.map +1 -1
  105. package/lib/components/canvas/CubeCanvasContextMenu.d.ts.map +1 -1
  106. package/lib/components/canvas/CubeCanvasContextMenu.js +2 -1
  107. package/lib/components/canvas/CubeCanvasContextMenu.js.map +1 -1
  108. package/lib/components/canvas/CubeCanvasElements.d.ts +18 -1
  109. package/lib/components/canvas/CubeCanvasElements.d.ts.map +1 -1
  110. package/lib/components/canvas/CubeCanvasElements.js +58 -3
  111. package/lib/components/canvas/CubeCanvasElements.js.map +1 -1
  112. package/lib/components/canvas/CubeCanvasLayout.js +1 -1
  113. package/lib/components/canvas/CubeCanvasNode.d.ts.map +1 -1
  114. package/lib/components/canvas/CubeCanvasNode.js +8 -4
  115. package/lib/components/canvas/CubeCanvasNode.js.map +1 -1
  116. package/lib/components/dev-settings/CubeDevSettings.d.ts +35 -0
  117. package/lib/components/dev-settings/CubeDevSettings.d.ts.map +1 -0
  118. package/lib/components/dev-settings/CubeDevSettings.js +50 -0
  119. package/lib/components/dev-settings/CubeDevSettings.js.map +1 -0
  120. package/lib/components/editors/CubeColumnChecklist.d.ts.map +1 -1
  121. package/lib/components/editors/CubeColumnChecklist.js +2 -2
  122. package/lib/components/editors/CubeColumnChecklist.js.map +1 -1
  123. package/lib/components/editors/CubeColumnPicker.d.ts.map +1 -1
  124. package/lib/components/editors/CubeColumnPicker.js +3 -3
  125. package/lib/components/editors/CubeColumnPicker.js.map +1 -1
  126. package/lib/components/editors/CubeConcatEditor.js +2 -2
  127. package/lib/components/editors/CubeConcatEditor.js.map +1 -1
  128. package/lib/components/editors/CubeExpressionFilterEditor.d.ts +25 -0
  129. package/lib/components/editors/CubeExpressionFilterEditor.d.ts.map +1 -0
  130. package/lib/components/editors/CubeExpressionFilterEditor.js +83 -0
  131. package/lib/components/editors/CubeExpressionFilterEditor.js.map +1 -0
  132. package/lib/components/editors/CubeExtendEditor.d.ts +2 -0
  133. package/lib/components/editors/CubeExtendEditor.d.ts.map +1 -1
  134. package/lib/components/editors/CubeExtendEditor.js +3 -3
  135. package/lib/components/editors/CubeExtendEditor.js.map +1 -1
  136. package/lib/components/editors/CubeFilterEditor.d.ts.map +1 -1
  137. package/lib/components/editors/CubeFilterEditor.js +13 -2
  138. package/lib/components/editors/CubeFilterEditor.js.map +1 -1
  139. package/lib/components/editors/CubeFunctionSourceEditor.d.ts +25 -0
  140. package/lib/components/editors/CubeFunctionSourceEditor.d.ts.map +1 -0
  141. package/lib/components/editors/CubeFunctionSourceEditor.js +55 -0
  142. package/lib/components/editors/CubeFunctionSourceEditor.js.map +1 -0
  143. package/lib/components/editors/CubeJoinEditor.d.ts.map +1 -1
  144. package/lib/components/editors/CubeJoinEditor.js +16 -4
  145. package/lib/components/editors/CubeJoinEditor.js.map +1 -1
  146. package/lib/components/editors/CubeNodeEditorPanel.d.ts.map +1 -1
  147. package/lib/components/editors/CubeNodeEditorPanel.js +18 -8
  148. package/lib/components/editors/CubeNodeEditorPanel.js.map +1 -1
  149. package/lib/components/editors/CubeNodeEditorPopper.d.ts +5 -1
  150. package/lib/components/editors/CubeNodeEditorPopper.d.ts.map +1 -1
  151. package/lib/components/editors/CubeNodeEditorPopper.js +10 -2
  152. package/lib/components/editors/CubeNodeEditorPopper.js.map +1 -1
  153. package/lib/components/editors/CubeNodeEditorRegistry.d.ts.map +1 -1
  154. package/lib/components/editors/CubeNodeEditorRegistry.js +9 -1
  155. package/lib/components/editors/CubeNodeEditorRegistry.js.map +1 -1
  156. package/lib/components/editors/CubePivotEditor.d.ts +26 -0
  157. package/lib/components/editors/CubePivotEditor.d.ts.map +1 -0
  158. package/lib/components/editors/CubePivotEditor.js +93 -0
  159. package/lib/components/editors/CubePivotEditor.js.map +1 -0
  160. package/lib/components/editors/CubeRestrictEditor.d.ts.map +1 -1
  161. package/lib/components/editors/CubeRestrictEditor.js +2 -2
  162. package/lib/components/editors/CubeRestrictEditor.js.map +1 -1
  163. package/lib/components/editors/CubeServiceSourceEditor.d.ts +25 -0
  164. package/lib/components/editors/CubeServiceSourceEditor.d.ts.map +1 -0
  165. package/lib/components/editors/CubeServiceSourceEditor.js +41 -0
  166. package/lib/components/editors/CubeServiceSourceEditor.js.map +1 -0
  167. package/lib/components/grid/CubeColumnFormatDialog.d.ts +28 -0
  168. package/lib/components/grid/CubeColumnFormatDialog.d.ts.map +1 -0
  169. package/lib/components/grid/CubeColumnFormatDialog.js +94 -0
  170. package/lib/components/grid/CubeColumnFormatDialog.js.map +1 -0
  171. package/lib/components/grid/CubeDrilldownBar.d.ts +37 -0
  172. package/lib/components/grid/CubeDrilldownBar.d.ts.map +1 -0
  173. package/lib/components/grid/CubeDrilldownBar.js +77 -0
  174. package/lib/components/grid/CubeDrilldownBar.js.map +1 -0
  175. package/lib/components/grid/CubeGridRegion.d.ts.map +1 -1
  176. package/lib/components/grid/CubeGridRegion.js +40 -26
  177. package/lib/components/grid/CubeGridRegion.js.map +1 -1
  178. package/lib/components/grid/CubeGridValues.d.ts +31 -1
  179. package/lib/components/grid/CubeGridValues.d.ts.map +1 -1
  180. package/lib/components/grid/CubeGridValues.js +108 -1
  181. package/lib/components/grid/CubeGridValues.js.map +1 -1
  182. package/lib/components/grid/CubeResultGrid.d.ts +68 -5
  183. package/lib/components/grid/CubeResultGrid.d.ts.map +1 -1
  184. package/lib/components/grid/CubeResultGrid.js +308 -35
  185. package/lib/components/grid/CubeResultGrid.js.map +1 -1
  186. package/lib/components/grid/CubeRunStatsPanel.d.ts +28 -0
  187. package/lib/components/grid/CubeRunStatsPanel.d.ts.map +1 -0
  188. package/lib/components/grid/CubeRunStatsPanel.js +61 -0
  189. package/lib/components/grid/CubeRunStatsPanel.js.map +1 -0
  190. package/lib/components/grid/CubeServerSideGrid.d.ts +36 -0
  191. package/lib/components/grid/CubeServerSideGrid.d.ts.map +1 -0
  192. package/lib/components/grid/CubeServerSideGrid.js +114 -0
  193. package/lib/components/grid/CubeServerSideGrid.js.map +1 -0
  194. package/lib/components/grid/CubeSqlDialog.d.ts +24 -0
  195. package/lib/components/grid/CubeSqlDialog.d.ts.map +1 -0
  196. package/lib/components/grid/CubeSqlDialog.js +39 -0
  197. package/lib/components/grid/CubeSqlDialog.js.map +1 -0
  198. package/lib/components/grid/CubeSqlFormat.d.ts +20 -0
  199. package/lib/components/grid/CubeSqlFormat.d.ts.map +1 -0
  200. package/lib/components/grid/CubeSqlFormat.js +32 -0
  201. package/lib/components/grid/CubeSqlFormat.js.map +1 -0
  202. package/lib/components/palette/CubePalette.d.ts.map +1 -1
  203. package/lib/components/palette/CubePalette.js +32 -13
  204. package/lib/components/palette/CubePalette.js.map +1 -1
  205. package/lib/components/show-pure/CubeShowPureDialog.d.ts +4 -1
  206. package/lib/components/show-pure/CubeShowPureDialog.d.ts.map +1 -1
  207. package/lib/components/show-pure/CubeShowPureDialog.js +8 -4
  208. package/lib/components/show-pure/CubeShowPureDialog.js.map +1 -1
  209. package/lib/components/source-picker/CubeDataProductTab.d.ts.map +1 -1
  210. package/lib/components/source-picker/CubeDataProductTab.js +37 -16
  211. package/lib/components/source-picker/CubeDataProductTab.js.map +1 -1
  212. package/lib/components/source-picker/CubeDirectConnectionTab.d.ts.map +1 -1
  213. package/lib/components/source-picker/CubeDirectConnectionTab.js +6 -4
  214. package/lib/components/source-picker/CubeDirectConnectionTab.js.map +1 -1
  215. package/lib/components/source-picker/CubeFunctionSteps.d.ts +36 -0
  216. package/lib/components/source-picker/CubeFunctionSteps.d.ts.map +1 -0
  217. package/lib/components/source-picker/CubeFunctionSteps.js +76 -0
  218. package/lib/components/source-picker/CubeFunctionSteps.js.map +1 -0
  219. package/lib/components/source-picker/CubeIngestTab.d.ts.map +1 -1
  220. package/lib/components/source-picker/CubeIngestTab.js +39 -16
  221. package/lib/components/source-picker/CubeIngestTab.js.map +1 -1
  222. package/lib/components/source-picker/CubeInlineModelTab.d.ts +3 -2
  223. package/lib/components/source-picker/CubeInlineModelTab.d.ts.map +1 -1
  224. package/lib/components/source-picker/CubeInlineModelTab.js +23 -13
  225. package/lib/components/source-picker/CubeInlineModelTab.js.map +1 -1
  226. package/lib/components/source-picker/CubePickerListItem.d.ts +47 -0
  227. package/lib/components/source-picker/CubePickerListItem.d.ts.map +1 -0
  228. package/lib/components/source-picker/CubePickerListItem.js +62 -0
  229. package/lib/components/source-picker/CubePickerListItem.js.map +1 -0
  230. package/lib/components/source-picker/CubeProjectTab.d.ts +4 -3
  231. package/lib/components/source-picker/CubeProjectTab.d.ts.map +1 -1
  232. package/lib/components/source-picker/CubeProjectTab.js +7 -4
  233. package/lib/components/source-picker/CubeProjectTab.js.map +1 -1
  234. package/lib/components/source-picker/CubeServiceTab.d.ts +27 -0
  235. package/lib/components/source-picker/CubeServiceTab.d.ts.map +1 -0
  236. package/lib/components/source-picker/CubeServiceTab.js +36 -0
  237. package/lib/components/source-picker/CubeServiceTab.js.map +1 -0
  238. package/lib/components/source-picker/CubeSourcePicker.d.ts.map +1 -1
  239. package/lib/components/source-picker/CubeSourcePicker.js +16 -3
  240. package/lib/components/source-picker/CubeSourcePicker.js.map +1 -1
  241. package/lib/components/source-picker/CubeTablePreview.d.ts +29 -0
  242. package/lib/components/source-picker/CubeTablePreview.d.ts.map +1 -0
  243. package/lib/components/source-picker/CubeTablePreview.js +10 -0
  244. package/lib/components/source-picker/CubeTablePreview.js.map +1 -0
  245. package/lib/components/spec-transfer/CubeImportPureDialog.d.ts +27 -0
  246. package/lib/components/spec-transfer/CubeImportPureDialog.d.ts.map +1 -0
  247. package/lib/components/spec-transfer/CubeImportPureDialog.js +38 -0
  248. package/lib/components/spec-transfer/CubeImportPureDialog.js.map +1 -0
  249. package/lib/components/spec-transfer/CubeSpecTransferDialog.d.ts.map +1 -1
  250. package/lib/components/spec-transfer/CubeSpecTransferDialog.js +9 -3
  251. package/lib/components/spec-transfer/CubeSpecTransferDialog.js.map +1 -1
  252. package/lib/graph-manager/CubeDataProductCatalog.d.ts +10 -0
  253. package/lib/graph-manager/CubeDataProductCatalog.d.ts.map +1 -1
  254. package/lib/graph-manager/CubeDataProductCatalog.js.map +1 -1
  255. package/lib/graph-manager/CubeEngine.d.ts +46 -1
  256. package/lib/graph-manager/CubeEngine.d.ts.map +1 -1
  257. package/lib/graph-manager/CubeEngine.js.map +1 -1
  258. package/lib/graph-manager/CubeEngineClientSettings.d.ts +43 -0
  259. package/lib/graph-manager/CubeEngineClientSettings.d.ts.map +1 -0
  260. package/lib/graph-manager/CubeEngineClientSettings.js +51 -0
  261. package/lib/graph-manager/CubeEngineClientSettings.js.map +1 -0
  262. package/lib/graph-manager/CubeIngest.d.ts +5 -0
  263. package/lib/graph-manager/CubeIngest.d.ts.map +1 -1
  264. package/lib/graph-manager/CubeIngest.js +10 -0
  265. package/lib/graph-manager/CubeIngest.js.map +1 -1
  266. package/lib/graph-manager/CubeIngestCatalog.d.ts +26 -0
  267. package/lib/graph-manager/CubeIngestCatalog.d.ts.map +1 -1
  268. package/lib/graph-manager/CubeIngestCatalog.js +6 -0
  269. package/lib/graph-manager/CubeIngestCatalog.js.map +1 -1
  270. package/lib/graph-manager/CubeLakehouseRuntime.d.ts +29 -0
  271. package/lib/graph-manager/CubeLakehouseRuntime.d.ts.map +1 -0
  272. package/lib/graph-manager/CubeLakehouseRuntime.js +40 -0
  273. package/lib/graph-manager/CubeLakehouseRuntime.js.map +1 -0
  274. package/lib/graph-manager/CubeProjectCatalog.d.ts +3 -3
  275. package/lib/graph-manager/CubeService.d.ts +20 -0
  276. package/lib/graph-manager/CubeService.d.ts.map +1 -0
  277. package/lib/graph-manager/CubeService.js +22 -0
  278. package/lib/graph-manager/CubeService.js.map +1 -0
  279. package/lib/graph-manager/CubeServiceCatalog.d.ts +31 -0
  280. package/lib/graph-manager/CubeServiceCatalog.d.ts.map +1 -0
  281. package/lib/graph-manager/CubeServiceCatalog.js +17 -0
  282. package/lib/graph-manager/CubeServiceCatalog.js.map +1 -0
  283. package/lib/graph-manager/protocol/pure/CubeEngineBuilder.d.ts +52 -5
  284. package/lib/graph-manager/protocol/pure/CubeEngineBuilder.d.ts.map +1 -1
  285. package/lib/graph-manager/protocol/pure/CubeEngineBuilder.js +63 -5
  286. package/lib/graph-manager/protocol/pure/CubeEngineBuilder.js.map +1 -1
  287. package/lib/graph-manager/protocol/pure/v1/V1_CubeDataProductModel.d.ts +9 -6
  288. package/lib/graph-manager/protocol/pure/v1/V1_CubeDataProductModel.d.ts.map +1 -1
  289. package/lib/graph-manager/protocol/pure/v1/V1_CubeDataProductModel.js +12 -8
  290. package/lib/graph-manager/protocol/pure/v1/V1_CubeDataProductModel.js.map +1 -1
  291. package/lib/graph-manager/protocol/pure/v1/V1_CubeFunctionOutlineBuilder.d.ts +30 -0
  292. package/lib/graph-manager/protocol/pure/v1/V1_CubeFunctionOutlineBuilder.d.ts.map +1 -0
  293. package/lib/graph-manager/protocol/pure/v1/V1_CubeFunctionOutlineBuilder.js +229 -0
  294. package/lib/graph-manager/protocol/pure/v1/V1_CubeFunctionOutlineBuilder.js.map +1 -0
  295. package/lib/graph-manager/protocol/pure/v1/V1_CubeIngestDefinition.d.ts.map +1 -1
  296. package/lib/graph-manager/protocol/pure/v1/V1_CubeIngestDefinition.js +18 -9
  297. package/lib/graph-manager/protocol/pure/v1/V1_CubeIngestDefinition.js.map +1 -1
  298. package/lib/graph-manager/protocol/pure/v1/V1_CubeIngestModel.d.ts +4 -9
  299. package/lib/graph-manager/protocol/pure/v1/V1_CubeIngestModel.d.ts.map +1 -1
  300. package/lib/graph-manager/protocol/pure/v1/V1_CubeIngestModel.js +2 -1
  301. package/lib/graph-manager/protocol/pure/v1/V1_CubeIngestModel.js.map +1 -1
  302. package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaReader.d.ts +34 -0
  303. package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaReader.d.ts.map +1 -0
  304. package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaReader.js +332 -0
  305. package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaReader.js.map +1 -0
  306. package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.d.ts.map +1 -1
  307. package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.js +49 -10
  308. package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.js.map +1 -1
  309. package/lib/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.d.ts +1 -1
  310. package/lib/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.d.ts.map +1 -1
  311. package/lib/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.js +3 -1
  312. package/lib/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.js.map +1 -1
  313. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeConnectionExplorer.d.ts +2 -1
  314. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeConnectionExplorer.d.ts.map +1 -1
  315. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeConnectionExplorer.js +2 -1
  316. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeConnectionExplorer.js.map +1 -1
  317. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.d.ts +18 -0
  318. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.d.ts.map +1 -1
  319. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.js +74 -6
  320. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.js.map +1 -1
  321. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeProjectCatalog.d.ts.map +1 -1
  322. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeProjectCatalog.js +7 -4
  323. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeProjectCatalog.js.map +1 -1
  324. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeServiceCatalog.d.ts +31 -0
  325. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeServiceCatalog.d.ts.map +1 -0
  326. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeServiceCatalog.js +69 -0
  327. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeServiceCatalog.js.map +1 -0
  328. package/lib/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.d.ts.map +1 -1
  329. package/lib/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.js +6 -2
  330. package/lib/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.js.map +1 -1
  331. package/lib/index.css +2 -2
  332. package/lib/index.css.map +1 -1
  333. package/lib/index.d.ts +12 -3
  334. package/lib/index.d.ts.map +1 -1
  335. package/lib/index.js +10 -1
  336. package/lib/index.js.map +1 -1
  337. package/lib/stores/CubeAddPlacement.d.ts +10 -3
  338. package/lib/stores/CubeAddPlacement.d.ts.map +1 -1
  339. package/lib/stores/CubeAddPlacement.js +16 -5
  340. package/lib/stores/CubeAddPlacement.js.map +1 -1
  341. package/lib/stores/CubeDevSettingsState.d.ts +47 -0
  342. package/lib/stores/CubeDevSettingsState.d.ts.map +1 -0
  343. package/lib/stores/CubeDevSettingsState.js +99 -0
  344. package/lib/stores/CubeDevSettingsState.js.map +1 -0
  345. package/lib/stores/CubeEditorState.d.ts +173 -43
  346. package/lib/stores/CubeEditorState.d.ts.map +1 -1
  347. package/lib/stores/CubeEditorState.js +498 -113
  348. package/lib/stores/CubeEditorState.js.map +1 -1
  349. package/lib/stores/CubeEngineChecks.d.ts +59 -0
  350. package/lib/stores/CubeEngineChecks.d.ts.map +1 -0
  351. package/lib/stores/CubeEngineChecks.js +100 -0
  352. package/lib/stores/CubeEngineChecks.js.map +1 -0
  353. package/lib/stores/CubeExamples.d.ts.map +1 -1
  354. package/lib/stores/CubeExamples.js +39 -2
  355. package/lib/stores/CubeExamples.js.map +1 -1
  356. package/lib/stores/CubeExamplesState.d.ts +1 -1
  357. package/lib/stores/CubeExamplesState.d.ts.map +1 -1
  358. package/lib/stores/CubeExamplesState.js +2 -2
  359. package/lib/stores/CubeExamplesState.js.map +1 -1
  360. package/lib/stores/CubeExecutionState.d.ts.map +1 -1
  361. package/lib/stores/CubeExecutionState.js +24 -33
  362. package/lib/stores/CubeExecutionState.js.map +1 -1
  363. package/lib/stores/CubeExportState.d.ts +41 -0
  364. package/lib/stores/CubeExportState.d.ts.map +1 -0
  365. package/lib/stores/CubeExportState.js +134 -0
  366. package/lib/stores/CubeExportState.js.map +1 -0
  367. package/lib/stores/CubeExpressionFilterCheck.d.ts +51 -0
  368. package/lib/stores/CubeExpressionFilterCheck.d.ts.map +1 -0
  369. package/lib/stores/CubeExpressionFilterCheck.js +134 -0
  370. package/lib/stores/CubeExpressionFilterCheck.js.map +1 -0
  371. package/lib/stores/CubeExtendTyping.d.ts +6 -14
  372. package/lib/stores/CubeExtendTyping.d.ts.map +1 -1
  373. package/lib/stores/CubeExtendTyping.js +6 -33
  374. package/lib/stores/CubeExtendTyping.js.map +1 -1
  375. package/lib/stores/CubeFunctionRecheck.d.ts +30 -0
  376. package/lib/stores/CubeFunctionRecheck.d.ts.map +1 -0
  377. package/lib/stores/CubeFunctionRecheck.js +67 -0
  378. package/lib/stores/CubeFunctionRecheck.js.map +1 -0
  379. package/lib/stores/CubeGridFetcher.d.ts +75 -0
  380. package/lib/stores/CubeGridFetcher.d.ts.map +1 -0
  381. package/lib/stores/CubeGridFetcher.js +197 -0
  382. package/lib/stores/CubeGridFetcher.js.map +1 -0
  383. package/lib/stores/CubeGridQuickActions.d.ts +18 -6
  384. package/lib/stores/CubeGridQuickActions.d.ts.map +1 -1
  385. package/lib/stores/CubeGridQuickActions.js +32 -12
  386. package/lib/stores/CubeGridQuickActions.js.map +1 -1
  387. package/lib/stores/CubeGridState.d.ts +136 -0
  388. package/lib/stores/CubeGridState.d.ts.map +1 -0
  389. package/lib/stores/CubeGridState.js +317 -0
  390. package/lib/stores/CubeGridState.js.map +1 -0
  391. package/lib/stores/CubeHost.d.ts +42 -0
  392. package/lib/stores/CubeHost.d.ts.map +1 -1
  393. package/lib/stores/CubeHost.js +4 -0
  394. package/lib/stores/CubeHost.js.map +1 -1
  395. package/lib/stores/CubeLambdaImportState.d.ts +118 -0
  396. package/lib/stores/CubeLambdaImportState.d.ts.map +1 -0
  397. package/lib/stores/CubeLambdaImportState.js +302 -0
  398. package/lib/stores/CubeLambdaImportState.js.map +1 -0
  399. package/lib/stores/CubeLambdaSources.d.ts +45 -0
  400. package/lib/stores/CubeLambdaSources.d.ts.map +1 -0
  401. package/lib/stores/CubeLambdaSources.js +261 -0
  402. package/lib/stores/CubeLambdaSources.js.map +1 -0
  403. package/lib/stores/CubeQueryRun.d.ts +59 -0
  404. package/lib/stores/CubeQueryRun.d.ts.map +1 -0
  405. package/lib/stores/CubeQueryRun.js +101 -0
  406. package/lib/stores/CubeQueryRun.js.map +1 -0
  407. package/lib/stores/CubeRunStatsState.d.ts +61 -0
  408. package/lib/stores/CubeRunStatsState.d.ts.map +1 -0
  409. package/lib/stores/CubeRunStatsState.js +54 -0
  410. package/lib/stores/CubeRunStatsState.js.map +1 -0
  411. package/lib/stores/CubeRunningStepLambda.d.ts +25 -0
  412. package/lib/stores/CubeRunningStepLambda.d.ts.map +1 -0
  413. package/lib/stores/CubeRunningStepLambda.js +45 -0
  414. package/lib/stores/CubeRunningStepLambda.js.map +1 -0
  415. package/lib/stores/CubeServiceRecheck.d.ts +29 -0
  416. package/lib/stores/CubeServiceRecheck.d.ts.map +1 -0
  417. package/lib/stores/CubeServiceRecheck.js +33 -0
  418. package/lib/stores/CubeServiceRecheck.js.map +1 -0
  419. package/lib/stores/CubeShowPureState.d.ts +14 -1
  420. package/lib/stores/CubeShowPureState.d.ts.map +1 -1
  421. package/lib/stores/CubeShowPureState.js +41 -11
  422. package/lib/stores/CubeShowPureState.js.map +1 -1
  423. package/lib/stores/CubeSourcePickerState.d.ts +20 -4
  424. package/lib/stores/CubeSourcePickerState.d.ts.map +1 -1
  425. package/lib/stores/CubeSourcePickerState.js +75 -14
  426. package/lib/stores/CubeSourcePickerState.js.map +1 -1
  427. package/lib/stores/LocalModelCatalog.d.ts.map +1 -1
  428. package/lib/stores/LocalModelCatalog.js +3 -1
  429. package/lib/stores/LocalModelCatalog.js.map +1 -1
  430. package/lib/stores/editors/CubeExpressionFilterDraft.d.ts +91 -0
  431. package/lib/stores/editors/CubeExpressionFilterDraft.d.ts.map +1 -0
  432. package/lib/stores/editors/CubeExpressionFilterDraft.js +254 -0
  433. package/lib/stores/editors/CubeExpressionFilterDraft.js.map +1 -0
  434. package/lib/stores/editors/CubeFunctionDraft.d.ts +34 -0
  435. package/lib/stores/editors/CubeFunctionDraft.d.ts.map +1 -0
  436. package/lib/stores/editors/CubeFunctionDraft.js +69 -0
  437. package/lib/stores/editors/CubeFunctionDraft.js.map +1 -0
  438. package/lib/stores/editors/CubeNodeDraftRegistry.d.ts +4 -2
  439. package/lib/stores/editors/CubeNodeDraftRegistry.d.ts.map +1 -1
  440. package/lib/stores/editors/CubeNodeDraftRegistry.js +20 -3
  441. package/lib/stores/editors/CubeNodeDraftRegistry.js.map +1 -1
  442. package/lib/stores/editors/CubePivotDraft.d.ts +93 -0
  443. package/lib/stores/editors/CubePivotDraft.d.ts.map +1 -0
  444. package/lib/stores/editors/CubePivotDraft.js +267 -0
  445. package/lib/stores/editors/CubePivotDraft.js.map +1 -0
  446. package/lib/stores/fixtures/CubeSalesDuckDbModel.d.ts +26 -0
  447. package/lib/stores/fixtures/CubeSalesDuckDbModel.d.ts.map +1 -0
  448. package/lib/stores/fixtures/CubeSalesDuckDbModel.js +46 -0
  449. package/lib/stores/fixtures/CubeSalesDuckDbModel.js.map +1 -0
  450. package/lib/stores/fixtures/CubeTradesModel.d.ts +4 -0
  451. package/lib/stores/fixtures/CubeTradesModel.d.ts.map +1 -1
  452. package/lib/stores/fixtures/CubeTradesModel.js +31 -1
  453. package/lib/stores/fixtures/CubeTradesModel.js.map +1 -1
  454. package/lib/stores/source-picker/CubeDataProductTabState.d.ts +34 -5
  455. package/lib/stores/source-picker/CubeDataProductTabState.d.ts.map +1 -1
  456. package/lib/stores/source-picker/CubeDataProductTabState.js +111 -26
  457. package/lib/stores/source-picker/CubeDataProductTabState.js.map +1 -1
  458. package/lib/stores/source-picker/CubeDirectConnectionTabState.d.ts +25 -2
  459. package/lib/stores/source-picker/CubeDirectConnectionTabState.d.ts.map +1 -1
  460. package/lib/stores/source-picker/CubeDirectConnectionTabState.js +183 -31
  461. package/lib/stores/source-picker/CubeDirectConnectionTabState.js.map +1 -1
  462. package/lib/stores/source-picker/CubeIngestTabState.d.ts +22 -9
  463. package/lib/stores/source-picker/CubeIngestTabState.d.ts.map +1 -1
  464. package/lib/stores/source-picker/CubeIngestTabState.js +84 -29
  465. package/lib/stores/source-picker/CubeIngestTabState.js.map +1 -1
  466. package/lib/stores/source-picker/CubeInlineModelTabState.d.ts +100 -4
  467. package/lib/stores/source-picker/CubeInlineModelTabState.d.ts.map +1 -1
  468. package/lib/stores/source-picker/CubeInlineModelTabState.js +415 -28
  469. package/lib/stores/source-picker/CubeInlineModelTabState.js.map +1 -1
  470. package/lib/stores/source-picker/CubeProjectTabState.d.ts +18 -3
  471. package/lib/stores/source-picker/CubeProjectTabState.d.ts.map +1 -1
  472. package/lib/stores/source-picker/CubeProjectTabState.js +26 -1
  473. package/lib/stores/source-picker/CubeProjectTabState.js.map +1 -1
  474. package/lib/stores/source-picker/CubeServiceTabState.d.ts +74 -0
  475. package/lib/stores/source-picker/CubeServiceTabState.d.ts.map +1 -0
  476. package/lib/stores/source-picker/CubeServiceTabState.js +216 -0
  477. package/lib/stores/source-picker/CubeServiceTabState.js.map +1 -0
  478. package/lib/stores/source-picker/CubeSourcePickerTab.d.ts +15 -3
  479. package/lib/stores/source-picker/CubeSourcePickerTab.d.ts.map +1 -1
  480. package/lib/stores/source-picker/CubeSourcePickerTab.js +21 -0
  481. package/lib/stores/source-picker/CubeSourcePickerTab.js.map +1 -1
  482. package/package.json +10 -9
  483. package/src/__lib__/LegendCubeCommand.ts +7 -0
  484. package/src/__lib__/LegendCubeFunctionLabels.ts +41 -0
  485. package/src/__lib__/LegendCubeHelpText.ts +23 -1
  486. package/src/__lib__/LegendCubeLabels.ts +170 -13
  487. package/src/__lib__/LegendCubeProjectSourceLabels.ts +26 -0
  488. package/src/__lib__/LegendCubeServiceLabels.ts +41 -0
  489. package/src/__lib__/LegendCubeTesting.ts +7 -0
  490. package/src/__test-utils__/CubeEngineTestSupport.ts +2 -1
  491. package/src/__test-utils__/CubeExpressionTestUtils.ts +29 -2
  492. package/src/__test-utils__/CubeFunctionTestOutline.ts +78 -0
  493. package/src/__test-utils__/CubeLambdaCorpus.ts +137 -0
  494. package/src/__test-utils__/CubePageTestUtils.tsx +34 -0
  495. package/src/__test-utils__/CubeTestApplication.ts +25 -0
  496. package/src/__test-utils__/FakeCubeEngine.ts +27 -0
  497. package/src/__test-utils__/FakeCubeIngestCatalog.ts +18 -0
  498. package/src/__test-utils__/FakeCubeServiceCatalog.ts +57 -0
  499. package/src/components/CubeAddItems.tsx +13 -6
  500. package/src/components/CubeDialogTheme.ts +25 -0
  501. package/src/components/CubeEditor.tsx +155 -129
  502. package/src/components/CubeFileMenu.tsx +127 -0
  503. package/src/components/CubeLambdaImportBanner.tsx +97 -0
  504. package/src/components/CubeNodeIcon.tsx +7 -0
  505. package/src/components/CubeSchemaColumnsTable.tsx +7 -2
  506. package/src/components/canvas/CubeCanvas.tsx +52 -13
  507. package/src/components/canvas/CubeCanvasContextMenu.tsx +33 -2
  508. package/src/components/canvas/CubeCanvasElements.ts +76 -3
  509. package/src/components/canvas/CubeCanvasLayout.ts +1 -1
  510. package/src/components/canvas/CubeCanvasNode.tsx +30 -3
  511. package/src/components/dev-settings/CubeDevSettings.tsx +154 -0
  512. package/src/components/editors/CubeColumnChecklist.tsx +8 -2
  513. package/src/components/editors/CubeColumnPicker.tsx +6 -3
  514. package/src/components/editors/CubeConcatEditor.tsx +2 -2
  515. package/src/components/editors/CubeExpressionFilterEditor.tsx +193 -0
  516. package/src/components/editors/CubeExtendEditor.tsx +3 -3
  517. package/src/components/editors/CubeFilterEditor.tsx +13 -1
  518. package/src/components/editors/CubeFunctionSourceEditor.tsx +140 -0
  519. package/src/components/editors/CubeJoinEditor.tsx +23 -4
  520. package/src/components/editors/CubeNodeEditorPanel.tsx +22 -10
  521. package/src/components/editors/CubeNodeEditorPopper.tsx +9 -1
  522. package/src/components/editors/CubeNodeEditorRegistry.ts +12 -0
  523. package/src/components/editors/CubePivotEditor.tsx +277 -0
  524. package/src/components/editors/CubeRestrictEditor.tsx +8 -2
  525. package/src/components/editors/CubeServiceSourceEditor.tsx +77 -0
  526. package/src/components/grid/CubeColumnFormatDialog.tsx +289 -0
  527. package/src/components/grid/CubeDrilldownBar.tsx +219 -0
  528. package/src/components/grid/CubeGridRegion.tsx +170 -54
  529. package/src/components/grid/CubeGridValues.ts +146 -1
  530. package/src/components/grid/CubeResultGrid.tsx +443 -41
  531. package/src/components/grid/CubeRunStatsPanel.tsx +156 -0
  532. package/src/components/grid/CubeServerSideGrid.tsx +200 -0
  533. package/src/components/grid/CubeSqlDialog.tsx +90 -0
  534. package/src/components/grid/CubeSqlFormat.ts +37 -0
  535. package/src/components/palette/CubePalette.tsx +45 -12
  536. package/src/components/show-pure/CubeShowPureDialog.tsx +19 -5
  537. package/src/components/source-picker/CubeDataProductTab.tsx +169 -75
  538. package/src/components/source-picker/CubeDirectConnectionTab.tsx +42 -30
  539. package/src/components/source-picker/CubeFunctionSteps.tsx +244 -0
  540. package/src/components/source-picker/CubeIngestTab.tsx +159 -79
  541. package/src/components/source-picker/CubeInlineModelTab.tsx +110 -81
  542. package/src/components/source-picker/CubePickerListItem.tsx +118 -0
  543. package/src/components/source-picker/CubeProjectTab.tsx +6 -3
  544. package/src/components/source-picker/CubeServiceTab.tsx +151 -0
  545. package/src/components/source-picker/CubeSourcePicker.tsx +54 -18
  546. package/src/components/source-picker/CubeTablePreview.tsx +49 -0
  547. package/src/components/spec-transfer/CubeImportPureDialog.tsx +122 -0
  548. package/src/components/spec-transfer/CubeSpecTransferDialog.tsx +21 -8
  549. package/src/graph-manager/CubeDataProductCatalog.ts +11 -0
  550. package/src/graph-manager/CubeEngine.ts +51 -1
  551. package/src/graph-manager/CubeEngineClientSettings.ts +64 -0
  552. package/src/graph-manager/CubeIngest.ts +15 -0
  553. package/src/graph-manager/CubeIngestCatalog.ts +33 -0
  554. package/src/graph-manager/CubeLakehouseRuntime.ts +43 -0
  555. package/src/graph-manager/CubeProjectCatalog.ts +3 -3
  556. package/src/graph-manager/CubeService.ts +29 -0
  557. package/src/graph-manager/CubeServiceCatalog.ts +35 -0
  558. package/src/graph-manager/protocol/pure/CubeEngineBuilder.ts +115 -5
  559. package/src/graph-manager/protocol/pure/v1/V1_CubeDataProductModel.ts +13 -7
  560. package/src/graph-manager/protocol/pure/v1/V1_CubeFunctionOutlineBuilder.ts +312 -0
  561. package/src/graph-manager/protocol/pure/v1/V1_CubeIngestDefinition.ts +35 -9
  562. package/src/graph-manager/protocol/pure/v1/V1_CubeIngestModel.ts +6 -15
  563. package/src/graph-manager/protocol/pure/v1/V1_CubeLambdaReader.ts +471 -0
  564. package/src/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.ts +70 -15
  565. package/src/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.ts +3 -1
  566. package/src/graph-manager/protocol/pure/v1/V1_LegendCubeConnectionExplorer.ts +7 -1
  567. package/src/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.ts +122 -7
  568. package/src/graph-manager/protocol/pure/v1/V1_LegendCubeProjectCatalog.ts +9 -4
  569. package/src/graph-manager/protocol/pure/v1/V1_LegendCubeServiceCatalog.ts +92 -0
  570. package/src/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.ts +6 -1
  571. package/src/index.ts +32 -2
  572. package/src/stores/CubeAddPlacement.ts +25 -5
  573. package/src/stores/CubeDevSettingsState.ts +117 -0
  574. package/src/stores/CubeEditorState.ts +687 -197
  575. package/src/stores/CubeEngineChecks.ts +240 -0
  576. package/src/stores/CubeExamples.ts +70 -1
  577. package/src/stores/CubeExamplesState.ts +4 -2
  578. package/src/stores/CubeExecutionState.ts +26 -57
  579. package/src/stores/CubeExportState.ts +196 -0
  580. package/src/stores/CubeExpressionFilterCheck.ts +218 -0
  581. package/src/stores/CubeExtendTyping.ts +6 -46
  582. package/src/stores/CubeFunctionRecheck.ts +97 -0
  583. package/src/stores/CubeGridFetcher.ts +302 -0
  584. package/src/stores/CubeGridQuickActions.ts +33 -11
  585. package/src/stores/CubeGridState.ts +450 -0
  586. package/src/stores/CubeHost.ts +48 -0
  587. package/src/stores/CubeLambdaImportState.ts +434 -0
  588. package/src/stores/CubeLambdaSources.ts +390 -0
  589. package/src/stores/CubeQueryRun.ts +169 -0
  590. package/src/stores/CubeRunStatsState.ts +91 -0
  591. package/src/stores/CubeRunningStepLambda.ts +62 -0
  592. package/src/stores/CubeServiceRecheck.ts +53 -0
  593. package/src/stores/CubeShowPureState.ts +51 -12
  594. package/src/stores/CubeSourcePickerState.ts +89 -13
  595. package/src/stores/LocalModelCatalog.ts +6 -1
  596. package/src/stores/editors/CubeExpressionFilterDraft.ts +385 -0
  597. package/src/stores/editors/CubeFunctionDraft.ts +92 -0
  598. package/src/stores/editors/CubeNodeDraftRegistry.ts +27 -2
  599. package/src/stores/editors/CubePivotDraft.ts +355 -0
  600. package/src/stores/fixtures/CubeSalesDuckDbModel.ts +54 -0
  601. package/src/stores/fixtures/CubeTradesModel.ts +36 -1
  602. package/src/stores/source-picker/CubeDataProductTabState.ts +162 -35
  603. package/src/stores/source-picker/CubeDirectConnectionTabState.ts +246 -47
  604. package/src/stores/source-picker/CubeIngestTabState.ts +112 -38
  605. package/src/stores/source-picker/CubeInlineModelTabState.ts +514 -34
  606. package/src/stores/source-picker/CubeProjectTabState.ts +35 -3
  607. package/src/stores/source-picker/CubeServiceTabState.ts +288 -0
  608. package/src/stores/source-picker/CubeSourcePickerTab.ts +31 -2
  609. package/tsconfig.json +50 -0
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Copyright (c) 2026-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {
18
+ Dialog,
19
+ Modal,
20
+ ModalBody,
21
+ ModalFooter,
22
+ ModalFooterButton,
23
+ ModalHeader,
24
+ TimesIcon,
25
+ } from '@finos/legend-art';
26
+ import {
27
+ type AggregationFunction,
28
+ foldColumnName,
29
+ getAggregationDisplayName,
30
+ getDefaultDrilldownAggregation,
31
+ getDrilldownAggregations,
32
+ } from '@finos/legend-cube';
33
+ import { observer } from 'mobx-react-lite';
34
+ import { READ_ONLY_CUBE_TITLE } from '../../__lib__/LegendCubeLabels.js';
35
+ import { LEGEND_CUBE_TEST_ID } from '../../__lib__/LegendCubeTesting.js';
36
+ import type { CubeEditorState } from '../../stores/CubeEditorState.js';
37
+ import { CubeButton } from '../CubeButton.js';
38
+
39
+ /** The value of the setting that leaves a column empty on group rows */
40
+ const NO_AGGREGATION = '';
41
+
42
+ /**
43
+ * How a group row shows each column of the run that isn't a level (PLAN
44
+ * §11.10): a function its type offers, or nothing; the default (a number's
45
+ * Sum, nothing for any other column) is marked
46
+ */
47
+ export const CubeDrilldownSettingsDialog = observer(
48
+ (props: { editorState: CubeEditorState }) => {
49
+ const { editorState } = props;
50
+ const { grid } = editorState;
51
+ const { result } = editorState.execution;
52
+ const drilldown = grid.drilldown;
53
+ const darkMode =
54
+ !editorState.host.applicationStore.layoutService
55
+ .TEMPORARY__isLightColorThemeEnabled;
56
+ if (!result || !drilldown) {
57
+ return null;
58
+ }
59
+ const levels = new Set(drilldown.columns.map(foldColumnName));
60
+ const label = (fn: AggregationFunction | null, isDefault: boolean) =>
61
+ `${fn === null ? 'Nothing' : getAggregationDisplayName(fn)}${isDefault ? ' (default)' : ''}`;
62
+ return (
63
+ <Dialog open={grid.isSettingsShown} onClose={() => grid.closeSettings()}>
64
+ <Modal darkMode={darkMode} className="w-[520px] max-w-full">
65
+ <ModalHeader>
66
+ <div className="modal__title">Group rows</div>
67
+ </ModalHeader>
68
+ <ModalBody>
69
+ <p className="mb-2 text-base text-[var(--color-text-secondary)]">
70
+ {`What each group row shows in the columns the results don't drill down by.`}
71
+ </p>
72
+ <div
73
+ className="grid max-h-[50vh] grid-cols-[1fr_auto] items-center gap-x-3 gap-y-1 overflow-auto"
74
+ data-testid={LEGEND_CUBE_TEST_ID.DRILLDOWN_SETTINGS}
75
+ >
76
+ {result.schema.columns
77
+ .filter(({ name }) => !levels.has(foldColumnName(name)))
78
+ .map(({ name, type }) => {
79
+ const fallback = getDefaultDrilldownAggregation(type);
80
+ const current = drilldown.aggregationOf(name);
81
+ return [
82
+ <label
83
+ key={`${name}:label`}
84
+ htmlFor={`cube-drilldown-${name}`}
85
+ className="truncate text-base"
86
+ title={`${name} (${type.displayName})`}
87
+ >
88
+ {name}
89
+ </label>,
90
+ <select
91
+ key={`${name}:select`}
92
+ id={`cube-drilldown-${name}`}
93
+ aria-label={`Group rows' ${name}`}
94
+ className="h-6 rounded-sm border border-[var(--color-border-default)] bg-[var(--color-bg-input)] px-1 text-base text-[var(--color-text-primary)]"
95
+ value={current ?? NO_AGGREGATION}
96
+ disabled={editorState.readOnly}
97
+ title={
98
+ editorState.readOnly ? READ_ONLY_CUBE_TITLE : undefined
99
+ }
100
+ onChange={(event) =>
101
+ grid.setAggregation(
102
+ name,
103
+ event.target.value === NO_AGGREGATION
104
+ ? null
105
+ : (event.target.value as AggregationFunction),
106
+ )
107
+ }
108
+ >
109
+ <option value={NO_AGGREGATION}>
110
+ {label(null, fallback === null)}
111
+ </option>
112
+ {getDrilldownAggregations(type).map((fn) => (
113
+ <option key={fn} value={fn}>
114
+ {label(fn, fallback === fn)}
115
+ </option>
116
+ ))}
117
+ </select>,
118
+ ];
119
+ })}
120
+ </div>
121
+ </ModalBody>
122
+ <ModalFooter>
123
+ <ModalFooterButton
124
+ darkMode={darkMode}
125
+ formatText={false}
126
+ type="secondary"
127
+ text="Close"
128
+ onClick={() => grid.closeSettings()}
129
+ />
130
+ </ModalFooter>
131
+ </Modal>
132
+ </Dialog>
133
+ );
134
+ },
135
+ );
136
+
137
+ /**
138
+ * The drill-down above the grid in server-side mode (PLAN §11.10): its
139
+ * levels, outermost first, each removable; what it can't use, and why; the
140
+ * group rows' settings; and Clear. Shown while the cube has a drill-down.
141
+ */
142
+ export const CubeDrilldownBar = observer(
143
+ (props: { editorState: CubeEditorState }) => {
144
+ const { editorState } = props;
145
+ const { grid } = editorState;
146
+ const saved = editorState.document.meta.drilldown;
147
+ const drilldown = grid.drilldown;
148
+ if (
149
+ !saved ||
150
+ !drilldown ||
151
+ (!saved.columns.length && !drilldown.problems.length)
152
+ ) {
153
+ return null;
154
+ }
155
+ const { readOnly } = editorState;
156
+ return (
157
+ <div
158
+ className="flex min-h-8 shrink-0 flex-wrap items-center gap-2 border-b border-[var(--color-border-default)] px-2 py-1 text-base"
159
+ data-testid={LEGEND_CUBE_TEST_ID.DRILLDOWN_BAR}
160
+ >
161
+ <span className="text-[var(--color-text-secondary)]">
162
+ Drill down by
163
+ </span>
164
+ {drilldown.columns.map((column, index) => (
165
+ <span key={column} className="flex items-center gap-1">
166
+ {index > 0 && (
167
+ <span className="text-[var(--color-text-muted)]">›</span>
168
+ )}
169
+ <span className="flex items-center gap-1 rounded-sm border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] px-1">
170
+ {column}
171
+ <button
172
+ type="button"
173
+ className="text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] disabled:opacity-50"
174
+ aria-label={`Stop drilling down by ${column}`}
175
+ title={
176
+ readOnly
177
+ ? READ_ONLY_CUBE_TITLE
178
+ : `Stop drilling down by ${column}`
179
+ }
180
+ disabled={readOnly}
181
+ onClick={() =>
182
+ grid.removeLevel(
183
+ saved.columns.findIndex(
184
+ (level) =>
185
+ foldColumnName(level) === foldColumnName(column),
186
+ ),
187
+ )
188
+ }
189
+ >
190
+ <TimesIcon />
191
+ </button>
192
+ </span>
193
+ </span>
194
+ ))}
195
+ {drilldown.problems.length > 0 && (
196
+ <span
197
+ className="text-[var(--color-status-warn)]"
198
+ role="status"
199
+ title={drilldown.problems.join('\n')}
200
+ >
201
+ {drilldown.problems.length === 1
202
+ ? drilldown.problems[0]
203
+ : `${drilldown.problems.length} drill-down settings can't be used here.`}
204
+ </span>
205
+ )}
206
+ <span className="flex-1" />
207
+ <CubeButton onClick={() => grid.openSettings()}>Group rows…</CubeButton>
208
+ <CubeButton
209
+ disabled={readOnly}
210
+ title={readOnly ? READ_ONLY_CUBE_TITLE : 'Stop drilling down'}
211
+ onClick={() => grid.clearDrilldown()}
212
+ >
213
+ Clear
214
+ </CubeButton>
215
+ <CubeDrilldownSettingsDialog editorState={editorState} />
216
+ </div>
217
+ );
218
+ },
219
+ );
@@ -22,6 +22,7 @@ import { getCubeWarehouseErrorHint } from '../../__lib__/LegendCubeDataProductLa
22
22
  import {
23
23
  CUBE_PENDING_LABEL,
24
24
  formatDisabledReasons,
25
+ getLevelTruncationMessage,
25
26
  getRowLimitError,
26
27
  getTruncationMessage,
27
28
  ROW_LIMIT_WARNING_THRESHOLD,
@@ -31,9 +32,18 @@ import {
31
32
  CubeDataProductRunErrorKind,
32
33
  type CubeDataProductRuntimeState,
33
34
  } from '../../stores/CubeDataProductRuntimeState.js';
35
+ import type { CubeEngineError } from '../../graph-manager/CubeEngine.js';
34
36
  import type { CubeEditorState } from '../../stores/CubeEditorState.js';
37
+ import type { CubeExecutionResult } from '../../stores/CubeExecutionState.js';
35
38
  import { CubeButton } from '../CubeButton.js';
39
+ import { CubeGridMode } from '../../stores/CubeGridState.js';
40
+ import { parseWholeNumberText } from '../../stores/editors/CubeIntegerText.js';
36
41
  import { CubeResultGrid } from './CubeResultGrid.js';
42
+ import { CubeColumnFormatDialog } from './CubeColumnFormatDialog.js';
43
+ import { CubeDrilldownBar } from './CubeDrilldownBar.js';
44
+ import { CubeSqlDialog } from './CubeSqlDialog.js';
45
+ import { CubeRunStatsPanel } from './CubeRunStatsPanel.js';
46
+ import { CubeServerSideGrid } from './CubeServerSideGrid.js';
37
47
  import { formatDuration } from './CubeGridValues.js';
38
48
 
39
49
  /** The first line of an error is shown, at most this long; the rest is under Details */
@@ -45,10 +55,11 @@ const CubeRowLimitInput = observer(
45
55
  const [draft, setDraft] = useState(String(editorState.rowLimit));
46
56
  const [error, setError] = useState<string | undefined>();
47
57
  const commit = (): void => {
48
- const problem = getRowLimitError(draft);
58
+ const value = parseWholeNumberText(draft);
59
+ const problem = getRowLimitError(value);
49
60
  setError(problem);
50
- if (!problem) {
51
- editorState.setRowLimit(Number(draft.trim()));
61
+ if (!problem && value !== undefined) {
62
+ editorState.setRowLimit(value);
52
63
  }
53
64
  };
54
65
  return (
@@ -88,13 +99,54 @@ const CubeRowLimitInput = observer(
88
99
  },
89
100
  );
90
101
 
102
+ /** Server-side or local: how the grid shows the run (spec §12.1, PLAN §11.10) */
103
+ const CubeGridModeToggle = observer(
104
+ (props: { editorState: CubeEditorState }) => {
105
+ const { grid } = props.editorState;
106
+ const option = (mode: CubeGridMode, label: string, title: string) => (
107
+ <button
108
+ type="button"
109
+ className={`h-6 px-2 text-base ${
110
+ grid.mode === mode
111
+ ? 'bg-[var(--color-bg-selected)] font-medium text-[var(--color-text-primary)]'
112
+ : 'text-[var(--color-text-secondary)] hover:bg-[var(--color-bg-hover)]'
113
+ }`}
114
+ aria-pressed={grid.mode === mode}
115
+ title={title}
116
+ onClick={() => grid.setMode(mode)}
117
+ >
118
+ {label}
119
+ </button>
120
+ );
121
+ return (
122
+ <div
123
+ className="flex overflow-hidden rounded-sm border border-[var(--color-border-default)]"
124
+ role="group"
125
+ aria-label="Grid mode"
126
+ >
127
+ {option(
128
+ CubeGridMode.SERVER_SIDE,
129
+ 'Server-side',
130
+ 'Each sort and drill-down level runs on the engine, over every row of the query',
131
+ )}
132
+ {option(
133
+ CubeGridMode.LOCAL,
134
+ 'Local',
135
+ "The run's rows, grouped, pivoted and filtered in the browser",
136
+ )}
137
+ </div>
138
+ );
139
+ },
140
+ );
141
+
91
142
  const CubeGridToolbar = observer(
92
143
  (props: {
93
144
  editorState: CubeEditorState;
94
- showSql: boolean;
95
- onToggleSql: () => void;
145
+ onShowSql: () => void;
146
+ showRuns: boolean;
147
+ onToggleRuns: () => void;
96
148
  }) => {
97
- const { editorState, showSql, onToggleSql } = props;
149
+ const { editorState, onShowSql, showRuns, onToggleRuns } = props;
98
150
  const { execution } = editorState;
99
151
  const { result } = execution;
100
152
  const disabledReasons = execution.disabledReasons;
@@ -123,6 +175,7 @@ const CubeGridToolbar = observer(
123
175
  </CubeButton>
124
176
  )}
125
177
  <CubeRowLimitInput editorState={editorState} />
178
+ <CubeGridModeToggle editorState={editorState} />
126
179
  {execution.isRunning && (
127
180
  <span className="text-base text-[var(--color-text-secondary)]">
128
181
  {CUBE_PENDING_LABEL.EXECUTING_QUERY}
@@ -146,53 +199,50 @@ const CubeGridToolbar = observer(
146
199
  {getTruncationMessage(result.rowLimit)}
147
200
  </span>
148
201
  )}
202
+ {editorState.grid.isServerSide &&
203
+ editorState.grid.hasLimitedLevel && (
204
+ <span className="text-base text-[var(--color-status-warn)]">
205
+ {getLevelTruncationMessage(result.rowLimit)}
206
+ </span>
207
+ )}
208
+ {editorState.export.isExporting && (
209
+ <>
210
+ <span className="text-base text-[var(--color-text-secondary)]">
211
+ {CUBE_PENDING_LABEL.EXPORTING_CSV}
212
+ </span>
213
+ <CubeButton
214
+ title="Stop the export"
215
+ onClick={() => editorState.export.stop()}
216
+ >
217
+ Stop export
218
+ </CubeButton>
219
+ </>
220
+ )}
221
+ {editorState.grid.isServerSide && editorState.grid.fetching > 0 && (
222
+ <span className="text-base text-[var(--color-text-secondary)]">
223
+ {CUBE_PENDING_LABEL.FETCHING_ROWS}
224
+ </span>
225
+ )}
149
226
  {result.sql.length > 0 && (
150
- <CubeButton aria-expanded={showSql} onClick={onToggleSql}>
151
- {showSql ? 'Hide SQL' : 'Show SQL'}
227
+ <CubeButton aria-haspopup="dialog" onClick={onShowSql}>
228
+ Show SQL
152
229
  </CubeButton>
153
230
  )}
154
231
  </>
155
232
  )}
233
+ <span className="flex-1" />
234
+ <CubeButton
235
+ aria-expanded={showRuns}
236
+ title="The latest runs, fetches and exports, with their SQL"
237
+ onClick={onToggleRuns}
238
+ >
239
+ {`Runs (${editorState.runStats.entries.length})`}
240
+ </CubeButton>
156
241
  </div>
157
242
  );
158
243
  },
159
244
  );
160
245
 
161
- /** The SQL the run's database ran, with Copy */
162
- const CubeSqlPanel = observer((props: { editorState: CubeEditorState }) => {
163
- const { editorState } = props;
164
- const { applicationStore } = editorState.host;
165
- const sql = editorState.execution.result?.sql ?? [];
166
- if (!sql.length) {
167
- return null;
168
- }
169
- const copySql = (): void => {
170
- applicationStore.clipboardService
171
- .copyTextToClipboard(sql.join('\n\n'))
172
- .catch(applicationStore.alertUnhandledError);
173
- };
174
- return (
175
- <div
176
- className="flex max-h-40 shrink-0 gap-2 overflow-auto border-b border-[var(--color-border-default)] p-2"
177
- data-testid={LEGEND_CUBE_TEST_ID.SQL_PANEL}
178
- >
179
- <div className="min-w-0 flex-1">
180
- {sql.map((statement, index) => (
181
- <pre
182
- // statements hold no state, and the same one may run twice
183
- // eslint-disable-next-line react/no-array-index-key
184
- key={index}
185
- className="whitespace-pre-wrap font-mono text-sm"
186
- >
187
- {statement}
188
- </pre>
189
- ))}
190
- </div>
191
- <CubeButton onClick={copySql}>Copy SQL</CubeButton>
192
- </div>
193
- );
194
- });
195
-
196
246
  /**
197
247
  * On a data product cube, what to do about a run refused for its warehouse,
198
248
  * or for lack of access to the data: links to ask for it in the marketplace
@@ -230,11 +280,8 @@ const CubeDataProductRunErrorHelp = observer(
230
280
  );
231
281
 
232
282
  const CubeExecutionError = observer(
233
- (props: { editorState: CubeEditorState }) => {
234
- const error = props.editorState.execution.error;
235
- if (!error) {
236
- return null;
237
- }
283
+ (props: { editorState: CubeEditorState; error: CubeEngineError }) => {
284
+ const { error } = props;
238
285
  const isCut = error.firstLine.length > MAX_ERROR_LINE_LENGTH;
239
286
  const firstLine = isCut
240
287
  ? `${error.firstLine.slice(0, MAX_ERROR_LINE_LENGTH)}…`
@@ -269,12 +316,73 @@ const CubeExecutionError = observer(
269
316
  },
270
317
  );
271
318
 
319
+ /**
320
+ * The run's rows as the grid's mode shows them: in server-side mode built
321
+ * anew for each run and each drill-down, with a fetch's error above it
322
+ */
323
+ const CubeRunGrid = observer(
324
+ (props: {
325
+ editorState: CubeEditorState;
326
+ result: CubeExecutionResult;
327
+ darkMode: boolean;
328
+ }) => {
329
+ const { editorState, result, darkMode } = props;
330
+ const { grid } = editorState;
331
+ const exportError = editorState.export.error && (
332
+ <CubeExecutionError
333
+ editorState={editorState}
334
+ error={editorState.export.error}
335
+ />
336
+ );
337
+ if (!grid.isServerSide) {
338
+ return (
339
+ <div className="flex h-full flex-col">
340
+ {exportError}
341
+ <div className="min-h-0 flex-1">
342
+ <CubeResultGrid
343
+ key={result.id}
344
+ editorState={editorState}
345
+ result={result}
346
+ presentation={editorState.document.meta.presentation}
347
+ darkMode={darkMode}
348
+ />
349
+ </div>
350
+ </div>
351
+ );
352
+ }
353
+ const drilldown = editorState.document.meta.drilldown;
354
+ return (
355
+ <div className="flex h-full flex-col">
356
+ <CubeDrilldownBar editorState={editorState} />
357
+ {exportError}
358
+ {grid.fetchError && (
359
+ <CubeExecutionError
360
+ editorState={editorState}
361
+ error={grid.fetchError}
362
+ />
363
+ )}
364
+ <div className="min-h-0 flex-1">
365
+ <CubeServerSideGrid
366
+ key={`${result.id}:${JSON.stringify(drilldown ?? null)}`}
367
+ editorState={editorState}
368
+ result={result}
369
+ levels={grid.drilldown?.columns ?? []}
370
+ presentation={editorState.document.meta.presentation}
371
+ darkMode={darkMode}
372
+ />
373
+ </div>
374
+ </div>
375
+ );
376
+ },
377
+ );
378
+
272
379
  /** The results: Execute, the row limit and the run's stats above the grid (PLAN §9) */
273
380
  export const CubeGridRegion = observer(
274
381
  (props: { editorState: CubeEditorState }) => {
275
382
  const { editorState } = props;
276
383
  const { execution, host } = editorState;
277
384
  const [showSql, setShowSql] = useState(false);
385
+ const [showRuns, setShowRuns] = useState(false);
278
386
  const darkMode =
279
387
  !host.applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled;
280
388
  return (
@@ -285,18 +393,26 @@ export const CubeGridRegion = observer(
285
393
  <PanelLoadingIndicator isLoading={execution.isRunning} />
286
394
  <CubeGridToolbar
287
395
  editorState={editorState}
288
- showSql={showSql}
289
- onToggleSql={() => setShowSql(!showSql)}
396
+ onShowSql={() => setShowSql(true)}
397
+ showRuns={showRuns}
398
+ onToggleRuns={() => setShowRuns(!showRuns)}
290
399
  />
400
+ {showRuns && <CubeRunStatsPanel editorState={editorState} />}
401
+ <CubeColumnFormatDialog editorState={editorState} />
291
402
  {showSql && !execution.isRunning && (
292
- <CubeSqlPanel editorState={editorState} />
403
+ <CubeSqlDialog
404
+ editorState={editorState}
405
+ onClose={() => setShowSql(false)}
406
+ />
293
407
  )}
294
408
  <div className="min-h-0 flex-1">
295
409
  {execution.error ? (
296
- <CubeExecutionError editorState={editorState} />
410
+ <CubeExecutionError
411
+ editorState={editorState}
412
+ error={execution.error}
413
+ />
297
414
  ) : execution.result ? (
298
- <CubeResultGrid
299
- key={execution.result.id}
415
+ <CubeRunGrid
300
416
  editorState={editorState}
301
417
  result={execution.result}
302
418
  darkMode={darkMode}
@@ -14,7 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { TypeFamily } from '@finos/legend-cube';
17
+ import {
18
+ type ColumnFormat,
19
+ ColumnFormatStyle,
20
+ type CubeType,
21
+ isColumnFormatStyle,
22
+ PrimitiveType,
23
+ TypeFamily,
24
+ } from '@finos/legend-cube';
18
25
  import type { CubeResultValue } from '../../graph-manager/CubeEngine.js';
19
26
 
20
27
  // How the grid shows and sorts values (PLAN §9, Settled before M1.8).
@@ -178,3 +185,141 @@ export const formatCellValue = (
178
185
  return text;
179
186
  }
180
187
  };
188
+
189
+ /**
190
+ * The digits after the point a decimal column keeps, e.g. 4 for
191
+ * `Numeric(14,4)`; none for another type, whose group rows round to
192
+ * `CUBE_GRID_FLOAT_DECIMAL_PLACES` (an Average of integers keeps 2 places)
193
+ */
194
+ export const getTypeScale = (type: CubeType): number | undefined =>
195
+ type instanceof PrimitiveType &&
196
+ type.family === TypeFamily.DECIMAL &&
197
+ type.params.length >= 2
198
+ ? type.params[1]
199
+ : undefined;
200
+
201
+ /**
202
+ * How a group row shows a number it aggregates (the review of the demo,
203
+ * 2026-10-13): its thousands grouped, an integer's too, since a sum or a
204
+ * count is a quantity, not an id; a fraction rounded to the column's scale,
205
+ * or to `CUBE_GRID_FLOAT_DECIMAL_PLACES` places for a column without one,
206
+ * so an Average doesn't show every digit. A value that isn't a number, or a
207
+ * column that isn't numeric, shows as it is. Copying keeps the exact value.
208
+ */
209
+ export const formatGroupRowValue = (
210
+ value: Exclude<CubeResultValue, null>,
211
+ family: TypeFamily,
212
+ scale?: number | undefined,
213
+ ): string => {
214
+ const text = String(value);
215
+ if (!isNumericFamily(family) || typeof value === 'boolean') {
216
+ return text;
217
+ }
218
+ const parts = PLAIN_NUMBER_TEXT.exec(text.trim())?.groups;
219
+ if (!parts) {
220
+ return text;
221
+ }
222
+ const places = scale ?? CUBE_GRID_FLOAT_DECIMAL_PLACES;
223
+ // the fraction's digits, the point left out
224
+ const fraction = (parts.fraction ?? '').slice(1);
225
+ if (fraction.length <= places) {
226
+ return groupThousands(text.trim());
227
+ }
228
+ const rounded = Number(text).toFixed(places);
229
+ // a value that rounds to zero shows no sign
230
+ return groupThousands(
231
+ Number(rounded) === 0 ? rounded.replace(/^-/u, '') : rounded,
232
+ );
233
+ };
234
+
235
+ /** The ISO 4217 codes the browser formats (PLAN §11.10: codes, not symbols, §21) */
236
+ export const getCubeCurrencyCodes = (): readonly string[] => {
237
+ const supportedValuesOf = (
238
+ Intl as unknown as {
239
+ supportedValuesOf?: (key: string) => string[];
240
+ }
241
+ ).supportedValuesOf;
242
+ return supportedValuesOf?.('currency') ?? ['EUR', 'GBP', 'JPY', 'USD'];
243
+ };
244
+
245
+ /** Why a format can't be used, if it can't: a style or a currency this browser doesn't know */
246
+ export const getColumnFormatProblem = (
247
+ format: ColumnFormat,
248
+ ): string | undefined => {
249
+ if (!isColumnFormatStyle(format.style)) {
250
+ return `The format "${format.style}" is unknown, so the column shows its values as they are.`;
251
+ }
252
+ if (
253
+ format.style === ColumnFormatStyle.CURRENCY &&
254
+ !getCubeCurrencyCodes().includes(format.currency ?? '')
255
+ ) {
256
+ return `The currency "${format.currency ?? ''}" is unknown, so the column shows its values as they are.`;
257
+ }
258
+ return undefined;
259
+ };
260
+
261
+ /**
262
+ * A number formatted as the column's format says (spec §13.1, PLAN §11.10),
263
+ * from its exact text, so no digit is lost (`Intl.NumberFormat` reads a
264
+ * decimal string exactly); `undefined` for a value that isn't a number or a
265
+ * format that can't be used (`getColumnFormatProblem`), which shows as if
266
+ * none were set
267
+ */
268
+ export const formatColumnValue = (
269
+ value: Exclude<CubeResultValue, null>,
270
+ format: ColumnFormat,
271
+ ): { readonly text: string; readonly negative: boolean } | undefined => {
272
+ const text = String(value).trim();
273
+ const parsed = typeof value === 'boolean' ? undefined : parseNumberText(text);
274
+ if (!parsed || getColumnFormatProblem(format) !== undefined) {
275
+ return undefined;
276
+ }
277
+ // with no places set, the value's own: '20.20' keeps its zero (a
278
+ // currency at least its usual cents), as the grid shows it unformatted
279
+ const ownPlaces = Math.min(
280
+ 20,
281
+ /e/iu.test(text)
282
+ ? Math.max(0, parsed.digits.length - parsed.point)
283
+ : (text.split('.')[1]?.length ?? 0),
284
+ );
285
+ const places = format.decimalPlaces;
286
+ const formatter = new Intl.NumberFormat('en-US', {
287
+ style:
288
+ format.style === ColumnFormatStyle.CURRENCY
289
+ ? 'currency'
290
+ : format.style === ColumnFormatStyle.PERCENT
291
+ ? 'percent'
292
+ : 'decimal',
293
+ ...(format.style === ColumnFormatStyle.CURRENCY
294
+ ? { currency: format.currency }
295
+ : {}),
296
+ useGrouping: format.grouping,
297
+ // a negative that rounds to zero shows as zero, with no sign
298
+ signDisplay: 'negative',
299
+ ...(places !== undefined
300
+ ? { minimumFractionDigits: places, maximumFractionDigits: places }
301
+ : format.style === ColumnFormatStyle.PERCENT
302
+ ? { minimumFractionDigits: 0, maximumFractionDigits: 20 }
303
+ : {
304
+ minimumFractionDigits: Math.max(
305
+ ownPlaces,
306
+ format.style === ColumnFormatStyle.CURRENCY
307
+ ? (new Intl.NumberFormat('en-US', {
308
+ style: 'currency',
309
+ currency: format.currency,
310
+ }).resolvedOptions().minimumFractionDigits ?? 0)
311
+ : 0,
312
+ ),
313
+ maximumFractionDigits: 20,
314
+ }),
315
+ });
316
+ // a decimal string keeps every digit, where a JS number would round
317
+ const shown = (number: string): string =>
318
+ formatter.format(number as unknown as number);
319
+ const signed = shown(text);
320
+ // negative as shown: one that rounds to zero isn't
321
+ const negative = parsed.negative && signed.includes('-');
322
+ return format.parenthesesIfNegative && negative
323
+ ? { text: `(${shown(text.replace(/^-/u, ''))})`, negative }
324
+ : { text: signed, negative };
325
+ };