@vizzly/semantic-layer-public 0.0.205-rc-2 → 0.0.206

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/QueryEngineConfig/bigquery.d.ts +2 -2
  2. package/dist/QueryEngineConfig/bigquery.js +3 -10
  3. package/dist/QueryEngineConfig/constants.d.ts +3 -4
  4. package/dist/QueryEngineConfig/constants.js +52 -130
  5. package/dist/QueryEngineConfig/getQueryEngineConfig.d.ts +2 -2
  6. package/dist/QueryEngineConfig/index.d.ts +0 -3
  7. package/dist/QueryEngineConfig/index.js +0 -3
  8. package/dist/QueryEngineConfig/localJS.d.ts +2 -2
  9. package/dist/QueryEngineConfig/localJS.js +3 -11
  10. package/dist/QueryEngineConfig/mariadb.d.ts +2 -2
  11. package/dist/QueryEngineConfig/mariadb.js +3 -17
  12. package/dist/QueryEngineConfig/merge.d.ts +2 -2
  13. package/dist/QueryEngineConfig/merge.js +3 -2
  14. package/dist/QueryEngineConfig/microsoftSQLServer.d.ts +2 -2
  15. package/dist/QueryEngineConfig/microsoftSQLServer.js +3 -10
  16. package/dist/QueryEngineConfig/mysql.d.ts +2 -2
  17. package/dist/QueryEngineConfig/mysql.js +3 -17
  18. package/dist/QueryEngineConfig/postgres.d.ts +2 -2
  19. package/dist/QueryEngineConfig/postgres.js +4 -4
  20. package/dist/QueryEngineConfig/redshift.d.ts +2 -2
  21. package/dist/QueryEngineConfig/redshift.js +3 -10
  22. package/dist/QueryEngineConfig/snowflake.d.ts +2 -2
  23. package/dist/QueryEngineConfig/snowflake.js +4 -4
  24. package/dist/QueryEngineConfig/support.d.ts +13 -6
  25. package/dist/QueryEngineConfig/support.js +69 -11
  26. package/dist/QueryEngineConfig/types.d.ts +0 -23
  27. package/package.json +3 -3
  28. package/dist/QueryEngineConfig/downcast.d.ts +0 -2
  29. package/dist/QueryEngineConfig/downcast.js +0 -47
  30. package/dist/QueryEngineConfig/helpers.d.ts +0 -10
  31. package/dist/QueryEngineConfig/helpers.js +0 -43
  32. package/dist/QueryEngineConfig/upcast.d.ts +0 -2
  33. package/dist/QueryEngineConfig/upcast.js +0 -48
@@ -1,2 +1,2 @@
1
- import { QueryEngineConfigV1 } from './types';
2
- export declare const queryEngineConfig: () => QueryEngineConfigV1;
1
+ import { QueryEngineConfig } from './types';
2
+ export declare const queryEngineConfig: () => QueryEngineConfig;
@@ -3,7 +3,6 @@ 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,
7
6
  origin: 'query-engine',
8
7
  supportedFeatures: [
9
8
  'simpleMaths',
@@ -17,7 +16,7 @@ const queryEngineConfig = () => ({
17
16
  'sqlViews',
18
17
  'dateMaths',
19
18
  ],
20
- supportedFunctions: (0, support_1.supportedFunctions)([
19
+ supportedTimeTruncFunctions: (0, support_1.supportedTimeTruncFunctions)([
21
20
  'month',
22
21
  'year',
23
22
  'quarter',
@@ -26,15 +25,8 @@ const queryEngineConfig = () => ({
26
25
  'hour',
27
26
  'minute',
28
27
  'second',
29
- 'sum',
30
- 'mean',
31
- 'min',
32
- 'max',
33
- 'count',
34
- 'countDistinct',
35
- 'round_to_0_dp',
36
- 'round_to_2_dp',
37
28
  ]),
29
+ supportedAggregates: (0, support_1.supportedAggregates)(['sum', 'mean', 'min', 'max', 'count', 'countDistinct']),
38
30
  supportedOperators: (0, support_1.supportedOperators)([
39
31
  '>',
40
32
  '<',
@@ -51,5 +43,6 @@ const queryEngineConfig = () => ({
51
43
  'array_contains',
52
44
  'array_does_not_contain',
53
45
  ]),
46
+ supportedTransformationFunctions: (0, support_1.supportedTransformationFunctions)(['round_to_0_dp', 'round_to_2_dp']),
54
47
  });
55
48
  exports.queryEngineConfig = queryEngineConfig;
@@ -1,5 +1,4 @@
1
- import { QueryEngineConfigV1, SupportedOperators } from './types';
1
+ import { SupportedAggregates, SupportedOperators, SupportedTimeTruncFunctions } from './types';
2
2
  export declare const supportedOperatorsConstants: SupportedOperators;
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'];
3
+ export declare const timeDimensionsConstants: SupportedTimeTruncFunctions;
4
+ export declare const supportedAggregatesConstants: SupportedAggregates;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SUPPORTED_FUNCTIONS = exports.functionToPublicName = exports.supportedOperatorsConstants = void 0;
3
+ exports.supportedAggregatesConstants = exports.timeDimensionsConstants = exports.supportedOperatorsConstants = void 0;
4
4
  exports.supportedOperatorsConstants = {
5
5
  '>': {
6
6
  publicName: 'Greater than',
@@ -67,181 +67,103 @@ exports.supportedOperatorsConstants = {
67
67
  validDataTypes: ['string[]'],
68
68
  },
69
69
  };
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
70
+ exports.timeDimensionsConstants = {
119
71
  month: {
120
- useFor: ['transform'],
121
- inputDataTypes: ['date_time'],
122
- outputDataType: 'date_time',
72
+ publicName: 'Monthly',
73
+ dateFormat: 'MMMM YYYY',
123
74
  },
124
75
  year: {
125
- useFor: ['transform'],
126
- inputDataTypes: ['date_time'],
127
- outputDataType: 'date_time',
76
+ publicName: 'Yearly',
77
+ dateFormat: 'YYYY',
128
78
  },
129
79
  quarter: {
130
- useFor: ['transform'],
131
- inputDataTypes: ['date_time'],
132
- outputDataType: 'date_time',
80
+ publicName: 'Per quarter',
81
+ dateFormat: 'quarter',
133
82
  },
134
83
  week: {
135
- useFor: ['transform'],
136
- inputDataTypes: ['date_time'],
137
- outputDataType: 'date_time',
84
+ publicName: 'Weekly',
85
+ dateFormat: 'week',
138
86
  },
139
87
  day: {
140
- useFor: ['transform'],
141
- inputDataTypes: ['date_time'],
142
- outputDataType: 'date_time',
88
+ publicName: 'Daily',
89
+ dateFormat: 'DD-MM-YYYY',
143
90
  },
144
91
  hourOfDayOnly: {
145
- useFor: ['transform'],
146
- inputDataTypes: ['date_time'],
147
- outputDataType: 'number',
92
+ publicName: 'Hour of day',
93
+ dateFormat: 'hour_of_day',
148
94
  },
149
95
  weekOfYearOnly: {
150
- useFor: ['transform'],
151
- inputDataTypes: ['date_time'],
152
- outputDataType: 'number',
96
+ publicName: 'Week of year',
97
+ dateFormat: 'week_of_year',
153
98
  },
154
99
  dayOfWeekOnly: {
155
- useFor: ['transform'],
156
- inputDataTypes: ['date_time'],
157
- outputDataType: 'number',
100
+ publicName: 'Day of week',
101
+ dateFormat: 'day_of_week_iso',
158
102
  },
159
103
  dayOfMonthOnly: {
160
- useFor: ['transform'],
161
- inputDataTypes: ['date_time'],
162
- outputDataType: 'number',
104
+ publicName: 'Day of month',
105
+ dateFormat: 'day_of_month',
163
106
  },
164
107
  second: {
165
- useFor: ['transform'],
166
- inputDataTypes: ['date_time'],
167
- outputDataType: 'date_time',
108
+ publicName: 'Per second',
109
+ dateFormat: 'hh:mm:ss',
168
110
  },
169
111
  hour: {
170
- useFor: ['transform'],
171
- inputDataTypes: ['date_time'],
172
- outputDataType: 'date_time',
112
+ publicName: 'Hourly',
113
+ dateFormat: 'hh:mm',
173
114
  },
174
115
  minute: {
175
- useFor: ['transform'],
176
- inputDataTypes: ['date_time'],
177
- outputDataType: 'date_time',
116
+ publicName: 'Per minute',
117
+ dateFormat: 'hh:mm',
178
118
  },
179
- // aggregates
119
+ };
120
+ exports.supportedAggregatesConstants = {
180
121
  mean: {
181
- useFor: ['aggregate'],
182
- inputDataTypes: ['number'],
183
- outputDataType: 'number',
122
+ publicName: 'Mean',
123
+ validDataTypes: ['number'],
184
124
  },
185
125
  sum: {
186
- useFor: ['aggregate'],
187
- inputDataTypes: ['number'],
188
- outputDataType: 'number',
126
+ publicName: 'Sum',
127
+ validDataTypes: ['number'],
189
128
  },
190
129
  min: {
191
- useFor: ['aggregate'],
192
- inputDataTypes: ['number'],
193
- outputDataType: 'number',
130
+ publicName: 'Min',
131
+ validDataTypes: ['number'],
194
132
  },
195
133
  max: {
196
- useFor: ['aggregate'],
197
- inputDataTypes: ['number'],
198
- outputDataType: 'number',
134
+ publicName: 'Max',
135
+ validDataTypes: ['number'],
199
136
  },
200
137
  count: {
201
- useFor: ['aggregate'],
202
- inputDataTypes: ['string', 'number', 'boolean', 'date_time', 'string[]'],
203
- outputDataType: 'number',
138
+ publicName: 'Count',
139
+ validDataTypes: ['string', 'number', 'boolean', 'date_time', 'string[]'],
204
140
  },
205
141
  countDistinct: {
206
- useFor: ['aggregate'],
207
- inputDataTypes: ['string', 'number', 'boolean', 'date_time'],
208
- outputDataType: 'number',
142
+ publicName: 'Unique',
143
+ validDataTypes: ['string', 'number', 'boolean', 'date_time'],
209
144
  },
210
145
  median: {
211
- useFor: ['aggregate'],
212
- inputDataTypes: ['number'],
213
- outputDataType: 'number',
146
+ publicName: 'Median',
147
+ validDataTypes: ['number'],
214
148
  },
215
149
  percentile25: {
216
- useFor: ['aggregate'],
217
- inputDataTypes: ['number'],
218
- outputDataType: 'number',
150
+ publicName: '25th percentile',
151
+ validDataTypes: ['number'],
219
152
  },
220
153
  percentile75: {
221
- useFor: ['aggregate'],
222
- inputDataTypes: ['number'],
223
- outputDataType: 'number',
154
+ publicName: '75th percentile',
155
+ validDataTypes: ['number'],
224
156
  },
225
157
  percentile90: {
226
- useFor: ['aggregate'],
227
- inputDataTypes: ['number'],
228
- outputDataType: 'number',
158
+ publicName: '90th percentile',
159
+ validDataTypes: ['number'],
229
160
  },
230
161
  percentile95: {
231
- useFor: ['aggregate'],
232
- inputDataTypes: ['number'],
233
- outputDataType: 'number',
162
+ publicName: '95th percentile',
163
+ validDataTypes: ['number'],
234
164
  },
235
165
  percentile99: {
236
- useFor: ['aggregate'],
237
- inputDataTypes: ['number'],
238
- outputDataType: 'number',
166
+ publicName: '99th percentile',
167
+ validDataTypes: ['number'],
239
168
  },
240
169
  };
241
- // {
242
- // [id: string]: {
243
- // useFor: Array<'aggregate' | 'transform'>;
244
- // inputDataTypes: Array<NormalizedDataType>;
245
- // outputDataType: NormalizedDataType;
246
- // };
247
- // }
@@ -1,3 +1,3 @@
1
1
  import { Client } from '@vizzly/sqlbuilder-public';
2
- import { QueryEngineConfigV1 } from './types';
3
- export declare const getQueryEngineConfig: (client: Client | 'js') => QueryEngineConfigV1;
2
+ import { QueryEngineConfig } from './types';
3
+ export declare const getQueryEngineConfig: (client: Client | 'js') => QueryEngineConfig;
@@ -1,7 +1,4 @@
1
1
  export * from './getQueryEngineConfig';
2
2
  export * from './merge';
3
- export * from './upcast';
4
- export * from './downcast';
5
- export * from './helpers';
6
3
  export * as Constants from './constants';
7
4
  export * as Support from './support';
@@ -29,8 +29,5 @@ 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);
35
32
  exports.Constants = __importStar(require("./constants"));
36
33
  exports.Support = __importStar(require("./support"));
@@ -1,2 +1,2 @@
1
- import { QueryEngineConfigV1 } from './types';
2
- export declare const localQueryEngineConfig: QueryEngineConfigV1;
1
+ import { QueryEngineConfig } from './types';
2
+ export declare const localQueryEngineConfig: QueryEngineConfig;
@@ -3,7 +3,6 @@ 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,
7
6
  origin: 'in-browser',
8
7
  supportedFeatures: [
9
8
  'simpleMaths',
@@ -15,7 +14,7 @@ exports.localQueryEngineConfig = {
15
14
  'encryptedDashboards',
16
15
  'dateMaths',
17
16
  ],
18
- supportedFunctions: (0, support_1.supportedFunctions)([
17
+ supportedTimeTruncFunctions: (0, support_1.supportedTimeTruncFunctions)([
19
18
  'month',
20
19
  'year',
21
20
  'quarter',
@@ -24,16 +23,8 @@ exports.localQueryEngineConfig = {
24
23
  'hour',
25
24
  'minute',
26
25
  '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',
36
26
  ]),
27
+ supportedAggregates: (0, support_1.supportedAggregates)(['sum', 'mean', 'min', 'max', 'count', 'countDistinct', 'median']),
37
28
  supportedOperators: (0, support_1.supportedOperators)([
38
29
  '>',
39
30
  '<',
@@ -50,4 +41,5 @@ exports.localQueryEngineConfig = {
50
41
  'array_contains',
51
42
  'array_does_not_contain',
52
43
  ]),
44
+ supportedTransformationFunctions: (0, support_1.supportedTransformationFunctions)(['round_to_0_dp', 'round_to_2_dp']),
53
45
  };
@@ -1,2 +1,2 @@
1
- import { QueryEngineConfigV1 } from './types';
2
- export declare const queryEngineConfig: () => QueryEngineConfigV1;
1
+ import { QueryEngineConfig } from './types';
2
+ export declare const queryEngineConfig: () => QueryEngineConfig;
@@ -3,7 +3,6 @@ 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,
7
6
  origin: 'query-engine',
8
7
  supportedFeatures: [
9
8
  'simpleMaths',
@@ -17,22 +16,8 @@ const queryEngineConfig = () => ({
17
16
  'sqlViews',
18
17
  'dateMaths',
19
18
  ],
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
- ]),
19
+ supportedTimeTruncFunctions: (0, support_1.supportedTimeTruncFunctions)(['month', 'year', 'day', 'hour', 'minute', 'second']),
20
+ supportedAggregates: (0, support_1.supportedAggregates)(['sum', 'mean', 'min', 'max', 'count', 'countDistinct']),
36
21
  supportedOperators: (0, support_1.supportedOperators)([
37
22
  '>',
38
23
  '<',
@@ -47,5 +32,6 @@ const queryEngineConfig = () => ({
47
32
  'contains_substring',
48
33
  'does_not_contain_substring',
49
34
  ]),
35
+ supportedTransformationFunctions: (0, support_1.supportedTransformationFunctions)(['round_to_0_dp', 'round_to_2_dp']),
50
36
  });
51
37
  exports.queryEngineConfig = queryEngineConfig;
@@ -1,3 +1,3 @@
1
- import { QueryEngineConfigV1 } from './types';
1
+ import { QueryEngineConfig } 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: QueryEngineConfigV1[]) => QueryEngineConfigV1;
3
+ export declare const merge: (...queryEngineConfigs: QueryEngineConfig[]) => QueryEngineConfig;
@@ -15,11 +15,12 @@ const merge = (...queryEngineConfigs) => {
15
15
  throw 'Cannot intersect non-object type in mapIntersection function.';
16
16
  };
17
17
  return {
18
- version: 1,
19
18
  origin: 'query-engine',
20
- supportedFunctions: mapIntersection('supportedFunctions'),
19
+ supportedAggregates: mapIntersection('supportedAggregates'),
21
20
  supportedFeatures: (0, lodash_1.intersection)(acc.supportedFeatures, current.supportedFeatures),
22
21
  supportedOperators: mapIntersection('supportedOperators'),
22
+ supportedTimeTruncFunctions: mapIntersection('supportedTimeTruncFunctions'),
23
+ supportedTransformationFunctions: mapIntersection('supportedTransformationFunctions'),
23
24
  };
24
25
  }, queryEngineConfigs[0]);
25
26
  };
@@ -1,2 +1,2 @@
1
- import { QueryEngineConfigV1 } from './types';
2
- export declare const queryEngineConfig: () => QueryEngineConfigV1;
1
+ import { QueryEngineConfig } from './types';
2
+ export declare const queryEngineConfig: () => QueryEngineConfig;
@@ -10,7 +10,6 @@ const isKustoFlavor = () => {
10
10
  };
11
11
  const queryEngineConfig = () => {
12
12
  return {
13
- version: 1,
14
13
  origin: 'query-engine',
15
14
  supportedFeatures: [
16
15
  'simpleMaths',
@@ -24,7 +23,7 @@ const queryEngineConfig = () => {
24
23
  'sqlViews',
25
24
  'dateMaths',
26
25
  ],
27
- supportedFunctions: (0, support_1.supportedFunctions)([
26
+ supportedTimeTruncFunctions: (0, support_1.supportedTimeTruncFunctions)([
28
27
  'month',
29
28
  'year',
30
29
  'quarter',
@@ -33,15 +32,8 @@ const queryEngineConfig = () => {
33
32
  'hour',
34
33
  'minute',
35
34
  ...(isKustoFlavor() ? [] : ['second']),
36
- 'sum',
37
- 'mean',
38
- 'min',
39
- 'max',
40
- 'count',
41
- 'countDistinct',
42
- 'round_to_0_dp',
43
- 'round_to_2_dp',
44
35
  ]),
36
+ supportedAggregates: (0, support_1.supportedAggregates)(['sum', 'mean', 'min', 'max', 'count', 'countDistinct']),
45
37
  supportedOperators: (0, support_1.supportedOperators)([
46
38
  '>',
47
39
  '<',
@@ -58,6 +50,7 @@ const queryEngineConfig = () => {
58
50
  'array_contains',
59
51
  'array_does_not_contain',
60
52
  ]),
53
+ supportedTransformationFunctions: (0, support_1.supportedTransformationFunctions)(['round_to_0_dp', 'round_to_2_dp']),
61
54
  };
62
55
  };
63
56
  exports.queryEngineConfig = queryEngineConfig;
@@ -1,2 +1,2 @@
1
- import { QueryEngineConfigV1 } from './types';
2
- export declare const queryEngineConfig: () => QueryEngineConfigV1;
1
+ import { QueryEngineConfig } from './types';
2
+ export declare const queryEngineConfig: () => QueryEngineConfig;
@@ -3,7 +3,6 @@ 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,
7
6
  origin: 'query-engine',
8
7
  supportedFeatures: [
9
8
  'simpleMaths',
@@ -16,22 +15,8 @@ const queryEngineConfig = () => ({
16
15
  'sqlViews',
17
16
  'dateMaths',
18
17
  ],
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
- ]),
18
+ supportedTimeTruncFunctions: (0, support_1.supportedTimeTruncFunctions)(['month', 'year', 'day', 'hour', 'minute', 'second']),
19
+ supportedAggregates: (0, support_1.supportedAggregates)(['sum', 'mean', 'min', 'max', 'count', 'countDistinct']),
35
20
  supportedOperators: (0, support_1.supportedOperators)([
36
21
  '>',
37
22
  '<',
@@ -46,5 +31,6 @@ const queryEngineConfig = () => ({
46
31
  'contains_substring',
47
32
  'does_not_contain_substring',
48
33
  ]),
34
+ supportedTransformationFunctions: (0, support_1.supportedTransformationFunctions)(['round_to_0_dp', 'round_to_2_dp']),
49
35
  });
50
36
  exports.queryEngineConfig = queryEngineConfig;
@@ -1,2 +1,2 @@
1
- import { QueryEngineConfigV1 } from './types';
2
- export declare const queryEngineConfig: () => QueryEngineConfigV1;
1
+ import { QueryEngineConfig } from './types';
2
+ export declare const queryEngineConfig: () => QueryEngineConfig;
@@ -3,7 +3,6 @@ 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,
7
6
  origin: 'query-engine',
8
7
  supportedFeatures: [
9
8
  'simpleMaths',
@@ -17,7 +16,7 @@ const queryEngineConfig = () => ({
17
16
  'sqlViews',
18
17
  'dateMaths',
19
18
  ],
20
- supportedFunctions: (0, support_1.supportedFunctions)([
19
+ supportedTimeTruncFunctions: (0, support_1.supportedTimeTruncFunctions)([
21
20
  'month',
22
21
  'year',
23
22
  'quarter',
@@ -29,6 +28,8 @@ const queryEngineConfig = () => ({
29
28
  'dayOfMonthOnly',
30
29
  'dayOfWeekOnly',
31
30
  'weekOfYearOnly',
31
+ ]),
32
+ supportedAggregates: (0, support_1.supportedAggregates)([
32
33
  'sum',
33
34
  'mean',
34
35
  'median',
@@ -41,8 +42,6 @@ const queryEngineConfig = () => ({
41
42
  'percentile90',
42
43
  'percentile95',
43
44
  'percentile99',
44
- 'round_to_0_dp',
45
- 'round_to_2_dp',
46
45
  ]),
47
46
  supportedOperators: (0, support_1.supportedOperators)([
48
47
  '>',
@@ -60,5 +59,6 @@ const queryEngineConfig = () => ({
60
59
  'array_contains',
61
60
  'array_does_not_contain',
62
61
  ]),
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 { QueryEngineConfigV1 } from './types';
2
- export declare const queryEngineConfig: () => QueryEngineConfigV1;
1
+ import { QueryEngineConfig } from './types';
2
+ export declare const queryEngineConfig: () => QueryEngineConfig;
@@ -3,7 +3,6 @@ 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,
7
6
  origin: 'query-engine',
8
7
  supportedFeatures: [
9
8
  'simpleMaths',
@@ -17,7 +16,7 @@ const queryEngineConfig = () => ({
17
16
  'sqlViews',
18
17
  'dateMaths',
19
18
  ],
20
- supportedFunctions: (0, support_1.supportedFunctions)([
19
+ supportedTimeTruncFunctions: (0, support_1.supportedTimeTruncFunctions)([
21
20
  'month',
22
21
  'year',
23
22
  'quarter',
@@ -26,15 +25,8 @@ const queryEngineConfig = () => ({
26
25
  'hour',
27
26
  'minute',
28
27
  'second',
29
- 'sum',
30
- 'mean',
31
- 'min',
32
- 'max',
33
- 'count',
34
- 'countDistinct',
35
- 'round_to_0_dp',
36
- 'round_to_2_dp',
37
28
  ]),
29
+ supportedAggregates: (0, support_1.supportedAggregates)(['sum', 'mean', 'min', 'max', 'count', 'countDistinct']),
38
30
  supportedOperators: (0, support_1.supportedOperators)([
39
31
  '>',
40
32
  '<',
@@ -51,5 +43,6 @@ const queryEngineConfig = () => ({
51
43
  'array_contains',
52
44
  'array_does_not_contain',
53
45
  ]),
46
+ supportedTransformationFunctions: (0, support_1.supportedTransformationFunctions)(['round_to_0_dp', 'round_to_2_dp']),
54
47
  });
55
48
  exports.queryEngineConfig = queryEngineConfig;
@@ -1,2 +1,2 @@
1
- import { QueryEngineConfigV1 } from './types';
2
- export declare const queryEngineConfig: () => QueryEngineConfigV1;
1
+ import { QueryEngineConfig } from './types';
2
+ export declare const queryEngineConfig: () => QueryEngineConfig;
@@ -3,7 +3,6 @@ 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,
7
6
  origin: 'query-engine',
8
7
  supportedFeatures: [
9
8
  'simpleMaths',
@@ -17,7 +16,7 @@ const queryEngineConfig = () => ({
17
16
  'sqlViews',
18
17
  'dateMaths',
19
18
  ],
20
- supportedFunctions: (0, support_1.supportedFunctions)([
19
+ supportedTimeTruncFunctions: (0, support_1.supportedTimeTruncFunctions)([
21
20
  'month',
22
21
  'year',
23
22
  'quarter',
@@ -30,6 +29,8 @@ const queryEngineConfig = () => ({
30
29
  'dayOfWeekOnly',
31
30
  'weekOfYearOnly',
32
31
  'hourOfDayOnly',
32
+ ]),
33
+ supportedAggregates: (0, support_1.supportedAggregates)([
33
34
  'sum',
34
35
  'mean',
35
36
  'median',
@@ -42,8 +43,6 @@ const queryEngineConfig = () => ({
42
43
  'percentile90',
43
44
  'percentile95',
44
45
  'percentile99',
45
- 'round_to_0_dp',
46
- 'round_to_2_dp',
47
46
  ]),
48
47
  supportedOperators: (0, support_1.supportedOperators)([
49
48
  '>',
@@ -63,5 +62,6 @@ const queryEngineConfig = () => ({
63
62
  'array_contains_any_of',
64
63
  'array_contains_all_of',
65
64
  ]),
65
+ supportedTransformationFunctions: (0, support_1.supportedTransformationFunctions)(['round_to_0_dp', 'round_to_2_dp']),
66
66
  });
67
67
  exports.queryEngineConfig = queryEngineConfig;
@@ -1,15 +1,22 @@
1
1
  import { NormalizedDataType } from '@vizzly/sqlbuilder-public';
2
- import { QueryEngineConfigV1, SupportedAggregates, SupportedOperators, SupportedTimeTruncFunctions } from './types';
3
- import { SUPPORTED_FUNCTIONS } from './constants';
2
+ import { QueryEngineConfig, SupportedAggregateOption, SupportedAggregates, SupportedOperators, SupportedTimeFunctions, SupportedTimeTruncFunctions, SupportedTransformationFunctions } from './types';
3
+ declare const vizzlySupportedTransformationFunctions: SupportedTransformationFunctions;
4
+ export declare const supportedTransformationFunctions: (keys?: Array<keyof typeof vizzlySupportedTransformationFunctions>) => SupportedTransformationFunctions;
5
+ export declare const supportedAggregatesFunction: (queryEngineConfig: QueryEngineConfig, dataType: NormalizedDataType, supportedAggregateOptions?: SupportedAggregateOption[]) => SupportedAggregateOption[];
4
6
  export declare const supportedOperators: (keys?: Array<string>) => SupportedOperators;
5
- export declare const supportedFunctions: (keys?: Array<keyof typeof SUPPORTED_FUNCTIONS>) => QueryEngineConfigV1['supportedFunctions'];
7
+ export declare const supportedTimeTruncFunctions: (keys?: Array<SupportedTimeFunctions>) => SupportedTimeTruncFunctions;
8
+ export declare const supportedAggregates: (keys?: Array<string>) => SupportedAggregates;
6
9
  export declare const isSupportedAggregateFunction: (supportedAggregateFunctions: SupportedAggregates, proposedFunction: string) => boolean;
7
10
  export declare const isSupportedAggregate: (value: string | undefined, supportedAggregates: SupportedAggregates) => boolean;
8
11
  export declare const isSupportedTimeTruncFunction: (supportedTimeFunctions: SupportedTimeTruncFunctions, proposedFunction: string) => boolean;
9
- export declare const ALL_SUPPORTED_CONSTANTS: {
12
+ export declare const ALL_SUPPORTED_CONSTANTS: ({
10
13
  namespace: string;
11
14
  constants: SupportedOperators;
12
- }[];
15
+ } | {
16
+ namespace: string;
17
+ constants: SupportedTimeTruncFunctions;
18
+ })[];
13
19
  export declare const validOperatorsForField: (field: {
14
20
  dataType: NormalizedDataType;
15
- }, queryEngineConfig: QueryEngineConfigV1) => string[];
21
+ }, queryEngineConfig: QueryEngineConfig) => string[];
22
+ export {};
@@ -1,8 +1,52 @@
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.supportedFunctions = exports.supportedOperators = void 0;
3
+ exports.validOperatorsForField = exports.ALL_SUPPORTED_CONSTANTS = exports.isSupportedTimeTruncFunction = exports.isSupportedAggregate = exports.isSupportedAggregateFunction = exports.supportedAggregates = exports.supportedTimeTruncFunctions = exports.supportedOperators = exports.supportedAggregatesFunction = exports.supportedTransformationFunctions = 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;
6
50
  const supportedOperators = (keys) => {
7
51
  const supportedOperators = (0, lodash_1.cloneDeep)(constants_1.supportedOperatorsConstants);
8
52
  if (!keys)
@@ -16,19 +60,33 @@ const supportedOperators = (keys) => {
16
60
  return supportedOperatorsSubset;
17
61
  };
18
62
  exports.supportedOperators = supportedOperators;
19
- const supportedFunctions = (keys) => {
20
- const allSupportedFunctions = (0, lodash_1.cloneDeep)(constants_1.SUPPORTED_FUNCTIONS);
63
+ const supportedTimeTruncFunctions = (keys) => {
64
+ const supportedAggregates = (0, lodash_1.cloneDeep)(constants_1.timeDimensionsConstants);
21
65
  if (!keys)
22
- return allSupportedFunctions;
23
- let supportedFunctions = {};
66
+ return supportedAggregates;
67
+ let supportedTimeDimensions = {};
24
68
  keys.forEach((key) => {
25
- if (!allSupportedFunctions[key])
69
+ if (!supportedAggregates[key])
26
70
  throw `Time trunc function ${key} not managed by Vizzly`;
27
- supportedFunctions[key] = allSupportedFunctions[key];
71
+ supportedTimeDimensions[key] = supportedAggregates[key];
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];
28
86
  });
29
- return supportedFunctions;
87
+ return supportedAggregatesSubset;
30
88
  };
31
- exports.supportedFunctions = supportedFunctions;
89
+ exports.supportedAggregates = supportedAggregates;
32
90
  const isSupportedAggregateFunction = (supportedAggregateFunctions, proposedFunction) => {
33
91
  return [...Object.keys(supportedAggregateFunctions), 'none'].includes(proposedFunction);
34
92
  };
@@ -46,8 +104,8 @@ const isSupportedTimeTruncFunction = (supportedTimeFunctions, proposedFunction)
46
104
  exports.isSupportedTimeTruncFunction = isSupportedTimeTruncFunction;
47
105
  exports.ALL_SUPPORTED_CONSTANTS = [
48
106
  { namespace: 'config.supported_operator', constants: constants_1.supportedOperatorsConstants },
49
- // { namespace: 'config.supported_aggregate', constants: supportedAggregatesConstants },
50
- // { namespace: 'config.supported_time', constants: timeDimensionsConstants },
107
+ { namespace: 'config.supported_aggregate', constants: constants_1.supportedAggregatesConstants },
108
+ { namespace: 'config.supported_time', constants: constants_1.timeDimensionsConstants },
51
109
  ];
52
110
  const validOperatorsForField = (field, queryEngineConfig) => {
53
111
  let operatorIds = [...Object.keys(queryEngineConfig.supportedOperators)];
@@ -1,6 +1,5 @@
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.*/
4
3
  export type QueryEngineConfig = {
5
4
  origin?: 'in-browser' | 'query-engine' | 'custom';
6
5
  supportedFeatures: SupportedFeature[];
@@ -9,19 +8,6 @@ export type QueryEngineConfig = {
9
8
  supportedTimeTruncFunctions: SupportedTimeTruncFunctions;
10
9
  supportedTransformationFunctions: SupportedTransformationFunctions;
11
10
  };
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
- };
25
11
  export type QueryEngineEndpoint = string | {
26
12
  endpoint: string;
27
13
  dynamicConfig?: Object;
@@ -29,16 +15,13 @@ export type QueryEngineEndpoint = string | {
29
15
  [headerKey: string]: string;
30
16
  };
31
17
  };
32
- /** @deprecated */
33
18
  export type SupportedFunction = {
34
19
  publicName: string;
35
20
  validDataTypes: Array<Exclude<NormalizedDataType, 'date_time'>>;
36
21
  };
37
- /** @deprecated */
38
22
  export type SupportedTransformationFunctions = {
39
23
  [id: string]: SupportedFunction;
40
24
  };
41
- /** @deprecated */
42
25
  export type SupportedTimeTruncFunction = {
43
26
  publicName: string;
44
27
  /**
@@ -48,7 +31,6 @@ export type SupportedTimeTruncFunction = {
48
31
  * */
49
32
  dateFormat: DateTimeFormat | (string & {});
50
33
  };
51
- /** @deprecated */
52
34
  export type SupportedTimeTruncFunctions = {
53
35
  [key: string]: SupportedTimeTruncFunction;
54
36
  };
@@ -59,18 +41,13 @@ export type SupportedOperator = {
59
41
  export type SupportedOperators = {
60
42
  [id: string]: SupportedOperator;
61
43
  };
62
- /** @deprecated */
63
44
  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 */
65
45
  export type SupportedAggregate = {
66
46
  publicName: string;
67
47
  validDataTypes: Array<NormalizedDataType>;
68
48
  };
69
- /** @deprecated */
70
49
  export type SupportedAggregates = {
71
50
  [id: string]: SupportedAggregate;
72
51
  };
73
- /** @deprecated */
74
52
  export type SupportedAggregateOption = string;
75
- /** @deprecated */
76
53
  export type SupportedTimeFunctions = 'minute' | 'hour' | 'second' | 'week' | 'quarter' | 'year' | 'month' | 'day' | 'dayOfMonthOnly' | 'dayOfWeekOnly' | 'hourOfDayOnly' | 'weekOfYearOnly';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizzly/semantic-layer-public",
3
- "version": "0.0.205-rc-2",
3
+ "version": "0.0.206",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,9 +24,9 @@
24
24
  "ts-jest": "^29.1.2",
25
25
  "typescript": "^5.4.5",
26
26
  "uuid": "^9.0.1",
27
- "@vizzly/sqlbuilder-public": "0.1.15"
27
+ "@vizzly/sqlbuilder-public": "0.1.16"
28
28
  },
29
29
  "peerDependencies": {
30
- "@vizzly/sqlbuilder-public": "0.1.15"
30
+ "@vizzly/sqlbuilder-public": "0.1.16"
31
31
  }
32
32
  }
@@ -1,2 +0,0 @@
1
- import { QueryEngineConfig, QueryEngineConfigV1 } from './types';
2
- export declare const downcast: (maybeOldQueryEngineConfig: QueryEngineConfig | QueryEngineConfigV1) => QueryEngineConfig;
@@ -1,47 +0,0 @@
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,10 +0,0 @@
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;
@@ -1,43 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- import { QueryEngineConfig, QueryEngineConfigV1 } from './types';
2
- export declare const upcast: (maybeOldQueryEngineConfig: QueryEngineConfig | QueryEngineConfigV1) => QueryEngineConfigV1;
@@ -1,48 +0,0 @@
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;