@finos/legend-query-builder 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderResultPanel.js +6 -14
- package/lib/components/QueryBuilderResultPanel.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.js +3 -1
- package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.js +2 -1
- package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js +8 -2
- package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/QueryBuilderState.d.ts +1 -1
- package/lib/stores/QueryBuilderState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderState.js +3 -3
- package/lib/stores/QueryBuilderState.js.map +1 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts +2 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.js +2 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.js.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts +9 -7
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js +15 -9
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.js +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts +2 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js +9 -2
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowState.d.ts +8 -1
- package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowState.js +36 -4
- package/lib/stores/fetch-structure/tds/window/QueryBuilderWindowState.js.map +1 -1
- package/package.json +5 -5
- package/src/components/QueryBuilderResultPanel.tsx +7 -15
- package/src/components/fetch-structure/QueryBuilderFetchStructurePanel.tsx +9 -3
- package/src/components/fetch-structure/QueryBuilderGraphFetchTreePanel.tsx +2 -4
- package/src/components/fetch-structure/QueryBuilderTDSWindowPanel.tsx +16 -4
- package/src/stores/QueryBuilderState.ts +3 -3
- package/src/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.ts +4 -2
- package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.ts +23 -15
- package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.ts +1 -1
- package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +11 -2
- package/src/stores/fetch-structure/tds/window/QueryBuilderWindowState.ts +53 -4
@@ -693,6 +693,12 @@ const QueryBuilderWindowColumnEditor = observer(
|
|
693
693
|
const isDuplicatedColumnName =
|
694
694
|
tdsState.isDuplicateColumn(windowColumnState);
|
695
695
|
|
696
|
+
const isInvalidColumnName = windowState.invalidWindowColumnNames.some(
|
697
|
+
(col) =>
|
698
|
+
col.invalidColumnName === windowColumnState.columnName ||
|
699
|
+
col.missingColumnName === windowColumnState.columnName,
|
700
|
+
);
|
701
|
+
|
696
702
|
// window columns
|
697
703
|
const windowOptions = windowColumnState.possibleReferencedColumns;
|
698
704
|
const addWindowOptions = windowOptions.filter(
|
@@ -1082,7 +1088,11 @@ const QueryBuilderWindowColumnEditor = observer(
|
|
1082
1088
|
value={windowColumnState.columnName}
|
1083
1089
|
onChange={changeColumnName}
|
1084
1090
|
validationErrorMessage={
|
1085
|
-
isDuplicatedColumnName
|
1091
|
+
isDuplicatedColumnName
|
1092
|
+
? 'Duplicated column'
|
1093
|
+
: isInvalidColumnName
|
1094
|
+
? 'Invalid column order'
|
1095
|
+
: undefined
|
1086
1096
|
}
|
1087
1097
|
/>
|
1088
1098
|
</div>
|
@@ -1175,9 +1185,11 @@ export const QueryBuilderTDSWindowPanel = observer(
|
|
1175
1185
|
<div className="panel__header">
|
1176
1186
|
<div className="panel__header__title">
|
1177
1187
|
<div className="panel__header__title__label">Window Function</div>
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1188
|
+
{tdsWindowState.windowValidationIssues.length && (
|
1189
|
+
<QueryBuilderPanelIssueCountBadge
|
1190
|
+
issues={tdsWindowState.windowValidationIssues}
|
1191
|
+
/>
|
1192
|
+
)}
|
1181
1193
|
</div>
|
1182
1194
|
<div className="panel__header__actions">
|
1183
1195
|
<button
|
@@ -145,7 +145,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
145
145
|
|
146
146
|
sideBarClassName: computed,
|
147
147
|
isQuerySupported: computed,
|
148
|
-
|
148
|
+
allValidationIssues: computed,
|
149
149
|
|
150
150
|
setShowFunctionsExplorerPanel: action,
|
151
151
|
setShowParametersPanel: action,
|
@@ -554,8 +554,8 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
554
554
|
}
|
555
555
|
}
|
556
556
|
|
557
|
-
get
|
558
|
-
return this.fetchStructureState.implementation.
|
557
|
+
get allValidationIssues(): string[] {
|
558
|
+
return this.fetchStructureState.implementation.allValidationIssues;
|
559
559
|
}
|
560
560
|
|
561
561
|
/**
|
@@ -45,7 +45,8 @@ export abstract class QueryBuilderFetchStructureImplementationState
|
|
45
45
|
) {
|
46
46
|
makeObservable(this, {
|
47
47
|
usedExplorerTreePropertyNodeIDs: computed,
|
48
|
-
|
48
|
+
fetchStructureValidationIssues: computed,
|
49
|
+
allValidationIssues: computed,
|
49
50
|
hashCode: computed,
|
50
51
|
});
|
51
52
|
|
@@ -55,7 +56,8 @@ export abstract class QueryBuilderFetchStructureImplementationState
|
|
55
56
|
|
56
57
|
abstract get type(): string;
|
57
58
|
abstract get usedExplorerTreePropertyNodeIDs(): string[];
|
58
|
-
abstract get
|
59
|
+
abstract get fetchStructureValidationIssues(): string[];
|
60
|
+
abstract get allValidationIssues(): string[];
|
59
61
|
|
60
62
|
abstract onClassChange(_class: Class | undefined): void;
|
61
63
|
abstract revealCompilationError(compilationError: CompilationError): boolean;
|
@@ -72,22 +72,15 @@ const DEFAULT_PURE_CONFIG_TYPE_NAME = '@type';
|
|
72
72
|
|
73
73
|
export class PureSerializationConfig {
|
74
74
|
typeKeyName: string;
|
75
|
-
includeType: boolean;
|
76
|
-
includeEnumType: boolean;
|
77
|
-
removePropertiesWithNullValues: boolean;
|
78
|
-
removePropertiesWithEmptySets: boolean;
|
79
|
-
fullyQualifiedTypePath: boolean;
|
80
|
-
includeObjectReference: boolean;
|
75
|
+
includeType: boolean | undefined;
|
76
|
+
includeEnumType: boolean | undefined;
|
77
|
+
removePropertiesWithNullValues: boolean | undefined;
|
78
|
+
removePropertiesWithEmptySets: boolean | undefined;
|
79
|
+
fullyQualifiedTypePath: boolean | undefined;
|
80
|
+
includeObjectReference: boolean | undefined;
|
81
81
|
|
82
82
|
constructor() {
|
83
|
-
// default values
|
84
83
|
this.typeKeyName = DEFAULT_PURE_CONFIG_TYPE_NAME;
|
85
|
-
this.includeType = true;
|
86
|
-
this.includeEnumType = true;
|
87
|
-
this.removePropertiesWithNullValues = true;
|
88
|
-
this.removePropertiesWithEmptySets = false;
|
89
|
-
this.fullyQualifiedTypePath = true;
|
90
|
-
this.includeObjectReference = false;
|
91
84
|
makeObservable(this, {
|
92
85
|
typeKeyName: observable,
|
93
86
|
includeType: observable,
|
@@ -106,6 +99,17 @@ export class PureSerializationConfig {
|
|
106
99
|
});
|
107
100
|
}
|
108
101
|
|
102
|
+
static createDefault(): PureSerializationConfig {
|
103
|
+
const config = new PureSerializationConfig();
|
104
|
+
config.typeKeyName = DEFAULT_PURE_CONFIG_TYPE_NAME;
|
105
|
+
config.includeType = true;
|
106
|
+
config.includeEnumType = true;
|
107
|
+
config.removePropertiesWithNullValues = true;
|
108
|
+
config.removePropertiesWithEmptySets = false;
|
109
|
+
config.fullyQualifiedTypePath = true;
|
110
|
+
return config;
|
111
|
+
}
|
112
|
+
|
109
113
|
setTypeName(val: string): void {
|
110
114
|
this.typeKeyName = val;
|
111
115
|
}
|
@@ -343,8 +347,12 @@ export class QueryBuilderGraphFetchTreeState
|
|
343
347
|
return Array.from(new Set(ids).values());
|
344
348
|
}
|
345
349
|
|
346
|
-
get
|
347
|
-
return
|
350
|
+
get fetchStructureValidationIssues(): string[] {
|
351
|
+
return [];
|
352
|
+
}
|
353
|
+
|
354
|
+
get allValidationIssues(): string[] {
|
355
|
+
return [];
|
348
356
|
}
|
349
357
|
|
350
358
|
override initialize(): void {
|
@@ -122,7 +122,7 @@ export const buildPureSerializationConfig = (
|
|
122
122
|
const property = Object.getOwnPropertyNames(config).find(
|
123
123
|
(p) => p === classProperty.name,
|
124
124
|
);
|
125
|
-
if (property) {
|
125
|
+
if (property && config[property] !== undefined) {
|
126
126
|
const keyExpressionInstance = new KeyExpressionInstanceValue();
|
127
127
|
// key expression
|
128
128
|
const keyInstance = new PrimitiveInstanceValue(
|
@@ -267,7 +267,7 @@ export class QueryBuilderTDSState
|
|
267
267
|
return Array.from(new Set(nodeIDs).values());
|
268
268
|
}
|
269
269
|
|
270
|
-
get
|
270
|
+
get fetchStructureValidationIssues(): string[] {
|
271
271
|
const hasDuplicatedProjectionColumns = this.projectionColumns.some(
|
272
272
|
(column) =>
|
273
273
|
this.projectionColumns.filter((c) => c.columnName === column.columnName)
|
@@ -280,7 +280,16 @@ export class QueryBuilderTDSState
|
|
280
280
|
if (hasNoProjectionColumns) {
|
281
281
|
return ['Query has no projection columns'];
|
282
282
|
}
|
283
|
-
return
|
283
|
+
return [];
|
284
|
+
}
|
285
|
+
|
286
|
+
get allValidationIssues(): string[] {
|
287
|
+
const fetchStructureValidationIssues = [
|
288
|
+
...this.fetchStructureValidationIssues,
|
289
|
+
...this.windowState.windowValidationIssues,
|
290
|
+
];
|
291
|
+
|
292
|
+
return fetchStructureValidationIssues;
|
284
293
|
}
|
285
294
|
|
286
295
|
get tdsColumns(): QueryBuilderTDSColumnState[] {
|
@@ -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
|
-
|
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
|
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
|
-
|
400
|
+
issues.push(`Query has duplicated window columns`);
|
358
401
|
}
|
359
|
-
return
|
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,
|