Expand `Message` type definitions

pull/1/head
Daniel Gasienica 7 years ago
parent b50c55172d
commit 1659354f51

@ -1,29 +1,28 @@
import { Attachment } from './Attachment'; import { Attachment } from './Attachment';
export type Message = IncomingMessage | OutgoingMessage; export type Message
= IncomingMessage
| OutgoingMessage
| VerifiedChangeMessage;
export type IncomingMessage = { export type IncomingMessage = Readonly<{
type: 'incoming'; type: 'incoming';
attachments: Array<Attachment>; attachments: Array<Attachment>;
body?: string; body?: string;
conversationId: string;
decrypted_at?: number; decrypted_at?: number;
errors?: Array<any>; errors?: Array<any>;
flags?: number; flags?: number;
id: string; id: string;
received_at: number; received_at: number;
sent_at: number;
source?: string; source?: string;
sourceDevice?: number; sourceDevice?: number;
timestamp: number; } & SharedMessageProperties & Message4 & ExpirationTimerUpdate>;
} & Message4
export type OutgoingMessage = { export type OutgoingMessage = Readonly<{
type: 'outgoing'; type: 'outgoing';
attachments: Array<Attachment>; attachments: Array<Attachment>;
body?: string; body?: string;
conversationId: string;
delivered: number; delivered: number;
delivered_to: Array<string>; delivered_to: Array<string>;
destination: string; // PhoneNumber destination: string; // PhoneNumber
@ -34,14 +33,30 @@ export type OutgoingMessage = {
received_at: number; received_at: number;
recipients?: Array<string>; // Array<PhoneNumber> recipients?: Array<string>; // Array<PhoneNumber>
sent: boolean; sent: boolean;
sent_at: number;
sent_to: Array<string>; // Array<PhoneNumber> sent_to: Array<string>; // Array<PhoneNumber>
synced: boolean; synced: boolean;
} & SharedMessageProperties & Message4 & ExpirationTimerUpdate>;
export type VerifiedChangeMessage = Readonly<{
type: 'verified-change';
} & SharedMessageProperties & Message4 & ExpirationTimerUpdate>;
type SharedMessageProperties = Readonly<{
conversationId: string;
sent_at: number;
timestamp: number; timestamp: number;
} & Message4 }>;
type ExpirationTimerUpdate = Readonly<{
expirationTimerUpdate?: Readonly<{
expireTimer: number;
fromSync: boolean;
source: string; // PhoneNumber
}>,
}>;
interface Message4 { type Message4 = Readonly<{
numAttachments?: number; numAttachments?: number;
numVisualMediaAttachments?: number; numVisualMediaAttachments?: number;
numFileAttachments?: number; numFileAttachments?: number;
} }>;

Loading…
Cancel
Save