@finos/legend-extension-dsl-data-space 10.3.0 → 10.3.1

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 (105) hide show
  1. package/lib/__lib__/{query/DSL_DataSpace_LegendQueryNavigation.d.ts → to-delete/DSL_DataSpace_LegendQueryNavigation_to_delete.d.ts} +5 -20
  2. package/lib/__lib__/to-delete/DSL_DataSpace_LegendQueryNavigation_to_delete.d.ts.map +1 -0
  3. package/lib/__lib__/{query/DSL_DataSpace_LegendQueryNavigation.js → to-delete/DSL_DataSpace_LegendQueryNavigation_to_delete.js} +34 -2
  4. package/lib/__lib__/to-delete/DSL_DataSpace_LegendQueryNavigation_to_delete.js.map +1 -0
  5. package/lib/components/DSL_DataSpace_LegendApplicationPlugin.js +2 -2
  6. package/lib/components/DSL_DataSpace_LegendApplicationPlugin.js.map +1 -1
  7. package/lib/components/index.d.ts +4 -4
  8. package/lib/components/index.d.ts.map +1 -1
  9. package/lib/components/index.js +4 -4
  10. package/lib/components/index.js.map +1 -1
  11. package/lib/components/query-builder/DataSpaceAdvancedSearchModal.d.ts.map +1 -0
  12. package/lib/components/query-builder/DataSpaceAdvancedSearchModal.js.map +1 -0
  13. package/lib/components/query-builder/DataSpaceQueryBuilder.d.ts.map +1 -0
  14. package/lib/components/query-builder/DataSpaceQueryBuilder.js.map +1 -0
  15. package/lib/components/query-builder/DataSpaceQueryBuilderTemplateQueryPanelContent.d.ts.map +1 -0
  16. package/lib/components/{query → query-builder}/DataSpaceQueryBuilderTemplateQueryPanelContent.js +2 -2
  17. package/lib/components/query-builder/DataSpaceQueryBuilderTemplateQueryPanelContent.js.map +1 -0
  18. package/lib/components/query-builder/QueryDataSpaceUtil.d.ts.map +1 -0
  19. package/lib/components/query-builder/QueryDataSpaceUtil.js.map +1 -0
  20. package/lib/components/{query → query-builder}/index.d.ts +3 -1
  21. package/lib/components/query-builder/index.d.ts.map +1 -0
  22. package/lib/components/{query → query-builder}/index.js +3 -1
  23. package/lib/components/query-builder/index.js.map +1 -0
  24. package/lib/graph-manager/index.d.ts +1 -0
  25. package/lib/graph-manager/index.d.ts.map +1 -1
  26. package/lib/graph-manager/index.js +1 -0
  27. package/lib/graph-manager/index.js.map +1 -1
  28. package/lib/index.css +1 -1
  29. package/lib/package.json +3 -5
  30. package/lib/stores/query/DataSpaceAdvancedSearchState.d.ts.map +1 -1
  31. package/lib/stores/query/DataSpaceAdvancedSearchState.js +1 -2
  32. package/lib/stores/query/DataSpaceAdvancedSearchState.js.map +1 -1
  33. package/lib/stores/query-builder/DataSpaceQueryBuilderState.js +1 -1
  34. package/lib/stores/query-builder/DataSpaceQueryBuilderState.js.map +1 -1
  35. package/lib/{components/query/DataSpaceQueryCreator.d.ts → stores/shared/DataSpaceUtils.d.ts} +4 -4
  36. package/lib/stores/shared/DataSpaceUtils.d.ts.map +1 -0
  37. package/lib/stores/shared/DataSpaceUtils.js +32 -0
  38. package/lib/stores/shared/DataSpaceUtils.js.map +1 -0
  39. package/package.json +4 -6
  40. package/src/__lib__/{query/DSL_DataSpace_LegendQueryNavigation.ts → to-delete/DSL_DataSpace_LegendQueryNavigation_to_delete.ts} +47 -18
  41. package/src/components/DSL_DataSpace_LegendApplicationPlugin.tsx +5 -5
  42. package/src/components/index.ts +11 -4
  43. package/src/components/{query → query-builder}/DataSpaceQueryBuilderTemplateQueryPanelContent.tsx +3 -3
  44. package/src/components/{query → query-builder}/index.ts +7 -1
  45. package/src/graph-manager/index.ts +1 -0
  46. package/src/stores/query/DataSpaceAdvancedSearchState.ts +4 -2
  47. package/src/stores/query-builder/DataSpaceQueryBuilderState.ts +1 -1
  48. package/src/stores/shared/DataSpaceUtils.ts +42 -0
  49. package/tsconfig.json +7 -13
  50. package/lib/__lib__/query/DSL_DataSpace_LegendQueryNavigation.d.ts.map +0 -1
  51. package/lib/__lib__/query/DSL_DataSpace_LegendQueryNavigation.js.map +0 -1
  52. package/lib/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.d.ts +0 -29
  53. package/lib/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.d.ts.map +0 -1
  54. package/lib/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.js +0 -243
  55. package/lib/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.js.map +0 -1
  56. package/lib/components/query/DataSpaceAdvancedSearchModal.d.ts.map +0 -1
  57. package/lib/components/query/DataSpaceAdvancedSearchModal.js.map +0 -1
  58. package/lib/components/query/DataSpaceQueryBuilder.d.ts.map +0 -1
  59. package/lib/components/query/DataSpaceQueryBuilder.js.map +0 -1
  60. package/lib/components/query/DataSpaceQueryBuilderTemplateQueryPanelContent.d.ts.map +0 -1
  61. package/lib/components/query/DataSpaceQueryBuilderTemplateQueryPanelContent.js.map +0 -1
  62. package/lib/components/query/DataSpaceQueryCreator.d.ts.map +0 -1
  63. package/lib/components/query/DataSpaceQueryCreator.js +0 -41
  64. package/lib/components/query/DataSpaceQueryCreator.js.map +0 -1
  65. package/lib/components/query/DataSpaceQuerySetup.d.ts +0 -21
  66. package/lib/components/query/DataSpaceQuerySetup.d.ts.map +0 -1
  67. package/lib/components/query/DataSpaceQuerySetup.js +0 -63
  68. package/lib/components/query/DataSpaceQuerySetup.js.map +0 -1
  69. package/lib/components/query/DataSpaceTemplateQueryCreator.d.ts +0 -19
  70. package/lib/components/query/DataSpaceTemplateQueryCreator.d.ts.map +0 -1
  71. package/lib/components/query/DataSpaceTemplateQueryCreator.js +0 -37
  72. package/lib/components/query/DataSpaceTemplateQueryCreator.js.map +0 -1
  73. package/lib/components/query/QueryDataSpaceUtil.d.ts.map +0 -1
  74. package/lib/components/query/QueryDataSpaceUtil.js.map +0 -1
  75. package/lib/components/query/index.d.ts.map +0 -1
  76. package/lib/components/query/index.js.map +0 -1
  77. package/lib/stores/query/DataSpaceQueryCreatorStore.d.ts +0 -38
  78. package/lib/stores/query/DataSpaceQueryCreatorStore.d.ts.map +0 -1
  79. package/lib/stores/query/DataSpaceQueryCreatorStore.js +0 -149
  80. package/lib/stores/query/DataSpaceQueryCreatorStore.js.map +0 -1
  81. package/lib/stores/query/DataSpaceQuerySetupStore.d.ts +0 -51
  82. package/lib/stores/query/DataSpaceQuerySetupStore.d.ts.map +0 -1
  83. package/lib/stores/query/DataSpaceQuerySetupStore.js +0 -107
  84. package/lib/stores/query/DataSpaceQuerySetupStore.js.map +0 -1
  85. package/lib/stores/query/DataSpaceTemplateQueryCreatorStore.d.ts +0 -35
  86. package/lib/stores/query/DataSpaceTemplateQueryCreatorStore.d.ts.map +0 -1
  87. package/lib/stores/query/DataSpaceTemplateQueryCreatorStore.js +0 -108
  88. package/lib/stores/query/DataSpaceTemplateQueryCreatorStore.js.map +0 -1
  89. package/src/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.tsx +0 -445
  90. package/src/components/query/DataSpaceQueryCreator.tsx +0 -99
  91. package/src/components/query/DataSpaceQuerySetup.tsx +0 -165
  92. package/src/components/query/DataSpaceTemplateQueryCreator.tsx +0 -82
  93. package/src/stores/query/DataSpaceQueryCreatorStore.ts +0 -308
  94. package/src/stores/query/DataSpaceQuerySetupStore.ts +0 -208
  95. package/src/stores/query/DataSpaceTemplateQueryCreatorStore.ts +0 -207
  96. /package/lib/components/{query → query-builder}/DataSpaceAdvancedSearchModal.d.ts +0 -0
  97. /package/lib/components/{query → query-builder}/DataSpaceAdvancedSearchModal.js +0 -0
  98. /package/lib/components/{query → query-builder}/DataSpaceQueryBuilder.d.ts +0 -0
  99. /package/lib/components/{query → query-builder}/DataSpaceQueryBuilder.js +0 -0
  100. /package/lib/components/{query → query-builder}/DataSpaceQueryBuilderTemplateQueryPanelContent.d.ts +0 -0
  101. /package/lib/components/{query → query-builder}/QueryDataSpaceUtil.d.ts +0 -0
  102. /package/lib/components/{query → query-builder}/QueryDataSpaceUtil.js +0 -0
  103. /package/src/components/{query → query-builder}/DataSpaceAdvancedSearchModal.tsx +0 -0
  104. /package/src/components/{query → query-builder}/DataSpaceQueryBuilder.tsx +0 -0
  105. /package/src/components/{query → query-builder}/QueryDataSpaceUtil.ts +0 -0
@@ -1,445 +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 packageJson from '../../../package.json' assert { type: 'json' };
18
- import {
19
- type ExistingQueryEditorStateBuilder,
20
- type QueryEditorStore,
21
- type QuerySetupActionConfiguration,
22
- ExistingQueryEditorStore,
23
- LegendQueryApplicationPlugin,
24
- LEGEND_QUERY_APP_EVENT,
25
- createViewProjectHandler,
26
- createViewSDLCProjectHandler,
27
- type QueryEditorActionConfiguration,
28
- type NewQueryNavigationPath,
29
- } from '@finos/legend-application-query';
30
- import { ArrowCircleUpIcon, SquareIcon } from '@finos/legend-art';
31
- import {
32
- ActionAlertActionType,
33
- ActionAlertType,
34
- type ApplicationPageEntry,
35
- } from '@finos/legend-application';
36
- import {
37
- DATA_SPACE_QUERY_ROUTE_PATTERN,
38
- generateDataSpaceQueryCreatorRoute,
39
- generateDataSpaceQuerySetupRoute,
40
- } from '../../__lib__/query/DSL_DataSpace_LegendQueryNavigation.js';
41
- import { DataSpaceQueryCreator } from './DataSpaceQueryCreator.js';
42
- import {
43
- type Query,
44
- type Mapping,
45
- type PackageableRuntime,
46
- } from '@finos/legend-graph';
47
- import {
48
- DataSpaceQueryBuilderState,
49
- DataSpaceProjectInfo,
50
- } from '../../stores/query-builder/DataSpaceQueryBuilderState.js';
51
- import type { DataSpaceInfo } from '../../stores/shared/DataSpaceInfo.js';
52
- import { getOwnDataSpace } from '../../graph-manager/DSL_DataSpace_GraphManagerHelper.js';
53
- import {
54
- assertErrorThrown,
55
- buildUrl,
56
- guaranteeNonNullable,
57
- LogEvent,
58
- } from '@finos/legend-shared';
59
- import type { QueryBuilderState } from '@finos/legend-query-builder';
60
- import { DataSpaceQuerySetup } from './DataSpaceQuerySetup.js';
61
- import { DSL_DataSpace_getGraphManagerExtension } from '../../graph-manager/protocol/pure/DSL_DataSpace_PureGraphManagerExtension.js';
62
- import {
63
- LATEST_VERSION_ALIAS,
64
- StoreProjectData,
65
- } from '@finos/legend-server-depot';
66
- import { retrieveAnalyticsResultCache } from '../../graph-manager/action/analytics/DataSpaceAnalysisHelper.js';
67
- import { flowResult } from 'mobx';
68
- import type {
69
- DataSpace,
70
- DataSpaceExecutionContext,
71
- } from '../../graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.js';
72
- import { DataSpaceTemplateQueryCreator } from './DataSpaceTemplateQueryCreator.js';
73
- import { DataSpaceTemplateQueryCreatorStore } from '../../stores/query/DataSpaceTemplateQueryCreatorStore.js';
74
- import { parseProjectIdentifier } from '@finos/legend-storage';
75
- import { getDataSpaceQueryInfo } from './QueryDataSpaceUtil.js';
76
- import { generateDataSpaceTemplateQueryPromotionRoute } from '../../__lib__/shared/DSL_DataSpace_LegendNavigation.js';
77
-
78
- const resolveExecutionContext = (
79
- dataSpace: DataSpace,
80
- queryMapping: Mapping,
81
- queryRuntime: PackageableRuntime,
82
- ): DataSpaceExecutionContext | undefined => {
83
- const matchingExecContexts = dataSpace.executionContexts.filter(
84
- (ec) => ec.mapping.value === queryMapping,
85
- );
86
- if (matchingExecContexts.length > 1) {
87
- const matchRuntime = matchingExecContexts.find(
88
- (exec) => exec.defaultRuntime.value.path === queryRuntime.path,
89
- );
90
- // TODO: we will safely do this for now. Long term we should save exec context key into query store
91
- // we should make runtime/mapping optional
92
- return matchRuntime ?? matchingExecContexts[0];
93
- }
94
- return matchingExecContexts[0];
95
- };
96
-
97
- export class DSL_DataSpace_LegendQueryApplicationPlugin extends LegendQueryApplicationPlugin {
98
- constructor() {
99
- super(packageJson.extensions.applicationQueryPlugin, packageJson.version);
100
- }
101
-
102
- override getExtraRootAppRedirectPath(): string | undefined {
103
- return DATA_SPACE_QUERY_ROUTE_PATTERN.SETUP;
104
- }
105
-
106
- override getExtraApplicationPageEntries(): ApplicationPageEntry[] {
107
- return [
108
- // data space query editor setup
109
- {
110
- key: 'data-space-query-setup-application-page',
111
- addressPatterns: [DATA_SPACE_QUERY_ROUTE_PATTERN.SETUP],
112
- renderer: DataSpaceQuerySetup,
113
- },
114
- // data space template query creator
115
- // Heads-up: TEMPLATE_QUERY must come before CREATE as it has a more specific pattern than CREATE.
116
- {
117
- key: 'data-space-template-query-viewer-application-page',
118
- addressPatterns: [DATA_SPACE_QUERY_ROUTE_PATTERN.TEMPLATE_QUERY],
119
- renderer: DataSpaceTemplateQueryCreator,
120
- },
121
- // data space query editor
122
- {
123
- key: 'data-space-query-editor-application-page',
124
- addressPatterns: [DATA_SPACE_QUERY_ROUTE_PATTERN.CREATE],
125
- renderer: DataSpaceQueryCreator,
126
- },
127
- ];
128
- }
129
-
130
- override getExtraQuerySetupActionConfigurations(): QuerySetupActionConfiguration[] {
131
- return [
132
- {
133
- key: 'create-query-from-data-space',
134
- isAdvanced: false,
135
- isCreateAction: true,
136
- action: async (setupStore) => {
137
- setupStore.applicationStore.navigationService.navigator.goToLocation(
138
- generateDataSpaceQuerySetupRoute(),
139
- );
140
- },
141
- label: 'Create query from data space',
142
- className: 'query-setup__landing-page__action--data-space',
143
- icon: (
144
- <SquareIcon className="query-setup__landing-page__icon--data-space" />
145
- ),
146
- },
147
- ];
148
- }
149
-
150
- override getExtraExistingQueryEditorStateBuilders(): ExistingQueryEditorStateBuilder[] {
151
- return [
152
- async (
153
- query: Query,
154
- editorStore: ExistingQueryEditorStore,
155
- ): Promise<QueryBuilderState | undefined> => {
156
- const dataSpacePath = getDataSpaceQueryInfo(query);
157
- if (dataSpacePath) {
158
- const dataSpace = getOwnDataSpace(
159
- dataSpacePath,
160
- editorStore.graphManagerState.graph,
161
- );
162
- const mapping = query.mapping.value;
163
- const matchingExecutionContext = resolveExecutionContext(
164
- dataSpace,
165
- mapping,
166
- query.runtime.value,
167
- );
168
- if (!matchingExecutionContext) {
169
- // if a matching execution context is not found, it means this query is not
170
- // properly created from a data space, therefore, we cannot support this case
171
- return undefined;
172
- }
173
- let dataSpaceAnalysisResult;
174
- try {
175
- const project = StoreProjectData.serialization.fromJson(
176
- await editorStore.depotServerClient.getProject(
177
- query.groupId,
178
- query.artifactId,
179
- ),
180
- );
181
- dataSpaceAnalysisResult =
182
- await DSL_DataSpace_getGraphManagerExtension(
183
- editorStore.graphManagerState.graphManager,
184
- ).retrieveDataSpaceAnalysisFromCache(() =>
185
- retrieveAnalyticsResultCache(
186
- project,
187
- query.versionId,
188
- dataSpace.path,
189
- editorStore.depotServerClient,
190
- ),
191
- );
192
- } catch {
193
- // do nothing
194
- }
195
- const projectInfo = new DataSpaceProjectInfo(
196
- query.groupId,
197
- query.artifactId,
198
- query.versionId,
199
- createViewProjectHandler(editorStore.applicationStore),
200
- createViewSDLCProjectHandler(
201
- editorStore.applicationStore,
202
- editorStore.depotServerClient,
203
- ),
204
- );
205
- const sourceInfo = {
206
- groupId: projectInfo.groupId,
207
- artifactId: projectInfo.artifactId,
208
- versionId: projectInfo.versionId,
209
- dataSpace: dataSpace.path,
210
- };
211
- const dataSpaceQueryBuilderState = new DataSpaceQueryBuilderState(
212
- editorStore.applicationStore,
213
- editorStore.graphManagerState,
214
- editorStore.depotServerClient,
215
- dataSpace,
216
- matchingExecutionContext,
217
- (dataSpaceInfo: DataSpaceInfo) => {
218
- if (dataSpaceInfo.defaultExecutionContext) {
219
- const proceed = (): void =>
220
- editorStore.applicationStore.navigationService.navigator.goToLocation(
221
- generateDataSpaceQueryCreatorRoute(
222
- guaranteeNonNullable(dataSpaceInfo.groupId),
223
- guaranteeNonNullable(dataSpaceInfo.artifactId),
224
- LATEST_VERSION_ALIAS, //always default to latest
225
- dataSpaceInfo.path,
226
- guaranteeNonNullable(
227
- dataSpaceInfo.defaultExecutionContext,
228
- ),
229
- undefined,
230
- undefined,
231
- ),
232
- );
233
- const updateQueryAndProceed = async (): Promise<void> => {
234
- try {
235
- await flowResult(
236
- editorStore.updateState.updateQuery(undefined, undefined),
237
- );
238
- proceed();
239
- } catch (error) {
240
- assertErrorThrown(error);
241
- editorStore.applicationStore.logService.error(
242
- LogEvent.create(LEGEND_QUERY_APP_EVENT.GENERIC_FAILURE),
243
- error,
244
- );
245
- editorStore.applicationStore.notificationService.notifyError(
246
- error,
247
- );
248
- }
249
- };
250
- if (
251
- !query.isCurrentUserQuery ||
252
- !editorStore.queryBuilderState?.changeDetectionState
253
- .hasChanged
254
- ) {
255
- proceed();
256
- } else {
257
- editorStore.applicationStore.alertService.setActionAlertInfo({
258
- message: `To change the data space, you need to save the current query
259
- to proceed`,
260
- type: ActionAlertType.CAUTION,
261
- actions: [
262
- {
263
- label: 'Save query and Proceed',
264
- type: ActionAlertActionType.PROCEED_WITH_CAUTION,
265
- handler: () => {
266
- updateQueryAndProceed().catch(
267
- editorStore.applicationStore.alertUnhandledError,
268
- );
269
- },
270
- },
271
- {
272
- label: 'Abort',
273
- type: ActionAlertActionType.PROCEED,
274
- default: true,
275
- },
276
- ],
277
- });
278
- }
279
- } else {
280
- editorStore.applicationStore.notificationService.notifyWarning(
281
- `Can't switch data space: default execution context not specified`,
282
- );
283
- }
284
- },
285
- true,
286
- dataSpaceAnalysisResult,
287
- undefined,
288
- undefined,
289
- undefined,
290
- projectInfo,
291
- editorStore.applicationStore.config.options.queryBuilderConfig,
292
- sourceInfo,
293
- );
294
- const mappingModelCoverageAnalysisResult =
295
- dataSpaceAnalysisResult?.executionContextsIndex.get(
296
- matchingExecutionContext.name,
297
- )?.mappingModelCoverageAnalysisResult;
298
- if (mappingModelCoverageAnalysisResult) {
299
- dataSpaceQueryBuilderState.explorerState.mappingModelCoverageAnalysisResult =
300
- mappingModelCoverageAnalysisResult;
301
- }
302
- return dataSpaceQueryBuilderState;
303
- }
304
- return undefined;
305
- },
306
- ];
307
- }
308
-
309
- override getExtraNewQueryNavigationPaths(): NewQueryNavigationPath[] {
310
- return [
311
- (
312
- query: Query,
313
- editorStore: ExistingQueryEditorStore,
314
- ): string | undefined => {
315
- const dataSpacePath = getDataSpaceQueryInfo(query);
316
- const queryBuilderState = editorStore.queryBuilderState;
317
- if (
318
- dataSpacePath &&
319
- queryBuilderState instanceof DataSpaceQueryBuilderState
320
- ) {
321
- queryBuilderState.executionContext.name;
322
- return generateDataSpaceQueryCreatorRoute(
323
- query.groupId,
324
- query.artifactId,
325
- query.versionId,
326
- dataSpacePath,
327
- // TODO: fix execution key once that is fixed
328
- queryBuilderState.executionContext.name,
329
- undefined,
330
- undefined,
331
- );
332
- }
333
- return undefined;
334
- },
335
- ];
336
- }
337
-
338
- override getExtraQueryHeaders(): ((
339
- editorStore: QueryEditorStore,
340
- ) => React.ReactNode | undefined)[] {
341
- return [
342
- (editorStore: QueryEditorStore): React.ReactNode | undefined => {
343
- if (editorStore instanceof DataSpaceTemplateQueryCreatorStore) {
344
- return (
345
- <div className="query-editor__dataspace__header">
346
- <div className="query-editor__header__content__main query-editor__header__content__title__text query-editor__dataspace__header__title__text">
347
- {editorStore.templateQueryTitle}
348
- </div>
349
- <div className="query-editor__dataspace__header__title__tag">
350
- template
351
- </div>
352
- </div>
353
- );
354
- }
355
- return undefined;
356
- },
357
- ];
358
- }
359
-
360
- override getExtraQueryEditorActionConfigurations(): QueryEditorActionConfiguration[] {
361
- return [
362
- {
363
- key: 'promote-as-curated-template-query',
364
- renderer: (editorStore, queryBuilderState) => {
365
- const proceedCuratedTemplateQueryPromotion =
366
- async (): Promise<void> => {
367
- if (
368
- !(
369
- editorStore instanceof ExistingQueryEditorStore &&
370
- queryBuilderState instanceof DataSpaceQueryBuilderState
371
- )
372
- ) {
373
- return;
374
- }
375
- // fetch project data
376
- const project = StoreProjectData.serialization.fromJson(
377
- await editorStore.depotServerClient.getProject(
378
- editorStore.lightQuery.groupId,
379
- editorStore.lightQuery.artifactId,
380
- ),
381
- );
382
-
383
- // find the matching SDLC instance
384
- const projectIDPrefix = parseProjectIdentifier(
385
- project.projectId,
386
- ).prefix;
387
- const matchingSDLCEntry =
388
- editorStore.applicationStore.config.studioInstances.find(
389
- (entry) => entry.sdlcProjectIDPrefix === projectIDPrefix,
390
- );
391
- if (matchingSDLCEntry) {
392
- editorStore.applicationStore.navigationService.navigator.visitAddress(
393
- buildUrl([
394
- editorStore.applicationStore.config.studioApplicationUrl,
395
- generateDataSpaceTemplateQueryPromotionRoute(
396
- editorStore.lightQuery.groupId,
397
- editorStore.lightQuery.artifactId,
398
- editorStore.lightQuery.versionId,
399
- queryBuilderState.dataSpace.path,
400
- editorStore.lightQuery.id,
401
- ),
402
- ]),
403
- );
404
- } else {
405
- editorStore.applicationStore.notificationService.notifyWarning(
406
- `Can't find the corresponding SDLC instance to productionize the query`,
407
- );
408
- }
409
- };
410
-
411
- const proceed = (): void => {
412
- queryBuilderState.changeDetectionState.alertUnsavedChanges(() => {
413
- proceedCuratedTemplateQueryPromotion().catch(
414
- editorStore.applicationStore.alertUnhandledError,
415
- );
416
- });
417
- };
418
-
419
- return (
420
- <>
421
- {editorStore instanceof ExistingQueryEditorStore &&
422
- queryBuilderState instanceof DataSpaceQueryBuilderState && (
423
- <button
424
- className="query-editor__header__action btn--dark"
425
- tabIndex={-1}
426
- onClick={proceed}
427
- title={
428
- !(editorStore instanceof ExistingQueryEditorStore)
429
- ? 'Please save your query first before promoting'
430
- : 'Promote Curated Template query...'
431
- }
432
- >
433
- <ArrowCircleUpIcon className="query-editor__header__action__icon--productionize" />
434
- <div className="query-editor__header__action__label">
435
- Promote as Template Query
436
- </div>
437
- </button>
438
- )}
439
- </>
440
- );
441
- },
442
- },
443
- ];
444
- }
445
- }
@@ -1,99 +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 { observer, useLocalObservable } from 'mobx-react-lite';
18
- import { useApplicationStore } from '@finos/legend-application';
19
- import { useParams } from '@finos/legend-application/browser';
20
- import {
21
- QueryEditor,
22
- QueryEditorStoreContext,
23
- useLegendQueryApplicationStore,
24
- useLegendQueryBaseStore,
25
- } from '@finos/legend-application-query';
26
- import { DataSpaceQueryCreatorStore } from '../../stores/query/DataSpaceQueryCreatorStore.js';
27
- import {
28
- type DataSpaceQueryCreatorPathParams,
29
- DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN,
30
- DATA_SPACE_QUERY_CREATOR_QUERY_PARAM_TOKEN,
31
- } from '../../__lib__/query/DSL_DataSpace_LegendQueryNavigation.js';
32
- import { parseGAVCoordinates } from '@finos/legend-storage';
33
-
34
- const DataSpaceQueryCreatorStoreProvider: React.FC<{
35
- children: React.ReactNode;
36
- gav: string;
37
- dataSpacePath: string;
38
- executionContext: string;
39
- runtimePath: string | undefined;
40
- classPath: string | undefined;
41
- }> = ({
42
- children,
43
- gav,
44
- dataSpacePath,
45
- executionContext,
46
- runtimePath,
47
- classPath,
48
- }) => {
49
- const { groupId, artifactId, versionId } = parseGAVCoordinates(gav);
50
- const applicationStore = useLegendQueryApplicationStore();
51
- const baseStore = useLegendQueryBaseStore();
52
- const store = useLocalObservable(
53
- () =>
54
- new DataSpaceQueryCreatorStore(
55
- applicationStore,
56
- baseStore.depotServerClient,
57
- groupId,
58
- artifactId,
59
- versionId,
60
- dataSpacePath,
61
- executionContext,
62
- runtimePath,
63
- classPath,
64
- ),
65
- );
66
- return (
67
- <QueryEditorStoreContext.Provider value={store}>
68
- {children}
69
- </QueryEditorStoreContext.Provider>
70
- );
71
- };
72
-
73
- export const DataSpaceQueryCreator = observer(() => {
74
- const applicationStore = useApplicationStore();
75
- const parameters = useParams<DataSpaceQueryCreatorPathParams>();
76
- const gav = parameters[DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.GAV];
77
- const dataSpacePath =
78
- parameters[DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.DATA_SPACE_PATH];
79
- const executionContext =
80
- parameters[DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.EXECUTION_CONTEXT];
81
- const runtimePath =
82
- parameters[DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.RUNTIME_PATH];
83
- const classPath =
84
- applicationStore.navigationService.navigator.getCurrentLocationParameterValue(
85
- DATA_SPACE_QUERY_CREATOR_QUERY_PARAM_TOKEN.CLASS_PATH,
86
- );
87
-
88
- return (
89
- <DataSpaceQueryCreatorStoreProvider
90
- gav={gav}
91
- dataSpacePath={dataSpacePath}
92
- executionContext={executionContext}
93
- runtimePath={runtimePath}
94
- classPath={classPath}
95
- >
96
- <QueryEditor />
97
- </DataSpaceQueryCreatorStoreProvider>
98
- );
99
- });