import * as v from "../../../../shared/src/valita.js";
import {} from "../change-source/protocol/current/data.js";
import { changeStreamDataSchema } from "../change-source/protocol/current/downstream.js";
// v1: Client-side support for JSON_FORMAT. Introduced in 0.18.
// v2: Adds the "status" message which is initially used to signal that the
//     subscription is valid (i.e. starting at the requested watermark).
//     Introduced in 0.19.
// v3: Adds the "taskID" to the subscription context, and support for
//     the BackupMonitor-mediated "/snapshot" request.
export const PROTOCOL_VERSION = 3;
/**
 * The StatusMessage payload for now is empty, but can be extended to
 * include meta-level information in the future.
 */
export const statusSchema = v.object({
    tag: v.literal('status'),
});
export const statusMessageSchema = v.tuple([v.literal('status'), statusSchema]);
const subscriptionErrorSchema = v.object({
    type: v.number(), // ErrorType
    message: v.string().optional(),
});
const errorSchema = v.tuple([v.literal('error'), subscriptionErrorSchema]);
export const downstreamSchema = v.union(statusMessageSchema, changeStreamDataSchema, errorSchema);
//# sourceMappingURL=change-streamer.js.map