import { z } from "zod";
const saveCredentialsSchema = z.object({
  credentials: z.record(
    z.string().min(1).max(128),
    z.union([z.string().max(2e4), z.number(), z.boolean(), z.null()])
  )
}).refine((value) => Object.keys(value.credentials).length <= 200, {
  message: "At most 200 credential fields are allowed"
});
const updateVersionSchema = z.object({
  apiVersion: z.string().min(1)
});
const updateStateSchema = z.object({
  isEnabled: z.boolean().optional(),
  reauthRequired: z.boolean().optional()
}).refine((value) => value.isEnabled !== void 0 || value.reauthRequired !== void 0, {
  message: "At least one state field must be provided"
});
const integrationLogLevelSchema = z.enum(["info", "warn", "error"]);
const listIntegrationLogsQuerySchema = z.object({
  integrationId: z.string().min(1).optional(),
  level: integrationLogLevelSchema.optional(),
  runId: z.string().uuid().optional(),
  entityType: z.string().optional(),
  entityId: z.string().uuid().optional(),
  page: z.coerce.number().int().min(1).default(1),
  pageSize: z.coerce.number().int().min(1).max(100).default(20)
});
const optionalBooleanQuery = z.preprocess(
  (value) => {
    if (value === void 0 || value === "" || value === null) return void 0;
    if (value === true || value === "true" || value === "1") return true;
    if (value === false || value === "false" || value === "0") return false;
    return value;
  },
  z.boolean().optional()
);
const integrationMarketplaceHealthStatusSchema = z.enum(["healthy", "degraded", "unhealthy", "unconfigured"]);
const listIntegrationsQuerySchema = z.object({
  q: z.string().max(200).optional(),
  category: z.string().max(64).optional(),
  bundleId: z.string().max(128).optional(),
  isEnabled: optionalBooleanQuery,
  healthStatus: integrationMarketplaceHealthStatusSchema.optional(),
  sort: z.enum(["title", "category", "enabledAt", "healthStatus"]).optional(),
  order: z.enum(["asc", "desc"]).default("asc"),
  page: z.coerce.number().int().min(1).default(1),
  pageSize: z.coerce.number().int().min(1).max(100).default(100)
});
export {
  integrationLogLevelSchema,
  integrationMarketplaceHealthStatusSchema,
  listIntegrationLogsQuerySchema,
  listIntegrationsQuerySchema,
  saveCredentialsSchema,
  updateStateSchema,
  updateVersionSchema
};
//# sourceMappingURL=validators.js.map
