imessage-ts
Version:
TypeScript library for interacting with iMessage on macOS - send messages, monitor chats, and automate responses
136 lines • 3.26 kB
TypeScript
/**
* Types for iMessage database entities and API
*/
export declare enum MessageType {
TEXT = 0,
ATTACHMENT = 1,
REACTION = 2,
LINK = 3,
APP_STICKER = 4,
DIGITAL_TOUCH = 5
}
export declare enum MessageStatus {
SENT = 0,
DELIVERED = 1,
READ = 2,
FAILED = 3,
SENDING = 4
}
export declare enum AttachmentType {
IMAGE = "image",
VIDEO = "video",
AUDIO = "audio",
FILE = "file",
LOCATION = "location",
CONTACT = "contact",
APP_SPECIFIC = "app-specific"
}
export interface MessageAttachment {
id: string;
messageId: string;
fileName: string;
filePath: string;
fileSize: number;
mimeType: string;
transferName: string;
type: AttachmentType;
created: Date;
}
export interface MessageEntity {
id: string;
guid: string;
text: string | null;
handle: string | null;
handleId: number | null;
service: string;
date: Date;
dateRead: Date | null;
dateDelivered: Date | null;
isFromMe: boolean;
isDeleted: boolean;
isAudioMessage: boolean;
isPlayed: boolean;
chatId: string;
attachments?: MessageAttachment[];
type: MessageType;
status: MessageStatus;
}
export interface ContactEntity {
id: number;
firstName: string | null;
lastName: string | null;
displayName: string | null;
phoneNumbers: string[];
emails: string[];
avatar?: string;
}
export interface ConversationEntity {
id: string;
guid: string;
chatIdentifier: string;
displayName: string | null;
isGroup: boolean;
participants: ContactEntity[];
lastMessage?: MessageEntity;
lastActivity?: Date;
unreadCount?: number;
}
export interface DatabaseOptions {
databasePath?: string;
attachmentsPath?: string;
pollInterval?: number;
catchUpOnStart?: boolean;
}
export interface MessageQueryOptions {
conversationId?: string;
limit?: number;
offset?: number;
before?: Date;
after?: Date;
fromHandle?: string;
onlyFromMe?: boolean;
onlyWithAttachments?: boolean;
}
export interface ConversationQueryOptions {
limit?: number;
offset?: number;
searchTerm?: string;
onlyGroups?: boolean;
onlyWithUnread?: boolean;
}
export interface AttachmentQueryOptions {
messageId?: string;
conversationId?: string;
types?: AttachmentType[];
limit?: number;
offset?: number;
}
export declare enum MessageService {
IMESSAGE = "iMessage",
SMS = "SMS"
}
export interface SendMessageOptions {
text: string;
to: string | string[];
attachments?: string[];
subject?: string;
service?: MessageService;
}
export interface MessageEvent {
message: MessageEntity;
conversation: ConversationEntity;
}
export interface MessageReadEvent {
messageId: string;
conversationId: string;
readAt: Date;
}
export interface IMessageClientEvents {
message: (event: MessageEvent) => void;
messageRead: (event: MessageReadEvent) => void;
messageDelivered: (event: MessageReadEvent) => void;
messageSent: (message: MessageEntity) => void;
messageFailed: (message: MessageEntity, error: Error) => void;
error: (error: Error) => void;
}
//# sourceMappingURL=index.d.ts.map