import { jsonSchema } from "../../shared/src/json-schema.js";
import { readonly } from "../../shared/src/valita.js";
import { astSchema } from "./ast.js";
import { object, number, string, literal, array, union } from "@badrap/valita";
const putOpSchema = object({
  op: literal("put"),
  hash: string(),
  ttl: number().optional()
});
const upPutOpSchema = putOpSchema.extend({
  // All fields are optional in this transitional period.
  // - ast is filled in for client queries
  // - name and args are filled in for custom queries
  ast: astSchema.optional(),
  name: string().optional(),
  args: readonly(array(jsonSchema)).optional()
});
const delOpSchema = object({
  op: literal("del"),
  hash: string()
});
const clearOpSchema = object({
  op: literal("clear")
});
const patchOpSchema = union(putOpSchema, delOpSchema, clearOpSchema);
const upPatchOpSchema = union(upPutOpSchema, delOpSchema, clearOpSchema);
const queriesPatchSchema = array(patchOpSchema);
const upQueriesPatchSchema = array(upPatchOpSchema);
export {
  putOpSchema,
  queriesPatchSchema,
  upPutOpSchema,
  upQueriesPatchSchema
};
//# sourceMappingURL=queries-patch.js.map
