@cloudbase/js-sdk
Version:
cloudbase javascript sdk
41 lines (40 loc) • 1.09 kB
TypeScript
export type DataType = 'init' | 'update' | 'add' | 'remove' | 'replace' | 'limit';
export type QueueType = 'init' | 'enqueue' | 'dequeue' | 'update';
export interface IDatabaseServiceContext extends IServiceContext {
appConfig: IAppConfig;
ws?: any;
}
export interface IAppConfig {
docSizeLimit: number;
realtimePingInterval: number;
realtimePongWaitTimeout: number;
request: any;
}
export interface IWatchOptions {
onChange: (snapshot: ISnapshot) => void;
onError: (error: any) => void;
}
export interface ISnapshot {
id: number;
docChanges: ISingleDBEvent[];
docs: Record<string, any>;
type?: SnapshotType;
}
export interface ISingleDBEvent {
id: number;
dataType: DataType;
queueType: QueueType;
docId: string;
doc: Record<string, any>;
updatedFields?: any;
removedFields?: any;
}
export type SnapshotType = 'init';
export interface DBRealtimeListener {
close: () => void;
}
export interface IRealtimeListenerConstructorOptions extends IWatchOptions {
}
export interface IServiceContext {
env?: string;
}