-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
Copy pathtime_scale.ts
50 lines (48 loc) · 1.3 KB
/
time_scale.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { ExecutionContext } from '../../../../../../src/plugins/expressions/common';
import type { TimeScaleExpressionFunction } from './types';
export const getTimeScale = (
getTimezone: (context: ExecutionContext) => string | Promise<string>
): TimeScaleExpressionFunction => ({
name: 'lens_time_scale',
type: 'datatable',
help: '',
args: {
dateColumnId: {
types: ['string'],
help: '',
required: true,
},
inputColumnId: {
types: ['string'],
help: '',
required: true,
},
outputColumnId: {
types: ['string'],
help: '',
required: true,
},
outputColumnName: {
types: ['string'],
help: '',
},
targetUnit: {
types: ['string'],
options: ['s', 'm', 'h', 'd'],
help: '',
required: true,
},
},
inputTypes: ['datatable'],
async fn(...args) {
/** Build optimization: prevent adding extra code into initial bundle **/
const { timeScaleFn } = await import('./time_scale_fn');
return timeScaleFn(getTimezone)(...args);
},
});