@finos/legend-query-builder 4.14.40 → 4.14.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. package/lib/components/QueryBuilderParametersPanel.d.ts.map +1 -1
  2. package/lib/components/QueryBuilderParametersPanel.js +20 -2
  3. package/lib/components/QueryBuilderParametersPanel.js.map +1 -1
  4. package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
  5. package/lib/components/QueryBuilderSideBar.js +5 -14
  6. package/lib/components/QueryBuilderSideBar.js.map +1 -1
  7. package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
  8. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +12 -4
  9. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
  10. package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
  11. package/lib/components/filter/QueryBuilderFilterPanel.js +6 -2
  12. package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
  13. package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
  14. package/lib/components/result/QueryBuilderResultPanel.js +2 -1
  15. package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
  16. package/lib/components/shared/BasicValueSpecificationEditor.d.ts +11 -9
  17. package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -1
  18. package/lib/components/shared/BasicValueSpecificationEditor.js +158 -143
  19. package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
  20. package/lib/components/shared/QueryBuilderVariableSelector.d.ts.map +1 -1
  21. package/lib/components/shared/QueryBuilderVariableSelector.js +8 -1
  22. package/lib/components/shared/QueryBuilderVariableSelector.js.map +1 -1
  23. package/lib/index.css +2 -2
  24. package/lib/index.css.map +1 -1
  25. package/lib/package.json +1 -1
  26. package/lib/stores/QueryBuilderPropertyEditorState.d.ts +1 -0
  27. package/lib/stores/QueryBuilderPropertyEditorState.d.ts.map +1 -1
  28. package/lib/stores/QueryBuilderPropertyEditorState.js +2 -1
  29. package/lib/stores/QueryBuilderPropertyEditorState.js.map +1 -1
  30. package/lib/stores/QueryBuilderState.d.ts.map +1 -1
  31. package/lib/stores/QueryBuilderState.js +12 -0
  32. package/lib/stores/QueryBuilderState.js.map +1 -1
  33. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.js +2 -2
  34. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.js.map +1 -1
  35. package/lib/stores/filter/QueryBuilderFilterState.d.ts +1 -1
  36. package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
  37. package/lib/stores/filter/QueryBuilderFilterState.js +4 -3
  38. package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
  39. package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.js +2 -2
  40. package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.js.map +1 -1
  41. package/lib/stores/milestoning/QueryBuilderMilestoningHelper.d.ts +1 -0
  42. package/lib/stores/milestoning/QueryBuilderMilestoningHelper.d.ts.map +1 -1
  43. package/lib/stores/milestoning/QueryBuilderMilestoningHelper.js +16 -0
  44. package/lib/stores/milestoning/QueryBuilderMilestoningHelper.js.map +1 -1
  45. package/lib/stores/milestoning/QueryBuilderMilestoningState.d.ts +3 -0
  46. package/lib/stores/milestoning/QueryBuilderMilestoningState.d.ts.map +1 -1
  47. package/lib/stores/milestoning/QueryBuilderMilestoningState.js +40 -0
  48. package/lib/stores/milestoning/QueryBuilderMilestoningState.js.map +1 -1
  49. package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts +1 -0
  50. package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts.map +1 -1
  51. package/lib/stores/shared/ValueSpecificationEditorHelper.js +48 -0
  52. package/lib/stores/shared/ValueSpecificationEditorHelper.js.map +1 -1
  53. package/package.json +8 -8
  54. package/src/components/QueryBuilderParametersPanel.tsx +55 -0
  55. package/src/components/QueryBuilderSideBar.tsx +0 -35
  56. package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +22 -6
  57. package/src/components/filter/QueryBuilderFilterPanel.tsx +13 -5
  58. package/src/components/result/QueryBuilderResultPanel.tsx +9 -1
  59. package/src/components/shared/BasicValueSpecificationEditor.tsx +288 -285
  60. package/src/components/shared/QueryBuilderVariableSelector.tsx +22 -0
  61. package/src/stores/QueryBuilderPropertyEditorState.ts +2 -1
  62. package/src/stores/QueryBuilderState.ts +14 -0
  63. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.ts +2 -2
  64. package/src/stores/filter/QueryBuilderFilterState.ts +6 -3
  65. package/src/stores/filter/operators/QueryBuilderFilterOperator_In.ts +2 -2
  66. package/src/stores/milestoning/QueryBuilderMilestoningHelper.ts +24 -0
  67. package/src/stores/milestoning/QueryBuilderMilestoningState.ts +54 -0
  68. package/src/stores/shared/ValueSpecificationEditorHelper.ts +63 -0
@@ -149,6 +149,18 @@ export const VariableViewer = observer(
149
149
  const variableTypeName =
150
150
  variable.genericType?.value.rawType.name ??
151
151
  (isConstant ? CALCULATED : undefined);
152
+ const isMilestoningParameter =
153
+ queryBuilderState.milestoningState.isMilestoningParameter(variable);
154
+ const milestoningParameterValue =
155
+ queryBuilderState.milestoningState.getMilestoningParameterValue(variable);
156
+ const milestoningParameterValueString = isMilestoningParameter
157
+ ? milestoningParameterValue
158
+ ? getNameOfValueSpecification(
159
+ milestoningParameterValue,
160
+ queryBuilderState,
161
+ )
162
+ : undefined
163
+ : undefined;
152
164
  const deleteDisabled = isReadOnly || isVariableUsed;
153
165
  const deleteTitle = isVariableUsed ? 'Used in query' : 'Remove';
154
166
  const editVariable = (): void => {
@@ -227,6 +239,16 @@ export const VariableViewer = observer(
227
239
  <div className="query-builder__variables__variable__type__label">
228
240
  {variableTypeName ?? 'unknown'}
229
241
  </div>
242
+ {isMilestoningParameter && (
243
+ <>
244
+ <div className="query-builder__variables__variable__type__label query-builder__variables__variable__type__label--milestoning">
245
+ milestoning
246
+ </div>
247
+ <div className="query-builder__constants__value">
248
+ {milestoningParameterValueString}
249
+ </div>
250
+ </>
251
+ )}
230
252
  </div>
231
253
  )}
232
254
  </div>
@@ -161,7 +161,8 @@ export const generateValueSpecificationForParameter = (
161
161
  return createNullishValue(graph);
162
162
  };
163
163
 
164
- const fillDerivedPropertyParameterValues = (
164
+ //here
165
+ export const fillDerivedPropertyParameterValues = (
165
166
  derivedPropertyExpressionState: QueryBuilderDerivedPropertyExpressionState,
166
167
  ): void => {
167
168
  const parameterValues: ValueSpecification[] =
@@ -110,6 +110,8 @@ import type { QueryBuilderConfig } from '../graph-manager/QueryBuilderConfig.js'
110
110
  import { QUERY_BUILDER_EVENT } from '../__lib__/QueryBuilderEvent.js';
111
111
  import { QueryBuilderChangeHistoryState } from './QueryBuilderChangeHistoryState.js';
112
112
  import { type QueryBuilderWorkflowState } from './query-workflow/QueryBuilderWorkFlowState.js';
113
+ import { initializeMilestoningStateFromDerivedProperty } from './milestoning/QueryBuilderMilestoningHelper.js';
114
+ import { QueryBuilderSimpleProjectionColumnState } from './fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js';
113
115
 
114
116
  export interface QuerySDLC {}
115
117
 
@@ -697,6 +699,18 @@ export abstract class QueryBuilderState implements CommandRegistrar {
697
699
  );
698
700
  }
699
701
  if (this.parametersState.parameterStates.length > 0) {
702
+ const fetchStructureStateImp = this.fetchStructureState.implementation;
703
+ if (fetchStructureStateImp instanceof QueryBuilderTDSState) {
704
+ fetchStructureStateImp.projectionColumns.forEach((colState) => {
705
+ if (colState instanceof QueryBuilderSimpleProjectionColumnState) {
706
+ colState.propertyExpressionState.derivedPropertyExpressionStates.forEach(
707
+ (state) => {
708
+ initializeMilestoningStateFromDerivedProperty(state);
709
+ },
710
+ );
711
+ }
712
+ });
713
+ }
700
714
  this.setShowParametersPanel(true);
701
715
  }
702
716
  this.fetchStructureState.initializeWithQuery();
@@ -53,7 +53,7 @@ export class QueryBuilderPostFilterOperator_In
53
53
  implements Hashable
54
54
  {
55
55
  getLabel(): string {
56
- return 'is in';
56
+ return 'is in list of';
57
57
  }
58
58
 
59
59
  isCompatibleWithType(type: Type): boolean {
@@ -168,7 +168,7 @@ export class QueryBuilderPostFilterOperator_In
168
168
 
169
169
  export class QueryBuilderPostFilterOperator_NotIn extends QueryBuilderPostFilterOperator_In {
170
170
  override getLabel(): string {
171
- return `is not in`;
171
+ return `is not in list of`;
172
172
  }
173
173
 
174
174
  override buildPostFilterConditionExpression(
@@ -128,17 +128,20 @@ export class FilterConditionState implements Hashable {
128
128
  );
129
129
  }
130
130
 
131
- *handleTypeaheadSearch(): GeneratorFn<void> {
131
+ *handleTypeaheadSearch(
132
+ searchValue?: ValueSpecification | undefined,
133
+ ): GeneratorFn<void> {
134
+ const value = searchValue ?? this.value;
132
135
  try {
133
136
  this.typeaheadSearchState.inProgress();
134
137
  this.typeaheadSearchResults = undefined;
135
- if (performTypeahead(this.value)) {
138
+ if (performTypeahead(value)) {
136
139
  const result =
137
140
  (yield this.filterState.queryBuilderState.graphManagerState.graphManager.runQuery(
138
141
  buildPropertyTypeaheadQuery(
139
142
  this.filterState.queryBuilderState,
140
143
  this.propertyExpressionState.propertyExpression,
141
- this.value,
144
+ value,
142
145
  ),
143
146
  guaranteeNonNullable(
144
147
  this.filterState.queryBuilderState.executionContextState.mapping,
@@ -48,7 +48,7 @@ export class QueryBuilderFilterOperator_In
48
48
  implements Hashable
49
49
  {
50
50
  getLabel(filterConditionState: FilterConditionState): string {
51
- return 'is in';
51
+ return 'is in list of';
52
52
  }
53
53
 
54
54
  isCompatibleWithFilterConditionProperty(
@@ -172,7 +172,7 @@ export class QueryBuilderFilterOperator_In
172
172
 
173
173
  export class QueryBuilderFilterOperator_NotIn extends QueryBuilderFilterOperator_In {
174
174
  override getLabel(filterConditionState: FilterConditionState): string {
175
- return `is not in`;
175
+ return `is not in list of`;
176
176
  }
177
177
 
178
178
  override buildFilterConditionExpression(
@@ -290,6 +290,30 @@ export const generateMilestonedPropertyParameterValue = (
290
290
  );
291
291
  };
292
292
 
293
+ export const initializeMilestoningStateFromDerivedProperty = (
294
+ derivedPropertyExpressionState: QueryBuilderDerivedPropertyExpressionState,
295
+ ): void => {
296
+ const milestoningState =
297
+ derivedPropertyExpressionState.queryBuilderState.milestoningState;
298
+ const temporalTarget =
299
+ derivedPropertyExpressionState.propertyExpression.func.value.genericType
300
+ .value.rawType instanceof Class &&
301
+ derivedPropertyExpressionState.propertyExpression.func.value._OWNER
302
+ ._generatedMilestonedProperties.length !== 0
303
+ ? getMilestoneTemporalStereotype(
304
+ derivedPropertyExpressionState.propertyExpression.func.value
305
+ .genericType.value.rawType,
306
+ derivedPropertyExpressionState.queryBuilderState.graphManagerState
307
+ .graph,
308
+ )
309
+ : undefined;
310
+ if (temporalTarget) {
311
+ milestoningState
312
+ .getMilestoningImplementation(temporalTarget)
313
+ .initializeMilestoningParameters();
314
+ }
315
+ };
316
+
293
317
  export const validateMilestoningPropertyExpressionChain = (
294
318
  sourceStereotype: MILESTONING_STEREOTYPE | undefined,
295
319
  targetStereotype: MILESTONING_STEREOTYPE,
@@ -451,6 +451,33 @@ export class QueryBuilderMilestoningState implements Hashable {
451
451
  return milestoningParameter;
452
452
  }
453
453
 
454
+ updateMilestoningParameterValue(
455
+ parameter: VariableExpression,
456
+ value: ValueSpecification | undefined,
457
+ ): void {
458
+ const variableState =
459
+ this.queryBuilderState.parametersState.parameterStates.find(
460
+ (param) => param.parameter.name === parameter.name,
461
+ );
462
+ if (variableState) {
463
+ variableState.setValue(value);
464
+ }
465
+ }
466
+
467
+ getMilestoningParameterValue(
468
+ milestoningParameter: ValueSpecification,
469
+ ): ValueSpecification | undefined {
470
+ let value: ValueSpecification | undefined = milestoningParameter;
471
+ if (milestoningParameter instanceof VariableExpression) {
472
+ const paramState =
473
+ this.queryBuilderState.parametersState.parameterStates.find(
474
+ (param) => param.parameter.name === milestoningParameter.name,
475
+ );
476
+ value = paramState?.value;
477
+ }
478
+ return value;
479
+ }
480
+
454
481
  isVariableUsed(variable: VariableExpression): boolean {
455
482
  const usedInBusiness = this.businessDate
456
483
  ? isValueExpressionReferencedInValue(variable, this.businessDate)
@@ -461,6 +488,33 @@ export class QueryBuilderMilestoningState implements Hashable {
461
488
  return usedInBusiness || usedInProcessingDate;
462
489
  }
463
490
 
491
+ isMilestoningParameter(parameter: VariableExpression): boolean {
492
+ let isMilestoningParameter = false;
493
+ if (this.businessDate instanceof VariableExpression) {
494
+ isMilestoningParameter =
495
+ parameter.name ===
496
+ guaranteeType(this.businessDate, VariableExpression).name;
497
+ }
498
+ if (this.processingDate instanceof VariableExpression) {
499
+ isMilestoningParameter =
500
+ isMilestoningParameter ||
501
+ parameter.name ===
502
+ guaranteeType(this.processingDate, VariableExpression).name;
503
+ }
504
+ if (this.startDate instanceof VariableExpression) {
505
+ isMilestoningParameter =
506
+ isMilestoningParameter ||
507
+ parameter.name ===
508
+ guaranteeType(this.startDate, VariableExpression).name;
509
+ }
510
+ if (this.endDate instanceof VariableExpression) {
511
+ isMilestoningParameter =
512
+ isMilestoningParameter ||
513
+ parameter.name === guaranteeType(this.endDate, VariableExpression).name;
514
+ }
515
+ return isMilestoningParameter;
516
+ }
517
+
464
518
  get hashCode(): string {
465
519
  return hashArray([
466
520
  QUERY_BUILDER_STATE_HASH_STRUCTURE.MILESTONING_STATE,
@@ -321,3 +321,66 @@ export const valueSpecReturnTDS = (
321
321
  retunType && tdsType && (retunType === tdsType || retunType === tdsRowType),
322
322
  );
323
323
  };
324
+
325
+ export const convertTextToPrimitiveInstanceValue = (
326
+ expectedType: Type,
327
+ value: string,
328
+ obseverContext: ObserverContext,
329
+ ): PrimitiveInstanceValue | null => {
330
+ let result = null;
331
+ if (expectedType instanceof PrimitiveType) {
332
+ switch (expectedType.path) {
333
+ case PRIMITIVE_TYPE.STRING: {
334
+ result = new PrimitiveInstanceValue(
335
+ GenericTypeExplicitReference.create(new GenericType(expectedType)),
336
+ );
337
+ instanceValue_setValues(result, [value.toString()], obseverContext);
338
+ break;
339
+ }
340
+ case PRIMITIVE_TYPE.NUMBER:
341
+ case PRIMITIVE_TYPE.FLOAT:
342
+ case PRIMITIVE_TYPE.DECIMAL:
343
+ case PRIMITIVE_TYPE.INTEGER: {
344
+ if (isNaN(Number(value))) {
345
+ return null;
346
+ }
347
+ result = new PrimitiveInstanceValue(
348
+ GenericTypeExplicitReference.create(new GenericType(expectedType)),
349
+ );
350
+ instanceValue_setValues(result, [Number(value)], obseverContext);
351
+ break;
352
+ }
353
+ case PRIMITIVE_TYPE.DATE:
354
+ case PRIMITIVE_TYPE.STRICTDATE: {
355
+ if (isNaN(Date.parse(value))) {
356
+ return null;
357
+ }
358
+ result = new PrimitiveInstanceValue(
359
+ GenericTypeExplicitReference.create(new GenericType(expectedType)),
360
+ );
361
+ instanceValue_setValues(result, [value], obseverContext);
362
+ break;
363
+ }
364
+ case PRIMITIVE_TYPE.DATETIME: {
365
+ if (
366
+ isNaN(Date.parse(value)) ||
367
+ !new Date(value).getTime() ||
368
+ (value.includes('%') &&
369
+ (isNaN(Date.parse(value.slice(1))) ||
370
+ !new Date(value.slice(1)).getTime()))
371
+ ) {
372
+ return null;
373
+ }
374
+ result = new PrimitiveInstanceValue(
375
+ GenericTypeExplicitReference.create(new GenericType(expectedType)),
376
+ );
377
+ instanceValue_setValues(result, [value], obseverContext);
378
+ break;
379
+ }
380
+ default:
381
+ // unsupported expected type, just escape
382
+ return null;
383
+ }
384
+ }
385
+ return result;
386
+ };