@finos/legend-query-builder 2.0.1 → 2.1.1

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.
Files changed (38) hide show
  1. package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
  2. package/lib/components/QueryBuilderResultPanel.js +6 -7
  3. package/lib/components/QueryBuilderResultPanel.js.map +1 -1
  4. package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
  5. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +19 -17
  6. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
  7. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.d.ts.map +1 -1
  8. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js +31 -29
  9. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js.map +1 -1
  10. package/lib/index.css +2 -2
  11. package/lib/index.css.map +1 -1
  12. package/lib/package.json +2 -2
  13. package/lib/stores/QueryBuilderResultState.d.ts +7 -3
  14. package/lib/stores/QueryBuilderResultState.d.ts.map +1 -1
  15. package/lib/stores/QueryBuilderResultState.js +14 -20
  16. package/lib/stores/QueryBuilderResultState.js.map +1 -1
  17. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts +3 -0
  18. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts.map +1 -1
  19. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.js.map +1 -1
  20. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts +10 -1
  21. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts.map +1 -1
  22. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js +36 -1
  23. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js.map +1 -1
  24. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts +6 -0
  25. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts.map +1 -1
  26. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js +21 -2
  27. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
  28. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.js +4 -4
  29. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.js.map +1 -1
  30. package/package.json +9 -9
  31. package/src/components/QueryBuilderResultPanel.tsx +18 -20
  32. package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +128 -126
  33. package/src/components/fetch-structure/QueryBuilderTDSWindowPanel.tsx +254 -251
  34. package/src/stores/QueryBuilderResultState.ts +28 -33
  35. package/src/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.ts +5 -0
  36. package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.ts +44 -0
  37. package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +28 -0
  38. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.ts +4 -4
@@ -26,6 +26,7 @@ import type { QueryBuilderExplorerTreePropertyNodeData } from '../explorer/Query
26
26
  import type { QueryBuilderState } from '../QueryBuilderState.js';
27
27
  import type { LambdaFunctionBuilderOption } from '../QueryBuilderValueSpecificationBuilderHelper.js';
28
28
  import type { QueryBuilderFetchStructureState } from './QueryBuilderFetchStructureState.js';
29
+ import type { ExportDataInfo } from '../QueryBuilderResultState.js';
29
30
 
30
31
  export enum FETCH_STRUCTURE_IMPLEMENTATION {
31
32
  TABULAR_DATA_STRUCTURE = 'TABULAR_DATA_STRUCTURE',
@@ -75,4 +76,8 @@ export abstract class QueryBuilderFetchStructureImplementationState
75
76
  get TEMPORARY__showPostFetchStructurePanel(): boolean {
76
77
  return this.queryBuilderState.filterState.showPanel;
77
78
  }
79
+
80
+ // export options
81
+ abstract get exportDataFormatOptions(): string[];
82
+ abstract getExportDataInfo(format: string): ExportDataInfo;
78
83
  }
@@ -51,15 +51,22 @@ import {
51
51
  guaranteeNonNullable,
52
52
  hashArray,
53
53
  type Hashable,
54
+ UnsupportedOperationError,
55
+ ContentType,
54
56
  } from '@finos/legend-shared';
55
57
  import { QUERY_BUILDER_HASH_STRUCTURE } from '../../../graphManager/QueryBuilderHashUtils.js';
56
58
  import { isValueExpressionReferencedInValue } from '../../QueryBuilderValueSpecificationHelper.js';
59
+ import type { ExportDataInfo } from '../../QueryBuilderResultState.js';
57
60
 
58
61
  export enum SERIALIZATION_TYPE {
59
62
  PURE = 'PURE',
60
63
  EXTERNAL_FORMAT = 'EXTERNAL_FORMAT',
61
64
  }
62
65
 
66
+ export enum GRAPH_FETCH_EXPORT_DATA_FORMAT {
67
+ RESULT = 'RESULT',
68
+ }
69
+
63
70
  const DEFAULT_PURE_CONFIG_TYPE_NAME = '@type';
64
71
 
65
72
  export class PureSerializationConfig {
@@ -135,6 +142,8 @@ export abstract class GraphFetchSerializationState {
135
142
  }
136
143
 
137
144
  abstract getLabel(): string;
145
+
146
+ abstract get serializationContentType(): ContentType;
138
147
  }
139
148
 
140
149
  export class GraphFetchPureSerializationState extends GraphFetchSerializationState {
@@ -161,6 +170,10 @@ export class GraphFetchPureSerializationState extends GraphFetchSerializationSta
161
170
  override getLabel(): string {
162
171
  return SERIALIZATION_TYPE.PURE;
163
172
  }
173
+
174
+ override get serializationContentType(): ContentType {
175
+ return ContentType.APPLICATION_JSON;
176
+ }
164
177
  }
165
178
 
166
179
  export class GraphFetchExternalFormatSerializationState extends GraphFetchSerializationState {
@@ -176,6 +189,7 @@ export class GraphFetchExternalFormatSerializationState extends GraphFetchSerial
176
189
  makeObservable(this, {
177
190
  targetBinding: observable,
178
191
  treeData: observable.ref,
192
+ serializationContentType: computed,
179
193
  });
180
194
  this.targetBinding = targetBinding;
181
195
  this.treeData = treeData;
@@ -192,6 +206,20 @@ export class GraphFetchExternalFormatSerializationState extends GraphFetchSerial
192
206
  override getLabel(): string {
193
207
  return SERIALIZATION_TYPE.EXTERNAL_FORMAT;
194
208
  }
209
+
210
+ override get serializationContentType(): ContentType {
211
+ const contentType = this.targetBinding.contentType;
212
+ if (Object.values(ContentType).includes(contentType as ContentType)) {
213
+ return contentType as ContentType;
214
+ } else {
215
+ // TEMP: need to investigate if flatdata should be returned as content type
216
+ // for now we will assume all flatdata is csv
217
+ if (contentType === 'application/x.flatdata') {
218
+ return ContentType.TEXT_CSV;
219
+ }
220
+ return ContentType.TEXT_PLAIN;
221
+ }
222
+ }
195
223
  }
196
224
 
197
225
  export class QueryBuilderGraphFetchTreeState
@@ -321,6 +349,22 @@ export class QueryBuilderGraphFetchTreeState
321
349
  );
322
350
  }
323
351
 
352
+ override get exportDataFormatOptions(): string[] {
353
+ return [GRAPH_FETCH_EXPORT_DATA_FORMAT.RESULT];
354
+ }
355
+
356
+ override getExportDataInfo(format: string): ExportDataInfo {
357
+ if (format === GRAPH_FETCH_EXPORT_DATA_FORMAT.RESULT) {
358
+ return {
359
+ contentType: this.serializationState.serializationContentType,
360
+ };
361
+ } else {
362
+ throw new UnsupportedOperationError(
363
+ `Unsupported Graph Fetch export type ${format}`,
364
+ );
365
+ }
366
+ }
367
+
324
368
  onClassChange(_class: Class | undefined): void {
325
369
  this.updateTreeData(_class);
326
370
  }
@@ -35,6 +35,8 @@ import {
35
35
  filterByType,
36
36
  type Hashable,
37
37
  hashArray,
38
+ UnsupportedOperationError,
39
+ ContentType,
38
40
  } from '@finos/legend-shared';
39
41
  import type { QueryBuilderState } from '../../QueryBuilderState.js';
40
42
  import {
@@ -52,6 +54,7 @@ import {
52
54
  matchFunctionName,
53
55
  SimpleFunctionExpression,
54
56
  getAllSuperclasses,
57
+ EXECUTION_SERIALIZATION_FORMAT,
55
58
  } from '@finos/legend-graph';
56
59
  import {
57
60
  DEFAULT_LAMBDA_VARIABLE_NAME,
@@ -97,6 +100,12 @@ import type { QueryBuilderTDS_WindowOperator } from './window/operators/QueryBui
97
100
  import { getQueryBuilderCoreWindowOperators } from './window/QueryBuilderWindowGroupByOperatorLoader.js';
98
101
  import type { QueryBuilderTDSColumnState } from './QueryBuilderTDSColumnState.js';
99
102
  import { QUERY_BUILDER_SETTING_KEY } from '../../../application/QueryBuilderSetting.js';
103
+ import type { ExportDataInfo } from '../../QueryBuilderResultState.js';
104
+
105
+ // TODO: should we support raw once externalize() is supported on TDS ?
106
+ export enum TDS_EXECUTION_SERIALIZATION_FORMAT {
107
+ CSV = 'CSV',
108
+ }
100
109
 
101
110
  export class QueryBuilderTDSState
102
111
  extends QueryBuilderFetchStructureImplementationState
@@ -289,6 +298,25 @@ export class QueryBuilderTDSState
289
298
  ];
290
299
  }
291
300
 
301
+ override get exportDataFormatOptions(): string[] {
302
+ return [TDS_EXECUTION_SERIALIZATION_FORMAT.CSV];
303
+ }
304
+
305
+ override getExportDataInfo(format: string): ExportDataInfo {
306
+ switch (format) {
307
+ case TDS_EXECUTION_SERIALIZATION_FORMAT.CSV:
308
+ return {
309
+ contentType: ContentType.TEXT_CSV,
310
+ serializationFormat: EXECUTION_SERIALIZATION_FORMAT.CSV,
311
+ };
312
+
313
+ default:
314
+ throw new UnsupportedOperationError(
315
+ `Unsupported TDS export type ${format}`,
316
+ );
317
+ }
318
+ }
319
+
292
320
  isDuplicateColumn(col: QueryBuilderTDSColumnState): boolean {
293
321
  return (
294
322
  this.tdsColumns.filter((c) => c.columnName === col.columnName).length > 1
@@ -47,8 +47,8 @@ export class QueryBuilderPostFilterOperator_GreaterThanEqual extends QueryBuilde
47
47
  PRIMITIVE_TYPE.DATETIME &&
48
48
  postFilterConditionState.value?.genericType?.value.rawType.path !==
49
49
  PRIMITIVE_TYPE.DATETIME
50
- ? SUPPORTED_FUNCTIONS.IS_AFTER_DAY
51
- : QUERY_BUILDER_SUPPORTED_FUNCTIONS.GREATER_THAN,
50
+ ? SUPPORTED_FUNCTIONS.IS_ON_OR_AFTER_DAY
51
+ : QUERY_BUILDER_SUPPORTED_FUNCTIONS.GREATER_THAN_EQUAL,
52
52
  );
53
53
  }
54
54
 
@@ -64,8 +64,8 @@ export class QueryBuilderPostFilterOperator_GreaterThanEqual extends QueryBuilde
64
64
  .path === PRIMITIVE_TYPE.DATETIME &&
65
65
  expression.parametersValues[1]?.genericType?.value.rawType.path !==
66
66
  PRIMITIVE_TYPE.DATETIME
67
- ? SUPPORTED_FUNCTIONS.IS_AFTER_DAY
68
- : QUERY_BUILDER_SUPPORTED_FUNCTIONS.GREATER_THAN,
67
+ ? SUPPORTED_FUNCTIONS.IS_ON_OR_AFTER_DAY
68
+ : QUERY_BUILDER_SUPPORTED_FUNCTIONS.GREATER_THAN_EQUAL,
69
69
  this,
70
70
  );
71
71
  }