@vizzly/semantic-layer-public 0.0.204 → 0.0.205-rc-2
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/dist/QueryEngineConfig/bigquery.d.ts +2 -2
- package/dist/QueryEngineConfig/bigquery.js +10 -3
- package/dist/QueryEngineConfig/constants.d.ts +4 -3
- package/dist/QueryEngineConfig/constants.js +130 -52
- package/dist/QueryEngineConfig/downcast.d.ts +2 -0
- package/dist/QueryEngineConfig/downcast.js +47 -0
- package/dist/QueryEngineConfig/getQueryEngineConfig.d.ts +2 -2
- package/dist/QueryEngineConfig/helpers.d.ts +10 -0
- package/dist/QueryEngineConfig/helpers.js +43 -0
- package/dist/QueryEngineConfig/index.d.ts +3 -0
- package/dist/QueryEngineConfig/index.js +3 -0
- package/dist/QueryEngineConfig/localJS.d.ts +2 -2
- package/dist/QueryEngineConfig/localJS.js +11 -3
- package/dist/QueryEngineConfig/mariadb.d.ts +2 -2
- package/dist/QueryEngineConfig/mariadb.js +17 -3
- package/dist/QueryEngineConfig/merge.d.ts +2 -2
- package/dist/QueryEngineConfig/merge.js +2 -3
- package/dist/QueryEngineConfig/microsoftSQLServer.d.ts +2 -2
- package/dist/QueryEngineConfig/microsoftSQLServer.js +10 -3
- package/dist/QueryEngineConfig/mysql.d.ts +2 -2
- package/dist/QueryEngineConfig/mysql.js +17 -3
- package/dist/QueryEngineConfig/postgres.d.ts +2 -2
- package/dist/QueryEngineConfig/postgres.js +4 -4
- package/dist/QueryEngineConfig/redshift.d.ts +2 -2
- package/dist/QueryEngineConfig/redshift.js +10 -3
- package/dist/QueryEngineConfig/snowflake.d.ts +2 -2
- package/dist/QueryEngineConfig/snowflake.js +4 -4
- package/dist/QueryEngineConfig/support.d.ts +6 -13
- package/dist/QueryEngineConfig/support.js +11 -69
- package/dist/QueryEngineConfig/types.d.ts +23 -0
- package/dist/QueryEngineConfig/upcast.d.ts +2 -0
- package/dist/QueryEngineConfig/upcast.js +48 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const queryEngineConfig: () =>
|
|
1
|
+
import { QueryEngineConfigV1 } from './types';
|
|
2
|
+
export declare const queryEngineConfig: () => QueryEngineConfigV1;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.queryEngineConfig = void 0;
|
|
4
4
|
const support_1 = require("./support");
|
|
5
5
|
const queryEngineConfig = () => ({
|
|
6
|
+
version: 1,
|
|
6
7
|
origin: 'query-engine',
|
|
7
8
|
supportedFeatures: [
|
|
8
9
|
'simpleMaths',
|
|
@@ -16,7 +17,7 @@ const queryEngineConfig = () => ({
|
|
|
16
17
|
'sqlViews',
|
|
17
18
|
'dateMaths',
|
|
18
19
|
],
|
|
19
|
-
|
|
20
|
+
supportedFunctions: (0, support_1.supportedFunctions)([
|
|
20
21
|
'month',
|
|
21
22
|
'year',
|
|
22
23
|
'quarter',
|
|
@@ -25,8 +26,15 @@ const queryEngineConfig = () => ({
|
|
|
25
26
|
'hour',
|
|
26
27
|
'minute',
|
|
27
28
|
'second',
|
|
29
|
+
'sum',
|
|
30
|
+
'mean',
|
|
31
|
+
'min',
|
|
32
|
+
'max',
|
|
33
|
+
'count',
|
|
34
|
+
'countDistinct',
|
|
35
|
+
'round_to_0_dp',
|
|
36
|
+
'round_to_2_dp',
|
|
28
37
|
]),
|
|
29
|
-
supportedAggregates: (0, support_1.supportedAggregates)(['sum', 'mean', 'min', 'max', 'count', 'countDistinct']),
|
|
30
38
|
supportedOperators: (0, support_1.supportedOperators)([
|
|
31
39
|
'>',
|
|
32
40
|
'<',
|
|
@@ -43,6 +51,5 @@ const queryEngineConfig = () => ({
|
|
|
43
51
|
'array_contains',
|
|
44
52
|
'array_does_not_contain',
|
|
45
53
|
]),
|
|
46
|
-
supportedTransformationFunctions: (0, support_1.supportedTransformationFunctions)(['round_to_0_dp', 'round_to_2_dp']),
|
|
47
54
|
});
|
|
48
55
|
exports.queryEngineConfig = queryEngineConfig;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QueryEngineConfigV1, SupportedOperators } from './types';
|
|
2
2
|
export declare const supportedOperatorsConstants: SupportedOperators;
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
3
|
+
/** Map a function to it's default public name. */
|
|
4
|
+
export declare const functionToPublicName: (functionName: string) => string;
|
|
5
|
+
export declare const SUPPORTED_FUNCTIONS: QueryEngineConfigV1['supportedFunctions'];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.SUPPORTED_FUNCTIONS = exports.functionToPublicName = exports.supportedOperatorsConstants = void 0;
|
|
4
4
|
exports.supportedOperatorsConstants = {
|
|
5
5
|
'>': {
|
|
6
6
|
publicName: 'Greater than',
|
|
@@ -67,103 +67,181 @@ exports.supportedOperatorsConstants = {
|
|
|
67
67
|
validDataTypes: ['string[]'],
|
|
68
68
|
},
|
|
69
69
|
};
|
|
70
|
-
|
|
70
|
+
/** Map a function to it's default public name. */
|
|
71
|
+
const functionToPublicName = (functionName) => {
|
|
72
|
+
const publicName = {
|
|
73
|
+
month: 'Monthly',
|
|
74
|
+
year: 'Yearly',
|
|
75
|
+
quarter: 'Per quarter',
|
|
76
|
+
week: 'Weekly',
|
|
77
|
+
day: 'Daily',
|
|
78
|
+
hourOfDayOnly: 'Hour of day',
|
|
79
|
+
weekOfYearOnly: 'Week of year',
|
|
80
|
+
dayOfWeekOnly: 'Day of week',
|
|
81
|
+
dayOfMonthOnly: 'Day of month',
|
|
82
|
+
second: 'Per second',
|
|
83
|
+
hour: 'Hourly',
|
|
84
|
+
minute: 'Per minute',
|
|
85
|
+
mean: 'Mean',
|
|
86
|
+
sum: 'Sum',
|
|
87
|
+
min: 'Min',
|
|
88
|
+
max: 'Max',
|
|
89
|
+
count: 'Count',
|
|
90
|
+
countDistinct: 'Unique',
|
|
91
|
+
median: 'Median',
|
|
92
|
+
percentile25: '25th percentile',
|
|
93
|
+
percentile75: '75th percentile',
|
|
94
|
+
percentile90: '90th percentile',
|
|
95
|
+
percentile95: '95th percentile',
|
|
96
|
+
percentile99: '99th percentile',
|
|
97
|
+
round_to_0_dp: 'Round to 0dp',
|
|
98
|
+
round_to_2_dp: 'Round to 2dp',
|
|
99
|
+
}[functionName];
|
|
100
|
+
if (publicName)
|
|
101
|
+
return publicName;
|
|
102
|
+
console.warn(`Missing public name for function '${functionName}'.`);
|
|
103
|
+
return functionName;
|
|
104
|
+
};
|
|
105
|
+
exports.functionToPublicName = functionToPublicName;
|
|
106
|
+
exports.SUPPORTED_FUNCTIONS = {
|
|
107
|
+
// rounding
|
|
108
|
+
round_to_0_dp: {
|
|
109
|
+
useFor: ['transform'],
|
|
110
|
+
inputDataTypes: ['number'],
|
|
111
|
+
outputDataType: 'number',
|
|
112
|
+
},
|
|
113
|
+
round_to_2_dp: {
|
|
114
|
+
useFor: ['transform'],
|
|
115
|
+
inputDataTypes: ['number'],
|
|
116
|
+
outputDataType: 'number',
|
|
117
|
+
},
|
|
118
|
+
// times
|
|
71
119
|
month: {
|
|
72
|
-
|
|
73
|
-
|
|
120
|
+
useFor: ['transform'],
|
|
121
|
+
inputDataTypes: ['date_time'],
|
|
122
|
+
outputDataType: 'date_time',
|
|
74
123
|
},
|
|
75
124
|
year: {
|
|
76
|
-
|
|
77
|
-
|
|
125
|
+
useFor: ['transform'],
|
|
126
|
+
inputDataTypes: ['date_time'],
|
|
127
|
+
outputDataType: 'date_time',
|
|
78
128
|
},
|
|
79
129
|
quarter: {
|
|
80
|
-
|
|
81
|
-
|
|
130
|
+
useFor: ['transform'],
|
|
131
|
+
inputDataTypes: ['date_time'],
|
|
132
|
+
outputDataType: 'date_time',
|
|
82
133
|
},
|
|
83
134
|
week: {
|
|
84
|
-
|
|
85
|
-
|
|
135
|
+
useFor: ['transform'],
|
|
136
|
+
inputDataTypes: ['date_time'],
|
|
137
|
+
outputDataType: 'date_time',
|
|
86
138
|
},
|
|
87
139
|
day: {
|
|
88
|
-
|
|
89
|
-
|
|
140
|
+
useFor: ['transform'],
|
|
141
|
+
inputDataTypes: ['date_time'],
|
|
142
|
+
outputDataType: 'date_time',
|
|
90
143
|
},
|
|
91
144
|
hourOfDayOnly: {
|
|
92
|
-
|
|
93
|
-
|
|
145
|
+
useFor: ['transform'],
|
|
146
|
+
inputDataTypes: ['date_time'],
|
|
147
|
+
outputDataType: 'number',
|
|
94
148
|
},
|
|
95
149
|
weekOfYearOnly: {
|
|
96
|
-
|
|
97
|
-
|
|
150
|
+
useFor: ['transform'],
|
|
151
|
+
inputDataTypes: ['date_time'],
|
|
152
|
+
outputDataType: 'number',
|
|
98
153
|
},
|
|
99
154
|
dayOfWeekOnly: {
|
|
100
|
-
|
|
101
|
-
|
|
155
|
+
useFor: ['transform'],
|
|
156
|
+
inputDataTypes: ['date_time'],
|
|
157
|
+
outputDataType: 'number',
|
|
102
158
|
},
|
|
103
159
|
dayOfMonthOnly: {
|
|
104
|
-
|
|
105
|
-
|
|
160
|
+
useFor: ['transform'],
|
|
161
|
+
inputDataTypes: ['date_time'],
|
|
162
|
+
outputDataType: 'number',
|
|
106
163
|
},
|
|
107
164
|
second: {
|
|
108
|
-
|
|
109
|
-
|
|
165
|
+
useFor: ['transform'],
|
|
166
|
+
inputDataTypes: ['date_time'],
|
|
167
|
+
outputDataType: 'date_time',
|
|
110
168
|
},
|
|
111
169
|
hour: {
|
|
112
|
-
|
|
113
|
-
|
|
170
|
+
useFor: ['transform'],
|
|
171
|
+
inputDataTypes: ['date_time'],
|
|
172
|
+
outputDataType: 'date_time',
|
|
114
173
|
},
|
|
115
174
|
minute: {
|
|
116
|
-
|
|
117
|
-
|
|
175
|
+
useFor: ['transform'],
|
|
176
|
+
inputDataTypes: ['date_time'],
|
|
177
|
+
outputDataType: 'date_time',
|
|
118
178
|
},
|
|
119
|
-
|
|
120
|
-
exports.supportedAggregatesConstants = {
|
|
179
|
+
// aggregates
|
|
121
180
|
mean: {
|
|
122
|
-
|
|
123
|
-
|
|
181
|
+
useFor: ['aggregate'],
|
|
182
|
+
inputDataTypes: ['number'],
|
|
183
|
+
outputDataType: 'number',
|
|
124
184
|
},
|
|
125
185
|
sum: {
|
|
126
|
-
|
|
127
|
-
|
|
186
|
+
useFor: ['aggregate'],
|
|
187
|
+
inputDataTypes: ['number'],
|
|
188
|
+
outputDataType: 'number',
|
|
128
189
|
},
|
|
129
190
|
min: {
|
|
130
|
-
|
|
131
|
-
|
|
191
|
+
useFor: ['aggregate'],
|
|
192
|
+
inputDataTypes: ['number'],
|
|
193
|
+
outputDataType: 'number',
|
|
132
194
|
},
|
|
133
195
|
max: {
|
|
134
|
-
|
|
135
|
-
|
|
196
|
+
useFor: ['aggregate'],
|
|
197
|
+
inputDataTypes: ['number'],
|
|
198
|
+
outputDataType: 'number',
|
|
136
199
|
},
|
|
137
200
|
count: {
|
|
138
|
-
|
|
139
|
-
|
|
201
|
+
useFor: ['aggregate'],
|
|
202
|
+
inputDataTypes: ['string', 'number', 'boolean', 'date_time', 'string[]'],
|
|
203
|
+
outputDataType: 'number',
|
|
140
204
|
},
|
|
141
205
|
countDistinct: {
|
|
142
|
-
|
|
143
|
-
|
|
206
|
+
useFor: ['aggregate'],
|
|
207
|
+
inputDataTypes: ['string', 'number', 'boolean', 'date_time'],
|
|
208
|
+
outputDataType: 'number',
|
|
144
209
|
},
|
|
145
210
|
median: {
|
|
146
|
-
|
|
147
|
-
|
|
211
|
+
useFor: ['aggregate'],
|
|
212
|
+
inputDataTypes: ['number'],
|
|
213
|
+
outputDataType: 'number',
|
|
148
214
|
},
|
|
149
215
|
percentile25: {
|
|
150
|
-
|
|
151
|
-
|
|
216
|
+
useFor: ['aggregate'],
|
|
217
|
+
inputDataTypes: ['number'],
|
|
218
|
+
outputDataType: 'number',
|
|
152
219
|
},
|
|
153
220
|
percentile75: {
|
|
154
|
-
|
|
155
|
-
|
|
221
|
+
useFor: ['aggregate'],
|
|
222
|
+
inputDataTypes: ['number'],
|
|
223
|
+
outputDataType: 'number',
|
|
156
224
|
},
|
|
157
225
|
percentile90: {
|
|
158
|
-
|
|
159
|
-
|
|
226
|
+
useFor: ['aggregate'],
|
|
227
|
+
inputDataTypes: ['number'],
|
|
228
|
+
outputDataType: 'number',
|
|
160
229
|
},
|
|
161
230
|
percentile95: {
|
|
162
|
-
|
|
163
|
-
|
|
231
|
+
useFor: ['aggregate'],
|
|
232
|
+
inputDataTypes: ['number'],
|
|
233
|
+
outputDataType: 'number',
|
|
164
234
|
},
|
|
165
235
|
percentile99: {
|
|
166
|
-
|
|
167
|
-
|
|
236
|
+
useFor: ['aggregate'],
|
|
237
|
+
inputDataTypes: ['number'],
|
|
238
|
+
outputDataType: 'number',
|
|
168
239
|
},
|
|
169
240
|
};
|
|
241
|
+
// {
|
|
242
|
+
// [id: string]: {
|
|
243
|
+
// useFor: Array<'aggregate' | 'transform'>;
|
|
244
|
+
// inputDataTypes: Array<NormalizedDataType>;
|
|
245
|
+
// outputDataType: NormalizedDataType;
|
|
246
|
+
// };
|
|
247
|
+
// }
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.downcast = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const downcast = (maybeOldQueryEngineConfig) => {
|
|
6
|
+
if (!('version' in maybeOldQueryEngineConfig)) {
|
|
7
|
+
return maybeOldQueryEngineConfig;
|
|
8
|
+
}
|
|
9
|
+
let supportedAggregates = {};
|
|
10
|
+
let supportedTimeTruncFunctions = {};
|
|
11
|
+
let supportedTransformationFunctions = {};
|
|
12
|
+
if ('supportedFunctions' in maybeOldQueryEngineConfig) {
|
|
13
|
+
Object.keys(maybeOldQueryEngineConfig.supportedFunctions).forEach((func) => {
|
|
14
|
+
const f = maybeOldQueryEngineConfig.supportedFunctions[func];
|
|
15
|
+
if (f.useFor.includes('aggregate')) {
|
|
16
|
+
supportedAggregates[func] = {
|
|
17
|
+
publicName: (0, constants_1.functionToPublicName)(func),
|
|
18
|
+
validDataTypes: f.inputDataTypes,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
else if (f.outputDataType == 'date_time') {
|
|
22
|
+
supportedTimeTruncFunctions[func] = {
|
|
23
|
+
publicName: (0, constants_1.functionToPublicName)(func),
|
|
24
|
+
dateFormat: supportedTimeTruncFunctions[func].dateFormat,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
else if (['round_to_0_dp', 'round_to_2_dp'].includes(func)) {
|
|
28
|
+
supportedTransformationFunctions[func] = {
|
|
29
|
+
publicName: (0, constants_1.functionToPublicName)(func),
|
|
30
|
+
validDataTypes: f.inputDataTypes,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.warn(`[VIZZLY] ignoring downcasting function ${func}`);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
origin: maybeOldQueryEngineConfig.origin,
|
|
40
|
+
supportedFeatures: maybeOldQueryEngineConfig.supportedFeatures,
|
|
41
|
+
supportedOperators: maybeOldQueryEngineConfig.supportedOperators,
|
|
42
|
+
supportedAggregates,
|
|
43
|
+
supportedTimeTruncFunctions,
|
|
44
|
+
supportedTransformationFunctions,
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
exports.downcast = downcast;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Client } from '@vizzly/sqlbuilder-public';
|
|
2
|
-
import {
|
|
3
|
-
export declare const getQueryEngineConfig: (client: Client | 'js') =>
|
|
2
|
+
import { QueryEngineConfigV1 } from './types';
|
|
3
|
+
export declare const getQueryEngineConfig: (client: Client | 'js') => QueryEngineConfigV1;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { QueryEngineConfigV1 } from './types';
|
|
2
|
+
export declare const takeTimeFunctions: (queryEngineConfig: QueryEngineConfigV1) => string[];
|
|
3
|
+
/** Is the value any query engine function? */
|
|
4
|
+
export declare const isQueryEngineFunction: (queryEngineConfig: QueryEngineConfigV1, possible: string) => boolean;
|
|
5
|
+
/** Is the given value an aggregate function? */
|
|
6
|
+
export declare const isAggregateFunction: (queryEngineConfig: QueryEngineConfigV1, possibleAggregateFunction: string) => boolean;
|
|
7
|
+
/** Is the given value a time trunc function? */
|
|
8
|
+
export declare const isTimeTruncFunction: (queryEngineConfig: QueryEngineConfigV1, possibleTimeTruncFunction: string) => boolean;
|
|
9
|
+
/** Is the given value a transformation function? */
|
|
10
|
+
export declare const isTransformationFunction: (queryEngineConfig: QueryEngineConfigV1, possibleTransformationFunction: string) => boolean;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTransformationFunction = exports.isTimeTruncFunction = exports.isAggregateFunction = exports.isQueryEngineFunction = exports.takeTimeFunctions = void 0;
|
|
4
|
+
const takeTimeFunctions = (queryEngineConfig) => {
|
|
5
|
+
const funcs = Object.keys(queryEngineConfig.supportedFunctions);
|
|
6
|
+
return funcs.filter((fn) => {
|
|
7
|
+
return queryEngineConfig.supportedFunctions[fn].inputDataTypes.includes('date_time');
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
exports.takeTimeFunctions = takeTimeFunctions;
|
|
11
|
+
/** Is the value any query engine function? */
|
|
12
|
+
const isQueryEngineFunction = (queryEngineConfig, possible) => {
|
|
13
|
+
const allAggregateFunctions = Object.keys(queryEngineConfig.supportedFunctions);
|
|
14
|
+
return allAggregateFunctions.includes(possible);
|
|
15
|
+
};
|
|
16
|
+
exports.isQueryEngineFunction = isQueryEngineFunction;
|
|
17
|
+
/** Is the given value an aggregate function? */
|
|
18
|
+
const isAggregateFunction = (queryEngineConfig, possibleAggregateFunction) => {
|
|
19
|
+
const allAggregateFunctions = Object.keys(queryEngineConfig.supportedFunctions).filter((funcName) => {
|
|
20
|
+
const sF = queryEngineConfig.supportedFunctions[funcName];
|
|
21
|
+
return sF.useFor.includes('aggregate');
|
|
22
|
+
});
|
|
23
|
+
return allAggregateFunctions.includes(possibleAggregateFunction);
|
|
24
|
+
};
|
|
25
|
+
exports.isAggregateFunction = isAggregateFunction;
|
|
26
|
+
/** Is the given value a time trunc function? */
|
|
27
|
+
const isTimeTruncFunction = (queryEngineConfig, possibleTimeTruncFunction) => {
|
|
28
|
+
const allTimeTruncFunctions = Object.keys(queryEngineConfig.supportedFunctions).filter((funcName) => {
|
|
29
|
+
const sF = queryEngineConfig.supportedFunctions[funcName];
|
|
30
|
+
return (sF.useFor.includes('transform') && sF.inputDataTypes.includes('date_time') && sF.outputDataType === 'date_time');
|
|
31
|
+
});
|
|
32
|
+
return allTimeTruncFunctions.includes(possibleTimeTruncFunction);
|
|
33
|
+
};
|
|
34
|
+
exports.isTimeTruncFunction = isTimeTruncFunction;
|
|
35
|
+
/** Is the given value a transformation function? */
|
|
36
|
+
const isTransformationFunction = (queryEngineConfig, possibleTransformationFunction) => {
|
|
37
|
+
const allTransformationFunctions = Object.keys(queryEngineConfig.supportedFunctions).filter((funcName) => {
|
|
38
|
+
const sF = queryEngineConfig.supportedFunctions[funcName];
|
|
39
|
+
return sF.useFor.includes('transform') && sF.outputDataType != 'date_time';
|
|
40
|
+
});
|
|
41
|
+
return allTransformationFunctions.includes(possibleTransformationFunction);
|
|
42
|
+
};
|
|
43
|
+
exports.isTransformationFunction = isTransformationFunction;
|
|
@@ -29,5 +29,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.Support = exports.Constants = void 0;
|
|
30
30
|
__exportStar(require("./getQueryEngineConfig"), exports);
|
|
31
31
|
__exportStar(require("./merge"), exports);
|
|
32
|
+
__exportStar(require("./upcast"), exports);
|
|
33
|
+
__exportStar(require("./downcast"), exports);
|
|
34
|
+
__exportStar(require("./helpers"), exports);
|
|
32
35
|
exports.Constants = __importStar(require("./constants"));
|
|
33
36
|
exports.Support = __importStar(require("./support"));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const localQueryEngineConfig:
|
|
1
|
+
import { QueryEngineConfigV1 } from './types';
|
|
2
|
+
export declare const localQueryEngineConfig: QueryEngineConfigV1;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.localQueryEngineConfig = void 0;
|
|
4
4
|
const support_1 = require("./support");
|
|
5
5
|
exports.localQueryEngineConfig = {
|
|
6
|
+
version: 1,
|
|
6
7
|
origin: 'in-browser',
|
|
7
8
|
supportedFeatures: [
|
|
8
9
|
'simpleMaths',
|
|
@@ -14,7 +15,7 @@ exports.localQueryEngineConfig = {
|
|
|
14
15
|
'encryptedDashboards',
|
|
15
16
|
'dateMaths',
|
|
16
17
|
],
|
|
17
|
-
|
|
18
|
+
supportedFunctions: (0, support_1.supportedFunctions)([
|
|
18
19
|
'month',
|
|
19
20
|
'year',
|
|
20
21
|
'quarter',
|
|
@@ -23,8 +24,16 @@ exports.localQueryEngineConfig = {
|
|
|
23
24
|
'hour',
|
|
24
25
|
'minute',
|
|
25
26
|
'second',
|
|
27
|
+
'sum',
|
|
28
|
+
'mean',
|
|
29
|
+
'min',
|
|
30
|
+
'max',
|
|
31
|
+
'count',
|
|
32
|
+
'countDistinct',
|
|
33
|
+
'median',
|
|
34
|
+
'round_to_0_dp',
|
|
35
|
+
'round_to_2_dp',
|
|
26
36
|
]),
|
|
27
|
-
supportedAggregates: (0, support_1.supportedAggregates)(['sum', 'mean', 'min', 'max', 'count', 'countDistinct', 'median']),
|
|
28
37
|
supportedOperators: (0, support_1.supportedOperators)([
|
|
29
38
|
'>',
|
|
30
39
|
'<',
|
|
@@ -41,5 +50,4 @@ exports.localQueryEngineConfig = {
|
|
|
41
50
|
'array_contains',
|
|
42
51
|
'array_does_not_contain',
|
|
43
52
|
]),
|
|
44
|
-
supportedTransformationFunctions: (0, support_1.supportedTransformationFunctions)(['round_to_0_dp', 'round_to_2_dp']),
|
|
45
53
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const queryEngineConfig: () =>
|
|
1
|
+
import { QueryEngineConfigV1 } from './types';
|
|
2
|
+
export declare const queryEngineConfig: () => QueryEngineConfigV1;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.queryEngineConfig = void 0;
|
|
4
4
|
const support_1 = require("./support");
|
|
5
5
|
const queryEngineConfig = () => ({
|
|
6
|
+
version: 1,
|
|
6
7
|
origin: 'query-engine',
|
|
7
8
|
supportedFeatures: [
|
|
8
9
|
'simpleMaths',
|
|
@@ -16,8 +17,22 @@ const queryEngineConfig = () => ({
|
|
|
16
17
|
'sqlViews',
|
|
17
18
|
'dateMaths',
|
|
18
19
|
],
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
supportedFunctions: (0, support_1.supportedFunctions)([
|
|
21
|
+
'month',
|
|
22
|
+
'year',
|
|
23
|
+
'day',
|
|
24
|
+
'hour',
|
|
25
|
+
'minute',
|
|
26
|
+
'second',
|
|
27
|
+
'sum',
|
|
28
|
+
'mean',
|
|
29
|
+
'min',
|
|
30
|
+
'max',
|
|
31
|
+
'count',
|
|
32
|
+
'countDistinct',
|
|
33
|
+
'round_to_0_dp',
|
|
34
|
+
'round_to_2_dp',
|
|
35
|
+
]),
|
|
21
36
|
supportedOperators: (0, support_1.supportedOperators)([
|
|
22
37
|
'>',
|
|
23
38
|
'<',
|
|
@@ -32,6 +47,5 @@ const queryEngineConfig = () => ({
|
|
|
32
47
|
'contains_substring',
|
|
33
48
|
'does_not_contain_substring',
|
|
34
49
|
]),
|
|
35
|
-
supportedTransformationFunctions: (0, support_1.supportedTransformationFunctions)(['round_to_0_dp', 'round_to_2_dp']),
|
|
36
50
|
});
|
|
37
51
|
exports.queryEngineConfig = queryEngineConfig;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QueryEngineConfigV1 } from './types';
|
|
2
2
|
/** If more than one DB is used, then we need to combine the configs and take the intersection of features. */
|
|
3
|
-
export declare const merge: (...queryEngineConfigs:
|
|
3
|
+
export declare const merge: (...queryEngineConfigs: QueryEngineConfigV1[]) => QueryEngineConfigV1;
|
|
@@ -15,12 +15,11 @@ const merge = (...queryEngineConfigs) => {
|
|
|
15
15
|
throw 'Cannot intersect non-object type in mapIntersection function.';
|
|
16
16
|
};
|
|
17
17
|
return {
|
|
18
|
+
version: 1,
|
|
18
19
|
origin: 'query-engine',
|
|
19
|
-
|
|
20
|
+
supportedFunctions: mapIntersection('supportedFunctions'),
|
|
20
21
|
supportedFeatures: (0, lodash_1.intersection)(acc.supportedFeatures, current.supportedFeatures),
|
|
21
22
|
supportedOperators: mapIntersection('supportedOperators'),
|
|
22
|
-
supportedTimeTruncFunctions: mapIntersection('supportedTimeTruncFunctions'),
|
|
23
|
-
supportedTransformationFunctions: mapIntersection('supportedTransformationFunctions'),
|
|
24
23
|
};
|
|
25
24
|
}, queryEngineConfigs[0]);
|
|
26
25
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const queryEngineConfig: () =>
|
|
1
|
+
import { QueryEngineConfigV1 } from './types';
|
|
2
|
+
export declare const queryEngineConfig: () => QueryEngineConfigV1;
|
|
@@ -10,6 +10,7 @@ const isKustoFlavor = () => {
|
|
|
10
10
|
};
|
|
11
11
|
const queryEngineConfig = () => {
|
|
12
12
|
return {
|
|
13
|
+
version: 1,
|
|
13
14
|
origin: 'query-engine',
|
|
14
15
|
supportedFeatures: [
|
|
15
16
|
'simpleMaths',
|
|
@@ -23,7 +24,7 @@ const queryEngineConfig = () => {
|
|
|
23
24
|
'sqlViews',
|
|
24
25
|
'dateMaths',
|
|
25
26
|
],
|
|
26
|
-
|
|
27
|
+
supportedFunctions: (0, support_1.supportedFunctions)([
|
|
27
28
|
'month',
|
|
28
29
|
'year',
|
|
29
30
|
'quarter',
|
|
@@ -32,8 +33,15 @@ const queryEngineConfig = () => {
|
|
|
32
33
|
'hour',
|
|
33
34
|
'minute',
|
|
34
35
|
...(isKustoFlavor() ? [] : ['second']),
|
|
36
|
+
'sum',
|
|
37
|
+
'mean',
|
|
38
|
+
'min',
|
|
39
|
+
'max',
|
|
40
|
+
'count',
|
|
41
|
+
'countDistinct',
|
|
42
|
+
'round_to_0_dp',
|
|
43
|
+
'round_to_2_dp',
|
|
35
44
|
]),
|
|
36
|
-
supportedAggregates: (0, support_1.supportedAggregates)(['sum', 'mean', 'min', 'max', 'count', 'countDistinct']),
|
|
37
45
|
supportedOperators: (0, support_1.supportedOperators)([
|
|
38
46
|
'>',
|
|
39
47
|
'<',
|
|
@@ -50,7 +58,6 @@ const queryEngineConfig = () => {
|
|
|
50
58
|
'array_contains',
|
|
51
59
|
'array_does_not_contain',
|
|
52
60
|
]),
|
|
53
|
-
supportedTransformationFunctions: (0, support_1.supportedTransformationFunctions)(['round_to_0_dp', 'round_to_2_dp']),
|
|
54
61
|
};
|
|
55
62
|
};
|
|
56
63
|
exports.queryEngineConfig = queryEngineConfig;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const queryEngineConfig: () =>
|
|
1
|
+
import { QueryEngineConfigV1 } from './types';
|
|
2
|
+
export declare const queryEngineConfig: () => QueryEngineConfigV1;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.queryEngineConfig = void 0;
|
|
4
4
|
const support_1 = require("./support");
|
|
5
5
|
const queryEngineConfig = () => ({
|
|
6
|
+
version: 1,
|
|
6
7
|
origin: 'query-engine',
|
|
7
8
|
supportedFeatures: [
|
|
8
9
|
'simpleMaths',
|
|
@@ -15,8 +16,22 @@ const queryEngineConfig = () => ({
|
|
|
15
16
|
'sqlViews',
|
|
16
17
|
'dateMaths',
|
|
17
18
|
],
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
supportedFunctions: (0, support_1.supportedFunctions)([
|
|
20
|
+
'month',
|
|
21
|
+
'year',
|
|
22
|
+
'day',
|
|
23
|
+
'hour',
|
|
24
|
+
'minute',
|
|
25
|
+
'second',
|
|
26
|
+
'sum',
|
|
27
|
+
'mean',
|
|
28
|
+
'min',
|
|
29
|
+
'max',
|
|
30
|
+
'count',
|
|
31
|
+
'countDistinct',
|
|
32
|
+
'round_to_0_dp',
|
|
33
|
+
'round_to_2_dp',
|
|
34
|
+
]),
|
|
20
35
|
supportedOperators: (0, support_1.supportedOperators)([
|
|
21
36
|
'>',
|
|
22
37
|
'<',
|
|
@@ -31,6 +46,5 @@ const queryEngineConfig = () => ({
|
|
|
31
46
|
'contains_substring',
|
|
32
47
|
'does_not_contain_substring',
|
|
33
48
|
]),
|
|
34
|
-
supportedTransformationFunctions: (0, support_1.supportedTransformationFunctions)(['round_to_0_dp', 'round_to_2_dp']),
|
|
35
49
|
});
|
|
36
50
|
exports.queryEngineConfig = queryEngineConfig;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const queryEngineConfig: () =>
|
|
1
|
+
import { QueryEngineConfigV1 } from './types';
|
|
2
|
+
export declare const queryEngineConfig: () => QueryEngineConfigV1;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.queryEngineConfig = void 0;
|
|
4
4
|
const support_1 = require("./support");
|
|
5
5
|
const queryEngineConfig = () => ({
|
|
6
|
+
version: 1,
|
|
6
7
|
origin: 'query-engine',
|
|
7
8
|
supportedFeatures: [
|
|
8
9
|
'simpleMaths',
|
|
@@ -16,7 +17,7 @@ const queryEngineConfig = () => ({
|
|
|
16
17
|
'sqlViews',
|
|
17
18
|
'dateMaths',
|
|
18
19
|
],
|
|
19
|
-
|
|
20
|
+
supportedFunctions: (0, support_1.supportedFunctions)([
|
|
20
21
|
'month',
|
|
21
22
|
'year',
|
|
22
23
|
'quarter',
|
|
@@ -28,8 +29,6 @@ const queryEngineConfig = () => ({
|
|
|
28
29
|
'dayOfMonthOnly',
|
|
29
30
|
'dayOfWeekOnly',
|
|
30
31
|
'weekOfYearOnly',
|
|
31
|
-
]),
|
|
32
|
-
supportedAggregates: (0, support_1.supportedAggregates)([
|
|
33
32
|
'sum',
|
|
34
33
|
'mean',
|
|
35
34
|
'median',
|
|
@@ -42,6 +41,8 @@ const queryEngineConfig = () => ({
|
|
|
42
41
|
'percentile90',
|
|
43
42
|
'percentile95',
|
|
44
43
|
'percentile99',
|
|
44
|
+
'round_to_0_dp',
|
|
45
|
+
'round_to_2_dp',
|
|
45
46
|
]),
|
|
46
47
|
supportedOperators: (0, support_1.supportedOperators)([
|
|
47
48
|
'>',
|
|
@@ -59,6 +60,5 @@ const queryEngineConfig = () => ({
|
|
|
59
60
|
'array_contains',
|
|
60
61
|
'array_does_not_contain',
|
|
61
62
|
]),
|
|
62
|
-
supportedTransformationFunctions: (0, support_1.supportedTransformationFunctions)(['round_to_0_dp', 'round_to_2_dp']),
|
|
63
63
|
});
|
|
64
64
|
exports.queryEngineConfig = queryEngineConfig;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const queryEngineConfig: () =>
|
|
1
|
+
import { QueryEngineConfigV1 } from './types';
|
|
2
|
+
export declare const queryEngineConfig: () => QueryEngineConfigV1;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.queryEngineConfig = void 0;
|
|
4
4
|
const support_1 = require("./support");
|
|
5
5
|
const queryEngineConfig = () => ({
|
|
6
|
+
version: 1,
|
|
6
7
|
origin: 'query-engine',
|
|
7
8
|
supportedFeatures: [
|
|
8
9
|
'simpleMaths',
|
|
@@ -16,7 +17,7 @@ const queryEngineConfig = () => ({
|
|
|
16
17
|
'sqlViews',
|
|
17
18
|
'dateMaths',
|
|
18
19
|
],
|
|
19
|
-
|
|
20
|
+
supportedFunctions: (0, support_1.supportedFunctions)([
|
|
20
21
|
'month',
|
|
21
22
|
'year',
|
|
22
23
|
'quarter',
|
|
@@ -25,8 +26,15 @@ const queryEngineConfig = () => ({
|
|
|
25
26
|
'hour',
|
|
26
27
|
'minute',
|
|
27
28
|
'second',
|
|
29
|
+
'sum',
|
|
30
|
+
'mean',
|
|
31
|
+
'min',
|
|
32
|
+
'max',
|
|
33
|
+
'count',
|
|
34
|
+
'countDistinct',
|
|
35
|
+
'round_to_0_dp',
|
|
36
|
+
'round_to_2_dp',
|
|
28
37
|
]),
|
|
29
|
-
supportedAggregates: (0, support_1.supportedAggregates)(['sum', 'mean', 'min', 'max', 'count', 'countDistinct']),
|
|
30
38
|
supportedOperators: (0, support_1.supportedOperators)([
|
|
31
39
|
'>',
|
|
32
40
|
'<',
|
|
@@ -43,6 +51,5 @@ const queryEngineConfig = () => ({
|
|
|
43
51
|
'array_contains',
|
|
44
52
|
'array_does_not_contain',
|
|
45
53
|
]),
|
|
46
|
-
supportedTransformationFunctions: (0, support_1.supportedTransformationFunctions)(['round_to_0_dp', 'round_to_2_dp']),
|
|
47
54
|
});
|
|
48
55
|
exports.queryEngineConfig = queryEngineConfig;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const queryEngineConfig: () =>
|
|
1
|
+
import { QueryEngineConfigV1 } from './types';
|
|
2
|
+
export declare const queryEngineConfig: () => QueryEngineConfigV1;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.queryEngineConfig = void 0;
|
|
4
4
|
const support_1 = require("./support");
|
|
5
5
|
const queryEngineConfig = () => ({
|
|
6
|
+
version: 1,
|
|
6
7
|
origin: 'query-engine',
|
|
7
8
|
supportedFeatures: [
|
|
8
9
|
'simpleMaths',
|
|
@@ -16,7 +17,7 @@ const queryEngineConfig = () => ({
|
|
|
16
17
|
'sqlViews',
|
|
17
18
|
'dateMaths',
|
|
18
19
|
],
|
|
19
|
-
|
|
20
|
+
supportedFunctions: (0, support_1.supportedFunctions)([
|
|
20
21
|
'month',
|
|
21
22
|
'year',
|
|
22
23
|
'quarter',
|
|
@@ -29,8 +30,6 @@ const queryEngineConfig = () => ({
|
|
|
29
30
|
'dayOfWeekOnly',
|
|
30
31
|
'weekOfYearOnly',
|
|
31
32
|
'hourOfDayOnly',
|
|
32
|
-
]),
|
|
33
|
-
supportedAggregates: (0, support_1.supportedAggregates)([
|
|
34
33
|
'sum',
|
|
35
34
|
'mean',
|
|
36
35
|
'median',
|
|
@@ -43,6 +42,8 @@ const queryEngineConfig = () => ({
|
|
|
43
42
|
'percentile90',
|
|
44
43
|
'percentile95',
|
|
45
44
|
'percentile99',
|
|
45
|
+
'round_to_0_dp',
|
|
46
|
+
'round_to_2_dp',
|
|
46
47
|
]),
|
|
47
48
|
supportedOperators: (0, support_1.supportedOperators)([
|
|
48
49
|
'>',
|
|
@@ -62,6 +63,5 @@ const queryEngineConfig = () => ({
|
|
|
62
63
|
'array_contains_any_of',
|
|
63
64
|
'array_contains_all_of',
|
|
64
65
|
]),
|
|
65
|
-
supportedTransformationFunctions: (0, support_1.supportedTransformationFunctions)(['round_to_0_dp', 'round_to_2_dp']),
|
|
66
66
|
});
|
|
67
67
|
exports.queryEngineConfig = queryEngineConfig;
|
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
import { NormalizedDataType } from '@vizzly/sqlbuilder-public';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const supportedTransformationFunctions: (keys?: Array<keyof typeof vizzlySupportedTransformationFunctions>) => SupportedTransformationFunctions;
|
|
5
|
-
export declare const supportedAggregatesFunction: (queryEngineConfig: QueryEngineConfig, dataType: NormalizedDataType, supportedAggregateOptions?: SupportedAggregateOption[]) => SupportedAggregateOption[];
|
|
2
|
+
import { QueryEngineConfigV1, SupportedAggregates, SupportedOperators, SupportedTimeTruncFunctions } from './types';
|
|
3
|
+
import { SUPPORTED_FUNCTIONS } from './constants';
|
|
6
4
|
export declare const supportedOperators: (keys?: Array<string>) => SupportedOperators;
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const supportedAggregates: (keys?: Array<string>) => SupportedAggregates;
|
|
5
|
+
export declare const supportedFunctions: (keys?: Array<keyof typeof SUPPORTED_FUNCTIONS>) => QueryEngineConfigV1['supportedFunctions'];
|
|
9
6
|
export declare const isSupportedAggregateFunction: (supportedAggregateFunctions: SupportedAggregates, proposedFunction: string) => boolean;
|
|
10
7
|
export declare const isSupportedAggregate: (value: string | undefined, supportedAggregates: SupportedAggregates) => boolean;
|
|
11
8
|
export declare const isSupportedTimeTruncFunction: (supportedTimeFunctions: SupportedTimeTruncFunctions, proposedFunction: string) => boolean;
|
|
12
|
-
export declare const ALL_SUPPORTED_CONSTANTS:
|
|
9
|
+
export declare const ALL_SUPPORTED_CONSTANTS: {
|
|
13
10
|
namespace: string;
|
|
14
11
|
constants: SupportedOperators;
|
|
15
|
-
}
|
|
16
|
-
namespace: string;
|
|
17
|
-
constants: SupportedTimeTruncFunctions;
|
|
18
|
-
})[];
|
|
12
|
+
}[];
|
|
19
13
|
export declare const validOperatorsForField: (field: {
|
|
20
14
|
dataType: NormalizedDataType;
|
|
21
|
-
}, queryEngineConfig:
|
|
22
|
-
export {};
|
|
15
|
+
}, queryEngineConfig: QueryEngineConfigV1) => string[];
|
|
@@ -1,52 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validOperatorsForField = exports.ALL_SUPPORTED_CONSTANTS = exports.isSupportedTimeTruncFunction = exports.isSupportedAggregate = exports.isSupportedAggregateFunction = exports.
|
|
3
|
+
exports.validOperatorsForField = exports.ALL_SUPPORTED_CONSTANTS = exports.isSupportedTimeTruncFunction = exports.isSupportedAggregate = exports.isSupportedAggregateFunction = exports.supportedFunctions = exports.supportedOperators = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
|
-
const vizzlySupportedTransformationFunctions = {
|
|
7
|
-
round_to_0_dp: {
|
|
8
|
-
publicName: 'Round to 0dp',
|
|
9
|
-
validDataTypes: ['number'],
|
|
10
|
-
},
|
|
11
|
-
round_to_2_dp: {
|
|
12
|
-
publicName: 'Round to 2dp',
|
|
13
|
-
validDataTypes: ['number'],
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
const supportedTransformationFunctions = (keys) => {
|
|
17
|
-
const supportedAggregates = (0, lodash_1.cloneDeep)(vizzlySupportedTransformationFunctions);
|
|
18
|
-
if (!keys)
|
|
19
|
-
return supportedAggregates;
|
|
20
|
-
let supportedTimeDimensions = {};
|
|
21
|
-
keys.forEach((key) => {
|
|
22
|
-
if (!supportedAggregates[key])
|
|
23
|
-
throw `Transformation function ${key} is not managed by Vizzly`;
|
|
24
|
-
supportedTimeDimensions[key] = supportedAggregates[key];
|
|
25
|
-
});
|
|
26
|
-
return supportedTimeDimensions;
|
|
27
|
-
};
|
|
28
|
-
exports.supportedTransformationFunctions = supportedTransformationFunctions;
|
|
29
|
-
const supportedAggregatesFunction = (queryEngineConfig, dataType, supportedAggregateOptions) => {
|
|
30
|
-
const supportedAggregates = queryEngineConfig.supportedAggregates;
|
|
31
|
-
// Derive default order from supportedAggregates
|
|
32
|
-
const derivedDefaultOrder = Object.keys(supportedAggregates).filter((aggregateId) => supportedAggregates[aggregateId].validDataTypes.includes(dataType));
|
|
33
|
-
// supportedAggregateOptions?.forEach((option) => {
|
|
34
|
-
// if (!supportedAggregates.hasOwnProperty(option)) {
|
|
35
|
-
// logWarning(`Unsupported aggregate option: ${option} on ${dataType}`);
|
|
36
|
-
// }
|
|
37
|
-
// });
|
|
38
|
-
// Determine the order of aggregates to use
|
|
39
|
-
let orderToUse = supportedAggregateOptions && supportedAggregateOptions.length > 0
|
|
40
|
-
? supportedAggregateOptions.filter((option) => derivedDefaultOrder.includes(option))
|
|
41
|
-
: derivedDefaultOrder;
|
|
42
|
-
// If no valid options found in supportedAggregateOptions, use derivedDefaultOrder
|
|
43
|
-
if (supportedAggregateOptions && supportedAggregateOptions.length > 0 && orderToUse.length === 0) {
|
|
44
|
-
orderToUse = derivedDefaultOrder;
|
|
45
|
-
}
|
|
46
|
-
// Return the aggregates in the order determined
|
|
47
|
-
return orderToUse;
|
|
48
|
-
};
|
|
49
|
-
exports.supportedAggregatesFunction = supportedAggregatesFunction;
|
|
50
6
|
const supportedOperators = (keys) => {
|
|
51
7
|
const supportedOperators = (0, lodash_1.cloneDeep)(constants_1.supportedOperatorsConstants);
|
|
52
8
|
if (!keys)
|
|
@@ -60,33 +16,19 @@ const supportedOperators = (keys) => {
|
|
|
60
16
|
return supportedOperatorsSubset;
|
|
61
17
|
};
|
|
62
18
|
exports.supportedOperators = supportedOperators;
|
|
63
|
-
const
|
|
64
|
-
const
|
|
19
|
+
const supportedFunctions = (keys) => {
|
|
20
|
+
const allSupportedFunctions = (0, lodash_1.cloneDeep)(constants_1.SUPPORTED_FUNCTIONS);
|
|
65
21
|
if (!keys)
|
|
66
|
-
return
|
|
67
|
-
let
|
|
22
|
+
return allSupportedFunctions;
|
|
23
|
+
let supportedFunctions = {};
|
|
68
24
|
keys.forEach((key) => {
|
|
69
|
-
if (!
|
|
25
|
+
if (!allSupportedFunctions[key])
|
|
70
26
|
throw `Time trunc function ${key} not managed by Vizzly`;
|
|
71
|
-
|
|
72
|
-
});
|
|
73
|
-
return supportedTimeDimensions;
|
|
74
|
-
};
|
|
75
|
-
exports.supportedTimeTruncFunctions = supportedTimeTruncFunctions;
|
|
76
|
-
// Aggregates supported by the Vizzly query engine.
|
|
77
|
-
const supportedAggregates = (keys) => {
|
|
78
|
-
const supportedAggregates = (0, lodash_1.cloneDeep)(constants_1.supportedAggregatesConstants);
|
|
79
|
-
if (!keys)
|
|
80
|
-
return supportedAggregates;
|
|
81
|
-
let supportedAggregatesSubset = {};
|
|
82
|
-
keys.forEach((key) => {
|
|
83
|
-
if (!supportedAggregates[key])
|
|
84
|
-
throw `Aggregate ${key} not managed by Vizzly`;
|
|
85
|
-
supportedAggregatesSubset[key] = supportedAggregates[key];
|
|
27
|
+
supportedFunctions[key] = allSupportedFunctions[key];
|
|
86
28
|
});
|
|
87
|
-
return
|
|
29
|
+
return supportedFunctions;
|
|
88
30
|
};
|
|
89
|
-
exports.
|
|
31
|
+
exports.supportedFunctions = supportedFunctions;
|
|
90
32
|
const isSupportedAggregateFunction = (supportedAggregateFunctions, proposedFunction) => {
|
|
91
33
|
return [...Object.keys(supportedAggregateFunctions), 'none'].includes(proposedFunction);
|
|
92
34
|
};
|
|
@@ -104,8 +46,8 @@ const isSupportedTimeTruncFunction = (supportedTimeFunctions, proposedFunction)
|
|
|
104
46
|
exports.isSupportedTimeTruncFunction = isSupportedTimeTruncFunction;
|
|
105
47
|
exports.ALL_SUPPORTED_CONSTANTS = [
|
|
106
48
|
{ namespace: 'config.supported_operator', constants: constants_1.supportedOperatorsConstants },
|
|
107
|
-
{ namespace: 'config.supported_aggregate', constants:
|
|
108
|
-
{ namespace: 'config.supported_time', constants:
|
|
49
|
+
// { namespace: 'config.supported_aggregate', constants: supportedAggregatesConstants },
|
|
50
|
+
// { namespace: 'config.supported_time', constants: timeDimensionsConstants },
|
|
109
51
|
];
|
|
110
52
|
const validOperatorsForField = (field, queryEngineConfig) => {
|
|
111
53
|
let operatorIds = [...Object.keys(queryEngineConfig.supportedOperators)];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NormalizedDataType } from '@vizzly/sqlbuilder-public';
|
|
2
2
|
export type SupportedFeature = 'subquery' | 'simpleMaths' | 'aggregateMaths' | 'switchField' | 'configManagerUi' | 'roundedNumbers' | 'sqlDefinedDataSet' | 'encryptedDashboards' | 'sqlViews' | 'dateMaths';
|
|
3
|
+
/** @deprecated use QueryEngineConfigV1 instead.*/
|
|
3
4
|
export type QueryEngineConfig = {
|
|
4
5
|
origin?: 'in-browser' | 'query-engine' | 'custom';
|
|
5
6
|
supportedFeatures: SupportedFeature[];
|
|
@@ -8,6 +9,19 @@ export type QueryEngineConfig = {
|
|
|
8
9
|
supportedTimeTruncFunctions: SupportedTimeTruncFunctions;
|
|
9
10
|
supportedTransformationFunctions: SupportedTransformationFunctions;
|
|
10
11
|
};
|
|
12
|
+
export type QueryEngineConfigV1 = {
|
|
13
|
+
version: 1;
|
|
14
|
+
origin?: 'in-browser' | 'query-engine' | 'custom';
|
|
15
|
+
supportedFeatures: SupportedFeature[];
|
|
16
|
+
supportedOperators: SupportedOperators;
|
|
17
|
+
supportedFunctions: {
|
|
18
|
+
[id: string]: {
|
|
19
|
+
useFor: Array<'aggregate' | 'transform'>;
|
|
20
|
+
inputDataTypes: Array<NormalizedDataType>;
|
|
21
|
+
outputDataType: NormalizedDataType;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
11
25
|
export type QueryEngineEndpoint = string | {
|
|
12
26
|
endpoint: string;
|
|
13
27
|
dynamicConfig?: Object;
|
|
@@ -15,13 +29,16 @@ export type QueryEngineEndpoint = string | {
|
|
|
15
29
|
[headerKey: string]: string;
|
|
16
30
|
};
|
|
17
31
|
};
|
|
32
|
+
/** @deprecated */
|
|
18
33
|
export type SupportedFunction = {
|
|
19
34
|
publicName: string;
|
|
20
35
|
validDataTypes: Array<Exclude<NormalizedDataType, 'date_time'>>;
|
|
21
36
|
};
|
|
37
|
+
/** @deprecated */
|
|
22
38
|
export type SupportedTransformationFunctions = {
|
|
23
39
|
[id: string]: SupportedFunction;
|
|
24
40
|
};
|
|
41
|
+
/** @deprecated */
|
|
25
42
|
export type SupportedTimeTruncFunction = {
|
|
26
43
|
publicName: string;
|
|
27
44
|
/**
|
|
@@ -31,6 +48,7 @@ export type SupportedTimeTruncFunction = {
|
|
|
31
48
|
* */
|
|
32
49
|
dateFormat: DateTimeFormat | (string & {});
|
|
33
50
|
};
|
|
51
|
+
/** @deprecated */
|
|
34
52
|
export type SupportedTimeTruncFunctions = {
|
|
35
53
|
[key: string]: SupportedTimeTruncFunction;
|
|
36
54
|
};
|
|
@@ -41,13 +59,18 @@ export type SupportedOperator = {
|
|
|
41
59
|
export type SupportedOperators = {
|
|
42
60
|
[id: string]: SupportedOperator;
|
|
43
61
|
};
|
|
62
|
+
/** @deprecated */
|
|
44
63
|
export type DateTimeFormat = 'DD/MM/YYYY' | 'MM/DD/YYYY' | 'DD-MM-YYYY' | 'MM-DD-YYYY' | 'DD MMMM YYYY, hh:mm' | 'dddd DD MMMM YYYY, hh:mm' | 'hh:mm' | 'hh:mm:ss' | 'DD MMMM YYYY' | 'MMMM YYYY' | 'YYYY' | 'YYYY-MM-DD[T]HH:mm:ss' | 'quarter' | 'week';
|
|
64
|
+
/** @deprecated */
|
|
45
65
|
export type SupportedAggregate = {
|
|
46
66
|
publicName: string;
|
|
47
67
|
validDataTypes: Array<NormalizedDataType>;
|
|
48
68
|
};
|
|
69
|
+
/** @deprecated */
|
|
49
70
|
export type SupportedAggregates = {
|
|
50
71
|
[id: string]: SupportedAggregate;
|
|
51
72
|
};
|
|
73
|
+
/** @deprecated */
|
|
52
74
|
export type SupportedAggregateOption = string;
|
|
75
|
+
/** @deprecated */
|
|
53
76
|
export type SupportedTimeFunctions = 'minute' | 'hour' | 'second' | 'week' | 'quarter' | 'year' | 'month' | 'day' | 'dayOfMonthOnly' | 'dayOfWeekOnly' | 'hourOfDayOnly' | 'weekOfYearOnly';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.upcast = void 0;
|
|
4
|
+
const upcast = (maybeOldQueryEngineConfig) => {
|
|
5
|
+
if ('version' in maybeOldQueryEngineConfig && maybeOldQueryEngineConfig.version === 1) {
|
|
6
|
+
return maybeOldQueryEngineConfig;
|
|
7
|
+
}
|
|
8
|
+
let supportedFunctions = {};
|
|
9
|
+
// Add the aggregate functions.
|
|
10
|
+
if ('supportedAggregates' in maybeOldQueryEngineConfig) {
|
|
11
|
+
Object.keys(maybeOldQueryEngineConfig.supportedAggregates).forEach((agg) => {
|
|
12
|
+
supportedFunctions[agg] = {
|
|
13
|
+
useFor: ['aggregate'],
|
|
14
|
+
inputDataTypes: maybeOldQueryEngineConfig.supportedAggregates[agg].validDataTypes,
|
|
15
|
+
outputDataType: 'number',
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
// Add the date time tunc functions.
|
|
20
|
+
if ('supportedTimeTruncFunctions' in maybeOldQueryEngineConfig) {
|
|
21
|
+
Object.keys(maybeOldQueryEngineConfig.supportedTimeTruncFunctions).forEach((timeTruncFunc) => {
|
|
22
|
+
supportedFunctions[timeTruncFunc] = {
|
|
23
|
+
useFor: ['transform'],
|
|
24
|
+
inputDataTypes: ['date_time'],
|
|
25
|
+
outputDataType: 'date_time',
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// Add the transformation functions.
|
|
30
|
+
if ('supportedTransformationFunctions' in maybeOldQueryEngineConfig) {
|
|
31
|
+
Object.keys(maybeOldQueryEngineConfig.supportedTransformationFunctions).forEach((transformFunc) => {
|
|
32
|
+
// Only number transformations used to be supported here...
|
|
33
|
+
supportedFunctions[transformFunc] = {
|
|
34
|
+
useFor: ['transform'],
|
|
35
|
+
inputDataTypes: supportedFunctions[transformFunc].inputDataTypes,
|
|
36
|
+
outputDataType: 'number',
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
version: 1,
|
|
42
|
+
origin: maybeOldQueryEngineConfig.origin,
|
|
43
|
+
supportedFeatures: maybeOldQueryEngineConfig.supportedFeatures,
|
|
44
|
+
supportedOperators: maybeOldQueryEngineConfig.supportedOperators,
|
|
45
|
+
supportedFunctions,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
exports.upcast = upcast;
|