@finos/legend-query-builder 4.5.1 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. package/lib/__lib__/QueryBuilderTesting.d.ts +1 -0
  2. package/lib/__lib__/QueryBuilderTesting.d.ts.map +1 -1
  3. package/lib/__lib__/QueryBuilderTesting.js +1 -0
  4. package/lib/__lib__/QueryBuilderTesting.js.map +1 -1
  5. package/lib/components/QueryBuilderConstantExpressionPanel.d.ts.map +1 -1
  6. package/lib/components/QueryBuilderConstantExpressionPanel.js +11 -4
  7. package/lib/components/QueryBuilderConstantExpressionPanel.js.map +1 -1
  8. package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
  9. package/lib/components/QueryBuilderResultPanel.js +1 -1
  10. package/lib/components/QueryBuilderResultPanel.js.map +1 -1
  11. package/lib/components/shared/BasicValueSpecificationEditor.js +1 -1
  12. package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
  13. package/lib/components/shared/CustomDatePicker.d.ts.map +1 -1
  14. package/lib/components/shared/CustomDatePicker.js +6 -2
  15. package/lib/components/shared/CustomDatePicker.js.map +1 -1
  16. package/lib/components/shared/QueryBuilderVariableSelector.d.ts.map +1 -1
  17. package/lib/components/shared/QueryBuilderVariableSelector.js +11 -3
  18. package/lib/components/shared/QueryBuilderVariableSelector.js.map +1 -1
  19. package/lib/index.css +1 -1
  20. package/lib/package.json +1 -1
  21. package/lib/stores/QueryBuilderConstantsState.d.ts +10 -3
  22. package/lib/stores/QueryBuilderConstantsState.d.ts.map +1 -1
  23. package/lib/stores/QueryBuilderConstantsState.js +23 -8
  24. package/lib/stores/QueryBuilderConstantsState.js.map +1 -1
  25. package/lib/stores/QueryBuilderStateBuilder.d.ts +1 -1
  26. package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
  27. package/lib/stores/QueryBuilderStateBuilder.js +9 -4
  28. package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
  29. package/lib/stores/QueryBuilderValueSpecificationBuilder.js +1 -0
  30. package/lib/stores/QueryBuilderValueSpecificationBuilder.js.map +1 -1
  31. package/package.json +3 -3
  32. package/src/__lib__/QueryBuilderTesting.ts +1 -0
  33. package/src/components/QueryBuilderConstantExpressionPanel.tsx +18 -9
  34. package/src/components/QueryBuilderResultPanel.tsx +4 -1
  35. package/src/components/shared/BasicValueSpecificationEditor.tsx +1 -1
  36. package/src/components/shared/CustomDatePicker.tsx +6 -7
  37. package/src/components/shared/QueryBuilderVariableSelector.tsx +19 -8
  38. package/src/stores/QueryBuilderConstantsState.ts +43 -9
  39. package/src/stores/QueryBuilderStateBuilder.ts +20 -8
  40. package/src/stores/QueryBuilderValueSpecificationBuilder.ts +1 -1
@@ -17,6 +17,7 @@
17
17
  import {
18
18
  type Type,
19
19
  type ValueSpecification,
20
+ type INTERNAL__UnknownValueSpecification,
20
21
  GenericType,
21
22
  GenericTypeExplicitReference,
22
23
  observe_ValueSpecification,
@@ -37,7 +38,7 @@ import type { QueryBuilderState } from './QueryBuilderState.js';
37
38
  import { buildDefaultInstanceValue } from './shared/ValueSpecificationEditorHelper.js';
38
39
  import { valueSpecification_setGenericType } from './shared/ValueSpecificationModifierHelper.js';
39
40
 
40
- export class QueryBuilderConstantExpressionState implements Hashable {
41
+ export abstract class QueryBuilderConstantExpressionState implements Hashable {
41
42
  readonly queryBuilderState: QueryBuilderState;
42
43
  readonly uuid = uuid();
43
44
  variable: VariableExpression;
@@ -48,13 +49,36 @@ export class QueryBuilderConstantExpressionState implements Hashable {
48
49
  variable: VariableExpression,
49
50
  value: ValueSpecification,
50
51
  ) {
52
+ this.queryBuilderState = queryBuilderState;
53
+ this.variable = variable;
54
+ this.value = value;
55
+ }
56
+
57
+ get hashCode(): string {
58
+ return hashArray([
59
+ QUERY_BUILDER_STATE_HASH_STRUCTURE.CONSTANT_EXPRESSION_STATE,
60
+ this.variable.name,
61
+ this.value,
62
+ ]);
63
+ }
64
+ }
65
+
66
+ export class QueryBuilderSimpleConstantExpressionState
67
+ extends QueryBuilderConstantExpressionState
68
+ implements Hashable
69
+ {
70
+ constructor(
71
+ queryBuilderState: QueryBuilderState,
72
+ variable: VariableExpression,
73
+ value: ValueSpecification,
74
+ ) {
75
+ super(queryBuilderState, variable, value);
51
76
  makeObservable(this, {
52
77
  variable: observable,
53
78
  value: observable,
54
79
  setValueSpec: action,
55
80
  changeValSpecType: action,
56
81
  });
57
- this.queryBuilderState = queryBuilderState;
58
82
  this.value = observe_ValueSpecification(
59
83
  value,
60
84
  this.queryBuilderState.observerContext,
@@ -63,7 +87,6 @@ export class QueryBuilderConstantExpressionState implements Hashable {
63
87
  variable,
64
88
  this.queryBuilderState.observerContext,
65
89
  );
66
- this.variable = variable;
67
90
  }
68
91
 
69
92
  changeValSpecType(type: Type): void {
@@ -106,13 +129,24 @@ export class QueryBuilderConstantExpressionState implements Hashable {
106
129
  );
107
130
  }
108
131
  }
132
+ }
109
133
 
110
- get hashCode(): string {
111
- return hashArray([
112
- QUERY_BUILDER_STATE_HASH_STRUCTURE.CONSTANT_EXPRESSION_STATE,
113
- this.variable.name,
114
- this.value,
115
- ]);
134
+ export class QueryBuilderCalculatedConstantExpressionState
135
+ extends QueryBuilderConstantExpressionState
136
+ implements Hashable
137
+ {
138
+ declare value: INTERNAL__UnknownValueSpecification;
139
+
140
+ constructor(
141
+ queryBuilderState: QueryBuilderState,
142
+ variable: VariableExpression,
143
+ value: INTERNAL__UnknownValueSpecification,
144
+ ) {
145
+ super(queryBuilderState, variable, value);
146
+ makeObservable(this, {
147
+ variable: observable,
148
+ value: observable,
149
+ });
116
150
  }
117
151
  }
118
152
 
@@ -31,7 +31,7 @@ import {
31
31
  type GraphFetchTreeInstanceValue,
32
32
  type ValueSpecificationVisitor,
33
33
  InstanceValue,
34
- type INTERNAL__UnknownValueSpecification,
34
+ INTERNAL__UnknownValueSpecification,
35
35
  type LambdaFunction,
36
36
  type KeyExpressionInstanceValue,
37
37
  matchFunctionName,
@@ -81,7 +81,11 @@ import {
81
81
  import { LambdaParameterState } from './shared/LambdaParameterState.js';
82
82
  import { processTDS_OLAPGroupByExpression } from './fetch-structure/tds/window/QueryBuilderWindowStateBuilder.js';
83
83
  import { processWatermarkExpression } from './watermark/QueryBuilderWatermarkStateBuilder.js';
84
- import { QueryBuilderConstantExpressionState } from './QueryBuilderConstantsState.js';
84
+ import {
85
+ type QueryBuilderConstantExpressionState,
86
+ QueryBuilderCalculatedConstantExpressionState,
87
+ QueryBuilderSimpleConstantExpressionState,
88
+ } from './QueryBuilderConstantsState.js';
85
89
  import { checkIfEquivalent } from './milestoning/QueryBuilderMilestoningHelper.js';
86
90
  import type { QueryBuilderParameterValue } from './QueryBuilderParametersState.js';
87
91
  import { QueryBuilderEmbeddedFromExecutionContextState } from './QueryBuilderExecutionContextState.js';
@@ -143,12 +147,20 @@ const processLetExpression = (
143
147
  );
144
148
  // process right side (value)
145
149
  const rightSide = guaranteeNonNullable(parameters[1]);
146
- // final
147
- const constantExpression = new QueryBuilderConstantExpressionState(
148
- queryBuilderState,
149
- varExp,
150
- rightSide,
151
- );
150
+ let constantExpression: QueryBuilderConstantExpressionState;
151
+ if (rightSide instanceof INTERNAL__UnknownValueSpecification) {
152
+ constantExpression = new QueryBuilderCalculatedConstantExpressionState(
153
+ queryBuilderState,
154
+ varExp,
155
+ rightSide,
156
+ );
157
+ } else {
158
+ constantExpression = new QueryBuilderSimpleConstantExpressionState(
159
+ queryBuilderState,
160
+ varExp,
161
+ rightSide,
162
+ );
163
+ }
152
164
  queryBuilderState.constantState.setShowConstantPanel(true);
153
165
  queryBuilderState.constantState.addConstant(constantExpression);
154
166
  };
@@ -40,7 +40,7 @@ import type { QueryBuilderFetchStructureState } from './fetch-structure/QueryBui
40
40
  import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../graph/QueryBuilderMetaModelConst.js';
41
41
  import { buildWatermarkExpression } from './watermark/QueryBuilderWatermarkValueSpecificationBuilder.js';
42
42
  import { buildExecutionQueryFromLambdaFunction } from './shared/LambdaParameterState.js';
43
- import type { QueryBuilderConstantExpressionState } from './QueryBuilderConstantsState.js';
43
+ import { type QueryBuilderConstantExpressionState } from './QueryBuilderConstantsState.js';
44
44
  import {
45
45
  QueryBuilderEmbeddedFromExecutionContextState,
46
46
  type QueryBuilderExecutionContextState,