@finos/legend-query-builder 1.0.5 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. package/lib/application/QueryBuilderEvent.d.ts +7 -7
  2. package/lib/application/QueryBuilderEvent.d.ts.map +1 -1
  3. package/lib/application/QueryBuilderEvent.js +7 -7
  4. package/lib/application/QueryBuilderEvent.js.map +1 -1
  5. package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.js +2 -2
  6. package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.js.map +1 -1
  7. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts +3 -2
  8. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts.map +1 -1
  9. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.js +53 -13
  10. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.js.map +1 -1
  11. package/lib/graphManager/QueryBuilderSupportedFunctions.d.ts +1 -0
  12. package/lib/graphManager/QueryBuilderSupportedFunctions.d.ts.map +1 -1
  13. package/lib/graphManager/QueryBuilderSupportedFunctions.js +1 -0
  14. package/lib/graphManager/QueryBuilderSupportedFunctions.js.map +1 -1
  15. package/lib/index.css +17 -1
  16. package/lib/index.css.map +1 -1
  17. package/lib/package.json +6 -6
  18. package/lib/stores/QueryBuilderStateBuilder.d.ts +2 -1
  19. package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
  20. package/lib/stores/QueryBuilderStateBuilder.js +8 -1
  21. package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
  22. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts +1 -0
  23. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts.map +1 -1
  24. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.js.map +1 -1
  25. package/lib/stores/fetch-structure/QueryBuilderFetchStructureState.d.ts.map +1 -1
  26. package/lib/stores/fetch-structure/QueryBuilderFetchStructureState.js +3 -2
  27. package/lib/stores/fetch-structure/QueryBuilderFetchStructureState.js.map +1 -1
  28. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts +49 -1
  29. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts.map +1 -1
  30. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js +126 -0
  31. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js.map +1 -1
  32. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.d.ts +1 -0
  33. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.d.ts.map +1 -1
  34. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.js +85 -4
  35. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.js.map +1 -1
  36. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.d.ts +3 -2
  37. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.d.ts.map +1 -1
  38. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.js +96 -14
  39. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.js.map +1 -1
  40. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts +1 -0
  41. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts.map +1 -1
  42. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js +6 -0
  43. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
  44. package/package.json +13 -13
  45. package/src/application/QueryBuilderEvent.ts +7 -7
  46. package/src/components/fetch-structure/QueryBuilderFetchStructurePanel.tsx +2 -2
  47. package/src/components/fetch-structure/QueryBuilderGraphFetchTreePanel.tsx +240 -5
  48. package/src/graphManager/QueryBuilderSupportedFunctions.ts +1 -0
  49. package/src/stores/QueryBuilderStateBuilder.ts +20 -0
  50. package/src/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.ts +2 -0
  51. package/src/stores/fetch-structure/QueryBuilderFetchStructureState.ts +3 -2
  52. package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.ts +158 -0
  53. package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.ts +258 -4
  54. package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.ts +166 -24
  55. package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +7 -0
@@ -29,6 +29,18 @@ import {
29
29
  SquareIcon,
30
30
  InfoCircleIcon,
31
31
  PanelDropZone,
32
+ BlankPanelContent,
33
+ Dialog,
34
+ ModalHeader,
35
+ Modal,
36
+ ModalBody,
37
+ Panel,
38
+ PanelForm,
39
+ PanelFormTextField,
40
+ PanelFormBooleanField,
41
+ ModalFooterButton,
42
+ ModalFooter,
43
+ SerializeIcon,
32
44
  } from '@finos/legend-art';
33
45
  import { QUERY_BUILDER_TEST_ID } from '../../application/QueryBuilderTesting.js';
34
46
  import { isNonNullable } from '@finos/legend-shared';
@@ -42,8 +54,13 @@ import {
42
54
  type QueryBuilderExplorerTreeDragSource,
43
55
  QUERY_BUILDER_EXPLORER_TREE_DND_TYPE,
44
56
  } from '../../stores/explorer/QueryBuilderExplorerState.js';
45
- import type { QueryBuilderGraphFetchTreeState } from '../../stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js';
57
+ import {
58
+ GraphFetchPureSerializationState,
59
+ PureSerializationConfig,
60
+ type QueryBuilderGraphFetchTreeState,
61
+ } from '../../stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js';
46
62
  import { getClassPropertyIcon } from '../shared/ElementIconUtils.js';
63
+ import { QueryBuilderTextEditorMode } from '../../stores/QueryBuilderTextEditorState.js';
47
64
 
48
65
  const QueryBuilderGraphFetchTreeNodeContainer: React.FC<
49
66
  TreeNodeContainerProps<
@@ -134,14 +151,157 @@ const QueryBuilderGraphFetchTreeNodeContainer: React.FC<
134
151
  );
135
152
  };
136
153
 
154
+ const PureSerializationConfigModal = observer(
155
+ (props: {
156
+ pureSerializationState: GraphFetchPureSerializationState;
157
+ graphFetchState: QueryBuilderGraphFetchTreeState;
158
+ config: PureSerializationConfig;
159
+ }) => {
160
+ const { pureSerializationState, graphFetchState, config } = props;
161
+ const applicationStore = graphFetchState.queryBuilderState.applicationStore;
162
+ const toAdd = !pureSerializationState.config;
163
+ const handleAction = (): void => {
164
+ if (toAdd) {
165
+ pureSerializationState.setConfig(config);
166
+ }
167
+ pureSerializationState.setConfigModal(false);
168
+ };
169
+ const removeConfig = (): void => {
170
+ pureSerializationState.setConfig(undefined);
171
+ pureSerializationState.setConfigModal(false);
172
+ graphFetchState.queryBuilderState.applicationStore.notificationService.notifySuccess(
173
+ 'Serialization config removed',
174
+ );
175
+ };
176
+ const close = (): void => pureSerializationState.setConfigModal(false);
177
+ return (
178
+ <Dialog
179
+ open={pureSerializationState.configModal}
180
+ onClose={close}
181
+ classes={{
182
+ root: 'editor-modal__root-container',
183
+ container: 'editor-modal__container',
184
+ paper: 'editor-modal__content',
185
+ }}
186
+ >
187
+ <Modal
188
+ darkMode={
189
+ !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
190
+ }
191
+ className="query-builder-graph-fetch-config"
192
+ >
193
+ <ModalHeader
194
+ title={`${
195
+ toAdd ? 'Add Serialization Config' : 'Edit Serialization Config'
196
+ }`}
197
+ />
198
+ <ModalBody className="query-builder-graph-fetch-config__content">
199
+ <Panel>
200
+ <PanelForm>
201
+ <PanelFormTextField
202
+ name="Type Key Name"
203
+ value={config.typeKeyName}
204
+ isReadOnly={false}
205
+ update={(value: string | undefined): void =>
206
+ config.setTypeName(value ?? '')
207
+ }
208
+ errorMessage={
209
+ config.typeKeyName === ''
210
+ ? `Type key name can't be empty`
211
+ : undefined
212
+ }
213
+ />
214
+ <PanelFormBooleanField
215
+ name="Include Type"
216
+ value={config.includeType}
217
+ isReadOnly={false}
218
+ update={(value: boolean | undefined): void =>
219
+ config.setIncludeType(Boolean(value))
220
+ }
221
+ />
222
+
223
+ <PanelFormBooleanField
224
+ name="Include Enum Type"
225
+ value={config.includeEnumType}
226
+ isReadOnly={false}
227
+ update={(value: boolean | undefined): void =>
228
+ config.setInclueEnumType(Boolean(value))
229
+ }
230
+ />
231
+
232
+ <PanelFormBooleanField
233
+ name="Remove Properties With Null Values"
234
+ value={config.removePropertiesWithNullValues}
235
+ isReadOnly={false}
236
+ update={(value: boolean | undefined): void =>
237
+ config.setRemovePropertiesWithNullValues(Boolean(value))
238
+ }
239
+ />
240
+
241
+ <PanelFormBooleanField
242
+ name="Remove properties with empty sets"
243
+ value={config.removePropertiesWithEmptySets}
244
+ isReadOnly={false}
245
+ update={(value: boolean | undefined): void =>
246
+ config.setRemovePropertiesWithEmptySets(Boolean(value))
247
+ }
248
+ />
249
+
250
+ <PanelFormBooleanField
251
+ name="Use Fully Qualified Type Path"
252
+ value={config.fullyQualifiedTypePath}
253
+ isReadOnly={false}
254
+ update={(value: boolean | undefined): void =>
255
+ config.setFullyQualifiedTypePath(Boolean(value))
256
+ }
257
+ />
258
+ <PanelFormBooleanField
259
+ name="Include Object Reference"
260
+ value={config.includeObjectReference}
261
+ isReadOnly={false}
262
+ update={(value: boolean | undefined): void =>
263
+ config.setIncludeObjectReference(Boolean(value))
264
+ }
265
+ />
266
+ </PanelForm>
267
+ </Panel>
268
+ </ModalBody>
269
+ <ModalFooter>
270
+ {!toAdd && (
271
+ <ModalFooterButton
272
+ className="btn--caution"
273
+ text="Remove Config"
274
+ onClick={removeConfig}
275
+ />
276
+ )}
277
+ <button
278
+ className="btn modal__footer__close-btn btn--dark"
279
+ onClick={handleAction}
280
+ >
281
+ {toAdd ? 'Add Config' : 'Close'}
282
+ </button>
283
+ </ModalFooter>
284
+ </Modal>
285
+ </Dialog>
286
+ );
287
+ },
288
+ );
289
+
137
290
  export const QueryBuilderGraphFetchTreeExplorer = observer(
138
291
  (props: {
139
292
  graphFetchState: QueryBuilderGraphFetchTreeState;
293
+ pureSerializationState: GraphFetchPureSerializationState;
140
294
  treeData: QueryBuilderGraphFetchTreeData;
141
295
  updateTreeData: (data: QueryBuilderGraphFetchTreeData) => void;
142
296
  isReadOnly: boolean;
143
297
  }) => {
144
- const { graphFetchState, treeData, updateTreeData, isReadOnly } = props;
298
+ const {
299
+ graphFetchState,
300
+ pureSerializationState,
301
+ treeData,
302
+ updateTreeData,
303
+ isReadOnly,
304
+ } = props;
145
305
 
146
306
  const onNodeSelect = (node: QueryBuilderGraphFetchTreeNodeData): void => {
147
307
  if (node.childrenIds.length) {
@@ -165,9 +325,30 @@ export const QueryBuilderGraphFetchTreeExplorer = observer(
165
325
  const toggleChecked = (): void =>
166
326
  graphFetchState.setChecked(!graphFetchState.isChecked);
167
327
 
328
+ const openConfigModal = (): void => {
329
+ pureSerializationState.setConfigModal(true);
330
+ };
331
+
168
332
  return (
169
333
  <div className="query-builder-graph-fetch-tree">
170
334
  <div className="query-builder-graph-fetch-tree__toolbar">
335
+ <div className="query-builder-graph-fetch-tree__actions">
336
+ <button
337
+ className="query-builder-graph-fetch-tree__actions__action-btn__label"
338
+ onClick={openConfigModal}
339
+ title={`${
340
+ pureSerializationState.config
341
+ ? 'Edit pure serialization config'
342
+ : 'Add pure serialization config'
343
+ }`}
344
+ tabIndex={-1}
345
+ >
346
+ <SerializeIcon className="query-builder-graph-fetch-tree__actions__action-btn__label__icon" />
347
+ <div className="query-builder-graph-fetch-tree__actions__action-btn__label__title">
348
+ {pureSerializationState.config ? 'Edit Config' : 'Add Config'}
349
+ </div>
350
+ </button>
351
+ </div>
171
352
  <div
172
353
  className={clsx('panel__content__form__section__toggler')}
173
354
  onClick={toggleChecked}
@@ -189,6 +370,15 @@ export const QueryBuilderGraphFetchTreeExplorer = observer(
189
370
  </div>
190
371
  </div>
191
372
  <div className="query-builder-graph-fetch-tree__container">
373
+ {pureSerializationState.configModal && (
374
+ <PureSerializationConfigModal
375
+ pureSerializationState={pureSerializationState}
376
+ graphFetchState={graphFetchState}
377
+ config={
378
+ pureSerializationState.config ?? new PureSerializationConfig()
379
+ }
380
+ />
381
+ )}
192
382
  <TreeView
193
383
  components={{
194
384
  TreeNodeContainer: QueryBuilderGraphFetchTreeNodeContainer,
@@ -207,9 +397,13 @@ export const QueryBuilderGraphFetchTreeExplorer = observer(
207
397
  },
208
398
  );
209
399
 
210
- export const QueryBuilderGraphFetchTreePanel = observer(
211
- (props: { graphFetchTreeState: QueryBuilderGraphFetchTreeState }) => {
212
- const { graphFetchTreeState } = props;
400
+ const QueryBuilderGraphFetchTreePanel = observer(
401
+ (props: {
402
+ graphFetchTreeState: QueryBuilderGraphFetchTreeState;
403
+
404
+ pureSerializationState: GraphFetchPureSerializationState;
405
+ }) => {
406
+ const { graphFetchTreeState, pureSerializationState } = props;
213
407
  const treeData = graphFetchTreeState.treeData;
214
408
 
215
409
  // Deep/Graph Fetch Tree
@@ -264,6 +458,7 @@ export const QueryBuilderGraphFetchTreePanel = observer(
264
458
  {treeData && !isGraphFetchTreeDataEmpty(treeData) && (
265
459
  <QueryBuilderGraphFetchTreeExplorer
266
460
  graphFetchState={graphFetchTreeState}
461
+ pureSerializationState={pureSerializationState}
267
462
  treeData={treeData}
268
463
  isReadOnly={false}
269
464
  updateTreeData={updateTreeData}
@@ -274,3 +469,43 @@ export const QueryBuilderGraphFetchTreePanel = observer(
274
469
  );
275
470
  },
276
471
  );
472
+
473
+ export const QueryBuilderGraphFetchPanel = observer(
474
+ (props: { graphFetchTreeState: QueryBuilderGraphFetchTreeState }) => {
475
+ const { graphFetchTreeState } = props;
476
+ const serializationState = graphFetchTreeState.serializationState;
477
+ const handleTextModeClick = (): void =>
478
+ graphFetchTreeState.queryBuilderState.textEditorState.openModal(
479
+ QueryBuilderTextEditorMode.TEXT,
480
+ );
481
+ if (serializationState instanceof GraphFetchPureSerializationState) {
482
+ return (
483
+ <QueryBuilderGraphFetchTreePanel
484
+ graphFetchTreeState={graphFetchTreeState}
485
+ pureSerializationState={serializationState}
486
+ />
487
+ );
488
+ }
489
+ return (
490
+ <div
491
+ data-testid={QUERY_BUILDER_TEST_ID.QUERY_BUILDER_GRAPH_FETCH}
492
+ className="panel__content"
493
+ >
494
+ <BlankPanelContent>
495
+ <div className="unsupported-element-editor__main">
496
+ <div className="unsupported-element-editor__summary">
497
+ Unsupported Graph Fetch Serialization Type
498
+ </div>
499
+
500
+ <button
501
+ className="btn--dark unsupported-element-editor__to-text-mode__btn"
502
+ onClick={handleTextModeClick}
503
+ >
504
+ Edit in text mode
505
+ </button>
506
+ </div>
507
+ </BlankPanelContent>
508
+ </div>
509
+ );
510
+ },
511
+ );
@@ -30,6 +30,7 @@ export enum QUERY_BUILDER_SUPPORTED_FUNCTIONS {
30
30
  GRAPH_FETCH = 'meta::pure::graphFetch::execution::graphFetch',
31
31
  GRAPH_FETCH_CHECKED = 'meta::pure::graphFetch::execution::graphFetchChecked',
32
32
  SERIALIZE = 'meta::pure::graphFetch::execution::serialize',
33
+ EXTERNALIZE = 'meta::external::shared::format::functions::externalize',
33
34
 
34
35
  // TDS
35
36
  TDS_FILTER = 'meta::pure::tds::filter',
@@ -32,6 +32,7 @@ import {
32
32
  type InstanceValue,
33
33
  type INTERNAL__UnknownValueSpecification,
34
34
  type LambdaFunction,
35
+ type KeyExpressionInstanceValue,
35
36
  matchFunctionName,
36
37
  Class,
37
38
  type CollectionInstanceValue,
@@ -53,6 +54,7 @@ import {
53
54
  } from './fetch-structure/tds/aggregation/QueryBuilderAggregationStateBuilder.js';
54
55
  import {
55
56
  processGraphFetchExpression,
57
+ processGraphFetchExternalizeExpression,
56
58
  processGraphFetchSerializeExpression,
57
59
  } from './fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.js';
58
60
  import {
@@ -503,6 +505,18 @@ export class QueryBuilderValueSpecificationProcessor
503
505
  this.parentLambda,
504
506
  );
505
507
  return;
508
+ } else if (
509
+ matchFunctionName(
510
+ functionName,
511
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.EXTERNALIZE,
512
+ )
513
+ ) {
514
+ processGraphFetchExternalizeExpression(
515
+ valueSpecification,
516
+ this.queryBuilderState,
517
+ this.parentLambda,
518
+ );
519
+ return;
506
520
  } else if (
507
521
  matchFunctionName(functionName, [
508
522
  QUERY_BUILDER_SUPPORTED_FUNCTIONS.GRAPH_FETCH_CHECKED,
@@ -563,6 +577,12 @@ export class QueryBuilderValueSpecificationProcessor
563
577
  throw new UnsupportedOperationError();
564
578
  }
565
579
 
580
+ visit_KeyExpressionInstanceValue(
581
+ valueSpecification: KeyExpressionInstanceValue,
582
+ ): void {
583
+ throw new UnsupportedOperationError();
584
+ }
585
+
566
586
  visit_CollectionInstanceValue(
567
587
  valueSpecification: CollectionInstanceValue,
568
588
  ): void {
@@ -55,6 +55,7 @@ export abstract class QueryBuilderFetchStructureImplementationState
55
55
  abstract get type(): string;
56
56
  abstract get usedExplorerTreePropertyNodeIDs(): string[];
57
57
  abstract get validationIssues(): string[] | undefined;
58
+
58
59
  abstract onClassChange(_class: Class | undefined): void;
59
60
  abstract revealCompilationError(compilationError: CompilationError): boolean;
60
61
  abstract clearCompilationError(): void;
@@ -68,6 +69,7 @@ export abstract class QueryBuilderFetchStructureImplementationState
68
69
  lambdaFunction: LambdaFunction,
69
70
  options?: LambdaFunctionBuilderOption,
70
71
  ): void;
72
+ abstract initialize(): void;
71
73
  abstract get hashCode(): string;
72
74
 
73
75
  get TEMPORARY__showPostFetchStructurePanel(): boolean {
@@ -59,20 +59,21 @@ export class QueryBuilderFetchStructureState {
59
59
  this.queryBuilderState,
60
60
  this,
61
61
  );
62
- return;
62
+ break;
63
63
  }
64
64
  case FETCH_STRUCTURE_IMPLEMENTATION.GRAPH_FETCH: {
65
65
  this.implementation = new QueryBuilderGraphFetchTreeState(
66
66
  this.queryBuilderState,
67
67
  this,
68
68
  );
69
- return;
69
+ break;
70
70
  }
71
71
  default:
72
72
  throw new UnsupportedOperationError(
73
73
  `Can't change fetch-structure implementation to unsupported type: '${type}'`,
74
74
  );
75
75
  }
76
+ this.implementation.initialize();
76
77
  }
77
78
 
78
79
  fetchProperty(node: QueryBuilderExplorerTreeNodeData): void {
@@ -24,6 +24,7 @@ import {
24
24
  PackageableElementExplicitReference,
25
25
  RootGraphFetchTree,
26
26
  getAllSuperclasses,
27
+ type Binding,
27
28
  } from '@finos/legend-graph';
28
29
  import {
29
30
  type QueryBuilderGraphFetchTreeData,
@@ -54,6 +55,145 @@ import {
54
55
  import { QUERY_BUILDER_HASH_STRUCTURE } from '../../../graphManager/QueryBuilderHashUtils.js';
55
56
  import { isValueExpressionReferencedInValue } from '../../QueryBuilderValueSpecificationHelper.js';
56
57
 
58
+ export enum SERIALIZATION_TYPE {
59
+ PURE = 'PURE',
60
+ EXTERNAL_FORMAT = 'EXTERNAL_FORMAT',
61
+ }
62
+
63
+ const DEFAULT_PURE_CONFIG_TYPE_NAME = '@type';
64
+
65
+ export class PureSerializationConfig {
66
+ typeKeyName: string;
67
+ includeType: boolean;
68
+ includeEnumType: boolean;
69
+ removePropertiesWithNullValues: boolean;
70
+ removePropertiesWithEmptySets: boolean;
71
+ fullyQualifiedTypePath: boolean;
72
+ includeObjectReference: boolean;
73
+
74
+ constructor() {
75
+ // default values
76
+ this.typeKeyName = DEFAULT_PURE_CONFIG_TYPE_NAME;
77
+ this.includeType = true;
78
+ this.includeEnumType = true;
79
+ this.removePropertiesWithNullValues = true;
80
+ this.removePropertiesWithEmptySets = false;
81
+ this.fullyQualifiedTypePath = true;
82
+ this.includeObjectReference = false;
83
+ makeObservable(this, {
84
+ typeKeyName: observable,
85
+ includeType: observable,
86
+ includeEnumType: observable,
87
+ removePropertiesWithNullValues: observable,
88
+ removePropertiesWithEmptySets: observable,
89
+ fullyQualifiedTypePath: observable,
90
+ includeObjectReference: observable,
91
+ setTypeName: action,
92
+ setIncludeObjectReference: action,
93
+ setIncludeType: action,
94
+ setFullyQualifiedTypePath: action,
95
+ setRemovePropertiesWithEmptySets: action,
96
+ setInclueEnumType: action,
97
+ setRemovePropertiesWithNullValues: action,
98
+ });
99
+ }
100
+
101
+ setTypeName(val: string): void {
102
+ this.typeKeyName = val;
103
+ }
104
+
105
+ setIncludeType(val: boolean): void {
106
+ this.includeType = val;
107
+ }
108
+
109
+ setInclueEnumType(val: boolean): void {
110
+ this.includeEnumType = val;
111
+ }
112
+
113
+ setRemovePropertiesWithNullValues(val: boolean): void {
114
+ this.removePropertiesWithNullValues = val;
115
+ }
116
+
117
+ setRemovePropertiesWithEmptySets(val: boolean): void {
118
+ this.removePropertiesWithEmptySets = val;
119
+ }
120
+
121
+ setFullyQualifiedTypePath(val: boolean): void {
122
+ this.fullyQualifiedTypePath = val;
123
+ }
124
+
125
+ setIncludeObjectReference(val: boolean): void {
126
+ this.includeObjectReference = val;
127
+ }
128
+ }
129
+
130
+ export abstract class GraphFetchSerializationState {
131
+ readonly queryBuilderGraphFetchTreeState: QueryBuilderGraphFetchTreeState;
132
+
133
+ constructor(graphFetchTreeState: QueryBuilderGraphFetchTreeState) {
134
+ this.queryBuilderGraphFetchTreeState = graphFetchTreeState;
135
+ }
136
+
137
+ abstract getLabel(): string;
138
+ }
139
+
140
+ export class GraphFetchPureSerializationState extends GraphFetchSerializationState {
141
+ config: PureSerializationConfig | undefined;
142
+ configModal = false;
143
+
144
+ constructor(graphFetchTreeState: QueryBuilderGraphFetchTreeState) {
145
+ super(graphFetchTreeState);
146
+ makeObservable(this, {
147
+ config: observable,
148
+ configModal: observable,
149
+ setConfigModal: action,
150
+ });
151
+ }
152
+
153
+ setConfig(value: PureSerializationConfig | undefined): void {
154
+ this.config = value;
155
+ }
156
+
157
+ setConfigModal(val: boolean): void {
158
+ this.configModal = val;
159
+ }
160
+
161
+ override getLabel(): string {
162
+ return SERIALIZATION_TYPE.PURE;
163
+ }
164
+ }
165
+
166
+ export class GraphFetchExternalFormatSerializationState extends GraphFetchSerializationState {
167
+ targetBinding: Binding;
168
+ treeData: QueryBuilderGraphFetchTreeData | undefined;
169
+
170
+ constructor(
171
+ graphFetchTreeState: QueryBuilderGraphFetchTreeState,
172
+ targetBinding: Binding,
173
+ treeData: QueryBuilderGraphFetchTreeData | undefined,
174
+ ) {
175
+ super(graphFetchTreeState);
176
+ makeObservable(this, {
177
+ targetBinding: observable,
178
+ treeData: observable.ref,
179
+ });
180
+ this.targetBinding = targetBinding;
181
+ this.treeData = treeData;
182
+ }
183
+
184
+ setBinding(value: Binding): void {
185
+ this.targetBinding = value;
186
+ }
187
+
188
+ setGraphFetchTree(val: QueryBuilderGraphFetchTreeData | undefined): void {
189
+ this.treeData = val;
190
+ }
191
+
192
+ override getLabel(): string {
193
+ return SERIALIZATION_TYPE.EXTERNAL_FORMAT;
194
+ }
195
+ }
196
+
57
197
  export class QueryBuilderGraphFetchTreeState
58
198
  extends QueryBuilderFetchStructureImplementationState
59
199
  implements Hashable
@@ -66,6 +206,11 @@ export class QueryBuilderGraphFetchTreeState
66
206
  */
67
207
  isChecked = false;
68
208
 
209
+ /**
210
+ * Used to describe how the graph fetch tree is serialized to the final result set
211
+ */
212
+ serializationState: GraphFetchSerializationState;
213
+
69
214
  constructor(
70
215
  queryBuilderState: QueryBuilderState,
71
216
  fetchStructureState: QueryBuilderFetchStructureState,
@@ -75,13 +220,18 @@ export class QueryBuilderGraphFetchTreeState
75
220
  makeObservable(this, {
76
221
  treeData: observable.ref,
77
222
  isChecked: observable,
223
+ serializationState: observable,
78
224
  TEMPORARY__showPostFetchStructurePanel: computed,
79
225
  setGraphFetchTree: action,
226
+ setSerializationState: action,
80
227
  setChecked: action,
228
+ initialize: action,
81
229
  });
82
230
 
83
231
  // try to initialize the graph-fetch tree data using the setup class
84
232
  this.updateTreeData(this.queryBuilderState.class);
233
+ // we will default to standard pure serialization with no config
234
+ this.serializationState = new GraphFetchPureSerializationState(this);
85
235
  }
86
236
 
87
237
  get type(): string {
@@ -143,6 +293,14 @@ export class QueryBuilderGraphFetchTreeState
143
293
  return undefined;
144
294
  }
145
295
 
296
+ override initialize(): void {
297
+ this.queryBuilderState.filterState.setShowPanel(true);
298
+ }
299
+
300
+ setSerializationState(val: GraphFetchSerializationState): void {
301
+ this.serializationState = val;
302
+ }
303
+
146
304
  setGraphFetchTree(val: QueryBuilderGraphFetchTreeData | undefined): void {
147
305
  this.treeData = val;
148
306
  }