← Public packages
@tannerlinsley/imessage
Read, search, draft, and explicitly send iMessages on a Mac, using only built-in macOS tools.
Files
import { native, object, integer, filters, text } from "./core.ts";
import type { ConversationPage } from "./types.ts";
/**
* List local Messages conversations to find the exact chat ID and participants.
* @param input - limit (1..50, default 20), beforeChatId cursor, and optional iMessage, SMS, or RCS service, and participant phone or email (exact address, phone formatting ignored, no country-code guessing).
* @returns Conversations in descending creation ID order, participants, and the next cursor. No message content.
* @example
* import conversations from 'kody:@tannerlinsley/imessage/conversations';
* const page = await conversations({limit:10,service:'iMessage'});
*/
export default async function conversations(
input: {
limit?: number;
beforeChatId?: number;
participant?: string;
service?: "iMessage" | "SMS" | "RCS";
} = {},
): Promise<ConversationPage> {
const p = object(input, ["limit", "beforeChatId", "service", "participant"]);
const options = filters(p);
if (p.participant !== undefined)
options.participant = text(p.participant, "participant", 254).trim();
if (p.beforeChatId !== undefined) options.beforeChatId = integer(p.beforeChatId, "beforeChatId");
return native<ConversationPage>({
action: "conversations",
...options,
limit: integer(p.limit, "limit", 20, 50),
});
}