@finos/legend-application-repl 0.0.28 → 0.0.30

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 (245) hide show
  1. package/grammar/datacube_filter__lexer.g4 +40 -0
  2. package/grammar/datacube_filter__parser.g4 +14 -0
  3. package/grammar/generateGrammar.js +43 -0
  4. package/grammar/parser/generated/datacube_filter__lexer.interp +59 -0
  5. package/grammar/parser/generated/datacube_filter__lexer.tokens +14 -0
  6. package/grammar/parser/generated/datacube_filter__lexer.ts +142 -0
  7. package/grammar/parser/generated/datacube_filter__parser.interp +38 -0
  8. package/grammar/parser/generated/datacube_filter__parser.tokens +14 -0
  9. package/grammar/parser/generated/datacube_filter__parser.ts +514 -0
  10. package/grammar/parser/parser.ts +55 -0
  11. package/lib/components/Core_LegendREPLApplicationPlugin.d.ts.map +1 -1
  12. package/lib/components/Core_LegendREPLApplicationPlugin.js +0 -7
  13. package/lib/components/Core_LegendREPLApplicationPlugin.js.map +1 -1
  14. package/lib/components/LegendREPLApplication.d.ts +0 -1
  15. package/lib/components/LegendREPLApplication.d.ts.map +1 -1
  16. package/lib/components/LegendREPLFrameworkProvider.d.ts +0 -1
  17. package/lib/components/LegendREPLFrameworkProvider.d.ts.map +1 -1
  18. package/lib/components/REPLStoreProvider.d.ts +1 -1
  19. package/lib/components/REPLStoreProvider.d.ts.map +1 -1
  20. package/lib/components/REPLStoreProvider.js +1 -1
  21. package/lib/components/REPLStoreProvider.js.map +1 -1
  22. package/lib/components/dataCube/DataCube.d.ts.map +1 -1
  23. package/lib/components/dataCube/DataCube.js +15 -4
  24. package/lib/components/dataCube/DataCube.js.map +1 -1
  25. package/lib/components/dataCube/editor/DataCubeEditor.d.ts +2 -4
  26. package/lib/components/dataCube/editor/DataCubeEditor.d.ts.map +1 -1
  27. package/lib/components/dataCube/editor/DataCubeEditor.js +109 -32
  28. package/lib/components/dataCube/editor/DataCubeEditor.js.map +1 -1
  29. package/lib/components/dataCube/editor/DataCubeEditorCodePanel.d.ts +1 -1
  30. package/lib/components/dataCube/editor/DataCubeEditorCodePanel.d.ts.map +1 -1
  31. package/lib/components/dataCube/editor/DataCubeEditorCodePanel.js +178 -104
  32. package/lib/components/dataCube/editor/DataCubeEditorCodePanel.js.map +1 -1
  33. package/lib/components/dataCube/editor/{DataCubeEditorSortPanel.d.ts → DataCubeEditorColumnPropertiesPanel.d.ts} +2 -5
  34. package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.d.ts.map +1 -0
  35. package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.js +27 -0
  36. package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.js.map +1 -0
  37. package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.d.ts +19 -0
  38. package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.d.ts.map +1 -0
  39. package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.js +27 -0
  40. package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.js.map +1 -0
  41. package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.d.ts +22 -0
  42. package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.d.ts.map +1 -0
  43. package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.js +230 -0
  44. package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.js.map +1 -0
  45. package/lib/components/dataCube/editor/DataCubeEditorExtendedColumnsPanel.d.ts +19 -0
  46. package/lib/components/dataCube/editor/DataCubeEditorExtendedColumnsPanel.d.ts.map +1 -0
  47. package/lib/components/dataCube/editor/DataCubeEditorExtendedColumnsPanel.js +27 -0
  48. package/lib/components/dataCube/editor/DataCubeEditorExtendedColumnsPanel.js.map +1 -0
  49. package/lib/components/dataCube/editor/DataCubeEditorFilterPanel.d.ts +19 -0
  50. package/lib/components/dataCube/editor/DataCubeEditorFilterPanel.d.ts.map +1 -0
  51. package/lib/components/dataCube/editor/DataCubeEditorFilterPanel.js +27 -0
  52. package/lib/components/dataCube/editor/DataCubeEditorFilterPanel.js.map +1 -0
  53. package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.d.ts +19 -0
  54. package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.d.ts.map +1 -0
  55. package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.js +27 -0
  56. package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.js.map +1 -0
  57. package/lib/components/dataCube/editor/DataCubeEditorHPivotsPanel.d.ts +19 -0
  58. package/lib/components/dataCube/editor/DataCubeEditorHPivotsPanel.d.ts.map +1 -0
  59. package/lib/components/dataCube/editor/DataCubeEditorHPivotsPanel.js +27 -0
  60. package/lib/components/dataCube/editor/DataCubeEditorHPivotsPanel.js.map +1 -0
  61. package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.d.ts +19 -0
  62. package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.d.ts.map +1 -0
  63. package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.js +26 -0
  64. package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.js.map +1 -0
  65. package/lib/components/dataCube/editor/DataCubeEditorVPivotsPanel.d.ts +19 -0
  66. package/lib/components/dataCube/editor/DataCubeEditorVPivotsPanel.d.ts.map +1 -0
  67. package/lib/components/dataCube/editor/DataCubeEditorVPivotsPanel.js +27 -0
  68. package/lib/components/dataCube/editor/DataCubeEditorVPivotsPanel.js.map +1 -0
  69. package/lib/components/dataCube/grid/DataCubeGrid.d.ts +1 -4
  70. package/lib/components/dataCube/grid/DataCubeGrid.d.ts.map +1 -1
  71. package/lib/components/dataCube/grid/DataCubeGrid.js +75 -30
  72. package/lib/components/dataCube/grid/DataCubeGrid.js.map +1 -1
  73. package/lib/grammar/generated/datacube_filter__lexer.d.ts +31 -0
  74. package/lib/grammar/generated/datacube_filter__lexer.js +118 -0
  75. package/lib/grammar/generated/datacube_filter__parser.d.ts +91 -0
  76. package/lib/grammar/generated/datacube_filter__parser.js +485 -0
  77. package/lib/grammar/parser.d.ts +16 -0
  78. package/lib/grammar/parser.js +39 -0
  79. package/lib/index.css +2 -2
  80. package/lib/index.css.map +1 -1
  81. package/lib/package.json +9 -6
  82. package/lib/server/REPLServerClient.d.ts +2 -3
  83. package/lib/server/REPLServerClient.d.ts.map +1 -1
  84. package/lib/server/models/DataCubeEngineModels.d.ts +8 -1
  85. package/lib/server/models/DataCubeEngineModels.d.ts.map +1 -1
  86. package/lib/server/models/DataCubeEngineModels.js +13 -0
  87. package/lib/server/models/DataCubeEngineModels.js.map +1 -1
  88. package/lib/stores/dataCube/DataCubeDefaultConfig.d.ts +17 -0
  89. package/lib/stores/dataCube/DataCubeDefaultConfig.d.ts.map +1 -0
  90. package/lib/stores/dataCube/DataCubeDefaultConfig.js +17 -0
  91. package/lib/stores/dataCube/DataCubeDefaultConfig.js.map +1 -0
  92. package/lib/stores/dataCube/DataCubeState.d.ts +6 -6
  93. package/lib/stores/dataCube/DataCubeState.d.ts.map +1 -1
  94. package/lib/stores/dataCube/DataCubeState.js +18 -14
  95. package/lib/stores/dataCube/DataCubeState.js.map +1 -1
  96. package/lib/stores/dataCube/{DataCubeStore.d.ts → REPLStore.d.ts} +1 -1
  97. package/lib/stores/dataCube/REPLStore.d.ts.map +1 -0
  98. package/lib/stores/dataCube/{DataCubeStore.js → REPLStore.js} +1 -1
  99. package/lib/stores/dataCube/REPLStore.js.map +1 -0
  100. package/lib/stores/dataCube/core/DataCubeCoreState.d.ts +29 -0
  101. package/lib/stores/dataCube/core/DataCubeCoreState.d.ts.map +1 -0
  102. package/lib/stores/dataCube/core/DataCubeCoreState.js +46 -0
  103. package/lib/stores/dataCube/core/DataCubeCoreState.js.map +1 -0
  104. package/lib/stores/dataCube/core/DataCubeEngine.d.ts +2 -3
  105. package/lib/stores/dataCube/core/DataCubeEngine.d.ts.map +1 -1
  106. package/lib/stores/dataCube/core/DataCubeEngine.js +2 -3
  107. package/lib/stores/dataCube/core/DataCubeEngine.js.map +1 -1
  108. package/lib/stores/dataCube/core/DataCubeQueryBuilder.d.ts +27 -3
  109. package/lib/stores/dataCube/core/DataCubeQueryBuilder.d.ts.map +1 -1
  110. package/lib/stores/dataCube/core/DataCubeQueryBuilder.js +210 -278
  111. package/lib/stores/dataCube/core/DataCubeQueryBuilder.js.map +1 -1
  112. package/lib/stores/dataCube/core/DataCubeQueryEngine.d.ts +72 -0
  113. package/lib/stores/dataCube/core/DataCubeQueryEngine.d.ts.map +1 -0
  114. package/lib/stores/dataCube/core/DataCubeQueryEngine.js +67 -0
  115. package/lib/stores/dataCube/core/DataCubeQueryEngine.js.map +1 -0
  116. package/lib/stores/dataCube/core/DataCubeQuerySnapshot.d.ts +73 -38
  117. package/lib/stores/dataCube/core/DataCubeQuerySnapshot.d.ts.map +1 -1
  118. package/lib/stores/dataCube/core/DataCubeQuerySnapshot.js +101 -40
  119. package/lib/stores/dataCube/core/DataCubeQuerySnapshot.js.map +1 -1
  120. package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.d.ts +32 -0
  121. package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.d.ts.map +1 -0
  122. package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.js +232 -0
  123. package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.js.map +1 -0
  124. package/lib/stores/dataCube/core/DataCubeQuerySnapshotManager.d.ts +8 -2
  125. package/lib/stores/dataCube/core/DataCubeQuerySnapshotManager.d.ts.map +1 -1
  126. package/lib/stores/dataCube/core/DataCubeQuerySnapshotManager.js +20 -5
  127. package/lib/stores/dataCube/core/DataCubeQuerySnapshotManager.js.map +1 -1
  128. package/lib/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.d.ts +8 -3
  129. package/lib/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.d.ts.map +1 -1
  130. package/lib/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.js +8 -4
  131. package/lib/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.js.map +1 -1
  132. package/lib/stores/dataCube/editor/{DataCubeEditorCodeState.d.ts → DataCubeEditorCodePanelState.d.ts} +6 -5
  133. package/lib/stores/dataCube/editor/DataCubeEditorCodePanelState.d.ts.map +1 -0
  134. package/lib/stores/dataCube/editor/{DataCubeEditorCodeState.js → DataCubeEditorCodePanelState.js} +7 -7
  135. package/lib/stores/dataCube/editor/DataCubeEditorCodePanelState.js.map +1 -0
  136. package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.d.ts +30 -0
  137. package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.d.ts.map +1 -0
  138. package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.js +51 -0
  139. package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.js.map +1 -0
  140. package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.d.ts +29 -0
  141. package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.d.ts.map +1 -0
  142. package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.js +63 -0
  143. package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.js.map +1 -0
  144. package/lib/stores/dataCube/editor/{DataCubeEditorQuerySnapshotBuilder.d.ts → DataCubeEditorPanelState.d.ts} +2 -2
  145. package/lib/stores/dataCube/editor/DataCubeEditorPanelState.d.ts.map +1 -0
  146. package/lib/stores/dataCube/editor/{DataCubeEditorQuerySnapshotBuilder.js → DataCubeEditorPanelState.js} +1 -1
  147. package/lib/stores/dataCube/editor/DataCubeEditorPanelState.js.map +1 -0
  148. package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.d.ts +34 -0
  149. package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.d.ts.map +1 -0
  150. package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.js +67 -0
  151. package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.js.map +1 -0
  152. package/lib/stores/dataCube/editor/DataCubeEditorState.d.ts +10 -7
  153. package/lib/stores/dataCube/editor/DataCubeEditorState.d.ts.map +1 -1
  154. package/lib/stores/dataCube/editor/DataCubeEditorState.js +25 -17
  155. package/lib/stores/dataCube/editor/DataCubeEditorState.js.map +1 -1
  156. package/lib/stores/dataCube/grid/DataCubeGridClientEngine.d.ts +13 -7
  157. package/lib/stores/dataCube/grid/DataCubeGridClientEngine.d.ts.map +1 -1
  158. package/lib/stores/dataCube/grid/DataCubeGridClientEngine.js +87 -86
  159. package/lib/stores/dataCube/grid/DataCubeGridClientEngine.js.map +1 -1
  160. package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.d.ts +20 -0
  161. package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.d.ts.map +1 -0
  162. package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.js +103 -0
  163. package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.js.map +1 -0
  164. package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.d.ts +7 -1
  165. package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.d.ts.map +1 -1
  166. package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.js +121 -214
  167. package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.js.map +1 -1
  168. package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.d.ts +25 -0
  169. package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.d.ts.map +1 -0
  170. package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.js +83 -0
  171. package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.js.map +1 -0
  172. package/lib/stores/dataCube/grid/DataCubeGridState.d.ts +6 -5
  173. package/lib/stores/dataCube/grid/DataCubeGridState.d.ts.map +1 -1
  174. package/lib/stores/dataCube/grid/DataCubeGridState.js +32 -10
  175. package/lib/stores/dataCube/grid/DataCubeGridState.js.map +1 -1
  176. package/package.json +15 -12
  177. package/src/components/Core_LegendREPLApplicationPlugin.tsx +0 -7
  178. package/src/components/REPLStoreProvider.tsx +1 -1
  179. package/src/components/dataCube/DataCube.tsx +51 -29
  180. package/src/components/dataCube/editor/DataCubeEditor.tsx +204 -95
  181. package/src/components/dataCube/editor/DataCubeEditorCodePanel.tsx +186 -190
  182. package/src/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.tsx +42 -0
  183. package/src/components/dataCube/editor/DataCubeEditorColumnsPanel.tsx +41 -0
  184. package/src/components/dataCube/editor/DataCubeEditorColumnsSelector.tsx +408 -0
  185. package/src/components/dataCube/editor/DataCubeEditorExtendedColumnsPanel.tsx +41 -0
  186. package/src/components/dataCube/editor/DataCubeEditorFilterPanel.tsx +41 -0
  187. package/src/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.tsx +48 -0
  188. package/src/components/dataCube/editor/DataCubeEditorHPivotsPanel.tsx +41 -0
  189. package/src/components/dataCube/editor/DataCubeEditorSortsPanel.tsx +41 -0
  190. package/src/components/dataCube/editor/DataCubeEditorVPivotsPanel.tsx +41 -0
  191. package/src/components/dataCube/grid/DataCubeGrid.tsx +134 -43
  192. package/src/server/REPLServerClient.ts +2 -2
  193. package/src/server/models/DataCubeEngineModels.ts +23 -1
  194. package/{lib/grid.css → src/stores/dataCube/DataCubeDefaultConfig.ts} +2 -2
  195. package/src/stores/dataCube/DataCubeState.ts +26 -20
  196. package/src/stores/dataCube/core/DataCubeCoreState.ts +57 -0
  197. package/src/stores/dataCube/core/DataCubeEngine.ts +6 -4
  198. package/src/stores/dataCube/core/DataCubeQueryBuilder.ts +349 -353
  199. package/src/stores/dataCube/core/DataCubeQueryEngine.ts +90 -0
  200. package/src/stores/dataCube/core/DataCubeQuerySnapshot.ts +168 -156
  201. package/src/stores/dataCube/core/DataCubeQuerySnapshotBuilder.ts +398 -0
  202. package/src/stores/dataCube/core/DataCubeQuerySnapshotManager.ts +37 -5
  203. package/src/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.ts +13 -5
  204. package/src/stores/dataCube/editor/{DataCubeEditorCodeState.ts → DataCubeEditorCodePanelState.ts} +6 -6
  205. package/src/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.ts +61 -0
  206. package/src/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.ts +80 -0
  207. package/src/stores/dataCube/editor/{DataCubeEditorQuerySnapshotBuilder.ts → DataCubeEditorPanelState.ts} +1 -1
  208. package/src/stores/dataCube/editor/DataCubeEditorSortsPanelState.ts +116 -0
  209. package/src/stores/dataCube/editor/DataCubeEditorState.ts +29 -20
  210. package/src/stores/dataCube/grid/DataCubeGridClientEngine.ts +96 -128
  211. package/src/stores/dataCube/grid/DataCubeGridQueryBuilder.ts +154 -0
  212. package/src/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.tsx +191 -0
  213. package/src/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.ts +127 -0
  214. package/src/stores/dataCube/grid/DataCubeGridState.ts +41 -14
  215. package/tsconfig.json +23 -9
  216. package/lib/components/dataCube/editor/DataCubeEditorSortPanel.d.ts.map +0 -1
  217. package/lib/components/dataCube/editor/DataCubeEditorSortPanel.js +0 -61
  218. package/lib/components/dataCube/editor/DataCubeEditorSortPanel.js.map +0 -1
  219. package/lib/grid.css.map +0 -1
  220. package/lib/repl.css +0 -17
  221. package/lib/repl.css.map +0 -1
  222. package/lib/stores/dataCube/DataCubeMetaModelConst.d.ts +0 -63
  223. package/lib/stores/dataCube/DataCubeMetaModelConst.d.ts.map +0 -1
  224. package/lib/stores/dataCube/DataCubeMetaModelConst.js +0 -72
  225. package/lib/stores/dataCube/DataCubeMetaModelConst.js.map +0 -1
  226. package/lib/stores/dataCube/DataCubeStore.d.ts.map +0 -1
  227. package/lib/stores/dataCube/DataCubeStore.js.map +0 -1
  228. package/lib/stores/dataCube/core/DataCubeQueryAnalyzer.d.ts +0 -37
  229. package/lib/stores/dataCube/core/DataCubeQueryAnalyzer.d.ts.map +0 -1
  230. package/lib/stores/dataCube/core/DataCubeQueryAnalyzer.js +0 -269
  231. package/lib/stores/dataCube/core/DataCubeQueryAnalyzer.js.map +0 -1
  232. package/lib/stores/dataCube/editor/DataCubeEditorCodeState.d.ts.map +0 -1
  233. package/lib/stores/dataCube/editor/DataCubeEditorCodeState.js.map +0 -1
  234. package/lib/stores/dataCube/editor/DataCubeEditorQuerySnapshotBuilder.d.ts.map +0 -1
  235. package/lib/stores/dataCube/editor/DataCubeEditorQuerySnapshotBuilder.js.map +0 -1
  236. package/lib/stores/dataCube/editor/DataCubeEditorSortState.d.ts +0 -46
  237. package/lib/stores/dataCube/editor/DataCubeEditorSortState.d.ts.map +0 -1
  238. package/lib/stores/dataCube/editor/DataCubeEditorSortState.js +0 -133
  239. package/lib/stores/dataCube/editor/DataCubeEditorSortState.js.map +0 -1
  240. package/src/components/dataCube/editor/DataCubeEditorSortPanel.tsx +0 -274
  241. package/src/stores/dataCube/DataCubeMetaModelConst.ts +0 -76
  242. package/src/stores/dataCube/core/DataCubeQueryAnalyzer.ts +0 -424
  243. package/src/stores/dataCube/editor/DataCubeEditorSortState.ts +0 -198
  244. package/src/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.ts +0 -281
  245. /package/src/stores/dataCube/{DataCubeStore.ts → REPLStore.ts} +0 -0
@@ -0,0 +1,398 @@
1
+ /**
2
+ * Copyright (c) 2020-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
+ /***************************************************************************************
18
+ * [CORE]
19
+ *
20
+ * These are utilities used to build the query snapshot from the executable query.
21
+ * This is needed when we initialize the application by loading a persisted query.
22
+ ***************************************************************************************/
23
+
24
+ import {
25
+ V1_AppliedFunction,
26
+ V1_CInteger,
27
+ V1_ClassInstance,
28
+ V1_ColSpec,
29
+ V1_ColSpecArray,
30
+ V1_Collection,
31
+ V1_serializeValueSpecification,
32
+ extractElementNameFromPath as _name,
33
+ matchFunctionName,
34
+ type V1_ValueSpecification,
35
+ } from '@finos/legend-graph';
36
+ import type { DataCubeQuery } from '../../../server/models/DataCubeQuery.js';
37
+ import {
38
+ DataCubeQuerySnapshot,
39
+ DataCubeQuerySnapshotSortDirection,
40
+ type DataCubeQuerySnapshotColumn,
41
+ } from './DataCubeQuerySnapshot.js';
42
+ import {
43
+ assertTrue,
44
+ assertType,
45
+ guaranteeNonNullable,
46
+ guaranteeType,
47
+ type Clazz,
48
+ } from '@finos/legend-shared';
49
+ import {
50
+ DataCubeFunction,
51
+ type DataCubeQueryFunctionMap,
52
+ } from './DataCubeQueryEngine.js';
53
+
54
+ // --------------------------------- UTILITIES ---------------------------------
55
+
56
+ function _param<T extends V1_ValueSpecification>(
57
+ func: V1_AppliedFunction,
58
+ paramIdx: number,
59
+ clazz: Clazz<T>,
60
+ ): T {
61
+ assertTrue(
62
+ func.parameters.length >= paramIdx + 1,
63
+ `Can't process ${_name(func.function)}: Expected at least ${paramIdx + 1} parameter(s)`,
64
+ );
65
+ return guaranteeType(
66
+ func.parameters[paramIdx],
67
+ clazz,
68
+ `Can't process ${_name(func.function)}: Found unexpected type for parameter at index ${paramIdx}`,
69
+ );
70
+ }
71
+
72
+ function _colSpecParam(func: V1_AppliedFunction, paramIdx: number): V1_ColSpec {
73
+ return guaranteeType(
74
+ _param(func, paramIdx, V1_ClassInstance).value,
75
+ V1_ColSpec,
76
+ `Can't process ${_name(func.function)}: Expected parameter at index ${paramIdx} to be a column specification`,
77
+ );
78
+ }
79
+
80
+ function _colSpecArrayParam(
81
+ func: V1_AppliedFunction,
82
+ paramIdx: number,
83
+ ): V1_ColSpecArray {
84
+ return guaranteeType(
85
+ _param(func, paramIdx, V1_ClassInstance).value,
86
+ V1_ColSpecArray,
87
+ `Can't process ${_name(func.function)}: Expected parameter at index ${paramIdx} to be a column specification list`,
88
+ );
89
+ }
90
+
91
+ function _funcMatch(
92
+ value: V1_ValueSpecification,
93
+ functionNames: string | string[],
94
+ ): V1_AppliedFunction {
95
+ assertType(
96
+ value,
97
+ V1_AppliedFunction,
98
+ `Can't process function: Found unexpected value specification type`,
99
+ );
100
+ assertTrue(
101
+ matchFunctionName(
102
+ value.function,
103
+ Array.isArray(functionNames) ? functionNames : [functionNames],
104
+ ),
105
+ `Can't process function: Expected function name to be one of [${Array.isArray(functionNames) ? functionNames.join(', ') : functionNames}]`,
106
+ );
107
+ return value;
108
+ }
109
+
110
+ // --------------------------------- BUILDING BLOCKS ---------------------------------
111
+
112
+ const _SUPPORTED_TOP_LEVEL_FUNCTIONS: {
113
+ func: string;
114
+ parameters: number;
115
+ }[] = [
116
+ { func: DataCubeFunction.EXTEND, parameters: 1 },
117
+ { func: DataCubeFunction.FILTER, parameters: 1 },
118
+ { func: DataCubeFunction.GROUP_BY, parameters: 3 },
119
+ { func: DataCubeFunction.LIMIT, parameters: 1 },
120
+ { func: DataCubeFunction.PIVOT, parameters: 3 },
121
+ { func: DataCubeFunction.SELECT, parameters: 1 },
122
+ { func: DataCubeFunction.SORT, parameters: 1 },
123
+
124
+ { func: DataCubeFunction.CAST, parameters: 1 },
125
+ ];
126
+
127
+ // NOTE: this corresponds to the sequence:
128
+ // extend()->filter()->groupBy()->select()->pivot()->cast()->extend()->sort()->limit()
129
+ // which represents the ONLY query shape that we currently support
130
+ const _FUNCTION_SEQUENCE_COMPOSITION_PATTERN: {
131
+ func: string;
132
+ repeat?: boolean | undefined;
133
+ required?: boolean | undefined;
134
+ }[] = [
135
+ { func: DataCubeFunction.EXTEND },
136
+ { func: DataCubeFunction.FILTER },
137
+ { func: DataCubeFunction.GROUP_BY },
138
+ { func: DataCubeFunction.PIVOT },
139
+ { func: DataCubeFunction.CAST },
140
+ { func: DataCubeFunction.EXTEND },
141
+ { func: DataCubeFunction.SELECT },
142
+ { func: DataCubeFunction.SORT },
143
+ { func: DataCubeFunction.LIMIT },
144
+ ];
145
+ const _FUNCTION_SEQUENCE_COMPOSITION_PATTERN_REGEXP = new RegExp(
146
+ `^${_FUNCTION_SEQUENCE_COMPOSITION_PATTERN
147
+ .map(
148
+ (entry) =>
149
+ `(?:<${_name(entry.func)}>)${entry.repeat ? '*' : !entry.required ? '?' : ''}`,
150
+ )
151
+ .join('')}$`,
152
+ );
153
+
154
+ /**
155
+ * Since the query created by DataCube will be a chain call of various functions,
156
+ * this utility function will extract that sequence of function calls as well as
157
+ * do various basic checks for the validity, composition, and order of those functions.
158
+ */
159
+ function extractQueryFunctionSequence(query: V1_ValueSpecification) {
160
+ // Make sure this is a sequence of function calls
161
+ if (!(query instanceof V1_AppliedFunction)) {
162
+ throw new Error(
163
+ `Query must be a sequence of function calls (e.g. x()->y()->z())`,
164
+ );
165
+ }
166
+ const sequence: V1_AppliedFunction[] = [];
167
+ let currentQuery = query;
168
+ while (currentQuery instanceof V1_AppliedFunction) {
169
+ const supportedFunc = _SUPPORTED_TOP_LEVEL_FUNCTIONS.find((spec) =>
170
+ matchFunctionName(currentQuery.function, spec.func),
171
+ );
172
+
173
+ // Check that all functions in sequence are supported
174
+ if (!supportedFunc) {
175
+ throw new Error(`Found unsupported function ${currentQuery.function}()`);
176
+ }
177
+ if (currentQuery.parameters.length > supportedFunc.parameters) {
178
+ const vs = currentQuery.parameters[0];
179
+ if (!(vs instanceof V1_AppliedFunction)) {
180
+ throw new Error(
181
+ `Query must be a sequence of function calls (e.g. x()->y()->z())`,
182
+ );
183
+ }
184
+ currentQuery.parameters = currentQuery.parameters.slice(1);
185
+ sequence.unshift(currentQuery);
186
+ currentQuery = vs;
187
+ } else {
188
+ sequence.unshift(currentQuery);
189
+ break;
190
+ }
191
+ }
192
+
193
+ // Check that sequence follows the supported pattern
194
+ const sequenceFormText = sequence
195
+ .map((func) => `<${_name(func.function)}>`)
196
+ .join('');
197
+ if (!sequenceFormText.match(_FUNCTION_SEQUENCE_COMPOSITION_PATTERN_REGEXP)) {
198
+ throw new Error(
199
+ `Unsupported function composition ${sequence.map((fn) => `${_name(fn.function)}()`).join('->')} (supported composition: ${_FUNCTION_SEQUENCE_COMPOSITION_PATTERN.map((entry) => `${_name(entry.func)}()`).join('->')})`,
200
+ );
201
+ }
202
+
203
+ // Special checks
204
+ // Check that the first and second extend() must be separated by either groupBy() or pivot() (i.e. aggregation)
205
+ const firstExtendIndex = sequence.findIndex((func) =>
206
+ matchFunctionName(func.function, DataCubeFunction.EXTEND),
207
+ );
208
+ const secondExtendIndex = sequence.findLastIndex((func) =>
209
+ matchFunctionName(func.function, DataCubeFunction.EXTEND),
210
+ );
211
+ if (firstExtendIndex !== -1 && firstExtendIndex !== secondExtendIndex) {
212
+ const seq = sequence.slice(firstExtendIndex + 1, secondExtendIndex);
213
+ if (
214
+ !seq.some(
215
+ (func) =>
216
+ matchFunctionName(func.function, DataCubeFunction.GROUP_BY) ||
217
+ matchFunctionName(func.function, DataCubeFunction.PIVOT),
218
+ )
219
+ ) {
220
+ throw new Error(
221
+ `Found invalid usage of group-level extend() for query without aggregation such as pivot() and groupBy()`,
222
+ );
223
+ }
224
+ }
225
+
226
+ // Check that pivot() and cast() must co-present and stand consecutively in the sequence
227
+ const pivotFunc = sequence.find((func) =>
228
+ matchFunctionName(func.function, DataCubeFunction.PIVOT),
229
+ );
230
+ const castFunc = sequence.find((func) =>
231
+ matchFunctionName(func.function, DataCubeFunction.CAST),
232
+ );
233
+ if (Boolean(pivotFunc) !== Boolean(castFunc)) {
234
+ throw new Error(`Found usage of dynamic function pivot() without casting`);
235
+ }
236
+
237
+ return sequence;
238
+ }
239
+
240
+ /**
241
+ * Turn the function sequence into a map of available functions
242
+ * for easier construction of the snapshot
243
+ */
244
+ function extractFunctionMap(
245
+ sequence: V1_AppliedFunction[],
246
+ ): DataCubeQueryFunctionMap {
247
+ let leafExtend: V1_AppliedFunction | undefined = undefined;
248
+ let groupExtend: V1_AppliedFunction | undefined = undefined;
249
+ const aggregationFuncIndex = sequence.findLastIndex((func) =>
250
+ matchFunctionName(func.function, [
251
+ DataCubeFunction.PIVOT,
252
+ DataCubeFunction.GROUP_BY,
253
+ ]),
254
+ );
255
+ const firstExtendIndex = sequence.findIndex((func) =>
256
+ matchFunctionName(func.function, DataCubeFunction.EXTEND),
257
+ );
258
+ const secondExtendIndex = sequence.findLastIndex((func) =>
259
+ matchFunctionName(func.function, DataCubeFunction.EXTEND),
260
+ );
261
+ if (aggregationFuncIndex !== -1) {
262
+ if (firstExtendIndex !== secondExtendIndex) {
263
+ leafExtend = sequence[firstExtendIndex];
264
+ groupExtend = sequence[secondExtendIndex];
265
+ }
266
+ } else {
267
+ if (firstExtendIndex !== -1) {
268
+ leafExtend = sequence[firstExtendIndex];
269
+ }
270
+ }
271
+
272
+ const filter = sequence.find((func) =>
273
+ matchFunctionName(func.function, DataCubeFunction.FILTER),
274
+ );
275
+ const groupBy = sequence.find((func) =>
276
+ matchFunctionName(func.function, DataCubeFunction.GROUP_BY),
277
+ );
278
+ const select = sequence.find((func) =>
279
+ matchFunctionName(func.function, DataCubeFunction.SELECT),
280
+ );
281
+ const pivot = sequence.find((func) =>
282
+ matchFunctionName(func.function, DataCubeFunction.PIVOT),
283
+ );
284
+ const cast = sequence.find((func) =>
285
+ matchFunctionName(func.function, DataCubeFunction.CAST),
286
+ );
287
+ const sort = sequence.find((func) =>
288
+ matchFunctionName(func.function, DataCubeFunction.SORT),
289
+ );
290
+ const limit = sequence.find((func) =>
291
+ matchFunctionName(func.function, DataCubeFunction.LIMIT),
292
+ );
293
+ return {
294
+ leafExtend,
295
+ filter,
296
+ groupBy,
297
+ pivot,
298
+ pivotCast: cast,
299
+ groupExtend,
300
+ select,
301
+ sort,
302
+ limit,
303
+ };
304
+ }
305
+
306
+ // --------------------------------- MAIN ---------------------------------
307
+
308
+ /**
309
+ * Analyze the partial query to build a query snapshot.
310
+ *
311
+ * Implementation-wise, this extracts the function call sequence, then walk the
312
+ * sequence in order to fill in the information for the snapshot.
313
+ */
314
+ export function validateAndBuildQuerySnapshot(
315
+ partialQuery: V1_ValueSpecification,
316
+ sourceQuery: V1_ValueSpecification,
317
+ baseQuery: DataCubeQuery,
318
+ ) {
319
+ // --------------------------------- BASE ---------------------------------
320
+ // Build the function call sequence and the function map to make the
321
+ // analysis more ergonomic
322
+
323
+ const sequence = extractQueryFunctionSequence(partialQuery);
324
+ const funcMap = extractFunctionMap(sequence);
325
+ const snapshot = DataCubeQuerySnapshot.create(
326
+ baseQuery.name,
327
+ baseQuery.source.runtime,
328
+ V1_serializeValueSpecification(sourceQuery, []),
329
+ baseQuery.configuration,
330
+ );
331
+ const data = snapshot.data;
332
+ const colsMap = new Map<string, DataCubeQuerySnapshotColumn>();
333
+ const _col = (colSpec: V1_ColSpec) =>
334
+ guaranteeNonNullable(colsMap.get(colSpec.name));
335
+
336
+ // --------------------------------- SOURCE ---------------------------------
337
+
338
+ data.originalColumns = baseQuery.source.columns;
339
+ data.originalColumns.map((col) => colsMap.set(col.name, col));
340
+
341
+ // --------------------------------- LEAF EXTEND ---------------------------------
342
+ // TODO: @akphi - implement this
343
+
344
+ // --------------------------------- FILTER ---------------------------------
345
+ // TODO: @akphi - implement this
346
+
347
+ // --------------------------------- GROUP BY ---------------------------------
348
+ // TODO: @akphi - implement this
349
+
350
+ // --------------------------------- PIVOT ---------------------------------
351
+ // TODO: @akphi - implement this
352
+
353
+ // --------------------------------- CAST ---------------------------------
354
+ // TODO: @akphi - implement this
355
+
356
+ // --------------------------------- GROUP EXTEND ---------------------------------
357
+ // TODO: @akphi - implement this
358
+
359
+ // --------------------------------- SORT ---------------------------------
360
+
361
+ if (funcMap.sort) {
362
+ data.sortColumns = _param(funcMap.sort, 0, V1_Collection).values.map(
363
+ (value) => {
364
+ const sortColFunc = _funcMatch(value, [
365
+ DataCubeFunction.ASC,
366
+ DataCubeFunction.DESC,
367
+ ]);
368
+ return {
369
+ ..._col(_colSpecParam(sortColFunc, 0)),
370
+ direction:
371
+ _name(sortColFunc.function) === DataCubeFunction.ASC
372
+ ? DataCubeQuerySnapshotSortDirection.ASCENDING
373
+ : DataCubeQuerySnapshotSortDirection.DESCENDING,
374
+ };
375
+ },
376
+ );
377
+ }
378
+
379
+ // --------------------------------- SELECT ---------------------------------
380
+
381
+ if (funcMap.select) {
382
+ data.selectColumns = _colSpecArrayParam(funcMap.select, 0).colSpecs.map(
383
+ (colSpec) => ({
384
+ ..._col(colSpec),
385
+ }),
386
+ );
387
+ }
388
+
389
+ // --------------------------------- LIMIT ---------------------------------
390
+
391
+ if (funcMap.limit) {
392
+ const value = funcMap.limit.parameters[0];
393
+ assertType(value, V1_CInteger);
394
+ data.limit = value.value;
395
+ }
396
+
397
+ return snapshot;
398
+ }
@@ -19,21 +19,26 @@ import type { DataCubeState } from '../DataCubeState.js';
19
19
  import type { DataCubeQuerySnapshot } from './DataCubeQuerySnapshot.js';
20
20
  import type { DataCubeQuerySnapshotSubscriber } from './DataCubeQuerySnapshotSubscriber.js';
21
21
  import {
22
+ IllegalStateError,
22
23
  LogEvent,
23
24
  assertErrorThrown,
24
25
  guaranteeNonNullable,
25
26
  } from '@finos/legend-shared';
27
+ import type { DataCubeQuery } from '../../../server/models/DataCubeQuery.js';
26
28
 
27
29
  // TODO: use this when we implement undo/redo
28
30
  // const DATA_CUBE_MAX_SNAPSHOT_COUNT = 100;
29
31
 
30
32
  export class DataCubeQuerySnapshotManager {
31
- private readonly dataCubeState: DataCubeState;
33
+ private readonly dataCube: DataCubeState;
32
34
  private readonly subscribers: DataCubeQuerySnapshotSubscriber[] = [];
33
35
  private readonly snapshots: DataCubeQuerySnapshot[] = [];
34
36
 
35
- constructor(dataCubeState: DataCubeState) {
36
- this.dataCubeState = dataCubeState;
37
+ private _initialSnapshot: DataCubeQuerySnapshot | undefined;
38
+ private _initialQuery: DataCubeQuery | undefined;
39
+
40
+ constructor(dataCube: DataCubeState) {
41
+ this.dataCube = dataCube;
37
42
  }
38
43
 
39
44
  get currentSnapshot(): DataCubeQuerySnapshot {
@@ -44,6 +49,33 @@ export class DataCubeQuerySnapshotManager {
44
49
  this.subscribers.push(subscriber);
45
50
  }
46
51
 
52
+ initialize(
53
+ initialSnapshot: DataCubeQuerySnapshot,
54
+ initialQuery: DataCubeQuery,
55
+ ): void {
56
+ if (this._initialSnapshot || this._initialQuery) {
57
+ throw new IllegalStateError(
58
+ `Snapshot manager has already been initialized`,
59
+ );
60
+ }
61
+ this._initialSnapshot = initialSnapshot;
62
+ this._initialQuery = initialQuery;
63
+ }
64
+
65
+ get initialSnapshot(): DataCubeQuerySnapshot {
66
+ return guaranteeNonNullable(
67
+ this._initialSnapshot,
68
+ `Snapshot manager has not been initialized`,
69
+ );
70
+ }
71
+
72
+ get initialQuery(): DataCubeQuery {
73
+ return guaranteeNonNullable(
74
+ this._initialQuery,
75
+ `Snapshot manager has not been initialized`,
76
+ );
77
+ }
78
+
47
79
  broadcastSnapshot(snapshot: DataCubeQuerySnapshot): void {
48
80
  this.snapshots.push(snapshot);
49
81
  this.subscribers.forEach((subscriber) => {
@@ -51,11 +83,11 @@ export class DataCubeQuerySnapshotManager {
51
83
  if (currentSnapshot?.uuid !== snapshot.uuid) {
52
84
  subscriber.receiveSnapshot(snapshot).catch((error: unknown) => {
53
85
  assertErrorThrown(error);
54
- this.dataCubeState.applicationStore.logService.error(
86
+ this.dataCube.application.logService.error(
55
87
  LogEvent.create(
56
88
  APPLICATION_EVENT.ILLEGAL_APPLICATION_STATE_OCCURRED,
57
89
  ),
58
- `Error ocurred when subscribers receive and apply new snapshot should be handled gracefully`,
90
+ `Subscribers receiving and applying new snapshot should be handled gracefully`,
59
91
  error,
60
92
  );
61
93
  });
@@ -14,18 +14,26 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ import type { LegendREPLApplicationStore } from '../../LegendREPLBaseStore.js';
18
+ import type { DataCubeState } from '../DataCubeState.js';
19
+ import type { DataCubeEngine } from './DataCubeEngine.js';
17
20
  import type { DataCubeQuerySnapshot } from './DataCubeQuerySnapshot.js';
18
- import type { DataCubeQuerySnapshotManager } from './DataCubeQuerySnapshotManager.js';
19
21
 
20
22
  export abstract class DataCubeQuerySnapshotSubscriber {
21
- readonly manager: DataCubeQuerySnapshotManager;
23
+ readonly dataCube!: DataCubeState;
24
+ readonly application!: LegendREPLApplicationStore;
25
+ readonly engine!: DataCubeEngine;
26
+
22
27
  private latestSnapshot: DataCubeQuerySnapshot | undefined;
23
28
 
24
- constructor(snapshotManager: DataCubeQuerySnapshotManager) {
25
- this.manager = snapshotManager;
29
+ constructor(dataCube: DataCubeState) {
30
+ this.dataCube = dataCube;
31
+ this.application = dataCube.application;
32
+ this.engine = dataCube.engine;
26
33
  }
27
34
 
28
35
  abstract applySnapshot(snapshot: DataCubeQuerySnapshot): Promise<void>;
36
+ abstract initialize(): Promise<void>;
29
37
 
30
38
  async receiveSnapshot(snapshot: DataCubeQuerySnapshot): Promise<void> {
31
39
  this.latestSnapshot = snapshot;
@@ -34,7 +42,7 @@ export abstract class DataCubeQuerySnapshotSubscriber {
34
42
 
35
43
  publishSnapshot(snapshot: DataCubeQuerySnapshot): void {
36
44
  this.latestSnapshot = snapshot;
37
- this.manager.broadcastSnapshot(snapshot);
45
+ this.dataCube.snapshotManager.broadcastSnapshot(snapshot);
38
46
  }
39
47
 
40
48
  getLatestSnapshot(): DataCubeQuerySnapshot | undefined {
@@ -30,7 +30,7 @@ import {
30
30
  V1_ParserError,
31
31
  } from '@finos/legend-graph';
32
32
 
33
- export class DataCubeQueryEditorState {
33
+ class DataCubeQueryEditorState {
34
34
  uuid = uuid();
35
35
  query: string;
36
36
  parserError?: ParserError | undefined;
@@ -77,13 +77,13 @@ export class DataCubeQueryEditorState {
77
77
  }
78
78
  }
79
79
 
80
- export class DataCubeQueryCodeEditorState {
81
- readonly dataCubeState!: DataCubeState;
80
+ export class DataCubeEditorCodePanelState {
81
+ readonly dataCube!: DataCubeState;
82
82
 
83
83
  queryEditorState!: DataCubeQueryEditorState;
84
84
  currentSubQuery?: string | undefined;
85
85
 
86
- constructor(dataCubeState: DataCubeState) {
86
+ constructor(dataCube: DataCubeState) {
87
87
  makeObservable(this, {
88
88
  currentSubQuery: observable,
89
89
  queryEditorState: observable,
@@ -91,7 +91,7 @@ export class DataCubeQueryCodeEditorState {
91
91
  parseQuery: flow,
92
92
  });
93
93
 
94
- this.dataCubeState = dataCubeState;
94
+ this.dataCube = dataCube;
95
95
  this.queryEditorState = new DataCubeQueryEditorState('');
96
96
  }
97
97
 
@@ -103,7 +103,7 @@ export class DataCubeQueryCodeEditorState {
103
103
  try {
104
104
  this.queryEditorState.setParserError(undefined);
105
105
  yield flowResult(
106
- this.dataCubeState.editorStore.client.parseQuery({
106
+ this.dataCube.replStore.client.parseQuery({
107
107
  code: `|${this.queryEditorState.query}`,
108
108
  }),
109
109
  );
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Copyright (c) 2020-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 { makeObservable, observable, action } from 'mobx';
18
+
19
+ export abstract class DataCubeEditorColumnsSelectorColumnState {
20
+ abstract get name(): string;
21
+ }
22
+
23
+ export class DataCubeEditorColumnsSelectorState<
24
+ T extends DataCubeEditorColumnsSelectorColumnState,
25
+ > {
26
+ availableColumns: T[] = [];
27
+ selectedColumns: T[] = [];
28
+ availableColumnsSearchText = '';
29
+ selectedColumnsSearchText = '';
30
+
31
+ constructor() {
32
+ makeObservable(this, {
33
+ availableColumns: observable,
34
+ selectedColumns: observable,
35
+ availableColumnsSearchText: observable,
36
+ selectedColumnsSearchText: observable,
37
+ setAvailableColumns: action,
38
+ setSelectedColumns: action,
39
+ setSelectedColumnsSearchText: action,
40
+ setAvailableColumnsSearchText: action,
41
+ });
42
+ }
43
+
44
+ setAvailableColumns(val: T[]): void {
45
+ this.availableColumns = val
46
+ .slice()
47
+ .sort((a, b) => a.name.localeCompare(b.name));
48
+ }
49
+
50
+ setSelectedColumns(val: T[]): void {
51
+ this.selectedColumns = val;
52
+ }
53
+
54
+ setAvailableColumnsSearchText(val: string): void {
55
+ this.availableColumnsSearchText = val;
56
+ }
57
+
58
+ setSelectedColumnsSearchText(val: string): void {
59
+ this.selectedColumnsSearchText = val;
60
+ }
61
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Copyright (c) 2020-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 { action, makeObservable, observable } from 'mobx';
18
+ import type { DataCubeState } from '../DataCubeState.js';
19
+ import type { DataCubeQuerySnapshot } from '../core/DataCubeQuerySnapshot.js';
20
+ import type { DataCubeQueryEditorPanelState } from './DataCubeEditorPanelState.js';
21
+
22
+ export class DataCubeEditorGeneralPropertiesPanelState
23
+ implements DataCubeQueryEditorPanelState
24
+ {
25
+ readonly dataCube!: DataCubeState;
26
+ name = '';
27
+ limit = -1;
28
+
29
+ constructor(dataCube: DataCubeState) {
30
+ this.dataCube = dataCube;
31
+
32
+ makeObservable(this, {
33
+ name: observable,
34
+ setName: action,
35
+
36
+ limit: observable,
37
+ setLimit: action,
38
+ });
39
+ }
40
+
41
+ setName(val: string): void {
42
+ this.name = val;
43
+ }
44
+
45
+ setLimit(val: number | undefined): void {
46
+ this.limit = Math.round(val === undefined || val < 0 ? -1 : val);
47
+ }
48
+
49
+ applySnaphot(snapshot: DataCubeQuerySnapshot): void {
50
+ this.setName(snapshot.data.name);
51
+ this.setLimit(snapshot.data.limit);
52
+ }
53
+
54
+ buildSnapshot(
55
+ newSnapshot: DataCubeQuerySnapshot,
56
+ baseSnapshot: DataCubeQuerySnapshot,
57
+ ): boolean {
58
+ const data = baseSnapshot.data;
59
+ // name
60
+ if (this.name !== data.name) {
61
+ data.name = this.name;
62
+ return true;
63
+ }
64
+
65
+ // limit
66
+ if (data.limit === undefined) {
67
+ if (this.limit !== -1) {
68
+ data.limit = this.limit;
69
+ return true;
70
+ }
71
+ } else {
72
+ if (this.limit !== data.limit) {
73
+ data.limit = this.limit;
74
+ return true;
75
+ }
76
+ }
77
+
78
+ return false;
79
+ }
80
+ }