@finos/legend-query-builder 4.17.82 → 4.17.84

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.
@@ -0,0 +1,131 @@
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
+ import { DataProduct, ModelAccessPointGroup, CORE_PURE_PATH, resolveUsableDataProductClasses, } from '@finos/legend-graph';
17
+ import { QueryBuilderState } from '../../QueryBuilderState.js';
18
+ import {} from '@finos/legend-application';
19
+ import { renderDataProductQueryBuilderSetupPanelContent } from '../../../components/workflows/DataProductQueryBuilder.js';
20
+ import { ActionState, filterByType, } from '@finos/legend-shared';
21
+ import { action, computed, flow, makeObservable, observable } from 'mobx';
22
+ import { DepotEntityWithOrigin, } from '@finos/legend-storage';
23
+ import { compareLabelFn } from '@finos/legend-art';
24
+ export const buildDataProductOption = (value) => ({
25
+ label: value.name,
26
+ value,
27
+ });
28
+ export const buildExecOptions = (val) => {
29
+ return {
30
+ label: val.key,
31
+ value: val,
32
+ };
33
+ };
34
+ export class DataProductQueryBuilderState extends QueryBuilderState {
35
+ onClassChange;
36
+ onDataProductChange;
37
+ onExecutionContextChange;
38
+ loadDataProductModelState = ActionState.create();
39
+ nativeModelAccess;
40
+ dataProduct;
41
+ dataProductArtifact;
42
+ selectedExecContext;
43
+ entities;
44
+ prioritizeEntityFunc;
45
+ TEMPORARY__setupPanelContentRenderer = () => renderDataProductQueryBuilderSetupPanelContent(this);
46
+ constructor(applicationStore, graphManagerState, workflow, dataProduct, artifact, actionConfig, nativeNativeModelAccess, nativeModelExecContext, prioritizeEntityFunc, onDataProductChange, onExecutionContextChange, onClassChange, config, sourceInfo) {
47
+ super(applicationStore, graphManagerState, workflow, config, sourceInfo);
48
+ makeObservable(this, {
49
+ selectedExecContext: observable,
50
+ dataProduct: observable,
51
+ setExecOptions: action,
52
+ selectedDataProductOption: computed,
53
+ isProductLinkable: computed,
54
+ loadEntities: flow,
55
+ entities: observable,
56
+ });
57
+ this.workflowState.updateActionConfig(actionConfig);
58
+ this.dataProduct = dataProduct;
59
+ this.dataProductArtifact = artifact;
60
+ this.nativeModelAccess = nativeNativeModelAccess;
61
+ this.selectedExecContext = nativeModelExecContext;
62
+ this.prioritizeEntityFunc = prioritizeEntityFunc;
63
+ this.onDataProductChange = onDataProductChange;
64
+ this.onExecutionContextChange = onExecutionContextChange;
65
+ this.onClassChange = onClassChange;
66
+ }
67
+ get isProductLinkable() {
68
+ return false;
69
+ }
70
+ copyDataProductLinkToClipBoard() {
71
+ if (!this.isProductLinkable) {
72
+ this.applicationStore.notificationService.notifyError('Data Product link is not available.');
73
+ }
74
+ }
75
+ getElementType() {
76
+ return DataProduct;
77
+ }
78
+ setExecOptions(exec) {
79
+ this.selectedExecContext = exec;
80
+ }
81
+ *loadEntities() {
82
+ this.loadDataProductModelState.inProgress();
83
+ this.entities = this.graphManagerState.graph.allOwnElements
84
+ .filter(filterByType(this.getElementType()))
85
+ .map((element) => this.transformElement(element));
86
+ this.loadDataProductModelState.complete();
87
+ }
88
+ transformElement(element) {
89
+ return new DepotEntityWithOrigin(undefined, element.name, element.path, CORE_PURE_PATH.DATA_PRODUCT);
90
+ }
91
+ get dataProductOptions() {
92
+ const sortedAllOptions = (this.entities ?? [])
93
+ .map(buildDataProductOption)
94
+ .sort(compareLabelFn);
95
+ return this.prioritizeEntityFunc
96
+ ? [
97
+ ...sortedAllOptions.filter((val) => this.prioritizeEntityFunc?.(val.value)),
98
+ ...sortedAllOptions.filter((val) => !this.prioritizeEntityFunc?.(val.value)),
99
+ ]
100
+ : sortedAllOptions;
101
+ }
102
+ get selectedDataProductOption() {
103
+ return {
104
+ label: this.dataProduct.title ?? this.dataProduct.name,
105
+ value: new DepotEntityWithOrigin(undefined, this.dataProduct.name, this.dataProduct.path, CORE_PURE_PATH.DATA_PRODUCT),
106
+ };
107
+ }
108
+ get isSupported() {
109
+ return (this.dataProduct.nativeModelAccess !== undefined ||
110
+ // contains model access point group
111
+ this.dataProduct.accessPointGroups.filter(filterByType(ModelAccessPointGroup)).length > 0);
112
+ }
113
+ // includes model access point group if more than one group
114
+ get execOptions() {
115
+ return (this.dataProduct.nativeModelAccess?.nativeModelExecutionContexts.map(buildExecOptions) ?? []).sort(compareLabelFn);
116
+ }
117
+ async propagateExecutionContextChange(requireReBuildingGraph) {
118
+ const currentMapping = this.executionContextState.mapping;
119
+ const execMapping = this.selectedExecContext.mapping.value;
120
+ if (execMapping !== currentMapping) {
121
+ this.changeMapping(execMapping, {
122
+ keepQueryContent: true,
123
+ });
124
+ const classes = resolveUsableDataProductClasses(this.nativeModelAccess.featuredElements, this.selectedExecContext.mapping.value, this.graphManagerState, undefined);
125
+ if (this.class && !classes.includes(this.class)) {
126
+ this.setClass(classes[0]);
127
+ }
128
+ }
129
+ }
130
+ }
131
+ //# sourceMappingURL=DataProductQueryBuilderState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataProductQueryBuilderState.js","sourceRoot":"","sources":["../../../../src/stores/workflows/dataProduct/DataProductQueryBuilderState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAGL,WAAW,EAEX,qBAAqB,EAErB,cAAc,EAEd,+BAA+B,GAChC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAsC,MAAM,2BAA2B,CAAC;AAM/E,OAAO,EAAE,8CAA8C,EAAE,MAAM,0DAA0D,CAA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I,CAAC,WAAW,CAAC,iBAAiB,CAAC,MAAM,CACvC,YAAY,CAAC,qBAAqB,CAAC,CACpC,CAAC,MAAM,GAAG,CAAC,CACb,CAAC;IACJ,CAAC;IAED,2DAA2D;IAC3D,IAAI,WAAW;QACb,OAAO,CACL,IAAI,CAAC,WAAW,CAAC,iBAAiB,EAAE,4BAA4B,CAAC,GAAG,CAClE,gBAAgB,CACjB,IAAI,EAAE,CACR,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACzB,CAAC;IAEQ,KAAK,CAAC,+BAA+B,CAC5C,sBAA4C;QAE5C,MAAM,cAAc,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC;QAC1D,MAAM,WAAW,GAAG,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC;QAC3D,IAAI,WAAW,KAAK,cAAc,EAAE,CAAC;YACnC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE;gBAC9B,gBAAgB,EAAE,IAAI;aACvB,CAAC,CAAC;YACH,MAAM,OAAO,GAAG,+BAA+B,CAC7C,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,EACvC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,KAAK,EACtC,IAAI,CAAC,iBAAiB,EACtB,SAAS,CACV,CAAC;YACF,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBAChD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finos/legend-query-builder",
3
- "version": "4.17.82",
3
+ "version": "4.17.84",
4
4
  "description": "Legend query builder core",
5
5
  "keywords": [
6
6
  "legend",
@@ -43,15 +43,15 @@
43
43
  "test:watch": "jest --watch"
44
44
  },
45
45
  "dependencies": {
46
- "@finos/legend-application": "16.0.93",
46
+ "@finos/legend-application": "16.0.95",
47
47
  "@finos/legend-art": "7.1.141",
48
- "@finos/legend-code-editor": "2.0.149",
49
- "@finos/legend-data-cube": "0.3.64",
50
- "@finos/legend-graph": "32.3.29",
51
- "@finos/legend-lego": "2.0.166",
52
- "@finos/legend-server-depot": "6.1.7",
48
+ "@finos/legend-code-editor": "2.0.151",
49
+ "@finos/legend-data-cube": "0.3.66",
50
+ "@finos/legend-graph": "32.3.31",
51
+ "@finos/legend-lego": "2.0.168",
52
+ "@finos/legend-server-depot": "6.1.9",
53
53
  "@finos/legend-shared": "11.0.22",
54
- "@finos/legend-storage": "3.0.141",
54
+ "@finos/legend-storage": "3.0.143",
55
55
  "@testing-library/dom": "10.4.0",
56
56
  "@testing-library/react": "16.2.0",
57
57
  "@types/react": "19.0.10",
@@ -0,0 +1,198 @@
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 { useApplicationStore } from '@finos/legend-application';
18
+ import {
19
+ buildExecOptions,
20
+ type DataProductOption,
21
+ type DataProductQueryBuilderState,
22
+ } from '../../stores/workflows/dataProduct/DataProductQueryBuilderState.js';
23
+ import { CustomSelectorInput } from '@finos/legend-art';
24
+ import { QueryBuilderClassSelector } from '../QueryBuilderSideBar.js';
25
+ import { observer } from 'mobx-react-lite';
26
+ import {
27
+ resolveUsableDataProductClasses,
28
+ type NativeModelExecutionContext,
29
+ } from '@finos/legend-graph';
30
+ import type { DepotEntityWithOrigin } from '@finos/legend-storage';
31
+ import { useEffect } from 'react';
32
+ import { flowResult } from 'mobx';
33
+
34
+ export type NativeExecutionContextOption = {
35
+ label: string;
36
+ value: NativeModelExecutionContext;
37
+ };
38
+
39
+ export const buildNativeExecutionContextOption = (
40
+ value: NativeModelExecutionContext,
41
+ ): NativeExecutionContextOption => ({
42
+ label: value.key,
43
+ value,
44
+ });
45
+
46
+ export type DataProductRuntimeInfoOption = {
47
+ label: string;
48
+ value: NativeModelExecutionContext;
49
+ };
50
+ export const buildDataProductRuntimeInfoOption = (
51
+ value: NativeModelExecutionContext,
52
+ ): DataProductRuntimeInfoOption => ({
53
+ label: value.key,
54
+ value,
55
+ });
56
+
57
+ export const buildDataProductOption = (
58
+ value: DepotEntityWithOrigin,
59
+ ): DataProductOption => ({
60
+ label: value.name,
61
+ value,
62
+ });
63
+
64
+ const DataProductQueryBuilderSetupPanelContent = observer(
65
+ (props: { queryBuilderState: DataProductQueryBuilderState }) => {
66
+ const { queryBuilderState } = props;
67
+ const applicationStore = useApplicationStore();
68
+ // data product
69
+ const nativeAccessGroup = queryBuilderState.nativeModelAccess;
70
+ const selectedExecContext = queryBuilderState.selectedExecContext;
71
+ const dataProductOptions = queryBuilderState.dataProductOptions;
72
+ const selectedDataProductOption =
73
+ queryBuilderState.selectedDataProductOption;
74
+ const onDataProductOptionChange = (
75
+ option: DataProductOption | null,
76
+ ): void => {
77
+ if (option?.value) {
78
+ queryBuilderState
79
+ .onDataProductChange?.(option.value)
80
+ .catch(queryBuilderState.applicationStore.alertUnhandledError);
81
+ }
82
+ };
83
+ // execution context
84
+ const executionContextOptions = queryBuilderState.execOptions;
85
+ const showExecutionContextOptions = executionContextOptions.length > 1;
86
+ const selectedExecOptions = buildExecOptions(selectedExecContext);
87
+ // class
88
+ const classes = resolveUsableDataProductClasses(
89
+ nativeAccessGroup.featuredElements,
90
+ selectedExecContext.mapping.value,
91
+ queryBuilderState.graphManagerState,
92
+ undefined,
93
+ );
94
+
95
+ useEffect(() => {
96
+ flowResult(queryBuilderState.loadEntities()).catch(
97
+ applicationStore.alertUnhandledError,
98
+ );
99
+ }, [queryBuilderState, applicationStore]);
100
+
101
+ const onExecutionContextOptionChange = async (
102
+ option: NativeExecutionContextOption,
103
+ ): Promise<void> => {
104
+ if (option.value === queryBuilderState.selectedExecContext) {
105
+ return;
106
+ }
107
+ const currentMapping =
108
+ queryBuilderState.selectedExecContext.mapping.value.path;
109
+ queryBuilderState.setExecOptions(option.value);
110
+ await queryBuilderState.propagateExecutionContextChange(
111
+ currentMapping === option.value.mapping.value.path,
112
+ );
113
+ queryBuilderState.onExecutionContextChange?.(option.value);
114
+ };
115
+
116
+ const handleExecutionContextOptionChange = (
117
+ option: NativeExecutionContextOption,
118
+ ): void => {
119
+ flowResult(onExecutionContextOptionChange(option));
120
+ };
121
+
122
+ return (
123
+ <div className="query-builder__setup__config-group">
124
+ <div className="query-builder__setup__config-group__content">
125
+ <div className="query-builder__setup__config-group__item">
126
+ <label
127
+ className="btn--sm query-builder__setup__config-group__data-product"
128
+ title="data product"
129
+ htmlFor="query-builder__setup__data-product-selector"
130
+ >
131
+ Data Product
132
+ </label>
133
+ <CustomSelectorInput
134
+ inputId="query-builder__setup__data-product-selector"
135
+ className="panel__content__form__section__dropdown query-builder__setup__config-group__item__selector"
136
+ options={dataProductOptions}
137
+ isLoading={
138
+ queryBuilderState.loadDataProductModelState.isInProgress
139
+ }
140
+ onChange={onDataProductOptionChange}
141
+ value={selectedDataProductOption}
142
+ placeholder="Search for data product..."
143
+ escapeClearsValue={true}
144
+ darkMode={
145
+ !applicationStore.layoutService
146
+ .TEMPORARY__isLightColorThemeEnabled
147
+ }
148
+ />
149
+ </div>
150
+ {Boolean(showExecutionContextOptions) && (
151
+ <div className="query-builder__setup__config-group__item">
152
+ <label
153
+ className="btn--sm query-builder__setup__config-group__item__label"
154
+ title="execution context"
155
+ htmlFor="query-builder__setup__context-selector"
156
+ >
157
+ Context
158
+ </label>
159
+ <CustomSelectorInput
160
+ inputId="query-builder__setup__context-selector"
161
+ className="panel__content__form__section__dropdown query-builder__setup__config-group__item__selector"
162
+ placeholder="Choose an execution context..."
163
+ options={executionContextOptions}
164
+ disabled={
165
+ executionContextOptions.length < 1 ||
166
+ (executionContextOptions.length === 1 &&
167
+ Boolean(selectedExecOptions))
168
+ }
169
+ onChange={handleExecutionContextOptionChange}
170
+ value={selectedExecOptions}
171
+ darkMode={
172
+ !applicationStore.layoutService
173
+ .TEMPORARY__isLightColorThemeEnabled
174
+ }
175
+ />
176
+ </div>
177
+ )}
178
+ <div className="query-builder__setup__config-group__item">
179
+ <QueryBuilderClassSelector
180
+ queryBuilderState={queryBuilderState}
181
+ classes={classes}
182
+ onClassChange={queryBuilderState.onClassChange}
183
+ noMatchMessage="No compatible entity found for specified execution context"
184
+ />
185
+ </div>
186
+ </div>
187
+ </div>
188
+ );
189
+ },
190
+ );
191
+
192
+ export const renderDataProductQueryBuilderSetupPanelContent = (
193
+ queryBuilderState: DataProductQueryBuilderState,
194
+ ): React.ReactNode => (
195
+ <DataProductQueryBuilderSetupPanelContent
196
+ queryBuilderState={queryBuilderState}
197
+ />
198
+ );
package/src/index.ts CHANGED
@@ -34,9 +34,11 @@ export { QueryDataCubeViewer } from './components/data-cube/QueryBuilderDataCube
34
34
  export { QueryBuilder } from './components/QueryBuilder.js';
35
35
  export { QUERY_BUILDER_COMPONENT_ELEMENT_ID } from './components/QueryBuilderComponentElement.js';
36
36
  export {
37
- type QueryableSourceInfo as QuerySDLC,
38
37
  type QueryBuilderExtraFunctionAnalysisInfo,
38
+ type EntityWithOriginOption,
39
39
  QueryBuilderState,
40
+ ExtraOptionsConfig,
41
+ BaseQueryBuilderState,
40
42
  QUERY_BUILDER_LAMBDA_WRITER_MODE,
41
43
  INTERNAL__BasicQueryBuilderState,
42
44
  } from './stores/QueryBuilderState.js';
@@ -58,6 +60,7 @@ export {
58
60
  } from './components/QueryBuilderSideBar.js';
59
61
  export { ClassQueryBuilderState } from './stores/workflows/ClassQueryBuilderState.js';
60
62
  export { FunctionQueryBuilderState } from './stores/workflows/FunctionQueryBuilderState.js';
63
+ export { DataProductQueryBuilderState } from './stores/workflows/dataProduct/DataProductQueryBuilderState.js';
61
64
  export { MappingQueryBuilderState } from './stores/workflows/MappingQueryBuilderState.js';
62
65
  export {
63
66
  type ServiceExecutionContext,
@@ -116,9 +116,10 @@ import type { QueryBuilder_LegendApplicationPlugin_Extension } from './QueryBuil
116
116
  import { createDataCubeViewerStateFromQueryBuilder } from './data-cube/QueryBuilderDataCubeHelper.js';
117
117
  import type { QueryBuilderDataCubeViewerState } from './data-cube/QueryBuilderDataCubeViewerState.js';
118
118
  import { QueryBuilderTelemetryHelper } from '../__lib__/QueryBuilderTelemetryHelper.js';
119
-
120
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
121
- export interface QueryableSourceInfo {}
119
+ import type {
120
+ DepotEntityWithOrigin,
121
+ QueryableSourceInfo,
122
+ } from '@finos/legend-storage';
122
123
 
123
124
  export type QueryableClassMappingRuntimeInfo = QueryableSourceInfo & {
124
125
  class: string;
@@ -136,6 +137,53 @@ export enum QUERY_BUILDER_LAMBDA_WRITER_MODE {
136
137
  TYPED_FETCH_STRUCTURE = 'TYPED_FETCH_STRUCTURE',
137
138
  }
138
139
 
140
+ export type EntityWithOriginOption = {
141
+ label: string;
142
+ value: DepotEntityWithOrigin;
143
+ };
144
+
145
+ export class ExtraOptionsConfig<T> {
146
+ label: string;
147
+ type: string;
148
+ options:
149
+ | {
150
+ label: string;
151
+ value: T;
152
+ }[]
153
+ | undefined;
154
+ selectedValue: T | undefined;
155
+ onChange: (val: T) => void;
156
+ placeholder?: string | undefined;
157
+ disabled?: boolean | undefined;
158
+
159
+ constructor(
160
+ label: string,
161
+ type: string,
162
+ options: { label: string; value: T }[] | undefined,
163
+ selectedValue: T | undefined,
164
+ onChange: (val: T) => void,
165
+ placeholder?: string | undefined,
166
+ disabled?: boolean | undefined,
167
+ ) {
168
+ this.label = label;
169
+ this.type = type;
170
+ this.options = options;
171
+ this.selectedValue = selectedValue;
172
+ this.onChange = onChange;
173
+ this.placeholder = placeholder;
174
+ this.disabled = disabled;
175
+
176
+ makeObservable(this, {
177
+ options: observable,
178
+ setOptions: action,
179
+ });
180
+ }
181
+
182
+ setOptions(options: { label: string; value: T }[] | undefined): void {
183
+ this.options = options;
184
+ }
185
+ }
186
+
139
187
  export abstract class QueryBuilderState implements CommandRegistrar {
140
188
  readonly applicationStore: GenericLegendApplicationStore;
141
189
  readonly graphManagerState: GraphManagerState;
@@ -281,7 +329,6 @@ export abstract class QueryBuilderState implements CommandRegistrar {
281
329
  this.changeDetectionState = new QueryBuilderChangeDetectionState(this);
282
330
  this.changeHistoryState = new QueryBuilderChangeHistoryState(this);
283
331
  this.config = config;
284
-
285
332
  this.workflowState = workflowState;
286
333
  this.sourceInfo = sourceInfo;
287
334
  this.isQueryChatOpened =
@@ -960,6 +1007,17 @@ export abstract class QueryBuilderState implements CommandRegistrar {
960
1007
  }
961
1008
  }
962
1009
 
1010
+ /**
1011
+ * Base query builder state with result panel hidden.
1012
+ * This is useful for scenarios where the query builder is used
1013
+ * only for query construction without execution/result display.
1014
+ */
1015
+ export abstract class BaseQueryBuilderState extends QueryBuilderState {
1016
+ override get isResultPanelHidden(): boolean {
1017
+ return true;
1018
+ }
1019
+ }
1020
+
963
1021
  /**
964
1022
  * This type is used for testing and analytics operation in query builder.
965
1023
  * For example, we use this to build the preview data lambda, or to build the auto-complete lambda