@finos/legend-query-builder 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. package/lib/components/QueryBuilder.d.ts +1 -0
  2. package/lib/components/QueryBuilder.d.ts.map +1 -1
  3. package/lib/components/QueryBuilderDiffPanel.d.ts +1 -0
  4. package/lib/components/QueryBuilderDiffPanel.d.ts.map +1 -1
  5. package/lib/components/QueryBuilderParametersPanel.d.ts +1 -0
  6. package/lib/components/QueryBuilderParametersPanel.d.ts.map +1 -1
  7. package/lib/components/QueryBuilderParametersPanel.js +2 -2
  8. package/lib/components/QueryBuilderParametersPanel.js.map +1 -1
  9. package/lib/components/QueryBuilderPropertyExpressionEditor.d.ts +1 -0
  10. package/lib/components/QueryBuilderPropertyExpressionEditor.d.ts.map +1 -1
  11. package/lib/components/QueryBuilderResultPanel.d.ts +1 -0
  12. package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
  13. package/lib/components/QueryBuilderResultPanel.js +2 -2
  14. package/lib/components/QueryBuilderResultPanel.js.map +1 -1
  15. package/lib/components/QueryBuilderSideBar.d.ts +1 -0
  16. package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
  17. package/lib/components/QueryBuilderTextEditor.d.ts +1 -0
  18. package/lib/components/QueryBuilderTextEditor.d.ts.map +1 -1
  19. package/lib/components/QueryBuilderUnsupportedQueryEditor.d.ts +1 -0
  20. package/lib/components/QueryBuilderUnsupportedQueryEditor.d.ts.map +1 -1
  21. package/lib/components/QueryBuilderUnsupportedQueryEditor.js +2 -2
  22. package/lib/components/QueryBuilderUnsupportedQueryEditor.js.map +1 -1
  23. package/lib/components/QuerySetupUtils.d.ts +22 -0
  24. package/lib/components/QuerySetupUtils.d.ts.map +1 -0
  25. package/lib/components/QuerySetupUtils.js +20 -0
  26. package/lib/components/QuerySetupUtils.js.map +1 -0
  27. package/lib/components/explorer/QueryBuilderFunctionsExplorerPanel.d.ts +1 -0
  28. package/lib/components/explorer/QueryBuilderFunctionsExplorerPanel.d.ts.map +1 -1
  29. package/lib/components/explorer/QueryBuilderMilestoningEditor.d.ts +1 -0
  30. package/lib/components/explorer/QueryBuilderMilestoningEditor.d.ts.map +1 -1
  31. package/lib/components/explorer/QueryBuilderPropertySearchPanel.d.ts +1 -0
  32. package/lib/components/explorer/QueryBuilderPropertySearchPanel.d.ts.map +1 -1
  33. package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.d.ts +1 -0
  34. package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.d.ts.map +1 -1
  35. package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.js +3 -3
  36. package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.js.map +1 -1
  37. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts +1 -0
  38. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts.map +1 -1
  39. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.d.ts +1 -0
  40. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.d.ts.map +1 -1
  41. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js +3 -3
  42. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js.map +1 -1
  43. package/lib/components/fetch-structure/QueryBuilderProjectionPanel.d.ts +1 -0
  44. package/lib/components/fetch-structure/QueryBuilderProjectionPanel.d.ts.map +1 -1
  45. package/lib/components/fetch-structure/QueryBuilderProjectionPanel.js +2 -2
  46. package/lib/components/fetch-structure/QueryBuilderProjectionPanel.js.map +1 -1
  47. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts +1 -0
  48. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts.map +1 -1
  49. package/lib/components/filter/QueryBuilderFilterPanel.d.ts +1 -0
  50. package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
  51. package/lib/components/filter/QueryBuilderFilterPanel.js +2 -2
  52. package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
  53. package/lib/components/shared/QueryBuilderLambdaEditor.d.ts +1 -0
  54. package/lib/components/shared/QueryBuilderLambdaEditor.d.ts.map +1 -1
  55. package/lib/graphManager/protocol/pure/v1/V1_QueryBuilder_FunctionExpressionBuilder.d.ts.map +1 -1
  56. package/lib/graphManager/protocol/pure/v1/V1_QueryBuilder_FunctionExpressionBuilder.js +4 -4
  57. package/lib/graphManager/protocol/pure/v1/V1_QueryBuilder_FunctionExpressionBuilder.js.map +1 -1
  58. package/lib/index.css +1 -1
  59. package/lib/index.d.ts +1 -0
  60. package/lib/index.d.ts.map +1 -1
  61. package/lib/index.js +1 -0
  62. package/lib/index.js.map +1 -1
  63. package/lib/package.json +6 -6
  64. package/lib/stores/QueryBuilderChangeDetectionState.d.ts +1 -0
  65. package/lib/stores/QueryBuilderChangeDetectionState.d.ts.map +1 -1
  66. package/lib/stores/QueryBuilderChangeDetectionState.js +24 -0
  67. package/lib/stores/QueryBuilderChangeDetectionState.js.map +1 -1
  68. package/lib/stores/QueryBuilderParametersState.d.ts +1 -1
  69. package/lib/stores/QueryBuilderParametersState.d.ts.map +1 -1
  70. package/lib/stores/QueryBuilderParametersState.js +1 -1
  71. package/lib/stores/QueryBuilderParametersState.js.map +1 -1
  72. package/lib/stores/QueryBuilderState.d.ts.map +1 -1
  73. package/lib/stores/QueryBuilderState.js +2 -1
  74. package/lib/stores/QueryBuilderState.js.map +1 -1
  75. package/lib/stores/QueryBuilderTypeaheadHelper.d.ts.map +1 -1
  76. package/lib/stores/QueryBuilderTypeaheadHelper.js +3 -4
  77. package/lib/stores/QueryBuilderTypeaheadHelper.js.map +1 -1
  78. package/lib/stores/fetch-structure/projection/QueryBuilderProjectionValueSpecificationBuilder.d.ts.map +1 -1
  79. package/lib/stores/fetch-structure/projection/QueryBuilderProjectionValueSpecificationBuilder.js +7 -7
  80. package/lib/stores/fetch-structure/projection/QueryBuilderProjectionValueSpecificationBuilder.js.map +1 -1
  81. package/package.json +13 -13
  82. package/src/components/QueryBuilderParametersPanel.tsx +1 -2
  83. package/src/components/QueryBuilderResultPanel.tsx +3 -2
  84. package/src/components/QueryBuilderUnsupportedQueryEditor.tsx +8 -9
  85. package/src/components/QuerySetupUtils.ts +23 -0
  86. package/src/components/fetch-structure/QueryBuilderFetchStructurePanel.tsx +10 -5
  87. package/src/components/fetch-structure/QueryBuilderPostFilterPanel.tsx +5 -4
  88. package/src/components/fetch-structure/QueryBuilderProjectionPanel.tsx +3 -2
  89. package/src/components/filter/QueryBuilderFilterPanel.tsx +3 -2
  90. package/src/graphManager/protocol/pure/v1/V1_QueryBuilder_FunctionExpressionBuilder.ts +3 -4
  91. package/src/index.ts +1 -0
  92. package/src/stores/QueryBuilderChangeDetectionState.ts +31 -0
  93. package/src/stores/QueryBuilderParametersState.ts +3 -1
  94. package/src/stores/QueryBuilderState.ts +2 -1
  95. package/src/stores/QueryBuilderTypeaheadHelper.ts +6 -5
  96. package/src/stores/fetch-structure/projection/QueryBuilderProjectionValueSpecificationBuilder.ts +10 -10
  97. package/tsconfig.json +1 -0
package/src/index.ts CHANGED
@@ -39,3 +39,4 @@ export type { ServiceExecutionAnalysisResult } from './graphManager/action/analy
39
39
  export type { MappingRuntimeCompatibilityAnalysisResult } from './graphManager/action/analytics/MappingRuntimeCompatibilityAnalysis.js';
40
40
  export * from './stores/ServiceInfo.js';
41
41
  export * from './components/ServiceQuerySetupUtils.js';
42
+ export * from './components/QuerySetupUtils.js';
@@ -14,6 +14,10 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ import {
18
+ ActionAlertActionType,
19
+ ActionAlertType,
20
+ } from '@finos/legend-application';
17
21
  import type { RawLambda } from '@finos/legend-graph';
18
22
  import {
19
23
  ActionState,
@@ -136,4 +140,31 @@ export class QueryBuilderChangeDetectionState {
136
140
  this.initialQuery = initialQuery;
137
141
  this.initState.complete();
138
142
  }
143
+
144
+ alertUnsavedChanges(onProceed: () => void): void {
145
+ if (this.hasChanged) {
146
+ this.querybuilderState.applicationStore.setActionAlertInfo({
147
+ message:
148
+ 'Unsaved changes to your query will be lost if you continue. Do you still want to proceed?',
149
+ type: ActionAlertType.CAUTION,
150
+ actions: [
151
+ {
152
+ label: 'Proceed',
153
+ type: ActionAlertActionType.PROCEED_WITH_CAUTION,
154
+ handler:
155
+ this.querybuilderState.applicationStore.guardUnhandledError(
156
+ async () => onProceed(),
157
+ ),
158
+ },
159
+ {
160
+ label: 'Cancel',
161
+ type: ActionAlertActionType.PROCEED,
162
+ default: true,
163
+ },
164
+ ],
165
+ });
166
+ } else {
167
+ onProceed();
168
+ }
169
+ }
139
170
  }
@@ -33,11 +33,13 @@ export class QueryBuilderParametersState
33
33
  extends LambdaParametersState
34
34
  implements Hashable
35
35
  {
36
+ readonly queryBuilderState: QueryBuilderState;
37
+
36
38
  selectedParameter: LambdaParameterState | undefined;
37
- queryBuilderState: QueryBuilderState;
38
39
 
39
40
  constructor(queryBuilderState: QueryBuilderState) {
40
41
  super();
42
+
41
43
  makeObservable(this, {
42
44
  parameterValuesEditorState: observable,
43
45
  parameterStates: observable,
@@ -246,13 +246,14 @@ export abstract class QueryBuilderState {
246
246
  this.resetQueryContent();
247
247
  this.setClass(val);
248
248
  this.explorerState.refreshTreeData();
249
- this.milestoningState.updateMilestoningConfiguration();
250
249
  this.fetchStructureState.implementation.onClassChange(val);
250
+ this.milestoningState.updateMilestoningConfiguration();
251
251
  }
252
252
 
253
253
  changeMapping(val: Mapping): void {
254
254
  this.resetQueryResult();
255
255
  this.resetQueryContent();
256
+ this.milestoningState.updateMilestoningConfiguration();
256
257
  this.setMapping(val);
257
258
  }
258
259
 
@@ -36,9 +36,10 @@ import {
36
36
  } from './fetch-structure/projection/QueryBuilderProjectionColumnState.js';
37
37
  import type { QueryBuilderState } from './QueryBuilderState.js';
38
38
  import { QueryBuilderProjectionState } from './fetch-structure/projection/QueryBuilderProjectionState.js';
39
-
40
- const TYPEAHEAD_TAKE_LIMIT = 10;
41
- const START_LENGTH = 3;
39
+ import {
40
+ DEFAULT_TYPEAHEAD_SEARCH_LIMIT,
41
+ DEFAULT_TYPEAHEAD_SEARCH_MINIMUM_SEARCH_LENGTH,
42
+ } from '@finos/legend-application';
42
43
 
43
44
  const initializeQueryBuilderState = (
44
45
  queryBuilderState: QueryBuilderState,
@@ -49,7 +50,7 @@ const initializeQueryBuilderState = (
49
50
  QueryBuilderProjectionState,
50
51
  );
51
52
  projectionState.resultSetModifierState.distinct = true;
52
- projectionState.resultSetModifierState.limit = TYPEAHEAD_TAKE_LIMIT;
53
+ projectionState.resultSetModifierState.limit = DEFAULT_TYPEAHEAD_SEARCH_LIMIT;
53
54
  return builderState;
54
55
  };
55
56
 
@@ -142,7 +143,7 @@ export const performTypeahead = (
142
143
  switch (_type.path) {
143
144
  case PRIMITIVE_TYPE.STRING: {
144
145
  const value = val.values[0] as string;
145
- return value.length >= START_LENGTH;
146
+ return value.length >= DEFAULT_TYPEAHEAD_SEARCH_MINIMUM_SEARCH_LENGTH;
146
147
  }
147
148
  default:
148
149
  return false;
@@ -20,7 +20,6 @@ import {
20
20
  extractElementNameFromPath,
21
21
  GenericType,
22
22
  GenericTypeExplicitReference,
23
- Multiplicity,
24
23
  PrimitiveInstanceValue,
25
24
  PRIMITIVE_TYPE,
26
25
  SimpleFunctionExpression,
@@ -126,10 +125,11 @@ const appendResultSetModifier = (
126
125
  ),
127
126
  multiplicityOne,
128
127
  );
129
- const multiplicity = new Multiplicity(
130
- resultModifierState.sortColumns.length,
131
- resultModifierState.sortColumns.length,
132
- );
128
+ const multiplicity =
129
+ resultModifierState.projectionState.queryBuilderState.graphManagerState.graph.getMultiplicity(
130
+ resultModifierState.sortColumns.length,
131
+ resultModifierState.sortColumns.length,
132
+ );
133
133
  const collection = new CollectionInstanceValue(
134
134
  multiplicity,
135
135
  undefined,
@@ -215,7 +215,7 @@ export const appendProjection = (
215
215
  );
216
216
 
217
217
  const colLambdas = new CollectionInstanceValue(
218
- new Multiplicity(
218
+ queryBuilderState.graphManagerState.graph.getMultiplicity(
219
219
  projectionState.columns.length -
220
220
  projectionState.aggregationState.columns.length,
221
221
  projectionState.columns.length -
@@ -223,13 +223,13 @@ export const appendProjection = (
223
223
  ),
224
224
  );
225
225
  const aggregateLambdas = new CollectionInstanceValue(
226
- new Multiplicity(
226
+ queryBuilderState.graphManagerState.graph.getMultiplicity(
227
227
  projectionState.aggregationState.columns.length,
228
228
  projectionState.aggregationState.columns.length,
229
229
  ),
230
230
  );
231
231
  const colAliases = new CollectionInstanceValue(
232
- new Multiplicity(
232
+ queryBuilderState.graphManagerState.graph.getMultiplicity(
233
233
  projectionState.columns.length,
234
234
  projectionState.columns.length,
235
235
  ),
@@ -330,13 +330,13 @@ export const appendProjection = (
330
330
  multiplicityOne,
331
331
  );
332
332
  const colLambdas = new CollectionInstanceValue(
333
- new Multiplicity(
333
+ queryBuilderState.graphManagerState.graph.getMultiplicity(
334
334
  projectionState.columns.length,
335
335
  projectionState.columns.length,
336
336
  ),
337
337
  );
338
338
  const colAliases = new CollectionInstanceValue(
339
- new Multiplicity(
339
+ queryBuilderState.graphManagerState.graph.getMultiplicity(
340
340
  projectionState.columns.length,
341
341
  projectionState.columns.length,
342
342
  ),
package/tsconfig.json CHANGED
@@ -35,6 +35,7 @@
35
35
  "files": [
36
36
  "./src/index.ts",
37
37
  "./src/components/QueryBuilder_TestID.ts",
38
+ "./src/components/QuerySetupUtils.ts",
38
39
  "./src/graphManager/QueryBuilderHashUtils.ts",
39
40
  "./src/graphManager/QueryBuilderSupportedFunctions.ts",
40
41
  "./src/graphManager/QueryBuilder_GraphManagerPlugin.ts",