@finos/legend-query-builder 4.15.0 → 4.15.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
  2. package/lib/components/QueryBuilderSideBar.js +4 -4
  3. package/lib/components/QueryBuilderSideBar.js.map +1 -1
  4. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts.map +1 -1
  5. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js +2 -1
  6. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js.map +1 -1
  7. package/lib/components/data-cube/QueryBuilderDataCube.d.ts.map +1 -1
  8. package/lib/components/data-cube/QueryBuilderDataCube.js +3 -10
  9. package/lib/components/data-cube/QueryBuilderDataCube.js.map +1 -1
  10. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +1 -1
  11. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
  12. package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
  13. package/lib/components/result/QueryBuilderResultPanel.js +13 -1
  14. package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
  15. package/lib/components/result/tds/QueryBuilderTDSGridResult.d.ts.map +1 -1
  16. package/lib/components/result/tds/QueryBuilderTDSGridResult.js +4 -4
  17. package/lib/components/result/tds/QueryBuilderTDSGridResult.js.map +1 -1
  18. package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -1
  19. package/lib/components/shared/BasicValueSpecificationEditor.js +5 -5
  20. package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
  21. package/lib/components/shared/CustomDatePicker.d.ts.map +1 -1
  22. package/lib/components/shared/CustomDatePicker.js +2 -2
  23. package/lib/components/shared/CustomDatePicker.js.map +1 -1
  24. package/lib/components/workflows/ClassQueryBuilder.d.ts.map +1 -1
  25. package/lib/components/workflows/ClassQueryBuilder.js +3 -3
  26. package/lib/components/workflows/ClassQueryBuilder.js.map +1 -1
  27. package/lib/components/workflows/MappingQueryBuilder.d.ts.map +1 -1
  28. package/lib/components/workflows/MappingQueryBuilder.js +3 -3
  29. package/lib/components/workflows/MappingQueryBuilder.js.map +1 -1
  30. package/lib/index.css +1 -1
  31. package/lib/package.json +7 -7
  32. package/lib/stores/data-cube/QueryBuilderDataCubeApplicationEngine.d.ts +1 -3
  33. package/lib/stores/data-cube/QueryBuilderDataCubeApplicationEngine.d.ts.map +1 -1
  34. package/lib/stores/data-cube/QueryBuilderDataCubeApplicationEngine.js +1 -7
  35. package/lib/stores/data-cube/QueryBuilderDataCubeApplicationEngine.js.map +1 -1
  36. package/lib/stores/data-cube/QueryBuilderDataCubeEngine.d.ts +5 -2
  37. package/lib/stores/data-cube/QueryBuilderDataCubeEngine.d.ts.map +1 -1
  38. package/lib/stores/data-cube/QueryBuilderDataCubeEngine.js +14 -2
  39. package/lib/stores/data-cube/QueryBuilderDataCubeEngine.js.map +1 -1
  40. package/lib/stores/data-cube/QueryBuilderDataCubeEngineHelper.d.ts +1 -1
  41. package/lib/stores/data-cube/QueryBuilderDataCubeEngineHelper.d.ts.map +1 -1
  42. package/lib/stores/data-cube/QueryBuilderDataCubeEngineHelper.js +8 -1
  43. package/lib/stores/data-cube/QueryBuilderDataCubeEngineHelper.js.map +1 -1
  44. package/lib/stores/shared/LambdaParameterState.d.ts +2 -1
  45. package/lib/stores/shared/LambdaParameterState.d.ts.map +1 -1
  46. package/lib/stores/shared/LambdaParameterState.js +1 -0
  47. package/lib/stores/shared/LambdaParameterState.js.map +1 -1
  48. package/package.json +17 -17
  49. package/src/components/QueryBuilderSideBar.tsx +11 -10
  50. package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +8 -2
  51. package/src/components/data-cube/QueryBuilderDataCube.tsx +4 -16
  52. package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +1 -1
  53. package/src/components/result/QueryBuilderResultPanel.tsx +23 -3
  54. package/src/components/result/tds/QueryBuilderTDSGridResult.tsx +11 -6
  55. package/src/components/shared/BasicValueSpecificationEditor.tsx +21 -15
  56. package/src/components/shared/CustomDatePicker.tsx +10 -17
  57. package/src/components/workflows/ClassQueryBuilder.tsx +6 -5
  58. package/src/components/workflows/MappingQueryBuilder.tsx +6 -5
  59. package/src/stores/data-cube/QueryBuilderDataCubeApplicationEngine.ts +1 -12
  60. package/src/stores/data-cube/QueryBuilderDataCubeEngine.ts +23 -0
  61. package/src/stores/data-cube/QueryBuilderDataCubeEngineHelper.ts +16 -1
  62. package/src/stores/shared/LambdaParameterState.ts +1 -0
@@ -1007,11 +1007,8 @@ const CustomDateInstanceValueEditor: React.FC<{
1007
1007
  value: t.toString(),
1008
1008
  label: t.toString(),
1009
1009
  }))}
1010
- onChange={(val: {
1011
- label: string;
1012
- value: CUSTOM_DATE_OPTION_UNIT;
1013
- }): void => {
1014
- setUnitValue(val.value);
1010
+ onChange={(val: { label: string; value: string }): void => {
1011
+ setUnitValue(val.value as CUSTOM_DATE_OPTION_UNIT);
1015
1012
  changeValue(
1016
1013
  durationValue,
1017
1014
  val.value,
@@ -1032,11 +1029,8 @@ const CustomDateInstanceValueEditor: React.FC<{
1032
1029
  value: t.toString(),
1033
1030
  label: t.toString(),
1034
1031
  }))}
1035
- onChange={(val: {
1036
- label: string;
1037
- value: CUSTOM_DATE_OPTION_DIRECTION;
1038
- }): void => {
1039
- setDirectionValue(val.value);
1032
+ onChange={(val: { label: string; value: string }): void => {
1033
+ setDirectionValue(val.value as CUSTOM_DATE_OPTION_DIRECTION);
1040
1034
  changeValue(
1041
1035
  durationValue,
1042
1036
  unitValue,
@@ -1059,11 +1053,10 @@ const CustomDateInstanceValueEditor: React.FC<{
1059
1053
  label: t.toString(),
1060
1054
  }),
1061
1055
  )}
1062
- onChange={(val: {
1063
- label: string;
1064
- value: CUSTOM_DATE_OPTION_REFERENCE_MOMENT;
1065
- }): void => {
1066
- setReferenceMomentValueValue(val.value);
1056
+ onChange={(val: { label: string; value: string }): void => {
1057
+ setReferenceMomentValueValue(
1058
+ val.value as CUSTOM_DATE_OPTION_REFERENCE_MOMENT,
1059
+ );
1067
1060
  changeValue(durationValue, unitValue, directionValue, val.value);
1068
1061
  }}
1069
1062
  value={{ value: referenceMomentValue, label: referenceMomentValue }}
@@ -1128,7 +1121,7 @@ const CustomFirstDayOfValueSpecificationEditor: React.FC<{
1128
1121
  <div className="value-spec-editor__date-picker__custom-date">
1129
1122
  <div className="value-spec-editor__date-picker__custom-date__input">
1130
1123
  <CustomSelectorInput
1131
- ref={selectorRef}
1124
+ inputRef={selectorRef}
1132
1125
  placeholder="Choose a unit..."
1133
1126
  className="value-spec-editor__date-picker__custom-date__input-dropdown value-spec-editor__date-picker__custom-date__input-dropdown--full"
1134
1127
  options={Object.values(CUSTOM_DATE_FIRST_DAY_OF_UNIT).map((t) => ({
@@ -1197,7 +1190,7 @@ const CustomPreviousDayOfWeekValueSpecificationEditor: React.FC<{
1197
1190
  <div className="value-spec-editor__date-picker__custom-date">
1198
1191
  <div className="value-spec-editor__date-picker__custom-date__input">
1199
1192
  <CustomSelectorInput
1200
- ref={selectorRef}
1193
+ inputRef={selectorRef}
1201
1194
  placeholder="Choose a day..."
1202
1195
  className="value-spec-editor__date-picker__custom-date__input-dropdown value-spec-editor__date-picker__custom-date__input-dropdown--full"
1203
1196
  options={Object.values(CUSTOM_DATE_DAY_OF_WEEK).map((t) => ({
@@ -90,8 +90,9 @@ const ClassQueryBuilderSetupPanelContent = observer(
90
90
  const mappingFilterOption = createFilter({
91
91
  ignoreCase: true,
92
92
  ignoreAccents: false,
93
- stringify: (option: PackageableElementOption<Mapping>): string =>
94
- option.value.path,
93
+ stringify: (option: {
94
+ data: PackageableElementOption<Mapping>;
95
+ }): string => option.data.value.path,
95
96
  });
96
97
 
97
98
  // runtime
@@ -124,9 +125,9 @@ const ClassQueryBuilderSetupPanelContent = observer(
124
125
  const runtimeFilterOption = createFilter({
125
126
  ignoreCase: true,
126
127
  ignoreAccents: false,
127
- stringify: (option: { value: Runtime }): string =>
128
- option.value instanceof RuntimePointer
129
- ? option.value.packageableRuntime.value.path
128
+ stringify: (option: { data: { value: Runtime } }): string =>
129
+ option.data.value instanceof RuntimePointer
130
+ ? option.data.value.packageableRuntime.value.path
130
131
  : 'custom',
131
132
  });
132
133
 
@@ -76,8 +76,9 @@ const MappingQueryBuilderSetupPanelContent = observer(
76
76
  const mappingFilterOption = createFilter({
77
77
  ignoreCase: true,
78
78
  ignoreAccents: false,
79
- stringify: (option: PackageableElementOption<Mapping>): string =>
80
- option.value.path,
79
+ stringify: (option: {
80
+ data: PackageableElementOption<Mapping>;
81
+ }): string => option.data.value.path,
81
82
  });
82
83
 
83
84
  // runtime
@@ -111,9 +112,9 @@ const MappingQueryBuilderSetupPanelContent = observer(
111
112
  const runtimeFilterOption = createFilter({
112
113
  ignoreCase: true,
113
114
  ignoreAccents: false,
114
- stringify: (option: { value: Runtime }): string =>
115
- guaranteeType(option.value, RuntimePointer).packageableRuntime.value
116
- .path,
115
+ stringify: (option: { data: { value: Runtime } }): string =>
116
+ guaranteeType(option.data.value, RuntimePointer).packageableRuntime
117
+ .value.path,
117
118
  });
118
119
 
119
120
  // class
@@ -19,10 +19,7 @@ import {
19
19
  shouldDisplayVirtualAssistantDocumentationEntry,
20
20
  type GenericLegendApplicationStore,
21
21
  } from '@finos/legend-application';
22
- import {
23
- DataCubeApplicationEngine,
24
- type ActionAlert,
25
- } from '@finos/legend-data-cube';
22
+ import { DataCubeApplicationEngine } from '@finos/legend-data-cube';
26
23
  import { LogEvent, type DocumentationEntry } from '@finos/legend-shared';
27
24
 
28
25
  export class QueryBuilderDataCubeApplicationEngine extends DataCubeApplicationEngine {
@@ -58,14 +55,6 @@ export class QueryBuilderDataCubeApplicationEngine extends DataCubeApplicationEn
58
55
  this.application.layoutService.setWindowTitle(title);
59
56
  }
60
57
 
61
- alertAction(alertInfo: ActionAlert | undefined) {
62
- this.currentActionAlert = alertInfo;
63
- }
64
-
65
- alertUnhandledError(error: Error) {
66
- this.application.alertUnhandledError(error);
67
- }
68
-
69
58
  logDebug(message: string, ...data: unknown[]) {
70
59
  this.application.logService.debug(
71
60
  LogEvent.create(APPLICATION_EVENT.DEBUG),
@@ -28,6 +28,7 @@ import {
28
28
  type GraphManagerState,
29
29
  type PureModel,
30
30
  type V1_ValueSpecification,
31
+ type ParameterValue,
31
32
  } from '@finos/legend-graph';
32
33
  import {
33
34
  _elementPtr,
@@ -67,9 +68,13 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
67
68
  readonly graphState: GraphManagerState;
68
69
  readonly selectInitialQuery: RawLambda;
69
70
  readonly mappingPath: string | undefined;
71
+ readonly parameterValues: ParameterValue[] | undefined;
70
72
  readonly runtimePath: string;
73
+ _parameters: object | undefined;
74
+
71
75
  constructor(
72
76
  selectQuery: RawLambda,
77
+ parameterValues: ParameterValue[] | undefined,
73
78
  mappingPath: string | undefined,
74
79
  runtimePath: string,
75
80
  graphManagerState: GraphManagerState,
@@ -79,6 +84,7 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
79
84
  this.selectInitialQuery = selectQuery;
80
85
  this.mappingPath = mappingPath;
81
86
  this.runtimePath = runtimePath;
87
+ this.parameterValues = parameterValues;
82
88
  }
83
89
 
84
90
  get sourceLabel(): string {
@@ -105,6 +111,7 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
105
111
  ) {
106
112
  srcFuncExp = srcFuncExp.body[0];
107
113
  }
114
+ this._parameters = this.selectInitialQuery.parameters;
108
115
  const fromFuncExp = new V1_AppliedFunction();
109
116
  fromFuncExp.function = _functionName(SUPPORTED_FUNCTIONS.FROM);
110
117
  fromFuncExp.parameters = [srcFuncExp];
@@ -159,6 +166,8 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
159
166
  // we return undefined as we assume the grid license is set at the application level where query builder is built
160
167
  return Promise.resolve({
161
168
  gridClientLicense: undefined,
169
+ simpleSampleDataTableName: '',
170
+ complexSampleDataTableName: '',
162
171
  });
163
172
  }
164
173
  override async getQueryTypeahead(
@@ -191,6 +200,16 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
191
200
  );
192
201
  }
193
202
 
203
+ override getQueryCode(
204
+ query: V1_ValueSpecification,
205
+ pretty?: boolean | undefined,
206
+ ): Promise<string> {
207
+ return this.graphState.graphManager.valueSpecificationToPureCode(
208
+ V1_serializeValueSpecification(query, []),
209
+ pretty,
210
+ );
211
+ }
212
+
194
213
  override getQueryRelationType(
195
214
  query: V1_ValueSpecification,
196
215
  ): Promise<RelationType> {
@@ -227,12 +246,16 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
227
246
  executedSQL: string;
228
247
  }> {
229
248
  const lambda = this.buildRawLambdaFromValueSpec(query);
249
+ lambda.parameters = this._parameters;
230
250
  const [executionWithMetadata, queryString] = await Promise.all([
231
251
  this.graphState.graphManager.runQuery(
232
252
  lambda,
233
253
  undefined,
234
254
  undefined,
235
255
  this.graph,
256
+ {
257
+ parameterValues: this.parameterValues ?? [],
258
+ },
236
259
  ),
237
260
  this.graphState.graphManager.lambdaToPureCode(lambda),
238
261
  ]);
@@ -15,9 +15,13 @@
15
15
  */
16
16
 
17
17
  import { type DataCubeEngine } from '@finos/legend-data-cube';
18
- import type { QueryBuilderState } from '../QueryBuilderState.js';
18
+ import {
19
+ QUERY_BUILDER_LAMBDA_WRITER_MODE,
20
+ type QueryBuilderState,
21
+ } from '../QueryBuilderState.js';
19
22
  import { RuntimePointer } from '@finos/legend-graph';
20
23
  import { QueryBuilderDataCubeEngine } from './QueryBuilderDataCubeEngine.js';
24
+ import { buildExecutionParameterValues } from '../shared/LambdaParameterState.js';
21
25
 
22
26
  export const createDataCubeEngineFromQueryBuilder = (
23
27
  queryBuilderState: QueryBuilderState,
@@ -31,11 +35,22 @@ export const createDataCubeEngineFromQueryBuilder = (
31
35
  if (!runtime) {
32
36
  return undefined;
33
37
  }
38
+ const currentLambdaWriterMode = queryBuilderState.lambdaWriteMode;
39
+ // ensure we write in new tds mode
40
+ queryBuilderState.setLambdaWriteMode(
41
+ QUERY_BUILDER_LAMBDA_WRITER_MODE.TYPED_FETCH_STRUCTURE,
42
+ );
43
+ const parameterValues = buildExecutionParameterValues(
44
+ queryBuilderState.parametersState.parameterStates,
45
+ queryBuilderState.graphManagerState,
46
+ );
34
47
  const queryBuilderEngine = new QueryBuilderDataCubeEngine(
35
48
  queryBuilderState.buildQuery(),
49
+ parameterValues,
36
50
  queryBuilderState.executionContextState.mapping?.path,
37
51
  runtime,
38
52
  queryBuilderState.graphManagerState,
39
53
  );
54
+ queryBuilderState.setLambdaWriteMode(currentLambdaWriterMode);
40
55
  return queryBuilderEngine;
41
56
  };
@@ -60,6 +60,7 @@ import {
60
60
  export enum PARAMETER_SUBMIT_ACTION {
61
61
  RUN = 'RUN',
62
62
  EXPORT = 'EXPORT',
63
+ DATA_CUBE = 'DATA_CUBE',
63
64
  }
64
65
 
65
66
  enum LAMABA_PARAMETER_HASH_STRUCTURE {