mime-chat/src/types.ts

131 lines
2.1 KiB
TypeScript

/**
* Messages from platform except for CLOSE_AUTH_FAIL
*/
interface ClientProtocol {
header: string;
body: Init | Update;
}
/**
* Initial message from platform to seed uiState
*/
interface Init {
profile: Profile;
messages: Message[];
}
/**
* Update something in uiState
*/
interface Update {
name: string;
data: Profile | Message[] | Message | Annotation | string;
}
/**
* A standard message in Messenger
*/
interface Message {
modifier: string;
content: Content[];
context: Context;
seen: boolean;
uid: string;
}
interface Content {
text: string;
audio: string | boolean;
}
interface Context {
img: string | boolean;
text: string | boolean;
}
/**
* Update a specific attribute in a given message
*/
interface Annotation {
name: string;
data: Context | Content[] | boolean;
uid: string;
}
/**
* Send raw, uncategorized data to the platform
*/
interface Raw {
text: string | boolean;
audio: Int16Array | boolean;
}
/**
* The oppisite of Raw, when you know exactly what needs to get done
*/
interface PlatformRequest {
intent: string;
params: any;
epic: string | boolean;
confidence: number;
}
interface WindowState {
width: number;
height: number;
x: number | null;
y: number | null;
}
interface Profile {
crimata_id: string;
name: string;
photo: string;
}
interface AccountCredentials {
email: string;
password: string;
}
/*
* Electron Ipc
*/
interface IpcHandlerCallback<I, O> {
(payload: I | null): Promise<Error | O>;
}
interface IpcListenerCallback<T> {
(payload: T): void;
}
interface IIpcHandler<I, O> {
handle(): void;
remove(): void;
readonly _handlerCallback: IpcHandlerCallback<I, O>;
}
interface IIpcListener<I> {
listen(): void;
remove(): void;
readonly _listenerCallback: IpcListenerCallback<I>;
}
interface IPCHandlers {
[handler: string]: IIpcHandler<any, any>;
}
interface IPCListeners {
[listener: string]: IIpcListener<any> | null;
}
interface IpcRendererEvent<T> {
channel: string;
payload: T | null;
}
interface FocusPayload {
isFocused: boolean;
}