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

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 (301) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +5 -2
  3. package/lib/__lib__/LegendCubeCommand.d.ts +26 -0
  4. package/lib/__lib__/LegendCubeCommand.d.ts.map +1 -0
  5. package/lib/__lib__/LegendCubeCommand.js +40 -0
  6. package/lib/__lib__/LegendCubeCommand.js.map +1 -0
  7. package/lib/__lib__/LegendCubeHelpText.d.ts +19 -0
  8. package/lib/__lib__/LegendCubeHelpText.d.ts.map +1 -0
  9. package/lib/__lib__/LegendCubeHelpText.js +27 -0
  10. package/lib/__lib__/LegendCubeHelpText.js.map +1 -0
  11. package/lib/__lib__/LegendCubeLabels.d.ts +68 -0
  12. package/lib/__lib__/LegendCubeLabels.d.ts.map +1 -0
  13. package/lib/__lib__/LegendCubeLabels.js +109 -0
  14. package/lib/__lib__/LegendCubeLabels.js.map +1 -0
  15. package/lib/__lib__/LegendCubeTesting.d.ts +33 -0
  16. package/lib/__lib__/LegendCubeTesting.d.ts.map +1 -0
  17. package/lib/__lib__/LegendCubeTesting.js +34 -0
  18. package/lib/__lib__/LegendCubeTesting.js.map +1 -0
  19. package/lib/__test-utils__/CubeCanvasTestUtils.d.ts +24 -0
  20. package/lib/__test-utils__/CubeCanvasTestUtils.d.ts.map +1 -0
  21. package/lib/__test-utils__/CubeCanvasTestUtils.js +37 -0
  22. package/lib/__test-utils__/CubeCanvasTestUtils.js.map +1 -0
  23. package/lib/__test-utils__/CubeEngineTestSupport.d.ts +41 -0
  24. package/lib/__test-utils__/CubeEngineTestSupport.d.ts.map +1 -0
  25. package/lib/__test-utils__/CubeEngineTestSupport.js +76 -0
  26. package/lib/__test-utils__/CubeEngineTestSupport.js.map +1 -0
  27. package/lib/__test-utils__/CubeNorthwindTestQueries.d.ts +31 -0
  28. package/lib/__test-utils__/CubeNorthwindTestQueries.d.ts.map +1 -0
  29. package/lib/__test-utils__/CubeNorthwindTestQueries.js +102 -0
  30. package/lib/__test-utils__/CubeNorthwindTestQueries.js.map +1 -0
  31. package/lib/__test-utils__/CubePageTestUtils.d.ts +33 -0
  32. package/lib/__test-utils__/CubePageTestUtils.d.ts.map +1 -0
  33. package/lib/__test-utils__/CubePageTestUtils.js +68 -0
  34. package/lib/__test-utils__/CubePageTestUtils.js.map +1 -0
  35. package/lib/__test-utils__/CubeTestApplication.d.ts +30 -0
  36. package/lib/__test-utils__/CubeTestApplication.d.ts.map +1 -0
  37. package/lib/__test-utils__/CubeTestApplication.js +57 -0
  38. package/lib/__test-utils__/CubeTestApplication.js.map +1 -0
  39. package/lib/__test-utils__/FakeCubeEngine.d.ts +41 -0
  40. package/lib/__test-utils__/FakeCubeEngine.d.ts.map +1 -0
  41. package/lib/__test-utils__/FakeCubeEngine.js +85 -0
  42. package/lib/__test-utils__/FakeCubeEngine.js.map +1 -0
  43. package/lib/components/CubeButton.d.ts +20 -0
  44. package/lib/components/CubeButton.d.ts.map +1 -0
  45. package/lib/components/CubeButton.js +24 -0
  46. package/lib/components/CubeButton.js.map +1 -0
  47. package/lib/components/CubeEditor.d.ts +31 -0
  48. package/lib/components/CubeEditor.d.ts.map +1 -0
  49. package/lib/components/CubeEditor.js +90 -0
  50. package/lib/components/CubeEditor.js.map +1 -0
  51. package/lib/components/CubeNodeIcon.d.ts +23 -0
  52. package/lib/components/CubeNodeIcon.d.ts.map +1 -0
  53. package/lib/components/CubeNodeIcon.js +32 -0
  54. package/lib/components/CubeNodeIcon.js.map +1 -0
  55. package/lib/components/canvas/CubeCanvas.d.ts +37 -0
  56. package/lib/components/canvas/CubeCanvas.d.ts.map +1 -0
  57. package/lib/components/canvas/CubeCanvas.js +135 -0
  58. package/lib/components/canvas/CubeCanvas.js.map +1 -0
  59. package/lib/components/canvas/CubeCanvasContext.d.ts +19 -0
  60. package/lib/components/canvas/CubeCanvasContext.d.ts.map +1 -0
  61. package/lib/components/canvas/CubeCanvasContext.js +22 -0
  62. package/lib/components/canvas/CubeCanvasContext.js.map +1 -0
  63. package/lib/components/canvas/CubeCanvasContextMenu.d.ts +28 -0
  64. package/lib/components/canvas/CubeCanvasContextMenu.d.ts.map +1 -0
  65. package/lib/components/canvas/CubeCanvasContextMenu.js +35 -0
  66. package/lib/components/canvas/CubeCanvasContextMenu.js.map +1 -0
  67. package/lib/components/canvas/CubeCanvasDnd.d.ts +43 -0
  68. package/lib/components/canvas/CubeCanvasDnd.d.ts.map +1 -0
  69. package/lib/components/canvas/CubeCanvasDnd.js +51 -0
  70. package/lib/components/canvas/CubeCanvasDnd.js.map +1 -0
  71. package/lib/components/canvas/CubeCanvasEdge.d.ts +24 -0
  72. package/lib/components/canvas/CubeCanvasEdge.d.ts.map +1 -0
  73. package/lib/components/canvas/CubeCanvasEdge.js +33 -0
  74. package/lib/components/canvas/CubeCanvasEdge.js.map +1 -0
  75. package/lib/components/canvas/CubeCanvasElements.d.ts +64 -0
  76. package/lib/components/canvas/CubeCanvasElements.d.ts.map +1 -0
  77. package/lib/components/canvas/CubeCanvasElements.js +96 -0
  78. package/lib/components/canvas/CubeCanvasElements.js.map +1 -0
  79. package/lib/components/canvas/CubeCanvasLayout.d.ts +32 -0
  80. package/lib/components/canvas/CubeCanvasLayout.d.ts.map +1 -0
  81. package/lib/components/canvas/CubeCanvasLayout.js +63 -0
  82. package/lib/components/canvas/CubeCanvasLayout.js.map +1 -0
  83. package/lib/components/canvas/CubeCanvasNode.d.ts +29 -0
  84. package/lib/components/canvas/CubeCanvasNode.d.ts.map +1 -0
  85. package/lib/components/canvas/CubeCanvasNode.js +72 -0
  86. package/lib/components/canvas/CubeCanvasNode.js.map +1 -0
  87. package/lib/components/editors/CubeColumnPicker.d.ts +40 -0
  88. package/lib/components/editors/CubeColumnPicker.d.ts.map +1 -0
  89. package/lib/components/editors/CubeColumnPicker.js +51 -0
  90. package/lib/components/editors/CubeColumnPicker.js.map +1 -0
  91. package/lib/components/editors/CubeFilterEditor.d.ts +26 -0
  92. package/lib/components/editors/CubeFilterEditor.d.ts.map +1 -0
  93. package/lib/components/editors/CubeFilterEditor.js +90 -0
  94. package/lib/components/editors/CubeFilterEditor.js.map +1 -0
  95. package/lib/components/editors/CubeJoinEditor.d.ts +26 -0
  96. package/lib/components/editors/CubeJoinEditor.d.ts.map +1 -0
  97. package/lib/components/editors/CubeJoinEditor.js +76 -0
  98. package/lib/components/editors/CubeJoinEditor.js.map +1 -0
  99. package/lib/components/editors/CubeNodeEditorPanel.d.ts +29 -0
  100. package/lib/components/editors/CubeNodeEditorPanel.d.ts.map +1 -0
  101. package/lib/components/editors/CubeNodeEditorPanel.js +71 -0
  102. package/lib/components/editors/CubeNodeEditorPanel.js.map +1 -0
  103. package/lib/components/editors/CubeNodeEditorRegistry.d.ts +44 -0
  104. package/lib/components/editors/CubeNodeEditorRegistry.d.ts.map +1 -0
  105. package/lib/components/editors/CubeNodeEditorRegistry.js +30 -0
  106. package/lib/components/editors/CubeNodeEditorRegistry.js.map +1 -0
  107. package/lib/components/editors/CubeSourceEditor.d.ts +25 -0
  108. package/lib/components/editors/CubeSourceEditor.d.ts.map +1 -0
  109. package/lib/components/editors/CubeSourceEditor.js +42 -0
  110. package/lib/components/editors/CubeSourceEditor.js.map +1 -0
  111. package/lib/components/editors/CubeValueEditor.d.ts +40 -0
  112. package/lib/components/editors/CubeValueEditor.d.ts.map +1 -0
  113. package/lib/components/editors/CubeValueEditor.js +177 -0
  114. package/lib/components/editors/CubeValueEditor.js.map +1 -0
  115. package/lib/components/grid/CubeGridRegion.d.ts +23 -0
  116. package/lib/components/grid/CubeGridRegion.d.ts.map +1 -0
  117. package/lib/components/grid/CubeGridRegion.js +94 -0
  118. package/lib/components/grid/CubeGridRegion.js.map +1 -0
  119. package/lib/components/grid/CubeGridValues.d.ts +25 -0
  120. package/lib/components/grid/CubeGridValues.d.ts.map +1 -0
  121. package/lib/components/grid/CubeGridValues.js +95 -0
  122. package/lib/components/grid/CubeGridValues.js.map +1 -0
  123. package/lib/components/grid/CubeResultGrid.d.ts +26 -0
  124. package/lib/components/grid/CubeResultGrid.d.ts.map +1 -0
  125. package/lib/components/grid/CubeResultGrid.js +50 -0
  126. package/lib/components/grid/CubeResultGrid.js.map +1 -0
  127. package/lib/components/palette/CubePalette.d.ts +29 -0
  128. package/lib/components/palette/CubePalette.d.ts.map +1 -0
  129. package/lib/components/palette/CubePalette.js +73 -0
  130. package/lib/components/palette/CubePalette.js.map +1 -0
  131. package/lib/components/show-pure/CubeShowPureDialog.d.ts +23 -0
  132. package/lib/components/show-pure/CubeShowPureDialog.d.ts.map +1 -0
  133. package/lib/components/show-pure/CubeShowPureDialog.js +37 -0
  134. package/lib/components/show-pure/CubeShowPureDialog.js.map +1 -0
  135. package/lib/components/source-picker/CubeSourcePicker.d.ts +22 -0
  136. package/lib/components/source-picker/CubeSourcePicker.d.ts.map +1 -0
  137. package/lib/components/source-picker/CubeSourcePicker.js +89 -0
  138. package/lib/components/source-picker/CubeSourcePicker.js.map +1 -0
  139. package/lib/components/spec-transfer/CubeSpecTransferDialog.d.ts +26 -0
  140. package/lib/components/spec-transfer/CubeSpecTransferDialog.d.ts.map +1 -0
  141. package/lib/components/spec-transfer/CubeSpecTransferDialog.js +45 -0
  142. package/lib/components/spec-transfer/CubeSpecTransferDialog.js.map +1 -0
  143. package/lib/graph-manager/CubeEngine.d.ts +115 -0
  144. package/lib/graph-manager/CubeEngine.d.ts.map +1 -0
  145. package/lib/graph-manager/CubeEngine.js +61 -0
  146. package/lib/graph-manager/CubeEngine.js.map +1 -0
  147. package/lib/graph-manager/CubeModelOutlineHelper.d.ts +25 -0
  148. package/lib/graph-manager/CubeModelOutlineHelper.d.ts.map +1 -0
  149. package/lib/graph-manager/CubeModelOutlineHelper.js +24 -0
  150. package/lib/graph-manager/CubeModelOutlineHelper.js.map +1 -0
  151. package/lib/graph-manager/protocol/pure/CubeEngineBuilder.d.ts +26 -0
  152. package/lib/graph-manager/protocol/pure/CubeEngineBuilder.d.ts.map +1 -0
  153. package/lib/graph-manager/protocol/pure/CubeEngineBuilder.js +22 -0
  154. package/lib/graph-manager/protocol/pure/CubeEngineBuilder.js.map +1 -0
  155. package/lib/graph-manager/protocol/pure/v1/V1_CubeEngineErrors.d.ts +27 -0
  156. package/lib/graph-manager/protocol/pure/v1/V1_CubeEngineErrors.d.ts.map +1 -0
  157. package/lib/graph-manager/protocol/pure/v1/V1_CubeEngineErrors.js +76 -0
  158. package/lib/graph-manager/protocol/pure/v1/V1_CubeEngineErrors.js.map +1 -0
  159. package/lib/graph-manager/protocol/pure/v1/V1_CubeExecutionResultReader.d.ts +27 -0
  160. package/lib/graph-manager/protocol/pure/v1/V1_CubeExecutionResultReader.d.ts.map +1 -0
  161. package/lib/graph-manager/protocol/pure/v1/V1_CubeExecutionResultReader.js +82 -0
  162. package/lib/graph-manager/protocol/pure/v1/V1_CubeExecutionResultReader.js.map +1 -0
  163. package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.d.ts +32 -0
  164. package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.d.ts.map +1 -0
  165. package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.js +195 -0
  166. package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.js.map +1 -0
  167. package/lib/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.d.ts +20 -0
  168. package/lib/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.d.ts.map +1 -0
  169. package/lib/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.js +121 -0
  170. package/lib/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.js.map +1 -0
  171. package/lib/graph-manager/protocol/pure/v1/V1_CubeRelationTypeAdapter.d.ts +24 -0
  172. package/lib/graph-manager/protocol/pure/v1/V1_CubeRelationTypeAdapter.d.ts.map +1 -0
  173. package/lib/graph-manager/protocol/pure/v1/V1_CubeRelationTypeAdapter.js +43 -0
  174. package/lib/graph-manager/protocol/pure/v1/V1_CubeRelationTypeAdapter.js.map +1 -0
  175. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.d.ts +45 -0
  176. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.d.ts.map +1 -0
  177. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.js +171 -0
  178. package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.js.map +1 -0
  179. package/lib/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.d.ts +22 -0
  180. package/lib/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.d.ts.map +1 -0
  181. package/lib/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.js +79 -0
  182. package/lib/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.js.map +1 -0
  183. package/lib/index.css +17 -0
  184. package/lib/index.css.map +1 -0
  185. package/lib/index.d.ts +25 -0
  186. package/lib/index.d.ts.map +1 -0
  187. package/lib/index.js +24 -0
  188. package/lib/index.js.map +1 -0
  189. package/lib/stores/CubeEditorState.d.ts +206 -0
  190. package/lib/stores/CubeEditorState.d.ts.map +1 -0
  191. package/lib/stores/CubeEditorState.js +551 -0
  192. package/lib/stores/CubeEditorState.js.map +1 -0
  193. package/lib/stores/CubeExecutionState.d.ts +67 -0
  194. package/lib/stores/CubeExecutionState.d.ts.map +1 -0
  195. package/lib/stores/CubeExecutionState.js +196 -0
  196. package/lib/stores/CubeExecutionState.js.map +1 -0
  197. package/lib/stores/CubeHost.d.ts +31 -0
  198. package/lib/stores/CubeHost.d.ts.map +1 -0
  199. package/lib/stores/CubeHost.js +17 -0
  200. package/lib/stores/CubeHost.js.map +1 -0
  201. package/lib/stores/CubeNodeEditorState.d.ts +85 -0
  202. package/lib/stores/CubeNodeEditorState.d.ts.map +1 -0
  203. package/lib/stores/CubeNodeEditorState.js +207 -0
  204. package/lib/stores/CubeNodeEditorState.js.map +1 -0
  205. package/lib/stores/CubeShowPureState.d.ts +38 -0
  206. package/lib/stores/CubeShowPureState.d.ts.map +1 -0
  207. package/lib/stores/CubeShowPureState.js +83 -0
  208. package/lib/stores/CubeShowPureState.js.map +1 -0
  209. package/lib/stores/CubeSourcePickerState.d.ts +98 -0
  210. package/lib/stores/CubeSourcePickerState.d.ts.map +1 -0
  211. package/lib/stores/CubeSourcePickerState.js +334 -0
  212. package/lib/stores/CubeSourcePickerState.js.map +1 -0
  213. package/lib/stores/CubeSpecTransferState.d.ts +60 -0
  214. package/lib/stores/CubeSpecTransferState.d.ts.map +1 -0
  215. package/lib/stores/CubeSpecTransferState.js +167 -0
  216. package/lib/stores/CubeSpecTransferState.js.map +1 -0
  217. package/lib/stores/LocalModelCatalog.d.ts +37 -0
  218. package/lib/stores/LocalModelCatalog.d.ts.map +1 -0
  219. package/lib/stores/LocalModelCatalog.js +49 -0
  220. package/lib/stores/LocalModelCatalog.js.map +1 -0
  221. package/lib/stores/editors/CubeFilterDraft.d.ts +61 -0
  222. package/lib/stores/editors/CubeFilterDraft.d.ts.map +1 -0
  223. package/lib/stores/editors/CubeFilterDraft.js +186 -0
  224. package/lib/stores/editors/CubeFilterDraft.js.map +1 -0
  225. package/lib/stores/editors/CubeJoinDraft.d.ts +63 -0
  226. package/lib/stores/editors/CubeJoinDraft.d.ts.map +1 -0
  227. package/lib/stores/editors/CubeJoinDraft.js +136 -0
  228. package/lib/stores/editors/CubeJoinDraft.js.map +1 -0
  229. package/lib/stores/editors/CubeNodeDraft.d.ts +38 -0
  230. package/lib/stores/editors/CubeNodeDraft.d.ts.map +1 -0
  231. package/lib/stores/editors/CubeNodeDraft.js +35 -0
  232. package/lib/stores/editors/CubeNodeDraft.js.map +1 -0
  233. package/lib/stores/editors/CubeNodeDraftRegistry.d.ts +29 -0
  234. package/lib/stores/editors/CubeNodeDraftRegistry.d.ts.map +1 -0
  235. package/lib/stores/editors/CubeNodeDraftRegistry.js +33 -0
  236. package/lib/stores/editors/CubeNodeDraftRegistry.js.map +1 -0
  237. package/lib/stores/fixtures/CubeNorthwindModel.d.ts +23 -0
  238. package/lib/stores/fixtures/CubeNorthwindModel.d.ts.map +1 -0
  239. package/lib/stores/fixtures/CubeNorthwindModel.js +338 -0
  240. package/lib/stores/fixtures/CubeNorthwindModel.js.map +1 -0
  241. package/package.json +81 -3
  242. package/src/__lib__/LegendCubeCommand.ts +44 -0
  243. package/src/__lib__/LegendCubeHelpText.ts +38 -0
  244. package/src/__lib__/LegendCubeLabels.ts +141 -0
  245. package/src/__lib__/LegendCubeTesting.ts +33 -0
  246. package/src/__test-utils__/CubeCanvasTestUtils.ts +53 -0
  247. package/src/__test-utils__/CubeEngineTestSupport.ts +137 -0
  248. package/src/__test-utils__/CubeNorthwindTestQueries.ts +165 -0
  249. package/src/__test-utils__/CubePageTestUtils.tsx +96 -0
  250. package/src/__test-utils__/CubeTestApplication.ts +82 -0
  251. package/src/__test-utils__/FakeCubeEngine.ts +139 -0
  252. package/src/components/CubeButton.tsx +35 -0
  253. package/src/components/CubeEditor.tsx +239 -0
  254. package/src/components/CubeNodeIcon.tsx +47 -0
  255. package/src/components/canvas/CubeCanvas.tsx +260 -0
  256. package/src/components/canvas/CubeCanvasContext.ts +31 -0
  257. package/src/components/canvas/CubeCanvasContextMenu.tsx +89 -0
  258. package/src/components/canvas/CubeCanvasDnd.ts +82 -0
  259. package/src/components/canvas/CubeCanvasEdge.tsx +57 -0
  260. package/src/components/canvas/CubeCanvasElements.ts +150 -0
  261. package/src/components/canvas/CubeCanvasLayout.ts +88 -0
  262. package/src/components/canvas/CubeCanvasNode.tsx +141 -0
  263. package/src/components/editors/CubeColumnPicker.tsx +114 -0
  264. package/src/components/editors/CubeFilterEditor.tsx +309 -0
  265. package/src/components/editors/CubeJoinEditor.tsx +224 -0
  266. package/src/components/editors/CubeNodeEditorPanel.tsx +204 -0
  267. package/src/components/editors/CubeNodeEditorRegistry.ts +61 -0
  268. package/src/components/editors/CubeSourceEditor.tsx +116 -0
  269. package/src/components/editors/CubeValueEditor.tsx +332 -0
  270. package/src/components/grid/CubeGridRegion.tsx +274 -0
  271. package/src/components/grid/CubeGridValues.ts +125 -0
  272. package/src/components/grid/CubeResultGrid.tsx +84 -0
  273. package/src/components/palette/CubePalette.tsx +177 -0
  274. package/src/components/show-pure/CubeShowPureDialog.tsx +101 -0
  275. package/src/components/source-picker/CubeSourcePicker.tsx +304 -0
  276. package/src/components/spec-transfer/CubeSpecTransferDialog.tsx +157 -0
  277. package/src/graph-manager/CubeEngine.ts +155 -0
  278. package/src/graph-manager/CubeModelOutlineHelper.ts +32 -0
  279. package/src/graph-manager/protocol/pure/CubeEngineBuilder.ts +34 -0
  280. package/src/graph-manager/protocol/pure/v1/V1_CubeEngineErrors.ts +109 -0
  281. package/src/graph-manager/protocol/pure/v1/V1_CubeExecutionResultReader.ts +115 -0
  282. package/src/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.ts +257 -0
  283. package/src/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.ts +157 -0
  284. package/src/graph-manager/protocol/pure/v1/V1_CubeRelationTypeAdapter.ts +58 -0
  285. package/src/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.ts +278 -0
  286. package/src/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.ts +124 -0
  287. package/src/index.ts +41 -0
  288. package/src/stores/CubeEditorState.ts +702 -0
  289. package/src/stores/CubeExecutionState.ts +255 -0
  290. package/src/stores/CubeHost.ts +32 -0
  291. package/src/stores/CubeNodeEditorState.ts +255 -0
  292. package/src/stores/CubeShowPureState.ts +96 -0
  293. package/src/stores/CubeSourcePickerState.ts +426 -0
  294. package/src/stores/CubeSpecTransferState.ts +198 -0
  295. package/src/stores/LocalModelCatalog.ts +70 -0
  296. package/src/stores/editors/CubeFilterDraft.ts +241 -0
  297. package/src/stores/editors/CubeJoinDraft.ts +197 -0
  298. package/src/stores/editors/CubeNodeDraft.ts +46 -0
  299. package/src/stores/editors/CubeNodeDraftRegistry.ts +49 -0
  300. package/src/stores/fixtures/CubeNorthwindModel.ts +355 -0
  301. package/tsconfig.json +118 -0
@@ -0,0 +1,278 @@
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
+ EmitRole,
19
+ type IR,
20
+ lambda,
21
+ type ModelContext,
22
+ type Schema,
23
+ storeAccessor,
24
+ } from '@finos/legend-cube';
25
+ import { V1_EngineServerClient, V1_RenderStyle } from '@finos/legend-graph';
26
+ import {
27
+ type PlainObject,
28
+ stringifyLosslessJSON,
29
+ type TracerService,
30
+ } from '@finos/legend-shared';
31
+ import {
32
+ type AccessorPath,
33
+ type CubeEngine,
34
+ CubeEngineError,
35
+ CubeEngineErrorKind,
36
+ type CubeModelOutline,
37
+ type CubeResult,
38
+ type NodeId,
39
+ } from '../../../CubeEngine.js';
40
+ import {
41
+ V1_buildCubeEngineError,
42
+ V1_toCubeEngineError,
43
+ } from './V1_CubeEngineErrors.js';
44
+ import {
45
+ V1_CubeUnreadableResultError,
46
+ V1_readCubeExecutionResult,
47
+ } from './V1_CubeExecutionResultReader.js';
48
+ import { V1_serializeCubeLambda } from './V1_CubeLambdaSerializer.js';
49
+ import { V1_buildCubeModelOutline } from './V1_CubeModelOutlineBuilder.js';
50
+ import { V1_buildCubeSchema } from './V1_CubeRelationTypeAdapter.js';
51
+
52
+ /** The engine client's configuration, as the host gives it (legend-graph doesn't export its type) */
53
+ export type V1_CubeEngineConfig = ConstructorParameters<
54
+ typeof V1_EngineServerClient
55
+ >[0];
56
+
57
+ /** The only model kind the slice runs: Pure text (PLAN §6.2.2) */
58
+ const TEXT_MODEL_TYPE = 'text';
59
+
60
+ const EXECUTION_CLIENT_VERSION = 'vX_X_X';
61
+
62
+ /**
63
+ * The node an execution lambda runs: the one its `from` call is stamped with
64
+ * (`{| <relation>->limit(…)->from(runtime)}`), where errors without a stamp go
65
+ */
66
+ const captureNodeOf = (executionLambda: IR): NodeId | undefined => {
67
+ const from =
68
+ executionLambda.k === 'lambda' ? executionLambda.body[0] : undefined;
69
+ return from?.k === 'func' ? from.origin?.nodeId : undefined;
70
+ };
71
+
72
+ /** The message for a model of a kind this version can't run (PLAN §8.7) */
73
+ export const V1_unsupportedModelMessage = (type: string): string =>
74
+ `This cube's model kind "${type}" isn't supported yet.`;
75
+
76
+ /**
77
+ * The Legend engine behind the Cube engine port (PLAN §8.7). It sends the
78
+ * cube's saved model context as it is, lambdas as protocol JSON with lossless
79
+ * numbers, and reads every response itself: the graph manager's wrappers drop
80
+ * type parameters and read numbers lossily (D8).
81
+ */
82
+ export class V1_LegendCubeEngine implements CubeEngine {
83
+ readonly client: V1_EngineServerClient;
84
+
85
+ constructor(config: V1_CubeEngineConfig, tracerService: TracerService) {
86
+ this.client = new V1_EngineServerClient(config);
87
+ // every call throws without one
88
+ this.client.setTracerService(tracerService);
89
+ }
90
+
91
+ /** The model's Pure text, or an unsupported-model error for any other kind */
92
+ private textOf(model: ModelContext, nodeId?: NodeId): string {
93
+ if (model._type !== TEXT_MODEL_TYPE || typeof model.code !== 'string') {
94
+ throw new CubeEngineError(
95
+ CubeEngineErrorKind.UNSUPPORTED_MODEL,
96
+ V1_unsupportedModelMessage(model._type),
97
+ nodeId,
98
+ );
99
+ }
100
+ return model.code;
101
+ }
102
+
103
+ async loadModel(model: ModelContext): Promise<CubeModelOutline> {
104
+ const code = this.textOf(model);
105
+ try {
106
+ return V1_buildCubeModelOutline(
107
+ await this.client.grammarToJSON_model(code),
108
+ );
109
+ } catch (error) {
110
+ throw V1_toCubeEngineError(error, undefined, CubeEngineErrorKind.COMPILE);
111
+ }
112
+ }
113
+
114
+ resolveSchemas(
115
+ model: ModelContext,
116
+ accessors: ReadonlyMap<NodeId, AccessorPath>,
117
+ ): Promise<Map<NodeId, Schema | CubeEngineError>> {
118
+ return this.typeAll(
119
+ model,
120
+ new Map(
121
+ [...accessors].map(([nodeId, path]) => [
122
+ nodeId,
123
+ lambda(
124
+ [],
125
+ [storeAccessor(path, { nodeId, role: EmitRole.ACCESSOR })],
126
+ ),
127
+ ]),
128
+ ),
129
+ );
130
+ }
131
+
132
+ typeLambdas(
133
+ model: ModelContext,
134
+ lambdas: ReadonlyMap<NodeId, IR>,
135
+ ): Promise<Map<NodeId, Schema | CubeEngineError>> {
136
+ return this.typeAll(model, lambdas);
137
+ }
138
+
139
+ /** Types every lambda in one batch call: one entry per key, whatever fails */
140
+ private async typeAll(
141
+ model: ModelContext,
142
+ lambdas: ReadonlyMap<NodeId, IR>,
143
+ ): Promise<Map<NodeId, Schema | CubeEngineError>> {
144
+ const typed = new Map<NodeId, Schema | CubeEngineError>();
145
+ if (!lambdas.size) {
146
+ return typed;
147
+ }
148
+ const failAll = (error: unknown): Map<NodeId, CubeEngineError> =>
149
+ new Map(
150
+ [...lambdas.keys()].map((nodeId) => [
151
+ nodeId,
152
+ V1_toCubeEngineError(error, nodeId, CubeEngineErrorKind.COMPILE),
153
+ ]),
154
+ );
155
+ let response: PlainObject;
156
+ try {
157
+ this.textOf(model);
158
+ const body = stringifyLosslessJSON({
159
+ model,
160
+ lambdas: Object.fromEntries(
161
+ [...lambdas].map(([nodeId, ir]) => [
162
+ nodeId,
163
+ V1_serializeCubeLambda(ir),
164
+ ]),
165
+ ),
166
+ });
167
+ // sent as text, so numbers keep every digit; the client sends a string body as it is
168
+ response = (await this.client.batchLambdasRelationType(
169
+ body as unknown as PlainObject,
170
+ )) as unknown as PlainObject;
171
+ } catch (error) {
172
+ return failAll(error);
173
+ }
174
+ // the engine answers `result`; legend-graph's response type says `results` (LG-1)
175
+ const results = (response.result ?? response.results ?? {}) as PlainObject;
176
+ const errors = (response.errors ?? {}) as PlainObject;
177
+ // own keys only: a node id like `__proto__` mustn't read Object.prototype
178
+ lambdas.forEach((_, nodeId) => {
179
+ const relationType = Object.hasOwn(results, nodeId)
180
+ ? results[nodeId]
181
+ : undefined;
182
+ if (relationType) {
183
+ try {
184
+ typed.set(nodeId, V1_buildCubeSchema(relationType as PlainObject));
185
+ } catch (error) {
186
+ typed.set(
187
+ nodeId,
188
+ new CubeEngineError(
189
+ CubeEngineErrorKind.COMPILE,
190
+ (error as Error).message,
191
+ nodeId,
192
+ ),
193
+ );
194
+ }
195
+ return;
196
+ }
197
+ typed.set(
198
+ nodeId,
199
+ V1_buildCubeEngineError(
200
+ Object.hasOwn(errors, nodeId) ? errors[nodeId] : undefined,
201
+ nodeId,
202
+ CubeEngineErrorKind.COMPILE,
203
+ ) ??
204
+ new CubeEngineError(
205
+ CubeEngineErrorKind.NETWORK,
206
+ `The engine gave no type for this node`,
207
+ nodeId,
208
+ ),
209
+ );
210
+ });
211
+ return typed;
212
+ }
213
+
214
+ async execute(
215
+ model: ModelContext,
216
+ executionLambda: IR,
217
+ options?: { abortController?: AbortController | undefined },
218
+ ): Promise<CubeResult> {
219
+ const captureId = captureNodeOf(executionLambda);
220
+ const startedAt = Date.now();
221
+ let text: string;
222
+ try {
223
+ this.textOf(model);
224
+ const body = stringifyLosslessJSON({
225
+ clientVersion: EXECUTION_CLIENT_VERSION,
226
+ function: V1_serializeCubeLambda(executionLambda),
227
+ model,
228
+ context: { _type: 'BaseExecutionContext' },
229
+ parameterValues: [],
230
+ });
231
+ // `returnAsResponse` leaves the body unread, so it can be read losslessly
232
+ const response = (await this.client.runQuery(
233
+ body as unknown as PlainObject,
234
+ {
235
+ returnAsResponse: true,
236
+ abortController: options?.abortController,
237
+ },
238
+ )) as Response;
239
+ text = await response.text();
240
+ } catch (error) {
241
+ throw V1_toCubeEngineError(
242
+ error,
243
+ captureId,
244
+ CubeEngineErrorKind.EXECUTION,
245
+ );
246
+ }
247
+ try {
248
+ return {
249
+ ...V1_readCubeExecutionResult(text),
250
+ durationMs: Date.now() - startedAt,
251
+ };
252
+ } catch (error) {
253
+ if (error instanceof V1_CubeUnreadableResultError) {
254
+ throw new CubeEngineError(
255
+ CubeEngineErrorKind.EXECUTION,
256
+ error.message,
257
+ captureId,
258
+ );
259
+ }
260
+ throw error;
261
+ }
262
+ }
263
+
264
+ async renderPure(lambdaIR: IR): Promise<string> {
265
+ try {
266
+ // sent as text, as typing and execution are: the serialized lambda holds
267
+ // lossless numbers, which plain JSON.stringify would write as objects
268
+ return await this.client.JSONToGrammar_lambda(
269
+ stringifyLosslessJSON(
270
+ V1_serializeCubeLambda(lambdaIR),
271
+ ) as unknown as PlainObject,
272
+ V1_RenderStyle.PRETTY,
273
+ );
274
+ } catch (error) {
275
+ throw V1_toCubeEngineError(error, undefined, CubeEngineErrorKind.COMPILE);
276
+ }
277
+ }
278
+ }
@@ -0,0 +1,124 @@
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 { jest } from '@jest/globals';
18
+ import { ENGINE_TEST_SUPPORT__grammarToJSON_model } from '@finos/legend-graph/test';
19
+ import {
20
+ NetworkClientError,
21
+ type PlainObject,
22
+ TracerService,
23
+ } from '@finos/legend-shared';
24
+ import { AxiosError } from 'axios';
25
+ import {
26
+ CUBE_ENGINE_TEST__execute,
27
+ CUBE_ENGINE_TEST__jsonToGrammar_lambda,
28
+ CUBE_ENGINE_TEST__lambdaRelationTypeBatch,
29
+ } from '../../../../../__test-utils__/CubeEngineTestSupport.js';
30
+ import { V1_LegendCubeEngine } from '../V1_LegendCubeEngine.js';
31
+
32
+ // The real Cube engine, its client's calls routed to the engine on :6300 by
33
+ // Cube's own test helpers (PLAN §3.4): the test environment refuses network
34
+ // calls, and the execute helper hands back the body unread, so the lossless
35
+ // reader runs as in the browser. Every helper fails as the client does.
36
+
37
+ /** A failed call, as the engine client throws it: a `NetworkClientError` with the engine's payload */
38
+ const clientError = (status: number, payload: unknown): NetworkClientError =>
39
+ new NetworkClientError(
40
+ {
41
+ status,
42
+ statusText: String(status),
43
+ url: 'http://localhost:6300/api',
44
+ } as Response,
45
+ payload as NetworkClientError['payload'],
46
+ );
47
+
48
+ /** The payload of a failed call, as the client reads it: JSON when it parses, else its text */
49
+ const parseOrText = (text: string): unknown => {
50
+ try {
51
+ return JSON.parse(text);
52
+ } catch {
53
+ return text;
54
+ }
55
+ };
56
+
57
+ /** A helper's non-2xx response, rethrown as the client throws it */
58
+ const rethrowAsClientError = (error: unknown): never => {
59
+ if (error instanceof AxiosError && error.response) {
60
+ const data: unknown = error.response.data;
61
+ throw clientError(
62
+ error.response.status,
63
+ typeof data === 'string' ? parseOrText(data) : data,
64
+ );
65
+ }
66
+ throw error;
67
+ };
68
+
69
+ export const V1_createEngineBackedCubeEngine = (): {
70
+ engine: V1_LegendCubeEngine;
71
+ calls: Record<
72
+ 'grammarToJSON_model' | 'batchLambdasRelationType' | 'runQuery',
73
+ jest.Mock
74
+ >;
75
+ } => {
76
+ const engine = new V1_LegendCubeEngine(
77
+ { baseUrl: 'http://localhost:6300/api' },
78
+ new TracerService(),
79
+ );
80
+ const { client } = engine;
81
+ const grammarToJSON_model = jest
82
+ .spyOn(client, 'grammarToJSON_model')
83
+ .mockImplementation(
84
+ async (code: string) =>
85
+ (await ENGINE_TEST_SUPPORT__grammarToJSON_model(code).catch(
86
+ rethrowAsClientError,
87
+ )) as PlainObject,
88
+ );
89
+ const batchLambdasRelationType = jest
90
+ .spyOn(client, 'batchLambdasRelationType')
91
+ .mockImplementation(
92
+ async (input) =>
93
+ (await CUBE_ENGINE_TEST__lambdaRelationTypeBatch(input).catch(
94
+ rethrowAsClientError,
95
+ )) as never,
96
+ );
97
+ const runQuery = jest
98
+ .spyOn(client, 'runQuery')
99
+ .mockImplementation(async (input) => {
100
+ const response = await CUBE_ENGINE_TEST__execute(
101
+ input as unknown as string,
102
+ );
103
+ if (!response.ok) {
104
+ throw clientError(response.status, parseOrText(await response.text()));
105
+ }
106
+ return response as unknown as Response;
107
+ });
108
+ jest
109
+ .spyOn(client, 'JSONToGrammar_lambda')
110
+ .mockImplementation(async (lambda, renderStyle) =>
111
+ CUBE_ENGINE_TEST__jsonToGrammar_lambda(lambda, renderStyle).catch(
112
+ rethrowAsClientError,
113
+ ),
114
+ );
115
+ return {
116
+ engine,
117
+ calls: {
118
+ grammarToJSON_model: grammarToJSON_model as unknown as jest.Mock,
119
+ batchLambdasRelationType:
120
+ batchLambdasRelationType as unknown as jest.Mock,
121
+ runQuery: runQuery as unknown as jest.Mock,
122
+ },
123
+ };
124
+ };
package/src/index.ts ADDED
@@ -0,0 +1,41 @@
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
+ export {
18
+ LEGEND_CUBE_COMMAND_CONFIG,
19
+ LEGEND_CUBE_COMMAND_KEY,
20
+ } from './__lib__/LegendCubeCommand.js';
21
+ export { LEGEND_CUBE_TEST_ID } from './__lib__/LegendCubeTesting.js';
22
+ export { CubeEditor } from './components/CubeEditor.js';
23
+
24
+ export * from './graph-manager/CubeEngine.js';
25
+ export { getRuntimesForDatabase } from './graph-manager/CubeModelOutlineHelper.js';
26
+ export {
27
+ buildCubeEngine,
28
+ type CubeEngineConfig,
29
+ } from './graph-manager/protocol/pure/CubeEngineBuilder.js';
30
+ export type { CubeHost } from './stores/CubeHost.js';
31
+ export {
32
+ BUNDLED_MODELS,
33
+ type BundledModel,
34
+ createTextModel,
35
+ LocalModelCatalog,
36
+ } from './stores/LocalModelCatalog.js';
37
+ export {
38
+ CUBE_NORTHWIND_DATABASE,
39
+ CUBE_NORTHWIND_MODEL,
40
+ CUBE_NORTHWIND_RUNTIME,
41
+ } from './stores/fixtures/CubeNorthwindModel.js';