import { z } from "zod";
const aggregateFunctionSchema = z.enum(["count", "sum", "avg", "min", "max"]);
const dateGranularitySchema = z.enum(["day", "week", "month", "quarter", "year"]);
const dateRangePresetSchema = z.enum([
  "today",
  "yesterday",
  "this_week",
  "last_week",
  "this_month",
  "last_month",
  "this_quarter",
  "last_quarter",
  "this_year",
  "last_year",
  "last_7_days",
  "last_30_days",
  "last_90_days"
]);
const filterOperatorSchema = z.enum([
  "eq",
  "neq",
  "gt",
  "gte",
  "lt",
  "lte",
  "in",
  "not_in",
  "is_null",
  "is_not_null"
]);
const widgetDataRequestSchema = z.object({
  entityType: z.string().min(1),
  metric: z.object({
    field: z.string().min(1),
    aggregate: aggregateFunctionSchema
  }),
  groupBy: z.object({
    field: z.string().min(1),
    granularity: dateGranularitySchema.optional(),
    limit: z.number().int().min(1).max(100).optional(),
    resolveLabels: z.boolean().optional()
  }).optional(),
  filters: z.array(
    z.object({
      field: z.string().min(1),
      operator: filterOperatorSchema,
      value: z.unknown().optional()
    })
  ).optional(),
  dateRange: z.object({
    field: z.string().min(1),
    preset: dateRangePresetSchema
  }).optional(),
  comparison: z.object({
    type: z.enum(["previous_period", "previous_year"])
  }).optional()
});
const widgetDataItemSchema = z.object({
  groupKey: z.unknown(),
  groupLabel: z.string().optional(),
  value: z.number().nullable()
});
const widgetDataResponseSchema = z.object({
  value: z.number().nullable(),
  data: z.array(widgetDataItemSchema),
  comparison: z.object({
    value: z.number().nullable(),
    change: z.number(),
    direction: z.enum(["up", "down", "unchanged"])
  }).optional(),
  metadata: z.object({
    fetchedAt: z.string(),
    recordCount: z.number()
  })
});
export {
  aggregateFunctionSchema,
  dateGranularitySchema,
  dateRangePresetSchema,
  filterOperatorSchema,
  widgetDataItemSchema,
  widgetDataRequestSchema,
  widgetDataResponseSchema
};
//# sourceMappingURL=schema.js.map
