UNPKG

@timescaledb/schemas

Version:

This package contains Zod schemas and types for all TimescaleDB objects.

149 lines (148 loc) 5.47 kB
import { z } from 'zod'; import { TimeRange } from './time-range'; import { WhereClause } from './where'; export declare const TimeBucketMetricTypeSchema: z.ZodEnum<["count", "distinct_count", "sum", "avg", "min", "max", "first", "last"]>; export type TimeBucketMetricType = z.infer<typeof TimeBucketMetricTypeSchema>; export declare const MetricConfigSchema: z.ZodObject<{ type: z.ZodEnum<["count", "distinct_count", "sum", "avg", "min", "max", "first", "last"]>; column: z.ZodOptional<z.ZodString>; alias: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { type: "count" | "sum" | "avg" | "min" | "max" | "distinct_count" | "first" | "last"; column?: string | undefined; alias?: string | undefined; }, { type: "count" | "sum" | "avg" | "min" | "max" | "distinct_count" | "first" | "last"; column?: string | undefined; alias?: string | undefined; }>; export type MetricConfig = z.infer<typeof MetricConfigSchema>; export declare const TimeBucketConfigSchema: z.ZodObject<{ interval: z.ZodString; metrics: z.ZodArray<z.ZodObject<{ type: z.ZodEnum<["count", "distinct_count", "sum", "avg", "min", "max", "first", "last"]>; column: z.ZodOptional<z.ZodString>; alias: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { type: "count" | "sum" | "avg" | "min" | "max" | "distinct_count" | "first" | "last"; column?: string | undefined; alias?: string | undefined; }, { type: "count" | "sum" | "avg" | "min" | "max" | "distinct_count" | "first" | "last"; column?: string | undefined; alias?: string | undefined; }>, "many">; }, "strip", z.ZodTypeAny, { interval: string; metrics: { type: "count" | "sum" | "avg" | "min" | "max" | "distinct_count" | "first" | "last"; column?: string | undefined; alias?: string | undefined; }[]; }, { interval: string; metrics: { type: "count" | "sum" | "avg" | "min" | "max" | "distinct_count" | "first" | "last"; column?: string | undefined; alias?: string | undefined; }[]; }>; export type TimeBucketConfig = z.infer<typeof TimeBucketConfigSchema>; export declare const TimeBucketRowSchema: z.ZodIntersection<z.ZodObject<{ interval: z.ZodString; }, "strip", z.ZodTypeAny, { interval: string; }, { interval: string; }>, z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodNumber, z.ZodString]>>>; export type TimeBucketRow = z.infer<typeof TimeBucketRowSchema>; export declare const TimeBucketResultSchema: z.ZodArray<z.ZodIntersection<z.ZodObject<{ interval: z.ZodString; }, "strip", z.ZodTypeAny, { interval: string; }, { interval: string; }>, z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodNumber, z.ZodString]>>>, "many">; export type TimeBucketResult = z.infer<typeof TimeBucketResultSchema>; export declare const GetTimeBucketOptionsSchema: z.ZodObject<{ range: z.ZodObject<{ column_name: z.ZodString; }, "strip", z.ZodTypeAny, { column_name: string; }, { column_name: string; }>; where: z.ZodOptional<z.ZodString>; config: z.ZodObject<{ interval: z.ZodString; metrics: z.ZodArray<z.ZodObject<{ type: z.ZodEnum<["count", "distinct_count", "sum", "avg", "min", "max", "first", "last"]>; column: z.ZodOptional<z.ZodString>; alias: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { type: "count" | "sum" | "avg" | "min" | "max" | "distinct_count" | "first" | "last"; column?: string | undefined; alias?: string | undefined; }, { type: "count" | "sum" | "avg" | "min" | "max" | "distinct_count" | "first" | "last"; column?: string | undefined; alias?: string | undefined; }>, "many">; }, "strip", z.ZodTypeAny, { interval: string; metrics: { type: "count" | "sum" | "avg" | "min" | "max" | "distinct_count" | "first" | "last"; column?: string | undefined; alias?: string | undefined; }[]; }, { interval: string; metrics: { type: "count" | "sum" | "avg" | "min" | "max" | "distinct_count" | "first" | "last"; column?: string | undefined; alias?: string | undefined; }[]; }>; }, "strip", z.ZodTypeAny, { config: { interval: string; metrics: { type: "count" | "sum" | "avg" | "min" | "max" | "distinct_count" | "first" | "last"; column?: string | undefined; alias?: string | undefined; }[]; }; range: { column_name: string; }; where?: string | undefined; }, { config: { interval: string; metrics: { type: "count" | "sum" | "avg" | "min" | "max" | "distinct_count" | "first" | "last"; column?: string | undefined; alias?: string | undefined; }[]; }; range: { column_name: string; }; where?: string | undefined; }>; export type EntityColumns<T> = { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]; export interface TimeBucketMetric<T> { type: TimeBucketMetricType; column?: EntityColumns<T>; alias?: string; } export interface TimeBucketOptions<T> { timeRange: TimeRange; bucket: { interval: string; metrics: TimeBucketMetric<T>[]; }; where?: WhereClause; }