@finos/legend-query-builder 3.0.2 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
  2. package/lib/components/QueryBuilderResultPanel.js +6 -14
  3. package/lib/components/QueryBuilderResultPanel.js.map +1 -1
  4. package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.d.ts.map +1 -1
  5. package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.js +3 -1
  6. package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.js.map +1 -1
  7. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts.map +1 -1
  8. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.js +2 -1
  9. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.js.map +1 -1
  10. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.d.ts.map +1 -1
  11. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js +8 -2
  12. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js.map +1 -1
  13. package/lib/index.css +16 -0
  14. package/lib/package.json +1 -1
  15. package/lib/stores/QueryBuilderPropertyEditorState.js +6 -6
  16. package/lib/stores/QueryBuilderPropertyEditorState.js.map +1 -1
  17. package/lib/stores/QueryBuilderState.d.ts +1 -1
  18. package/lib/stores/QueryBuilderState.d.ts.map +1 -1
  19. package/lib/stores/QueryBuilderState.js +3 -3
  20. package/lib/stores/QueryBuilderState.js.map +1 -1
  21. package/lib/stores/QueryBuilderValueSpecificationBuilderHelper.d.ts.map +1 -1
  22. package/lib/stores/QueryBuilderValueSpecificationBuilderHelper.js +3 -3
  23. package/lib/stores/QueryBuilderValueSpecificationBuilderHelper.js.map +1 -1
  24. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts +2 -1
  25. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts.map +1 -1
  26. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.js +2 -1
  27. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.js.map +1 -1
  28. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts +9 -7
  29. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts.map +1 -1
  30. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js +15 -9
  31. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js.map +1 -1
  32. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.js +1 -1
  33. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.js.map +1 -1
  34. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts +2 -1
  35. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts.map +1 -1
  36. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js +9 -2
  37. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
  38. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js +2 -2
  39. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js.map +1 -1
  40. package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowState.d.ts +8 -1
  41. package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowState.d.ts.map +1 -1
  42. package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowState.js +36 -4
  43. package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowState.js.map +1 -1
  44. package/lib/stores/filter/QueryBuilderFilterState.js +2 -2
  45. package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
  46. package/lib/stores/workflows/ClassQueryBuilderState.js +3 -3
  47. package/lib/stores/workflows/ClassQueryBuilderState.js.map +1 -1
  48. package/lib/stores/workflows/MappingQueryBuilderState.js +3 -3
  49. package/lib/stores/workflows/MappingQueryBuilderState.js.map +1 -1
  50. package/lib/stores/workflows/ServiceQueryBuilderState.js +2 -2
  51. package/lib/stores/workflows/ServiceQueryBuilderState.js.map +1 -1
  52. package/package.json +9 -9
  53. package/src/components/QueryBuilderResultPanel.tsx +7 -15
  54. package/src/components/fetch-structure/QueryBuilderFetchStructurePanel.tsx +9 -3
  55. package/src/components/fetch-structure/QueryBuilderGraphFetchTreePanel.tsx +2 -4
  56. package/src/components/fetch-structure/QueryBuilderTDSWindowPanel.tsx +16 -4
  57. package/src/stores/QueryBuilderPropertyEditorState.ts +6 -6
  58. package/src/stores/QueryBuilderState.ts +3 -3
  59. package/src/stores/QueryBuilderValueSpecificationBuilderHelper.ts +3 -5
  60. package/src/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.ts +4 -2
  61. package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.ts +23 -15
  62. package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.ts +1 -1
  63. package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +11 -2
  64. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.ts +2 -2
  65. package/src/stores/fetch-structure/tds/window/QueryBuilderWindowState.ts +53 -4
  66. package/src/stores/filter/QueryBuilderFilterState.ts +2 -2
  67. package/src/stores/workflows/ClassQueryBuilderState.ts +3 -3
  68. package/src/stores/workflows/MappingQueryBuilderState.ts +3 -3
  69. package/src/stores/workflows/ServiceQueryBuilderState.ts +2 -2
@@ -38,6 +38,11 @@ export interface QueryBuilderWindowColumnDragSource {
38
38
  columnState: QueryBuilderTDSColumnState;
39
39
  }
40
40
 
41
+ interface QueryBuilderInvalidWindowColumnName {
42
+ invalidColumnName: string;
43
+ missingColumnName: string;
44
+ }
45
+
41
46
  export type QueryBuilderWindowDropTarget =
42
47
  | QueryBuilderProjectionColumnDragSource
43
48
  | QueryBuilderWindowColumnDragSource;
@@ -333,7 +338,8 @@ export class QueryBuilderWindowState implements Hashable {
333
338
  makeObservable(this, {
334
339
  windowColumns: observable,
335
340
  editColumn: observable,
336
- validationIssues: computed,
341
+ invalidWindowColumnNames: computed,
342
+ windowValidationIssues: computed,
337
343
  addWindowColumn: action,
338
344
  removeColumn: action,
339
345
  moveColumn: action,
@@ -347,16 +353,53 @@ export class QueryBuilderWindowState implements Hashable {
347
353
  return !this.windowColumns.length;
348
354
  }
349
355
 
350
- get validationIssues(): string[] | undefined {
356
+ get invalidWindowColumnNames(): QueryBuilderInvalidWindowColumnName[] {
357
+ const invalidColNames: QueryBuilderInvalidWindowColumnName[] = [];
358
+ const windowCols = this.windowColumns;
359
+ windowCols.forEach((item, index) => {
360
+ if (
361
+ item.operationState instanceof
362
+ QueryBuilderTDS_WindowAggreationOperatorState
363
+ ) {
364
+ if (
365
+ item.operationState.columnState instanceof
366
+ QueryBuilderWindowColumnState
367
+ ) {
368
+ const windowColumnName = item.operationState.columnState.columnName;
369
+ const hasExistingColumn = item.windowState.isColumnOrderValid(
370
+ windowColumnName,
371
+ index,
372
+ );
373
+ if (!hasExistingColumn) {
374
+ invalidColNames.push({
375
+ invalidColumnName: item.columnName,
376
+ missingColumnName: windowColumnName,
377
+ });
378
+ }
379
+ }
380
+ }
381
+ });
382
+ return invalidColNames;
383
+ }
384
+
385
+ get windowValidationIssues(): string[] {
386
+ const invalidWindowColumnNames = this.invalidWindowColumnNames;
387
+ const issues = [];
388
+ invalidWindowColumnNames.forEach((item) => {
389
+ issues.push(
390
+ `Column '${item.invalidColumnName}' cannot exist before column name '${item.missingColumnName}'`,
391
+ );
392
+ });
393
+
351
394
  const hasDuplicatedWindowColumns = this.windowColumns.some(
352
395
  (column) =>
353
396
  this.windowColumns.filter((c) => c.columnName === column.columnName)
354
397
  .length > 1,
355
398
  );
356
399
  if (hasDuplicatedWindowColumns) {
357
- return ['Query has duplicated window columns'];
400
+ issues.push(`Query has duplicated window columns`);
358
401
  }
359
- return undefined;
402
+ return issues;
360
403
  }
361
404
 
362
405
  get referencedTDSColumns(): QueryBuilderTDSColumnState[] {
@@ -388,6 +431,12 @@ export class QueryBuilderWindowState implements Hashable {
388
431
  }
389
432
  }
390
433
 
434
+ isColumnOrderValid(columnName: string, indexRange: number): boolean {
435
+ return this.windowColumns
436
+ .slice(0, indexRange)
437
+ .some((col) => col.columnName === columnName);
438
+ }
439
+
391
440
  get hashCode(): string {
392
441
  return hashArray([
393
442
  QUERY_BUILDER_STATE_HASH_STRUCTURE.TDS_WINDOW_GROUPBY_STATE,
@@ -19,7 +19,7 @@ import type { TreeNodeData, TreeData } from '@finos/legend-art';
19
19
  import {
20
20
  type GeneratorFn,
21
21
  assertTrue,
22
- getNullableFirstElement,
22
+ getNullableFirstEntry,
23
23
  guaranteeNonNullable,
24
24
  guaranteeType,
25
25
  IllegalStateError,
@@ -456,7 +456,7 @@ export class QueryBuilderFilterState
456
456
  this.rootIds.length < 2,
457
457
  'Query builder filter tree cannot have more than 1 root',
458
458
  );
459
- const rootId = getNullableFirstElement(this.rootIds);
459
+ const rootId = getNullableFirstEntry(this.rootIds);
460
460
  return rootId ? this.getNode(rootId) : undefined;
461
461
  }
462
462
 
@@ -22,7 +22,7 @@ import {
22
22
  RuntimePointer,
23
23
  PackageableElementExplicitReference,
24
24
  } from '@finos/legend-graph';
25
- import { getNullableFirstElement } from '@finos/legend-shared';
25
+ import { getNullableFirstEntry } from '@finos/legend-shared';
26
26
  import type React from 'react';
27
27
  import { renderClassQueryBuilderSetupPanelContent } from '../../components/workflows/ClassQueryBuilder.js';
28
28
  import { QueryBuilderState } from '../QueryBuilderState.js';
@@ -49,7 +49,7 @@ export class ClassQueryBuilderState extends QueryBuilderState {
49
49
  return;
50
50
  }
51
51
  // try to select the first compatible mapping
52
- const possibleNewMapping = getNullableFirstElement(compatibleMappings);
52
+ const possibleNewMapping = getNullableFirstEntry(compatibleMappings);
53
53
  if (possibleNewMapping) {
54
54
  this.changeMapping(possibleNewMapping);
55
55
  this.propagateMappingChange(possibleNewMapping);
@@ -68,7 +68,7 @@ export class ClassQueryBuilderState extends QueryBuilderState {
68
68
  mapping,
69
69
  this.graphManagerState.usableRuntimes,
70
70
  );
71
- const possibleNewRuntime = getNullableFirstElement(compatibleRuntimes);
71
+ const possibleNewRuntime = getNullableFirstEntry(compatibleRuntimes);
72
72
  if (possibleNewRuntime) {
73
73
  this.changeRuntime(
74
74
  new RuntimePointer(
@@ -24,7 +24,7 @@ import {
24
24
  PackageableElementExplicitReference,
25
25
  getMappingCompatibleClasses,
26
26
  } from '@finos/legend-graph';
27
- import { getNullableFirstElement } from '@finos/legend-shared';
27
+ import { getNullableFirstEntry } from '@finos/legend-shared';
28
28
  import { renderMappingQueryBuilderSetupPanelContent } from '../../components/workflows/MappingQueryBuilder.js';
29
29
  import { QueryBuilderState } from '../QueryBuilderState.js';
30
30
 
@@ -61,7 +61,7 @@ export class MappingQueryBuilderState extends QueryBuilderState {
61
61
  mapping,
62
62
  this.graphManagerState.usableRuntimes,
63
63
  );
64
- const possibleNewRuntime = getNullableFirstElement(compatibleRuntimes);
64
+ const possibleNewRuntime = getNullableFirstEntry(compatibleRuntimes);
65
65
  if (possibleNewRuntime) {
66
66
  this.changeRuntime(
67
67
  new RuntimePointer(
@@ -77,7 +77,7 @@ export class MappingQueryBuilderState extends QueryBuilderState {
77
77
  // if there is no chosen class or the chosen one is not compatible
78
78
  // with the mapping then pick a compatible class if possible
79
79
  if (!this.class || !compatibleClasses.includes(this.class)) {
80
- const possibleNewClass = getNullableFirstElement(compatibleClasses);
80
+ const possibleNewClass = getNullableFirstEntry(compatibleClasses);
81
81
  if (possibleNewClass) {
82
82
  this.changeClass(possibleNewClass);
83
83
  }
@@ -26,7 +26,7 @@ import {
26
26
  } from '@finos/legend-graph';
27
27
  import {
28
28
  assertTrue,
29
- getNullableFirstElement,
29
+ getNullableFirstEntry,
30
30
  guaranteeNonNullable,
31
31
  IllegalStateError,
32
32
  } from '@finos/legend-shared';
@@ -159,7 +159,7 @@ export class ServiceQueryBuilderState extends QueryBuilderState {
159
159
  // if there is no chosen class or the chosen one is not compatible
160
160
  // with the mapping then pick a compatible class if possible
161
161
  if (!this.class || !compatibleClasses.includes(this.class)) {
162
- const possibleNewClass = getNullableFirstElement(compatibleClasses);
162
+ const possibleNewClass = getNullableFirstEntry(compatibleClasses);
163
163
  if (possibleNewClass) {
164
164
  this.changeClass(possibleNewClass);
165
165
  }