Add basic `Message` type definition

This commit is contained in:
Daniel Gasienica 2018-04-09 19:26:48 -04:00
parent 9513e90a84
commit f25a579f32
1 changed files with 47 additions and 0 deletions

47
ts/types/Message.ts Normal file
View File

@ -0,0 +1,47 @@
import { Attachment } from './Attachment';
export type Message = IncomingMessage | OutgoingMessage;
export type IncomingMessage = {
type: 'incoming';
attachments: Array<Attachment>;
body?: string;
conversationId: string;
decrypted_at?: number;
errors?: Array<any>;
flags?: number;
id: string;
received_at: number;
sent_at: number;
source?: string;
sourceDevice?: number;
timestamp: number;
} & Message4
export type OutgoingMessage = {
type: 'outgoing';
attachments: Array<Attachment>;
body?: string;
conversationId: string;
delivered: number;
delivered_to: Array<string>;
destination: string; // PhoneNumber
expirationStartTimestamp: number;
expires_at?: number;
expireTimer?: number;
id: string;
received_at: number;
recipients?: Array<string>; // Array<PhoneNumber>
sent: boolean;
sent_at: number;
sent_to: Array<string>; // Array<PhoneNumber>
synced: boolean;
timestamp: number;
} & Message4
interface Message4 {
numAttachments?: number;
numVisualMediaAttachments?: number;
numFileAttachments?: number;
}