@photon-ai/advanced-imessage-kit 1.14.3 → 1.16.0

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/dist/index.d.cts CHANGED
@@ -57,15 +57,66 @@ type AttachmentResponse = {
57
57
  hasLivePhoto?: boolean;
58
58
  };
59
59
 
60
+ interface TextStyle {
61
+ start: number;
62
+ end: number;
63
+ bold?: boolean;
64
+ italic?: boolean;
65
+ underline?: boolean;
66
+ strikethrough?: boolean;
67
+ }
68
+ type TextAnimation = "big" | "small" | "shake" | "nod" | "explode" | "ripple" | "bloom" | "jitter";
69
+ type BubbleEffect = "slam" | "loud" | "gentle" | "invisibleInk" | "confetti" | "lasers" | "fireworks" | "balloons" | "hearts" | "shootingStar" | "celebration" | "echo" | "spotlight";
60
70
  interface SendMessageOptions {
61
71
  chatGuid: string;
62
72
  message: string;
63
73
  tempGuid?: string;
64
74
  subject?: string;
65
- effectId?: string;
66
75
  selectedMessageGuid?: string;
67
76
  partIndex?: number;
68
77
  richLink?: boolean;
78
+ textStyles?: TextStyle[];
79
+ textAnimation?: TextAnimation;
80
+ bubbleEffect?: BubbleEffect;
81
+ }
82
+ type SendMultipartMessagePart = {
83
+ partIndex?: number;
84
+ text: string;
85
+ mention?: Record<string, unknown>;
86
+ } | {
87
+ partIndex?: number;
88
+ filePath: string;
89
+ fileName?: string;
90
+ };
91
+ interface SendMultipartMessageOptions {
92
+ chatGuid: string;
93
+ parts: SendMultipartMessagePart[];
94
+ tempGuid?: string;
95
+ subject?: string;
96
+ effectId?: string;
97
+ selectedMessageGuid?: string;
98
+ partIndex?: number;
99
+ ddScan?: boolean;
100
+ attributedBody?: Record<string, unknown> | Record<string, unknown>[];
101
+ }
102
+ interface SendIMessageAppOptions {
103
+ chatGuid: string;
104
+ balloonBundleId: string;
105
+ appName: string;
106
+ url: string;
107
+ ldtext?: string;
108
+ layoutClass?: string;
109
+ userInfo?: {
110
+ caption?: string;
111
+ subcaption?: string;
112
+ "secondary-subcaption"?: string;
113
+ "tertiary-subcaption"?: string;
114
+ "image-title"?: string;
115
+ "image-subtitle"?: string;
116
+ };
117
+ appId?: number;
118
+ imageBase64?: string;
119
+ sessionIdentifier?: string;
69
120
  }
70
121
  interface MessageData {
71
122
  guid: string;
@@ -434,7 +485,7 @@ declare class ChatModule {
434
485
  service?: "iMessage" | "SMS";
435
486
  tempGuid?: string;
436
487
  subject?: string;
437
- effectId?: string;
488
+ bubbleEffect?: BubbleEffect;
438
489
  attributedBody?: Record<string, unknown>;
439
490
  }): Promise<ChatResponse>;
440
491
  getChat(guid: string, options?: {
@@ -533,7 +584,9 @@ declare class MessageModule {
533
584
  private readonly http;
534
585
  private readonly enqueueSend;
535
586
  constructor(http: AxiosInstance, enqueueSend?: <T>(task: () => Promise<T>) => Promise<T>);
587
+ private uploadMultipartAttachment;
536
588
  sendMessage(options: SendMessageOptions): Promise<MessageResponse>;
589
+ sendMultipartMessage(options: SendMultipartMessageOptions): Promise<MessageResponse>;
537
590
  getMessage(guid: string, options?: {
538
591
  with?: string[];
539
592
  }): Promise<MessageResponse>;
@@ -737,4 +790,4 @@ declare function parsePollVotes(message: MessageResponse): ParsedPollVote | null
737
790
  declare function getPollSummary(message: MessageResponse): string;
738
791
  declare function getPollOneLiner(message: MessageResponse): string;
739
792
 
740
- export { type AddPollOptionOptions, AdvancedIMessageKit, type Attachment, type AttachmentResponse, type BackupData, CHAT_READ_STATUS_CHANGED, type Chat, type ChatResponse, type ClientConfig, type CreatePollOptions, FT_CALL_STATUS_CHANGED, type FaceTimeStatusData, type FindMyLocationItem, GROUP_ICON_CHANGED, GROUP_ICON_REMOVED, GROUP_NAME_CHANGE, HELLO_WORLD, type Handle, type HandleResponse, IMESSAGE_ALIASES_REMOVED, INCOMING_FACETIME, MESSAGE_SEND_ERROR, MESSAGE_UPDATED, type Message, type MessageData, type MessageResponse, NEW_FINDMY_LOCATION, NEW_MESSAGE, NEW_SERVER, PARTICIPANT_ADDED, PARTICIPANT_LEFT, PARTICIPANT_REMOVED, type ParsedPoll, type ParsedPollVote, type PhotonEventMap, type PhotonEventName, type PollDefinition, type PollMessageResponse, type PollOption, type PollVote, type PollVoteResponse, SCHEDULED_MESSAGE_CREATED, SCHEDULED_MESSAGE_DELETED, SCHEDULED_MESSAGE_ERROR, SCHEDULED_MESSAGE_SENT, SCHEDULED_MESSAGE_UPDATED, SDK, SERVER_UPDATE, SERVER_UPDATE_DOWNLOADING, SERVER_UPDATE_INSTALLING, SETTINGS_BACKUP_CREATED, SETTINGS_BACKUP_DELETED, SETTINGS_BACKUP_UPDATED, type ScheduledMessageData, type SendAttachmentOptions, type SendMessageOptions, type SendStickerOptions, type ServerMetadataResponse, type ServerUpdateData, THEME_BACKUP_CREATED, THEME_BACKUP_DELETED, THEME_BACKUP_UPDATED, TYPING_INDICATOR, type TypedEventEmitter, type ValidRemoveTapback, type ValidTapback, type VotePollOptions, getLogger, getOptionTextById, getPollOneLiner, getPollSummary, isPollMessage, isPollVote, parsePollDefinition, parsePollVotes, setGlobalLogLevel, setGlobalLogToFile };
793
+ export { type AddPollOptionOptions, AdvancedIMessageKit, type Attachment, type AttachmentResponse, type BackupData, type BubbleEffect, CHAT_READ_STATUS_CHANGED, type Chat, type ChatResponse, type ClientConfig, type CreatePollOptions, FT_CALL_STATUS_CHANGED, type FaceTimeStatusData, type FindMyLocationItem, GROUP_ICON_CHANGED, GROUP_ICON_REMOVED, GROUP_NAME_CHANGE, HELLO_WORLD, type Handle, type HandleResponse, IMESSAGE_ALIASES_REMOVED, INCOMING_FACETIME, MESSAGE_SEND_ERROR, MESSAGE_UPDATED, type Message, type MessageData, type MessageResponse, NEW_FINDMY_LOCATION, NEW_MESSAGE, NEW_SERVER, PARTICIPANT_ADDED, PARTICIPANT_LEFT, PARTICIPANT_REMOVED, type ParsedPoll, type ParsedPollVote, type PhotonEventMap, type PhotonEventName, type PollDefinition, type PollMessageResponse, type PollOption, type PollVote, type PollVoteResponse, SCHEDULED_MESSAGE_CREATED, SCHEDULED_MESSAGE_DELETED, SCHEDULED_MESSAGE_ERROR, SCHEDULED_MESSAGE_SENT, SCHEDULED_MESSAGE_UPDATED, SDK, SERVER_UPDATE, SERVER_UPDATE_DOWNLOADING, SERVER_UPDATE_INSTALLING, SETTINGS_BACKUP_CREATED, SETTINGS_BACKUP_DELETED, SETTINGS_BACKUP_UPDATED, type ScheduledMessageData, type SendAttachmentOptions, type SendIMessageAppOptions, type SendMessageOptions, type SendMultipartMessageOptions, type SendMultipartMessagePart, type SendStickerOptions, type ServerMetadataResponse, type ServerUpdateData, THEME_BACKUP_CREATED, THEME_BACKUP_DELETED, THEME_BACKUP_UPDATED, TYPING_INDICATOR, type TextAnimation, type TextStyle, type TypedEventEmitter, type ValidRemoveTapback, type ValidTapback, type VotePollOptions, getLogger, getOptionTextById, getPollOneLiner, getPollSummary, isPollMessage, isPollVote, parsePollDefinition, parsePollVotes, setGlobalLogLevel, setGlobalLogToFile };
package/dist/index.d.ts CHANGED
@@ -57,15 +57,66 @@ type AttachmentResponse = {
57
57
  hasLivePhoto?: boolean;
58
58
  };
59
59
 
60
+ interface TextStyle {
61
+ start: number;
62
+ end: number;
63
+ bold?: boolean;
64
+ italic?: boolean;
65
+ underline?: boolean;
66
+ strikethrough?: boolean;
67
+ }
68
+ type TextAnimation = "big" | "small" | "shake" | "nod" | "explode" | "ripple" | "bloom" | "jitter";
69
+ type BubbleEffect = "slam" | "loud" | "gentle" | "invisibleInk" | "confetti" | "lasers" | "fireworks" | "balloons" | "hearts" | "shootingStar" | "celebration" | "echo" | "spotlight";
60
70
  interface SendMessageOptions {
61
71
  chatGuid: string;
62
72
  message: string;
63
73
  tempGuid?: string;
64
74
  subject?: string;
65
- effectId?: string;
66
75
  selectedMessageGuid?: string;
67
76
  partIndex?: number;
68
77
  richLink?: boolean;
78
+ textStyles?: TextStyle[];
79
+ textAnimation?: TextAnimation;
80
+ bubbleEffect?: BubbleEffect;
81
+ }
82
+ type SendMultipartMessagePart = {
83
+ partIndex?: number;
84
+ text: string;
85
+ mention?: Record<string, unknown>;
86
+ } | {
87
+ partIndex?: number;
88
+ filePath: string;
89
+ fileName?: string;
90
+ };
91
+ interface SendMultipartMessageOptions {
92
+ chatGuid: string;
93
+ parts: SendMultipartMessagePart[];
94
+ tempGuid?: string;
95
+ subject?: string;
96
+ effectId?: string;
97
+ selectedMessageGuid?: string;
98
+ partIndex?: number;
99
+ ddScan?: boolean;
100
+ attributedBody?: Record<string, unknown> | Record<string, unknown>[];
101
+ }
102
+ interface SendIMessageAppOptions {
103
+ chatGuid: string;
104
+ balloonBundleId: string;
105
+ appName: string;
106
+ url: string;
107
+ ldtext?: string;
108
+ layoutClass?: string;
109
+ userInfo?: {
110
+ caption?: string;
111
+ subcaption?: string;
112
+ "secondary-subcaption"?: string;
113
+ "tertiary-subcaption"?: string;
114
+ "image-title"?: string;
115
+ "image-subtitle"?: string;
116
+ };
117
+ appId?: number;
118
+ imageBase64?: string;
119
+ sessionIdentifier?: string;
69
120
  }
70
121
  interface MessageData {
71
122
  guid: string;
@@ -434,7 +485,7 @@ declare class ChatModule {
434
485
  service?: "iMessage" | "SMS";
435
486
  tempGuid?: string;
436
487
  subject?: string;
437
- effectId?: string;
488
+ bubbleEffect?: BubbleEffect;
438
489
  attributedBody?: Record<string, unknown>;
439
490
  }): Promise<ChatResponse>;
440
491
  getChat(guid: string, options?: {
@@ -533,7 +584,9 @@ declare class MessageModule {
533
584
  private readonly http;
534
585
  private readonly enqueueSend;
535
586
  constructor(http: AxiosInstance, enqueueSend?: <T>(task: () => Promise<T>) => Promise<T>);
587
+ private uploadMultipartAttachment;
536
588
  sendMessage(options: SendMessageOptions): Promise<MessageResponse>;
589
+ sendMultipartMessage(options: SendMultipartMessageOptions): Promise<MessageResponse>;
537
590
  getMessage(guid: string, options?: {
538
591
  with?: string[];
539
592
  }): Promise<MessageResponse>;
@@ -737,4 +790,4 @@ declare function parsePollVotes(message: MessageResponse): ParsedPollVote | null
737
790
  declare function getPollSummary(message: MessageResponse): string;
738
791
  declare function getPollOneLiner(message: MessageResponse): string;
739
792
 
740
- export { type AddPollOptionOptions, AdvancedIMessageKit, type Attachment, type AttachmentResponse, type BackupData, CHAT_READ_STATUS_CHANGED, type Chat, type ChatResponse, type ClientConfig, type CreatePollOptions, FT_CALL_STATUS_CHANGED, type FaceTimeStatusData, type FindMyLocationItem, GROUP_ICON_CHANGED, GROUP_ICON_REMOVED, GROUP_NAME_CHANGE, HELLO_WORLD, type Handle, type HandleResponse, IMESSAGE_ALIASES_REMOVED, INCOMING_FACETIME, MESSAGE_SEND_ERROR, MESSAGE_UPDATED, type Message, type MessageData, type MessageResponse, NEW_FINDMY_LOCATION, NEW_MESSAGE, NEW_SERVER, PARTICIPANT_ADDED, PARTICIPANT_LEFT, PARTICIPANT_REMOVED, type ParsedPoll, type ParsedPollVote, type PhotonEventMap, type PhotonEventName, type PollDefinition, type PollMessageResponse, type PollOption, type PollVote, type PollVoteResponse, SCHEDULED_MESSAGE_CREATED, SCHEDULED_MESSAGE_DELETED, SCHEDULED_MESSAGE_ERROR, SCHEDULED_MESSAGE_SENT, SCHEDULED_MESSAGE_UPDATED, SDK, SERVER_UPDATE, SERVER_UPDATE_DOWNLOADING, SERVER_UPDATE_INSTALLING, SETTINGS_BACKUP_CREATED, SETTINGS_BACKUP_DELETED, SETTINGS_BACKUP_UPDATED, type ScheduledMessageData, type SendAttachmentOptions, type SendMessageOptions, type SendStickerOptions, type ServerMetadataResponse, type ServerUpdateData, THEME_BACKUP_CREATED, THEME_BACKUP_DELETED, THEME_BACKUP_UPDATED, TYPING_INDICATOR, type TypedEventEmitter, type ValidRemoveTapback, type ValidTapback, type VotePollOptions, getLogger, getOptionTextById, getPollOneLiner, getPollSummary, isPollMessage, isPollVote, parsePollDefinition, parsePollVotes, setGlobalLogLevel, setGlobalLogToFile };
793
+ export { type AddPollOptionOptions, AdvancedIMessageKit, type Attachment, type AttachmentResponse, type BackupData, type BubbleEffect, CHAT_READ_STATUS_CHANGED, type Chat, type ChatResponse, type ClientConfig, type CreatePollOptions, FT_CALL_STATUS_CHANGED, type FaceTimeStatusData, type FindMyLocationItem, GROUP_ICON_CHANGED, GROUP_ICON_REMOVED, GROUP_NAME_CHANGE, HELLO_WORLD, type Handle, type HandleResponse, IMESSAGE_ALIASES_REMOVED, INCOMING_FACETIME, MESSAGE_SEND_ERROR, MESSAGE_UPDATED, type Message, type MessageData, type MessageResponse, NEW_FINDMY_LOCATION, NEW_MESSAGE, NEW_SERVER, PARTICIPANT_ADDED, PARTICIPANT_LEFT, PARTICIPANT_REMOVED, type ParsedPoll, type ParsedPollVote, type PhotonEventMap, type PhotonEventName, type PollDefinition, type PollMessageResponse, type PollOption, type PollVote, type PollVoteResponse, SCHEDULED_MESSAGE_CREATED, SCHEDULED_MESSAGE_DELETED, SCHEDULED_MESSAGE_ERROR, SCHEDULED_MESSAGE_SENT, SCHEDULED_MESSAGE_UPDATED, SDK, SERVER_UPDATE, SERVER_UPDATE_DOWNLOADING, SERVER_UPDATE_INSTALLING, SETTINGS_BACKUP_CREATED, SETTINGS_BACKUP_DELETED, SETTINGS_BACKUP_UPDATED, type ScheduledMessageData, type SendAttachmentOptions, type SendIMessageAppOptions, type SendMessageOptions, type SendMultipartMessageOptions, type SendMultipartMessagePart, type SendStickerOptions, type ServerMetadataResponse, type ServerUpdateData, THEME_BACKUP_CREATED, THEME_BACKUP_DELETED, THEME_BACKUP_UPDATED, TYPING_INDICATOR, type TextAnimation, type TextStyle, type TypedEventEmitter, type ValidRemoveTapback, type ValidTapback, type VotePollOptions, getLogger, getOptionTextById, getPollOneLiner, getPollSummary, isPollMessage, isPollVote, parsePollDefinition, parsePollVotes, setGlobalLogLevel, setGlobalLogToFile };
package/dist/index.js CHANGED
@@ -135,14 +135,16 @@ function extractService(chatGuid) {
135
135
  return void 0;
136
136
  }
137
137
  async function createChatWithMessage(options) {
138
- const { http, address, message, tempGuid, subject, effectId, service } = options;
138
+ const { http, address, message, tempGuid, subject, bubbleEffect, textStyles, textAnimation, service } = options;
139
139
  try {
140
140
  const response = await http.post("/api/v1/chat/new", {
141
141
  addresses: [address],
142
142
  message,
143
143
  tempGuid,
144
144
  subject,
145
- effectId,
145
+ bubbleEffect,
146
+ textStyles,
147
+ textAnimation,
146
148
  ...service && { service }
147
149
  });
148
150
  return response.data.data?.guid;
@@ -500,6 +502,15 @@ var MessageModule = class {
500
502
  this.http = http;
501
503
  this.enqueueSend = enqueueSend;
502
504
  }
505
+ async uploadMultipartAttachment(part, fileName = part.fileName || path__default.basename(part.filePath)) {
506
+ const fileBuffer = await readFile(part.filePath);
507
+ const form = new FormData();
508
+ form.append("attachment", fileBuffer, fileName);
509
+ const response = await this.http.post("/api/v1/attachment/upload", form, {
510
+ headers: form.getHeaders()
511
+ });
512
+ return response.data.data.path;
513
+ }
503
514
  async sendMessage(options) {
504
515
  return this.enqueueSend(async () => {
505
516
  const tempGuid = options.tempGuid || randomUUID();
@@ -518,13 +529,70 @@ var MessageModule = class {
518
529
  message: options.message,
519
530
  tempGuid,
520
531
  subject: options.subject,
521
- effectId: options.effectId,
532
+ bubbleEffect: options.bubbleEffect,
533
+ textStyles: options.textStyles,
534
+ textAnimation: options.textAnimation,
522
535
  service
523
536
  });
524
537
  return { guid: tempGuid, text: options.message, dateCreated: Date.now() };
525
538
  }
526
539
  });
527
540
  }
541
+ async sendMultipartMessage(options) {
542
+ return this.enqueueSend(async () => {
543
+ const tempGuid = options.tempGuid || randomUUID();
544
+ const buildPayloadPart = async (part, index) => {
545
+ const resolvedPartIndex = part.partIndex ?? index;
546
+ if ("text" in part) {
547
+ return {
548
+ partIndex: resolvedPartIndex,
549
+ text: part.text,
550
+ ...part.mention ? { mention: part.mention } : {}
551
+ };
552
+ }
553
+ const fileName = part.fileName || path__default.basename(part.filePath);
554
+ const uploadedPath = await this.uploadMultipartAttachment(part, fileName);
555
+ return {
556
+ partIndex: resolvedPartIndex,
557
+ attachment: uploadedPath,
558
+ name: fileName
559
+ };
560
+ };
561
+ const uploadParts = async () => {
562
+ const parts = [];
563
+ for (const [index, part] of options.parts.entries()) {
564
+ parts.push(await buildPayloadPart(part, index));
565
+ }
566
+ return parts;
567
+ };
568
+ const send = async (chatGuid) => {
569
+ const parts = await uploadParts();
570
+ const payload = {
571
+ chatGuid,
572
+ tempGuid,
573
+ parts,
574
+ subject: options.subject,
575
+ effectId: options.effectId,
576
+ selectedMessageGuid: options.selectedMessageGuid,
577
+ partIndex: options.partIndex ?? 0,
578
+ ddScan: options.ddScan ?? false,
579
+ attributedBody: options.attributedBody
580
+ };
581
+ const response = await this.http.post("/api/v1/message/multipart", payload);
582
+ return response.data.data;
583
+ };
584
+ try {
585
+ return await send(options.chatGuid);
586
+ } catch (error) {
587
+ if (isChatNotExistError(error)) {
588
+ throw new Error(
589
+ "Chat does not exist for multipart send. Use an existing chatGuid, or create the chat first before calling sendMultipartMessage()."
590
+ );
591
+ }
592
+ throw error;
593
+ }
594
+ });
595
+ }
528
596
  async getMessage(guid, options) {
529
597
  const response = await this.http.get(`/api/v1/message/${encodeURIComponent(guid)}`, {
530
598
  params: options?.with ? { with: options.with.join(",") } : {}