@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,807 @@
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
+ buildSchemasAndValidity,
19
+ createNodeRegistry,
20
+ CubeDocument,
21
+ diffSchemas,
22
+ findLostSortOrders,
23
+ MESSAGE_SORT_COLUMNS_CUT,
24
+ MESSAGE_SORT_COLUMNS_DROPPED,
25
+ MESSAGE_SORT_ORDER_LOST,
26
+ type ModelContext,
27
+ type NodeRegistry,
28
+ type Query,
29
+ QueryEmitter,
30
+ type QueryNode,
31
+ RelationalTableSource,
32
+ rereadQueryFilterValues,
33
+ type Schema,
34
+ type SchemaInferenceResult,
35
+ } from '@finos/legend-cube';
36
+ import type { CommandRegistrar } from '@finos/legend-application';
37
+ import type { GeneratorFn } from '@finos/legend-shared';
38
+ import {
39
+ action,
40
+ computed,
41
+ flow,
42
+ flowResult,
43
+ makeObservable,
44
+ observable,
45
+ } from 'mobx';
46
+ import { LEGEND_CUBE_COMMAND_KEY } from '../__lib__/LegendCubeCommand.js';
47
+ import {
48
+ CUBE_EDITOR_CLOSED_REASON,
49
+ DEFAULT_ROW_LIMIT,
50
+ getSchemaDriftWarning,
51
+ getSourceRecheckWarning,
52
+ LEGEND_CUBE_USER_DATA_KEY,
53
+ MAX_UNDO_STEPS,
54
+ } from '../__lib__/LegendCubeLabels.js';
55
+ import {
56
+ CubeEngineError,
57
+ CubeEngineErrorKind,
58
+ type CubeModelOutline,
59
+ } from '../graph-manager/CubeEngine.js';
60
+ import { getDatabaseType } from '../graph-manager/CubeModelOutlineHelper.js';
61
+ import { CubeExecutionState } from './CubeExecutionState.js';
62
+ import type { CubeHost } from './CubeHost.js';
63
+ import { CubeNodeEditorState } from './CubeNodeEditorState.js';
64
+ import { CubeShowPureState } from './CubeShowPureState.js';
65
+ import { CubeSourcePickerState } from './CubeSourcePickerState.js';
66
+ import { CubeSpecTransferState } from './CubeSpecTransferState.js';
67
+
68
+ /** An engine error placed on a node: its first line shows on the node, its detail in the grid */
69
+ export interface CubeHostIssue {
70
+ readonly firstLine: string;
71
+ readonly detail: string;
72
+ }
73
+
74
+ const isValidRowLimit = (value: number | undefined): value is number =>
75
+ value !== undefined && Number.isSafeInteger(value) && value >= 1;
76
+
77
+ /** Focus is where text is typed, so Ctrl+Z is the field's own undo */
78
+ const isTypingText = (): boolean => {
79
+ const element = document.activeElement;
80
+ return (
81
+ element instanceof HTMLInputElement ||
82
+ element instanceof HTMLTextAreaElement ||
83
+ (element instanceof HTMLElement && element.isContentEditable)
84
+ );
85
+ };
86
+
87
+ /**
88
+ * The state of one Cube page (PLAN §7.8). The document is immutable: every
89
+ * edit makes a new one through `applyDocument`, which keeps the previous one
90
+ * for undo. Domain and port values are held by reference, never observed
91
+ * deeply.
92
+ */
93
+ export class CubeEditorState implements CommandRegistrar {
94
+ readonly host: CubeHost;
95
+ /** One registry for inference, emission and the saved spec */
96
+ readonly registry: NodeRegistry;
97
+ readonly execution: CubeExecutionState;
98
+ readonly sourcePicker: CubeSourcePickerState;
99
+ readonly specTransfer: CubeSpecTransferState;
100
+ readonly showPure: CubeShowPureState;
101
+ readonly nodeEditor: CubeNodeEditorState;
102
+
103
+ document: CubeDocument;
104
+ /** Earlier documents, oldest first */
105
+ history: readonly CubeDocument[] = [];
106
+ /** Engine errors by node id: shown with the node's own errors, never part of inference */
107
+ hostIssues: ReadonlyMap<string, CubeHostIssue> = new Map();
108
+ /**
109
+ * Warnings by node key, e.g. a table that changed since the cube was saved:
110
+ * shown on the node, never errors, and gone once the node is replaced
111
+ */
112
+ warnings: ReadonlyMap<number, readonly string[]> = new Map();
113
+ /**
114
+ * The outline of each model the cube used, loaded when an editor needs it,
115
+ * e.g. for the Join's 'type unknown' warning; by reference, never observed
116
+ * deeply
117
+ */
118
+ private modelOutlines: ReadonlyMap<ModelContext, CubeModelOutline> =
119
+ new Map();
120
+ /** Sources sent to the engine to be typed again, until it answers */
121
+ private pendingSources: ReadonlySet<QueryNode> = new Set();
122
+ /** The rows a run returns; kept per user, never in the cube */
123
+ rowLimit: number;
124
+ /** The palette shows icons only; kept per user, never in the cube */
125
+ isPaletteCollapsed: boolean;
126
+ /**
127
+ * The cube was saved by a newer version of Cube: it can be viewed and run,
128
+ * but not changed, undone or exported (Settled before M1.8)
129
+ */
130
+ readOnly = false;
131
+ /** Documents in the undo history that were read-only, so undo restores the flag */
132
+ private readonly readOnlyDocuments = new WeakSet<CubeDocument>();
133
+ /** Documents an import replaced: undoing back to one opens another cube again */
134
+ private readonly importedOver = new WeakSet<CubeDocument>();
135
+
136
+ constructor(host: CubeHost, document = new CubeDocument()) {
137
+ makeObservable<CubeEditorState, 'pendingSources' | 'modelOutlines'>(this, {
138
+ pendingSources: observable.ref,
139
+ modelOutlines: observable.ref,
140
+ modelOutline: computed,
141
+ loadModelOutline: flow,
142
+ document: observable.ref,
143
+ history: observable.ref,
144
+ hostIssues: observable.ref,
145
+ warnings: observable.ref,
146
+ derivedWarnings: computed,
147
+ isResolvingSources: computed,
148
+ rowLimit: observable,
149
+ isPaletteCollapsed: observable,
150
+ readOnly: observable,
151
+ analysis: computed,
152
+ emitter: computed,
153
+ canUndo: computed,
154
+ isDialogOpen: computed,
155
+ applyDocument: action,
156
+ undo: action,
157
+ importDocument: action,
158
+ reresolveSources: flow,
159
+ refreshSource: flow,
160
+ applyQuery: action,
161
+ select: action,
162
+ connect: action,
163
+ addNode: action,
164
+ addConfiguredNode: action,
165
+ dropNode: action,
166
+ removeNode: action,
167
+ swapInputs: action,
168
+ setShowGraph: action,
169
+ setPaletteCollapsed: action,
170
+ setHostIssue: action,
171
+ clearHostIssues: action,
172
+ setRowLimit: action,
173
+ });
174
+ this.host = host;
175
+ this.registry = createNodeRegistry();
176
+ this.document = document;
177
+ const storedLimit = host.applicationStore.userDataService.getNumericValue(
178
+ LEGEND_CUBE_USER_DATA_KEY.ROW_LIMIT,
179
+ );
180
+ this.rowLimit = isValidRowLimit(storedLimit)
181
+ ? storedLimit
182
+ : DEFAULT_ROW_LIMIT;
183
+ this.isPaletteCollapsed =
184
+ host.applicationStore.userDataService.getBooleanValue(
185
+ LEGEND_CUBE_USER_DATA_KEY.PALETTE_COLLAPSED,
186
+ ) ?? false;
187
+ this.execution = new CubeExecutionState(this);
188
+ this.sourcePicker = new CubeSourcePickerState(this);
189
+ this.specTransfer = new CubeSpecTransferState(this);
190
+ this.showPure = new CubeShowPureState(this);
191
+ this.nodeEditor = new CubeNodeEditorState(this);
192
+ }
193
+
194
+ /** Each node's schema and errors, query-level rules included, as the emitter sees them */
195
+ get analysis(): SchemaInferenceResult {
196
+ return buildSchemasAndValidity(
197
+ this.document.query,
198
+ this.registry.queryRules,
199
+ );
200
+ }
201
+
202
+ get emitter(): QueryEmitter {
203
+ return new QueryEmitter(this.document.query, this.registry);
204
+ }
205
+
206
+ /** The cube shown has tables being typed again, after an import */
207
+ get isResolvingSources(): boolean {
208
+ return this.document.query.nodes.some((node) =>
209
+ this.pendingSources.has(node),
210
+ );
211
+ }
212
+
213
+ /** The source is being typed again by the engine, e.g. after an import */
214
+ isPendingSource(node: QueryNode): boolean {
215
+ return this.pendingSources.has(node);
216
+ }
217
+
218
+ /**
219
+ * Warnings worked out from the query, by node id: a Sort whose order is
220
+ * lost before it is used (PLAN §11.4). Never stored and never errors, so
221
+ * Execute stays enabled; they go as soon as the query no longer loses it.
222
+ * A partial loss names each node that removes some of the Sort's columns,
223
+ * then the columns that came after a removed one. A loss waits until the
224
+ * Sort and every node it names have no errors, e.g. a Restrict just added,
225
+ * with no column yet: their own errors come first.
226
+ */
227
+ get derivedWarnings(): ReadonlyMap<string, readonly string[]> {
228
+ const { validity, schemas } = this.analysis;
229
+ const isValid = (nodeId: string): boolean =>
230
+ validity.get(nodeId)?.length === 0;
231
+ const { query } = this.document;
232
+ return new Map(
233
+ Array.from(findLostSortOrders(query, undefined, schemas))
234
+ .filter(
235
+ ([sortId, loss]) =>
236
+ isValid(sortId) &&
237
+ isValid(loss.nodeId) &&
238
+ (loss.removals ?? []).every(({ nodeId }) => isValid(nodeId)),
239
+ )
240
+ .map(([sortId, loss]) => [
241
+ sortId,
242
+ loss.removals
243
+ ? [
244
+ ...loss.removals.map(({ nodeId, columns }) =>
245
+ MESSAGE_SORT_COLUMNS_DROPPED(columns, nodeId),
246
+ ),
247
+ ...(loss.cutColumns?.length
248
+ ? [MESSAGE_SORT_COLUMNS_CUT(loss.cutColumns)]
249
+ : []),
250
+ ]
251
+ : [MESSAGE_SORT_ORDER_LOST(loss.nodeId)],
252
+ ]),
253
+ );
254
+ }
255
+
256
+ /** A node's warnings: the stored ones (by key), then the derived ones (by id) */
257
+ getNodeWarnings(node: QueryNode): readonly string[] {
258
+ return [
259
+ ...(this.warnings.get(node.key) ?? []),
260
+ ...(this.derivedWarnings.get(node.id) ?? []),
261
+ ];
262
+ }
263
+
264
+ /**
265
+ * The node's errors, each once: its own and those of the query rules, then
266
+ * the first line of the engine's error on it
267
+ */
268
+ getNodeErrors(nodeId: string): readonly string[] {
269
+ const hostIssue = this.hostIssues.get(nodeId);
270
+ return [
271
+ ...new Set([
272
+ ...(this.analysis.validity.get(nodeId) ?? []),
273
+ ...(hostIssue ? [hostIssue.firstLine] : []),
274
+ ]),
275
+ ];
276
+ }
277
+
278
+ /** The outline of the cube's model, once an editor has loaded it */
279
+ get modelOutline(): CubeModelOutline | undefined {
280
+ const model = this.document.context?.model;
281
+ return model === undefined ? undefined : this.getModelOutline(model);
282
+ }
283
+
284
+ /** The outline of a model, once loaded */
285
+ getModelOutline(model: ModelContext): CubeModelOutline | undefined {
286
+ return this.modelOutlines.get(model);
287
+ }
288
+
289
+ /**
290
+ * The database type a run of the query up to the node needs, with the
291
+ * model's runtime (PLAN §11.4), from the model's outline once it is loaded
292
+ * (`loadModelOutline`): the type of the runtime's connections to the
293
+ * databases the node reads. None without an outline, which writes every
294
+ * operation the native way.
295
+ */
296
+ getRunDatabaseType(
297
+ query: Query,
298
+ nodeId: string,
299
+ model: ModelContext,
300
+ runtime: string,
301
+ ): string | undefined {
302
+ const outline = this.getModelOutline(model);
303
+ if (!outline) {
304
+ return undefined;
305
+ }
306
+ const databases = new Set<string>();
307
+ const visit = (id: string): void => {
308
+ const node = query.getNode(id);
309
+ if (node instanceof RelationalTableSource) {
310
+ databases.add(node.database);
311
+ }
312
+ query
313
+ .getInputIds(id)
314
+ .forEach((inputId) => inputId !== undefined && visit(inputId));
315
+ };
316
+ visit(nodeId);
317
+ return getDatabaseType(outline, runtime, [...databases]);
318
+ }
319
+
320
+ /**
321
+ * Loads the outline of a model, the cube's by default, once per model. It
322
+ * only adds warnings and database types, so a model that fails to load
323
+ * shows none and runs every operation the native way.
324
+ */
325
+ *loadModelOutline(
326
+ model: ModelContext | undefined = this.document.context?.model,
327
+ ): GeneratorFn<void> {
328
+ if (model === undefined || this.modelOutlines.has(model)) {
329
+ return;
330
+ }
331
+ try {
332
+ const outline = (yield this.host.modelCatalog.loadOutline(
333
+ model,
334
+ )) as CubeModelOutline;
335
+ this.modelOutlines = new Map([...this.modelOutlines, [model, outline]]);
336
+ } catch {
337
+ // no outline, no warning: nothing is blocked on it
338
+ }
339
+ }
340
+
341
+ /** One of Cube's dialogs is open: the source picker, Import or Export, Show Pure */
342
+ get isDialogOpen(): boolean {
343
+ return (
344
+ this.sourcePicker.isOpen ||
345
+ this.specTransfer.mode !== undefined ||
346
+ this.showPure.isOpen
347
+ );
348
+ }
349
+
350
+ /**
351
+ * The page's keyboard shortcuts, while it is open (spec §17.12). Each does
352
+ * nothing when its button can't be used, and nothing while a Cube dialog
353
+ * is open, since a dialog doesn't stop the app's shortcuts (user's choice,
354
+ * 2026-10-07). Undo leaves Ctrl+Z to a text field that has the focus.
355
+ */
356
+ registerCommands(): void {
357
+ const { commandService, alertUnhandledError } = this.host.applicationStore;
358
+ commandService.registerCommand({
359
+ key: LEGEND_CUBE_COMMAND_KEY.EXECUTE,
360
+ trigger: () =>
361
+ !this.isDialogOpen &&
362
+ this.execution.canExecute &&
363
+ !this.execution.isRunning,
364
+ action: () => {
365
+ flowResult(this.execution.execute()).catch(alertUnhandledError);
366
+ },
367
+ });
368
+ commandService.registerCommand({
369
+ key: LEGEND_CUBE_COMMAND_KEY.UNDO,
370
+ trigger: () => !this.isDialogOpen && this.canUndo && !isTypingText(),
371
+ action: () => this.undo(),
372
+ });
373
+ }
374
+
375
+ deregisterCommands(): void {
376
+ Object.values(LEGEND_CUBE_COMMAND_KEY).forEach((key) =>
377
+ this.host.applicationStore.commandService.deregisterCommand(key),
378
+ );
379
+ }
380
+
381
+ get canUndo(): boolean {
382
+ return this.history.length > 0 && !this.readOnly;
383
+ }
384
+
385
+ /** The one way to change the cube; the document before goes to the undo history */
386
+ applyDocument(next: CubeDocument): void {
387
+ if (next === this.document) {
388
+ return;
389
+ }
390
+ this.pushHistory();
391
+ this.replaceDocument(next);
392
+ }
393
+
394
+ /**
395
+ * Opens another cube in place of this one, e.g. an imported spec: one undo
396
+ * step. Stops any run and any table being added, closes the node editor
397
+ * without applying its edits, and drops the last run's rows and errors,
398
+ * which belong to the cube before. Never runs the cube.
399
+ */
400
+ importDocument(next: CubeDocument, readOnly: boolean): void {
401
+ this.pushHistory();
402
+ this.importedOver.add(this.document);
403
+ this.execution.reset();
404
+ this.sourcePicker.close();
405
+ this.nodeEditor.discard(CUBE_EDITOR_CLOSED_REASON.CUBE_REPLACED);
406
+ this.hostIssues = new Map();
407
+ // warnings are kept: they are by node key, which the imported nodes don't
408
+ // share, and Undo brings back the nodes they belong to
409
+ this.document = next;
410
+ this.readOnly = readOnly;
411
+ flowResult(this.reresolveSources()).catch(
412
+ this.host.applicationStore.alertUnhandledError,
413
+ );
414
+ }
415
+
416
+ /**
417
+ * Types the cube's tables again, in one engine call, outside the undo
418
+ * history (PLAN §10.3, Settled before M1.8):
419
+ * - a table whose columns are the saved ones is left as it is;
420
+ * - a table that changed takes its new columns, with a warning listing the
421
+ * changes;
422
+ * - a table with saved columns that can't be typed keeps them, with a
423
+ * warning; one without them shows the engine's error.
424
+ *
425
+ * Then filter values saved as invalid text are read again against the
426
+ * columns. The answer goes to every document holding the very source
427
+ * objects that were typed: the cube shown and the undo snapshots taken
428
+ * meanwhile, so undoing an edit made while the tables were typed keeps
429
+ * them typed. A source the user changed meanwhile is a new object, and is
430
+ * left alone.
431
+ *
432
+ * `only` types just these sources of the cube shown, e.g. one Refresh. A
433
+ * table found unchanged loses any earlier warning.
434
+ */
435
+ *reresolveSources(
436
+ only?: readonly RelationalTableSource[],
437
+ ): GeneratorFn<void> {
438
+ const { context, query } = this.document;
439
+ const sources = (only ?? query.nodes).filter(
440
+ (node): node is RelationalTableSource =>
441
+ node instanceof RelationalTableSource &&
442
+ query.getNode(node.id) === node,
443
+ );
444
+ if (!context || !sources.length) {
445
+ return;
446
+ }
447
+ this.pendingSources = new Set([...this.pendingSources, ...sources]);
448
+ let answers: ReadonlyMap<string, Schema | CubeEngineError>;
449
+ try {
450
+ answers = (yield this.host.engine.resolveSchemas(
451
+ context.model,
452
+ new Map(
453
+ sources.map((source) => [
454
+ source.id,
455
+ [source.database, source.schema, source.table],
456
+ ]),
457
+ ),
458
+ )) as Map<string, Schema | CubeEngineError>;
459
+ } catch (error) {
460
+ const failure =
461
+ error instanceof CubeEngineError
462
+ ? error
463
+ : new CubeEngineError(
464
+ CubeEngineErrorKind.NETWORK,
465
+ error instanceof Error ? error.message : String(error),
466
+ );
467
+ answers = new Map(sources.map((source) => [source.id, failure]));
468
+ } finally {
469
+ this.pendingSources = new Set(
470
+ [...this.pendingSources].filter(
471
+ (node) => !sources.includes(node as RelationalTableSource),
472
+ ),
473
+ );
474
+ }
475
+ const warnings = new Map(this.warnings);
476
+ /** Each typed source, by the object that was sent, and what replaces it */
477
+ const replacements = new Map<
478
+ RelationalTableSource,
479
+ RelationalTableSource
480
+ >();
481
+ sources.forEach((source) => {
482
+ const answer =
483
+ answers.get(source.id) ??
484
+ new CubeEngineError(
485
+ CubeEngineErrorKind.COMPILE,
486
+ 'The engine gave no schema for this table',
487
+ source.id,
488
+ );
489
+ const saved =
490
+ source.resolution.kind === 'resolved'
491
+ ? source.resolution.schema
492
+ : undefined;
493
+ if (answer instanceof CubeEngineError) {
494
+ if (saved) {
495
+ warnings.set(source.key, [getSourceRecheckWarning(answer.firstLine)]);
496
+ } else if (
497
+ source.resolution.kind !== 'failed' ||
498
+ source.resolution.message !== answer.detail
499
+ ) {
500
+ // a table that fails as it did before is left as it is
501
+ replacements.set(
502
+ source,
503
+ source.withResolution({ kind: 'failed', message: answer.detail }),
504
+ );
505
+ }
506
+ return;
507
+ }
508
+ if (saved?.isIdenticalTo(answer)) {
509
+ warnings.delete(source.key);
510
+ return;
511
+ }
512
+ const resolved = source.withResolution({
513
+ kind: 'resolved',
514
+ schema: answer,
515
+ });
516
+ if (saved) {
517
+ warnings.set(resolved.key, [
518
+ getSchemaDriftWarning(diffSchemas(saved, answer)),
519
+ ]);
520
+ }
521
+ replacements.set(source, resolved);
522
+ });
523
+ this.warnings = warnings;
524
+ if (!replacements.size) {
525
+ return;
526
+ }
527
+ // documents that shared a query share its checked one, so an undo
528
+ // between them still finds the query unchanged
529
+ const checkedQueries = new Map<Query, Query>();
530
+ const check = (document: CubeDocument): CubeDocument => {
531
+ let checked = checkedQueries.get(document.query);
532
+ if (checked === undefined) {
533
+ let replaced = document.query;
534
+ replacements.forEach((resolved, source) => {
535
+ if (replaced.getNode(source.id) === source) {
536
+ replaced = replaced.replace(resolved);
537
+ }
538
+ });
539
+ checked =
540
+ replaced === document.query
541
+ ? replaced
542
+ : rereadQueryFilterValues(replaced, this.registry.queryRules);
543
+ checkedQueries.set(document.query, checked);
544
+ }
545
+ if (checked === document.query) {
546
+ return document;
547
+ }
548
+ const next = document.withQuery(checked);
549
+ if (this.readOnlyDocuments.has(document)) {
550
+ this.readOnlyDocuments.add(next);
551
+ }
552
+ if (this.importedOver.has(document)) {
553
+ this.importedOver.add(next);
554
+ }
555
+ return next;
556
+ };
557
+ this.history = this.history.map(check);
558
+ const next = check(this.document);
559
+ if (next !== this.document) {
560
+ this.replaceDocument(next);
561
+ }
562
+ }
563
+
564
+ /**
565
+ * Types a table again with the engine, from its Source panel (spec §17.6),
566
+ * as a re-check after an import does: no undo step, nothing changes when
567
+ * its columns are the same, and a warning lists any change.
568
+ */
569
+ *refreshSource(nodeId: string): GeneratorFn<void> {
570
+ const source = this.document.query.getNode(nodeId);
571
+ if (source instanceof RelationalTableSource) {
572
+ yield flowResult(this.reresolveSources([source]));
573
+ }
574
+ }
575
+
576
+ /**
577
+ * Restores the document before the last edit; does nothing when there is
578
+ * no history. A restored query is a new object (PLAN §4.3), so rows that
579
+ * ran before the edit show as stale. An edit that left the query alone,
580
+ * such as a rename, keeps it, with its rows and engine errors. Undoing an
581
+ * import closes the node editor and the picker, as the import did.
582
+ */
583
+ undo(): void {
584
+ const previous = this.history.at(-1);
585
+ if (!previous || !this.canUndo) {
586
+ return;
587
+ }
588
+ this.history = this.history.slice(0, -1);
589
+ this.readOnly = this.readOnlyDocuments.has(previous);
590
+ if (this.importedOver.has(previous)) {
591
+ // the cube before an import is another cube, as the import was
592
+ this.sourcePicker.close();
593
+ this.nodeEditor.discard(CUBE_EDITOR_CLOSED_REASON.CUBE_REPLACED);
594
+ }
595
+ const { query } = this.document;
596
+ this.replaceDocument(
597
+ previous.withQuery(
598
+ previous.query === query ? query : previous.query.clone(),
599
+ ),
600
+ );
601
+ }
602
+
603
+ private pushHistory(): void {
604
+ if (this.readOnly) {
605
+ this.readOnlyDocuments.add(this.document);
606
+ }
607
+ this.history = [...this.history, this.document].slice(-MAX_UNDO_STEPS);
608
+ }
609
+
610
+ /** Engine errors belong to the query they came from, so they are dropped when the query changes */
611
+ private replaceDocument(next: CubeDocument): void {
612
+ if (next.query !== this.document.query) {
613
+ this.hostIssues = new Map();
614
+ this.execution.clearError();
615
+ }
616
+ this.document = next;
617
+ }
618
+
619
+ applyQuery(next: Query): void {
620
+ this.applyDocument(this.document.withQuery(next));
621
+ }
622
+
623
+ /** Makes a node the capture node, the one Execute runs */
624
+ select(nodeId: string): void {
625
+ if (this.document.query.canSelect(nodeId)) {
626
+ this.applyQuery(this.document.query.select(nodeId));
627
+ }
628
+ }
629
+
630
+ /**
631
+ * Feeds a node into another, on the port if given, else the first free one.
632
+ * Does nothing when the query doesn't allow it or the cube is read-only.
633
+ */
634
+ connect(sourceId: string, targetId: string, port?: string): void {
635
+ const { query } = this.document;
636
+ if (!this.readOnly && query.canConnect(sourceId, targetId, port)) {
637
+ this.applyQuery(query.connect(sourceId, targetId, port));
638
+ }
639
+ }
640
+
641
+ /**
642
+ * Whether a node of the type can be added: a transform, unconnected or
643
+ * spliced in after `afterId`, when the query allows it; a source only
644
+ * unconnected, through the source picker. Never while the cube is read-only.
645
+ */
646
+ canAddNode(type: string, afterId?: string): boolean {
647
+ const definition = this.registry.get(type);
648
+ if (this.readOnly || !definition) {
649
+ return false;
650
+ }
651
+ if (definition.kind === 'source') {
652
+ return afterId === undefined;
653
+ }
654
+ const { query } = this.document;
655
+ return query.canAdd(definition.create(query.generateId(type)), afterId);
656
+ }
657
+
658
+ /**
659
+ * Adds a node of the type, as the palette and the context menu do (spec
660
+ * §17.4): a transform with its default settings, unconnected or spliced in
661
+ * after `afterId`; a source opens the source picker, which adds it once
662
+ * the engine has typed it. Does nothing `canAddNode` refuses.
663
+ */
664
+ addNode(type: string, afterId?: string): void {
665
+ const definition = this.registry.get(type);
666
+ if (!definition || !this.canAddNode(type, afterId)) {
667
+ return;
668
+ }
669
+ if (definition.kind === 'source') {
670
+ this.sourcePicker.open();
671
+ return;
672
+ }
673
+ const { query } = this.document;
674
+ this.applyQuery(
675
+ query.add(definition.create(query.generateId(type)), afterId),
676
+ );
677
+ }
678
+
679
+ /**
680
+ * Adds a node made elsewhere, with its settings, as the grid's quick
681
+ * actions do (spec §12.4): spliced in after `afterId`, so it becomes the
682
+ * node that runs when that one did, as one undo step. Does nothing in a
683
+ * read-only cube, or when the query can't take it.
684
+ */
685
+ addConfiguredNode(node: QueryNode, afterId?: string): void {
686
+ const { query } = this.document;
687
+ if (this.readOnly || !query.canAdd(node, afterId)) {
688
+ return;
689
+ }
690
+ this.applyQuery(query.add(node, afterId));
691
+ }
692
+
693
+ /** Whether dropping a node on another does anything: connect it, or else move it after it */
694
+ canDropNode(nodeId: string, targetId: string): boolean {
695
+ const { query } = this.document;
696
+ return (
697
+ !this.readOnly &&
698
+ (query.canConnect(nodeId, targetId) || query.canMove(nodeId, targetId))
699
+ );
700
+ }
701
+
702
+ /**
703
+ * Drops a node on another (spec §17.4): it feeds the target's first free
704
+ * port if it can, else it moves to after the target
705
+ */
706
+ dropNode(nodeId: string, targetId: string): void {
707
+ if (!this.canDropNode(nodeId, targetId)) {
708
+ return;
709
+ }
710
+ const { query } = this.document;
711
+ this.applyQuery(
712
+ query.canConnect(nodeId, targetId)
713
+ ? query.connect(nodeId, targetId)
714
+ : query.move(nodeId, targetId),
715
+ );
716
+ }
717
+
718
+ canRemoveNode(nodeId: string): boolean {
719
+ return !this.readOnly && this.document.query.canRemove(nodeId);
720
+ }
721
+
722
+ /**
723
+ * Removes a node, healing the chain around it. Removing the last node also
724
+ * clears the cube's model and runtime, in the same undo step, so the next
725
+ * table can come from any model (user's choice, 2026-10-07).
726
+ */
727
+ removeNode(nodeId: string): void {
728
+ if (!this.canRemoveNode(nodeId)) {
729
+ return;
730
+ }
731
+ // the node editor, if it shows the node, closes by itself
732
+ const query = this.document.query.remove(nodeId);
733
+ this.applyDocument(
734
+ query.isEmpty
735
+ ? this.document.withContext(undefined).withQuery(query)
736
+ : this.document.withQuery(query),
737
+ );
738
+ }
739
+
740
+ canSwapInputs(nodeId: string): boolean {
741
+ return !this.readOnly && this.document.query.canSwapInputs(nodeId);
742
+ }
743
+
744
+ /** Swaps a binary node's two inputs; its settings follow them, e.g. a Join's key columns */
745
+ swapInputs(nodeId: string): void {
746
+ if (this.canSwapInputs(nodeId)) {
747
+ this.applyQuery(this.document.query.swapInputs(nodeId));
748
+ }
749
+ }
750
+
751
+ /**
752
+ * Shows or hides the graph, which the cube saves (spec §17.1). An undoable
753
+ * edit that leaves the query, and so the rows, as they are (M1.8b).
754
+ */
755
+ setShowGraph(showGraph: boolean): void {
756
+ const { meta } = this.document;
757
+ if (meta.presentation.showGraph !== showGraph) {
758
+ this.applyDocument(
759
+ this.document.withMeta({
760
+ ...meta,
761
+ presentation: { ...meta.presentation, showGraph },
762
+ }),
763
+ );
764
+ }
765
+ }
766
+
767
+ setHostIssue(nodeId: string, error: CubeEngineError): void {
768
+ this.hostIssues = new Map([
769
+ ...this.hostIssues,
770
+ [nodeId, { firstLine: error.firstLine, detail: error.detail }],
771
+ ]);
772
+ }
773
+
774
+ clearHostIssues(): void {
775
+ if (this.hostIssues.size) {
776
+ this.hostIssues = new Map();
777
+ }
778
+ }
779
+
780
+ /** Sets and remembers the row limit; a value that isn't a whole number of at least 1 is refused */
781
+ setRowLimit(value: number): boolean {
782
+ if (!isValidRowLimit(value)) {
783
+ return false;
784
+ }
785
+ this.rowLimit = value;
786
+ this.host.applicationStore.userDataService.persistValue(
787
+ LEGEND_CUBE_USER_DATA_KEY.ROW_LIMIT,
788
+ value,
789
+ );
790
+ return true;
791
+ }
792
+
793
+ /** Collapses or expands the palette, and remembers it for the user */
794
+ setPaletteCollapsed(collapsed: boolean): void {
795
+ this.isPaletteCollapsed = collapsed;
796
+ this.host.applicationStore.userDataService.persistValue(
797
+ LEGEND_CUBE_USER_DATA_KEY.PALETTE_COLLAPSED,
798
+ collapsed,
799
+ );
800
+ }
801
+
802
+ /** Stops any run; call when the page closes */
803
+ dispose(): void {
804
+ this.execution.stop();
805
+ this.nodeEditor.dispose();
806
+ }
807
+ }