@finos/legend-query-builder 4.14.35 → 4.14.37

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. package/lib/__lib__/QueryBuilderDocumentation.d.ts +2 -1
  2. package/lib/__lib__/QueryBuilderDocumentation.d.ts.map +1 -1
  3. package/lib/__lib__/QueryBuilderDocumentation.js +1 -0
  4. package/lib/__lib__/QueryBuilderDocumentation.js.map +1 -1
  5. package/lib/__lib__/QueryBuilderTesting.d.ts +1 -0
  6. package/lib/__lib__/QueryBuilderTesting.d.ts.map +1 -1
  7. package/lib/__lib__/QueryBuilderTesting.js +1 -0
  8. package/lib/__lib__/QueryBuilderTesting.js.map +1 -1
  9. package/lib/components/QueryBuilder.d.ts.map +1 -1
  10. package/lib/components/QueryBuilder.js +55 -19
  11. package/lib/components/QueryBuilder.js.map +1 -1
  12. package/lib/components/QueryBuilderConstantExpressionPanel.d.ts.map +1 -1
  13. package/lib/components/QueryBuilderConstantExpressionPanel.js +30 -13
  14. package/lib/components/QueryBuilderConstantExpressionPanel.js.map +1 -1
  15. package/lib/components/QueryBuilderPropertyExpressionEditor.d.ts.map +1 -1
  16. package/lib/components/QueryBuilderPropertyExpressionEditor.js +2 -1
  17. package/lib/components/QueryBuilderPropertyExpressionEditor.js.map +1 -1
  18. package/lib/components/QueryBuilderSideBar.d.ts +0 -16
  19. package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
  20. package/lib/components/QueryBuilderSideBar.js +32 -104
  21. package/lib/components/QueryBuilderSideBar.js.map +1 -1
  22. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.d.ts.map +1 -1
  23. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js +2 -1
  24. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js.map +1 -1
  25. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts.map +1 -1
  26. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +50 -5
  27. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
  28. package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
  29. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +2 -1
  30. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
  31. package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
  32. package/lib/components/filter/QueryBuilderFilterPanel.js +2 -1
  33. package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
  34. package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
  35. package/lib/components/result/QueryBuilderResultPanel.js +18 -6
  36. package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
  37. package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -1
  38. package/lib/components/shared/BasicValueSpecificationEditor.js +62 -28
  39. package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
  40. package/lib/components/shared/CustomDatePicker.d.ts +1 -0
  41. package/lib/components/shared/CustomDatePicker.d.ts.map +1 -1
  42. package/lib/components/shared/CustomDatePicker.js +13 -9
  43. package/lib/components/shared/CustomDatePicker.js.map +1 -1
  44. package/lib/components/shared/QueryBuilderVariableSelector.d.ts +1 -0
  45. package/lib/components/shared/QueryBuilderVariableSelector.d.ts.map +1 -1
  46. package/lib/components/shared/QueryBuilderVariableSelector.js +2 -2
  47. package/lib/components/shared/QueryBuilderVariableSelector.js.map +1 -1
  48. package/lib/components/workflows/ClassQueryBuilder.d.ts.map +1 -1
  49. package/lib/components/workflows/ClassQueryBuilder.js +19 -16
  50. package/lib/components/workflows/ClassQueryBuilder.js.map +1 -1
  51. package/lib/components/workflows/MappingQueryBuilder.d.ts.map +1 -1
  52. package/lib/components/workflows/MappingQueryBuilder.js +18 -15
  53. package/lib/components/workflows/MappingQueryBuilder.js.map +1 -1
  54. package/lib/components/workflows/ServiceQueryBuilder.d.ts.map +1 -1
  55. package/lib/components/workflows/ServiceQueryBuilder.js +13 -10
  56. package/lib/components/workflows/ServiceQueryBuilder.js.map +1 -1
  57. package/lib/index.css +2 -2
  58. package/lib/index.css.map +1 -1
  59. package/lib/index.d.ts +2 -1
  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 +1 -1
  64. package/lib/stores/QueryBuilderConstantsState.d.ts.map +1 -1
  65. package/lib/stores/QueryBuilderConstantsState.js +2 -1
  66. package/lib/stores/QueryBuilderConstantsState.js.map +1 -1
  67. package/lib/stores/QueryBuilderPropertyEditorState.d.ts +1 -1
  68. package/lib/stores/QueryBuilderPropertyEditorState.d.ts.map +1 -1
  69. package/lib/stores/QueryBuilderPropertyEditorState.js +12 -34
  70. package/lib/stores/QueryBuilderPropertyEditorState.js.map +1 -1
  71. package/lib/stores/QueryBuilderState.d.ts +3 -0
  72. package/lib/stores/QueryBuilderState.d.ts.map +1 -1
  73. package/lib/stores/QueryBuilderState.js +15 -1
  74. package/lib/stores/QueryBuilderState.js.map +1 -1
  75. package/lib/stores/QueryBuilderValueSpecificationHelper.d.ts +2 -1
  76. package/lib/stores/QueryBuilderValueSpecificationHelper.d.ts.map +1 -1
  77. package/lib/stores/QueryBuilderValueSpecificationHelper.js +23 -1
  78. package/lib/stores/QueryBuilderValueSpecificationHelper.js.map +1 -1
  79. package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts +29 -0
  80. package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts.map +1 -1
  81. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts +2 -0
  82. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts.map +1 -1
  83. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.js +2 -0
  84. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.js.map +1 -1
  85. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts +2 -0
  86. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts.map +1 -1
  87. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js +6 -0
  88. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js.map +1 -1
  89. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts +2 -0
  90. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts.map +1 -1
  91. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js +15 -0
  92. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
  93. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts +3 -0
  94. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts.map +1 -1
  95. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js +42 -3
  96. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js.map +1 -1
  97. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.d.ts.map +1 -1
  98. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.js +6 -5
  99. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.js.map +1 -1
  100. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.d.ts.map +1 -1
  101. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.js +6 -5
  102. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.js.map +1 -1
  103. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.d.ts.map +1 -1
  104. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.js +8 -37
  105. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.js.map +1 -1
  106. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.d.ts.map +1 -1
  107. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.js +7 -10
  108. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.js.map +1 -1
  109. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.d.ts.map +1 -1
  110. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.js +7 -10
  111. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.js.map +1 -1
  112. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.d.ts.map +1 -1
  113. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.js +6 -5
  114. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.js.map +1 -1
  115. package/lib/stores/filter/QueryBuilderFilterState.d.ts +3 -0
  116. package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
  117. package/lib/stores/filter/QueryBuilderFilterState.js +30 -2
  118. package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
  119. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.d.ts.map +1 -1
  120. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.js +5 -4
  121. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.js.map +1 -1
  122. package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.d.ts.map +1 -1
  123. package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.js +5 -4
  124. package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.js.map +1 -1
  125. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.d.ts.map +1 -1
  126. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.js +7 -35
  127. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.js.map +1 -1
  128. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.d.ts.map +1 -1
  129. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.js +6 -8
  130. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.js.map +1 -1
  131. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.d.ts.map +1 -1
  132. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.js +6 -8
  133. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.js.map +1 -1
  134. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.d.ts.map +1 -1
  135. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.js +6 -8
  136. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.js.map +1 -1
  137. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.d.ts.map +1 -1
  138. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.js +6 -8
  139. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.js.map +1 -1
  140. package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.d.ts.map +1 -1
  141. package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.js +5 -4
  142. package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.js.map +1 -1
  143. package/lib/stores/query-workflow/QueryBuilderWorkFlowState.d.ts +5 -0
  144. package/lib/stores/query-workflow/QueryBuilderWorkFlowState.d.ts.map +1 -1
  145. package/lib/stores/query-workflow/QueryBuilderWorkFlowState.js +7 -0
  146. package/lib/stores/query-workflow/QueryBuilderWorkFlowState.js.map +1 -1
  147. package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts +1 -1
  148. package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts.map +1 -1
  149. package/lib/stores/shared/ValueSpecificationEditorHelper.js +20 -10
  150. package/lib/stores/shared/ValueSpecificationEditorHelper.js.map +1 -1
  151. package/lib/stores/watermark/QueryBuilderWatermarkState.d.ts +0 -2
  152. package/lib/stores/watermark/QueryBuilderWatermarkState.d.ts.map +1 -1
  153. package/lib/stores/watermark/QueryBuilderWatermarkState.js +0 -6
  154. package/lib/stores/watermark/QueryBuilderWatermarkState.js.map +1 -1
  155. package/lib/stores/workflows/MappingQueryBuilderState.d.ts +2 -2
  156. package/lib/stores/workflows/MappingQueryBuilderState.d.ts.map +1 -1
  157. package/lib/stores/workflows/MappingQueryBuilderState.js +2 -1
  158. package/lib/stores/workflows/MappingQueryBuilderState.js.map +1 -1
  159. package/lib/stores/workflows/ServiceQueryBuilderState.d.ts +2 -2
  160. package/lib/stores/workflows/ServiceQueryBuilderState.d.ts.map +1 -1
  161. package/lib/stores/workflows/ServiceQueryBuilderState.js +2 -1
  162. package/lib/stores/workflows/ServiceQueryBuilderState.js.map +1 -1
  163. package/package.json +4 -4
  164. package/src/__lib__/QueryBuilderDocumentation.ts +1 -0
  165. package/src/__lib__/QueryBuilderTesting.ts +1 -0
  166. package/src/components/QueryBuilder.tsx +179 -54
  167. package/src/components/QueryBuilderConstantExpressionPanel.tsx +36 -14
  168. package/src/components/QueryBuilderPropertyExpressionEditor.tsx +2 -0
  169. package/src/components/QueryBuilderSideBar.tsx +138 -339
  170. package/src/components/fetch-structure/QueryBuilderPostFilterPanel.tsx +6 -1
  171. package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +139 -1
  172. package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +17 -0
  173. package/src/components/filter/QueryBuilderFilterPanel.tsx +6 -0
  174. package/src/components/result/QueryBuilderResultPanel.tsx +63 -6
  175. package/src/components/shared/BasicValueSpecificationEditor.tsx +96 -34
  176. package/src/components/shared/CustomDatePicker.tsx +18 -11
  177. package/src/components/shared/QueryBuilderVariableSelector.tsx +2 -2
  178. package/src/components/workflows/ClassQueryBuilder.tsx +79 -77
  179. package/src/components/workflows/MappingQueryBuilder.tsx +75 -76
  180. package/src/components/workflows/ServiceQueryBuilder.tsx +71 -70
  181. package/src/index.ts +2 -1
  182. package/src/stores/QueryBuilderConstantsState.ts +2 -0
  183. package/src/stores/QueryBuilderPropertyEditorState.ts +15 -53
  184. package/src/stores/QueryBuilderState.ts +23 -1
  185. package/src/stores/QueryBuilderValueSpecificationHelper.ts +32 -0
  186. package/src/stores/QueryBuilder_LegendApplicationPlugin_Extension.ts +39 -0
  187. package/src/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.ts +4 -0
  188. package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.ts +8 -0
  189. package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +32 -0
  190. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.ts +59 -0
  191. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.ts +5 -5
  192. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.ts +5 -5
  193. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.ts +10 -69
  194. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.ts +7 -18
  195. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.ts +7 -18
  196. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.ts +5 -5
  197. package/src/stores/filter/QueryBuilderFilterState.ts +48 -2
  198. package/src/stores/filter/operators/QueryBuilderFilterOperator_Contain.ts +5 -5
  199. package/src/stores/filter/operators/QueryBuilderFilterOperator_EndWith.ts +5 -5
  200. package/src/stores/filter/operators/QueryBuilderFilterOperator_Equal.ts +10 -71
  201. package/src/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.ts +6 -14
  202. package/src/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.ts +6 -14
  203. package/src/stores/filter/operators/QueryBuilderFilterOperator_LessThan.ts +6 -14
  204. package/src/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.ts +6 -14
  205. package/src/stores/filter/operators/QueryBuilderFilterOperator_StartWith.ts +5 -5
  206. package/src/stores/query-workflow/QueryBuilderWorkFlowState.ts +10 -0
  207. package/src/stores/shared/ValueSpecificationEditorHelper.ts +32 -16
  208. package/src/stores/watermark/QueryBuilderWatermarkState.ts +0 -7
  209. package/src/stores/workflows/MappingQueryBuilderState.ts +7 -1
  210. package/src/stores/workflows/ServiceQueryBuilderState.ts +6 -1
  211. package/tsconfig.json +0 -1
  212. package/lib/components/watermark/QueryBuilderWatermark.d.ts +0 -22
  213. package/lib/components/watermark/QueryBuilderWatermark.d.ts.map +0 -1
  214. package/lib/components/watermark/QueryBuilderWatermark.js +0 -83
  215. package/lib/components/watermark/QueryBuilderWatermark.js.map +0 -1
  216. package/src/components/watermark/QueryBuilderWatermark.tsx +0 -218
@@ -134,11 +134,11 @@ export const buildDefaultInstanceValue = (
134
134
  graph: PureModel,
135
135
  type: Type,
136
136
  observerContext: ObserverContext,
137
+ enableInitializingDefaultValue: boolean,
137
138
  ): ValueSpecification => {
138
139
  const path = type.path;
139
140
  switch (path) {
140
141
  case PRIMITIVE_TYPE.STRING:
141
- case PRIMITIVE_TYPE.BOOLEAN:
142
142
  case PRIMITIVE_TYPE.STRICTDATE:
143
143
  case PRIMITIVE_TYPE.DATETIME:
144
144
  case PRIMITIVE_TYPE.NUMBER:
@@ -147,6 +147,16 @@ export const buildDefaultInstanceValue = (
147
147
  case PRIMITIVE_TYPE.BINARY:
148
148
  case PRIMITIVE_TYPE.BYTE:
149
149
  case PRIMITIVE_TYPE.INTEGER: {
150
+ return buildPrimitiveInstanceValue(
151
+ graph,
152
+ path,
153
+ enableInitializingDefaultValue
154
+ ? generateDefaultValueForPrimitiveType(path)
155
+ : null,
156
+ observerContext,
157
+ );
158
+ }
159
+ case PRIMITIVE_TYPE.BOOLEAN: {
150
160
  return buildPrimitiveInstanceValue(
151
161
  graph,
152
162
  path,
@@ -158,29 +168,34 @@ export const buildDefaultInstanceValue = (
158
168
  return buildPrimitiveInstanceValue(
159
169
  graph,
160
170
  PRIMITIVE_TYPE.STRICTDATE,
161
- generateDefaultValueForPrimitiveType(path),
171
+ enableInitializingDefaultValue
172
+ ? generateDefaultValueForPrimitiveType(path)
173
+ : null,
162
174
  observerContext,
163
175
  );
164
176
  }
165
177
  default:
166
178
  if (type instanceof Enumeration) {
167
- if (type.values.length > 0) {
168
- const enumValueInstanceValue = new EnumValueInstanceValue(
169
- GenericTypeExplicitReference.create(new GenericType(type)),
170
- );
171
- instanceValue_setValues(
172
- enumValueInstanceValue,
173
- [EnumValueExplicitReference.create(type.values[0] as Enum)],
174
- observerContext,
175
- );
176
- return enumValueInstanceValue;
177
- }
178
- throw new UnsupportedOperationError(
179
- `Can't get default value for enumeration since enumeration '${path}' has no value`,
179
+ const enumValueInstanceValue = new EnumValueInstanceValue(
180
+ GenericTypeExplicitReference.create(new GenericType(type)),
180
181
  );
182
+ if (enableInitializingDefaultValue) {
183
+ if (type.values.length > 0) {
184
+ instanceValue_setValues(
185
+ enumValueInstanceValue,
186
+ [EnumValueExplicitReference.create(type.values[0] as Enum)],
187
+ observerContext,
188
+ );
189
+ } else {
190
+ throw new UnsupportedOperationError(
191
+ `Can't get default value for enumeration since enumeration '${path}' has no value`,
192
+ );
193
+ }
194
+ }
195
+ return enumValueInstanceValue;
181
196
  }
182
197
  throw new UnsupportedOperationError(
183
- `Can't get default value for type'${path}'`,
198
+ `Can't get default value for type '${path}'`,
184
199
  );
185
200
  }
186
201
  };
@@ -201,6 +216,7 @@ export const buildDefaultEmptyStringLambda = (
201
216
  graph,
202
217
  PrimitiveType.STRING,
203
218
  observerContext,
219
+ true,
204
220
  );
205
221
  return lambdaFunction;
206
222
  };
@@ -32,14 +32,11 @@ import { isValueExpressionReferencedInValue } from '../QueryBuilderValueSpecific
32
32
  export class QueryBuilderWatermarkState implements Hashable {
33
33
  readonly queryBuilderState: QueryBuilderState;
34
34
  value?: ValueSpecification | undefined;
35
- isEditingWatermark = false;
36
35
 
37
36
  constructor(queryBuilderState: QueryBuilderState) {
38
37
  makeObservable(this, {
39
38
  value: observable,
40
- isEditingWatermark: observable,
41
39
  setValue: action,
42
- setIsEditingWatermark: action,
43
40
  hashCode: computed,
44
41
  });
45
42
 
@@ -57,10 +54,6 @@ export class QueryBuilderWatermarkState implements Hashable {
57
54
  return watermarkConstant;
58
55
  }
59
56
 
60
- setIsEditingWatermark(val: boolean): void {
61
- this.isEditingWatermark = val;
62
- }
63
-
64
57
  setValue(val: ValueSpecification | undefined): void {
65
58
  this.value = val
66
59
  ? observe_ValueSpecification(val, this.queryBuilderState.observerContext)
@@ -28,7 +28,10 @@ import { getNullableFirstEntry } from '@finos/legend-shared';
28
28
  import { renderMappingQueryBuilderSetupPanelContent } from '../../components/workflows/MappingQueryBuilder.js';
29
29
  import { QueryBuilderState } from '../QueryBuilderState.js';
30
30
  import type { QueryBuilderConfig } from '../../graph-manager/QueryBuilderConfig.js';
31
- import type { QueryBuilderWorkflowState } from '../query-workflow/QueryBuilderWorkFlowState.js';
31
+ import type {
32
+ QueryBuilderActionConfig,
33
+ QueryBuilderWorkflowState,
34
+ } from '../query-workflow/QueryBuilderWorkFlowState.js';
32
35
 
33
36
  export class MappingQueryBuilderState extends QueryBuilderState {
34
37
  readonly onMappingChange?: ((val: Mapping) => void) | undefined;
@@ -41,6 +44,7 @@ export class MappingQueryBuilderState extends QueryBuilderState {
41
44
  applicationStore: GenericLegendApplicationStore,
42
45
  graphManagerState: GraphManagerState,
43
46
  workflowState: QueryBuilderWorkflowState,
47
+ actionConfig: QueryBuilderActionConfig,
44
48
  onMappingChange?: ((val: Mapping) => void) | undefined,
45
49
  onRuntimeChange?: ((val: Runtime) => void) | undefined,
46
50
  config?: QueryBuilderConfig | undefined,
@@ -50,12 +54,14 @@ export class MappingQueryBuilderState extends QueryBuilderState {
50
54
  applicationStore,
51
55
  graphManagerState,
52
56
  workflowState,
57
+
53
58
  config,
54
59
  sourceInfo,
55
60
  );
56
61
 
57
62
  this.onMappingChange = onMappingChange;
58
63
  this.onRuntimeChange = onRuntimeChange;
64
+ this.workflowState.updateActionConfig(actionConfig);
59
65
  }
60
66
 
61
67
  /**
@@ -34,7 +34,10 @@ import { action, makeObservable, observable } from 'mobx';
34
34
  import { renderServiceQueryBuilderSetupPanelContent } from '../../components/workflows/ServiceQueryBuilder.js';
35
35
  import { QueryBuilderState } from '../QueryBuilderState.js';
36
36
  import type { QueryBuilderConfig } from '../../graph-manager/QueryBuilderConfig.js';
37
- import type { QueryBuilderWorkflowState } from '../query-workflow/QueryBuilderWorkFlowState.js';
37
+ import type {
38
+ QueryBuilderActionConfig,
39
+ QueryBuilderWorkflowState,
40
+ } from '../query-workflow/QueryBuilderWorkFlowState.js';
38
41
 
39
42
  export type ServiceExecutionContext = {
40
43
  key: string;
@@ -60,6 +63,7 @@ export class ServiceQueryBuilderState extends QueryBuilderState {
60
63
  applicationStore: GenericLegendApplicationStore,
61
64
  graphManagerState: GraphManagerState,
62
65
  workflowState: QueryBuilderWorkflowState,
66
+ actionConfig: QueryBuilderActionConfig,
63
67
  service: Service,
64
68
  usableServices: Service[] | undefined,
65
69
  executionContextKey?: string | undefined,
@@ -87,6 +91,7 @@ export class ServiceQueryBuilderState extends QueryBuilderState {
87
91
  this.usableServices = usableServices;
88
92
  this.onServiceChange = onServiceChange;
89
93
  this.onExecutionContextChange = onExecutionContextChange;
94
+ this.workflowState.updateActionConfig(actionConfig);
90
95
 
91
96
  if (service.execution instanceof PureSingleExecution) {
92
97
  this.executionContextState.mapping = service.execution.mapping?.value;
package/tsconfig.json CHANGED
@@ -258,7 +258,6 @@
258
258
  "./src/components/shared/QueryBuilderPropertyInfoTooltip.tsx",
259
259
  "./src/components/shared/QueryBuilderRootClassInfoTooltip.tsx",
260
260
  "./src/components/shared/QueryBuilderVariableSelector.tsx",
261
- "./src/components/watermark/QueryBuilderWatermark.tsx",
262
261
  "./src/components/workflows/ClassQueryBuilder.tsx",
263
262
  "./src/components/workflows/MappingQueryBuilder.tsx",
264
263
  "./src/components/workflows/ServiceQueryBuilder.tsx"
@@ -1,22 +0,0 @@
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
- import type { QueryBuilderState } from '../../stores/QueryBuilderState.js';
17
- export declare const QueryBuilderWatermarkEditor: ((props: {
18
- queryBuilderState: QueryBuilderState;
19
- }) => import("react/jsx-runtime").JSX.Element) & {
20
- displayName: string;
21
- };
22
- //# sourceMappingURL=QueryBuilderWatermark.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"QueryBuilderWatermark.d.ts","sourceRoot":"","sources":["../../../src/components/watermark/QueryBuilderWatermark.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAyBH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AA6F3E,eAAO,MAAM,2BAA2B,WAC9B;IAAE,iBAAiB,EAAE,iBAAiB,CAAA;CAAE;;CAoFjD,CAAC"}
@@ -1,83 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- /**
3
- * Copyright (c) 2020-present, Goldman Sachs
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- import { Dialog, PanelDropZone, PanelFormBooleanField, PanelForm, PanelDivider, Modal, ModalBody, ModalFooter, ModalHeader, PanelFormSection, ModalFooterButton, } from '@finos/legend-art';
18
- import { areMultiplicitiesEqual, Multiplicity, PrimitiveType, } from '@finos/legend-graph';
19
- import { observer } from 'mobx-react-lite';
20
- import { useCallback, useState } from 'react';
21
- import { useDrop } from 'react-dnd';
22
- import { BasicValueSpecificationEditor, QUERY_BUILDER_VARIABLE_DND_TYPE, } from '../shared/BasicValueSpecificationEditor.js';
23
- import { VariableSelector } from '../shared/QueryBuilderVariableSelector.js';
24
- import { clone, deepClone } from '@finos/legend-shared';
25
- const isParamaterCompatibleWithWaterMark = (parameter) => PrimitiveType.STRING === parameter.genericType?.value.rawType &&
26
- areMultiplicitiesEqual(parameter.multiplicity, Multiplicity.ONE);
27
- const WatermarkValueEditor = observer((props) => {
28
- const { selectedValue, setSelectedValue, handleResetValue, watermarkState, } = props;
29
- const graph = watermarkState.queryBuilderState.graphManagerState.graph;
30
- const handleDrop = useCallback((item) => {
31
- setSelectedValue(item.variable);
32
- }, [setSelectedValue]);
33
- const [{ isParameterValueDragOver }, dropTargetConnector] = useDrop(() => ({
34
- accept: [QUERY_BUILDER_VARIABLE_DND_TYPE],
35
- drop: (item, monitor) => {
36
- if (!monitor.didDrop() &&
37
- // Only allows parameters with muliplicity 1 and type string
38
- isParamaterCompatibleWithWaterMark(item.variable)) {
39
- handleDrop(item);
40
- } // prevent drop event propagation to accomondate for nested DnD
41
- },
42
- collect: (monitor) => ({
43
- isParameterValueDragOver: monitor.isOver({
44
- shallow: true,
45
- }),
46
- }),
47
- }), [handleDrop]);
48
- return (_jsx(PanelFormSection, { children: _jsx("div", { className: "query-builder__variable-editor", children: _jsx(PanelDropZone, { isDragOver: isParameterValueDragOver, dropTargetConnector: dropTargetConnector, children: _jsx(BasicValueSpecificationEditor, { valueSpecification: selectedValue, setValueSpecification: (val) => {
49
- setSelectedValue(clone(val));
50
- }, graph: graph, obseverContext: watermarkState.queryBuilderState.observerContext, typeCheckOption: {
51
- expectedType: PrimitiveType.STRING,
52
- }, resetValue: handleResetValue, isConstant: watermarkState.queryBuilderState.constantState.isValueSpecConstant(selectedValue) }) }) }) }));
53
- });
54
- export const QueryBuilderWatermarkEditor = observer((props) => {
55
- const { queryBuilderState } = props;
56
- const applicationStore = queryBuilderState.applicationStore;
57
- const watermarkState = queryBuilderState.watermarkState;
58
- const [selectedValue, setSelectedValue] = useState(deepClone(watermarkState.value));
59
- const handleCancel = () => {
60
- watermarkState.setIsEditingWatermark(false);
61
- };
62
- const handleApply = () => {
63
- watermarkState.setValue(selectedValue);
64
- handleCancel();
65
- };
66
- const handleResetValue = () => {
67
- setSelectedValue(watermarkState.getDefaultValue());
68
- };
69
- const toggleWatermark = () => {
70
- if (selectedValue) {
71
- setSelectedValue(undefined);
72
- }
73
- else {
74
- handleResetValue();
75
- }
76
- };
77
- return (_jsx(Dialog, { open: Boolean(watermarkState.isEditingWatermark), onClose: handleCancel, classes: {
78
- root: 'editor-modal__root-container',
79
- container: 'editor-modal__container',
80
- paper: 'editor-modal__content',
81
- }, children: _jsxs(Modal, { darkMode: !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled, className: "editor-modal query-builder__watermark__modal", children: [_jsx(ModalHeader, { title: "Watermark" }), _jsx(ModalBody, { children: _jsxs(PanelForm, { children: [_jsx(PanelFormBooleanField, { isReadOnly: false, value: selectedValue !== undefined, prompt: "Enable watermark", update: toggleWatermark }), selectedValue && (_jsxs(_Fragment, { children: [_jsx(WatermarkValueEditor, { selectedValue: selectedValue, setSelectedValue: setSelectedValue, handleResetValue: handleResetValue, watermarkState: watermarkState }), _jsx(PanelDivider, {}), _jsx(VariableSelector, { filterBy: isParamaterCompatibleWithWaterMark, queryBuilderState: queryBuilderState })] }))] }) }), _jsxs(ModalFooter, { children: [_jsx(ModalFooterButton, { text: "Apply", onClick: handleApply }), _jsx(ModalFooterButton, { text: "Cancel", onClick: handleCancel, type: "secondary" })] })] }) }));
82
- });
83
- //# sourceMappingURL=QueryBuilderWatermark.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"QueryBuilderWatermark.js","sourceRoot":"","sources":["../../../src/components/watermark/QueryBuilderWatermark.tsx"],"names":[],"mappings":"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"}
@@ -1,218 +0,0 @@
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
- Dialog,
19
- PanelDropZone,
20
- PanelFormBooleanField,
21
- PanelForm,
22
- PanelDivider,
23
- Modal,
24
- ModalBody,
25
- ModalFooter,
26
- ModalHeader,
27
- PanelFormSection,
28
- ModalFooterButton,
29
- } from '@finos/legend-art';
30
- import {
31
- areMultiplicitiesEqual,
32
- Multiplicity,
33
- PrimitiveType,
34
- type VariableExpression,
35
- type ValueSpecification,
36
- } from '@finos/legend-graph';
37
- import { observer } from 'mobx-react-lite';
38
- import { useCallback, useState } from 'react';
39
- import { useDrop } from 'react-dnd';
40
- import type { QueryBuilderState } from '../../stores/QueryBuilderState.js';
41
- import type { QueryBuilderWatermarkState } from '../../stores/watermark/QueryBuilderWatermarkState.js';
42
- import {
43
- BasicValueSpecificationEditor,
44
- QUERY_BUILDER_VARIABLE_DND_TYPE,
45
- type QueryBuilderVariableDragSource,
46
- } from '../shared/BasicValueSpecificationEditor.js';
47
- import { VariableSelector } from '../shared/QueryBuilderVariableSelector.js';
48
- import { clone, deepClone } from '@finos/legend-shared';
49
-
50
- const isParamaterCompatibleWithWaterMark = (
51
- parameter: VariableExpression,
52
- ): boolean =>
53
- PrimitiveType.STRING === parameter.genericType?.value.rawType &&
54
- areMultiplicitiesEqual(parameter.multiplicity, Multiplicity.ONE);
55
-
56
- const WatermarkValueEditor = observer(
57
- (props: {
58
- selectedValue: ValueSpecification;
59
- setSelectedValue: (val: ValueSpecification) => void;
60
- handleResetValue: () => void;
61
- watermarkState: QueryBuilderWatermarkState;
62
- }) => {
63
- const {
64
- selectedValue,
65
- setSelectedValue,
66
- handleResetValue,
67
- watermarkState,
68
- } = props;
69
-
70
- const graph = watermarkState.queryBuilderState.graphManagerState.graph;
71
-
72
- const handleDrop = useCallback(
73
- (item: QueryBuilderVariableDragSource): void => {
74
- setSelectedValue(item.variable);
75
- },
76
- [setSelectedValue],
77
- );
78
-
79
- const [{ isParameterValueDragOver }, dropTargetConnector] = useDrop<
80
- QueryBuilderVariableDragSource,
81
- void,
82
- { isParameterValueDragOver: boolean }
83
- >(
84
- () => ({
85
- accept: [QUERY_BUILDER_VARIABLE_DND_TYPE],
86
- drop: (item, monitor): void => {
87
- if (
88
- !monitor.didDrop() &&
89
- // Only allows parameters with muliplicity 1 and type string
90
- isParamaterCompatibleWithWaterMark(item.variable)
91
- ) {
92
- handleDrop(item);
93
- } // prevent drop event propagation to accomondate for nested DnD
94
- },
95
- collect: (monitor) => ({
96
- isParameterValueDragOver: monitor.isOver({
97
- shallow: true,
98
- }),
99
- }),
100
- }),
101
- [handleDrop],
102
- );
103
-
104
- return (
105
- <PanelFormSection>
106
- <div className="query-builder__variable-editor">
107
- <PanelDropZone
108
- isDragOver={isParameterValueDragOver}
109
- dropTargetConnector={dropTargetConnector}
110
- >
111
- <BasicValueSpecificationEditor
112
- valueSpecification={selectedValue}
113
- setValueSpecification={(val: ValueSpecification): void => {
114
- setSelectedValue(clone(val));
115
- }}
116
- graph={graph}
117
- obseverContext={watermarkState.queryBuilderState.observerContext}
118
- typeCheckOption={{
119
- expectedType: PrimitiveType.STRING,
120
- }}
121
- resetValue={handleResetValue}
122
- isConstant={watermarkState.queryBuilderState.constantState.isValueSpecConstant(
123
- selectedValue,
124
- )}
125
- />
126
- </PanelDropZone>
127
- </div>
128
- </PanelFormSection>
129
- );
130
- },
131
- );
132
-
133
- export const QueryBuilderWatermarkEditor = observer(
134
- (props: { queryBuilderState: QueryBuilderState }) => {
135
- const { queryBuilderState } = props;
136
- const applicationStore = queryBuilderState.applicationStore;
137
- const watermarkState = queryBuilderState.watermarkState;
138
-
139
- const [selectedValue, setSelectedValue] = useState(
140
- deepClone(watermarkState.value),
141
- );
142
-
143
- const handleCancel = (): void => {
144
- watermarkState.setIsEditingWatermark(false);
145
- };
146
-
147
- const handleApply = (): void => {
148
- watermarkState.setValue(selectedValue);
149
- handleCancel();
150
- };
151
-
152
- const handleResetValue = (): void => {
153
- setSelectedValue(watermarkState.getDefaultValue());
154
- };
155
-
156
- const toggleWatermark = (): void => {
157
- if (selectedValue) {
158
- setSelectedValue(undefined);
159
- } else {
160
- handleResetValue();
161
- }
162
- };
163
-
164
- return (
165
- <Dialog
166
- open={Boolean(watermarkState.isEditingWatermark)}
167
- onClose={handleCancel}
168
- classes={{
169
- root: 'editor-modal__root-container',
170
- container: 'editor-modal__container',
171
- paper: 'editor-modal__content',
172
- }}
173
- >
174
- <Modal
175
- darkMode={
176
- !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
177
- }
178
- className="editor-modal query-builder__watermark__modal"
179
- >
180
- <ModalHeader title="Watermark" />
181
- <ModalBody>
182
- <PanelForm>
183
- <PanelFormBooleanField
184
- isReadOnly={false}
185
- value={selectedValue !== undefined}
186
- prompt="Enable watermark"
187
- update={toggleWatermark}
188
- />
189
- {selectedValue && (
190
- <>
191
- <WatermarkValueEditor
192
- selectedValue={selectedValue}
193
- setSelectedValue={setSelectedValue}
194
- handleResetValue={handleResetValue}
195
- watermarkState={watermarkState}
196
- />
197
- <PanelDivider />
198
- <VariableSelector
199
- filterBy={isParamaterCompatibleWithWaterMark}
200
- queryBuilderState={queryBuilderState}
201
- />
202
- </>
203
- )}
204
- </PanelForm>
205
- </ModalBody>
206
- <ModalFooter>
207
- <ModalFooterButton text="Apply" onClick={handleApply} />
208
- <ModalFooterButton
209
- text="Cancel"
210
- onClick={handleCancel}
211
- type="secondary"
212
- />
213
- </ModalFooter>
214
- </Modal>
215
- </Dialog>
216
- );
217
- },
218
- );