import { jsonSchema } from "../../shared/src/json-schema.js";
import { readonlyArray } from "../../shared/src/valita.js";
import { astSchema } from "./ast.js";
import { object, string, literal, boolean, union, tuple } from "@badrap/valita";
const inspectUpBase = object({
  id: string()
});
const inspectQueriesUpBodySchema = inspectUpBase.extend({
  op: literal("queries"),
  clientID: string().optional()
});
const inspectMetricsUpSchema = inspectUpBase.extend({
  op: literal("metrics")
});
const inspectVersionUpSchema = inspectUpBase.extend({
  op: literal("version")
});
const inspectAuthenticateUpSchema = inspectUpBase.extend({
  op: literal("authenticate"),
  value: string()
});
const analyzeQueryOptionsSchema = object({
  vendedRows: boolean().optional(),
  syncedRows: boolean().optional(),
  joinPlans: boolean().optional()
});
const inspectAnalyzeQueryUpSchema = inspectUpBase.extend({
  op: literal("analyze-query"),
  /** @deprecated Use {@linkcode ast} instead */
  value: astSchema.optional(),
  options: analyzeQueryOptionsSchema.optional(),
  ast: astSchema.optional(),
  name: string().optional(),
  args: readonlyArray(jsonSchema).optional()
});
const inspectUpBodySchema = union(
  inspectQueriesUpBodySchema,
  inspectMetricsUpSchema,
  inspectVersionUpSchema,
  inspectAuthenticateUpSchema,
  inspectAnalyzeQueryUpSchema
);
const inspectUpMessageSchema = tuple([
  literal("inspect"),
  inspectUpBodySchema
]);
export {
  inspectAnalyzeQueryUpSchema,
  inspectAuthenticateUpSchema,
  inspectUpMessageSchema
};
//# sourceMappingURL=inspect-up.js.map
