@finos/legend-query-builder 4.15.41 → 4.15.42
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/index.css +1 -1
- package/lib/package.json +3 -3
- package/lib/stores/data-cube/QueryBuilderDataCubeEngine.d.ts +7 -8
- package/lib/stores/data-cube/QueryBuilderDataCubeEngine.d.ts.map +1 -1
- package/lib/stores/data-cube/QueryBuilderDataCubeEngine.js +46 -48
- package/lib/stores/data-cube/QueryBuilderDataCubeEngine.js.map +1 -1
- package/package.json +9 -9
- package/src/stores/data-cube/QueryBuilderDataCubeEngine.ts +86 -86
package/lib/index.css
CHANGED
package/lib/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finos/legend-query-builder",
|
|
3
|
-
"version": "4.15.
|
|
3
|
+
"version": "4.15.42",
|
|
4
4
|
"description": "Legend query builder core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"legend",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"@finos/legend-shared": "workspace:*",
|
|
53
53
|
"@finos/legend-storage": "workspace:*",
|
|
54
54
|
"@testing-library/dom": "10.4.0",
|
|
55
|
-
"@testing-library/react": "16.
|
|
56
|
-
"@types/react": "19.0.
|
|
55
|
+
"@testing-library/react": "16.2.0",
|
|
56
|
+
"@types/react": "19.0.8",
|
|
57
57
|
"@types/react-dom": "19.0.3",
|
|
58
58
|
"chart.js": "4.4.7",
|
|
59
59
|
"mathjs": "14.0.1",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { V1_Lambda, RawLambda, TDSExecutionResult, V1_AppliedFunction, type GraphManagerState, type
|
|
16
|
+
import { V1_Lambda, RawLambda, TDSExecutionResult, V1_AppliedFunction, type GraphManagerState, type V1_ValueSpecification, type ParameterValue } from '@finos/legend-graph';
|
|
17
17
|
import { DataCubeEngine, DataCubeSource, type CompletionItem, DataCubeQuery } from '@finos/legend-data-cube';
|
|
18
18
|
import { LogService, type PlainObject } from '@finos/legend-shared';
|
|
19
19
|
declare class QueryBuilderDataCubeSource extends DataCubeSource {
|
|
@@ -29,16 +29,11 @@ export declare class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
|
29
29
|
readonly runtimePath: string | undefined;
|
|
30
30
|
readonly parameters: object | undefined;
|
|
31
31
|
constructor(selectQuery: RawLambda, parameterValues: ParameterValue[] | undefined, mappingPath: string | undefined, runtimePath: string | undefined, graphManagerState: GraphManagerState);
|
|
32
|
-
get sourceLabel(): string;
|
|
33
|
-
get graph(): PureModel;
|
|
34
|
-
private getSourceFunctionExpression;
|
|
35
|
-
generateInitialQuery(): Promise<DataCubeQuery>;
|
|
36
32
|
processQuerySource(value: PlainObject): Promise<QueryBuilderDataCubeSource>;
|
|
37
|
-
private buildRawLambdaFromValueSpec;
|
|
38
|
-
getQueryTypeahead(code: string, baseQuery: V1_Lambda, source: DataCubeSource): Promise<CompletionItem[]>;
|
|
39
33
|
parseValueSpecification(code: string, returnSourceInformation?: boolean): Promise<V1_ValueSpecification>;
|
|
40
34
|
getValueSpecificationCode(value: V1_ValueSpecification, pretty?: boolean | undefined): Promise<string>;
|
|
41
|
-
|
|
35
|
+
getQueryTypeahead(code: string, baseQuery: V1_Lambda, source: DataCubeSource): Promise<CompletionItem[]>;
|
|
36
|
+
getQueryRelationReturnType(query: V1_Lambda, source: DataCubeSource): Promise<import("@finos/legend-graph").RelationTypeMetadata>;
|
|
42
37
|
getQueryCodeRelationReturnType(code: string, baseQuery: V1_ValueSpecification, source: DataCubeSource): Promise<import("@finos/legend-graph").RelationTypeMetadata>;
|
|
43
38
|
executeQuery(query: V1_Lambda, source: DataCubeSource): Promise<{
|
|
44
39
|
result: TDSExecutionResult;
|
|
@@ -46,6 +41,10 @@ export declare class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
|
46
41
|
executedSQL: string;
|
|
47
42
|
}>;
|
|
48
43
|
buildExecutionContext(source: DataCubeSource): V1_AppliedFunction | undefined;
|
|
44
|
+
private buildRawLambdaFromValueSpec;
|
|
45
|
+
private getSourceFunctionExpression;
|
|
46
|
+
generateInitialQuery(): Promise<DataCubeQuery>;
|
|
47
|
+
getRelationType(query: RawLambda): Promise<import("@finos/legend-graph").RelationTypeMetadata>;
|
|
49
48
|
}
|
|
50
49
|
export {};
|
|
51
50
|
//# sourceMappingURL=QueryBuilderDataCubeEngine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryBuilderDataCubeEngine.d.ts","sourceRoot":"","sources":["../../../src/stores/data-cube/QueryBuilderDataCubeEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,SAAS,EACT,SAAS,EAET,kBAAkB,EAClB,kBAAkB,EAKlB,KAAK,iBAAiB,EACtB,KAAK,
|
|
1
|
+
{"version":3,"file":"QueryBuilderDataCubeEngine.d.ts","sourceRoot":"","sources":["../../../src/stores/data-cube/QueryBuilderDataCubeEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,SAAS,EACT,SAAS,EAET,kBAAkB,EAClB,kBAAkB,EAKlB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EAGpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,cAAc,EACd,cAAc,EAGd,KAAK,cAAc,EAEnB,aAAa,EACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,UAAU,EACV,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAE9B,cAAM,0BAA2B,SAAQ,cAAc;IACrD,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED,qBAAa,0BAA2B,SAAQ,cAAc;IAC5D,Q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@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
|
37
37
|
this.parameterValues = parameterValues;
|
|
38
38
|
this.parameters = selectQuery.parameters;
|
|
39
39
|
}
|
|
40
|
-
get sourceLabel() {
|
|
41
|
-
return `Query Builder Report`;
|
|
42
|
-
}
|
|
43
|
-
get graph() {
|
|
44
|
-
return this.graphState.graph;
|
|
45
|
-
}
|
|
46
|
-
getSourceFunctionExpression() {
|
|
47
|
-
let srcFuncExp = V1_deserializeValueSpecification(this.graphState.graphManager.serializeRawValueSpecification(this.selectInitialQuery), []);
|
|
48
|
-
// We could do a further check here to ensure the experssion is an applied funciton
|
|
49
|
-
// this is because data cube expects an expression to be able to built further upon the queery
|
|
50
|
-
if (srcFuncExp instanceof V1_Lambda &&
|
|
51
|
-
srcFuncExp.body.length === 1 &&
|
|
52
|
-
srcFuncExp.body[0]) {
|
|
53
|
-
srcFuncExp = srcFuncExp.body[0];
|
|
54
|
-
}
|
|
55
|
-
return srcFuncExp;
|
|
56
|
-
}
|
|
57
|
-
async generateInitialQuery() {
|
|
58
|
-
const srcFuncExp = this.getSourceFunctionExpression();
|
|
59
|
-
const fromFuncExp = new V1_AppliedFunction();
|
|
60
|
-
fromFuncExp.function = _functionName(SUPPORTED_FUNCTIONS.FROM);
|
|
61
|
-
fromFuncExp.parameters = [srcFuncExp];
|
|
62
|
-
if (this.mappingPath) {
|
|
63
|
-
fromFuncExp.parameters.push(_elementPtr(this.mappingPath));
|
|
64
|
-
}
|
|
65
|
-
if (this.runtimePath) {
|
|
66
|
-
fromFuncExp.parameters.push(_elementPtr(this.runtimePath));
|
|
67
|
-
}
|
|
68
|
-
const columns = (await this.getRelationType(this.selectInitialQuery))
|
|
69
|
-
.columns;
|
|
70
|
-
const query = new DataCubeQuery();
|
|
71
|
-
query.query = `~[${columns.map((e) => `'${e.name}'`)}]->select()`;
|
|
72
|
-
return query;
|
|
73
|
-
}
|
|
74
40
|
async processQuerySource(value) {
|
|
75
41
|
// TODO: this is an abnormal usage of this method, this is the place
|
|
76
42
|
// where we can enforce which source this engine supports, instead
|
|
@@ -83,9 +49,11 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
|
83
49
|
source.query = srcFuncExp;
|
|
84
50
|
return source;
|
|
85
51
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
52
|
+
async parseValueSpecification(code, returnSourceInformation) {
|
|
53
|
+
return V1_deserializeValueSpecification(await this.graphState.graphManager.pureCodeToValueSpecification(code, returnSourceInformation), []);
|
|
54
|
+
}
|
|
55
|
+
async getValueSpecificationCode(value, pretty) {
|
|
56
|
+
return this.graphState.graphManager.valueSpecificationToPureCode(V1_serializeValueSpecification(value, []), pretty);
|
|
89
57
|
}
|
|
90
58
|
async getQueryTypeahead(code, baseQuery, source) {
|
|
91
59
|
const lambda = this.buildRawLambdaFromValueSpec(baseQuery);
|
|
@@ -93,18 +61,11 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
|
93
61
|
const offset = queryString.length;
|
|
94
62
|
const codeBlock = queryString + code;
|
|
95
63
|
const finalCode = codeBlock.substring(codeBlock.indexOf(LAMBDA_PIPE) + LAMBDA_PIPE.length, codeBlock.length);
|
|
96
|
-
const result = await this.graphState.graphManager.getCodeComplete(finalCode, this.graph, offset);
|
|
64
|
+
const result = await this.graphState.graphManager.getCodeComplete(finalCode, this.graphState.graph, offset);
|
|
97
65
|
return result.completions;
|
|
98
66
|
}
|
|
99
|
-
async
|
|
100
|
-
return
|
|
101
|
-
}
|
|
102
|
-
async getValueSpecificationCode(value, pretty) {
|
|
103
|
-
return this.graphState.graphManager.valueSpecificationToPureCode(V1_serializeValueSpecification(value, []), pretty);
|
|
104
|
-
}
|
|
105
|
-
async getRelationType(query) {
|
|
106
|
-
const relationType = await this.graphState.graphManager.getLambdaRelationType(query, this.graph);
|
|
107
|
-
return relationType;
|
|
67
|
+
async getQueryRelationReturnType(query, source) {
|
|
68
|
+
return this.getRelationType(this.buildRawLambdaFromValueSpec(query));
|
|
108
69
|
}
|
|
109
70
|
async getQueryCodeRelationReturnType(code, baseQuery, source) {
|
|
110
71
|
const queryString = await this.graphState.graphManager.valueSpecificationToPureCode(V1_serializeValueSpecification(baseQuery, []));
|
|
@@ -115,7 +76,7 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
|
115
76
|
const lambda = this.buildRawLambdaFromValueSpec(query);
|
|
116
77
|
lambda.parameters = this.parameters;
|
|
117
78
|
const [executionWithMetadata, queryString] = await Promise.all([
|
|
118
|
-
this.graphState.graphManager.runQuery(lambda, undefined, undefined, this.graph, {
|
|
79
|
+
this.graphState.graphManager.runQuery(lambda, undefined, undefined, this.graphState.graph, {
|
|
119
80
|
parameterValues: this.parameterValues ?? [],
|
|
120
81
|
}),
|
|
121
82
|
this.graphState.graphManager.lambdaToPureCode(lambda),
|
|
@@ -144,5 +105,42 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
|
144
105
|
}
|
|
145
106
|
return undefined;
|
|
146
107
|
}
|
|
108
|
+
// ---------------------------------- UTILITIES ----------------------------------
|
|
109
|
+
buildRawLambdaFromValueSpec(query) {
|
|
110
|
+
const json = guaranteeType(V1_deserializeRawValueSpecification(V1_serializeValueSpecification(query, [])), V1_RawLambda);
|
|
111
|
+
return new RawLambda(json.parameters, json.body);
|
|
112
|
+
}
|
|
113
|
+
getSourceFunctionExpression() {
|
|
114
|
+
let srcFuncExp = V1_deserializeValueSpecification(this.graphState.graphManager.serializeRawValueSpecification(this.selectInitialQuery), []);
|
|
115
|
+
// We could do a further check here to ensure the experssion is an applied funciton
|
|
116
|
+
// this is because data cube expects an expression to be able to built further upon the queery
|
|
117
|
+
if (srcFuncExp instanceof V1_Lambda &&
|
|
118
|
+
srcFuncExp.body.length === 1 &&
|
|
119
|
+
srcFuncExp.body[0]) {
|
|
120
|
+
srcFuncExp = srcFuncExp.body[0];
|
|
121
|
+
}
|
|
122
|
+
return srcFuncExp;
|
|
123
|
+
}
|
|
124
|
+
async generateInitialQuery() {
|
|
125
|
+
const srcFuncExp = this.getSourceFunctionExpression();
|
|
126
|
+
const fromFuncExp = new V1_AppliedFunction();
|
|
127
|
+
fromFuncExp.function = _functionName(SUPPORTED_FUNCTIONS.FROM);
|
|
128
|
+
fromFuncExp.parameters = [srcFuncExp];
|
|
129
|
+
if (this.mappingPath) {
|
|
130
|
+
fromFuncExp.parameters.push(_elementPtr(this.mappingPath));
|
|
131
|
+
}
|
|
132
|
+
if (this.runtimePath) {
|
|
133
|
+
fromFuncExp.parameters.push(_elementPtr(this.runtimePath));
|
|
134
|
+
}
|
|
135
|
+
const columns = (await this.getRelationType(this.selectInitialQuery))
|
|
136
|
+
.columns;
|
|
137
|
+
const query = new DataCubeQuery();
|
|
138
|
+
query.query = `~[${columns.map((e) => `'${e.name}'`)}]->select()`;
|
|
139
|
+
return query;
|
|
140
|
+
}
|
|
141
|
+
async getRelationType(query) {
|
|
142
|
+
const relationType = await this.graphState.graphManager.getLambdaRelationType(query, this.graphState.graph);
|
|
143
|
+
return relationType;
|
|
144
|
+
}
|
|
147
145
|
}
|
|
148
146
|
//# sourceMappingURL=QueryBuilderDataCubeEngine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryBuilderDataCubeEngine.js","sourceRoot":"","sources":["../../../src/stores/data-cube/QueryBuilderDataCubeEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,SAAS,EACT,SAAS,EACT,6BAA6B,EAC7B,kBAAkB,EAClB,kBAAkB,EAClB,mCAAmC,EACnC,gCAAgC,EAChC,YAAY,EACZ,8BAA8B,
|
|
1
|
+
{"version":3,"file":"QueryBuilderDataCubeEngine.js","sourceRoot":"","sources":["../../../src/stores/data-cube/QueryBuilderDataCubeEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,SAAS,EACT,SAAS,EACT,6BAA6B,EAC7B,kBAAk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CAAC,KAAgB;QACpC,MAAM,YAAY,GAChB,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,qBAAqB,CACtD,KAAK,EACL,IAAI,CAAC,UAAU,CAAC,KAAK,CACtB,CAAC;QACJ,OAAO,YAAY,CAAC;IACtB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finos/legend-query-builder",
|
|
3
|
-
"version": "4.15.
|
|
3
|
+
"version": "4.15.42",
|
|
4
4
|
"description": "Legend query builder core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"legend",
|
|
@@ -42,18 +42,18 @@
|
|
|
42
42
|
"test:watch": "jest --watch"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@finos/legend-application": "16.0.
|
|
46
|
-
"@finos/legend-art": "7.1.
|
|
47
|
-
"@finos/legend-code-editor": "2.0.
|
|
48
|
-
"@finos/legend-data-cube": "0.0.
|
|
49
|
-
"@finos/legend-graph": "32.0.
|
|
50
|
-
"@finos/legend-lego": "2.0.
|
|
45
|
+
"@finos/legend-application": "16.0.21",
|
|
46
|
+
"@finos/legend-art": "7.1.78",
|
|
47
|
+
"@finos/legend-code-editor": "2.0.37",
|
|
48
|
+
"@finos/legend-data-cube": "0.0.44",
|
|
49
|
+
"@finos/legend-graph": "32.0.5",
|
|
50
|
+
"@finos/legend-lego": "2.0.40",
|
|
51
51
|
"@finos/legend-server-depot": "6.0.77",
|
|
52
52
|
"@finos/legend-shared": "11.0.0",
|
|
53
53
|
"@finos/legend-storage": "3.0.119",
|
|
54
54
|
"@testing-library/dom": "10.4.0",
|
|
55
|
-
"@testing-library/react": "16.
|
|
56
|
-
"@types/react": "19.0.
|
|
55
|
+
"@testing-library/react": "16.2.0",
|
|
56
|
+
"@types/react": "19.0.8",
|
|
57
57
|
"@types/react-dom": "19.0.3",
|
|
58
58
|
"chart.js": "4.4.7",
|
|
59
59
|
"mathjs": "14.0.1",
|
|
@@ -25,7 +25,6 @@ import {
|
|
|
25
25
|
V1_RawLambda,
|
|
26
26
|
V1_serializeValueSpecification,
|
|
27
27
|
type GraphManagerState,
|
|
28
|
-
type PureModel,
|
|
29
28
|
type V1_ValueSpecification,
|
|
30
29
|
type ParameterValue,
|
|
31
30
|
LAMBDA_PIPE,
|
|
@@ -79,53 +78,7 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
|
79
78
|
this.parameters = selectQuery.parameters;
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
|
|
83
|
-
return `Query Builder Report`;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
get graph(): PureModel {
|
|
87
|
-
return this.graphState.graph;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
private getSourceFunctionExpression() {
|
|
91
|
-
let srcFuncExp = V1_deserializeValueSpecification(
|
|
92
|
-
this.graphState.graphManager.serializeRawValueSpecification(
|
|
93
|
-
this.selectInitialQuery,
|
|
94
|
-
),
|
|
95
|
-
[],
|
|
96
|
-
);
|
|
97
|
-
// We could do a further check here to ensure the experssion is an applied funciton
|
|
98
|
-
// this is because data cube expects an expression to be able to built further upon the queery
|
|
99
|
-
if (
|
|
100
|
-
srcFuncExp instanceof V1_Lambda &&
|
|
101
|
-
srcFuncExp.body.length === 1 &&
|
|
102
|
-
srcFuncExp.body[0]
|
|
103
|
-
) {
|
|
104
|
-
srcFuncExp = srcFuncExp.body[0];
|
|
105
|
-
}
|
|
106
|
-
return srcFuncExp;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async generateInitialQuery() {
|
|
110
|
-
const srcFuncExp = this.getSourceFunctionExpression();
|
|
111
|
-
const fromFuncExp = new V1_AppliedFunction();
|
|
112
|
-
fromFuncExp.function = _functionName(SUPPORTED_FUNCTIONS.FROM);
|
|
113
|
-
fromFuncExp.parameters = [srcFuncExp];
|
|
114
|
-
if (this.mappingPath) {
|
|
115
|
-
fromFuncExp.parameters.push(_elementPtr(this.mappingPath));
|
|
116
|
-
}
|
|
117
|
-
if (this.runtimePath) {
|
|
118
|
-
fromFuncExp.parameters.push(_elementPtr(this.runtimePath));
|
|
119
|
-
}
|
|
120
|
-
const columns = (await this.getRelationType(this.selectInitialQuery))
|
|
121
|
-
.columns;
|
|
122
|
-
const query = new DataCubeQuery();
|
|
123
|
-
query.query = `~[${columns.map((e) => `'${e.name}'`)}]->select()`;
|
|
124
|
-
|
|
125
|
-
return query;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
async processQuerySource(value: PlainObject) {
|
|
81
|
+
override async processQuerySource(value: PlainObject) {
|
|
129
82
|
// TODO: this is an abnormal usage of this method, this is the place
|
|
130
83
|
// where we can enforce which source this engine supports, instead
|
|
131
84
|
// of hardcoding the logic like this.
|
|
@@ -140,17 +93,30 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
|
140
93
|
return source;
|
|
141
94
|
}
|
|
142
95
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
96
|
+
override async parseValueSpecification(
|
|
97
|
+
code: string,
|
|
98
|
+
returnSourceInformation?: boolean,
|
|
99
|
+
) {
|
|
100
|
+
return V1_deserializeValueSpecification(
|
|
101
|
+
await this.graphState.graphManager.pureCodeToValueSpecification(
|
|
102
|
+
code,
|
|
103
|
+
returnSourceInformation,
|
|
147
104
|
),
|
|
148
|
-
|
|
105
|
+
[],
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
override async getValueSpecificationCode(
|
|
110
|
+
value: V1_ValueSpecification,
|
|
111
|
+
pretty?: boolean | undefined,
|
|
112
|
+
) {
|
|
113
|
+
return this.graphState.graphManager.valueSpecificationToPureCode(
|
|
114
|
+
V1_serializeValueSpecification(value, []),
|
|
115
|
+
pretty,
|
|
149
116
|
);
|
|
150
|
-
return new RawLambda(json.parameters, json.body);
|
|
151
117
|
}
|
|
152
118
|
|
|
153
|
-
async getQueryTypeahead(
|
|
119
|
+
override async getQueryTypeahead(
|
|
154
120
|
code: string,
|
|
155
121
|
baseQuery: V1_Lambda,
|
|
156
122
|
source: DataCubeSource,
|
|
@@ -166,42 +132,17 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
|
166
132
|
);
|
|
167
133
|
const result = await this.graphState.graphManager.getCodeComplete(
|
|
168
134
|
finalCode,
|
|
169
|
-
this.graph,
|
|
135
|
+
this.graphState.graph,
|
|
170
136
|
offset,
|
|
171
137
|
);
|
|
172
138
|
return result.completions as CompletionItem[];
|
|
173
139
|
}
|
|
174
140
|
|
|
175
|
-
override async
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
) {
|
|
179
|
-
return V1_deserializeValueSpecification(
|
|
180
|
-
await this.graphState.graphManager.pureCodeToValueSpecification(
|
|
181
|
-
code,
|
|
182
|
-
returnSourceInformation,
|
|
183
|
-
),
|
|
184
|
-
[],
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
override async getValueSpecificationCode(
|
|
189
|
-
value: V1_ValueSpecification,
|
|
190
|
-
pretty?: boolean | undefined,
|
|
141
|
+
override async getQueryRelationReturnType(
|
|
142
|
+
query: V1_Lambda,
|
|
143
|
+
source: DataCubeSource,
|
|
191
144
|
) {
|
|
192
|
-
return this.
|
|
193
|
-
V1_serializeValueSpecification(value, []),
|
|
194
|
-
pretty,
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
async getRelationType(query: RawLambda) {
|
|
199
|
-
const relationType =
|
|
200
|
-
await this.graphState.graphManager.getLambdaRelationType(
|
|
201
|
-
query,
|
|
202
|
-
this.graph,
|
|
203
|
-
);
|
|
204
|
-
return relationType;
|
|
145
|
+
return this.getRelationType(this.buildRawLambdaFromValueSpec(query));
|
|
205
146
|
}
|
|
206
147
|
|
|
207
148
|
override async getQueryCodeRelationReturnType(
|
|
@@ -227,7 +168,7 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
|
227
168
|
lambda,
|
|
228
169
|
undefined,
|
|
229
170
|
undefined,
|
|
230
|
-
this.graph,
|
|
171
|
+
this.graphState.graph,
|
|
231
172
|
{
|
|
232
173
|
parameterValues: this.parameterValues ?? [],
|
|
233
174
|
},
|
|
@@ -268,4 +209,63 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
|
|
|
268
209
|
}
|
|
269
210
|
return undefined;
|
|
270
211
|
}
|
|
212
|
+
|
|
213
|
+
// ---------------------------------- UTILITIES ----------------------------------
|
|
214
|
+
|
|
215
|
+
private buildRawLambdaFromValueSpec(query: V1_Lambda): RawLambda {
|
|
216
|
+
const json = guaranteeType(
|
|
217
|
+
V1_deserializeRawValueSpecification(
|
|
218
|
+
V1_serializeValueSpecification(query, []),
|
|
219
|
+
),
|
|
220
|
+
V1_RawLambda,
|
|
221
|
+
);
|
|
222
|
+
return new RawLambda(json.parameters, json.body);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private getSourceFunctionExpression() {
|
|
226
|
+
let srcFuncExp = V1_deserializeValueSpecification(
|
|
227
|
+
this.graphState.graphManager.serializeRawValueSpecification(
|
|
228
|
+
this.selectInitialQuery,
|
|
229
|
+
),
|
|
230
|
+
[],
|
|
231
|
+
);
|
|
232
|
+
// We could do a further check here to ensure the experssion is an applied funciton
|
|
233
|
+
// this is because data cube expects an expression to be able to built further upon the queery
|
|
234
|
+
if (
|
|
235
|
+
srcFuncExp instanceof V1_Lambda &&
|
|
236
|
+
srcFuncExp.body.length === 1 &&
|
|
237
|
+
srcFuncExp.body[0]
|
|
238
|
+
) {
|
|
239
|
+
srcFuncExp = srcFuncExp.body[0];
|
|
240
|
+
}
|
|
241
|
+
return srcFuncExp;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
async generateInitialQuery() {
|
|
245
|
+
const srcFuncExp = this.getSourceFunctionExpression();
|
|
246
|
+
const fromFuncExp = new V1_AppliedFunction();
|
|
247
|
+
fromFuncExp.function = _functionName(SUPPORTED_FUNCTIONS.FROM);
|
|
248
|
+
fromFuncExp.parameters = [srcFuncExp];
|
|
249
|
+
if (this.mappingPath) {
|
|
250
|
+
fromFuncExp.parameters.push(_elementPtr(this.mappingPath));
|
|
251
|
+
}
|
|
252
|
+
if (this.runtimePath) {
|
|
253
|
+
fromFuncExp.parameters.push(_elementPtr(this.runtimePath));
|
|
254
|
+
}
|
|
255
|
+
const columns = (await this.getRelationType(this.selectInitialQuery))
|
|
256
|
+
.columns;
|
|
257
|
+
const query = new DataCubeQuery();
|
|
258
|
+
query.query = `~[${columns.map((e) => `'${e.name}'`)}]->select()`;
|
|
259
|
+
|
|
260
|
+
return query;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async getRelationType(query: RawLambda) {
|
|
264
|
+
const relationType =
|
|
265
|
+
await this.graphState.graphManager.getLambdaRelationType(
|
|
266
|
+
query,
|
|
267
|
+
this.graphState.graph,
|
|
268
|
+
);
|
|
269
|
+
return relationType;
|
|
270
|
+
}
|
|
271
271
|
}
|