@finos/legend-query-builder 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. package/lib/{components/QueryBuilder_TestID.d.ts → application/QueryBuilderTesting.d.ts} +1 -1
  2. package/lib/application/QueryBuilderTesting.d.ts.map +1 -0
  3. package/lib/{components/QueryBuilder_TestID.js → application/QueryBuilderTesting.js} +1 -1
  4. package/lib/application/QueryBuilderTesting.js.map +1 -0
  5. package/lib/components/QueryBuilder.js +1 -1
  6. package/lib/components/QueryBuilder.js.map +1 -1
  7. package/lib/components/QueryBuilderComponentTestUtils.js +1 -1
  8. package/lib/components/QueryBuilderComponentTestUtils.js.map +1 -1
  9. package/lib/components/QueryBuilderConstantExpressionPanel.js +1 -1
  10. package/lib/components/QueryBuilderConstantExpressionPanel.js.map +1 -1
  11. package/lib/components/QueryBuilderParametersPanel.js +1 -1
  12. package/lib/components/QueryBuilderParametersPanel.js.map +1 -1
  13. package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
  14. package/lib/components/QueryBuilderResultPanel.js +2 -2
  15. package/lib/components/QueryBuilderResultPanel.js.map +1 -1
  16. package/lib/components/QueryBuilderSideBar.js +1 -1
  17. package/lib/components/QueryBuilderSideBar.js.map +1 -1
  18. package/lib/components/explorer/QueryBuilderExplorerPanel.js +1 -1
  19. package/lib/components/explorer/QueryBuilderExplorerPanel.js.map +1 -1
  20. package/lib/components/explorer/QueryBuilderPropertySearchPanel.js +1 -1
  21. package/lib/components/explorer/QueryBuilderPropertySearchPanel.js.map +1 -1
  22. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.js +1 -1
  23. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.js.map +1 -1
  24. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js +1 -1
  25. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js.map +1 -1
  26. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +1 -1
  27. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
  28. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js +1 -1
  29. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js.map +1 -1
  30. package/lib/components/filter/QueryBuilderFilterPanel.js +1 -1
  31. package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
  32. package/lib/components/shared/LambdaEditor.d.ts.map +1 -1
  33. package/lib/components/shared/LambdaEditor.js +2 -2
  34. package/lib/components/shared/LambdaEditor.js.map +1 -1
  35. package/lib/index.css +1 -1
  36. package/lib/index.d.ts +1 -1
  37. package/lib/index.d.ts.map +1 -1
  38. package/lib/index.js +1 -1
  39. package/lib/index.js.map +1 -1
  40. package/lib/package.json +1 -1
  41. package/lib/stores/QueryBuilderState.d.ts +2 -0
  42. package/lib/stores/QueryBuilderState.d.ts.map +1 -1
  43. package/lib/stores/QueryBuilderState.js +13 -4
  44. package/lib/stores/QueryBuilderState.js.map +1 -1
  45. package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
  46. package/lib/stores/QueryBuilderStateBuilder.js +15 -4
  47. package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
  48. package/lib/stores/milestoning/QueryBuilderMilestoningHelper.d.ts +1 -0
  49. package/lib/stores/milestoning/QueryBuilderMilestoningHelper.d.ts.map +1 -1
  50. package/lib/stores/milestoning/QueryBuilderMilestoningHelper.js +21 -17
  51. package/lib/stores/milestoning/QueryBuilderMilestoningHelper.js.map +1 -1
  52. package/package.json +4 -4
  53. package/src/components/QueryBuilder.tsx +1 -1
  54. package/src/components/QueryBuilderComponentTestUtils.tsx +1 -1
  55. package/src/components/QueryBuilderConstantExpressionPanel.tsx +1 -1
  56. package/src/components/QueryBuilderParametersPanel.tsx +1 -1
  57. package/src/components/QueryBuilderResultPanel.tsx +2 -1
  58. package/src/components/QueryBuilderSideBar.tsx +1 -1
  59. package/src/components/explorer/QueryBuilderExplorerPanel.tsx +1 -1
  60. package/src/components/explorer/QueryBuilderPropertySearchPanel.tsx +1 -1
  61. package/src/components/fetch-structure/QueryBuilderGraphFetchTreePanel.tsx +1 -1
  62. package/src/components/fetch-structure/QueryBuilderPostFilterPanel.tsx +1 -1
  63. package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +1 -1
  64. package/src/components/fetch-structure/QueryBuilderTDSWindowPanel.tsx +1 -1
  65. package/src/components/filter/QueryBuilderFilterPanel.tsx +1 -1
  66. package/src/components/shared/LambdaEditor.tsx +2 -1
  67. package/src/index.ts +1 -1
  68. package/src/stores/QueryBuilderState.ts +15 -4
  69. package/src/stores/QueryBuilderStateBuilder.ts +23 -8
  70. package/src/stores/milestoning/QueryBuilderMilestoningHelper.ts +34 -27
  71. package/tsconfig.json +1 -1
  72. package/lib/components/QueryBuilder_TestID.d.ts.map +0 -1
  73. package/lib/components/QueryBuilder_TestID.js.map +0 -1
  74. /package/src/{components/QueryBuilder_TestID.ts → application/QueryBuilderTesting.ts} +0 -0
@@ -69,6 +69,8 @@ import { LambdaParameterState } from './shared/LambdaParameterState.js';
69
69
  import { processTDS_OLAPGroupByExpression } from './fetch-structure/tds/window/QueryBuilderWindowStateBuilder.js';
70
70
  import { processWatermarkExpression } from './watermark/QueryBuilderWatermarkStateBuilder.js';
71
71
  import { QueryBuilderConstantExpressionState } from './QueryBuilderConstantsState.js';
72
+ import { checkIfEquivalent } from './milestoning/QueryBuilderMilestoningHelper.js';
73
+ import { QueryBuilderParametersState } from './QueryBuilderParametersState.js';
72
74
 
73
75
  const processGetAllExpression = (
74
76
  expression: SimpleFunctionExpression,
@@ -607,16 +609,29 @@ export const processParameters = (
607
609
  parameters: VariableExpression[],
608
610
  queryBuilderState: QueryBuilderState,
609
611
  ): void => {
610
- const queryParameterState = queryBuilderState.parametersState;
612
+ const queryParameterState = new QueryBuilderParametersState(
613
+ queryBuilderState,
614
+ );
615
+ // Here we won't process the parameters which are present in the previous state
616
+ // because we don't want to lose the parameter value
611
617
  parameters.forEach((parameter) => {
612
- const parameterState = new LambdaParameterState(
613
- parameter,
614
- queryBuilderState.observableContext,
615
- queryBuilderState.graphManagerState.graph,
616
- );
617
- parameterState.mockParameterValue();
618
- queryParameterState.addParameter(parameterState);
618
+ const oldParamterState =
619
+ queryBuilderState.parametersState.parameterStates.find((ps) =>
620
+ checkIfEquivalent(ps.parameter, parameter),
621
+ );
622
+ if (oldParamterState) {
623
+ queryParameterState.addParameter(oldParamterState);
624
+ } else {
625
+ const parameterState = new LambdaParameterState(
626
+ parameter,
627
+ queryBuilderState.observableContext,
628
+ queryBuilderState.graphManagerState.graph,
629
+ );
630
+ parameterState.mockParameterValue();
631
+ queryParameterState.addParameter(parameterState);
632
+ }
619
633
  });
634
+ queryBuilderState.parametersState = queryParameterState;
620
635
  };
621
636
 
622
637
  export const processQueryLambdaFunction = (
@@ -133,6 +133,40 @@ export const isDefaultDatePropagationSupported = (
133
133
  return false;
134
134
  };
135
135
 
136
+ export const checkIfEquivalent = (
137
+ param1: ValueSpecification | undefined,
138
+ param2: ValueSpecification | undefined,
139
+ ): boolean => {
140
+ if (
141
+ param1?.multiplicity.lowerBound !== param2?.multiplicity.lowerBound ||
142
+ param1?.multiplicity.upperBound !== param2?.multiplicity.upperBound
143
+ ) {
144
+ return false;
145
+ }
146
+ if (
147
+ param1 instanceof VariableExpression &&
148
+ param2 instanceof VariableExpression
149
+ ) {
150
+ return param1.name === param2.name;
151
+ } else if (
152
+ param1 instanceof PrimitiveInstanceValue &&
153
+ param2 instanceof PrimitiveInstanceValue
154
+ ) {
155
+ if (
156
+ param1.genericType.value.rawType.name === PRIMITIVE_TYPE.LATESTDATE &&
157
+ param2.genericType.value.rawType.name === PRIMITIVE_TYPE.LATESTDATE
158
+ ) {
159
+ return true;
160
+ }
161
+ return (
162
+ param1.genericType.value.rawType.name ===
163
+ param2.genericType.value.rawType.name &&
164
+ param1.values[0] === param2.values[0]
165
+ );
166
+ }
167
+ return false;
168
+ };
169
+
136
170
  /**
137
171
  * Check if the parameter value of the milestoned property is
138
172
  * the same as those specified in global scope, so that we can
@@ -144,33 +178,6 @@ export const matchMilestoningParameterValue = (
144
178
  parameterValue: ValueSpecification,
145
179
  milestoningDate: QueryBuilderMilestoningState,
146
180
  ): boolean => {
147
- const checkIfEquivalent = (
148
- param1: ValueSpecification | undefined,
149
- param2: ValueSpecification | undefined,
150
- ): boolean => {
151
- if (
152
- param1 instanceof VariableExpression &&
153
- param2 instanceof VariableExpression
154
- ) {
155
- return param1.name === param2.name;
156
- } else if (
157
- param1 instanceof PrimitiveInstanceValue &&
158
- param2 instanceof PrimitiveInstanceValue
159
- ) {
160
- if (
161
- param1.genericType.value.rawType.name === PRIMITIVE_TYPE.LATESTDATE &&
162
- param2.genericType.value.rawType.name === PRIMITIVE_TYPE.LATESTDATE
163
- ) {
164
- return true;
165
- }
166
- return (
167
- param1.genericType.value.rawType.name ===
168
- param2.genericType.value.rawType.name &&
169
- param1.values[0] === param2.values[0]
170
- );
171
- }
172
- return false;
173
- };
174
181
  switch (stereotype) {
175
182
  case MILESTONING_STEREOTYPE.BITEMPORAL:
176
183
  return (
package/tsconfig.json CHANGED
@@ -36,9 +36,9 @@
36
36
  "./src/application/QueryBuilderEvent.ts",
37
37
  "./src/application/QueryBuilderSetting.ts",
38
38
  "./src/application/QueryBuilderTelemetryHelper.ts",
39
+ "./src/application/QueryBuilderTesting.ts",
39
40
  "./src/components/QueryBuilderComponentElement.ts",
40
41
  "./src/components/QueryBuilder_LegendApplicationPlugin.ts",
41
- "./src/components/QueryBuilder_TestID.ts",
42
42
  "./src/components/QuerySetupUtils.ts",
43
43
  "./src/graphManager/QueryBuilderHashUtils.ts",
44
44
  "./src/graphManager/QueryBuilderSupportedFunctions.ts",
@@ -1 +0,0 @@
1
- {"version":3,"file":"QueryBuilder_TestID.d.ts","sourceRoot":"","sources":["../../src/components/QueryBuilder_TestID.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,oBAAY,qBAAqB;IAC/B,2BAA2B,iCAAiC;IAE5D,aAAa,mBAAmB;IAChC,mBAAmB,0BAA0B;IAC7C,iBAAiB,wBAAwB;IACzC,yBAAyB,iCAAiC;IAC1D,oBAAoB,2BAA2B;IAC/C,yBAAyB,gCAAgC;IACzD,4BAA4B,2BAA2B;IACvD,sBAAsB,6BAA6B;IACnD,mCAAmC,4CAA4C;IAC/E,0BAA0B,kCAAkC;IAC5D,wBAAwB,8BAA8B;IACtD,uBAAuB,6BAA6B;CACrD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"QueryBuilder_TestID.js","sourceRoot":"","sources":["../../src/components/QueryBuilder_TestID.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAN,IAAY,qBAeX;AAfD,WAAY,qBAAqB;IAC/B,qFAA4D,CAAA;IAE5D,yDAAgC,CAAA;IAChC,sEAA6C,CAAA;IAC7C,kEAAyC,CAAA;IACzC,mFAA0D,CAAA;IAC1D,wEAA+C,CAAA;IAC/C,kFAAyD,CAAA;IACzD,gFAAuD,CAAA;IACvD,4EAAmD,CAAA;IACnD,wGAA+E,CAAA;IAC/E,qFAA4D,CAAA;IAC5D,+EAAsD,CAAA;IACtD,6EAAoD,CAAA;AACtD,CAAC,EAfW,qBAAqB,GAArB,qBAAqB,KAArB,qBAAqB,QAehC"}