@photon-ai/advanced-imessage-kit 1.4.1 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,34 +18,34 @@ Advanced iMessage Kit is a full-featured iMessage SDK for **reading**, **sending
18
18
 
19
19
  ## Features
20
20
 
21
- | Feature | Description | Method | Example |
22
- | ------- | ----------- | ------ | ------- |
23
- | [Send Messages](#send-messages) | Send text messages to any contact | `messages.sendMessage()` | [message-send.ts](./examples/message-send.ts) |
24
- | [Reply to Messages](#send-messages) | Reply inline to a specific message | `messages.sendMessage()` | [message-reply.ts](./examples/message-reply.ts) |
25
- | [Message Effects](#send-messages) | Send with effects (confetti, fireworks, etc.) | `messages.sendMessage()` | [message-effects.ts](./examples/message-effects.ts) |
26
- | [Unsend Messages](#unsend-messages) | Retract a sent message | `messages.unsendMessage()` | [message-unsend.ts](./examples/message-unsend.ts) |
27
- | [Send Tapbacks](#send-tapbacks) | React with ❤️ 👍 👎 😂 ‼️ ❓ | `messages.sendReaction()` | [message-reaction.ts](./examples/message-reaction.ts) |
28
- | [Query Messages](#query-messages) | Search and filter message history | `messages.getMessages()` | [message-search.ts](./examples/message-search.ts) |
29
- | [Message History](#get-chat-messages) | View messages, reactions, polls, stickers | `chats.getChatMessages()` | [message-history.ts](./examples/message-history.ts) |
30
- | [Send Attachments](#send-attachments) | Send images, files, documents | `attachments.sendAttachment()` | [message-attachment.ts](./examples/message-attachment.ts) |
31
- | [Send Audio Messages](#send-audio-messages) | Send voice messages | `attachments.sendAttachment()` | [message-audio.ts](./examples/message-audio.ts) |
32
- | [Send Stickers](#send-stickers) | Send sticker as standalone message | `attachments.sendSticker()` | [message-sticker.ts](./examples/message-sticker.ts) |
33
- | [Reply Stickers](#send-stickers) | Attach sticker to a message bubble | `attachments.sendSticker()` | [message-reply-sticker.ts](./examples/message-reply-sticker.ts) |
34
- | [Download Attachments](#download-attachments) | Download received files and media | `attachments.downloadAttachment()` | [attachment-download.ts](./examples/attachment-download.ts) |
35
- | [Get Chats](#get-chats) | List all conversations | `chats.getChats()` | [chat-fetch.ts](./examples/chat-fetch.ts) |
36
- | [Manage Group Chats](#manage-group-chats) | Add/remove members, rename groups | `chats.addParticipant()` | [chat-group.ts](./examples/chat-group.ts) |
37
- | [Typing Indicators](#typing-indicators) | Show "typing..." status | `chats.startTyping()` | [message-typing.ts](./examples/message-typing.ts) |
38
- | [Get Contacts](#get-contacts) | Fetch device contacts | `contacts.getContacts()` | [contact-list.ts](./examples/contact-list.ts) |
39
- | [Share Contact Card](#share-contact-card) | Share your contact info in chat | `contacts.shareContactCard()` | [message-contact-card.ts](./examples/message-contact-card.ts) |
40
- | [Check iMessage Availability](#check-service-availability) | Verify if contact uses iMessage | `handles.getHandleAvailability()` | [service-check.ts](./examples/service-check.ts) |
41
- | [Server Info](#get-server-info) | Get server status and config | `server.getServerInfo()` | [server-info.ts](./examples/server-info.ts) |
42
- | [Message Statistics](#message-statistics) | Get message counts and analytics | `server.getMessageStats()` | [message-stats.ts](./examples/message-stats.ts) |
43
- | [Create Polls](#create-polls) | Create interactive polls in chat | `polls.create()` | [poll-create.ts](./examples/poll-create.ts) |
44
- | [Vote on Polls](#vote-on-polls) | Vote or unvote on poll options | `polls.vote()` | [poll-create.ts](./examples/poll-create.ts) |
45
- | [Add Poll Options](#add-poll-options) | Add options to existing polls | `polls.addOption()` | [poll-add-option.ts](./examples/poll-add-option.ts) |
46
- | [Find My Friends](#find-my-friends) _(WIP)_ | Get friends' locations | `icloud.getFindMyFriends()` | [findmy-friends.ts](./examples/findmy-friends.ts) |
47
- | [Real-time Events](#real-time-events) | Listen for new messages, typing, etc. | `sdk.on()` | [listen-simple.ts](./examples/listen-simple.ts) |
48
- | [Auto Reply](#real-time-events) | Build automated reply bots | `sdk.on()` | [auto-reply-hey.ts](./examples/auto-reply-hey.ts) |
21
+ | Feature | Description | Method | Example |
22
+ | ---------------------------------------------------------- | --------------------------------------------- | ---------------------------------- | --------------------------------------------------------------- |
23
+ | [Send Messages](#send-messages) | Send text messages to any contact | `messages.sendMessage()` | [message-send.ts](./examples/message-send.ts) |
24
+ | [Reply to Messages](#send-messages) | Reply inline to a specific message | `messages.sendMessage()` | [message-reply.ts](./examples/message-reply.ts) |
25
+ | [Message Effects](#send-messages) | Send with effects (confetti, fireworks, etc.) | `messages.sendMessage()` | [message-effects.ts](./examples/message-effects.ts) |
26
+ | [Unsend Messages](#unsend-messages) | Retract a sent message | `messages.unsendMessage()` | [message-unsend.ts](./examples/message-unsend.ts) |
27
+ | [Send Tapbacks](#send-tapbacks) | React with ❤️ 👍 👎 😂 ‼️ ❓ | `messages.sendReaction()` | [message-reaction.ts](./examples/message-reaction.ts) |
28
+ | [Query Messages](#query-messages) | Search and filter message history | `messages.getMessages()` | [message-search.ts](./examples/message-search.ts) |
29
+ | [Message History](#get-chat-messages) | View messages, reactions, polls, stickers | `chats.getChatMessages()` | [message-history.ts](./examples/message-history.ts) |
30
+ | [Send Attachments](#send-attachments) | Send images, files, documents | `attachments.sendAttachment()` | [message-attachment.ts](./examples/message-attachment.ts) |
31
+ | [Send Audio Messages](#send-audio-messages) | Send voice messages | `attachments.sendAttachment()` | [message-audio.ts](./examples/message-audio.ts) |
32
+ | [Send Stickers](#send-stickers) | Send sticker as standalone message | `attachments.sendSticker()` | [message-sticker.ts](./examples/message-sticker.ts) |
33
+ | [Reply Stickers](#send-stickers) | Attach sticker to a message bubble | `attachments.sendSticker()` | [message-reply-sticker.ts](./examples/message-reply-sticker.ts) |
34
+ | [Download Attachments](#download-attachments) | Download received files and media | `attachments.downloadAttachment()` | [attachment-download.ts](./examples/attachment-download.ts) |
35
+ | [Get Chats](#get-chats) | List all conversations | `chats.getChats()` | [chat-fetch.ts](./examples/chat-fetch.ts) |
36
+ | [Manage Group Chats](#manage-group-chats) | Add/remove members, rename groups | `chats.addParticipant()` | [chat-group.ts](./examples/chat-group.ts) |
37
+ | [Typing Indicators](#typing-indicators) | Show "typing..." status | `chats.startTyping()` | [message-typing.ts](./examples/message-typing.ts) |
38
+ | [Get Contacts](#get-contacts) | Fetch device contacts | `contacts.getContacts()` | [contact-list.ts](./examples/contact-list.ts) |
39
+ | [Share Contact Card](#share-contact-card) | Share your contact info in chat | `contacts.shareContactCard()` | [message-contact-card.ts](./examples/message-contact-card.ts) |
40
+ | [Check iMessage Availability](#check-service-availability) | Verify if contact uses iMessage | `handles.getHandleAvailability()` | [service-check.ts](./examples/service-check.ts) |
41
+ | [Server Info](#get-server-info) | Get server status and config | `server.getServerInfo()` | [server-info.ts](./examples/server-info.ts) |
42
+ | [Message Statistics](#message-statistics) | Get message counts and analytics | `server.getMessageStats()` | [message-stats.ts](./examples/message-stats.ts) |
43
+ | [Create Polls](#create-polls) | Create interactive polls in chat | `polls.create()` | [poll-create.ts](./examples/poll-create.ts) |
44
+ | [Vote on Polls](#vote-on-polls) | Vote or unvote on poll options | `polls.vote()` | [poll-create.ts](./examples/poll-create.ts) |
45
+ | [Add Poll Options](#add-poll-options) | Add options to existing polls | `polls.addOption()` | [poll-add-option.ts](./examples/poll-add-option.ts) |
46
+ | [Find My Friends](#find-my-friends) _(WIP)_ | Get friends' locations | `icloud.getFindMyFriends()` | [findmy-friends.ts](./examples/findmy-friends.ts) |
47
+ | [Real-time Events](#real-time-events) | Listen for new messages, typing, etc. | `sdk.on()` | [listen-simple.ts](./examples/listen-simple.ts) |
48
+ | [Auto Reply](#real-time-events) | Build automated reply bots | `sdk.on()` | [auto-reply-hey.ts](./examples/auto-reply-hey.ts) |
49
49
 
50
50
  ---
51
51
 
@@ -476,12 +476,18 @@ const card = await sdk.contacts.getContactCard("+1234567890");
476
476
  Share your contact card with a chat:
477
477
 
478
478
  ```typescript
479
- // Check if sharing is recommended
479
+ // chatGuid is the chat identifier (e.g. the `guid` field you get from chat APIs/events)
480
+ // Check whether the SDK recommends sharing your contact card in this chat.
481
+ //
482
+ // Returns:
483
+ // - true: sharing is recommended (typically when the other side shared theirs and you haven't shared yours yet)
484
+ // - false: NOT recommended (e.g. you've already shared, OR the other side hasn't shared theirs yet)
480
485
  const shouldShare = await sdk.contacts.shouldShareContact("chat-guid");
481
- // Returns false if you've already shared or they haven't shared theirs
482
486
 
483
- // Share your contact card
484
- await sdk.contacts.shareContactCard("chat-guid");
487
+ if (shouldShare) {
488
+ // Share your contact card (iMessage "Share Name and Photo")
489
+ await sdk.contacts.shareContactCard("chat-guid");
490
+ }
485
491
  ```
486
492
 
487
493
  > Example: [message-contact-card.ts](./examples/message-contact-card.ts)
@@ -651,7 +657,7 @@ import {
651
657
  parsePollVotes,
652
658
  getPollSummary,
653
659
  getOptionTextById,
654
- } from "@photon-ai/advanced-imessage-kit/lib/poll-utils";
660
+ } from "@photon-ai/advanced-imessage-kit";
655
661
 
656
662
  sdk.on("new-message", (message) => {
657
663
  if (isPollMessage(message)) {
@@ -888,22 +894,22 @@ bun run examples/<filename>.ts
888
894
 
889
895
  ### Message Operations
890
896
 
891
- | File | Description |
892
- | ----------------------------------------------------- | ------------------ |
893
- | [message-reply.ts](./examples/message-reply.ts) | Reply to messages |
894
- | [message-unsend.ts](./examples/message-unsend.ts) | Unsend messages |
895
- | [message-reaction.ts](./examples/message-reaction.ts) | Send Tapbacks |
896
- | [message-effects.ts](./examples/message-effects.ts) | Message effects |
897
- | [message-search.ts](./examples/message-search.ts) | Search messages |
898
- | [message-history.ts](./examples/message-history.ts) | Message history |
897
+ | File | Description |
898
+ | ----------------------------------------------------- | ----------------- |
899
+ | [message-reply.ts](./examples/message-reply.ts) | Reply to messages |
900
+ | [message-unsend.ts](./examples/message-unsend.ts) | Unsend messages |
901
+ | [message-reaction.ts](./examples/message-reaction.ts) | Send Tapbacks |
902
+ | [message-effects.ts](./examples/message-effects.ts) | Message effects |
903
+ | [message-search.ts](./examples/message-search.ts) | Search messages |
904
+ | [message-history.ts](./examples/message-history.ts) | Message history |
899
905
 
900
906
  ### Chats & Groups
901
907
 
902
- | File | Description |
903
- | ----------------------------------------------------- | ------------------- |
904
- | [chat-fetch.ts](./examples/chat-fetch.ts) | Get chat list |
905
- | [chat-group.ts](./examples/chat-group.ts) | Manage groups |
906
- | [message-typing.ts](./examples/message-typing.ts) | Typing indicators |
908
+ | File | Description |
909
+ | ------------------------------------------------- | ----------------- |
910
+ | [chat-fetch.ts](./examples/chat-fetch.ts) | Get chat list |
911
+ | [chat-group.ts](./examples/chat-group.ts) | Manage groups |
912
+ | [message-typing.ts](./examples/message-typing.ts) | Typing indicators |
907
913
 
908
914
  ### Contacts & Services
909
915
 
@@ -916,11 +922,11 @@ bun run examples/<filename>.ts
916
922
 
917
923
  ### Attachments & Media
918
924
 
919
- | File | Description |
920
- | --------------------------------------------------------------- | ------------------------- |
921
- | [attachment-download.ts](./examples/attachment-download.ts) | Download attachments |
922
- | [message-sticker.ts](./examples/message-sticker.ts) | Send standalone stickers |
923
- | [message-reply-sticker.ts](./examples/message-reply-sticker.ts) | Send reply stickers |
925
+ | File | Description |
926
+ | --------------------------------------------------------------- | ------------------------ |
927
+ | [attachment-download.ts](./examples/attachment-download.ts) | Download attachments |
928
+ | [message-sticker.ts](./examples/message-sticker.ts) | Send standalone stickers |
929
+ | [message-reply-sticker.ts](./examples/message-reply-sticker.ts) | Send reply stickers |
924
930
 
925
931
  ### Polls
926
932
 
package/dist/index.cjs CHANGED
@@ -555,7 +555,26 @@ var MessageModule = class {
555
555
  return response.data.data;
556
556
  }
557
557
  async searchMessages(options) {
558
- const response = await this.http.post("/api/v1/message/search", options);
558
+ const { query, chatGuid, offset, limit, sort, before, after } = options;
559
+ if (!query || query.trim().length === 0) {
560
+ throw new Error("Search query cannot be empty");
561
+ }
562
+ const where = [
563
+ {
564
+ statement: "message.text LIKE :text",
565
+ args: { text: `%${query}%` }
566
+ }
567
+ ];
568
+ const payload = {
569
+ where
570
+ };
571
+ if (chatGuid) payload.chatGuid = chatGuid;
572
+ if (offset !== void 0) payload.offset = offset;
573
+ if (limit !== void 0) payload.limit = limit;
574
+ if (sort) payload.sort = sort;
575
+ if (before !== void 0) payload.before = before;
576
+ if (after !== void 0) payload.after = after;
577
+ const response = await this.http.post("/api/v1/message/query", payload);
559
578
  return response.data.data;
560
579
  }
561
580
  };
@@ -1091,6 +1110,7 @@ exports.THEME_BACKUP_DELETED = THEME_BACKUP_DELETED;
1091
1110
  exports.THEME_BACKUP_UPDATED = THEME_BACKUP_UPDATED;
1092
1111
  exports.TYPING_INDICATOR = TYPING_INDICATOR;
1093
1112
  exports.getLogger = getLogger;
1113
+ exports.getOptionTextById = getOptionTextById;
1094
1114
  exports.getPollOneLiner = getPollOneLiner;
1095
1115
  exports.getPollSummary = getPollSummary;
1096
1116
  exports.isPollMessage = isPollMessage;