@finos/legend-application-studio 28.19.114 → 28.19.116

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 (26) hide show
  1. package/lib/components/editor/editor-group/dataProduct/DataProductQueryBuilderHelper.d.ts.map +1 -1
  2. package/lib/components/editor/editor-group/dataProduct/DataProductQueryBuilderHelper.js +25 -8
  3. package/lib/components/editor/editor-group/dataProduct/DataProductQueryBuilderHelper.js.map +1 -1
  4. package/lib/components/editor/side-bar/Explorer.d.ts.map +1 -1
  5. package/lib/components/editor/side-bar/Explorer.js +1 -8
  6. package/lib/components/editor/side-bar/Explorer.js.map +1 -1
  7. package/lib/index.css +1 -1
  8. package/lib/package.json +1 -1
  9. package/lib/stores/editor/editor-state/element-editor-state/dataProduct/DataProductEditorState.d.ts.map +1 -1
  10. package/lib/stores/editor/editor-state/element-editor-state/dataProduct/DataProductEditorState.js +2 -2
  11. package/lib/stores/editor/editor-state/element-editor-state/dataProduct/DataProductEditorState.js.map +1 -1
  12. package/package.json +16 -16
  13. package/src/components/editor/editor-group/dataProduct/DataProductQueryBuilderHelper.ts +54 -9
  14. package/src/components/editor/side-bar/Explorer.tsx +2 -19
  15. package/src/stores/editor/editor-state/element-editor-state/dataProduct/DataProductEditorState.ts +5 -4
  16. package/tsconfig.json +0 -2
  17. package/lib/components/editor/editor-group/database/IsolatedQueryDatabase.d.ts +0 -18
  18. package/lib/components/editor/editor-group/database/IsolatedQueryDatabase.d.ts.map +0 -1
  19. package/lib/components/editor/editor-group/database/IsolatedQueryDatabase.js +0 -58
  20. package/lib/components/editor/editor-group/database/IsolatedQueryDatabase.js.map +0 -1
  21. package/lib/stores/editor/editor-state/element-editor-state/database/QueryDatabaseState.d.ts +0 -37
  22. package/lib/stores/editor/editor-state/element-editor-state/database/QueryDatabaseState.d.ts.map +0 -1
  23. package/lib/stores/editor/editor-state/element-editor-state/database/QueryDatabaseState.js +0 -127
  24. package/lib/stores/editor/editor-state/element-editor-state/database/QueryDatabaseState.js.map +0 -1
  25. package/src/components/editor/editor-group/database/IsolatedQueryDatabase.tsx +0 -142
  26. package/src/stores/editor/editor-state/element-editor-state/database/QueryDatabaseState.ts +0 -240
@@ -1,240 +0,0 @@
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 {
18
- DEFAULT_GENERATION_PACKAGE,
19
- EngineRuntime,
20
- Database,
21
- RelationalDatabaseConnection,
22
- PackageableElementExplicitReference,
23
- StoreConnections,
24
- IdentifiedConnection,
25
- GraphManagerState,
26
- getMappingCompatibleClasses,
27
- } from '@finos/legend-graph';
28
- import type { EditorStore } from '../../../EditorStore.js';
29
- import {
30
- ActionState,
31
- assertErrorThrown,
32
- guaranteeNonNullable,
33
- type GeneratorFn,
34
- assertTrue,
35
- } from '@finos/legend-shared';
36
- import { action, flow, flowResult, makeObservable, observable } from 'mobx';
37
- import type { Entity } from '@finos/legend-storage';
38
- import {
39
- QueryBuilderAdvancedWorkflowState,
40
- QueryBuilderConfig,
41
- QueryBuilderState,
42
- } from '@finos/legend-query-builder';
43
- import {
44
- DEFAULT_TAB_SIZE,
45
- type GenericLegendApplicationStore,
46
- } from '@finos/legend-application';
47
- import { payloadDebugger } from '../../../panel-group/DevToolPanelState.js';
48
- import { renderDatabaseQueryBuilderSetupPanelContent } from '../../../../../components/editor/editor-group/database/IsolatedQueryDatabase.js';
49
-
50
- const replaceConnectionInEngineRuntime = (
51
- engineRuntime: EngineRuntime,
52
- connection: RelationalDatabaseConnection,
53
- databse: Database,
54
- ): void => {
55
- const _storeConnection = new StoreConnections(
56
- PackageableElementExplicitReference.create(databse),
57
- );
58
- const newconnection = new RelationalDatabaseConnection(
59
- PackageableElementExplicitReference.create(databse),
60
- connection.type,
61
- connection.datasourceSpecification,
62
- connection.authenticationStrategy,
63
- );
64
- newconnection.localMode = connection.localMode;
65
- newconnection.timeZone = connection.timeZone;
66
- _storeConnection.storeConnections = [
67
- new IdentifiedConnection('connection1', newconnection),
68
- ];
69
- engineRuntime.connections = [_storeConnection];
70
- };
71
- export class IsolatedDatabaseBuilderState extends QueryBuilderState {
72
- readonly database: Database;
73
- globalGraphManagerState: GraphManagerState;
74
- engineRuntime: EngineRuntime;
75
- connectionKey: string;
76
- compatibleConnections: Map<string, RelationalDatabaseConnection>;
77
-
78
- override TEMPORARY__setupPanelContentRenderer = (): React.ReactNode =>
79
- renderDatabaseQueryBuilderSetupPanelContent(this);
80
-
81
- constructor(
82
- applicationStore: GenericLegendApplicationStore,
83
- isolatedGraphManagerState: GraphManagerState,
84
- globalGraphManagerState: GraphManagerState,
85
- database: Database,
86
- connectionKey: string,
87
- runtime: EngineRuntime,
88
- compatibleConnections: Map<string, RelationalDatabaseConnection>,
89
- acceptedElementPaths?: string[],
90
- config?: QueryBuilderConfig | undefined,
91
- ) {
92
- super(
93
- applicationStore,
94
- isolatedGraphManagerState,
95
- QueryBuilderAdvancedWorkflowState.INSTANCE,
96
- config,
97
- );
98
- makeObservable(this, {
99
- connectionKey: observable,
100
- engineRuntime: observable,
101
- changeConnection: action,
102
- });
103
- this.database = database;
104
- this.globalGraphManagerState = globalGraphManagerState;
105
- this.engineRuntime = runtime;
106
- this.compatibleConnections = compatibleConnections;
107
- this.connectionKey = connectionKey;
108
- const classes = isolatedGraphManagerState.usableClasses;
109
- const electedMapping = guaranteeNonNullable(
110
- isolatedGraphManagerState.graph.mappings.filter((m) =>
111
- acceptedElementPaths ? acceptedElementPaths.includes(m.path) : true,
112
- )[0],
113
- 'Compatible mapping expected',
114
- );
115
-
116
- this.sourceElement = guaranteeNonNullable(
117
- getMappingCompatibleClasses(electedMapping, classes)[0],
118
- 'Compatible class expected for mapping',
119
- );
120
-
121
- this.executionContextState.mapping = electedMapping;
122
- this.executionContextState.runtimeValue = runtime;
123
- }
124
-
125
- changeConnection(key: string): void {
126
- const connection = this.compatibleConnections.get(key);
127
- if (connection) {
128
- replaceConnectionInEngineRuntime(
129
- this.engineRuntime,
130
- connection,
131
- this.database,
132
- );
133
- this.connectionKey = key;
134
- }
135
- }
136
- }
137
-
138
- export class QueryDatabaseState {
139
- editorStore: EditorStore;
140
- database: Database;
141
-
142
- constructor(database: Database, editorStore: EditorStore) {
143
- this.database = database;
144
- this.editorStore = editorStore;
145
-
146
- makeObservable(this, {
147
- init: flow,
148
- });
149
- }
150
- *init(): GeneratorFn<void> {
151
- try {
152
- const compConnections = new Map<string, RelationalDatabaseConnection>();
153
- this.editorStore.graphManagerState.usableConnections.forEach((conn) => {
154
- const val = conn.connectionValue;
155
- if (val instanceof RelationalDatabaseConnection) {
156
- compConnections.set(conn.path, val);
157
- }
158
- });
159
- assertTrue(
160
- compConnections.size > 0,
161
- `No compatible connections found for database ${this.database.path}`,
162
- );
163
- const embeddedQueryBuilderState =
164
- this.editorStore.embeddedQueryBuilderState;
165
- const databaseGraphManagerState = new GraphManagerState(
166
- this.editorStore.applicationStore.pluginManager,
167
- this.editorStore.applicationStore.logService,
168
- );
169
- yield databaseGraphManagerState.graphManager.initialize(
170
- {
171
- env: this.editorStore.applicationStore.config.env,
172
- tabSize: DEFAULT_TAB_SIZE,
173
- clientConfig: {
174
- baseUrl: this.editorStore.applicationStore.config.engineServerUrl,
175
- queryBaseUrl:
176
- this.editorStore.applicationStore.config.engineQueryServerUrl,
177
- enableCompression: true,
178
- payloadDebugger,
179
- },
180
- },
181
- {
182
- tracerService: this.editorStore.applicationStore.tracerService,
183
- },
184
- );
185
- databaseGraphManagerState.graph =
186
- this.editorStore.graphManagerState.createNewGraph();
187
- const copiedDb = new Database(this.database.name);
188
- databaseGraphManagerState.graph.addElement(
189
- copiedDb,
190
- guaranteeNonNullable(this.database.package?.path),
191
- );
192
- copiedDb.schemas = this.database.schemas;
193
- copiedDb.joins = this.database.joins;
194
- copiedDb.filters = this.database.filters;
195
- const entities =
196
- (yield this.editorStore.graphManagerState.graphManager.generateModelsFromDatabaseSpecification(
197
- this.database.path,
198
- DEFAULT_GENERATION_PACKAGE,
199
- this.editorStore.graphManagerState.graph,
200
- )) as Entity[];
201
- yield this.editorStore.graphManagerState.graphManager.buildGraph(
202
- databaseGraphManagerState.graph,
203
- entities,
204
- ActionState.create(),
205
- );
206
- const engineRuntime = new EngineRuntime();
207
- engineRuntime.mappings = databaseGraphManagerState.graph.mappings.map(
208
- (e) => PackageableElementExplicitReference.create(e),
209
- );
210
- const connectionEntry = guaranteeNonNullable(
211
- Array.from(compConnections.entries())[0],
212
- );
213
- const connection = connectionEntry[1];
214
- replaceConnectionInEngineRuntime(engineRuntime, connection, copiedDb);
215
- const config = new QueryBuilderConfig();
216
- const queryBuilderState = new IsolatedDatabaseBuilderState(
217
- this.editorStore.applicationStore,
218
- databaseGraphManagerState,
219
- this.editorStore.graphManagerState,
220
- copiedDb,
221
- connectionEntry[0],
222
- engineRuntime,
223
- compConnections,
224
- entities.map((e) => e.path),
225
- config,
226
- );
227
- yield flowResult(
228
- embeddedQueryBuilderState.setEmbeddedQueryBuilderConfiguration({
229
- setupQueryBuilderState: async () => queryBuilderState,
230
- actionConfigs: [],
231
- }),
232
- );
233
- } catch (error) {
234
- assertErrorThrown(error);
235
- this.editorStore.applicationStore.notificationService.notifyError(
236
- `Unable to query database: ${error.message}`,
237
- );
238
- }
239
- }
240
- }