1- import { AggregateFunctionSchema } from '@hyperdx/common-utils/dist/types' ;
2- import { MetricsDataType } from '@hyperdx/common-utils/dist/types' ;
1+ import {
2+ AggregateFunctionSchema ,
3+ MetricsDataType ,
4+ NumberFormatSchema ,
5+ SearchConditionLanguageSchema as whereLanguageSchema ,
6+ } from '@hyperdx/common-utils/dist/types' ;
37import { Types } from 'mongoose' ;
48import { z } from 'zod' ;
59
@@ -21,27 +25,8 @@ export type SourceTable = z.infer<typeof sourceTableSchema>;
2125// Charts & Dashboards
2226// ==============================
2327
24- const numberFormatSchema = z . object ( {
25- output : z . union ( [
26- z . literal ( 'currency' ) ,
27- z . literal ( 'percent' ) ,
28- z . literal ( 'byte' ) ,
29- z . literal ( 'time' ) ,
30- z . literal ( 'number' ) ,
31- ] ) ,
32- mantissa : z . number ( ) . optional ( ) ,
33- thousandSeparated : z . boolean ( ) . optional ( ) ,
34- average : z . boolean ( ) . optional ( ) ,
35- decimalBytes : z . boolean ( ) . optional ( ) ,
36- factor : z . number ( ) . optional ( ) ,
37- currencySymbol : z . string ( ) . optional ( ) ,
38- unit : z . string ( ) . optional ( ) ,
39- } ) ;
40-
4128const percentileLevelSchema = z . number ( ) . min ( 0 ) . max ( 1 ) . optional ( ) ;
4229
43- const whereLanguageSchema = z . enum ( [ 'sql' , 'lucene' ] ) . optional ( ) ;
44-
4530const timeChartSeriesSchema = z . object ( {
4631 type : z . literal ( 'time' ) ,
4732 sourceId : objectIdSchema ,
@@ -52,7 +37,7 @@ const timeChartSeriesSchema = z.object({
5237 where : z . string ( ) ,
5338 whereLanguage : whereLanguageSchema ,
5439 groupBy : z . array ( z . string ( ) ) . max ( 10 ) ,
55- numberFormat : numberFormatSchema . optional ( ) ,
40+ numberFormat : NumberFormatSchema . optional ( ) ,
5641 metricDataType : z . optional ( z . nativeEnum ( MetricsDataType ) ) ,
5742 metricName : z . string ( ) . optional ( ) ,
5843 displayType : z
@@ -73,7 +58,7 @@ const tableChartSeriesSchema = z.object({
7358 whereLanguage : whereLanguageSchema ,
7459 groupBy : z . array ( z . string ( ) ) . max ( 10 ) ,
7560 sortOrder : z . union ( [ z . literal ( 'desc' ) , z . literal ( 'asc' ) ] ) . optional ( ) ,
76- numberFormat : numberFormatSchema . optional ( ) ,
61+ numberFormat : NumberFormatSchema . optional ( ) ,
7762 metricDataType : z . nativeEnum ( MetricsDataType ) . optional ( ) ,
7863 metricName : z . string ( ) . optional ( ) ,
7964} ) ;
@@ -89,7 +74,7 @@ const numberChartSeriesSchema = z.object({
8974 alias : z . string ( ) . optional ( ) ,
9075 where : z . string ( ) ,
9176 whereLanguage : whereLanguageSchema ,
92- numberFormat : numberFormatSchema . optional ( ) ,
77+ numberFormat : NumberFormatSchema . optional ( ) ,
9378 metricDataType : z . nativeEnum ( MetricsDataType ) . optional ( ) ,
9479 metricName : z . string ( ) . optional ( ) ,
9580} ) ;
0 commit comments