UNPKG

@casual-simulation/aux-common

Version:
1,683 lines 60.7 kB
import type { AuthorizeActionMissingPermission, DenialReason } from '../common/DenialReason';
import type { NotSupportedError, ServerError } from '../Errors';
import type { ConnectionInfo } from '../common/ConnectionInfo';
import type { RemoteAction, DeviceAction, DeviceActionResult, RemoteActionResult, RemoteActionError, DeviceActionError } from '../common/RemoteActions';
import { z } from 'zod';
import type { GenericHttpRequest, GenericHttpResponse } from '../http/GenericHttpInterface';
import type { PublicUserInfo, ResourceKinds, SubjectType } from '../common';
import type { KnownErrorCodes } from '../rpc/ErrorCodes';
/**
 * Defines a websocket event.
 *
 * That is, an event that is used to manage and communicate over a websocket connection.
 *
 * There are currently three types of events:
 * - message: A message that was recieved.
 * - upload_request: A request to upload a large message to a large object store. (This event type only exists to get around message size limits)
 * - upload_response: A response to an upload_request event. (This event type only exists to get around message size limits)
 * - download_request: A request to tell the client to download a message from from a URL. (This event type only exists to get around message size limits)
 */
export type WebsocketEvent = WebsocketMessageEvent | WebsocketUploadRequestEvent | WebsocketUploadResponseEvent | WebsocketDownloadRequestEvent | WebsocketErrorEvent;
export declare enum WebsocketEventTypes {
    Message = 1,
    UploadRequest = 2,
    UploadResponse = 3,
    DownloadRequest = 4,
    Error = 5
}
export declare const websocketEventSchema: (() => z.ZodTuple<[z.ZodEnum<typeof WebsocketEventTypes>, z.ZodNumber], z.ZodAny>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodTuple<[z.ZodEnum<typeof WebsocketEventTypes>, z.ZodNumber], z.ZodAny>>;
};
/**
 * Defines a websocket event that contains a message.
 */
export type WebsocketMessageEvent = [
    type: WebsocketEventTypes.Message,
    id: number,
    data: WebsocketMessage
];
/**
 * Defines a websocket event that contains a request to upload a large message.
 */
export type WebsocketUploadRequestEvent = [
    type: WebsocketEventTypes.UploadRequest,
    id: number
];
export declare const websocketUploadRequestEventSchema: (() => z.ZodTuple<[z.ZodLiteral<WebsocketEventTypes.UploadRequest>, z.ZodNumber], null>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodTuple<[z.ZodLiteral<WebsocketEventTypes.UploadRequest>, z.ZodNumber], null>>;
};
export interface UploadHttpHeaders {
    [key: string]: string;
}
/**
 * Defines a websocket event that contains a response to an upload request.
 */
export type WebsocketUploadResponseEvent = [
    type: WebsocketEventTypes.UploadResponse,
    id: number,
    uploadUrl: string,
    uploadMethod: string,
    uploadHeaders: UploadHttpHeaders
];
export declare const websocketUploadResponseEventSchema: (() => z.ZodTuple<[z.ZodLiteral<WebsocketEventTypes.UploadResponse>, z.ZodNumber, z.ZodString, z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>], null>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodTuple<[z.ZodLiteral<WebsocketEventTypes.UploadResponse>, z.ZodNumber, z.ZodString, z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>], null>>;
};
export type WebsocketErrorCode = ServerError | NotSupportedError | KnownErrorCodes | 'invalid_record_key' | 'unacceptable_connection_token' | 'invalid_token' | 'session_expired' | 'user_is_banned' | 'unacceptable_connection_id' | 'message_not_found' | 'unacceptable_request' | 'record_not_found' | 'not_authorized' | 'action_not_supported' | 'not_logged_in' | 'subscription_limit_reached' | 'inst_not_found' | 'invalid_connection_state';
/**
 * Defines an interface that contains information about an error that occurred.
 */
export interface WebsocketErrorInfo {
    success: false;
    /**
     * The name of the record that the error is associated with.
     */
    recordName?: string | null;
    /**
     * The name of the inst that the error is associated with.
     */
    inst?: string;
    /**
     * The name of the branch that the error is associated with.
     */
    branch?: string;
    /**
     * The error code that occurred.
     */
    errorCode: WebsocketErrorCode;
    /**
     * The error message.
     */
    errorMessage: string;
    /**
     * The list of parsing issues that occurred.
     */
    issues?: z.core.$ZodIssue[];
    /**
     * The authorization denial reason.
     */
    reason?: DenialReason;
}
export declare const websocketErrorInfoSchema: (() => z.ZodObject<{
    errorCode: z.ZodString;
    errorMessage: z.ZodString;
    issues: z.ZodOptional<z.ZodArray<z.ZodAny>>;
    reason: z.ZodOptional<z.ZodAny>;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        errorCode: z.ZodString;
        errorMessage: z.ZodString;
        issues: z.ZodOptional<z.ZodArray<z.ZodAny>>;
        reason: z.ZodOptional<z.ZodAny>;
    }, z.core.$strip>>;
};
/**
 * Defines a websocket event that contains a response to an upload request.
 */
export type WebsocketErrorEvent = [
    type: WebsocketEventTypes.Error,
    id: number,
    info: WebsocketErrorInfo
];
export declare const websocketErrorEventSchema: (() => z.ZodTuple<[z.ZodLiteral<WebsocketEventTypes.Error>, z.ZodNumber, z.ZodObject<{
    errorCode: z.ZodString;
    errorMessage: z.ZodString;
    issues: z.ZodOptional<z.ZodArray<z.ZodAny>>;
    reason: z.ZodOptional<z.ZodAny>;
}, z.core.$strip>], null>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodTuple<[z.ZodLiteral<WebsocketEventTypes.Error>, z.ZodNumber, z.ZodObject<{
        errorCode: z.ZodString;
        errorMessage: z.ZodString;
        issues: z.ZodOptional<z.ZodArray<z.ZodAny>>;
        reason: z.ZodOptional<z.ZodAny>;
    }, z.core.$strip>], null>>;
};
/**
 * Defines a websocket event that contains a request to download a large message.
 */
export type WebsocketDownloadRequestEvent = [
    type: WebsocketEventTypes.DownloadRequest,
    id: number,
    downloadUrl: string,
    downloadMethod: string,
    downloadHeaders: UploadHttpHeaders
];
export declare const websocketDownloadRequestEventSchema: (() => z.ZodTuple<[z.ZodLiteral<WebsocketEventTypes.DownloadRequest>, z.ZodNumber, z.ZodString, z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>], null>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodTuple<[z.ZodLiteral<WebsocketEventTypes.DownloadRequest>, z.ZodNumber, z.ZodString, z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>], null>>;
};
export type WebsocketResponseMessage = LoginResultMessage | WatchBranchResultMessage | TimeSyncResponseMessage | UpdatesReceivedMessage | ReceiveDeviceActionMessage | ConnectedToBranchMessage | DisconnectedFromBranchMessage | RateLimitExceededMessage | WebsocketHttpResponseMessage | WebsocketHttpPartialResponseMessage | RequestMissingPermissionResponseMessage;
export type WebsocketRequestMessage = LoginMessage | WatchBranchMessage | UnwatchBranchMessage | AddUpdatesMessage | SendActionMessage | WatchBranchDevicesMessage | UnwatchBranchDevicesMessage | ConnectionCountMessage | TimeSyncRequestMessage | GetUpdatesMessage | WebsocketHttpRequestMessage | RequestMissingPermissionMessage | RequestMissingPermissionResponseMessage;
export type WebsocketMessage = WebsocketRequestMessage | WebsocketResponseMessage;
/**
 * Defines a login message.
 */
export interface LoginMessage {
    type: 'login';
    /**
     * The token that should be used to authenticate the connection.
     */
    connectionToken?: string;
    /**
     * The ID that the client wants to use for the connection.
     * Must be unique.
     */
    connectionId?: string;
}
export declare const loginMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"login">;
    connectionToken: z.ZodOptional<z.ZodString>;
    connectionId: z.ZodOptional<z.ZodString>;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"login">;
        connectionToken: z.ZodOptional<z.ZodString>;
        connectionId: z.ZodOptional<z.ZodString>;
    }, z.core.$strip>>;
};
/**
 * Defines a login result message.
 */
export type LoginResultMessage = LoginResultSuccessMessage | LoginResultFailureMessage;
export interface LoginResultBaseMessage {
    type: 'login_result';
}
export interface LoginResultSuccessMessage extends LoginResultBaseMessage {
    success: true;
    /**
     * The info for the connection.
     */
    info: ConnectionInfo;
}
export interface LoginResultFailureMessage extends LoginResultBaseMessage {
    success: false;
    /**
     * The error code that occurred.
     */
    errorCode: WebsocketErrorCode;
    /**
     * The error message that occurred.
     */
    errorMessage: string;
    /**
     * The authorization denial reason.
     */
    reason?: DenialReason;
}
/**
 * Defines an event which indicates that a branch should be watched.
 */
export interface WatchBranchMessage {
    type: 'repo/watch_branch';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * Whether the branch expires and should be deleted when it is no longer needed.
     * If not provided, the default is derived from the record name.
     */
    expires?: boolean;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The name of the branch to watch.
     */
    branch: string;
    /**
     * Whether the branch should be temporary.
     * That is, if the branch data should not be loaded from the database
     * and everything should be deleted once all the watchers have left.
     * Defaults to false.
     */
    temporary?: boolean;
    /**
     * The protocol that should be used.
     * Currently, "updates" is the only supported protocol.
     */
    protocol?: 'updates';
    /**
     * The markers that should be set on the inst if it is new.
     * If the inst already exists, this field is ignored.
     * If not provided, the default markers will be used.
     */
    markers?: string[];
}
export declare const watchBranchMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"repo/watch_branch">;
    recordName: z.ZodNullable<z.ZodString>;
    expires: z.ZodOptional<z.ZodBoolean>;
    inst: z.ZodString;
    branch: z.ZodString;
    temporary: z.ZodOptional<z.ZodBoolean>;
    markers: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"repo/watch_branch">;
        recordName: z.ZodNullable<z.ZodString>;
        expires: z.ZodOptional<z.ZodBoolean>;
        inst: z.ZodString;
        branch: z.ZodString;
        temporary: z.ZodOptional<z.ZodBoolean>;
        markers: z.ZodOptional<z.ZodArray<z.ZodString>>;
    }, z.core.$strip>>;
};
export type WatchBranchResultMessage = WatchBranchResultSuccessMessage | WatchBranchResultFailureMessage;
export interface WatchBranchResultSuccessMessage {
    type: 'repo/watch_branch_result';
    success: true;
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The name of the branch to watch.
     */
    branch: string;
}
export interface WatchBranchResultFailureMessage {
    type: 'repo/watch_branch_result';
    success: false;
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The name of the branch to watch.
     */
    branch: string;
    /**
     * The error code that occurred.
     */
    errorCode: WebsocketErrorCode;
    /**
     * The error message that occurred.
     */
    errorMessage: string;
    /**
     * The authorization denial reason.
     */
    reason?: DenialReason;
}
/**
 * Defines an event which indicates that a branch should be unwatched.
 */
export interface UnwatchBranchMessage {
    type: 'repo/unwatch_branch';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The name of the branch to unwatch.
     */
    branch: string;
}
export declare const unwatchBranchMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"repo/unwatch_branch">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"repo/unwatch_branch">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodString;
        branch: z.ZodString;
    }, z.core.$strip>>;
};
/**
 * Defines an event which indicates that devices connected to a branch should be watched.
 */
export interface WatchBranchDevicesMessage {
    type: 'repo/watch_branch_devices';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The name of the branch to unwatch.
     */
    branch: string;
}
export declare const watchBranchDevicesMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"repo/watch_branch_devices">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"repo/watch_branch_devices">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodString;
        branch: z.ZodString;
    }, z.core.$strip>>;
};
/**
 * Defines an event which indicates that devices connected to a branch should be no longer be watched.
 */
export interface UnwatchBranchDevicesMessage {
    type: 'repo/unwatch_branch_devices';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The name of the branch to unwatch.
     */
    branch: string;
}
export declare const unwatchBranchDevicesMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"repo/unwatch_branch_devices">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"repo/unwatch_branch_devices">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodString;
        branch: z.ZodString;
    }, z.core.$strip>>;
};
/**
 * Defines an event which indicates that some arbitrary updates should be added for the given branch.
 * Note that while all branches support both atoms and updates, they do not support mixed usage.
 * This means that clients which use updates should ignore atoms and vice versa.
 */
export interface AddUpdatesMessage {
    type: 'repo/add_updates';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The branch that the updates are for.
     */
    branch: string;
    /**
     * The updates that should be added.
     */
    updates: string[];
    /**
     * The ID for this "add update" event.
     * Used in the subsequent "update received" event to indicate
     * that this update was received and processed.
     *
     * This property is optional because update IDs are only needed for updates which are sent to the
     * server to be saved. (i.e. the client needs confirmation that it was saved) The server needs no such
     * confirmation, so it does not need to include an update ID.
     */
    updateId?: number;
    /**
     * Whether this message should be treated as the first message
     * after a watch_branch event.
     * This flag MUST be included on the first message as large apiary messages may appear out of order.
     */
    initial?: boolean;
    /**
     * The list of timestamps that the updates occurred at.
     */
    timestamps?: number[];
}
export declare const addUpdatesMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"repo/add_updates">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
    updates: z.ZodArray<z.ZodString>;
    updateId: z.ZodOptional<z.ZodNumber>;
    initial: z.ZodOptional<z.ZodBoolean>;
    timestamps: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"repo/add_updates">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodString;
        branch: z.ZodString;
        updates: z.ZodArray<z.ZodString>;
        updateId: z.ZodOptional<z.ZodNumber>;
        initial: z.ZodOptional<z.ZodBoolean>;
        timestamps: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
    }, z.core.$strip>>;
};
/**
 * Defines an event which indicates that the updates for the given branch should be retrieved.
 */
export interface GetUpdatesMessage {
    type: 'repo/get_updates';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The branch that the updates are for.
     */
    branch: string;
}
export declare const getUpdatesMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"repo/get_updates">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"repo/get_updates">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodString;
        branch: z.ZodString;
    }, z.core.$strip>>;
};
/**
 * Defines an event which indicates that an HTTP request should be made.
 */
export interface WebsocketHttpRequestMessage {
    type: 'http_request';
    /**
     * The ID of the request.
     */
    id: number;
    /**
     * The HTTP request.
     */
    request: Omit<GenericHttpRequest, 'ipAddress'>;
}
export declare const websocketHttpRequestMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"http_request">;
    request: z.ZodObject<{
        path: z.ZodString;
        pathParams: z.ZodObject<{}, z.core.$catchall<z.ZodString>>;
        method: z.ZodUnion<readonly [z.ZodLiteral<"GET">, z.ZodLiteral<"POST">, z.ZodLiteral<"PUT">, z.ZodLiteral<"DELETE">, z.ZodLiteral<"HEAD">, z.ZodLiteral<"OPTIONS">]>;
        query: z.ZodObject<{}, z.core.$catchall<z.ZodString>>;
        headers: z.ZodObject<{}, z.core.$catchall<z.ZodString>>;
        body: z.ZodUnion<readonly [z.ZodString, z.ZodNull]>;
    }, z.core.$strip>;
    id: z.ZodNumber;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"http_request">;
        request: z.ZodObject<{
            path: z.ZodString;
            pathParams: z.ZodObject<{}, z.core.$catchall<z.ZodString>>;
            method: z.ZodUnion<readonly [z.ZodLiteral<"GET">, z.ZodLiteral<"POST">, z.ZodLiteral<"PUT">, z.ZodLiteral<"DELETE">, z.ZodLiteral<"HEAD">, z.ZodLiteral<"OPTIONS">]>;
            query: z.ZodObject<{}, z.core.$catchall<z.ZodString>>;
            headers: z.ZodObject<{}, z.core.$catchall<z.ZodString>>;
            body: z.ZodUnion<readonly [z.ZodString, z.ZodNull]>;
        }, z.core.$strip>;
        id: z.ZodNumber;
    }, z.core.$strip>>;
};
export interface WebsocketHttpResponseMessage {
    type: 'http_response';
    /**
     * The ID of the request that this response is for.
     */
    id: number;
    /**
     * The response.
     */
    response: GenericHttpResponse;
}
export interface WebsocketHttpPartialResponseMessage {
    type: 'http_partial_response';
    /**
     * The ID of the request that this response is for.
     */
    id: number;
    /**
     * The index of the partial response.
     */
    index: number;
    /**
     * Whether this message is the final message.
     * If true, then the response will be omitted.
     */
    final?: boolean;
    /**
     * The response.
     */
    response?: Partial<GenericHttpResponse>;
}
/**
 * Defines an event which indicates that some arbitrary updates where added for the given branch.
 */
export interface UpdatesReceivedMessage {
    type: 'repo/updates_received';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The branch that the updates were received for.
     */
    branch: string;
    /**
     * The ID that was included in the original "add update" event.
     */
    updateId: number;
    /**
     * The error code that occurred.
     * If omitted, then no error occurred.
     */
    errorCode?: 'max_size_reached' | 'record_not_found' | 'inst_not_found';
    /**
     * The maximum allowed size for the inst.
     * Only included when the errorCode is set to "max_size_reached".
     */
    maxBranchSizeInBytes?: number;
    /**
     * The size that the inst would be at if the updates were added.
     * Only included when the errorCode is set to "max_size_reached".
     */
    neededBranchSizeInBytes?: number;
}
export declare const updatesReceivedMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"repo/updates_received">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
    updateId: z.ZodNumber;
    errorCode: z.ZodOptional<z.ZodEnum<{
        record_not_found: "record_not_found";
        inst_not_found: "inst_not_found";
        max_size_reached: "max_size_reached";
    }>>;
    maxBranchSizeInBytes: z.ZodOptional<z.ZodNumber>;
    neededBranchSizeInBytes: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"repo/updates_received">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodString;
        branch: z.ZodString;
        updateId: z.ZodNumber;
        errorCode: z.ZodOptional<z.ZodEnum<{
            record_not_found: "record_not_found";
            inst_not_found: "inst_not_found";
            max_size_reached: "max_size_reached";
        }>>;
        maxBranchSizeInBytes: z.ZodOptional<z.ZodNumber>;
        neededBranchSizeInBytes: z.ZodOptional<z.ZodNumber>;
    }, z.core.$strip>>;
};
/**
 * Sends the given remote action to devices connected to the given branch.
 */
export interface SendActionMessage {
    type: 'repo/send_action';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The branch.
     */
    branch: string;
    /**
     * The action to send.
     */
    action: RemoteAction | RemoteActionResult | RemoteActionError;
}
export declare const sendActionMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"repo/send_action">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
    action: z.ZodDiscriminatedUnion<[z.ZodObject<{
        connectionId: z.ZodOptional<z.ZodString>;
        sessionId: z.ZodOptional<z.ZodString>;
        userId: z.ZodOptional<z.ZodString>;
        broadcast: z.ZodOptional<z.ZodBoolean>;
        type: z.ZodLiteral<"remote">;
        event: z.ZodAny;
        allowBatching: z.ZodOptional<z.ZodBoolean>;
        taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
    }, z.core.$strip>, z.ZodObject<{
        connectionId: z.ZodOptional<z.ZodString>;
        sessionId: z.ZodOptional<z.ZodString>;
        userId: z.ZodOptional<z.ZodString>;
        broadcast: z.ZodOptional<z.ZodBoolean>;
        type: z.ZodLiteral<"remote_result">;
        result: z.ZodOptional<z.ZodAny>;
        taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
    }, z.core.$strip>, z.ZodObject<{
        connectionId: z.ZodOptional<z.ZodString>;
        sessionId: z.ZodOptional<z.ZodString>;
        userId: z.ZodOptional<z.ZodString>;
        broadcast: z.ZodOptional<z.ZodBoolean>;
        type: z.ZodLiteral<"remote_error">;
        error: z.ZodAny;
        taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
    }, z.core.$strip>], "type">;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"repo/send_action">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodString;
        branch: z.ZodString;
        action: z.ZodDiscriminatedUnion<[z.ZodObject<{
            connectionId: z.ZodOptional<z.ZodString>;
            sessionId: z.ZodOptional<z.ZodString>;
            userId: z.ZodOptional<z.ZodString>;
            broadcast: z.ZodOptional<z.ZodBoolean>;
            type: z.ZodLiteral<"remote">;
            event: z.ZodAny;
            allowBatching: z.ZodOptional<z.ZodBoolean>;
            taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
        }, z.core.$strip>, z.ZodObject<{
            connectionId: z.ZodOptional<z.ZodString>;
            sessionId: z.ZodOptional<z.ZodString>;
            userId: z.ZodOptional<z.ZodString>;
            broadcast: z.ZodOptional<z.ZodBoolean>;
            type: z.ZodLiteral<"remote_result">;
            result: z.ZodOptional<z.ZodAny>;
            taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
        }, z.core.$strip>, z.ZodObject<{
            connectionId: z.ZodOptional<z.ZodString>;
            sessionId: z.ZodOptional<z.ZodString>;
            userId: z.ZodOptional<z.ZodString>;
            broadcast: z.ZodOptional<z.ZodBoolean>;
            type: z.ZodLiteral<"remote_error">;
            error: z.ZodAny;
            taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
        }, z.core.$strip>], "type">;
    }, z.core.$strip>>;
};
/**
 * Sends the given device action to devices connected to the given branch.
 */
export interface ReceiveDeviceActionMessage {
    type: 'repo/receive_action';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The branch that the action is for.
     */
    branch: string;
    /**
     * The action that should be sent.
     */
    action: DeviceAction | DeviceActionResult | DeviceActionError;
}
export declare const receiveDeviceActionMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"repo/receive_action">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
    action: z.ZodDiscriminatedUnion<[z.ZodObject<{
        type: z.ZodLiteral<"device">;
        connection: z.ZodObject<{
            connectionId: z.ZodString;
            sessionId: z.ZodString;
            userId: z.ZodString;
        }, z.core.$strip>;
        event: z.ZodAny;
        taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
    }, z.core.$strip>, z.ZodObject<{
        type: z.ZodLiteral<"device_result">;
        result: z.ZodAny;
        taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
        connection: z.ZodObject<{
            connectionId: z.ZodString;
            sessionId: z.ZodString;
            userId: z.ZodString;
        }, z.core.$strip>;
    }, z.core.$strip>, z.ZodObject<{
        type: z.ZodLiteral<"device_error">;
        error: z.ZodAny;
        taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
        connection: z.ZodObject<{
            connectionId: z.ZodString;
            sessionId: z.ZodString;
            userId: z.ZodString;
        }, z.core.$strip>;
    }, z.core.$strip>], "type">;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"repo/receive_action">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodString;
        branch: z.ZodString;
        action: z.ZodDiscriminatedUnion<[z.ZodObject<{
            type: z.ZodLiteral<"device">;
            connection: z.ZodObject<{
                connectionId: z.ZodString;
                sessionId: z.ZodString;
                userId: z.ZodString;
            }, z.core.$strip>;
            event: z.ZodAny;
            taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
        }, z.core.$strip>, z.ZodObject<{
            type: z.ZodLiteral<"device_result">;
            result: z.ZodAny;
            taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
            connection: z.ZodObject<{
                connectionId: z.ZodString;
                sessionId: z.ZodString;
                userId: z.ZodString;
            }, z.core.$strip>;
        }, z.core.$strip>, z.ZodObject<{
            type: z.ZodLiteral<"device_error">;
            error: z.ZodAny;
            taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
            connection: z.ZodObject<{
                connectionId: z.ZodString;
                sessionId: z.ZodString;
                userId: z.ZodString;
            }, z.core.$strip>;
        }, z.core.$strip>], "type">;
    }, z.core.$strip>>;
};
/**
 * Defines an event which indicates that a connection has been made to a branch.
 */
export interface ConnectedToBranchMessage {
    type: 'repo/connected_to_branch';
    /**
     * Whether this event is for WATCH_DEVICES listeners or WATCH_BRANCH_DEVICES listeners.
     * If true, then listeners for a specific branch should ignore the event.
     */
    broadcast: boolean;
    /**
     * The name of the branch that was connected.
     */
    branch: WatchBranchMessage;
    /**
     * The info of session that connected.
     */
    connection: ConnectionInfo;
}
export declare const connectedToBranchMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"repo/connected_to_branch">;
    broadcast: z.ZodBoolean;
    branch: z.ZodObject<{
        type: z.ZodLiteral<"repo/watch_branch">;
        recordName: z.ZodNullable<z.ZodString>;
        expires: z.ZodOptional<z.ZodBoolean>;
        inst: z.ZodString;
        branch: z.ZodString;
        temporary: z.ZodOptional<z.ZodBoolean>;
        markers: z.ZodOptional<z.ZodArray<z.ZodString>>;
    }, z.core.$strip>;
    connection: z.ZodObject<{
        connectionId: z.ZodString;
        sessionId: z.ZodString;
        userId: z.ZodString;
    }, z.core.$strip>;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"repo/connected_to_branch">;
        broadcast: z.ZodBoolean;
        branch: z.ZodObject<{
            type: z.ZodLiteral<"repo/watch_branch">;
            recordName: z.ZodNullable<z.ZodString>;
            expires: z.ZodOptional<z.ZodBoolean>;
            inst: z.ZodString;
            branch: z.ZodString;
            temporary: z.ZodOptional<z.ZodBoolean>;
            markers: z.ZodOptional<z.ZodArray<z.ZodString>>;
        }, z.core.$strip>;
        connection: z.ZodObject<{
            connectionId: z.ZodString;
            sessionId: z.ZodString;
            userId: z.ZodString;
        }, z.core.$strip>;
    }, z.core.$strip>>;
};
/**
 * Defines an event which indicates that a connection has been removed from a branch.
 */
export interface DisconnectedFromBranchMessage {
    type: 'repo/disconnected_from_branch';
    /**
     * Whether this event is for WATCH_DEVICES listeners or WATCH_BRANCH_DEVICES listeners.
     * If true, then listeners for a specific branch should ignore the event.
     */
    broadcast: boolean;
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The name of the branch that was disconnected.
     */
    branch: string;
    /**
     * The info of session that disconnected.
     */
    connection: ConnectionInfo;
}
export declare const disconnectedFromBranchMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"repo/disconnected_from_branch">;
    broadcast: z.ZodBoolean;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
    connection: z.ZodObject<{
        connectionId: z.ZodString;
        sessionId: z.ZodString;
        userId: z.ZodString;
    }, z.core.$strip>;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"repo/disconnected_from_branch">;
        broadcast: z.ZodBoolean;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodString;
        branch: z.ZodString;
        connection: z.ZodObject<{
            connectionId: z.ZodString;
            sessionId: z.ZodString;
            userId: z.ZodString;
        }, z.core.$strip>;
    }, z.core.$strip>>;
};
export interface ConnectionCountMessage {
    type: 'repo/connection_count';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     * Null if all connections should be counted.
     */
    inst: string | null;
    /**
     * The name of the branch.
     * Null if all connections should be counted.
     */
    branch: string | null;
    /**
     * The number of connections.
     */
    count?: number;
}
export declare const connectionCountMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"repo/connection_count">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodNullable<z.ZodString>;
    branch: z.ZodNullable<z.ZodString>;
    count: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"repo/connection_count">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodNullable<z.ZodString>;
        branch: z.ZodNullable<z.ZodString>;
        count: z.ZodOptional<z.ZodNumber>;
    }, z.core.$strip>>;
};
/**
 * Defines an event which attempts to perform a time sync.
 */
export interface TimeSyncRequestMessage {
    type: 'sync/time';
    /**
     * The ID of the sync request.
     */
    id: number;
    /**
     * The client time in miliseconds since Jan 1 1970 UTC-0 that the request was made at.
     */
    clientRequestTime: number;
}
export declare const timeSyncRequestMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"sync/time">;
    id: z.ZodNumber;
    clientRequestTime: z.ZodNumber;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"sync/time">;
        id: z.ZodNumber;
        clientRequestTime: z.ZodNumber;
    }, z.core.$strip>>;
};
/**
 * Defines an event which is the response for a time sync.
 */
export interface TimeSyncResponseMessage {
    type: 'sync/time/response';
    /**
     * The ID of the sync request.
     */
    id: number;
    /**
     * The client time in miliseconds since Jan 1 1970 UTC-0 that the request was made at.
     */
    clientRequestTime: number;
    /**
     * The time that the server received the request at in miliseconds since Jan 1 1970 UTC-0.
     */
    serverReceiveTime: number;
    /**
     * The time that the server sent this response at in miliseconds since Jan 1 1970 UTC-0.
     */
    serverTransmitTime: number;
}
export declare const timeSyncResponseMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"sync/time/response">;
    id: z.ZodNumber;
    clientRequestTime: z.ZodNumber;
    serverReceiveTime: z.ZodNumber;
    serverTransmitTime: z.ZodNumber;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"sync/time/response">;
        id: z.ZodNumber;
        clientRequestTime: z.ZodNumber;
        serverReceiveTime: z.ZodNumber;
        serverTransmitTime: z.ZodNumber;
    }, z.core.$strip>>;
};
export interface RequestMissingPermissionMessage {
    type: 'permission/request/missing';
    /**
     * The permission that should be requested.
     */
    reason: AuthorizeActionMissingPermission;
    /**
     * The info of session that requested the permission.
     */
    connection?: ConnectionInfo;
    /**
     * The info about the user that is requesting the permission.
     */
    user?: PublicUserInfo;
}
export declare const requestMissingPermissionMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"permission/request/missing">;
    reason: z.ZodObject<{
        type: z.ZodLiteral<"missing_permission">;
        recordName: z.ZodString;
        resourceKind: z.ZodEnum<{
            search: "search";
            inst: "inst";
            file: "file";
            event: "event";
            role: "role";
            data: "data";
            marker: "marker";
            loom: "loom";
            "ai.sloyd": "ai.sloyd";
            "ai.hume": "ai.hume";
            "ai.openai.realtime": "ai.openai.realtime";
            "ai.chat": "ai.chat";
            "ai.image": "ai.image";
            "ai.skybox": "ai.skybox";
            webhook: "webhook";
            notification: "notification";
            package: "package";
            "package.version": "package.version";
            database: "database";
            purchasableItem: "purchasableItem";
            contract: "contract";
            invoice: "invoice";
        }>;
        resourceId: z.ZodString;
        action: z.ZodEnum<{
            run: "run";
            read: "read";
            create: "create";
            update: "update";
            delete: "delete";
            assign: "assign";
            unassign: "unassign";
            increment: "increment";
            count: "count";
            list: "list";
            grantPermission: "grantPermission";
            revokePermission: "revokePermission";
            grant: "grant";
            revoke: "revoke";
            sendAction: "sendAction";
            updateData: "updateData";
            send: "send";
            subscribe: "subscribe";
            unsubscribe: "unsubscribe";
            listSubscriptions: "listSubscriptions";
            purchase: "purchase";
            approve: "approve";
            cancel: "cancel";
        }>;
        subjectType: z.ZodEnum<{
            inst: "inst";
            user: "user";
            role: "role";
        }>;
        subjectId: z.ZodString;
    }, z.core.$strip>;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"permission/request/missing">;
        reason: z.ZodObject<{
            type: z.ZodLiteral<"missing_permission">;
            recordName: z.ZodString;
            resourceKind: z.ZodEnum<{
                search: "search";
                inst: "inst";
                file: "file";
                event: "event";
                role: "role";
                data: "data";
                marker: "marker";
                loom: "loom";
                "ai.sloyd": "ai.sloyd";
                "ai.hume": "ai.hume";
                "ai.openai.realtime": "ai.openai.realtime";
                "ai.chat": "ai.chat";
                "ai.image": "ai.image";
                "ai.skybox": "ai.skybox";
                webhook: "webhook";
                notification: "notification";
                package: "package";
                "package.version": "package.version";
                database: "database";
                purchasableItem: "purchasableItem";
                contract: "contract";
                invoice: "invoice";
            }>;
            resourceId: z.ZodString;
            action: z.ZodEnum<{
                run: "run";
                read: "read";
                create: "create";
                update: "update";
                delete: "delete";
                assign: "assign";
                unassign: "unassign";
                increment: "increment";
                count: "count";
                list: "list";
                grantPermission: "grantPermission";
                revokePermission: "revokePermission";
                grant: "grant";
                revoke: "revoke";
                sendAction: "sendAction";
                updateData: "updateData";
                send: "send";
                subscribe: "subscribe";
                unsubscribe: "unsubscribe";
                listSubscriptions: "listSubscriptions";
                purchase: "purchase";
                approve: "approve";
                cancel: "cancel";
            }>;
            subjectType: z.ZodEnum<{
                inst: "inst";
                user: "user";
                role: "role";
            }>;
            subjectId: z.ZodString;
        }, z.core.$strip>;
    }, z.core.$strip>>;
};
export type RequestMissingPermissionResponseMessage = RequestMissingPermissionResponseSuccessMessage | RequestMissingPermissionResponseFailureMessage;
export interface RequestMissingPermissionResponseSuccessMessage {
    type: 'permission/request/missing/response';
    success: true;
    recordName: string;
    resourceKind: ResourceKinds;
    resourceId: string;
    subjectType: SubjectType;
    subjectId: string;
    /**
     * The connection that responded to the request.
     */
    connection?: ConnectionInfo;
}
export interface RequestMissingPermissionResponseFailureMessage {
    type: 'permission/request/missing/response';
    success: false;
    recordName: string;
    resourceKind: ResourceKinds;
    resourceId: string;
    subjectType: SubjectType;
    subjectId: string;
    errorCode: WebsocketErrorCode;
    errorMessage: string;
    /**
     * The connection that responded to the request.
     */
    connection?: ConnectionInfo;
}
export declare const requestMissingPermissionResponseMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"permission/request/missing/response">;
    success: z.ZodBoolean;
    recordName: z.ZodString;
    resourceKind: z.ZodEnum<{
        search: "search";
        inst: "inst";
        file: "file";
        event: "event";
        role: "role";
        data: "data";
        marker: "marker";
        loom: "loom";
        "ai.sloyd": "ai.sloyd";
        "ai.hume": "ai.hume";
        "ai.openai.realtime": "ai.openai.realtime";
        "ai.chat": "ai.chat";
        "ai.image": "ai.image";
        "ai.skybox": "ai.skybox";
        webhook: "webhook";
        notification: "notification";
        package: "package";
        "package.version": "package.version";
        database: "database";
        purchasableItem: "purchasableItem";
        contract: "contract";
        invoice: "invoice";
    }>;
    resourceId: z.ZodString;
    subjectType: z.ZodEnum<{
        inst: "inst";
        user: "user";
        role: "role";
    }>;
    subjectId: z.ZodString;
    errorCode: z.ZodOptional<z.ZodString>;
    errorMessage: z.ZodOptional<z.ZodString>;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"permission/request/missing/response">;
        success: z.ZodBoolean;
        recordName: z.ZodString;
        resourceKind: z.ZodEnum<{
            search: "search";
            inst: "inst";
            file: "file";
            event: "event";
            role: "role";
            data: "data";
            marker: "marker";
            loom: "loom";
            "ai.sloyd": "ai.sloyd";
            "ai.hume": "ai.hume";
            "ai.openai.realtime": "ai.openai.realtime";
            "ai.chat": "ai.chat";
            "ai.image": "ai.image";
            "ai.skybox": "ai.skybox";
            webhook: "webhook";
            notification: "notification";
            package: "package";
            "package.version": "package.version";
            database: "database";
            purchasableItem: "purchasableItem";
            contract: "contract";
            invoice: "invoice";
        }>;
        resourceId: z.ZodString;
        subjectType: z.ZodEnum<{
            inst: "inst";
            user: "user";
            role: "role";
        }>;
        subjectId: z.ZodString;
        errorCode: z.ZodOptional<z.ZodString>;
        errorMessage: z.ZodOptional<z.ZodString>;
    }, z.core.$strip>>;
};
export interface RateLimitExceededMessage {
    type: 'rate_limit_exceeded';
    retryAfter: number;
    totalHits: number;
}
export declare const rateLimitExceededMessageSchema: (() => z.ZodObject<{
    type: z.ZodLiteral<"rate_limit_exceeded">;
    retryAfter: z.ZodNumber;
    totalHits: z.ZodNumber;
}, z.core.$strip>) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
        type: z.ZodLiteral<"rate_limit_exceeded">;
        retryAfter: z.ZodNumber;
        totalHits: z.ZodNumber;
    }, z.core.$strip>>;
};
export declare const websocketRequestMessageSchema: (() => z.ZodDiscriminatedUnion<[z.ZodObject<{
    type: z.ZodLiteral<"login">;
    connectionToken: z.ZodOptional<z.ZodString>;
    connectionId: z.ZodOptional<z.ZodString>;
}, z.core.$strip>, z.ZodObject<{
    type: z.ZodLiteral<"repo/watch_branch">;
    recordName: z.ZodNullable<z.ZodString>;
    expires: z.ZodOptional<z.ZodBoolean>;
    inst: z.ZodString;
    branch: z.ZodString;
    temporary: z.ZodOptional<z.ZodBoolean>;
    markers: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strip>, z.ZodObject<{
    type: z.ZodLiteral<"repo/unwatch_branch">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
    type: z.ZodLiteral<"repo/add_updates">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
    updates: z.ZodArray<z.ZodString>;
    updateId: z.ZodOptional<z.ZodNumber>;
    initial: z.ZodOptional<z.ZodBoolean>;
    timestamps: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
}, z.core.$strip>, z.ZodObject<{
    type: z.ZodLiteral<"repo/send_action">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
    action: z.ZodDiscriminatedUnion<[z.ZodObject<{
        connectionId: z.ZodOptional<z.ZodString>;
        sessionId: z.ZodOptional<z.ZodString>;
        userId: z.ZodOptional<z.ZodString>;
        broadcast: z.ZodOptional<z.ZodBoolean>;
        type: z.ZodLiteral<"remote">;
        event: z.ZodAny;
        allowBatching: z.ZodOptional<z.ZodBoolean>;
        taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
    }, z.core.$strip>, z.ZodObject<{
        connectionId: z.ZodOptional<z.ZodString>;
        sessionId: z.ZodOptional<z.ZodString>;
        userId: z.ZodOptional<z.ZodString>;
        broadcast: z.ZodOptional<z.ZodBoolean>;
        type: z.ZodLiteral<"remote_result">;
        result: z.ZodOptional<z.ZodAny>;
        taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
    }, z.core.$strip>, z.ZodObject<{
        connectionId: z.ZodOptional<z.ZodString>;
        sessionId: z.ZodOptional<z.ZodString>;
        userId: z.ZodOptional<z.ZodString>;
        broadcast: z.ZodOptional<z.ZodBoolean>;
        type: z.ZodLiteral<"remote_error">;
        error: z.ZodAny;
        taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
    }, z.core.$strip>], "type">;
}, z.core.$strip>, z.ZodObject<{
    type: z.ZodLiteral<"repo/watch_branch_devices">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
    type: z.ZodLiteral<"repo/unwatch_branch_devices">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
    type: z.ZodLiteral<"repo/connection_count">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodNullable<z.ZodString>;
    branch: z.ZodNullable<z.ZodString>;
    count: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>, z.ZodObject<{
    type: z.ZodLiteral<"sync/time">;
    id: z.ZodNumber;
    clientRequestTime: z.ZodNumber;
}, z.core.$strip>, z.ZodObject<{
    type: z.ZodLiteral<"repo/get_updates">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
    type: z.ZodLiteral<"http_request">;
    request: z.ZodObject<{
        path: z.ZodString;
        pathParams: z.ZodObject<{}, z.core.$catchall<z.ZodString>>;
        method: z.ZodUnion<readonly [z.ZodLiteral<"GET">, z.ZodLiteral<"POST">, z.ZodLiteral<"PUT">, z.ZodLiteral<"DELETE">, z.ZodLiteral<"HEAD">, z.ZodLiteral<"OPTIONS">]>;
        query: z.ZodObject<{}, z.core.$catchall<z.ZodString>>;
        headers: z.ZodObject<{}, z.core.$catchall<z.ZodString>>;
        body: z.ZodUnion<readonly [z.ZodString, z.ZodNull]>;
    }, z.core.$strip>;
    id: z.ZodNumber;
}, z.core.$strip>, z.ZodObject<{
    type: z.ZodLiteral<"permission/request/missing">;
    reason: z.ZodObject<{
        type: z.ZodLiteral<"missing_permission">;
        recordName: z.ZodString;
        resourceKind: z.ZodEnum<{
            search: "search";
            inst: "inst";
            file: "file";
            event: "event";
            role: "role";
            data: "data";
            marker: "marker";
            loom: "loom";
            "ai.sloyd": "ai.sloyd";
            "ai.hume": "ai.hume";
            "ai.openai.realtime": "ai.openai.realtime";
            "ai.chat": "ai.chat";
            "ai.image": "ai.image";
            "ai.skybox": "ai.skybox";
            webhook: "webhook";
            notification: "notification";
            package: "package";
            "package.version": "package.version";
            database: "database";
            purchasableItem: "purchasableItem";
            contract: "contract";
            invoice: "invoice";
        }>;
        resourceId: z.ZodString;
        action: z.ZodEnum<{
            run: "run";
            read: "read";
            create: "create";
            update: "update";
            delete: "delete";
            assign: "assign";
            unassign: "unassign";
            increment: "increment";
            count: "count";
            list: "list";
            grantPermission: "grantPermission";
            revokePermission: "revokePermission";
            grant: "grant";
            revoke: "revoke";
            sendAction: "sendAction";
            updateData: "updateData";
            send: "send";
            subscribe: "subscribe";
            unsubscribe: "unsubscribe";
            listSubscriptions: "listSubscriptions";
            purchase: "purchase";
            approve: "approve";
            cancel: "cancel";
        }>;
        subjectType: z.ZodEnum<{
            inst: "inst";
            user: "user";
            role: "role";
        }>;
        subjectId: z.ZodString;
    }, z.core.$strip>;
}, z.core.$strip>, z.ZodObject<{
    type: z.ZodLiteral<"permission/request/missing/response">;
    success: z.ZodBoolean;
    recordName: z.ZodString;
    resourceKind: z.ZodEnum<{
        search: "search";
        inst: "inst";
        file: "file";
        event: "event";
        role: "role";
        data: "data";
        marker: "marker";
        loom: "loom";
        "ai.sloyd": "ai.sloyd";
        "ai.hume": "ai.hume";
        "ai.openai.realtime": "ai.openai.realtime";
        "ai.chat": "ai.chat";
        "ai.image": "ai.image";
        "ai.skybox": "ai.skybox";
        webhook: "webhook";
        notification: "notification";
        package: "package";
        "package.version": "package.version";
        database: "database";
        purchasableItem: "purchasableItem";
        contract: "contract";
        invoice: "invoice";
    }>;
    resourceId: z.ZodString;
    subjectType: z.ZodEnum<{
        inst: "inst";
        user: "user";
        role: "role";
    }>;
    subjectId: z.ZodString;
    errorCode: z.ZodOptional<z.ZodString>;
    errorMessage: z.ZodOptional<z.ZodString>;
}, z.core.$strip>], "type">) & {
    cache: import("es-toolkit").MemoizeCache<any, z.ZodDiscriminatedUnion<[z.ZodObject<{
        type: z.ZodLiteral<"login">;
        connectionToken: z.ZodOptional<z.ZodString>;
        connectionId: z.ZodOptional<z.ZodString>;
    }, z.core.$strip>, z.ZodObject<{
        type: z.ZodLiteral<"repo/watch_branch">;
        recordName: z.ZodNullable<z.ZodString>;
        expires: z.ZodOptional<z.ZodBoolean>;
        inst: z.ZodString;
        branch: z.ZodString;
        temporary: z.ZodOptional<z.ZodBoolean>;
        markers: z.ZodOptional<z.ZodArray<z.ZodString>>;
    }, z.core.$strip>, z.ZodObject<{
        type: z.ZodLiteral<"repo/unwatch_branch">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodString;
        branch: z.ZodString;
    }, z.core.$strip>, z.ZodObject<{
        type: z.ZodLiteral<"repo/add_updates">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodString;
        branch: z.ZodString;
        updates: z.ZodArray<z.ZodString>;
        updateId: z.ZodOptional<z.ZodNumber>;
        initial: z.ZodOptional<z.ZodBoolean>;
        timestamps: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
    }, z.core.$strip>, z.ZodObject<{
        type: z.ZodLiteral<"repo/send_action">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodString;
        branch: z.ZodString;
        action: z.ZodDiscriminatedUnion<[z.ZodObject<{
            connectionId: z.ZodOptional<z.ZodString>;
            sessionId: z.ZodOptional<z.ZodString>;
            userId: z.ZodOptional<z.ZodString>;
            broadcast: z.ZodOptional<z.ZodBoolean>;
            type: z.ZodLiteral<"remote">;
            event: z.ZodAny;
            allowBatching: z.ZodOptional<z.ZodBoolean>;
            taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
        }, z.core.$strip>, z.ZodObject<{
            connectionId: z.ZodOptional<z.ZodString>;
            sessionId: z.ZodOptional<z.ZodString>;
            userId: z.ZodOptional<z.ZodString>;
            broadcast: z.ZodOptional<z.ZodBoolean>;
            type: z.ZodLiteral<"remote_result">;
            result: z.ZodOptional<z.ZodAny>;
            taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
        }, z.core.$strip>, z.ZodObject<{
            connectionId: z.ZodOptional<z.ZodString>;
            sessionId: z.ZodOptional<z.ZodString>;
            userId: z.ZodOptional<z.ZodString>;
            broadcast: z.ZodOptional<z.ZodBoolean>;
            type: z.ZodLiteral<"remote_error">;
            error: z.ZodAny;
            taskId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
        }, z.core.$strip>], "type">;
    }, z.core.$strip>, z.ZodObject<{
        type: z.ZodLiteral<"repo/watch_branch_devices">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodString;
        branch: z.ZodString;
    }, z.core.$strip>, z.ZodObject<{
        type: z.ZodLiteral<"repo/unwatch_branch_devices">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodString;
        branch: z.ZodString;
    }, z.core.$strip>, z.ZodObject<{
        type: z.ZodLiteral<"repo/connection_count">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodNullable<z.ZodString>;
        branch: z.ZodNullable<z.ZodString>;
        count: z.ZodOptional<z.ZodNumber>;
    }, z.core.$strip>, z.ZodObject<{
        type: z.ZodLiteral<"sync/time">;
        id: z.ZodNumber;
        clientRequestTime: z.ZodNumber;
    }, z.core.$strip>, z.ZodObject<{
        type: z.ZodLiteral<"repo/get_updates">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodString;
        branch: z.ZodString;
    }, z.core.$strip>, z.ZodObject<{
        type: z.ZodLiteral<"http_request">;
        request: z.ZodObject<{
            path: z.ZodString;
            pathParams: z.ZodObject<{}, z.core.$catchall<z.ZodString>>;
            method: z.ZodUnion<readonly [z.ZodLiteral<"GET">, z.ZodLiteral<"POST">, z.ZodLiteral<"PUT">, z.ZodLiteral<"DELETE">, z.ZodLiteral<"HEAD">, z.ZodLiteral<"OPTIONS">]>;
            query: z.ZodObject<{}, z.core.$catchall<z.ZodString>>;
            headers: z.ZodObject<{}, z.core.$catchall<z.ZodString>>;
            body: z.ZodUnion<readonly [z.ZodString, z.ZodNull]>;
        }, z.core.$strip>;
        id: z.ZodNumber;
    }, z.core.$strip>, z.ZodObject<{
        type: z.ZodLiteral<"permission/request/missing">;
        reason: z.ZodObject<{
            type: z.ZodLiteral<"missing_permission">;
            recordName: z.ZodString;
            resourceKind: z.ZodEnum<{
                search: "search";
                inst: "inst";
                file: "file";
                event: "event";
                role: "role";
                data: "data";
                marker: "marker";
                loom: "loom";
                "ai.sloyd": "ai.sloyd";
                "ai.hume": "ai.hume";
                "ai.openai.realtime": "ai.openai.realtime";
                "ai.chat": "ai.chat";
                "ai.image": "ai.image";
                "ai.skybox": "ai.skybox";
                webhook: "webhook";
                notification: "notification";
                package: "package";
                "package.version": "package.version";
                database: "database";
                purchasableItem: "purchasableItem";
                contract: "contract";
                invoice: "invoice";
            }>;
            resourceId: z.ZodString;
            action: z.ZodEnum<{
                run: "run";
                read: "read";
                create: "create";
                update: "update";
                delete: "delete";
                assign: "assign";
                unassign: "unassign";
                increment: "increment";
                count: "count";
                list: "list";
                grantPermission: "grantPermission";
                revokePermission: "revokePermission";
                grant: "grant";
                revoke: "revoke";
                sendAction: "sendAction";
                updateData: "updateData";
                send: "send";
                subscribe: "subscribe";
                unsubscribe: "unsubscribe";
                listSubscriptions: "listSubscriptions";
                purchase: "purchase";
                approve: "approve";
                cancel: "cancel";
            }>;
            subjectType: z.ZodEnum<{
                inst: "inst";
                user: "user";
                role: "role";
            }>;
            subjectId: z.ZodString;
        }, z.core.$strip>;
    }, z.core.$strip>, z.ZodObject<{
        type: z.ZodLiteral<"permission/request/missing/response">;
        success: z.ZodBoolean;
        recordName: z.ZodString;
        resourceKind: z.ZodEnum<{
            search: "search";
            inst: "inst";
            file: "file";
            event: "event";
            role: "role";
            data: "data";
            marker: "marker";
            loom: "loom";
            "ai.sloyd": "ai.sloyd";
            "ai.hume": "ai.hume";
            "ai.openai.realtime": "ai.openai.realtime";
            "ai.chat": "ai.chat";
            "ai.image": "ai.image";
            "ai.skybox": "ai.skybox";
            webhook: "webhook";
            notification: "notification";
            package: "package";
            "package.version": "package.version";
            database: "database";
            purchasableItem: "purchasableItem";
            contract: "contract";
            invoice: "invoice";
        }>;
        resourceId: z.ZodString;
        subjectType: z.ZodEnum<{
            inst: "inst";
            user: "user";
            role: "role";
        }>;
        subjectId: z.ZodString;
        errorCode: z.ZodOptional<z.ZodString>;
        errorMessage: z.ZodOptional<z.ZodString>;
    }, z.core.$strip>], "type">>;
};
//# sourceMappingURL=WebsocketEvents.d.ts.map