@finos/legend-cube-builder 0.0.0-stage → 0.0.3

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 (379) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +64 -2
  3. package/docs/adding-an-operation.md +92 -0
  4. package/docs/hosting.md +79 -0
  5. package/docs/testing.md +83 -0
  6. package/lib/__lib__/LegendCubeCommand.d.ts +26 -0
  7. package/lib/__lib__/LegendCubeCommand.d.ts.map +1 -0
  8. package/lib/__lib__/LegendCubeCommand.js +40 -0
  9. package/lib/__lib__/LegendCubeCommand.js.map +1 -0
  10. package/lib/__lib__/LegendCubeHelpText.d.ts +19 -0
  11. package/lib/__lib__/LegendCubeHelpText.d.ts.map +1 -0
  12. package/lib/__lib__/LegendCubeHelpText.js +35 -0
  13. package/lib/__lib__/LegendCubeHelpText.js.map +1 -0
  14. package/lib/__lib__/LegendCubeLabels.d.ts +87 -0
  15. package/lib/__lib__/LegendCubeLabels.d.ts.map +1 -0
  16. package/lib/__lib__/LegendCubeLabels.js +128 -0
  17. package/lib/__lib__/LegendCubeLabels.js.map +1 -0
  18. package/lib/__lib__/LegendCubeTesting.d.ts +33 -0
  19. package/lib/__lib__/LegendCubeTesting.d.ts.map +1 -0
  20. package/lib/__lib__/LegendCubeTesting.js +34 -0
  21. package/lib/__lib__/LegendCubeTesting.js.map +1 -0
  22. package/lib/__test-utils__/CubeCanvasTestUtils.d.ts +24 -0
  23. package/lib/__test-utils__/CubeCanvasTestUtils.d.ts.map +1 -0
  24. package/lib/__test-utils__/CubeCanvasTestUtils.js +37 -0
  25. package/lib/__test-utils__/CubeCanvasTestUtils.js.map +1 -0
  26. package/lib/__test-utils__/CubeEngineTestSupport.d.ts +47 -0
  27. package/lib/__test-utils__/CubeEngineTestSupport.d.ts.map +1 -0
  28. package/lib/__test-utils__/CubeEngineTestSupport.js +106 -0
  29. package/lib/__test-utils__/CubeEngineTestSupport.js.map +1 -0
  30. package/lib/__test-utils__/CubeNorthwindTestQueries.d.ts +31 -0
  31. package/lib/__test-utils__/CubeNorthwindTestQueries.d.ts.map +1 -0
  32. package/lib/__test-utils__/CubeNorthwindTestQueries.js +102 -0
  33. package/lib/__test-utils__/CubeNorthwindTestQueries.js.map +1 -0
  34. package/lib/__test-utils__/CubeOperationsTestUtils.d.ts +42 -0
  35. package/lib/__test-utils__/CubeOperationsTestUtils.d.ts.map +1 -0
  36. package/lib/__test-utils__/CubeOperationsTestUtils.js +92 -0
  37. package/lib/__test-utils__/CubeOperationsTestUtils.js.map +1 -0
  38. package/lib/__test-utils__/CubePageTestUtils.d.ts +33 -0
  39. package/lib/__test-utils__/CubePageTestUtils.d.ts.map +1 -0
  40. package/lib/__test-utils__/CubePageTestUtils.js +68 -0
  41. package/lib/__test-utils__/CubePageTestUtils.js.map +1 -0
  42. package/lib/__test-utils__/CubeTestApplication.d.ts +30 -0
  43. package/lib/__test-utils__/CubeTestApplication.d.ts.map +1 -0
  44. package/lib/__test-utils__/CubeTestApplication.js +57 -0
  45. package/lib/__test-utils__/CubeTestApplication.js.map +1 -0
  46. package/lib/__test-utils__/FakeCubeEngine.d.ts +41 -0
  47. package/lib/__test-utils__/FakeCubeEngine.d.ts.map +1 -0
  48. package/lib/__test-utils__/FakeCubeEngine.js +91 -0
  49. package/lib/__test-utils__/FakeCubeEngine.js.map +1 -0
  50. package/lib/components/CubeButton.d.ts +20 -0
  51. package/lib/components/CubeButton.d.ts.map +1 -0
  52. package/lib/components/CubeButton.js +24 -0
  53. package/lib/components/CubeButton.js.map +1 -0
  54. package/lib/components/CubeEditor.d.ts +31 -0
  55. package/lib/components/CubeEditor.d.ts.map +1 -0
  56. package/lib/components/CubeEditor.js +90 -0
  57. package/lib/components/CubeEditor.js.map +1 -0
  58. package/lib/components/CubeNodeIcon.d.ts +23 -0
  59. package/lib/components/CubeNodeIcon.d.ts.map +1 -0
  60. package/lib/components/CubeNodeIcon.js +42 -0
  61. package/lib/components/CubeNodeIcon.js.map +1 -0
  62. package/lib/components/canvas/CubeCanvas.d.ts +37 -0
  63. package/lib/components/canvas/CubeCanvas.d.ts.map +1 -0
  64. package/lib/components/canvas/CubeCanvas.js +137 -0
  65. package/lib/components/canvas/CubeCanvas.js.map +1 -0
  66. package/lib/components/canvas/CubeCanvasContext.d.ts +19 -0
  67. package/lib/components/canvas/CubeCanvasContext.d.ts.map +1 -0
  68. package/lib/components/canvas/CubeCanvasContext.js +22 -0
  69. package/lib/components/canvas/CubeCanvasContext.js.map +1 -0
  70. package/lib/components/canvas/CubeCanvasContextMenu.d.ts +28 -0
  71. package/lib/components/canvas/CubeCanvasContextMenu.d.ts.map +1 -0
  72. package/lib/components/canvas/CubeCanvasContextMenu.js +35 -0
  73. package/lib/components/canvas/CubeCanvasContextMenu.js.map +1 -0
  74. package/lib/components/canvas/CubeCanvasDnd.d.ts +43 -0
  75. package/lib/components/canvas/CubeCanvasDnd.d.ts.map +1 -0
  76. package/lib/components/canvas/CubeCanvasDnd.js +51 -0
  77. package/lib/components/canvas/CubeCanvasDnd.js.map +1 -0
  78. package/lib/components/canvas/CubeCanvasEdge.d.ts +24 -0
  79. package/lib/components/canvas/CubeCanvasEdge.d.ts.map +1 -0
  80. package/lib/components/canvas/CubeCanvasEdge.js +33 -0
  81. package/lib/components/canvas/CubeCanvasEdge.js.map +1 -0
  82. package/lib/components/canvas/CubeCanvasElements.d.ts +66 -0
  83. package/lib/components/canvas/CubeCanvasElements.d.ts.map +1 -0
  84. package/lib/components/canvas/CubeCanvasElements.js +97 -0
  85. package/lib/components/canvas/CubeCanvasElements.js.map +1 -0
  86. package/lib/components/canvas/CubeCanvasLayout.d.ts +32 -0
  87. package/lib/components/canvas/CubeCanvasLayout.d.ts.map +1 -0
  88. package/lib/components/canvas/CubeCanvasLayout.js +63 -0
  89. package/lib/components/canvas/CubeCanvasLayout.js.map +1 -0
  90. package/lib/components/canvas/CubeCanvasNode.d.ts +29 -0
  91. package/lib/components/canvas/CubeCanvasNode.d.ts.map +1 -0
  92. package/lib/components/canvas/CubeCanvasNode.js +75 -0
  93. package/lib/components/canvas/CubeCanvasNode.js.map +1 -0
  94. package/lib/components/editors/CubeColumnPicker.d.ts +47 -0
  95. package/lib/components/editors/CubeColumnPicker.d.ts.map +1 -0
  96. package/lib/components/editors/CubeColumnPicker.js +56 -0
  97. package/lib/components/editors/CubeColumnPicker.js.map +1 -0
  98. package/lib/components/editors/CubeDistinctEditor.d.ts +23 -0
  99. package/lib/components/editors/CubeDistinctEditor.d.ts.map +1 -0
  100. package/lib/components/editors/CubeDistinctEditor.js +24 -0
  101. package/lib/components/editors/CubeDistinctEditor.js.map +1 -0
  102. package/lib/components/editors/CubeFilterEditor.d.ts +26 -0
  103. package/lib/components/editors/CubeFilterEditor.d.ts.map +1 -0
  104. package/lib/components/editors/CubeFilterEditor.js +90 -0
  105. package/lib/components/editors/CubeFilterEditor.js.map +1 -0
  106. package/lib/components/editors/CubeIntegerField.d.ts +29 -0
  107. package/lib/components/editors/CubeIntegerField.d.ts.map +1 -0
  108. package/lib/components/editors/CubeIntegerField.js +30 -0
  109. package/lib/components/editors/CubeIntegerField.js.map +1 -0
  110. package/lib/components/editors/CubeJoinEditor.d.ts +26 -0
  111. package/lib/components/editors/CubeJoinEditor.d.ts.map +1 -0
  112. package/lib/components/editors/CubeJoinEditor.js +84 -0
  113. package/lib/components/editors/CubeJoinEditor.js.map +1 -0
  114. package/lib/components/editors/CubeNodeEditorPanel.d.ts +29 -0
  115. package/lib/components/editors/CubeNodeEditorPanel.d.ts.map +1 -0
  116. package/lib/components/editors/CubeNodeEditorPanel.js +72 -0
  117. package/lib/components/editors/CubeNodeEditorPanel.js.map +1 -0
  118. package/lib/components/editors/CubeNodeEditorRegistry.d.ts +44 -0
  119. package/lib/components/editors/CubeNodeEditorRegistry.d.ts.map +1 -0
  120. package/lib/components/editors/CubeNodeEditorRegistry.js +43 -0
  121. package/lib/components/editors/CubeNodeEditorRegistry.js.map +1 -0
  122. package/lib/components/editors/CubeRenameEditor.d.ts +26 -0
  123. package/lib/components/editors/CubeRenameEditor.d.ts.map +1 -0
  124. package/lib/components/editors/CubeRenameEditor.js +58 -0
  125. package/lib/components/editors/CubeRenameEditor.js.map +1 -0
  126. package/lib/components/editors/CubeRestrictEditor.d.ts +26 -0
  127. package/lib/components/editors/CubeRestrictEditor.d.ts.map +1 -0
  128. package/lib/components/editors/CubeRestrictEditor.js +23 -0
  129. package/lib/components/editors/CubeRestrictEditor.js.map +1 -0
  130. package/lib/components/editors/CubeRowCountEditor.d.ts +25 -0
  131. package/lib/components/editors/CubeRowCountEditor.d.ts.map +1 -0
  132. package/lib/components/editors/CubeRowCountEditor.js +38 -0
  133. package/lib/components/editors/CubeRowCountEditor.js.map +1 -0
  134. package/lib/components/editors/CubeSliceEditor.d.ts +25 -0
  135. package/lib/components/editors/CubeSliceEditor.d.ts.map +1 -0
  136. package/lib/components/editors/CubeSliceEditor.js +40 -0
  137. package/lib/components/editors/CubeSliceEditor.js.map +1 -0
  138. package/lib/components/editors/CubeSortEditor.d.ts +27 -0
  139. package/lib/components/editors/CubeSortEditor.d.ts.map +1 -0
  140. package/lib/components/editors/CubeSortEditor.js +72 -0
  141. package/lib/components/editors/CubeSortEditor.js.map +1 -0
  142. package/lib/components/editors/CubeSourceEditor.d.ts +25 -0
  143. package/lib/components/editors/CubeSourceEditor.d.ts.map +1 -0
  144. package/lib/components/editors/CubeSourceEditor.js +41 -0
  145. package/lib/components/editors/CubeSourceEditor.js.map +1 -0
  146. package/lib/components/editors/CubeValueEditor.d.ts +40 -0
  147. package/lib/components/editors/CubeValueEditor.d.ts.map +1 -0
  148. package/lib/components/editors/CubeValueEditor.js +178 -0
  149. package/lib/components/editors/CubeValueEditor.js.map +1 -0
  150. package/lib/components/grid/CubeGridRegion.d.ts +23 -0
  151. package/lib/components/grid/CubeGridRegion.d.ts.map +1 -0
  152. package/lib/components/grid/CubeGridRegion.js +94 -0
  153. package/lib/components/grid/CubeGridRegion.js.map +1 -0
  154. package/lib/components/grid/CubeGridValues.d.ts +25 -0
  155. package/lib/components/grid/CubeGridValues.d.ts.map +1 -0
  156. package/lib/components/grid/CubeGridValues.js +95 -0
  157. package/lib/components/grid/CubeGridValues.js.map +1 -0
  158. package/lib/components/grid/CubeResultGrid.d.ts +39 -0
  159. package/lib/components/grid/CubeResultGrid.d.ts.map +1 -0
  160. package/lib/components/grid/CubeResultGrid.js +86 -0
  161. package/lib/components/grid/CubeResultGrid.js.map +1 -0
  162. package/lib/components/palette/CubePalette.d.ts +29 -0
  163. package/lib/components/palette/CubePalette.d.ts.map +1 -0
  164. package/lib/components/palette/CubePalette.js +73 -0
  165. package/lib/components/palette/CubePalette.js.map +1 -0
  166. package/lib/components/show-pure/CubeShowPureDialog.d.ts +23 -0
  167. package/lib/components/show-pure/CubeShowPureDialog.d.ts.map +1 -0
  168. package/lib/components/show-pure/CubeShowPureDialog.js +37 -0
  169. package/lib/components/show-pure/CubeShowPureDialog.js.map +1 -0
  170. package/lib/components/source-picker/CubeSourcePicker.d.ts +22 -0
  171. package/lib/components/source-picker/CubeSourcePicker.d.ts.map +1 -0
  172. package/lib/components/source-picker/CubeSourcePicker.js +89 -0
  173. package/lib/components/source-picker/CubeSourcePicker.js.map +1 -0
  174. package/lib/components/spec-transfer/CubeSpecTransferDialog.d.ts +26 -0
  175. package/lib/components/spec-transfer/CubeSpecTransferDialog.d.ts.map +1 -0
  176. package/lib/components/spec-transfer/CubeSpecTransferDialog.js +45 -0
  177. package/lib/components/spec-transfer/CubeSpecTransferDialog.js.map +1 -0
  178. package/lib/graph-manager/CubeEngine.d.ts +128 -0
  179. package/lib/graph-manager/CubeEngine.d.ts.map +1 -0
  180. package/lib/graph-manager/CubeEngine.js +61 -0
  181. package/lib/graph-manager/CubeEngine.js.map +1 -0
  182. package/lib/graph-manager/CubeModelOutlineHelper.d.ts +33 -0
  183. package/lib/graph-manager/CubeModelOutlineHelper.d.ts.map +1 -0
  184. package/lib/graph-manager/CubeModelOutlineHelper.js +45 -0
  185. package/lib/graph-manager/CubeModelOutlineHelper.js.map +1 -0
  186. package/lib/graph-manager/protocol/pure/CubeEngineBuilder.d.ts +26 -0
  187. package/lib/graph-manager/protocol/pure/CubeEngineBuilder.d.ts.map +1 -0
  188. package/lib/graph-manager/protocol/pure/CubeEngineBuilder.js +22 -0
  189. package/lib/graph-manager/protocol/pure/CubeEngineBuilder.js.map +1 -0
  190. package/lib/graph-manager/protocol/pure/v1/V1_CubeEngineErrors.d.ts +27 -0
  191. package/lib/graph-manager/protocol/pure/v1/V1_CubeEngineErrors.d.ts.map +1 -0
  192. package/lib/graph-manager/protocol/pure/v1/V1_CubeEngineErrors.js +76 -0
  193. package/lib/graph-manager/protocol/pure/v1/V1_CubeEngineErrors.js.map +1 -0
  194. package/lib/graph-manager/protocol/pure/v1/V1_CubeExecutionResultReader.d.ts +27 -0
  195. package/lib/graph-manager/protocol/pure/v1/V1_CubeExecutionResultReader.d.ts.map +1 -0
  196. package/lib/graph-manager/protocol/pure/v1/V1_CubeExecutionResultReader.js +82 -0
  197. package/lib/graph-manager/protocol/pure/v1/V1_CubeExecutionResultReader.js.map +1 -0
  198. package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.d.ts +32 -0
  199. package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.d.ts.map +1 -0
  200. package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.js +195 -0
  201. package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.js.map +1 -0
  202. package/lib/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.d.ts +20 -0
  203. package/lib/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.d.ts.map +1 -0
  204. package/lib/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.js +174 -0
  205. package/lib/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.js.map +1 -0
  206. package/lib/graph-manager/protocol/pure/v1/V1_CubeRelationTypeAdapter.d.ts +24 -0
  207. package/lib/graph-manager/protocol/pure/v1/V1_CubeRelationTypeAdapter.d.ts.map +1 -0
  208. package/lib/graph-manager/protocol/pure/v1/V1_CubeRelationTypeAdapter.js +43 -0
  209. package/lib/graph-manager/protocol/pure/v1/V1_CubeRelationTypeAdapter.js.map +1 -0
  210. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.d.ts +45 -0
  211. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.d.ts.map +1 -0
  212. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.js +171 -0
  213. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.js.map +1 -0
  214. package/lib/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.d.ts +22 -0
  215. package/lib/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.d.ts.map +1 -0
  216. package/lib/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.js +79 -0
  217. package/lib/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.js.map +1 -0
  218. package/lib/index.css +17 -0
  219. package/lib/index.css.map +1 -0
  220. package/lib/index.d.ts +25 -0
  221. package/lib/index.d.ts.map +1 -0
  222. package/lib/index.js +24 -0
  223. package/lib/index.js.map +1 -0
  224. package/lib/stores/CubeEditorState.d.ts +236 -0
  225. package/lib/stores/CubeEditorState.d.ts.map +1 -0
  226. package/lib/stores/CubeEditorState.js +632 -0
  227. package/lib/stores/CubeEditorState.js.map +1 -0
  228. package/lib/stores/CubeExecutionState.d.ts +67 -0
  229. package/lib/stores/CubeExecutionState.d.ts.map +1 -0
  230. package/lib/stores/CubeExecutionState.js +212 -0
  231. package/lib/stores/CubeExecutionState.js.map +1 -0
  232. package/lib/stores/CubeGridQuickActions.d.ts +40 -0
  233. package/lib/stores/CubeGridQuickActions.d.ts.map +1 -0
  234. package/lib/stores/CubeGridQuickActions.js +86 -0
  235. package/lib/stores/CubeGridQuickActions.js.map +1 -0
  236. package/lib/stores/CubeHost.d.ts +31 -0
  237. package/lib/stores/CubeHost.d.ts.map +1 -0
  238. package/lib/stores/CubeHost.js +17 -0
  239. package/lib/stores/CubeHost.js.map +1 -0
  240. package/lib/stores/CubeNodeEditorState.d.ts +103 -0
  241. package/lib/stores/CubeNodeEditorState.d.ts.map +1 -0
  242. package/lib/stores/CubeNodeEditorState.js +262 -0
  243. package/lib/stores/CubeNodeEditorState.js.map +1 -0
  244. package/lib/stores/CubeShowPureState.d.ts +41 -0
  245. package/lib/stores/CubeShowPureState.d.ts.map +1 -0
  246. package/lib/stores/CubeShowPureState.js +100 -0
  247. package/lib/stores/CubeShowPureState.js.map +1 -0
  248. package/lib/stores/CubeSourcePickerState.d.ts +98 -0
  249. package/lib/stores/CubeSourcePickerState.d.ts.map +1 -0
  250. package/lib/stores/CubeSourcePickerState.js +334 -0
  251. package/lib/stores/CubeSourcePickerState.js.map +1 -0
  252. package/lib/stores/CubeSpecTransferState.d.ts +60 -0
  253. package/lib/stores/CubeSpecTransferState.d.ts.map +1 -0
  254. package/lib/stores/CubeSpecTransferState.js +167 -0
  255. package/lib/stores/CubeSpecTransferState.js.map +1 -0
  256. package/lib/stores/LocalModelCatalog.d.ts +37 -0
  257. package/lib/stores/LocalModelCatalog.d.ts.map +1 -0
  258. package/lib/stores/LocalModelCatalog.js +49 -0
  259. package/lib/stores/LocalModelCatalog.js.map +1 -0
  260. package/lib/stores/editors/CubeFilterDraft.d.ts +61 -0
  261. package/lib/stores/editors/CubeFilterDraft.d.ts.map +1 -0
  262. package/lib/stores/editors/CubeFilterDraft.js +186 -0
  263. package/lib/stores/editors/CubeFilterDraft.js.map +1 -0
  264. package/lib/stores/editors/CubeIntegerText.d.ts +24 -0
  265. package/lib/stores/editors/CubeIntegerText.d.ts.map +1 -0
  266. package/lib/stores/editors/CubeIntegerText.js +33 -0
  267. package/lib/stores/editors/CubeIntegerText.js.map +1 -0
  268. package/lib/stores/editors/CubeJoinDraft.d.ts +71 -0
  269. package/lib/stores/editors/CubeJoinDraft.d.ts.map +1 -0
  270. package/lib/stores/editors/CubeJoinDraft.js +145 -0
  271. package/lib/stores/editors/CubeJoinDraft.js.map +1 -0
  272. package/lib/stores/editors/CubeNodeDraft.d.ts +38 -0
  273. package/lib/stores/editors/CubeNodeDraft.d.ts.map +1 -0
  274. package/lib/stores/editors/CubeNodeDraft.js +35 -0
  275. package/lib/stores/editors/CubeNodeDraft.js.map +1 -0
  276. package/lib/stores/editors/CubeNodeDraftRegistry.d.ts +35 -0
  277. package/lib/stores/editors/CubeNodeDraftRegistry.d.ts.map +1 -0
  278. package/lib/stores/editors/CubeNodeDraftRegistry.js +55 -0
  279. package/lib/stores/editors/CubeNodeDraftRegistry.js.map +1 -0
  280. package/lib/stores/editors/CubeRenameDraft.d.ts +44 -0
  281. package/lib/stores/editors/CubeRenameDraft.d.ts.map +1 -0
  282. package/lib/stores/editors/CubeRenameDraft.js +79 -0
  283. package/lib/stores/editors/CubeRenameDraft.js.map +1 -0
  284. package/lib/stores/editors/CubeRestrictDraft.d.ts +37 -0
  285. package/lib/stores/editors/CubeRestrictDraft.d.ts.map +1 -0
  286. package/lib/stores/editors/CubeRestrictDraft.js +73 -0
  287. package/lib/stores/editors/CubeRestrictDraft.js.map +1 -0
  288. package/lib/stores/editors/CubeRowCountDraft.d.ts +42 -0
  289. package/lib/stores/editors/CubeRowCountDraft.d.ts.map +1 -0
  290. package/lib/stores/editors/CubeRowCountDraft.js +55 -0
  291. package/lib/stores/editors/CubeRowCountDraft.js.map +1 -0
  292. package/lib/stores/editors/CubeSliceDraft.d.ts +42 -0
  293. package/lib/stores/editors/CubeSliceDraft.d.ts.map +1 -0
  294. package/lib/stores/editors/CubeSliceDraft.js +72 -0
  295. package/lib/stores/editors/CubeSliceDraft.js.map +1 -0
  296. package/lib/stores/editors/CubeSortDraft.d.ts +49 -0
  297. package/lib/stores/editors/CubeSortDraft.d.ts.map +1 -0
  298. package/lib/stores/editors/CubeSortDraft.js +99 -0
  299. package/lib/stores/editors/CubeSortDraft.js.map +1 -0
  300. package/lib/stores/fixtures/CubeNorthwindModel.d.ts +23 -0
  301. package/lib/stores/fixtures/CubeNorthwindModel.d.ts.map +1 -0
  302. package/lib/stores/fixtures/CubeNorthwindModel.js +338 -0
  303. package/lib/stores/fixtures/CubeNorthwindModel.js.map +1 -0
  304. package/package.json +81 -3
  305. package/src/__lib__/LegendCubeCommand.ts +44 -0
  306. package/src/__lib__/LegendCubeHelpText.ts +58 -0
  307. package/src/__lib__/LegendCubeLabels.ts +171 -0
  308. package/src/__lib__/LegendCubeTesting.ts +33 -0
  309. package/src/__test-utils__/CubeCanvasTestUtils.ts +53 -0
  310. package/src/__test-utils__/CubeEngineTestSupport.ts +172 -0
  311. package/src/__test-utils__/CubeNorthwindTestQueries.ts +165 -0
  312. package/src/__test-utils__/CubeOperationsTestUtils.ts +177 -0
  313. package/src/__test-utils__/CubePageTestUtils.tsx +96 -0
  314. package/src/__test-utils__/CubeTestApplication.ts +82 -0
  315. package/src/__test-utils__/FakeCubeEngine.ts +145 -0
  316. package/src/components/CubeButton.tsx +35 -0
  317. package/src/components/CubeEditor.tsx +239 -0
  318. package/src/components/CubeNodeIcon.tsx +64 -0
  319. package/src/components/canvas/CubeCanvas.tsx +262 -0
  320. package/src/components/canvas/CubeCanvasContext.ts +31 -0
  321. package/src/components/canvas/CubeCanvasContextMenu.tsx +89 -0
  322. package/src/components/canvas/CubeCanvasDnd.ts +82 -0
  323. package/src/components/canvas/CubeCanvasEdge.tsx +57 -0
  324. package/src/components/canvas/CubeCanvasElements.ts +153 -0
  325. package/src/components/canvas/CubeCanvasLayout.ts +88 -0
  326. package/src/components/canvas/CubeCanvasNode.tsx +149 -0
  327. package/src/components/editors/CubeColumnPicker.tsx +138 -0
  328. package/src/components/editors/CubeDistinctEditor.tsx +28 -0
  329. package/src/components/editors/CubeFilterEditor.tsx +309 -0
  330. package/src/components/editors/CubeIntegerField.tsx +51 -0
  331. package/src/components/editors/CubeJoinEditor.tsx +247 -0
  332. package/src/components/editors/CubeNodeEditorPanel.tsx +215 -0
  333. package/src/components/editors/CubeNodeEditorRegistry.ts +81 -0
  334. package/src/components/editors/CubeRenameEditor.tsx +143 -0
  335. package/src/components/editors/CubeRestrictEditor.tsx +103 -0
  336. package/src/components/editors/CubeRowCountEditor.tsx +53 -0
  337. package/src/components/editors/CubeSliceEditor.tsx +69 -0
  338. package/src/components/editors/CubeSortEditor.tsx +206 -0
  339. package/src/components/editors/CubeSourceEditor.tsx +106 -0
  340. package/src/components/editors/CubeValueEditor.tsx +333 -0
  341. package/src/components/grid/CubeGridRegion.tsx +275 -0
  342. package/src/components/grid/CubeGridValues.ts +125 -0
  343. package/src/components/grid/CubeResultGrid.tsx +138 -0
  344. package/src/components/palette/CubePalette.tsx +177 -0
  345. package/src/components/show-pure/CubeShowPureDialog.tsx +101 -0
  346. package/src/components/source-picker/CubeSourcePicker.tsx +304 -0
  347. package/src/components/spec-transfer/CubeSpecTransferDialog.tsx +157 -0
  348. package/src/graph-manager/CubeEngine.ts +169 -0
  349. package/src/graph-manager/CubeModelOutlineHelper.ts +58 -0
  350. package/src/graph-manager/protocol/pure/CubeEngineBuilder.ts +34 -0
  351. package/src/graph-manager/protocol/pure/v1/V1_CubeEngineErrors.ts +109 -0
  352. package/src/graph-manager/protocol/pure/v1/V1_CubeExecutionResultReader.ts +115 -0
  353. package/src/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.ts +257 -0
  354. package/src/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.ts +243 -0
  355. package/src/graph-manager/protocol/pure/v1/V1_CubeRelationTypeAdapter.ts +58 -0
  356. package/src/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.ts +278 -0
  357. package/src/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.ts +127 -0
  358. package/src/index.ts +41 -0
  359. package/src/stores/CubeEditorState.ts +807 -0
  360. package/src/stores/CubeExecutionState.ts +288 -0
  361. package/src/stores/CubeGridQuickActions.ts +129 -0
  362. package/src/stores/CubeHost.ts +32 -0
  363. package/src/stores/CubeNodeEditorState.ts +324 -0
  364. package/src/stores/CubeShowPureState.ts +118 -0
  365. package/src/stores/CubeSourcePickerState.ts +426 -0
  366. package/src/stores/CubeSpecTransferState.ts +198 -0
  367. package/src/stores/LocalModelCatalog.ts +70 -0
  368. package/src/stores/editors/CubeFilterDraft.ts +241 -0
  369. package/src/stores/editors/CubeIntegerText.ts +34 -0
  370. package/src/stores/editors/CubeJoinDraft.ts +224 -0
  371. package/src/stores/editors/CubeNodeDraft.ts +46 -0
  372. package/src/stores/editors/CubeNodeDraftRegistry.ts +83 -0
  373. package/src/stores/editors/CubeRenameDraft.ts +110 -0
  374. package/src/stores/editors/CubeRestrictDraft.ts +83 -0
  375. package/src/stores/editors/CubeRowCountDraft.ts +69 -0
  376. package/src/stores/editors/CubeSliceDraft.ts +87 -0
  377. package/src/stores/editors/CubeSortDraft.ts +135 -0
  378. package/src/stores/fixtures/CubeNorthwindModel.ts +355 -0
  379. package/tsconfig.json +133 -0
@@ -0,0 +1,257 @@
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 type { IR, LiteralValue, Origin } from '@finos/legend-cube';
18
+ import { parseLosslessJSON, type PlainObject } from '@finos/legend-shared';
19
+
20
+ // Cube IR → V1 protocol lambda JSON (PLAN §8.3, §8.5), built as plain JSON,
21
+ // never through legend-graph's value-specification classes, whose serializer
22
+ // drops `sourceInformation`. Numbers are lossless number values, so the
23
+ // request body must be written with `stringifyLosslessJSON`.
24
+
25
+ /** The prefix of the source ids Cube stamps, `cube:<nodeId>:<role>` */
26
+ export const V1_CUBE_SOURCE_ID_PREFIX = 'cube:';
27
+
28
+ /** A JSON number token: what an integer, float or decimal literal must be */
29
+ const NUMBER_TOKEN = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/u;
30
+
31
+ /** The source id of an origin */
32
+ export const V1_buildCubeSourceId = (origin: Origin): string =>
33
+ `${V1_CUBE_SOURCE_ID_PREFIX}${origin.nodeId}:${origin.role}`;
34
+
35
+ /**
36
+ * The origin a source id names, or none when Cube didn't stamp it. A role
37
+ * never contains `:`, so a node id that does still reads back whole.
38
+ */
39
+ export const V1_parseCubeSourceId = (
40
+ sourceId: string | undefined,
41
+ ): Origin | undefined => {
42
+ if (!sourceId?.startsWith(V1_CUBE_SOURCE_ID_PREFIX)) {
43
+ return undefined;
44
+ }
45
+ const rest = sourceId.slice(V1_CUBE_SOURCE_ID_PREFIX.length);
46
+ const at = rest.lastIndexOf(':');
47
+ if (at <= 0 || at === rest.length - 1) {
48
+ return undefined;
49
+ }
50
+ return { nodeId: rest.slice(0, at), role: rest.slice(at + 1) };
51
+ };
52
+
53
+ const stamped = (json: PlainObject, origin: Origin | undefined): PlainObject =>
54
+ origin
55
+ ? {
56
+ ...json,
57
+ sourceInformation: { sourceId: V1_buildCubeSourceId(origin) },
58
+ }
59
+ : json;
60
+
61
+ /** A lossless JSON number for a numeric literal's text, written digit for digit */
62
+ const numberToken = (text: string): unknown => {
63
+ if (!NUMBER_TOKEN.test(text)) {
64
+ throw new Error(`"${text}" is not a number Cube can send`);
65
+ }
66
+ return parseLosslessJSON(text);
67
+ };
68
+
69
+ const serializeLiteral = (value: LiteralValue): PlainObject => {
70
+ switch (value.kind) {
71
+ case 'string':
72
+ case 'boolean':
73
+ case 'strictDate':
74
+ case 'dateTime':
75
+ return { _type: value.kind, value: value.value };
76
+ case 'integer':
77
+ case 'float':
78
+ case 'decimal':
79
+ return { _type: value.kind, value: numberToken(value.value) };
80
+ case 'enum':
81
+ // enumeration values are emitted as `enumValue`, with their enumeration
82
+ throw new Error(
83
+ `Can't send the enumeration value "${value.value}" as a literal`,
84
+ );
85
+ default: {
86
+ const unknown: never = value;
87
+ throw new Error(`Unknown literal ${JSON.stringify(unknown)}`);
88
+ }
89
+ }
90
+ };
91
+
92
+ /**
93
+ * The protocol JSON of an IR node. Every protocol node is stamped with the
94
+ * origin of its IR node, or else of its nearest ancestor that has one.
95
+ */
96
+ const serialize = (ir: IR, inherited: Origin | undefined): PlainObject => {
97
+ switch (ir.k) {
98
+ case 'func': {
99
+ const origin = ir.origin ?? inherited;
100
+ return stamped(
101
+ {
102
+ _type: 'func',
103
+ function: ir.name,
104
+ parameters: ir.params.map((param) => serialize(param, origin)),
105
+ },
106
+ origin,
107
+ );
108
+ }
109
+ case 'property': {
110
+ const origin = ir.origin ?? inherited;
111
+ return stamped(
112
+ {
113
+ _type: 'property',
114
+ property: ir.name,
115
+ parameters: [serialize(ir.receiver, origin)],
116
+ },
117
+ origin,
118
+ );
119
+ }
120
+ case 'var':
121
+ return stamped({ _type: 'var', name: ir.name }, inherited);
122
+ case 'lambda':
123
+ return stamped(
124
+ {
125
+ _type: 'lambda',
126
+ parameters: ir.params.map((name) =>
127
+ stamped({ _type: 'var', name }, inherited),
128
+ ),
129
+ body: ir.body.map((statement) => serialize(statement, inherited)),
130
+ },
131
+ inherited,
132
+ );
133
+ case 'literal':
134
+ return stamped(serializeLiteral(ir.value), ir.origin ?? inherited);
135
+ case 'collection':
136
+ return stamped(
137
+ {
138
+ _type: 'collection',
139
+ multiplicity: {
140
+ lowerBound: ir.values.length,
141
+ upperBound: ir.values.length,
142
+ },
143
+ values: ir.values.map((value) => serialize(value, inherited)),
144
+ },
145
+ inherited,
146
+ );
147
+ case 'colSpec':
148
+ // the engine reports a missing column on the spec's value, which is
149
+ // also what a column list holds, so the value is stamped too
150
+ return stamped(
151
+ {
152
+ _type: 'classInstance',
153
+ type: 'colSpec',
154
+ value: stamped(
155
+ {
156
+ name: ir.name,
157
+ ...(ir.fn1 ? { function1: serialize(ir.fn1, inherited) } : {}),
158
+ ...(ir.fn2 ? { function2: serialize(ir.fn2, inherited) } : {}),
159
+ },
160
+ inherited,
161
+ ),
162
+ },
163
+ inherited,
164
+ );
165
+ case 'colSpecArray':
166
+ return stamped(
167
+ {
168
+ _type: 'classInstance',
169
+ type: 'colSpecArray',
170
+ value: {
171
+ colSpecs: ir.specs.map((spec) => {
172
+ if (spec.k !== 'colSpec') {
173
+ throw new Error(
174
+ `A column list holds only column specs, not "${spec.k}"`,
175
+ );
176
+ }
177
+ return (serialize(spec, inherited) as { value: PlainObject })
178
+ .value;
179
+ }),
180
+ },
181
+ },
182
+ inherited,
183
+ );
184
+ case 'storeAccessor': {
185
+ const origin = ir.origin ?? inherited;
186
+ // the engine reports a wrong database, schema or table on the value
187
+ return stamped(
188
+ {
189
+ _type: 'classInstance',
190
+ type: '>',
191
+ value: stamped({ path: [...ir.path] }, origin),
192
+ },
193
+ origin,
194
+ );
195
+ }
196
+ case 'elementPtr':
197
+ return stamped(
198
+ { _type: 'packageableElementPtr', fullPath: ir.path },
199
+ inherited,
200
+ );
201
+ case 'genericType':
202
+ return stamped(
203
+ {
204
+ _type: 'genericTypeInstance',
205
+ genericType: {
206
+ rawType: { _type: 'packageableType', fullPath: ir.path },
207
+ typeArguments: [],
208
+ multiplicityArguments: [],
209
+ typeVariableValues: (ir.params ?? []).map((param) =>
210
+ stamped(
211
+ { _type: 'integer', value: numberToken(String(param)) },
212
+ inherited,
213
+ ),
214
+ ),
215
+ },
216
+ },
217
+ inherited,
218
+ );
219
+ case 'enumValue': {
220
+ const origin = ir.origin ?? inherited;
221
+ return stamped(
222
+ {
223
+ _type: 'property',
224
+ property: ir.value,
225
+ parameters: [
226
+ stamped(
227
+ { _type: 'packageableElementPtr', fullPath: ir.enumPath },
228
+ origin,
229
+ ),
230
+ ],
231
+ },
232
+ origin,
233
+ );
234
+ }
235
+ case 'let':
236
+ case 'block':
237
+ // window isolation (PLAN §8.6) comes with Partition, in M5
238
+ throw new Error(`Can't send "${ir.k}" yet`);
239
+ case 'raw':
240
+ return ir.json as PlainObject;
241
+ default: {
242
+ const unknown: never = ir;
243
+ throw new Error(`Unknown IR ${JSON.stringify(unknown)}`);
244
+ }
245
+ }
246
+ };
247
+
248
+ /**
249
+ * The protocol JSON of a lambda Cube emitted (a typing or an execution
250
+ * lambda), with lossless numbers: write it with `stringifyLosslessJSON`.
251
+ */
252
+ export const V1_serializeCubeLambda = (ir: IR): PlainObject => {
253
+ if (ir.k !== 'lambda') {
254
+ throw new Error(`Only a lambda can be sent, not "${ir.k}"`);
255
+ }
256
+ return serialize(ir, undefined);
257
+ };
@@ -0,0 +1,243 @@
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 { getRelationalDisplayName } from '@finos/legend-cube';
18
+ import type { PlainObject } from '@finos/legend-shared';
19
+ import {
20
+ CubeTableFlag,
21
+ type CubeModelOutline,
22
+ type CubeOutlineConnection,
23
+ type CubeOutlineDatabase,
24
+ type CubeOutlineRuntime,
25
+ type CubeOutlineSchema,
26
+ type CubeOutlineTable,
27
+ } from '../../../CubeEngine.js';
28
+
29
+ // The databases and runtimes of a parsed model (`{_type: 'data', elements}`),
30
+ // for the source picker (PLAN §6.2.3-§6.2.6). Read as plain JSON: only names,
31
+ // column types and store paths are needed, and an element's full protocol
32
+ // deserializer needs the graph manager's plugins.
33
+
34
+ const DATABASE_TYPE = 'relational';
35
+ const RUNTIME_TYPE = 'runtime';
36
+ const CONNECTION_TYPE = 'connection';
37
+ const CONNECTION_POINTER_TYPE = 'connectionPointer';
38
+ const RELATIONAL_CONNECTION_TYPE = 'RelationalDatabaseConnection';
39
+ /** The only runtime value whose store keys Cube can read; others are hidden */
40
+ const ENGINE_RUNTIME_TYPE = 'engineRuntime';
41
+
42
+ /** The flag a column type gives its table, if any (PLAN §6.2.6) */
43
+ const COLUMN_TYPE_FLAGS: Record<string, CubeTableFlag> = {
44
+ // the engine fails to type the whole table
45
+ Binary: CubeTableFlag.UNAVAILABLE,
46
+ Varbinary: CubeTableFlag.UNAVAILABLE,
47
+ // typed with a length of 1
48
+ Char: CubeTableFlag.LENGTH_UNKNOWN,
49
+ // an ARRAY column is parsed as Other; both are typed as a bare String
50
+ Other: CubeTableFlag.TYPE_UNKNOWN,
51
+ };
52
+
53
+ const asObject = (value: unknown): PlainObject =>
54
+ value && typeof value === 'object' && !Array.isArray(value)
55
+ ? (value as PlainObject)
56
+ : {};
57
+
58
+ const asList = (value: unknown): unknown[] =>
59
+ Array.isArray(value) ? value : [];
60
+
61
+ const asString = (value: unknown): string | undefined =>
62
+ typeof value === 'string' ? value : undefined;
63
+
64
+ const elementPath = (element: PlainObject): string => {
65
+ const name = asString(element.name) ?? '';
66
+ const pkg = asString(element.package);
67
+ return pkg ? `${pkg}::${name}` : name;
68
+ };
69
+
70
+ const buildTable = (json: unknown): CubeOutlineTable => {
71
+ const table = asObject(json);
72
+ const columns = asList(table.columns).map(asObject);
73
+ const flags = new Set<CubeTableFlag>();
74
+ const untypedColumns: string[] = [];
75
+ columns.forEach((column) => {
76
+ const flag = COLUMN_TYPE_FLAGS[asString(asObject(column.type)._type) ?? ''];
77
+ if (flag) {
78
+ flags.add(flag);
79
+ }
80
+ if (flag === CubeTableFlag.TYPE_UNKNOWN) {
81
+ // unquoted, as the engine names the column in the table's schema
82
+ untypedColumns.push(
83
+ getRelationalDisplayName(asString(column.name) ?? ''),
84
+ );
85
+ }
86
+ });
87
+ return {
88
+ name: asString(table.name) ?? '',
89
+ isView: false,
90
+ columnCount: columns.length,
91
+ flags: Object.values(CubeTableFlag).filter((flag) => flags.has(flag)),
92
+ untypedColumns,
93
+ };
94
+ };
95
+
96
+ const buildView = (json: unknown): CubeOutlineTable => {
97
+ const view = asObject(json);
98
+ return {
99
+ name: asString(view.name) ?? '',
100
+ isView: true,
101
+ columnCount: asList(view.columnMappings).length,
102
+ flags: [],
103
+ untypedColumns: [],
104
+ };
105
+ };
106
+
107
+ const buildSchema = (json: unknown): CubeOutlineSchema => {
108
+ const schema = asObject(json);
109
+ return {
110
+ name: asString(schema.name) ?? '',
111
+ tables: [
112
+ ...asList(schema.tables).map(buildTable),
113
+ ...asList(schema.views).map(buildView),
114
+ ],
115
+ };
116
+ };
117
+
118
+ const buildDatabase = (element: PlainObject): CubeOutlineDatabase => ({
119
+ path: elementPath(element),
120
+ // included stores are not followed (v1)
121
+ schemas: asList(element.schemas).map(buildSchema),
122
+ });
123
+
124
+ /** The database type of a relational connection value: its `type`, else its `databaseType` */
125
+ const getRelationalDatabaseType = (value: PlainObject): string | undefined =>
126
+ value._type === RELATIONAL_CONNECTION_TYPE
127
+ ? (asString(value.type) ?? asString(value.databaseType))
128
+ : undefined;
129
+
130
+ /**
131
+ * The database type of a runtime's connection, embedded or a pointer to a
132
+ * connection element (`connectionTypes`, by path); none for one that isn't
133
+ * relational
134
+ */
135
+ const getConnectionDatabaseType = (
136
+ json: unknown,
137
+ connectionTypes: ReadonlyMap<string, string>,
138
+ ): string | undefined => {
139
+ const connection = asObject(json);
140
+ if (connection._type === CONNECTION_POINTER_TYPE) {
141
+ const path = asString(connection.connection);
142
+ return path === undefined ? undefined : connectionTypes.get(path);
143
+ }
144
+ return getRelationalDatabaseType(connection);
145
+ };
146
+
147
+ /** The stores a runtime's connections are keyed by, in both syntaxes; none when it can't be read */
148
+ const buildRuntime = (
149
+ element: PlainObject,
150
+ connectionTypes: ReadonlyMap<string, string>,
151
+ ): CubeOutlineRuntime | undefined => {
152
+ const value = asObject(element.runtimeValue);
153
+ if (value._type !== ENGINE_RUNTIME_TYPE) {
154
+ return undefined;
155
+ }
156
+ const storePaths = [
157
+ // `connections: [<store>: [...]]`
158
+ ...asList(value.connections).map((connection) =>
159
+ asString(asObject(asObject(connection).store).path),
160
+ ),
161
+ // `connectionStores: [<connection>: [<store>, ...]]`
162
+ ...asList(value.connectionStores).flatMap((connectionStore) =>
163
+ asList(asObject(connectionStore).storePointers).map((pointer) =>
164
+ asString(asObject(pointer).path),
165
+ ),
166
+ ),
167
+ ].filter((path): path is string => path !== undefined);
168
+ const connections: CubeOutlineConnection[] = [];
169
+ const addConnection = (
170
+ storePath: string | undefined,
171
+ databaseType: string | undefined,
172
+ ): void => {
173
+ if (
174
+ storePath !== undefined &&
175
+ databaseType !== undefined &&
176
+ !connections.some(
177
+ (connection) =>
178
+ connection.storePath === storePath &&
179
+ connection.databaseType === databaseType,
180
+ )
181
+ ) {
182
+ connections.push({ storePath, databaseType });
183
+ }
184
+ };
185
+ asList(value.connections).forEach((json) => {
186
+ const storeConnections = asObject(json);
187
+ const storePath = asString(asObject(storeConnections.store).path);
188
+ asList(storeConnections.storeConnections).forEach((identified) =>
189
+ addConnection(
190
+ storePath,
191
+ getConnectionDatabaseType(
192
+ asObject(identified).connection,
193
+ connectionTypes,
194
+ ),
195
+ ),
196
+ );
197
+ });
198
+ asList(value.connectionStores).forEach((json) => {
199
+ const connectionStore = asObject(json);
200
+ const databaseType = getConnectionDatabaseType(
201
+ connectionStore.connectionPointer,
202
+ connectionTypes,
203
+ );
204
+ asList(connectionStore.storePointers).forEach((pointer) =>
205
+ addConnection(asString(asObject(pointer).path), databaseType),
206
+ );
207
+ });
208
+ return {
209
+ path: elementPath(element),
210
+ storePaths: [...new Set(storePaths)],
211
+ connections,
212
+ };
213
+ };
214
+
215
+ /** The outline of a parsed model: its Database elements and its readable runtimes, in model order */
216
+ export const V1_buildCubeModelOutline = (
217
+ modelData: PlainObject,
218
+ ): CubeModelOutline => {
219
+ const elements = asList(modelData.elements).map(asObject);
220
+ // the database type of each relational connection element, by path
221
+ const connectionTypes = new Map<string, string>();
222
+ elements
223
+ .filter((element) => element._type === CONNECTION_TYPE)
224
+ .forEach((element) => {
225
+ const databaseType = getRelationalDatabaseType(
226
+ asObject(element.connectionValue),
227
+ );
228
+ if (databaseType !== undefined) {
229
+ connectionTypes.set(elementPath(element), databaseType);
230
+ }
231
+ });
232
+ return {
233
+ databases: elements
234
+ .filter((element) => element._type === DATABASE_TYPE)
235
+ .map(buildDatabase),
236
+ runtimes: elements
237
+ .filter((element) => element._type === RUNTIME_TYPE)
238
+ .map((element) => buildRuntime(element, connectionTypes))
239
+ .filter(
240
+ (runtime): runtime is CubeOutlineRuntime => runtime !== undefined,
241
+ ),
242
+ };
243
+ };
@@ -0,0 +1,58 @@
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 { resolveCubeType, Schema, SchemaColumn } from '@finos/legend-cube';
18
+ import {
19
+ V1_CInteger,
20
+ V1_PackageableType,
21
+ V1_relationTypeModelSchema,
22
+ } from '@finos/legend-graph';
23
+ import type { PlainObject } from '@finos/legend-shared';
24
+ import { deserialize } from 'serializr';
25
+
26
+ // The engine's relation type → a Cube schema (PLAN §6.2.6), read through
27
+ // legend-graph's protocol schema. Its graph-manager wrappers are bypassed:
28
+ // they drop type parameters (D8).
29
+
30
+ /**
31
+ * The schema of a relation type: one column per relation column, in order,
32
+ * typed by its path and parameters (an unknown type is opaque) and nullable
33
+ * when it may be empty
34
+ */
35
+ export const V1_buildCubeSchema = (json: PlainObject): Schema => {
36
+ const relationType = deserialize(V1_relationTypeModelSchema, json);
37
+ return new Schema(
38
+ relationType.columns.map((column) => {
39
+ const { rawType, typeVariableValues } = column.genericType;
40
+ if (!(rawType instanceof V1_PackageableType)) {
41
+ throw new Error(`Column "${column.name}" has a type Cube can't read`);
42
+ }
43
+ const params = typeVariableValues.map((value) => {
44
+ if (!(value instanceof V1_CInteger)) {
45
+ throw new Error(
46
+ `Column "${column.name}" has a type parameter Cube can't read`,
47
+ );
48
+ }
49
+ return value.value;
50
+ });
51
+ return new SchemaColumn(
52
+ column.name,
53
+ resolveCubeType(rawType.fullPath, params),
54
+ column.multiplicity.lowerBound === 0,
55
+ );
56
+ }),
57
+ );
58
+ };