import { jsonSchema } from "../../shared/src/json-schema.js";
import * as v from "../../shared/src/valita.js";
import { astSchema } from "./ast.js";
export const transformRequestBodySchema = v.array(v.object({
    id: v.string(),
    name: v.string(),
    args: v.readonly(v.array(jsonSchema)),
}));
export const transformedQuerySchema = v.object({
    id: v.string(),
    name: v.string(),
    ast: astSchema,
});
export const appQueryErrorSchema = v.object({
    error: v.literal('app'),
    id: v.string(),
    name: v.string(),
    details: jsonSchema,
});
export const zeroErrorSchema = v.object({
    error: v.literal('zero'),
    id: v.string(),
    name: v.string(),
    details: jsonSchema,
});
export const httpQueryErrorSchema = v.object({
    error: v.literal('http'),
    id: v.string(),
    name: v.string(),
    status: v.number(),
    details: jsonSchema,
});
export const erroredQuerySchema = v.union(appQueryErrorSchema, httpQueryErrorSchema, zeroErrorSchema);
export const transformResponseBodySchema = v.array(v.union(transformedQuerySchema, erroredQuerySchema));
export const transformRequestMessageSchema = v.tuple([
    v.literal('transform'),
    transformRequestBodySchema,
]);
export const transformErrorMessageSchema = v.tuple([
    v.literal('transformError'),
    v.array(erroredQuerySchema),
]);
export const transformResponseMessageSchema = v.tuple([
    v.literal('transformed'),
    transformResponseBodySchema,
]);
//# sourceMappingURL=custom-queries.js.map