@finos/legend-cube-builder 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +5 -2
- package/lib/__lib__/LegendCubeCommand.d.ts +26 -0
- package/lib/__lib__/LegendCubeCommand.d.ts.map +1 -0
- package/lib/__lib__/LegendCubeCommand.js +40 -0
- package/lib/__lib__/LegendCubeCommand.js.map +1 -0
- package/lib/__lib__/LegendCubeHelpText.d.ts +19 -0
- package/lib/__lib__/LegendCubeHelpText.d.ts.map +1 -0
- package/lib/__lib__/LegendCubeHelpText.js +27 -0
- package/lib/__lib__/LegendCubeHelpText.js.map +1 -0
- package/lib/__lib__/LegendCubeLabels.d.ts +68 -0
- package/lib/__lib__/LegendCubeLabels.d.ts.map +1 -0
- package/lib/__lib__/LegendCubeLabels.js +109 -0
- package/lib/__lib__/LegendCubeLabels.js.map +1 -0
- package/lib/__lib__/LegendCubeTesting.d.ts +33 -0
- package/lib/__lib__/LegendCubeTesting.d.ts.map +1 -0
- package/lib/__lib__/LegendCubeTesting.js +34 -0
- package/lib/__lib__/LegendCubeTesting.js.map +1 -0
- package/lib/__test-utils__/CubeCanvasTestUtils.d.ts +24 -0
- package/lib/__test-utils__/CubeCanvasTestUtils.d.ts.map +1 -0
- package/lib/__test-utils__/CubeCanvasTestUtils.js +37 -0
- package/lib/__test-utils__/CubeCanvasTestUtils.js.map +1 -0
- package/lib/__test-utils__/CubeEngineTestSupport.d.ts +41 -0
- package/lib/__test-utils__/CubeEngineTestSupport.d.ts.map +1 -0
- package/lib/__test-utils__/CubeEngineTestSupport.js +76 -0
- package/lib/__test-utils__/CubeEngineTestSupport.js.map +1 -0
- package/lib/__test-utils__/CubeNorthwindTestQueries.d.ts +31 -0
- package/lib/__test-utils__/CubeNorthwindTestQueries.d.ts.map +1 -0
- package/lib/__test-utils__/CubeNorthwindTestQueries.js +102 -0
- package/lib/__test-utils__/CubeNorthwindTestQueries.js.map +1 -0
- package/lib/__test-utils__/CubePageTestUtils.d.ts +33 -0
- package/lib/__test-utils__/CubePageTestUtils.d.ts.map +1 -0
- package/lib/__test-utils__/CubePageTestUtils.js +68 -0
- package/lib/__test-utils__/CubePageTestUtils.js.map +1 -0
- package/lib/__test-utils__/CubeTestApplication.d.ts +30 -0
- package/lib/__test-utils__/CubeTestApplication.d.ts.map +1 -0
- package/lib/__test-utils__/CubeTestApplication.js +57 -0
- package/lib/__test-utils__/CubeTestApplication.js.map +1 -0
- package/lib/__test-utils__/FakeCubeEngine.d.ts +41 -0
- package/lib/__test-utils__/FakeCubeEngine.d.ts.map +1 -0
- package/lib/__test-utils__/FakeCubeEngine.js +85 -0
- package/lib/__test-utils__/FakeCubeEngine.js.map +1 -0
- package/lib/components/CubeButton.d.ts +20 -0
- package/lib/components/CubeButton.d.ts.map +1 -0
- package/lib/components/CubeButton.js +24 -0
- package/lib/components/CubeButton.js.map +1 -0
- package/lib/components/CubeEditor.d.ts +31 -0
- package/lib/components/CubeEditor.d.ts.map +1 -0
- package/lib/components/CubeEditor.js +90 -0
- package/lib/components/CubeEditor.js.map +1 -0
- package/lib/components/CubeNodeIcon.d.ts +23 -0
- package/lib/components/CubeNodeIcon.d.ts.map +1 -0
- package/lib/components/CubeNodeIcon.js +32 -0
- package/lib/components/CubeNodeIcon.js.map +1 -0
- package/lib/components/canvas/CubeCanvas.d.ts +37 -0
- package/lib/components/canvas/CubeCanvas.d.ts.map +1 -0
- package/lib/components/canvas/CubeCanvas.js +135 -0
- package/lib/components/canvas/CubeCanvas.js.map +1 -0
- package/lib/components/canvas/CubeCanvasContext.d.ts +19 -0
- package/lib/components/canvas/CubeCanvasContext.d.ts.map +1 -0
- package/lib/components/canvas/CubeCanvasContext.js +22 -0
- package/lib/components/canvas/CubeCanvasContext.js.map +1 -0
- package/lib/components/canvas/CubeCanvasContextMenu.d.ts +28 -0
- package/lib/components/canvas/CubeCanvasContextMenu.d.ts.map +1 -0
- package/lib/components/canvas/CubeCanvasContextMenu.js +35 -0
- package/lib/components/canvas/CubeCanvasContextMenu.js.map +1 -0
- package/lib/components/canvas/CubeCanvasDnd.d.ts +43 -0
- package/lib/components/canvas/CubeCanvasDnd.d.ts.map +1 -0
- package/lib/components/canvas/CubeCanvasDnd.js +51 -0
- package/lib/components/canvas/CubeCanvasDnd.js.map +1 -0
- package/lib/components/canvas/CubeCanvasEdge.d.ts +24 -0
- package/lib/components/canvas/CubeCanvasEdge.d.ts.map +1 -0
- package/lib/components/canvas/CubeCanvasEdge.js +33 -0
- package/lib/components/canvas/CubeCanvasEdge.js.map +1 -0
- package/lib/components/canvas/CubeCanvasElements.d.ts +64 -0
- package/lib/components/canvas/CubeCanvasElements.d.ts.map +1 -0
- package/lib/components/canvas/CubeCanvasElements.js +96 -0
- package/lib/components/canvas/CubeCanvasElements.js.map +1 -0
- package/lib/components/canvas/CubeCanvasLayout.d.ts +32 -0
- package/lib/components/canvas/CubeCanvasLayout.d.ts.map +1 -0
- package/lib/components/canvas/CubeCanvasLayout.js +63 -0
- package/lib/components/canvas/CubeCanvasLayout.js.map +1 -0
- package/lib/components/canvas/CubeCanvasNode.d.ts +29 -0
- package/lib/components/canvas/CubeCanvasNode.d.ts.map +1 -0
- package/lib/components/canvas/CubeCanvasNode.js +72 -0
- package/lib/components/canvas/CubeCanvasNode.js.map +1 -0
- package/lib/components/editors/CubeColumnPicker.d.ts +40 -0
- package/lib/components/editors/CubeColumnPicker.d.ts.map +1 -0
- package/lib/components/editors/CubeColumnPicker.js +51 -0
- package/lib/components/editors/CubeColumnPicker.js.map +1 -0
- package/lib/components/editors/CubeFilterEditor.d.ts +26 -0
- package/lib/components/editors/CubeFilterEditor.d.ts.map +1 -0
- package/lib/components/editors/CubeFilterEditor.js +90 -0
- package/lib/components/editors/CubeFilterEditor.js.map +1 -0
- package/lib/components/editors/CubeJoinEditor.d.ts +26 -0
- package/lib/components/editors/CubeJoinEditor.d.ts.map +1 -0
- package/lib/components/editors/CubeJoinEditor.js +76 -0
- package/lib/components/editors/CubeJoinEditor.js.map +1 -0
- package/lib/components/editors/CubeNodeEditorPanel.d.ts +29 -0
- package/lib/components/editors/CubeNodeEditorPanel.d.ts.map +1 -0
- package/lib/components/editors/CubeNodeEditorPanel.js +71 -0
- package/lib/components/editors/CubeNodeEditorPanel.js.map +1 -0
- package/lib/components/editors/CubeNodeEditorRegistry.d.ts +44 -0
- package/lib/components/editors/CubeNodeEditorRegistry.d.ts.map +1 -0
- package/lib/components/editors/CubeNodeEditorRegistry.js +30 -0
- package/lib/components/editors/CubeNodeEditorRegistry.js.map +1 -0
- package/lib/components/editors/CubeSourceEditor.d.ts +25 -0
- package/lib/components/editors/CubeSourceEditor.d.ts.map +1 -0
- package/lib/components/editors/CubeSourceEditor.js +42 -0
- package/lib/components/editors/CubeSourceEditor.js.map +1 -0
- package/lib/components/editors/CubeValueEditor.d.ts +40 -0
- package/lib/components/editors/CubeValueEditor.d.ts.map +1 -0
- package/lib/components/editors/CubeValueEditor.js +177 -0
- package/lib/components/editors/CubeValueEditor.js.map +1 -0
- package/lib/components/grid/CubeGridRegion.d.ts +23 -0
- package/lib/components/grid/CubeGridRegion.d.ts.map +1 -0
- package/lib/components/grid/CubeGridRegion.js +94 -0
- package/lib/components/grid/CubeGridRegion.js.map +1 -0
- package/lib/components/grid/CubeGridValues.d.ts +25 -0
- package/lib/components/grid/CubeGridValues.d.ts.map +1 -0
- package/lib/components/grid/CubeGridValues.js +95 -0
- package/lib/components/grid/CubeGridValues.js.map +1 -0
- package/lib/components/grid/CubeResultGrid.d.ts +26 -0
- package/lib/components/grid/CubeResultGrid.d.ts.map +1 -0
- package/lib/components/grid/CubeResultGrid.js +50 -0
- package/lib/components/grid/CubeResultGrid.js.map +1 -0
- package/lib/components/palette/CubePalette.d.ts +29 -0
- package/lib/components/palette/CubePalette.d.ts.map +1 -0
- package/lib/components/palette/CubePalette.js +73 -0
- package/lib/components/palette/CubePalette.js.map +1 -0
- package/lib/components/show-pure/CubeShowPureDialog.d.ts +23 -0
- package/lib/components/show-pure/CubeShowPureDialog.d.ts.map +1 -0
- package/lib/components/show-pure/CubeShowPureDialog.js +37 -0
- package/lib/components/show-pure/CubeShowPureDialog.js.map +1 -0
- package/lib/components/source-picker/CubeSourcePicker.d.ts +22 -0
- package/lib/components/source-picker/CubeSourcePicker.d.ts.map +1 -0
- package/lib/components/source-picker/CubeSourcePicker.js +89 -0
- package/lib/components/source-picker/CubeSourcePicker.js.map +1 -0
- package/lib/components/spec-transfer/CubeSpecTransferDialog.d.ts +26 -0
- package/lib/components/spec-transfer/CubeSpecTransferDialog.d.ts.map +1 -0
- package/lib/components/spec-transfer/CubeSpecTransferDialog.js +45 -0
- package/lib/components/spec-transfer/CubeSpecTransferDialog.js.map +1 -0
- package/lib/graph-manager/CubeEngine.d.ts +115 -0
- package/lib/graph-manager/CubeEngine.d.ts.map +1 -0
- package/lib/graph-manager/CubeEngine.js +61 -0
- package/lib/graph-manager/CubeEngine.js.map +1 -0
- package/lib/graph-manager/CubeModelOutlineHelper.d.ts +25 -0
- package/lib/graph-manager/CubeModelOutlineHelper.d.ts.map +1 -0
- package/lib/graph-manager/CubeModelOutlineHelper.js +24 -0
- package/lib/graph-manager/CubeModelOutlineHelper.js.map +1 -0
- package/lib/graph-manager/protocol/pure/CubeEngineBuilder.d.ts +26 -0
- package/lib/graph-manager/protocol/pure/CubeEngineBuilder.d.ts.map +1 -0
- package/lib/graph-manager/protocol/pure/CubeEngineBuilder.js +22 -0
- package/lib/graph-manager/protocol/pure/CubeEngineBuilder.js.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeEngineErrors.d.ts +27 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeEngineErrors.d.ts.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeEngineErrors.js +76 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeEngineErrors.js.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeExecutionResultReader.d.ts +27 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeExecutionResultReader.d.ts.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeExecutionResultReader.js +82 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeExecutionResultReader.js.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.d.ts +32 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.d.ts.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.js +195 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.js.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.d.ts +20 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.d.ts.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.js +121 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.js.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeRelationTypeAdapter.d.ts +24 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeRelationTypeAdapter.d.ts.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeRelationTypeAdapter.js +43 -0
- package/lib/graph-manager/protocol/pure/v1/V1_CubeRelationTypeAdapter.js.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.d.ts +45 -0
- package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.d.ts.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.js +171 -0
- package/lib/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.js.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.d.ts +22 -0
- package/lib/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.d.ts.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.js +79 -0
- package/lib/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.js.map +1 -0
- package/lib/index.css +17 -0
- package/lib/index.css.map +1 -0
- package/lib/index.d.ts +25 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +24 -0
- package/lib/index.js.map +1 -0
- package/lib/stores/CubeEditorState.d.ts +206 -0
- package/lib/stores/CubeEditorState.d.ts.map +1 -0
- package/lib/stores/CubeEditorState.js +551 -0
- package/lib/stores/CubeEditorState.js.map +1 -0
- package/lib/stores/CubeExecutionState.d.ts +67 -0
- package/lib/stores/CubeExecutionState.d.ts.map +1 -0
- package/lib/stores/CubeExecutionState.js +196 -0
- package/lib/stores/CubeExecutionState.js.map +1 -0
- package/lib/stores/CubeHost.d.ts +31 -0
- package/lib/stores/CubeHost.d.ts.map +1 -0
- package/lib/stores/CubeHost.js +17 -0
- package/lib/stores/CubeHost.js.map +1 -0
- package/lib/stores/CubeNodeEditorState.d.ts +85 -0
- package/lib/stores/CubeNodeEditorState.d.ts.map +1 -0
- package/lib/stores/CubeNodeEditorState.js +207 -0
- package/lib/stores/CubeNodeEditorState.js.map +1 -0
- package/lib/stores/CubeShowPureState.d.ts +38 -0
- package/lib/stores/CubeShowPureState.d.ts.map +1 -0
- package/lib/stores/CubeShowPureState.js +83 -0
- package/lib/stores/CubeShowPureState.js.map +1 -0
- package/lib/stores/CubeSourcePickerState.d.ts +98 -0
- package/lib/stores/CubeSourcePickerState.d.ts.map +1 -0
- package/lib/stores/CubeSourcePickerState.js +334 -0
- package/lib/stores/CubeSourcePickerState.js.map +1 -0
- package/lib/stores/CubeSpecTransferState.d.ts +60 -0
- package/lib/stores/CubeSpecTransferState.d.ts.map +1 -0
- package/lib/stores/CubeSpecTransferState.js +167 -0
- package/lib/stores/CubeSpecTransferState.js.map +1 -0
- package/lib/stores/LocalModelCatalog.d.ts +37 -0
- package/lib/stores/LocalModelCatalog.d.ts.map +1 -0
- package/lib/stores/LocalModelCatalog.js +49 -0
- package/lib/stores/LocalModelCatalog.js.map +1 -0
- package/lib/stores/editors/CubeFilterDraft.d.ts +61 -0
- package/lib/stores/editors/CubeFilterDraft.d.ts.map +1 -0
- package/lib/stores/editors/CubeFilterDraft.js +186 -0
- package/lib/stores/editors/CubeFilterDraft.js.map +1 -0
- package/lib/stores/editors/CubeJoinDraft.d.ts +63 -0
- package/lib/stores/editors/CubeJoinDraft.d.ts.map +1 -0
- package/lib/stores/editors/CubeJoinDraft.js +136 -0
- package/lib/stores/editors/CubeJoinDraft.js.map +1 -0
- package/lib/stores/editors/CubeNodeDraft.d.ts +38 -0
- package/lib/stores/editors/CubeNodeDraft.d.ts.map +1 -0
- package/lib/stores/editors/CubeNodeDraft.js +35 -0
- package/lib/stores/editors/CubeNodeDraft.js.map +1 -0
- package/lib/stores/editors/CubeNodeDraftRegistry.d.ts +29 -0
- package/lib/stores/editors/CubeNodeDraftRegistry.d.ts.map +1 -0
- package/lib/stores/editors/CubeNodeDraftRegistry.js +33 -0
- package/lib/stores/editors/CubeNodeDraftRegistry.js.map +1 -0
- package/lib/stores/fixtures/CubeNorthwindModel.d.ts +23 -0
- package/lib/stores/fixtures/CubeNorthwindModel.d.ts.map +1 -0
- package/lib/stores/fixtures/CubeNorthwindModel.js +338 -0
- package/lib/stores/fixtures/CubeNorthwindModel.js.map +1 -0
- package/package.json +81 -3
- package/src/__lib__/LegendCubeCommand.ts +44 -0
- package/src/__lib__/LegendCubeHelpText.ts +38 -0
- package/src/__lib__/LegendCubeLabels.ts +141 -0
- package/src/__lib__/LegendCubeTesting.ts +33 -0
- package/src/__test-utils__/CubeCanvasTestUtils.ts +53 -0
- package/src/__test-utils__/CubeEngineTestSupport.ts +137 -0
- package/src/__test-utils__/CubeNorthwindTestQueries.ts +165 -0
- package/src/__test-utils__/CubePageTestUtils.tsx +96 -0
- package/src/__test-utils__/CubeTestApplication.ts +82 -0
- package/src/__test-utils__/FakeCubeEngine.ts +139 -0
- package/src/components/CubeButton.tsx +35 -0
- package/src/components/CubeEditor.tsx +239 -0
- package/src/components/CubeNodeIcon.tsx +47 -0
- package/src/components/canvas/CubeCanvas.tsx +260 -0
- package/src/components/canvas/CubeCanvasContext.ts +31 -0
- package/src/components/canvas/CubeCanvasContextMenu.tsx +89 -0
- package/src/components/canvas/CubeCanvasDnd.ts +82 -0
- package/src/components/canvas/CubeCanvasEdge.tsx +57 -0
- package/src/components/canvas/CubeCanvasElements.ts +150 -0
- package/src/components/canvas/CubeCanvasLayout.ts +88 -0
- package/src/components/canvas/CubeCanvasNode.tsx +141 -0
- package/src/components/editors/CubeColumnPicker.tsx +114 -0
- package/src/components/editors/CubeFilterEditor.tsx +309 -0
- package/src/components/editors/CubeJoinEditor.tsx +224 -0
- package/src/components/editors/CubeNodeEditorPanel.tsx +204 -0
- package/src/components/editors/CubeNodeEditorRegistry.ts +61 -0
- package/src/components/editors/CubeSourceEditor.tsx +116 -0
- package/src/components/editors/CubeValueEditor.tsx +332 -0
- package/src/components/grid/CubeGridRegion.tsx +274 -0
- package/src/components/grid/CubeGridValues.ts +125 -0
- package/src/components/grid/CubeResultGrid.tsx +84 -0
- package/src/components/palette/CubePalette.tsx +177 -0
- package/src/components/show-pure/CubeShowPureDialog.tsx +101 -0
- package/src/components/source-picker/CubeSourcePicker.tsx +304 -0
- package/src/components/spec-transfer/CubeSpecTransferDialog.tsx +157 -0
- package/src/graph-manager/CubeEngine.ts +155 -0
- package/src/graph-manager/CubeModelOutlineHelper.ts +32 -0
- package/src/graph-manager/protocol/pure/CubeEngineBuilder.ts +34 -0
- package/src/graph-manager/protocol/pure/v1/V1_CubeEngineErrors.ts +109 -0
- package/src/graph-manager/protocol/pure/v1/V1_CubeExecutionResultReader.ts +115 -0
- package/src/graph-manager/protocol/pure/v1/V1_CubeLambdaSerializer.ts +257 -0
- package/src/graph-manager/protocol/pure/v1/V1_CubeModelOutlineBuilder.ts +157 -0
- package/src/graph-manager/protocol/pure/v1/V1_CubeRelationTypeAdapter.ts +58 -0
- package/src/graph-manager/protocol/pure/v1/V1_LegendCubeEngine.ts +278 -0
- package/src/graph-manager/protocol/pure/v1/__test-utils__/V1_CubeEngineTestUtils.ts +124 -0
- package/src/index.ts +41 -0
- package/src/stores/CubeEditorState.ts +702 -0
- package/src/stores/CubeExecutionState.ts +255 -0
- package/src/stores/CubeHost.ts +32 -0
- package/src/stores/CubeNodeEditorState.ts +255 -0
- package/src/stores/CubeShowPureState.ts +96 -0
- package/src/stores/CubeSourcePickerState.ts +426 -0
- package/src/stores/CubeSpecTransferState.ts +198 -0
- package/src/stores/LocalModelCatalog.ts +70 -0
- package/src/stores/editors/CubeFilterDraft.ts +241 -0
- package/src/stores/editors/CubeJoinDraft.ts +197 -0
- package/src/stores/editors/CubeNodeDraft.ts +46 -0
- package/src/stores/editors/CubeNodeDraftRegistry.ts +49 -0
- package/src/stores/fixtures/CubeNorthwindModel.ts +355 -0
- package/tsconfig.json +118 -0
|
@@ -0,0 +1,241 @@
|
|
|
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
|
+
changeFilterColumn,
|
|
19
|
+
changeFilterOperator,
|
|
20
|
+
ColumnComparisonFilter,
|
|
21
|
+
CompositeFilter,
|
|
22
|
+
CompositeFilterOperator,
|
|
23
|
+
encodeFilterRule,
|
|
24
|
+
type Filter,
|
|
25
|
+
type FilterOperator,
|
|
26
|
+
type FilterRule,
|
|
27
|
+
type FilterValue,
|
|
28
|
+
negateFilter,
|
|
29
|
+
normalizeFilter,
|
|
30
|
+
NotFilter,
|
|
31
|
+
type Schema,
|
|
32
|
+
unwrapFilter,
|
|
33
|
+
} from '@finos/legend-cube';
|
|
34
|
+
import { action, makeObservable, observable } from 'mobx';
|
|
35
|
+
import { CubeNodeDraft } from './CubeNodeDraft.js';
|
|
36
|
+
|
|
37
|
+
/** A condition with no column picked and no value: what Add puts in a group */
|
|
38
|
+
export const isBlankFilterRow = (rule: FilterRule): boolean =>
|
|
39
|
+
rule instanceof ColumnComparisonFilter &&
|
|
40
|
+
rule.columnName === '' &&
|
|
41
|
+
rule.value === undefined;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The rule without its blank conditions, and without the groups and
|
|
45
|
+
* negations left empty by that; `undefined` when nothing else is left
|
|
46
|
+
*/
|
|
47
|
+
export const pruneBlankFilterRows = (
|
|
48
|
+
rule: FilterRule,
|
|
49
|
+
): FilterRule | undefined => {
|
|
50
|
+
if (isBlankFilterRow(rule)) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
if (rule instanceof CompositeFilter) {
|
|
54
|
+
const rules = rule.rules
|
|
55
|
+
.map(pruneBlankFilterRows)
|
|
56
|
+
.filter((child): child is FilterRule => child !== undefined);
|
|
57
|
+
if (!rules.length) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
return rules.length === rule.rules.length &&
|
|
61
|
+
rules.every((child, index) => child === rule.rules[index])
|
|
62
|
+
? rule
|
|
63
|
+
: rule.withRules(rules);
|
|
64
|
+
}
|
|
65
|
+
if (rule instanceof NotFilter) {
|
|
66
|
+
const inner = pruneBlankFilterRows(rule.rule);
|
|
67
|
+
return inner === undefined
|
|
68
|
+
? undefined
|
|
69
|
+
: inner === rule.rule
|
|
70
|
+
? rule
|
|
71
|
+
: rule.withRule(inner);
|
|
72
|
+
}
|
|
73
|
+
return rule;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The tree with the rule of `key` replaced by what `replace` gives, or
|
|
78
|
+
* removed when it gives `undefined`; a negation whose rule is removed goes
|
|
79
|
+
* too. Rules that don't change stay the same objects.
|
|
80
|
+
*/
|
|
81
|
+
const replaceRule = (
|
|
82
|
+
rule: FilterRule,
|
|
83
|
+
key: number,
|
|
84
|
+
replace: (found: FilterRule) => FilterRule | undefined,
|
|
85
|
+
): FilterRule | undefined => {
|
|
86
|
+
if (rule.key === key) {
|
|
87
|
+
return replace(rule);
|
|
88
|
+
}
|
|
89
|
+
if (rule instanceof CompositeFilter) {
|
|
90
|
+
const rules = rule.rules
|
|
91
|
+
.map((child) => replaceRule(child, key, replace))
|
|
92
|
+
.filter((child): child is FilterRule => child !== undefined);
|
|
93
|
+
return rules.length === rule.rules.length &&
|
|
94
|
+
rules.every((child, index) => child === rule.rules[index])
|
|
95
|
+
? rule
|
|
96
|
+
: rule.withRules(rules);
|
|
97
|
+
}
|
|
98
|
+
if (rule instanceof NotFilter) {
|
|
99
|
+
const inner = replaceRule(rule.rule, key, replace);
|
|
100
|
+
return inner === undefined
|
|
101
|
+
? undefined
|
|
102
|
+
: inner === rule.rule
|
|
103
|
+
? rule
|
|
104
|
+
: rule.withRule(inner);
|
|
105
|
+
}
|
|
106
|
+
return rule;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const blankRow = (): ColumnComparisonFilter => new ColumnComparisonFilter('');
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The Filter editor's draft (spec §8.5, §17.6): the filter as a tree that
|
|
113
|
+
* always has an And/Or group at its top, so rows can be added to it. Each
|
|
114
|
+
* rule keeps its key across edits, so the editor's rows keep theirs.
|
|
115
|
+
*
|
|
116
|
+
* When built, blank conditions are left out, and a tree of nothing else
|
|
117
|
+
* stores no filter at all (user's choice, 2026-10-07): an Apply with an
|
|
118
|
+
* untouched blank row changes nothing. Rules this version can't read are
|
|
119
|
+
* kept as they were.
|
|
120
|
+
*/
|
|
121
|
+
export class CubeFilterDraft extends CubeNodeDraft<Filter> {
|
|
122
|
+
tree: CompositeFilter;
|
|
123
|
+
/** Anything was changed; until then, `build()` gives the original back */
|
|
124
|
+
private touched = false;
|
|
125
|
+
|
|
126
|
+
constructor(original: Filter) {
|
|
127
|
+
super(original);
|
|
128
|
+
makeObservable<CubeFilterDraft, 'touched'>(this, {
|
|
129
|
+
tree: observable.ref,
|
|
130
|
+
touched: observable,
|
|
131
|
+
setGroupOperator: action,
|
|
132
|
+
addCondition: action,
|
|
133
|
+
addGroup: action,
|
|
134
|
+
removeRule: action,
|
|
135
|
+
toggleNegation: action,
|
|
136
|
+
setColumn: action,
|
|
137
|
+
setOperator: action,
|
|
138
|
+
setValue: action,
|
|
139
|
+
});
|
|
140
|
+
this.tree = normalizeFilter(original.filter);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private update(
|
|
144
|
+
key: number,
|
|
145
|
+
replace: (rule: FilterRule) => FilterRule | undefined,
|
|
146
|
+
): void {
|
|
147
|
+
const tree = replaceRule(this.tree, key, replace);
|
|
148
|
+
// the top group stays a group
|
|
149
|
+
if (tree instanceof CompositeFilter && tree !== this.tree) {
|
|
150
|
+
this.tree = tree;
|
|
151
|
+
this.touched = true;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
setGroupOperator(groupKey: number, operator: CompositeFilterOperator): void {
|
|
156
|
+
this.update(groupKey, (rule) =>
|
|
157
|
+
rule instanceof CompositeFilter ? rule.withOperator(operator) : rule,
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Adds a blank condition at the end of the group */
|
|
162
|
+
addCondition(groupKey: number): void {
|
|
163
|
+
this.update(groupKey, (rule) =>
|
|
164
|
+
rule instanceof CompositeFilter
|
|
165
|
+
? rule.withRules([...rule.rules, blankRow()])
|
|
166
|
+
: rule,
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Adds a group holding one blank condition at the end of the group */
|
|
171
|
+
addGroup(groupKey: number): void {
|
|
172
|
+
this.update(groupKey, (rule) =>
|
|
173
|
+
rule instanceof CompositeFilter
|
|
174
|
+
? rule.withRules([
|
|
175
|
+
...rule.rules,
|
|
176
|
+
new CompositeFilter(CompositeFilterOperator.AND, [blankRow()]),
|
|
177
|
+
])
|
|
178
|
+
: rule,
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Removes a rule; the top group stays */
|
|
183
|
+
removeRule(key: number): void {
|
|
184
|
+
if (key !== this.tree.key) {
|
|
185
|
+
this.update(key, () => undefined);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Negates a rule as simply as it can (`negateFilter`): a comparison takes
|
|
191
|
+
* its negated operator, e.g. `is` and `is not`, a negation gives back its
|
|
192
|
+
* rule, anything else is wrapped in Not. The top group can't be negated.
|
|
193
|
+
*/
|
|
194
|
+
toggleNegation(key: number): void {
|
|
195
|
+
if (key !== this.tree.key) {
|
|
196
|
+
this.update(key, negateFilter);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** Changes a condition's column, keeping its operator and value when they still fit */
|
|
201
|
+
setColumn(key: number, columnName: string, schema: Schema): void {
|
|
202
|
+
this.update(key, (rule) =>
|
|
203
|
+
rule instanceof ColumnComparisonFilter
|
|
204
|
+
? changeFilterColumn(rule, columnName, schema)
|
|
205
|
+
: rule,
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** Changes a condition's operator, dropping its value when the operator takes another shape */
|
|
210
|
+
setOperator(key: number, operator: FilterOperator): void {
|
|
211
|
+
this.update(key, (rule) =>
|
|
212
|
+
rule instanceof ColumnComparisonFilter
|
|
213
|
+
? changeFilterOperator(rule, operator)
|
|
214
|
+
: rule,
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
setValue(key: number, value: FilterValue | undefined): void {
|
|
219
|
+
this.update(key, (rule) =>
|
|
220
|
+
rule instanceof ColumnComparisonFilter ? rule.withValue(value) : rule,
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
build(): Filter {
|
|
225
|
+
const { original } = this;
|
|
226
|
+
if (!this.touched) {
|
|
227
|
+
return original;
|
|
228
|
+
}
|
|
229
|
+
const pruned = pruneBlankFilterRows(this.tree);
|
|
230
|
+
const filter = pruned === undefined ? undefined : unwrapFilter(pruned);
|
|
231
|
+
// a saved group of one rule comes back as the rule: it saves differently
|
|
232
|
+
// but means the same, so it is no change
|
|
233
|
+
const isUnchanged =
|
|
234
|
+
filter === undefined
|
|
235
|
+
? original.filter === undefined
|
|
236
|
+
: original.filter !== undefined &&
|
|
237
|
+
JSON.stringify(encodeFilterRule(filter)) ===
|
|
238
|
+
JSON.stringify(encodeFilterRule(unwrapFilter(original.filter)));
|
|
239
|
+
return isUnchanged ? original : original.withFilter(filter);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
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
|
+
getSameNamedJoinKeys,
|
|
19
|
+
Join,
|
|
20
|
+
JoinType,
|
|
21
|
+
type Query,
|
|
22
|
+
RelationalTableSource,
|
|
23
|
+
type SchemaInferenceResult,
|
|
24
|
+
} from '@finos/legend-cube';
|
|
25
|
+
import { action, makeObservable, observable } from 'mobx';
|
|
26
|
+
import type { CubeModelOutline } from '../../graph-manager/CubeEngine.js';
|
|
27
|
+
import { CubeNodeDraft } from './CubeNodeDraft.js';
|
|
28
|
+
|
|
29
|
+
/** One pair of key columns, matched by position; `''` until a column is picked */
|
|
30
|
+
export interface CubeJoinKeyPair {
|
|
31
|
+
/** Identifies the row in the editor */
|
|
32
|
+
readonly key: number;
|
|
33
|
+
readonly left: string;
|
|
34
|
+
readonly right: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let nextPairKey = 1;
|
|
38
|
+
|
|
39
|
+
const isSameList = (a: readonly string[], b: readonly string[]): boolean =>
|
|
40
|
+
a.length === b.length && a.every((name, index) => name === b[index]);
|
|
41
|
+
|
|
42
|
+
/** The key lists pairs build: a pair with no column picked is left out */
|
|
43
|
+
const toKeyLists = (
|
|
44
|
+
pairs: readonly CubeJoinKeyPair[],
|
|
45
|
+
): [string[], string[]] => {
|
|
46
|
+
const kept = pairs.filter((pair) => pair.left || pair.right);
|
|
47
|
+
return [kept.map((pair) => pair.left), kept.map((pair) => pair.right)];
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The Join editor's draft (spec §17.6): the join type and the key column
|
|
52
|
+
* pairs. A pair with no column picked on either side is left out when built,
|
|
53
|
+
* as a Filter's blank rows are (user's choice, 2026-10-07).
|
|
54
|
+
*/
|
|
55
|
+
export class CubeJoinDraft extends CubeNodeDraft<Join> {
|
|
56
|
+
joinType: JoinType;
|
|
57
|
+
pairs: CubeJoinKeyPair[];
|
|
58
|
+
/** Anything was changed; until then, `build()` gives the original back */
|
|
59
|
+
private touched = false;
|
|
60
|
+
/**
|
|
61
|
+
* The key lists the pairs built before any edit, so edits undone by hand
|
|
62
|
+
* give the original back, even for saved lists of unequal length
|
|
63
|
+
*/
|
|
64
|
+
private readonly initialKeyLists: [string[], string[]];
|
|
65
|
+
|
|
66
|
+
constructor(original: Join) {
|
|
67
|
+
super(original);
|
|
68
|
+
makeObservable<CubeJoinDraft, 'touched'>(this, {
|
|
69
|
+
joinType: observable,
|
|
70
|
+
pairs: observable.ref,
|
|
71
|
+
touched: observable,
|
|
72
|
+
setJoinType: action,
|
|
73
|
+
addPair: action,
|
|
74
|
+
removePair: action,
|
|
75
|
+
setLeftColumn: action,
|
|
76
|
+
setRightColumn: action,
|
|
77
|
+
});
|
|
78
|
+
this.joinType = original.joinType;
|
|
79
|
+
this.pairs = Array.from(
|
|
80
|
+
{
|
|
81
|
+
length: Math.max(
|
|
82
|
+
original.leftColumns.length,
|
|
83
|
+
original.rightColumns.length,
|
|
84
|
+
),
|
|
85
|
+
},
|
|
86
|
+
(_, index) => ({
|
|
87
|
+
key: nextPairKey++,
|
|
88
|
+
left: original.leftColumns[index] ?? '',
|
|
89
|
+
right: original.rightColumns[index] ?? '',
|
|
90
|
+
}),
|
|
91
|
+
);
|
|
92
|
+
this.initialKeyLists = toKeyLists(this.pairs);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
setJoinType(joinType: JoinType): void {
|
|
96
|
+
this.joinType = joinType;
|
|
97
|
+
this.touched = true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
addPair(): void {
|
|
101
|
+
this.pairs = [...this.pairs, { key: nextPairKey++, left: '', right: '' }];
|
|
102
|
+
this.touched = true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
removePair(key: number): void {
|
|
106
|
+
this.pairs = this.pairs.filter((pair) => pair.key !== key);
|
|
107
|
+
this.touched = true;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
setLeftColumn(key: number, left: string): void {
|
|
111
|
+
this.pairs = this.pairs.map((pair) =>
|
|
112
|
+
pair.key === key ? { ...pair, left } : pair,
|
|
113
|
+
);
|
|
114
|
+
this.touched = true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
setRightColumn(key: number, right: string): void {
|
|
118
|
+
this.pairs = this.pairs.map((pair) =>
|
|
119
|
+
pair.key === key ? { ...pair, right } : pair,
|
|
120
|
+
);
|
|
121
|
+
this.touched = true;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
build(): Join {
|
|
125
|
+
const [leftColumns, rightColumns] = toKeyLists(this.pairs);
|
|
126
|
+
const [initialLeft, initialRight] = this.initialKeyLists;
|
|
127
|
+
const { original } = this;
|
|
128
|
+
return !this.touched ||
|
|
129
|
+
(this.joinType === original.joinType &&
|
|
130
|
+
isSameList(leftColumns, initialLeft) &&
|
|
131
|
+
isSameList(rightColumns, initialRight))
|
|
132
|
+
? original
|
|
133
|
+
: original.withSettings({
|
|
134
|
+
joinType: this.joinType,
|
|
135
|
+
leftColumns,
|
|
136
|
+
rightColumns,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The table sources a column of a node's output comes from: followed back
|
|
143
|
+
* through the inputs whose output has the column. A join key of the same name
|
|
144
|
+
* on both sides comes from the side the join keeps (the left for INNER and
|
|
145
|
+
* LEFT OUTER, the right for RIGHT OUTER), and from both for FULL OUTER, which
|
|
146
|
+
* merges them.
|
|
147
|
+
*/
|
|
148
|
+
export const findColumnSources = (
|
|
149
|
+
query: Query,
|
|
150
|
+
analysis: SchemaInferenceResult,
|
|
151
|
+
nodeId: string,
|
|
152
|
+
columnName: string,
|
|
153
|
+
): RelationalTableSource[] => {
|
|
154
|
+
const node = query.getNode(nodeId);
|
|
155
|
+
if (node instanceof RelationalTableSource) {
|
|
156
|
+
return node.resolution.kind === 'resolved' &&
|
|
157
|
+
node.resolution.schema.lookup(columnName)
|
|
158
|
+
? [node]
|
|
159
|
+
: [];
|
|
160
|
+
}
|
|
161
|
+
const inputIds = query.getInputIds(nodeId);
|
|
162
|
+
const [leftId, rightId] = inputIds;
|
|
163
|
+
const followed =
|
|
164
|
+
node instanceof Join &&
|
|
165
|
+
node.joinType !== JoinType.FULL_OUTER &&
|
|
166
|
+
getSameNamedJoinKeys(node.leftColumns, node.rightColumns).includes(
|
|
167
|
+
columnName,
|
|
168
|
+
)
|
|
169
|
+
? [node.joinType === JoinType.RIGHT_OUTER ? rightId : leftId]
|
|
170
|
+
: inputIds;
|
|
171
|
+
return followed.flatMap((inputId) =>
|
|
172
|
+
inputId !== undefined && analysis.schemas.get(inputId)?.lookup(columnName)
|
|
173
|
+
? findColumnSources(query, analysis, inputId, columnName)
|
|
174
|
+
: [],
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Whether the column of the node's output comes from a table column whose
|
|
180
|
+
* type Cube can't read (OTHER or ARRAY), so it was typed as a bare String
|
|
181
|
+
* (PLAN §8.7). Unknown until the model's outline has loaded.
|
|
182
|
+
*/
|
|
183
|
+
export const isUntypedColumn = (
|
|
184
|
+
outline: CubeModelOutline | undefined,
|
|
185
|
+
query: Query,
|
|
186
|
+
analysis: SchemaInferenceResult,
|
|
187
|
+
nodeId: string,
|
|
188
|
+
columnName: string,
|
|
189
|
+
): boolean =>
|
|
190
|
+
outline !== undefined &&
|
|
191
|
+
findColumnSources(query, analysis, nodeId, columnName).some((source) =>
|
|
192
|
+
outline.databases
|
|
193
|
+
.find((database) => database.path === source.database)
|
|
194
|
+
?.schemas.find((schema) => schema.name === source.schema)
|
|
195
|
+
?.tables.find((table) => table.name === source.table)
|
|
196
|
+
?.untypedColumns.includes(columnName),
|
|
197
|
+
);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { QueryNode } from '@finos/legend-cube';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The edits of one node in the side panel, kept until Apply (PLAN §7.4,
|
|
21
|
+
* spec §17.5). A node type's editor edits its draft, never the document:
|
|
22
|
+
* only the panel's Apply stores `build()`, as one undo step. A draft is
|
|
23
|
+
* made once each time the panel opens on a node, and again after an Apply.
|
|
24
|
+
*/
|
|
25
|
+
export abstract class CubeNodeDraft<N extends QueryNode = QueryNode> {
|
|
26
|
+
/** The node the draft was made from */
|
|
27
|
+
readonly original: N;
|
|
28
|
+
|
|
29
|
+
constructor(original: N) {
|
|
30
|
+
this.original = original;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The node Apply would store. Return `original` itself while nothing was
|
|
35
|
+
* edited; the panel also treats a node that saves the same as `original`
|
|
36
|
+
* as no change.
|
|
37
|
+
*/
|
|
38
|
+
abstract build(): N;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** A node with nothing to edit in the panel, such as a source or an Unknown node */
|
|
42
|
+
export class CubeReadOnlyNodeDraft extends CubeNodeDraft {
|
|
43
|
+
build(): QueryNode {
|
|
44
|
+
return this.original;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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 { Filter, Join, type QueryNode } from '@finos/legend-cube';
|
|
18
|
+
import { guaranteeType } from '@finos/legend-shared';
|
|
19
|
+
import type { CubeEditorState } from '../CubeEditorState.js';
|
|
20
|
+
import { CubeFilterDraft } from './CubeFilterDraft.js';
|
|
21
|
+
import { CubeJoinDraft } from './CubeJoinDraft.js';
|
|
22
|
+
import { type CubeNodeDraft, CubeReadOnlyNodeDraft } from './CubeNodeDraft.js';
|
|
23
|
+
|
|
24
|
+
/** Makes the draft of a node of one type */
|
|
25
|
+
export type CubeNodeDraftFactory = (
|
|
26
|
+
node: QueryNode,
|
|
27
|
+
editorState: CubeEditorState,
|
|
28
|
+
) => CubeNodeDraft;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The draft of each node type the panel edits, by type (PLAN §7.4). A
|
|
32
|
+
* transform with an editor in `CUBE_NODE_EDITORS` has its factory here; a
|
|
33
|
+
* source, which has nothing to edit, has none, and so no Apply or Cancel.
|
|
34
|
+
*/
|
|
35
|
+
export const CUBE_NODE_DRAFT_FACTORIES: ReadonlyMap<
|
|
36
|
+
string,
|
|
37
|
+
CubeNodeDraftFactory
|
|
38
|
+
> = new Map<string, CubeNodeDraftFactory>([
|
|
39
|
+
[Filter.TYPE, (node) => new CubeFilterDraft(guaranteeType(node, Filter))],
|
|
40
|
+
[Join.TYPE, (node) => new CubeJoinDraft(guaranteeType(node, Join))],
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
/** The node's draft; a node with nothing to edit gets a read-only one */
|
|
44
|
+
export const createCubeNodeDraft = (
|
|
45
|
+
node: QueryNode,
|
|
46
|
+
editorState: CubeEditorState,
|
|
47
|
+
): CubeNodeDraft =>
|
|
48
|
+
CUBE_NODE_DRAFT_FACTORIES.get(node.type)?.(node, editorState) ??
|
|
49
|
+
new CubeReadOnlyNodeDraft(node);
|