@finos/legend-query-builder 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. package/lib/components/QueryBuilder.d.ts.map +1 -1
  2. package/lib/components/QueryBuilder.js +24 -20
  3. package/lib/components/QueryBuilder.js.map +1 -1
  4. package/lib/components/QueryBuilderParametersPanel.d.ts.map +1 -1
  5. package/lib/components/QueryBuilderParametersPanel.js +4 -8
  6. package/lib/components/QueryBuilderParametersPanel.js.map +1 -1
  7. package/lib/components/QueryBuilderPropertyExpressionEditor.d.ts.map +1 -1
  8. package/lib/components/QueryBuilderPropertyExpressionEditor.js +2 -2
  9. package/lib/components/QueryBuilderPropertyExpressionEditor.js.map +1 -1
  10. package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
  11. package/lib/components/QueryBuilderResultPanel.js +4 -2
  12. package/lib/components/QueryBuilderResultPanel.js.map +1 -1
  13. package/lib/components/QueryBuilderTextEditor.d.ts.map +1 -1
  14. package/lib/components/QueryBuilderTextEditor.js +4 -4
  15. package/lib/components/QueryBuilderTextEditor.js.map +1 -1
  16. package/lib/components/explorer/QueryBuilderExplorerPanel.d.ts.map +1 -1
  17. package/lib/components/explorer/QueryBuilderExplorerPanel.js +3 -3
  18. package/lib/components/explorer/QueryBuilderExplorerPanel.js.map +1 -1
  19. package/lib/components/explorer/QueryBuilderMilestoningEditor.d.ts.map +1 -1
  20. package/lib/components/explorer/QueryBuilderMilestoningEditor.js +6 -6
  21. package/lib/components/explorer/QueryBuilderMilestoningEditor.js.map +1 -1
  22. package/lib/components/fetch-structure/QueryBuilderOlapGroupByPanel.d.ts.map +1 -1
  23. package/lib/components/fetch-structure/QueryBuilderOlapGroupByPanel.js +6 -6
  24. package/lib/components/fetch-structure/QueryBuilderOlapGroupByPanel.js.map +1 -1
  25. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts.map +1 -1
  26. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +3 -3
  27. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
  28. package/lib/components/shared/LambdaEditor.d.ts.map +1 -1
  29. package/lib/components/shared/LambdaEditor.js +3 -3
  30. package/lib/components/shared/LambdaEditor.js.map +1 -1
  31. package/lib/components/shared/LambdaParameterValuesEditor.d.ts.map +1 -1
  32. package/lib/components/shared/LambdaParameterValuesEditor.js +3 -3
  33. package/lib/components/shared/LambdaParameterValuesEditor.js.map +1 -1
  34. package/lib/components/watermark/QueryBuilderWatermark.d.ts +23 -0
  35. package/lib/components/watermark/QueryBuilderWatermark.d.ts.map +1 -0
  36. package/lib/components/watermark/QueryBuilderWatermark.js +67 -0
  37. package/lib/components/watermark/QueryBuilderWatermark.js.map +1 -0
  38. package/lib/graphManager/QueryBuilderHashUtils.d.ts +1 -0
  39. package/lib/graphManager/QueryBuilderHashUtils.d.ts.map +1 -1
  40. package/lib/graphManager/QueryBuilderHashUtils.js +2 -0
  41. package/lib/graphManager/QueryBuilderHashUtils.js.map +1 -1
  42. package/lib/graphManager/QueryBuilderSupportedFunctions.d.ts +1 -0
  43. package/lib/graphManager/QueryBuilderSupportedFunctions.d.ts.map +1 -1
  44. package/lib/graphManager/QueryBuilderSupportedFunctions.js +2 -0
  45. package/lib/graphManager/QueryBuilderSupportedFunctions.js.map +1 -1
  46. package/lib/graphManager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.d.ts.map +1 -1
  47. package/lib/graphManager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js +4 -1
  48. package/lib/graphManager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js.map +1 -1
  49. package/lib/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts +1 -0
  50. package/lib/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts.map +1 -1
  51. package/lib/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js +29 -2
  52. package/lib/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js.map +1 -1
  53. package/lib/index.css +2 -2
  54. package/lib/index.css.map +1 -1
  55. package/lib/package.json +1 -1
  56. package/lib/stores/QueryBuilderState.d.ts +4 -0
  57. package/lib/stores/QueryBuilderState.d.ts.map +1 -1
  58. package/lib/stores/QueryBuilderState.js +12 -0
  59. package/lib/stores/QueryBuilderState.js.map +1 -1
  60. package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
  61. package/lib/stores/QueryBuilderStateBuilder.js +12 -1
  62. package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
  63. package/lib/stores/QueryBuilderValueSpecificationBuilder.d.ts.map +1 -1
  64. package/lib/stores/QueryBuilderValueSpecificationBuilder.js +7 -1
  65. package/lib/stores/QueryBuilderValueSpecificationBuilder.js.map +1 -1
  66. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts.map +1 -1
  67. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js +2 -1
  68. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js.map +1 -1
  69. package/lib/stores/watermark/QueryBuilderWatermarkState.d.ts +31 -0
  70. package/lib/stores/watermark/QueryBuilderWatermarkState.d.ts.map +1 -0
  71. package/lib/stores/watermark/QueryBuilderWatermarkState.js +69 -0
  72. package/lib/stores/watermark/QueryBuilderWatermarkState.js.map +1 -0
  73. package/lib/stores/watermark/QueryBuilderWatermarkStateBuilder.d.ts +19 -0
  74. package/lib/stores/watermark/QueryBuilderWatermarkStateBuilder.d.ts.map +1 -0
  75. package/lib/stores/watermark/QueryBuilderWatermarkStateBuilder.js +30 -0
  76. package/lib/stores/watermark/QueryBuilderWatermarkStateBuilder.js.map +1 -0
  77. package/lib/stores/watermark/QueryBuilderWatermarkValueSpecificationBuilder.d.ts +19 -0
  78. package/lib/stores/watermark/QueryBuilderWatermarkValueSpecificationBuilder.d.ts.map +1 -0
  79. package/lib/stores/watermark/QueryBuilderWatermarkValueSpecificationBuilder.js +30 -0
  80. package/lib/stores/watermark/QueryBuilderWatermarkValueSpecificationBuilder.js.map +1 -0
  81. package/package.json +4 -4
  82. package/src/components/QueryBuilder.tsx +141 -109
  83. package/src/components/QueryBuilderParametersPanel.tsx +27 -35
  84. package/src/components/QueryBuilderPropertyExpressionEditor.tsx +16 -11
  85. package/src/components/QueryBuilderResultPanel.tsx +18 -0
  86. package/src/components/QueryBuilderTextEditor.tsx +22 -17
  87. package/src/components/explorer/QueryBuilderExplorerPanel.tsx +16 -11
  88. package/src/components/explorer/QueryBuilderMilestoningEditor.tsx +27 -18
  89. package/src/components/fetch-structure/QueryBuilderOlapGroupByPanel.tsx +22 -18
  90. package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +11 -9
  91. package/src/components/shared/LambdaEditor.tsx +20 -17
  92. package/src/components/shared/LambdaParameterValuesEditor.tsx +17 -10
  93. package/src/components/watermark/QueryBuilderWatermark.tsx +185 -0
  94. package/src/graphManager/QueryBuilderHashUtils.ts +3 -0
  95. package/src/graphManager/QueryBuilderSupportedFunctions.ts +2 -0
  96. package/src/graphManager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.ts +14 -0
  97. package/src/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.ts +76 -0
  98. package/src/stores/QueryBuilderState.ts +14 -0
  99. package/src/stores/QueryBuilderStateBuilder.ts +17 -1
  100. package/src/stores/QueryBuilderValueSpecificationBuilder.ts +11 -1
  101. package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.ts +2 -1
  102. package/src/stores/watermark/QueryBuilderWatermarkState.ts +114 -0
  103. package/src/stores/watermark/QueryBuilderWatermarkStateBuilder.ts +50 -0
  104. package/src/stores/watermark/QueryBuilderWatermarkValueSpecificationBuilder.ts +46 -0
  105. package/tsconfig.json +4 -0
@@ -19,6 +19,7 @@ import {
19
19
  assertTrue,
20
20
  assertType,
21
21
  filterByType,
22
+ guaranteeNonNullable,
22
23
  guaranteeType,
23
24
  returnUndefOnError,
24
25
  } from '@finos/legend-shared';
@@ -49,6 +50,7 @@ import {
49
50
  TYPICAL_MULTIPLICITY_TYPE,
50
51
  VariableExpression,
51
52
  CORE_PURE_PATH,
53
+ PRIMITIVE_TYPE,
52
54
  } from '@finos/legend-graph';
53
55
  import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../../QueryBuilderSupportedFunctions.js';
54
56
 
@@ -325,6 +327,7 @@ export const V1_buildFilterFunctionExpression = (
325
327
  ),
326
328
  ),
327
329
  ];
330
+
328
331
  const expression = V1_buildBaseSimpleFunctionExpression(
329
332
  processedParams,
330
333
  functionName,
@@ -570,6 +573,79 @@ export const V1_buildGroupByFunctionExpression = (
570
573
  return [expression, processedParams];
571
574
  };
572
575
 
576
+ export const V1_buildWatermarkFunctionExpression = (
577
+ functionName: string,
578
+ parameters: V1_ValueSpecification[],
579
+ openVariables: string[],
580
+ compileContext: V1_GraphBuilderContext,
581
+ processingContext: V1_ProcessingContext,
582
+ ): [SimpleFunctionExpression, ValueSpecification[]] | undefined => {
583
+ assertTrue(
584
+ parameters.length === 2,
585
+ `Can't build forWatermark() expression: forWatermark() expects 1 argument`,
586
+ );
587
+ const precedingExpression = (
588
+ parameters[0] as V1_ValueSpecification
589
+ ).accept_ValueSpecificationVisitor(
590
+ new V1_ValueSpecificationBuilder(
591
+ compileContext,
592
+ processingContext,
593
+ openVariables,
594
+ ),
595
+ );
596
+ assertNonNullable(
597
+ precedingExpression.genericType,
598
+ `Can't build forWatermark() expression: preceding expression return type is missing`,
599
+ );
600
+
601
+ const lambda = parameters[1];
602
+ if (lambda instanceof V1_Lambda) {
603
+ lambda.parameters.forEach((variable): void => {
604
+ if (variable.name && !variable.class) {
605
+ const variableExpression = new VariableExpression(
606
+ variable.name,
607
+ precedingExpression.multiplicity,
608
+ );
609
+ variableExpression.genericType = precedingExpression.genericType;
610
+ processingContext.addInferredVariables(
611
+ variable.name,
612
+ variableExpression,
613
+ );
614
+ }
615
+ });
616
+ }
617
+
618
+ const processedParams = [
619
+ precedingExpression,
620
+ (parameters[1] as V1_ValueSpecification).accept_ValueSpecificationVisitor(
621
+ new V1_ValueSpecificationBuilder(
622
+ compileContext,
623
+ processingContext,
624
+ openVariables,
625
+ ),
626
+ ),
627
+ ];
628
+
629
+ const watermarkValueParam = guaranteeNonNullable(processedParams[1]);
630
+ const watermarkValueParamType =
631
+ watermarkValueParam.genericType?.value.rawType;
632
+ assertTrue(
633
+ compileContext.graph.getPrimitiveType(PRIMITIVE_TYPE.STRING) ===
634
+ watermarkValueParamType,
635
+ "Can't build forWatermark() expression: watermark parameter is expected to be of type string.",
636
+ );
637
+
638
+ const expression = V1_buildBaseSimpleFunctionExpression(
639
+ processedParams,
640
+ functionName,
641
+ compileContext,
642
+ );
643
+
644
+ expression.genericType = precedingExpression.genericType;
645
+ expression.multiplicity = precedingExpression.multiplicity;
646
+ return [expression, processedParams];
647
+ };
648
+
573
649
  export const V1_buildOlapGroupByFunctionExpression = (
574
650
  functionName: string,
575
651
  parameters: V1_ValueSpecification[],
@@ -75,6 +75,7 @@ import { QueryBuilderChangeDetectionState } from './QueryBuilderChangeDetectionS
75
75
  import { QueryBuilderMilestoningState } from './QueryBuilderMilestoningState.js';
76
76
  import { QUERY_BUILDER_HASH_STRUCTURE } from '../graphManager/QueryBuilderHashUtils.js';
77
77
  import { QUERY_BUILDER_COMMAND_KEY } from './QueryBuilderCommand.js';
78
+ import { QueryBuilderWatermarkState } from './watermark/QueryBuilderWatermarkState.js';
78
79
 
79
80
  export abstract class QueryBuilderState implements CommandRegistrar {
80
81
  applicationStore: GenericLegendApplicationStore;
@@ -87,6 +88,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
87
88
  milestoningState: QueryBuilderMilestoningState;
88
89
  fetchStructureState: QueryBuilderFetchStructureState;
89
90
  filterState: QueryBuilderFilterState;
91
+ watermarkState: QueryBuilderWatermarkState;
90
92
  filterOperators: QueryBuilderFilterOperator[] =
91
93
  getQueryBuilderCoreFilterOperators();
92
94
  resultState: QueryBuilderResultState;
@@ -97,6 +99,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
97
99
  queryCompileState = ActionState.create();
98
100
  showFunctionsExplorerPanel = false;
99
101
  showParametersPanel = false;
102
+ isEditingWatermark = false;
100
103
 
101
104
  class?: Class | undefined;
102
105
  mapping?: Mapping | undefined;
@@ -116,11 +119,13 @@ export abstract class QueryBuilderState implements CommandRegistrar {
116
119
  functionsExplorerState: observable,
117
120
  fetchStructureState: observable,
118
121
  filterState: observable,
122
+ watermarkState: observable,
119
123
  resultState: observable,
120
124
  textEditorState: observable,
121
125
  unsupportedQueryState: observable,
122
126
  showFunctionsExplorerPanel: observable,
123
127
  showParametersPanel: observable,
128
+ isEditingWatermark: observable,
124
129
  changeDetectionState: observable,
125
130
  class: observable,
126
131
  mapping: observable,
@@ -132,6 +137,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
132
137
 
133
138
  setShowFunctionsExplorerPanel: action,
134
139
  setShowParametersPanel: action,
140
+ setIsEditingWatermark: action,
135
141
  setClass: action,
136
142
  setMapping: action,
137
143
  setRuntimeValue: action,
@@ -156,6 +162,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
156
162
  this.functionsExplorerState = new QueryFunctionsExplorerState(this);
157
163
  this.fetchStructureState = new QueryBuilderFetchStructureState(this);
158
164
  this.filterState = new QueryBuilderFilterState(this, this.filterOperators);
165
+ this.watermarkState = new QueryBuilderWatermarkState(this);
159
166
  this.resultState = new QueryBuilderResultState(this);
160
167
  this.textEditorState = new QueryBuilderTextEditorState(this);
161
168
  this.unsupportedQueryState = new QueryBuilderUnsupportedQueryState(this);
@@ -201,6 +208,10 @@ export abstract class QueryBuilderState implements CommandRegistrar {
201
208
  this.showParametersPanel = val;
202
209
  }
203
210
 
211
+ setIsEditingWatermark(val: boolean): void {
212
+ this.isEditingWatermark = val;
213
+ }
214
+
204
215
  setClass(val: Class | undefined): void {
205
216
  this.class = val;
206
217
  }
@@ -249,6 +260,8 @@ export abstract class QueryBuilderState implements CommandRegistrar {
249
260
  this.parametersState = new QueryBuilderParametersState(this);
250
261
  this.functionsExplorerState = new QueryFunctionsExplorerState(this);
251
262
  this.filterState = new QueryBuilderFilterState(this, this.filterOperators);
263
+ this.watermarkState = new QueryBuilderWatermarkState(this);
264
+
252
265
  const currentFetchStructureImplementationType =
253
266
  this.fetchStructureState.implementation.type;
254
267
  this.fetchStructureState = new QueryBuilderFetchStructureState(this);
@@ -482,6 +495,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
482
495
  this.milestoningState,
483
496
  this.parametersState,
484
497
  this.filterState,
498
+ this.watermarkState,
485
499
  this.fetchStructureState.implementation,
486
500
  ]);
487
501
  }
@@ -71,6 +71,7 @@ import {
71
71
  import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../graphManager/QueryBuilderSupportedFunctions.js';
72
72
  import { LambdaParameterState } from './shared/LambdaParameterState.js';
73
73
  import { processTDSOlapGroupByExpression } from './fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByStateBuilder.js';
74
+ import { processWatermarkExpression } from './watermark/QueryBuilderWatermarkStateBuilder.js';
74
75
 
75
76
  const processGetAllExpression = (
76
77
  expression: SimpleFunctionExpression,
@@ -410,11 +411,26 @@ export class QueryBuilderValueSpecificationProcessor
410
411
  this.queryBuilderState,
411
412
  );
412
413
  return;
414
+ } else if (
415
+ matchFunctionName(precedingExpression.functionName, [
416
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.WATERMARK,
417
+ ])
418
+ ) {
419
+ processFilterExpression(valueSpecification, this.queryBuilderState);
420
+ return;
413
421
  } else {
414
422
  throw new UnsupportedOperationError(
415
- `Can't process filter() expression: only support filter() immediately following getAll() or project()/groupBy()/olapGroupBy()`,
423
+ `Can't process filter() expression: only support filter() immediately following getAll() or project()/forWatermark()/groupBy()/olapGroupBy()`,
416
424
  );
417
425
  }
426
+ } else if (
427
+ matchFunctionName(
428
+ functionName,
429
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.WATERMARK,
430
+ )
431
+ ) {
432
+ processWatermarkExpression(valueSpecification, this.queryBuilderState);
433
+ return;
418
434
  } else if (
419
435
  matchFunctionName(
420
436
  functionName,
@@ -37,6 +37,7 @@ import type { LambdaFunctionBuilderOption } from './QueryBuilderValueSpecificati
37
37
  import type { QueryBuilderFetchStructureState } from './fetch-structure/QueryBuilderFetchStructureState.js';
38
38
  import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../graphManager/QueryBuilderSupportedFunctions.js';
39
39
  import { buildParametersLetLambdaFunc } from './shared/LambdaParameterState.js';
40
+ import { buildWatermarkExpression } from './watermark/QueryBuilderWatermarkValueSpecificationBuilder.js';
40
41
 
41
42
  const buildGetAllFunction = (
42
43
  _class: Class,
@@ -136,10 +137,19 @@ export const buildLambdaFunction = (
136
137
  }
137
138
  lambdaFunction.expressionSequence[0] = getAllFunction;
138
139
 
140
+ // build watermark
141
+ const watermarkFunction = buildWatermarkExpression(
142
+ queryBuilderState.watermarkState,
143
+ getAllFunction,
144
+ );
145
+ if (watermarkFunction) {
146
+ lambdaFunction.expressionSequence[0] = watermarkFunction;
147
+ }
148
+
139
149
  // build filter
140
150
  const filterFunction = buildFilterExpression(
141
151
  queryBuilderState.filterState,
142
- getAllFunction,
152
+ watermarkFunction ?? getAllFunction,
143
153
  );
144
154
  if (filterFunction) {
145
155
  lambdaFunction.expressionSequence[0] = filterFunction;
@@ -81,8 +81,9 @@ export const processTDSProjectExpression = (
81
81
  matchFunctionName(precedingExpression.functionName, [
82
82
  QUERY_BUILDER_SUPPORTED_FUNCTIONS.GET_ALL,
83
83
  QUERY_BUILDER_SUPPORTED_FUNCTIONS.FILTER,
84
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.WATERMARK,
84
85
  ]),
85
- `Can't process project() expression: only support project() immediately following either getAll() or filter()`,
86
+ `Can't process project() expression: only support project() immediately following either getAll(), filter(), or forWatermark()`,
86
87
  );
87
88
  QueryBuilderValueSpecificationProcessor.process(
88
89
  precedingExpression,
@@ -0,0 +1,114 @@
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 {
18
+ type ValueSpecification,
19
+ observe_ValueSpecification,
20
+ GenericTypeExplicitReference,
21
+ GenericType,
22
+ PRIMITIVE_TYPE,
23
+ PrimitiveInstanceValue,
24
+ TYPICAL_MULTIPLICITY_TYPE,
25
+ multiplicityComparator,
26
+ type VariableExpression,
27
+ } from '@finos/legend-graph';
28
+ import { type Hashable, hashArray } from '@finos/legend-shared';
29
+ import { makeObservable, observable, action, computed } from 'mobx';
30
+ import { QUERY_BUILDER_HASH_STRUCTURE } from '../../graphManager/QueryBuilderHashUtils.js';
31
+ import type { QueryBuilderState } from '../QueryBuilderState.js';
32
+
33
+ export class QueryBuilderWatermarkState implements Hashable {
34
+ readonly queryBuilderState: QueryBuilderState;
35
+ value?: ValueSpecification | undefined;
36
+ isEditingWatermark = false;
37
+
38
+ constructor(queryBuilderState: QueryBuilderState) {
39
+ makeObservable(this, {
40
+ value: observable,
41
+ isEditingWatermark: observable,
42
+ setValue: action,
43
+ resetValue: action,
44
+ enableWatermark: action,
45
+ setIsEditingWatermark: action,
46
+ hashCode: computed,
47
+ });
48
+
49
+ this.queryBuilderState = queryBuilderState;
50
+ }
51
+
52
+ isParamaterCompatibleWithWaterMark = (
53
+ parameter: VariableExpression,
54
+ ): boolean => {
55
+ const isString =
56
+ this.queryBuilderState.graphManagerState.graph.getPrimitiveType(
57
+ PRIMITIVE_TYPE.STRING,
58
+ ) === parameter.genericType?.value.rawType;
59
+
60
+ const isMultiplictyOne = multiplicityComparator(
61
+ parameter.multiplicity,
62
+ this.queryBuilderState.graphManagerState.graph.getTypicalMultiplicity(
63
+ TYPICAL_MULTIPLICITY_TYPE.ONE,
64
+ ),
65
+ );
66
+ return isString && isMultiplictyOne;
67
+ };
68
+
69
+ resetValue(): void {
70
+ const watermarkConstant = new PrimitiveInstanceValue(
71
+ GenericTypeExplicitReference.create(
72
+ new GenericType(
73
+ this.queryBuilderState.graphManagerState.graph.getPrimitiveType(
74
+ PRIMITIVE_TYPE.STRING,
75
+ ),
76
+ ),
77
+ ),
78
+ this.queryBuilderState.graphManagerState.graph.getTypicalMultiplicity(
79
+ TYPICAL_MULTIPLICITY_TYPE.ONE,
80
+ ),
81
+ );
82
+
83
+ watermarkConstant.values = ['watermarkValue'];
84
+ this.setValue(watermarkConstant);
85
+ }
86
+
87
+ setIsEditingWatermark(val: boolean): void {
88
+ this.isEditingWatermark = val;
89
+ }
90
+
91
+ enableWatermark(): void {
92
+ if (this.value) {
93
+ this.setValue(undefined);
94
+ } else {
95
+ this.resetValue();
96
+ }
97
+ }
98
+
99
+ setValue(val: ValueSpecification | undefined): void {
100
+ this.value = val
101
+ ? observe_ValueSpecification(
102
+ val,
103
+ this.queryBuilderState.observableContext,
104
+ )
105
+ : undefined;
106
+ }
107
+
108
+ get hashCode(): string {
109
+ return hashArray([
110
+ QUERY_BUILDER_HASH_STRUCTURE.WATERMARK_STATE,
111
+ this.value ?? '',
112
+ ]);
113
+ }
114
+ }
@@ -0,0 +1,50 @@
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 {
18
+ SimpleFunctionExpression,
19
+ matchFunctionName,
20
+ } from '@finos/legend-graph';
21
+ import { assertTrue, guaranteeType } from '@finos/legend-shared';
22
+ import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../graphManager/QueryBuilderSupportedFunctions.js';
23
+ import type { QueryBuilderState } from '../QueryBuilderState.js';
24
+ import { QueryBuilderValueSpecificationProcessor } from '../QueryBuilderStateBuilder.js';
25
+
26
+ export const processWatermarkExpression = (
27
+ expression: SimpleFunctionExpression,
28
+ queryBuilderState: QueryBuilderState,
29
+ ): void => {
30
+ // check preceding expression
31
+ const precedingExpression = guaranteeType(
32
+ expression.parametersValues[0],
33
+ SimpleFunctionExpression,
34
+ `Can't process forWatermark() expression: only support forWatermark() immediately following an expression`,
35
+ );
36
+ assertTrue(
37
+ matchFunctionName(precedingExpression.functionName, [
38
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.GET_ALL,
39
+ ]),
40
+ `Can't process forWatermark() expression: only support forWatermark() immediately following getAll()`,
41
+ );
42
+
43
+ QueryBuilderValueSpecificationProcessor.process(
44
+ precedingExpression,
45
+ queryBuilderState,
46
+ );
47
+
48
+ const watermarkValue = expression.parametersValues[1];
49
+ queryBuilderState.watermarkState.setValue(watermarkValue);
50
+ };
@@ -0,0 +1,46 @@
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 {
18
+ SimpleFunctionExpression,
19
+ extractElementNameFromPath,
20
+ type VariableExpression,
21
+ } from '@finos/legend-graph';
22
+ import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../graphManager/QueryBuilderSupportedFunctions.js';
23
+ import type { QueryBuilderWatermarkState } from './QueryBuilderWatermarkState.js';
24
+
25
+ export const buildWatermarkExpression = (
26
+ watermarkState: QueryBuilderWatermarkState,
27
+ getAllFunc: SimpleFunctionExpression,
28
+ ): SimpleFunctionExpression | undefined => {
29
+ if (!watermarkState.value) {
30
+ return undefined;
31
+ }
32
+
33
+ // main filter expression
34
+ const watermarkExpression = new SimpleFunctionExpression(
35
+ extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.WATERMARK),
36
+ (watermarkState.value as VariableExpression).multiplicity,
37
+ );
38
+
39
+ // param [0]
40
+ watermarkExpression.parametersValues.push(getAllFunc);
41
+
42
+ // param [1]
43
+ watermarkExpression.parametersValues.push(watermarkState.value);
44
+
45
+ return watermarkExpression;
46
+ };
package/tsconfig.json CHANGED
@@ -150,6 +150,9 @@
150
150
  "./src/stores/shared/LambdaParameterState.ts",
151
151
  "./src/stores/shared/ValueSpecificationEditorHelper.ts",
152
152
  "./src/stores/shared/ValueSpecificationModifierHelper.ts",
153
+ "./src/stores/watermark/QueryBuilderWatermarkState.ts",
154
+ "./src/stores/watermark/QueryBuilderWatermarkStateBuilder.ts",
155
+ "./src/stores/watermark/QueryBuilderWatermarkValueSpecificationBuilder.ts",
153
156
  "./src/stores/workflows/ClassQueryBuilderState.ts",
154
157
  "./src/stores/workflows/MappingQueryBuilderState.ts",
155
158
  "./src/stores/workflows/ServiceQueryBuilderState.ts",
@@ -184,6 +187,7 @@
184
187
  "./src/components/shared/LambdaParameterValuesEditor.tsx",
185
188
  "./src/components/shared/QueryBuilderPanelIssueCountBadge.tsx",
186
189
  "./src/components/shared/QueryBuilderPropertyInfoTooltip.tsx",
190
+ "./src/components/watermark/QueryBuilderWatermark.tsx",
187
191
  "./src/components/workflows/ClassQueryBuilder.tsx",
188
192
  "./src/components/workflows/MappingQueryBuilder.tsx",
189
193
  "./src/components/workflows/ServiceQueryBuilder.tsx"