@finos/legend-query-builder 1.0.6 → 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 +2 -2
  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
@@ -15,19 +15,45 @@
15
15
  */
16
16
 
17
17
  import {
18
+ PrimitiveInstanceValue,
19
+ type KeyExpression,
20
+ PRIMITIVE_TYPE,
18
21
  type LambdaFunction,
19
22
  GraphFetchTreeInstanceValue,
20
23
  matchFunctionName,
21
24
  RootGraphFetchTree,
22
25
  SimpleFunctionExpression,
26
+ InstanceValue,
27
+ PackageableElementReference,
28
+ Binding,
29
+ SUPPORTED_FUNCTIONS,
30
+ Class,
31
+ PURE_SERIALIZE_CONFIG_CLASS,
32
+ KeyExpressionInstanceValue,
33
+ CollectionInstanceValue,
34
+ getClassProperty,
35
+ PrimitiveType,
23
36
  } from '@finos/legend-graph';
24
- import { assertTrue, guaranteeType } from '@finos/legend-shared';
37
+ import {
38
+ assertIsBoolean,
39
+ assertIsString,
40
+ assertTrue,
41
+ guaranteeIsString,
42
+ guaranteeNonNullable,
43
+ guaranteeType,
44
+ } from '@finos/legend-shared';
25
45
  import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../../graphManager/QueryBuilderSupportedFunctions.js';
26
46
  import type { QueryBuilderState } from '../../QueryBuilderState.js';
27
47
  import { QueryBuilderValueSpecificationProcessor } from '../../QueryBuilderStateBuilder.js';
28
48
  import { FETCH_STRUCTURE_IMPLEMENTATION } from '../QueryBuilderFetchStructureImplementationState.js';
29
- import { QueryBuilderGraphFetchTreeState } from './QueryBuilderGraphFetchTreeState.js';
49
+ import {
50
+ GraphFetchExternalFormatSerializationState,
51
+ GraphFetchPureSerializationState,
52
+ PureSerializationConfig,
53
+ QueryBuilderGraphFetchTreeState,
54
+ } from './QueryBuilderGraphFetchTreeState.js';
30
55
  import { buildGraphFetchTreeData } from './QueryBuilderGraphFetchTreeUtil.js';
56
+ import {} from 'mobx';
31
57
 
32
58
  export const processGraphFetchExpression = (
33
59
  expression: SimpleFunctionExpression,
@@ -77,6 +103,67 @@ export const processGraphFetchExpression = (
77
103
  }
78
104
  };
79
105
 
106
+ type PropertyValue = object | string | number | boolean;
107
+
108
+ // Dynamically sets key values of config
109
+ // TODO we can further enhance this by making configInstance just a list of key value pairs and using class config definition to render in query builder
110
+ const processKeyExpressionValueOnSerializationConfig = (
111
+ keyExpression: KeyExpression,
112
+ configInstance: Record<PropertyKey, PropertyValue>,
113
+ configClassDef: Class,
114
+ idx: number,
115
+ ): void => {
116
+ // initial checks
117
+ const expressionKey = guaranteeType(
118
+ keyExpression.key,
119
+ PrimitiveInstanceValue,
120
+ `Can't process serialize() expression: serialization config key expression ${idx} key expected to be a primitive value`,
121
+ );
122
+ assertTrue(
123
+ expressionKey.genericType.value.rawType.path === PRIMITIVE_TYPE.STRING,
124
+ `Can't process serialize() expression: serialization config key expression ${idx} key expected to be a primitive string value`,
125
+ );
126
+ const keyValue = guaranteeIsString(
127
+ expressionKey.values[0],
128
+ `Can't process serialize() expression: serialization config key expression ${idx} expected to be a non-nullable primitive string value`,
129
+ );
130
+ // check instance
131
+ const properties = Object.getOwnPropertyNames(configInstance);
132
+ guaranteeNonNullable(
133
+ properties.find((prop) => prop === keyValue),
134
+ `Property name '${keyValue}' not defined in serialization config, accepted properties are ${properties.join(
135
+ ',',
136
+ )}`,
137
+ );
138
+ // check class
139
+ const _classProperty = getClassProperty(configClassDef, keyValue);
140
+ const _classType = guaranteeType(
141
+ _classProperty.genericType.value.rawType,
142
+ PrimitiveType,
143
+ `Only primitive types suppported for config. Property ${keyValue} for class ${PURE_SERIALIZE_CONFIG_CLASS} is of type ${_classProperty.genericType.value.rawType.path}`,
144
+ );
145
+ const expressionValue = guaranteeNonNullable(
146
+ guaranteeType(
147
+ keyExpression.expression,
148
+ PrimitiveInstanceValue,
149
+ `Can't process serialize() expression: config key expression's value expected to be a primitive instance value`,
150
+ ).values[0],
151
+ `Can't process serialize() expression: config key expression's value expected to be a non nullable primitive value`,
152
+ );
153
+ // TODO move to separate method and make it more robust
154
+ switch (_classType.path) {
155
+ case PRIMITIVE_TYPE.STRING:
156
+ assertIsString(expressionValue);
157
+ break;
158
+ case PRIMITIVE_TYPE.BOOLEAN:
159
+ assertIsBoolean(expressionValue);
160
+ break;
161
+ default:
162
+ return;
163
+ }
164
+ configInstance[keyValue] = expressionValue as PropertyValue;
165
+ };
166
+
80
167
  export const processGraphFetchSerializeExpression = (
81
168
  expression: SimpleFunctionExpression,
82
169
  queryBuilderState: QueryBuilderState,
@@ -89,8 +176,9 @@ export const processGraphFetchSerializeExpression = (
89
176
 
90
177
  // check parameters
91
178
  assertTrue(
92
- expression.parametersValues.length === 2,
93
- `Can't process serialize() expression: serialize() expects 1 argument`,
179
+ expression.parametersValues.length === 2 ||
180
+ expression.parametersValues.length === 3,
181
+ `Can't process serialize() expression: serialize() expects 1 or 2 argument`,
94
182
  );
95
183
 
96
184
  // check preceding expression
@@ -132,5 +220,171 @@ export const processGraphFetchSerializeExpression = (
132
220
  graphFetchTreeState.setGraphFetchTree(
133
221
  buildGraphFetchTreeData(graphFetchTreeRoot),
134
222
  );
223
+
224
+ const serializeConfigParameter = expression.parametersValues[2];
225
+ if (serializeConfigParameter) {
226
+ const pureConfigFunction = guaranteeType(
227
+ serializeConfigParameter,
228
+ SimpleFunctionExpression,
229
+ `Can't process serialize() expression: serialize() function expects a function to configure custom serialization`,
230
+ );
231
+ assertTrue(
232
+ matchFunctionName(pureConfigFunction.functionName, [
233
+ SUPPORTED_FUNCTIONS.NEW,
234
+ ]),
235
+ `Can't process serialize() expression: config expects 'new' function instaniate new config class`,
236
+ );
237
+
238
+ const pureSerializationState = guaranteeType(
239
+ graphFetchTreeState.serializationState,
240
+ GraphFetchPureSerializationState,
241
+ `Can't process serialize() expression: serialization state expected to be of type pure with serialize()`,
242
+ );
243
+ // first para: config class
244
+ const configClass = guaranteeType(
245
+ guaranteeType(
246
+ guaranteeType(
247
+ pureConfigFunction.parametersValues[0],
248
+ InstanceValue,
249
+ `Can't process serialize() expression: serialization config expects first param to be an instance value`,
250
+ ).values[0],
251
+ PackageableElementReference,
252
+ `Can't process serialize() expression: serialization config expects first param to be a packageable element`,
253
+ ).value,
254
+ Class,
255
+ `Can't process serialize() expression: serialization config expects first param to be a class`,
256
+ );
257
+ assertTrue(
258
+ configClass.path === PURE_SERIALIZE_CONFIG_CLASS,
259
+ `Can't process serialize() expression: serialiaztion config class expected to be ${PURE_SERIALIZE_CONFIG_CLASS}, got : ${configClass.path}`,
260
+ );
261
+ // 2nd param: empty string
262
+ // TODO: Investigate why `new` function as the second input as empty string
263
+
264
+ // 2rd param: key expression values representing property values of config
265
+ const collectionInstanceValue = guaranteeType(
266
+ pureConfigFunction.parametersValues[2],
267
+ CollectionInstanceValue,
268
+ `Can't process serialize() expression: serialization config expects third param to be a collection instance of key expressions`,
269
+ );
270
+ const serializationConfig = new PureSerializationConfig();
271
+ collectionInstanceValue.values.forEach((val, idx) => {
272
+ const keyExpInstance = guaranteeType(
273
+ val,
274
+ KeyExpressionInstanceValue,
275
+ `Can't process serialize() expression: collection instance value expects value ${
276
+ idx + 1
277
+ } to be key expression instance `,
278
+ );
279
+ const keyExpression = guaranteeNonNullable(
280
+ keyExpInstance.values[0],
281
+ `Can't process serialize() expression: serialization config key expression ${idx} expected to non null`,
282
+ );
283
+ processKeyExpressionValueOnSerializationConfig(
284
+ keyExpression,
285
+ serializationConfig as unknown as Record<PropertyKey, PropertyValue>,
286
+ configClass,
287
+ idx,
288
+ );
289
+ });
290
+ pureSerializationState.setConfig(serializationConfig);
291
+ }
292
+ }
293
+ };
294
+
295
+ export const processGraphFetchExternalizeExpression = (
296
+ expression: SimpleFunctionExpression,
297
+ queryBuilderState: QueryBuilderState,
298
+ parentLambda: LambdaFunction,
299
+ ): void => {
300
+ // update fetch-structure
301
+ queryBuilderState.fetchStructureState.changeImplementation(
302
+ FETCH_STRUCTURE_IMPLEMENTATION.GRAPH_FETCH,
303
+ );
304
+
305
+ // check parameters
306
+ assertTrue(
307
+ expression.parametersValues.length === 3,
308
+ `Can't process externalize() expression: externalize() expects 2 argument`,
309
+ );
310
+
311
+ const precedingExpression = guaranteeType(
312
+ expression.parametersValues[0],
313
+ SimpleFunctionExpression,
314
+ `Can't process externalize() expression: only support externalize() immediately following an expression`,
315
+ );
316
+
317
+ // build preceding expression
318
+ assertTrue(
319
+ matchFunctionName(precedingExpression.functionName, [
320
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.GRAPH_FETCH,
321
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.GRAPH_FETCH_CHECKED,
322
+ ]),
323
+ `Can't process externalize() expression: only support externalize() in graph-fetch expression`,
324
+ );
325
+ QueryBuilderValueSpecificationProcessor.process(
326
+ precedingExpression,
327
+ parentLambda,
328
+ queryBuilderState,
329
+ );
330
+
331
+ // build state
332
+ if (
333
+ queryBuilderState.fetchStructureState.implementation instanceof
334
+ QueryBuilderGraphFetchTreeState
335
+ ) {
336
+ const graphFetchTreeState =
337
+ queryBuilderState.fetchStructureState.implementation;
338
+ // TODO: move to graph fetch processing once we completely deattach serialize graph fetch from main graphfetch tree
339
+ const mainGraphFetchTree = guaranteeType(
340
+ precedingExpression.parametersValues[1],
341
+ GraphFetchTreeInstanceValue,
342
+ `Can't process graphfetch() expression: externalize() graph-fetch is missing`,
343
+ );
344
+ const mainGraphFetchTreeRoot = guaranteeType(
345
+ mainGraphFetchTree.values[0],
346
+ RootGraphFetchTree,
347
+ `Can't process graphfetch() expression: graph-fetch tree root is missing`,
348
+ );
349
+ graphFetchTreeState.setGraphFetchTree(
350
+ buildGraphFetchTreeData(mainGraphFetchTreeRoot),
351
+ );
352
+
353
+ // build externalizeState
354
+ const instanceExpression = guaranteeType(
355
+ expression.parametersValues[1],
356
+ InstanceValue,
357
+ `Can't process externalize() expression: only support externalize() with 1st parameter as instance value`,
358
+ );
359
+ const binding = guaranteeType(
360
+ guaranteeType(
361
+ instanceExpression.values[0],
362
+ PackageableElementReference,
363
+ `Can't process externalize() expression: only support externalize() with 1st parameter as packagableElement value`,
364
+ ).value,
365
+ Binding,
366
+ `Can't process externalize() expression: only support externalize() with 1st parameter as binding value`,
367
+ );
368
+
369
+ const externalizeState = new GraphFetchExternalFormatSerializationState(
370
+ graphFetchTreeState,
371
+ binding,
372
+ undefined,
373
+ );
374
+ graphFetchTreeState.setSerializationState(externalizeState);
375
+
376
+ const graphFetchTree = guaranteeType(
377
+ expression.parametersValues[2],
378
+ GraphFetchTreeInstanceValue,
379
+ `Can't process externalize() expression: externalize() graph-fetch is missing`,
380
+ );
381
+ const graphFetchTreeRoot = guaranteeType(
382
+ graphFetchTree.values[0],
383
+ RootGraphFetchTree,
384
+ `Can't process externalize() expression: externalize() graph-fetch tree root is missing`,
385
+ );
386
+ externalizeState.setGraphFetchTree(
387
+ buildGraphFetchTreeData(graphFetchTreeRoot),
388
+ );
135
389
  }
136
390
  };
@@ -15,20 +15,37 @@
15
15
  */
16
16
 
17
17
  import {
18
+ type ValueSpecification,
19
+ type LambdaFunction,
20
+ type PureModel,
18
21
  extractElementNameFromPath,
19
22
  GenericType,
20
23
  GenericTypeExplicitReference,
21
24
  matchFunctionName,
22
25
  PrimitiveInstanceValue,
23
26
  SimpleFunctionExpression,
24
- type ValueSpecification,
25
- type LambdaFunction,
26
27
  GraphFetchTreeInstanceValue,
27
28
  PrimitiveType,
29
+ InstanceValue,
30
+ Multiplicity,
31
+ PackageableElementExplicitReference,
32
+ SUPPORTED_FUNCTIONS,
33
+ PURE_SERIALIZE_CONFIG_CLASS,
34
+ CollectionInstanceValue,
35
+ KeyExpressionInstanceValue,
36
+ KeyExpression,
28
37
  } from '@finos/legend-graph';
29
- import { guaranteeNonNullable, guaranteeType } from '@finos/legend-shared';
38
+ import {
39
+ UnsupportedOperationError,
40
+ guaranteeNonNullable,
41
+ guaranteeType,
42
+ } from '@finos/legend-shared';
30
43
  import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../../graphManager/QueryBuilderSupportedFunctions.js';
31
- import type { QueryBuilderGraphFetchTreeState } from './QueryBuilderGraphFetchTreeState.js';
44
+ import {
45
+ GraphFetchExternalFormatSerializationState,
46
+ GraphFetchPureSerializationState,
47
+ type QueryBuilderGraphFetchTreeState,
48
+ } from './QueryBuilderGraphFetchTreeState.js';
32
49
  import { isGraphFetchTreeDataEmpty } from './QueryBuilderGraphFetchTreeUtil.js';
33
50
 
34
51
  const appendTakeLimit = (
@@ -79,6 +96,67 @@ const appendTakeLimit = (
79
96
  return lambda;
80
97
  };
81
98
 
99
+ export const buildPureSerializationConfig = (
100
+ config: Record<PropertyKey, boolean>,
101
+ graph: PureModel,
102
+ ): SimpleFunctionExpression => {
103
+ const configClass = graph.getClass(PURE_SERIALIZE_CONFIG_CLASS);
104
+ const newFunction = new SimpleFunctionExpression(
105
+ extractElementNameFromPath(SUPPORTED_FUNCTIONS.NEW),
106
+ );
107
+ // build instance
108
+ const instance = new InstanceValue(Multiplicity.ONE, undefined);
109
+ instance.values[0] = PackageableElementExplicitReference.create(configClass);
110
+ // build values
111
+ const primitiveInstance = new PrimitiveInstanceValue(
112
+ GenericTypeExplicitReference.create(new GenericType(PrimitiveType.STRING)),
113
+ );
114
+ primitiveInstance.values = [''];
115
+ const pureConfigCollection = new CollectionInstanceValue(
116
+ Multiplicity.ONE,
117
+ undefined,
118
+ );
119
+ configClass.properties.forEach((classProperty) => {
120
+ const property = Object.getOwnPropertyNames(config).find(
121
+ (p) => p === classProperty.name,
122
+ );
123
+ if (property) {
124
+ const keyExpressionInstance = new KeyExpressionInstanceValue();
125
+ // key expression
126
+ const keyInstance = new PrimitiveInstanceValue(
127
+ GenericTypeExplicitReference.create(
128
+ new GenericType(PrimitiveType.STRING),
129
+ ),
130
+ );
131
+ keyInstance.values = [property];
132
+ // primitive
133
+ const keyPrimitiveInstance = new PrimitiveInstanceValue(
134
+ GenericTypeExplicitReference.create(
135
+ new GenericType(classProperty.genericType.value.rawType),
136
+ ),
137
+ );
138
+ keyPrimitiveInstance.values = [config[property]];
139
+ const keyExpression = new KeyExpression(
140
+ keyInstance,
141
+ keyPrimitiveInstance,
142
+ false,
143
+ );
144
+ keyExpressionInstance.values = [keyExpression];
145
+ pureConfigCollection.values.push(keyExpressionInstance);
146
+ }
147
+ });
148
+ pureConfigCollection.multiplicity = new Multiplicity(
149
+ pureConfigCollection.values.length,
150
+ pureConfigCollection.values.length,
151
+ );
152
+ newFunction.parametersValues = [
153
+ instance,
154
+ primitiveInstance,
155
+ pureConfigCollection,
156
+ ];
157
+ return newFunction;
158
+ };
159
+
82
160
  export const appendGraphFetch = (
83
161
  graphFetchTreeState: QueryBuilderGraphFetchTreeState,
84
162
  lambdaFunction: LambdaFunction,
@@ -97,30 +175,94 @@ export const appendGraphFetch = (
97
175
  `Can't build graph-fetch tree expression: preceding expression is not defined`,
98
176
  );
99
177
 
100
- // build graph-fetch tree
101
- if (
102
- graphFetchTreeState.treeData &&
103
- !isGraphFetchTreeDataEmpty(graphFetchTreeState.treeData)
178
+ const seriaizationState = graphFetchTreeState.serializationState;
179
+ if (seriaizationState instanceof GraphFetchPureSerializationState) {
180
+ // build graph-fetch tree
181
+ if (
182
+ graphFetchTreeState.treeData &&
183
+ !isGraphFetchTreeDataEmpty(graphFetchTreeState.treeData)
184
+ ) {
185
+ const graphFetchInstance = new GraphFetchTreeInstanceValue();
186
+ graphFetchInstance.values = [graphFetchTreeState.treeData.tree];
187
+ const serializeFunction = new SimpleFunctionExpression(
188
+ extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.SERIALIZE),
189
+ );
190
+ const graphFetchFunc = new SimpleFunctionExpression(
191
+ graphFetchTreeState.isChecked
192
+ ? extractElementNameFromPath(
193
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.GRAPH_FETCH_CHECKED,
194
+ )
195
+ : extractElementNameFromPath(
196
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.GRAPH_FETCH,
197
+ ),
198
+ );
199
+ graphFetchFunc.parametersValues = [
200
+ precedingExpression,
201
+ graphFetchInstance,
202
+ ];
203
+ serializeFunction.parametersValues = [graphFetchFunc, graphFetchInstance];
204
+ if (seriaizationState.config) {
205
+ const configFunction = buildPureSerializationConfig(
206
+ seriaizationState.config as unknown as Record<PropertyKey, boolean>,
207
+ graphFetchTreeState.queryBuilderState.graphManagerState.graph,
208
+ );
209
+ serializeFunction.parametersValues.push(configFunction);
210
+ }
211
+ lambdaFunction.expressionSequence[0] = serializeFunction;
212
+ }
213
+ } else if (
214
+ seriaizationState instanceof GraphFetchExternalFormatSerializationState
104
215
  ) {
105
- const graphFetchInstance = new GraphFetchTreeInstanceValue();
106
- graphFetchInstance.values = [graphFetchTreeState.treeData.tree];
107
- const serializeFunction = new SimpleFunctionExpression(
108
- extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.SERIALIZE),
216
+ const externalizeFunction = new SimpleFunctionExpression(
217
+ extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.EXTERNALIZE),
109
218
  );
110
- const graphFetchFunc = new SimpleFunctionExpression(
111
- graphFetchTreeState.isChecked
112
- ? extractElementNameFromPath(
113
- QUERY_BUILDER_SUPPORTED_FUNCTIONS.GRAPH_FETCH_CHECKED,
114
- )
115
- : extractElementNameFromPath(
116
- QUERY_BUILDER_SUPPORTED_FUNCTIONS.GRAPH_FETCH,
117
- ),
219
+ const mainGraphTree = graphFetchTreeState.treeData;
220
+ const externalizeTree = seriaizationState.treeData;
221
+ if (
222
+ mainGraphTree &&
223
+ externalizeTree &&
224
+ !isGraphFetchTreeDataEmpty(mainGraphTree) &&
225
+ !isGraphFetchTreeDataEmpty(externalizeTree)
226
+ ) {
227
+ // 0th param
228
+ const graphFetchInstance = new GraphFetchTreeInstanceValue();
229
+ graphFetchInstance.values = [mainGraphTree.tree];
230
+ const graphFetchFunc = new SimpleFunctionExpression(
231
+ graphFetchTreeState.isChecked
232
+ ? extractElementNameFromPath(
233
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.GRAPH_FETCH_CHECKED,
234
+ )
235
+ : extractElementNameFromPath(
236
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.GRAPH_FETCH,
237
+ ),
238
+ );
239
+ graphFetchFunc.parametersValues = [
240
+ precedingExpression,
241
+ graphFetchInstance,
242
+ ];
243
+ // 1st param
244
+ const bindingInstance = new InstanceValue(Multiplicity.ONE, undefined);
245
+ bindingInstance.values = [
246
+ PackageableElementExplicitReference.create(
247
+ seriaizationState.targetBinding,
248
+ ),
249
+ ];
250
+ // 2nd parameter
251
+ const xtGraphFetchInstance = new GraphFetchTreeInstanceValue();
252
+ xtGraphFetchInstance.values = [externalizeTree.tree];
253
+ // build externalize
254
+ externalizeFunction.parametersValues = [
255
+ graphFetchFunc,
256
+ bindingInstance,
257
+ xtGraphFetchInstance,
258
+ ];
259
+ lambdaFunction.expressionSequence[0] = externalizeFunction;
260
+ }
261
+ } else {
262
+ throw new UnsupportedOperationError(
263
+ `Unsupported serialization state ${seriaizationState.getLabel()}`,
118
264
  );
119
- graphFetchFunc.parametersValues = [precedingExpression, graphFetchInstance];
120
- serializeFunction.parametersValues = [graphFetchFunc, graphFetchInstance];
121
- lambdaFunction.expressionSequence[0] = serializeFunction;
122
265
  }
123
-
124
266
  // build result set modifier: i.e. preview limit
125
267
  if (options?.isBuildingExecutionQuery) {
126
268
  appendTakeLimit(lambdaFunction, queryBuilderState.resultState.previewLimit);
@@ -135,6 +135,7 @@ export class QueryBuilderTDSState
135
135
  addColumn: action,
136
136
  moveColumn: action,
137
137
  replaceColumn: action,
138
+ initialize: action,
138
139
  setShowPostFilterPanel: action,
139
140
  setShowWindowFuncPanel: action,
140
141
  convertDerivationProjectionObjects: flow,
@@ -294,6 +295,12 @@ export class QueryBuilderTDSState
294
295
  );
295
296
  }
296
297
 
298
+ override initialize(): void {
299
+ this.queryBuilderState.filterState.setShowPanel(true);
300
+ this.setShowPostFilterPanel(false);
301
+ this.setShowWindowFuncPanel(false);
302
+ }
303
+
297
304
  isColumnInUse(tdsCol: QueryBuilderTDSColumnState): boolean {
298
305
  return Boolean(
299
306
  [