convex
Version:
Client for the Convex Cloud
128 lines • 3.45 kB
TypeScript
import { JSONValue } from "@convex-dev/common";
import { Long } from "../long.js";
/**
* Shared schema
*/
export declare function u64ToLong(encoded: EncodedU64): U64;
export declare function parseServerMessage(encoded: EncodedServerMessage): ServerMessage;
declare type U64 = Long;
declare type EncodedU64 = string;
/**
* Unique nonnegative integer identifying a single query.
*/
export declare type QueryId = number;
export declare type QuerySetVersion = number;
export declare type MutationId = number;
export declare type IdentityVersion = number;
/**
* Client message schema
*/
declare type Connect = {
type: "Connect";
sessionId: string;
connectionCount: number;
};
export declare type AddQuery = {
type: "Add";
queryId: QueryId;
udfPath: string;
args: JSONValue[];
};
export declare type RemoveQuery = {
type: "Remove";
queryId: QueryId;
};
export declare type QuerySetModification = {
type: "ModifyQuerySet";
baseVersion: QuerySetVersion;
newVersion: QuerySetVersion;
modifications: (AddQuery | RemoveQuery)[];
};
export declare type Mutation = {
type: "Mutation";
mutationId: MutationId;
udfPath: string;
args: JSONValue[];
};
export declare type Authenticate = {
type: "Authenticate";
tokenType: "Admin";
value: string;
baseVersion: IdentityVersion;
} | {
type: "Authenticate";
tokenType: "User";
value: string;
baseVersion: IdentityVersion;
} | {
type: "Authenticate";
tokenType: "None";
baseVersion: IdentityVersion;
};
export declare type ClientMessage = Connect | Authenticate | QuerySetModification | Mutation;
/**
* Server message schema
*/
declare type TS = U64;
declare type EncodedTS = EncodedU64;
declare type LogLines = string[];
export declare type StateVersion = {
querySet: QueryId;
ts: TS;
identity: IdentityVersion;
};
declare type EncodedStateVersion = Omit<StateVersion, "ts"> & {
ts: EncodedTS;
};
declare type StateModification = {
type: "QueryUpdated";
queryId: QueryId;
value: JSONValue;
logLines: LogLines;
} | {
type: "QueryFailed";
queryId: QueryId;
errorMessage: string;
logLines: LogLines;
} | {
type: "QueryRemoved";
queryId: QueryId;
};
export declare type Transition = {
type: "Transition";
startVersion: StateVersion;
endVersion: StateVersion;
modifications: StateModification[];
};
declare type MutationSuccess = {
type: "MutationResponse";
mutationId: MutationId;
success: true;
result: JSONValue;
ts: TS;
logLines: LogLines;
};
declare type MutationFailed = {
type: "MutationResponse";
mutationId: MutationId;
success: false;
result: string;
logLines: LogLines;
};
export declare type MutationResponse = MutationSuccess | MutationFailed;
declare type FatalError = {
type: "FatalError";
error: string;
};
export declare type ServerMessage = Transition | MutationResponse | FatalError;
declare type EncodedTransition = Omit<Transition, "startVersion" | "endVersion"> & {
startVersion: EncodedStateVersion;
endVersion: EncodedStateVersion;
};
declare type EncodedMutationSuccess = Omit<MutationSuccess, "ts"> & {
ts: EncodedTS;
};
declare type EncodedMutationResponse = MutationFailed | EncodedMutationSuccess;
declare type EncodedServerMessage = EncodedTransition | EncodedMutationResponse | FatalError;
export {};
//# sourceMappingURL=protocol.d.ts.map