import * as v from '../../../../../../shared/src/valita.ts';
import { type ShardConfig } from '../../../../types/shards.ts';
export declare const PROTOCOL_VERSION = 1;
export declare const ddlEventSchema: v.ObjectType<Omit<{
    context: v.ObjectType<{
        query: v.Type<string>;
    }, v.Type<string>>;
}, "schema" | "version"> & {
    version: v.Type<1>;
    schema: v.Type<{
        indexes: {
            isReplicaIdentity?: boolean | undefined;
            isPrimaryKey?: boolean | undefined;
            isImmediate?: boolean | undefined;
            name: string;
            columns: Record<string, "ASC" | "DESC">;
            schema: string;
            tableName: string;
            unique: boolean;
        }[];
        tables: {
            replicaIdentityColumns: string[];
            primaryKey?: string[] | undefined;
            schemaOID?: number | undefined;
            replicaIdentity?: "n" | "d" | "f" | "i" | undefined;
            name: string;
            schema: string;
            oid: number;
            columns: Record<string, {
                pgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | undefined;
                elemPgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | null | undefined;
                characterMaximumLength?: number | null | undefined;
                notNull?: boolean | null | undefined;
                dflt?: string | null | undefined;
                pos: number;
                dataType: string;
                typeOID: number;
            }>;
            publications: Record<string, {
                rowFilter: string | null;
            }>;
        }[];
    }>;
}, undefined>;
export declare const ddlStartEventSchema: v.ObjectType<Omit<Omit<{
    context: v.ObjectType<{
        query: v.Type<string>;
    }, v.Type<string>>;
}, "schema" | "version"> & {
    version: v.Type<1>;
    schema: v.Type<{
        indexes: {
            isReplicaIdentity?: boolean | undefined;
            isPrimaryKey?: boolean | undefined;
            isImmediate?: boolean | undefined;
            name: string;
            columns: Record<string, "ASC" | "DESC">;
            schema: string;
            tableName: string;
            unique: boolean;
        }[];
        tables: {
            replicaIdentityColumns: string[];
            primaryKey?: string[] | undefined;
            schemaOID?: number | undefined;
            replicaIdentity?: "n" | "d" | "f" | "i" | undefined;
            name: string;
            schema: string;
            oid: number;
            columns: Record<string, {
                pgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | undefined;
                elemPgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | null | undefined;
                characterMaximumLength?: number | null | undefined;
                notNull?: boolean | null | undefined;
                dflt?: string | null | undefined;
                pos: number;
                dataType: string;
                typeOID: number;
            }>;
            publications: Record<string, {
                rowFilter: string | null;
            }>;
        }[];
    }>;
}, "type"> & {
    type: v.Type<"ddlStart">;
}, undefined>;
export type DdlStartEvent = v.Infer<typeof ddlStartEventSchema>;
/**
 * The {@link DdlUpdateEvent} contains an updated schema resulting from
 * a particular ddl event. The event type provides information
 * (i.e. constraints) on the difference from the schema of the preceding
 * {@link DdlStartEvent}.
 *
 * Note that in almost all cases (the exception being `CREATE` events),
 * it is possible that there is no relevant difference between the
 * ddl-start schema and the ddl-update schema, as many aspects of the
 * schema (e.g. column constraints) are not relevant to downstream
 * replication.
 */
export declare const ddlUpdateEventSchema: v.ObjectType<Omit<Omit<{
    context: v.ObjectType<{
        query: v.Type<string>;
    }, v.Type<string>>;
}, "schema" | "version"> & {
    version: v.Type<1>;
    schema: v.Type<{
        indexes: {
            isReplicaIdentity?: boolean | undefined;
            isPrimaryKey?: boolean | undefined;
            isImmediate?: boolean | undefined;
            name: string;
            columns: Record<string, "ASC" | "DESC">;
            schema: string;
            tableName: string;
            unique: boolean;
        }[];
        tables: {
            replicaIdentityColumns: string[];
            primaryKey?: string[] | undefined;
            schemaOID?: number | undefined;
            replicaIdentity?: "n" | "d" | "f" | "i" | undefined;
            name: string;
            schema: string;
            oid: number;
            columns: Record<string, {
                pgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | undefined;
                elemPgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | null | undefined;
                characterMaximumLength?: number | null | undefined;
                notNull?: boolean | null | undefined;
                dflt?: string | null | undefined;
                pos: number;
                dataType: string;
                typeOID: number;
            }>;
            publications: Record<string, {
                rowFilter: string | null;
            }>;
        }[];
    }>;
}, "type" | "event"> & {
    type: v.Type<"ddlUpdate">;
    event: v.ObjectType<{
        tag: v.Type<string>;
    }, undefined>;
}, undefined>;
export type DdlUpdateEvent = v.Infer<typeof ddlUpdateEventSchema>;
/**
 * The `schemaSnapshot` message is a snapshot of a schema taken in response to
 * a `COMMENT ON PUBLICATION` command, which is a hook recognized by zero
 * to manually emit schema snapshots to support detection of schema changes
 * from `ALTER PUBLICATION` commands on supabase, which does not fire event
 * triggers for them (https://github.com/supabase/supautils/issues/123).
 *
 * The hook is exercised by bookmarking the publication change with
 * `COMMENT ON PUBLICATION` statements within e.g.
 *
 * ```sql
 * BEGIN;
 * COMMENT ON PUBLICATION my_publication IS 'whatever';
 * ALTER PUBLICATION my_publication ...;
 * COMMENT ON PUBLICATION my_publication IS 'whatever';
 * COMMIT;
 * ```
 *
 * The `change-source` will perform the diff between a `schemaSnapshot`
 * events and its preceding `schemaSnapshot` (or `ddlUpdate`) within the
 * transaction.
 *
 * In the case where event trigger support is missing, this results in
 * diffing the `schemaSnapshot`s before and after the `ALTER PUBLICATION`
 * statement, thus effecting the same logic that would have been exercised
 * between the `ddlStart` and `ddlEvent` events fired by a database with
 * fully functional event triggers.
 *
 * Note that if the same transaction is run on a database that *does*
 * support event triggers on `ALTER PUBLICATION` statements, the sequence
 * of emitted messages will be:
 *
 * * `schemaSnapshot`
 * * `ddlStart`
 * * `ddlUpdate`
 * * `schemaSnapshot`
 *
 * Since `schemaSnapshot` messages are diffed with the preceding
 * `schemaSnapshot` or `ddlUpdate` event (if any), there will be no schema
 * difference between the `ddlUpdate` and the second `schemaSnapshot`, and
 * thus the extra `COMMENT` statements will effectively be no-ops.
 */
export declare const schemaSnapshotEventSchema: v.ObjectType<Omit<Omit<{
    context: v.ObjectType<{
        query: v.Type<string>;
    }, v.Type<string>>;
}, "schema" | "version"> & {
    version: v.Type<1>;
    schema: v.Type<{
        indexes: {
            isReplicaIdentity?: boolean | undefined;
            isPrimaryKey?: boolean | undefined;
            isImmediate?: boolean | undefined;
            name: string;
            columns: Record<string, "ASC" | "DESC">;
            schema: string;
            tableName: string;
            unique: boolean;
        }[];
        tables: {
            replicaIdentityColumns: string[];
            primaryKey?: string[] | undefined;
            schemaOID?: number | undefined;
            replicaIdentity?: "n" | "d" | "f" | "i" | undefined;
            name: string;
            schema: string;
            oid: number;
            columns: Record<string, {
                pgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | undefined;
                elemPgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | null | undefined;
                characterMaximumLength?: number | null | undefined;
                notNull?: boolean | null | undefined;
                dflt?: string | null | undefined;
                pos: number;
                dataType: string;
                typeOID: number;
            }>;
            publications: Record<string, {
                rowFilter: string | null;
            }>;
        }[];
    }>;
}, "type" | "event"> & {
    type: v.Type<"schemaSnapshot">;
    event: v.ObjectType<{
        tag: v.Type<string>;
    }, undefined>;
}, undefined>;
export type SchemaSnapshotEvent = v.Infer<typeof schemaSnapshotEventSchema>;
export declare const replicationEventSchema: v.UnionType<[v.ObjectType<Omit<Omit<{
    context: v.ObjectType<{
        query: v.Type<string>;
    }, v.Type<string>>;
}, "schema" | "version"> & {
    version: v.Type<1>;
    schema: v.Type<{
        indexes: {
            isReplicaIdentity?: boolean | undefined;
            isPrimaryKey?: boolean | undefined;
            isImmediate?: boolean | undefined;
            name: string;
            columns: Record<string, "ASC" | "DESC">;
            schema: string;
            tableName: string;
            unique: boolean;
        }[];
        tables: {
            replicaIdentityColumns: string[];
            primaryKey?: string[] | undefined;
            schemaOID?: number | undefined;
            replicaIdentity?: "n" | "d" | "f" | "i" | undefined;
            name: string;
            schema: string;
            oid: number;
            columns: Record<string, {
                pgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | undefined;
                elemPgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | null | undefined;
                characterMaximumLength?: number | null | undefined;
                notNull?: boolean | null | undefined;
                dflt?: string | null | undefined;
                pos: number;
                dataType: string;
                typeOID: number;
            }>;
            publications: Record<string, {
                rowFilter: string | null;
            }>;
        }[];
    }>;
}, "type"> & {
    type: v.Type<"ddlStart">;
}, undefined>, v.ObjectType<Omit<Omit<{
    context: v.ObjectType<{
        query: v.Type<string>;
    }, v.Type<string>>;
}, "schema" | "version"> & {
    version: v.Type<1>;
    schema: v.Type<{
        indexes: {
            isReplicaIdentity?: boolean | undefined;
            isPrimaryKey?: boolean | undefined;
            isImmediate?: boolean | undefined;
            name: string;
            columns: Record<string, "ASC" | "DESC">;
            schema: string;
            tableName: string;
            unique: boolean;
        }[];
        tables: {
            replicaIdentityColumns: string[];
            primaryKey?: string[] | undefined;
            schemaOID?: number | undefined;
            replicaIdentity?: "n" | "d" | "f" | "i" | undefined;
            name: string;
            schema: string;
            oid: number;
            columns: Record<string, {
                pgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | undefined;
                elemPgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | null | undefined;
                characterMaximumLength?: number | null | undefined;
                notNull?: boolean | null | undefined;
                dflt?: string | null | undefined;
                pos: number;
                dataType: string;
                typeOID: number;
            }>;
            publications: Record<string, {
                rowFilter: string | null;
            }>;
        }[];
    }>;
}, "type" | "event"> & {
    type: v.Type<"ddlUpdate">;
    event: v.ObjectType<{
        tag: v.Type<string>;
    }, undefined>;
}, undefined>, v.ObjectType<Omit<Omit<{
    context: v.ObjectType<{
        query: v.Type<string>;
    }, v.Type<string>>;
}, "schema" | "version"> & {
    version: v.Type<1>;
    schema: v.Type<{
        indexes: {
            isReplicaIdentity?: boolean | undefined;
            isPrimaryKey?: boolean | undefined;
            isImmediate?: boolean | undefined;
            name: string;
            columns: Record<string, "ASC" | "DESC">;
            schema: string;
            tableName: string;
            unique: boolean;
        }[];
        tables: {
            replicaIdentityColumns: string[];
            primaryKey?: string[] | undefined;
            schemaOID?: number | undefined;
            replicaIdentity?: "n" | "d" | "f" | "i" | undefined;
            name: string;
            schema: string;
            oid: number;
            columns: Record<string, {
                pgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | undefined;
                elemPgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | null | undefined;
                characterMaximumLength?: number | null | undefined;
                notNull?: boolean | null | undefined;
                dflt?: string | null | undefined;
                pos: number;
                dataType: string;
                typeOID: number;
            }>;
            publications: Record<string, {
                rowFilter: string | null;
            }>;
        }[];
    }>;
}, "type" | "event"> & {
    type: v.Type<"schemaSnapshot">;
    event: v.ObjectType<{
        tag: v.Type<string>;
    }, undefined>;
}, undefined>]>;
export type ReplicationEvent = v.Infer<typeof replicationEventSchema>;
export declare const TAGS: readonly ["CREATE TABLE", "ALTER TABLE", "CREATE INDEX", "DROP TABLE", "DROP INDEX", "ALTER PUBLICATION", "ALTER SCHEMA"];
export declare function createEventTriggerStatements(shard: ShardConfig): string;
export declare function dropEventTriggerStatements(appID: string, shardID: string | number): string;
//# sourceMappingURL=ddl.d.ts.map