@finos/legend-extension-dsl-data-space 10.1.91 → 10.1.93

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. package/lib/__lib__/query/DSL_DataSpace_LegendQueryNavigation.d.ts +14 -1
  2. package/lib/__lib__/query/DSL_DataSpace_LegendQueryNavigation.d.ts.map +1 -1
  3. package/lib/__lib__/query/DSL_DataSpace_LegendQueryNavigation.js +14 -0
  4. package/lib/__lib__/query/DSL_DataSpace_LegendQueryNavigation.js.map +1 -1
  5. package/lib/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.d.ts.map +1 -1
  6. package/lib/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.js +8 -0
  7. package/lib/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.js.map +1 -1
  8. package/lib/components/query/DataSpaceTemplateQueryCreator.d.ts +19 -0
  9. package/lib/components/query/DataSpaceTemplateQueryCreator.d.ts.map +1 -0
  10. package/lib/components/query/DataSpaceTemplateQueryCreator.js +37 -0
  11. package/lib/components/query/DataSpaceTemplateQueryCreator.js.map +1 -0
  12. package/lib/graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.d.ts +2 -1
  13. package/lib/graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.d.ts.map +1 -1
  14. package/lib/graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.js +2 -0
  15. package/lib/graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.js.map +1 -1
  16. package/lib/graph-manager/protocol/pure/DSL_DataSpace_PureProtocolProcessorPlugin.d.ts +3 -1
  17. package/lib/graph-manager/protocol/pure/DSL_DataSpace_PureProtocolProcessorPlugin.d.ts.map +1 -1
  18. package/lib/graph-manager/protocol/pure/DSL_DataSpace_PureProtocolProcessorPlugin.js +19 -2
  19. package/lib/graph-manager/protocol/pure/DSL_DataSpace_PureProtocolProcessorPlugin.js.map +1 -1
  20. package/lib/graph-manager/protocol/pure/v1/model/packageableElements/dataSpace/V1_DSL_DataSpace_DataSpace.d.ts +2 -1
  21. package/lib/graph-manager/protocol/pure/v1/model/packageableElements/dataSpace/V1_DSL_DataSpace_DataSpace.d.ts.map +1 -1
  22. package/lib/graph-manager/protocol/pure/v1/model/packageableElements/dataSpace/V1_DSL_DataSpace_DataSpace.js +2 -0
  23. package/lib/graph-manager/protocol/pure/v1/model/packageableElements/dataSpace/V1_DSL_DataSpace_DataSpace.js.map +1 -1
  24. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_DataSpace_ProtocolHelper.d.ts.map +1 -1
  25. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_DataSpace_ProtocolHelper.js +2 -1
  26. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_DataSpace_ProtocolHelper.js.map +1 -1
  27. package/lib/index.css +1 -1
  28. package/lib/package.json +1 -1
  29. package/lib/stores/query/DataSpaceQueryCreatorStore.d.ts.map +1 -1
  30. package/lib/stores/query/DataSpaceQueryCreatorStore.js +11 -4
  31. package/lib/stores/query/DataSpaceQueryCreatorStore.js.map +1 -1
  32. package/lib/stores/query/DataSpaceTemplateQueryCreatorStore.d.ts +34 -0
  33. package/lib/stores/query/DataSpaceTemplateQueryCreatorStore.d.ts.map +1 -0
  34. package/lib/stores/query/DataSpaceTemplateQueryCreatorStore.js +112 -0
  35. package/lib/stores/query/DataSpaceTemplateQueryCreatorStore.js.map +1 -0
  36. package/package.json +7 -7
  37. package/src/__lib__/query/DSL_DataSpace_LegendQueryNavigation.ts +35 -0
  38. package/src/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.tsx +8 -0
  39. package/src/components/query/DataSpaceTemplateQueryCreator.tsx +82 -0
  40. package/src/graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.ts +3 -0
  41. package/src/graph-manager/protocol/pure/DSL_DataSpace_PureProtocolProcessorPlugin.ts +31 -0
  42. package/src/graph-manager/protocol/pure/v1/model/packageableElements/dataSpace/V1_DSL_DataSpace_DataSpace.ts +3 -0
  43. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_DataSpace_ProtocolHelper.ts +2 -0
  44. package/src/stores/query/DataSpaceQueryCreatorStore.ts +10 -6
  45. package/src/stores/query/DataSpaceTemplateQueryCreatorStore.ts +219 -0
  46. package/tsconfig.json +2 -0
@@ -0,0 +1,219 @@
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
+ extractElementNameFromPath,
19
+ type Query,
20
+ type RawLambda,
21
+ } from '@finos/legend-graph';
22
+ import {
23
+ QueryEditorStore,
24
+ type QueryPersistConfiguration,
25
+ type LegendQueryApplicationStore,
26
+ createViewProjectHandler,
27
+ createViewSDLCProjectHandler,
28
+ } from '@finos/legend-application-query';
29
+ import {
30
+ type DepotServerClient,
31
+ StoreProjectData,
32
+ LATEST_VERSION_ALIAS,
33
+ } from '@finos/legend-server-depot';
34
+ import { filterByType, guaranteeNonNullable, uuid } from '@finos/legend-shared';
35
+
36
+ import { getDataSpace } from '../../graph-manager/DSL_DataSpace_GraphManagerHelper.js';
37
+ import {
38
+ DataSpaceQueryBuilderState,
39
+ DataSpaceProjectInfo,
40
+ } from './DataSpaceQueryBuilderState.js';
41
+ import type { DataSpaceInfo } from './DataSpaceInfo.js';
42
+ import { generateDataSpaceTemplateQueryViewerRoute } from '../../__lib__/query/DSL_DataSpace_LegendQueryNavigation.js';
43
+ import {
44
+ DataSpaceExecutableTemplate,
45
+ type DataSpaceExecutionContext,
46
+ } from '../../graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.js';
47
+ import type { QueryBuilderState } from '@finos/legend-query-builder';
48
+ import type { ProjectGAVCoordinates } from '@finos/legend-storage';
49
+ import { DSL_DataSpace_getGraphManagerExtension } from '../../graph-manager/protocol/pure/DSL_DataSpace_PureGraphManagerExtension.js';
50
+ import { retrieveAnalyticsResultCache } from '../../graph-manager/action/analytics/DataSpaceAnalysisHelper.js';
51
+ import {
52
+ createQueryDataSpaceTaggedValue,
53
+ createQueryClassTaggedValue,
54
+ } from './DataSpaceQueryCreatorStore.js';
55
+
56
+ export class DataSpaceTemplateQueryCreatorStore extends QueryEditorStore {
57
+ readonly groupId: string;
58
+ readonly artifactId: string;
59
+ readonly versionId: string;
60
+ readonly dataSpacePath: string;
61
+ readonly templateQueryTitle: string;
62
+
63
+ constructor(
64
+ applicationStore: LegendQueryApplicationStore,
65
+ depotServerClient: DepotServerClient,
66
+ groupId: string,
67
+ artifactId: string,
68
+ versionId: string,
69
+ dataSpacePath: string,
70
+ templateQueryTitle: string,
71
+ ) {
72
+ super(applicationStore, depotServerClient);
73
+
74
+ this.groupId = groupId;
75
+ this.artifactId = artifactId;
76
+ this.versionId = versionId;
77
+ this.dataSpacePath = dataSpacePath;
78
+ this.templateQueryTitle = templateQueryTitle;
79
+ }
80
+
81
+ getProjectInfo(): ProjectGAVCoordinates {
82
+ return {
83
+ groupId: this.groupId,
84
+ artifactId: this.artifactId,
85
+ versionId: this.versionId,
86
+ };
87
+ }
88
+
89
+ async initializeQueryBuilderState(): Promise<QueryBuilderState> {
90
+ const dataSpace = getDataSpace(
91
+ this.dataSpacePath,
92
+ this.graphManagerState.graph,
93
+ );
94
+ const dataSpaceExecutableTemplate = guaranteeNonNullable(
95
+ dataSpace.executables
96
+ ?.filter(filterByType(DataSpaceExecutableTemplate))
97
+ .find((executable) => executable.title === this.templateQueryTitle),
98
+ `Can't find template query with title '${this.templateQueryTitle}'`,
99
+ );
100
+ const executionContext = guaranteeNonNullable(
101
+ dataSpaceExecutableTemplate.executionContextKey
102
+ ? dataSpace.executionContexts.filter(
103
+ (ec) => ec.name === dataSpaceExecutableTemplate.executionContextKey,
104
+ )[0]
105
+ : dataSpace.defaultExecutionContext,
106
+ `Can't find execution context '${dataSpaceExecutableTemplate.executionContextKey}'`,
107
+ );
108
+
109
+ let dataSpaceAnalysisResult;
110
+ try {
111
+ const project = StoreProjectData.serialization.fromJson(
112
+ await this.depotServerClient.getProject(this.groupId, this.artifactId),
113
+ );
114
+ dataSpaceAnalysisResult = await DSL_DataSpace_getGraphManagerExtension(
115
+ this.graphManagerState.graphManager,
116
+ ).retrieveDataSpaceAnalysisFromCache(() =>
117
+ retrieveAnalyticsResultCache(
118
+ project,
119
+ this.versionId,
120
+ dataSpace.path,
121
+ this.depotServerClient,
122
+ ),
123
+ );
124
+ } catch {
125
+ // do nothing
126
+ }
127
+ const projectInfo = new DataSpaceProjectInfo(
128
+ this.groupId,
129
+ this.artifactId,
130
+ this.versionId,
131
+ createViewProjectHandler(this.applicationStore),
132
+ createViewSDLCProjectHandler(
133
+ this.applicationStore,
134
+ this.depotServerClient,
135
+ ),
136
+ );
137
+ const sourceInfo = {
138
+ groupId: projectInfo.groupId,
139
+ artifactId: projectInfo.artifactId,
140
+ versionId: projectInfo.versionId,
141
+ dataSpace: dataSpace.path,
142
+ };
143
+ const queryBuilderState = new DataSpaceQueryBuilderState(
144
+ this.applicationStore,
145
+ this.graphManagerState,
146
+ this.depotServerClient,
147
+ dataSpace,
148
+ executionContext,
149
+ (dataSpaceInfo: DataSpaceInfo) => {
150
+ if (dataSpaceInfo.defaultExecutionContext) {
151
+ this.applicationStore.navigationService.navigator.goToLocation(
152
+ generateDataSpaceTemplateQueryViewerRoute(
153
+ guaranteeNonNullable(dataSpaceInfo.groupId),
154
+ guaranteeNonNullable(dataSpaceInfo.artifactId),
155
+ LATEST_VERSION_ALIAS, //always default to latest
156
+ dataSpaceInfo.path,
157
+ this.templateQueryTitle,
158
+ ),
159
+ );
160
+ } else {
161
+ this.applicationStore.notificationService.notifyWarning(
162
+ `Can't switch data space: default execution context not specified`,
163
+ );
164
+ }
165
+ },
166
+ true,
167
+ dataSpaceAnalysisResult,
168
+ (ec: DataSpaceExecutionContext) => {
169
+ this.applicationStore.navigationService.navigator.updateCurrentLocation(
170
+ generateDataSpaceTemplateQueryViewerRoute(
171
+ this.groupId,
172
+ this.artifactId,
173
+ this.versionId,
174
+ dataSpace.path,
175
+ this.templateQueryTitle,
176
+ ),
177
+ );
178
+ },
179
+ undefined,
180
+ undefined,
181
+ projectInfo,
182
+ this.applicationStore.config.options.queryBuilderConfig,
183
+ sourceInfo,
184
+ );
185
+ queryBuilderState.setExecutionContext(executionContext);
186
+ queryBuilderState.propagateExecutionContextChange(executionContext);
187
+ queryBuilderState.initializeWithQuery(dataSpaceExecutableTemplate.query);
188
+ return queryBuilderState;
189
+ }
190
+
191
+ getPersistConfiguration(
192
+ lambda: RawLambda,
193
+ options?: { update?: boolean | undefined },
194
+ ): QueryPersistConfiguration {
195
+ return {
196
+ defaultName: options?.update
197
+ ? `${extractElementNameFromPath(this.dataSpacePath)}`
198
+ : `New Query for ${extractElementNameFromPath(this.dataSpacePath)}[${
199
+ this.templateQueryTitle
200
+ }]`,
201
+ decorator: (query: Query): void => {
202
+ query.id = uuid();
203
+ query.groupId = this.groupId;
204
+ query.artifactId = this.artifactId;
205
+ query.versionId = this.versionId;
206
+ if (this.queryBuilderState?.class) {
207
+ query.taggedValues = [
208
+ createQueryDataSpaceTaggedValue(this.dataSpacePath),
209
+ createQueryClassTaggedValue(this.queryBuilderState.class.path),
210
+ ];
211
+ } else {
212
+ query.taggedValues = [
213
+ createQueryDataSpaceTaggedValue(this.dataSpacePath),
214
+ ];
215
+ }
216
+ },
217
+ };
218
+ }
219
+ }
package/tsconfig.json CHANGED
@@ -73,6 +73,7 @@
73
73
  "./src/stores/query/DataSpaceQueryBuilderState.ts",
74
74
  "./src/stores/query/DataSpaceQueryCreatorStore.ts",
75
75
  "./src/stores/query/DataSpaceQuerySetupStore.ts",
76
+ "./src/stores/query/DataSpaceTemplateQueryCreatorStore.ts",
76
77
  "./src/stores/studio/DataSpacePreviewState.ts",
77
78
  "./src/components/DSL_DataSpace_Icon.tsx",
78
79
  "./src/components/DSL_DataSpace_LegendApplicationPlugin.tsx",
@@ -94,6 +95,7 @@
94
95
  "./src/components/query/DataSpaceQueryBuilder.tsx",
95
96
  "./src/components/query/DataSpaceQueryCreator.tsx",
96
97
  "./src/components/query/DataSpaceQuerySetup.tsx",
98
+ "./src/components/query/DataSpaceTemplateQueryCreator.tsx",
97
99
  "./src/components/studio/DSL_DataSpace_LegendStudioApplicationPlugin.tsx",
98
100
  "./src/components/studio/DataSpacePreviewAction.tsx",
99
101
  "./src/components/studio/DataSpaceQueryAction.tsx",