@linqapp/sdk 0.2.0 → 0.4.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.
Files changed (107) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +31 -0
  3. package/client.d.mts +19 -6
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +19 -6
  6. package/client.d.ts.map +1 -1
  7. package/client.js +13 -0
  8. package/client.js.map +1 -1
  9. package/client.mjs +13 -0
  10. package/client.mjs.map +1 -1
  11. package/core/pagination.d.mts +69 -0
  12. package/core/pagination.d.mts.map +1 -0
  13. package/core/pagination.d.ts +69 -0
  14. package/core/pagination.d.ts.map +1 -0
  15. package/core/pagination.js +125 -0
  16. package/core/pagination.js.map +1 -0
  17. package/core/pagination.mjs +118 -0
  18. package/core/pagination.mjs.map +1 -0
  19. package/index.d.mts +1 -0
  20. package/index.d.mts.map +1 -1
  21. package/index.d.ts +1 -0
  22. package/index.d.ts.map +1 -1
  23. package/index.js +3 -1
  24. package/index.js.map +1 -1
  25. package/index.mjs +1 -0
  26. package/index.mjs.map +1 -1
  27. package/internal/tslib.js +18 -18
  28. package/package.json +11 -1
  29. package/pagination.d.mts +2 -0
  30. package/pagination.d.mts.map +1 -0
  31. package/pagination.d.ts +2 -0
  32. package/pagination.d.ts.map +1 -0
  33. package/pagination.js +6 -0
  34. package/pagination.js.map +1 -0
  35. package/pagination.mjs +2 -0
  36. package/pagination.mjs.map +1 -0
  37. package/resources/capability.d.mts +9 -9
  38. package/resources/capability.d.ts +9 -9
  39. package/resources/capability.js +4 -4
  40. package/resources/capability.mjs +4 -4
  41. package/resources/chats/chats.d.mts +67 -84
  42. package/resources/chats/chats.d.mts.map +1 -1
  43. package/resources/chats/chats.d.ts +67 -84
  44. package/resources/chats/chats.d.ts.map +1 -1
  45. package/resources/chats/chats.js +8 -4
  46. package/resources/chats/chats.js.map +1 -1
  47. package/resources/chats/chats.mjs +9 -5
  48. package/resources/chats/chats.mjs.map +1 -1
  49. package/resources/chats/index.d.mts +2 -2
  50. package/resources/chats/index.d.mts.map +1 -1
  51. package/resources/chats/index.d.ts +2 -2
  52. package/resources/chats/index.d.ts.map +1 -1
  53. package/resources/chats/index.js.map +1 -1
  54. package/resources/chats/index.mjs.map +1 -1
  55. package/resources/chats/messages.d.mts +12 -25
  56. package/resources/chats/messages.d.mts.map +1 -1
  57. package/resources/chats/messages.d.ts +12 -25
  58. package/resources/chats/messages.d.ts.map +1 -1
  59. package/resources/chats/messages.js +7 -3
  60. package/resources/chats/messages.js.map +1 -1
  61. package/resources/chats/messages.mjs +7 -3
  62. package/resources/chats/messages.mjs.map +1 -1
  63. package/resources/index.d.mts +4 -3
  64. package/resources/index.d.mts.map +1 -1
  65. package/resources/index.d.ts +4 -3
  66. package/resources/index.d.ts.map +1 -1
  67. package/resources/index.js +3 -1
  68. package/resources/index.js.map +1 -1
  69. package/resources/index.mjs +1 -0
  70. package/resources/index.mjs.map +1 -1
  71. package/resources/messages.d.mts +28 -72
  72. package/resources/messages.d.mts.map +1 -1
  73. package/resources/messages.d.ts +28 -72
  74. package/resources/messages.d.ts.map +1 -1
  75. package/resources/messages.js +25 -4
  76. package/resources/messages.js.map +1 -1
  77. package/resources/messages.mjs +25 -4
  78. package/resources/messages.mjs.map +1 -1
  79. package/resources/shared.d.mts +51 -0
  80. package/resources/shared.d.mts.map +1 -1
  81. package/resources/shared.d.ts +51 -0
  82. package/resources/shared.d.ts.map +1 -1
  83. package/resources/webhooks.d.mts +2506 -0
  84. package/resources/webhooks.d.mts.map +1 -0
  85. package/resources/webhooks.d.ts +2506 -0
  86. package/resources/webhooks.d.ts.map +1 -0
  87. package/resources/webhooks.js +12 -0
  88. package/resources/webhooks.js.map +1 -0
  89. package/resources/webhooks.mjs +8 -0
  90. package/resources/webhooks.mjs.map +1 -0
  91. package/src/client.ts +159 -20
  92. package/src/core/pagination.ts +212 -0
  93. package/src/index.ts +1 -0
  94. package/src/pagination.ts +2 -0
  95. package/src/resources/capability.ts +14 -14
  96. package/src/resources/chats/chats.ts +77 -100
  97. package/src/resources/chats/index.ts +4 -3
  98. package/src/resources/chats/messages.ts +21 -30
  99. package/src/resources/index.ts +55 -10
  100. package/src/resources/messages.ts +40 -90
  101. package/src/resources/shared.ts +62 -0
  102. package/src/resources/webhooks.ts +3089 -0
  103. package/src/version.ts +1 -1
  104. package/version.d.mts +1 -1
  105. package/version.d.ts +1 -1
  106. package/version.js +1 -1
  107. package/version.mjs +1 -1
@@ -4,14 +4,7 @@ import { APIResource } from '../../core/resource';
4
4
  import * as MessagesAPI from '../messages';
5
5
  import * as Shared from '../shared';
6
6
  import * as ChatsMessagesAPI from './messages';
7
- import {
8
- MessageListParams,
9
- MessageListResponse,
10
- MessageSendParams,
11
- MessageSendResponse,
12
- Messages,
13
- SentMessage,
14
- } from './messages';
7
+ import { MessageListParams, MessageSendParams, MessageSendResponse, Messages, SentMessage } from './messages';
15
8
  import * as ParticipantsAPI from './participants';
16
9
  import {
17
10
  ParticipantAddParams,
@@ -23,6 +16,7 @@ import {
23
16
  import * as TypingAPI from './typing';
24
17
  import { Typing } from './typing';
25
18
  import { APIPromise } from '../../core/api-promise';
19
+ import { ListChatsPagination, type ListChatsPaginationParams, PagePromise } from '../../core/pagination';
26
20
  import { buildHeaders } from '../../internal/headers';
27
21
  import { RequestOptions } from '../../internal/request-options';
28
22
  import { path } from '../../internal/utils/path';
@@ -120,13 +114,19 @@ export class Chats extends APIResource {
120
114
  *
121
115
  * @example
122
116
  * ```ts
123
- * const chats = await client.chats.list({
117
+ * // Automatically fetches more pages as needed.
118
+ * for await (const chat of client.chats.listChats({
124
119
  * from: '+13343284472',
125
- * });
120
+ * })) {
121
+ * // ...
122
+ * }
126
123
  * ```
127
124
  */
128
- list(query: ChatListParams, options?: RequestOptions): APIPromise<ChatListResponse> {
129
- return this._client.get('/v3/chats', { query, ...options });
125
+ listChats(
126
+ query: ChatListChatsParams,
127
+ options?: RequestOptions,
128
+ ): PagePromise<ChatsListChatsPagination, Chat> {
129
+ return this._client.getAPIList('/v3/chats', ListChatsPagination<Chat>, { query, ...options });
130
130
  }
131
131
 
132
132
  /**
@@ -203,6 +203,8 @@ export class Chats extends APIResource {
203
203
  }
204
204
  }
205
205
 
206
+ export type ChatsListChatsPagination = ListChatsPagination<Chat>;
207
+
206
208
  export interface Chat {
207
209
  /**
208
210
  * Unique identifier for the chat
@@ -247,6 +249,54 @@ export interface Chat {
247
249
  service?: Shared.ServiceType | null;
248
250
  }
249
251
 
252
+ export interface MediaPart {
253
+ /**
254
+ * Indicates this is a media attachment part
255
+ */
256
+ type: 'media';
257
+
258
+ /**
259
+ * Reference to a file pre-uploaded via `POST /v3/attachments` (optional). The file
260
+ * is already stored, so sends using this ID skip the download step — useful when
261
+ * sending the same file to many recipients.
262
+ *
263
+ * Either `url` or `attachment_id` must be provided, but not both.
264
+ */
265
+ attachment_id?: string;
266
+
267
+ /**
268
+ * Any publicly accessible HTTPS URL to the media file. The server downloads and
269
+ * sends the file automatically — no pre-upload step required.
270
+ *
271
+ * **Size limit:** 10MB maximum for URL-based downloads. For larger files (up to
272
+ * 100MB), use the pre-upload flow: `POST /v3/attachments` to get a presigned URL,
273
+ * upload directly, then reference by `attachment_id`.
274
+ *
275
+ * **Requirements:**
276
+ *
277
+ * - URL must use HTTPS
278
+ * - File content must be a supported format (the server validates the actual file
279
+ * content)
280
+ *
281
+ * **Supported formats:**
282
+ *
283
+ * - Images: .jpg, .jpeg, .png, .gif, .heic, .heif, .tif, .tiff, .bmp
284
+ * - Videos: .mp4, .mov, .m4v, .mpeg, .mpg, .3gp
285
+ * - Audio: .m4a, .mp3, .aac, .caf, .wav, .aiff, .amr
286
+ * - Documents: .pdf, .txt, .rtf, .csv, .doc, .docx, .xls, .xlsx, .ppt, .pptx,
287
+ * .pages, .numbers, .key, .epub, .zip, .html, .htm
288
+ * - Contact & Calendar: .vcf, .ics
289
+ *
290
+ * **Tip:** Audio sent here appears as a regular file attachment. To send audio as
291
+ * an iMessage voice memo bubble (with inline playback), use
292
+ * `/v3/chats/{chatId}/voicememo`. For repeated sends of the same file, use
293
+ * `attachment_id` to avoid redundant downloads.
294
+ *
295
+ * Either `url` or `attachment_id` must be provided, but not both.
296
+ */
297
+ url?: string;
298
+ }
299
+
250
300
  /**
251
301
  * Message content container. Groups all message-related fields together,
252
302
  * separating the "what" (message content) from the "where" (routing fields like
@@ -283,7 +333,7 @@ export interface MessageContent {
283
333
  * sub-limit. For bulk media sends exceeding 40 files, pre-upload via
284
334
  * `POST /v3/attachments` and reference by `attachment_id` or `download_url`.
285
335
  */
286
- parts: Array<MessageContent.TextPart | MessageContent.MediaPart>;
336
+ parts: Array<TextPart | MediaPart>;
287
337
 
288
338
  /**
289
339
  * iMessage effect to apply to this message (screen or bubble effect)
@@ -307,66 +357,16 @@ export interface MessageContent {
307
357
  reply_to?: MessagesAPI.ReplyTo;
308
358
  }
309
359
 
310
- export namespace MessageContent {
311
- export interface TextPart {
312
- /**
313
- * Indicates this is a text message part
314
- */
315
- type: 'text';
316
-
317
- /**
318
- * The text content
319
- */
320
- value: string;
321
- }
322
-
323
- export interface MediaPart {
324
- /**
325
- * Indicates this is a media attachment part
326
- */
327
- type: 'media';
328
-
329
- /**
330
- * Reference to a file pre-uploaded via `POST /v3/attachments` (optional). The file
331
- * is already stored, so sends using this ID skip the download step — useful when
332
- * sending the same file to many recipients.
333
- *
334
- * Either `url` or `attachment_id` must be provided, but not both.
335
- */
336
- attachment_id?: string;
360
+ export interface TextPart {
361
+ /**
362
+ * Indicates this is a text message part
363
+ */
364
+ type: 'text';
337
365
 
338
- /**
339
- * Any publicly accessible HTTPS URL to the media file. The server downloads and
340
- * sends the file automatically — no pre-upload step required.
341
- *
342
- * **Size limit:** 10MB maximum for URL-based downloads. For larger files (up to
343
- * 100MB), use the pre-upload flow: `POST /v3/attachments` to get a presigned URL,
344
- * upload directly, then reference by `attachment_id`.
345
- *
346
- * **Requirements:**
347
- *
348
- * - URL must use HTTPS
349
- * - File content must be a supported format (the server validates the actual file
350
- * content)
351
- *
352
- * **Supported formats:**
353
- *
354
- * - Images: .jpg, .jpeg, .png, .gif, .heic, .heif, .tif, .tiff, .bmp
355
- * - Videos: .mp4, .mov, .m4v, .mpeg, .mpg, .3gp
356
- * - Audio: .m4a, .mp3, .aac, .caf, .wav, .aiff, .amr
357
- * - Documents: .pdf, .txt, .rtf, .csv, .doc, .docx, .xls, .xlsx, .ppt, .pptx,
358
- * .pages, .numbers, .key, .epub, .zip, .html, .htm
359
- * - Contact & Calendar: .vcf, .ics
360
- *
361
- * **Tip:** Audio sent here appears as a regular file attachment. To send audio as
362
- * an iMessage voice memo bubble (with inline playback), use
363
- * `/v3/chats/{chatId}/voicememo`. For repeated sends of the same file, use
364
- * `attachment_id` to avoid redundant downloads.
365
- *
366
- * Either `url` or `attachment_id` must be provided, but not both.
367
- */
368
- url?: string;
369
- }
366
+ /**
367
+ * The text content
368
+ */
369
+ value: string;
370
370
  }
371
371
 
372
372
  /**
@@ -412,19 +412,6 @@ export namespace ChatCreateResponse {
412
412
  }
413
413
  }
414
414
 
415
- export interface ChatListResponse {
416
- /**
417
- * List of chats
418
- */
419
- chats: Array<Chat>;
420
-
421
- /**
422
- * Cursor for fetching the next page of results. Null if there are no more results
423
- * to fetch. Pass this value as the `cursor` parameter in the next request.
424
- */
425
- next_cursor?: string | null;
426
- }
427
-
428
415
  /**
429
416
  * Response for sending a voice memo to a chat
430
417
  */
@@ -564,24 +551,13 @@ export interface ChatUpdateParams {
564
551
  group_chat_icon?: string;
565
552
  }
566
553
 
567
- export interface ChatListParams {
554
+ export interface ChatListChatsParams extends ListChatsPaginationParams {
568
555
  /**
569
556
  * Phone number to filter chats by. Returns all chats made from this phone number.
570
557
  * Must be in E.164 format (e.g., `+13343284472`). The `+` is automatically
571
558
  * URL-encoded by HTTP clients.
572
559
  */
573
560
  from: string;
574
-
575
- /**
576
- * Pagination cursor from the previous response's `next_cursor` field. Omit this
577
- * parameter for the first page of results.
578
- */
579
- cursor?: string;
580
-
581
- /**
582
- * Maximum number of chats to return per page
583
- */
584
- limit?: number;
585
561
  }
586
562
 
587
563
  export interface ChatSendVoicememoParams {
@@ -603,13 +579,15 @@ Chats.Messages = Messages;
603
579
  export declare namespace Chats {
604
580
  export {
605
581
  type Chat as Chat,
582
+ type MediaPart as MediaPart,
606
583
  type MessageContent as MessageContent,
584
+ type TextPart as TextPart,
607
585
  type ChatCreateResponse as ChatCreateResponse,
608
- type ChatListResponse as ChatListResponse,
609
586
  type ChatSendVoicememoResponse as ChatSendVoicememoResponse,
587
+ type ChatsListChatsPagination as ChatsListChatsPagination,
610
588
  type ChatCreateParams as ChatCreateParams,
611
589
  type ChatUpdateParams as ChatUpdateParams,
612
- type ChatListParams as ChatListParams,
590
+ type ChatListChatsParams as ChatListChatsParams,
613
591
  type ChatSendVoicememoParams as ChatSendVoicememoParams,
614
592
  };
615
593
 
@@ -626,7 +604,6 @@ export declare namespace Chats {
626
604
  export {
627
605
  Messages as Messages,
628
606
  type SentMessage as SentMessage,
629
- type MessageListResponse as MessageListResponse,
630
607
  type MessageSendResponse as MessageSendResponse,
631
608
  type MessageListParams as MessageListParams,
632
609
  type MessageSendParams as MessageSendParams,
@@ -3,19 +3,20 @@
3
3
  export {
4
4
  Chats,
5
5
  type Chat,
6
+ type MediaPart,
6
7
  type MessageContent,
8
+ type TextPart,
7
9
  type ChatCreateResponse,
8
- type ChatListResponse,
9
10
  type ChatSendVoicememoResponse,
10
11
  type ChatCreateParams,
11
12
  type ChatUpdateParams,
12
- type ChatListParams,
13
+ type ChatListChatsParams,
13
14
  type ChatSendVoicememoParams,
15
+ type ChatsListChatsPagination,
14
16
  } from './chats';
15
17
  export {
16
18
  Messages,
17
19
  type SentMessage,
18
- type MessageListResponse,
19
20
  type MessageSendResponse,
20
21
  type MessageListParams,
21
22
  type MessageSendParams,
@@ -2,9 +2,15 @@
2
2
 
3
3
  import { APIResource } from '../../core/resource';
4
4
  import * as MessagesAPI from '../messages';
5
+ import { MessagesListMessagesPagination } from '../messages';
5
6
  import * as Shared from '../shared';
6
7
  import * as ChatsAPI from './chats';
7
8
  import { APIPromise } from '../../core/api-promise';
9
+ import {
10
+ ListMessagesPagination,
11
+ type ListMessagesPaginationParams,
12
+ PagePromise,
13
+ } from '../../core/pagination';
8
14
  import { RequestOptions } from '../../internal/request-options';
9
15
  import { path } from '../../internal/utils/path';
10
16
 
@@ -23,17 +29,24 @@ export class Messages extends APIResource {
23
29
  *
24
30
  * @example
25
31
  * ```ts
26
- * const messages = await client.chats.messages.list(
32
+ * // Automatically fetches more pages as needed.
33
+ * for await (const message of client.chats.messages.list(
27
34
  * '550e8400-e29b-41d4-a716-446655440000',
28
- * );
35
+ * )) {
36
+ * // ...
37
+ * }
29
38
  * ```
30
39
  */
31
40
  list(
32
41
  chatID: string,
33
42
  query: MessageListParams | null | undefined = {},
34
43
  options?: RequestOptions,
35
- ): APIPromise<MessageListResponse> {
36
- return this._client.get(path`/v3/chats/${chatID}/messages`, { query, ...options });
44
+ ): PagePromise<MessagesListMessagesPagination, MessagesAPI.Message> {
45
+ return this._client.getAPIList(
46
+ path`/v3/chats/${chatID}/messages`,
47
+ ListMessagesPagination<MessagesAPI.Message>,
48
+ { query, ...options },
49
+ );
37
50
  }
38
51
 
39
52
  /**
@@ -93,7 +106,7 @@ export interface SentMessage {
93
106
  /**
94
107
  * Message parts in order (text and media)
95
108
  */
96
- parts: Array<MessagesAPI.TextPart | MessagesAPI.MediaPart>;
109
+ parts: Array<Shared.TextPartResponse | Shared.MediaPartResponse>;
97
110
 
98
111
  /**
99
112
  * When the message was sent
@@ -131,19 +144,6 @@ export interface SentMessage {
131
144
  service?: Shared.ServiceType | null;
132
145
  }
133
146
 
134
- export interface MessageListResponse {
135
- /**
136
- * List of messages
137
- */
138
- messages: Array<MessagesAPI.Message>;
139
-
140
- /**
141
- * Cursor for fetching the next page of results. Null if there are no more results
142
- * to fetch. Pass this value as the `cursor` parameter in the next request.
143
- */
144
- next_cursor?: string | null;
145
- }
146
-
147
147
  /**
148
148
  * Response for sending a message to a chat
149
149
  */
@@ -159,17 +159,7 @@ export interface MessageSendResponse {
159
159
  message: SentMessage;
160
160
  }
161
161
 
162
- export interface MessageListParams {
163
- /**
164
- * Pagination cursor from previous next_cursor response
165
- */
166
- cursor?: string;
167
-
168
- /**
169
- * Maximum number of messages to return
170
- */
171
- limit?: number;
172
- }
162
+ export interface MessageListParams extends ListMessagesPaginationParams {}
173
163
 
174
164
  export interface MessageSendParams {
175
165
  /**
@@ -183,9 +173,10 @@ export interface MessageSendParams {
183
173
  export declare namespace Messages {
184
174
  export {
185
175
  type SentMessage as SentMessage,
186
- type MessageListResponse as MessageListResponse,
187
176
  type MessageSendResponse as MessageSendResponse,
188
177
  type MessageListParams as MessageListParams,
189
178
  type MessageSendParams as MessageSendParams,
190
179
  };
191
180
  }
181
+
182
+ export { type MessagesListMessagesPagination };
@@ -10,38 +10,39 @@ export {
10
10
  } from './attachments';
11
11
  export {
12
12
  Capability,
13
- type CapabilityCheckImessageResponse,
14
- type CapabilityCheckRcsResponse,
15
- type CapabilityCheckImessageParams,
16
- type CapabilityCheckRcsParams,
13
+ type CapabilityCheckiMessageResponse,
14
+ type CapabilityCheckRCSResponse,
15
+ type CapabilityCheckiMessageParams,
16
+ type CapabilityCheckRCSParams,
17
17
  } from './capability';
18
18
  export {
19
19
  Chats,
20
20
  type Chat,
21
+ type MediaPart,
21
22
  type MessageContent,
23
+ type TextPart,
22
24
  type ChatCreateResponse,
23
- type ChatListResponse,
24
25
  type ChatSendVoicememoResponse,
25
26
  type ChatCreateParams,
26
27
  type ChatUpdateParams,
27
- type ChatListParams,
28
+ type ChatListChatsParams,
28
29
  type ChatSendVoicememoParams,
30
+ type ChatsListChatsPagination,
29
31
  } from './chats/chats';
30
32
  export {
31
33
  Messages,
32
34
  type ChatHandle,
33
- type MediaPart,
34
35
  type Message,
35
36
  type MessageEffect,
36
37
  type Reaction,
37
38
  type ReactionType,
38
39
  type ReplyTo,
39
- type TextPart,
40
40
  type MessageAddReactionResponse,
41
- type MessageRetrieveThreadResponse,
41
+ type MessageUpdateParams,
42
42
  type MessageDeleteParams,
43
43
  type MessageAddReactionParams,
44
- type MessageRetrieveThreadParams,
44
+ type MessageListMessagesThreadParams,
45
+ type MessagesListMessagesPagination,
45
46
  } from './messages';
46
47
  export { PhoneNumbers, type PhoneNumberListResponse } from './phone-numbers';
47
48
  export { Phonenumbers, type PhonenumberListResponse } from './phonenumbers';
@@ -54,3 +55,47 @@ export {
54
55
  type WebhookSubscriptionCreateParams,
55
56
  type WebhookSubscriptionUpdateParams,
56
57
  } from './webhook-subscriptions';
58
+ export {
59
+ Webhooks,
60
+ type MessageEventV2,
61
+ type MessagePayload,
62
+ type ReactionEventBase,
63
+ type SchemasMediaPartResponse,
64
+ type SchemasMessageEffect,
65
+ type SchemasTextPartResponse,
66
+ type MessageSentV2026WebhookEvent,
67
+ type MessageReceivedV2026WebhookEvent,
68
+ type MessageReadV2026WebhookEvent,
69
+ type MessageDeliveredV2026WebhookEvent,
70
+ type MessageFailedV2026WebhookEvent,
71
+ type ReactionAddedV2026WebhookEvent,
72
+ type ReactionRemovedV2026WebhookEvent,
73
+ type ParticipantAddedV2026WebhookEvent,
74
+ type ParticipantRemovedV2026WebhookEvent,
75
+ type ChatGroupNameUpdatedV2026WebhookEvent,
76
+ type ChatGroupIconUpdatedV2026WebhookEvent,
77
+ type ChatGroupNameUpdateFailedV2026WebhookEvent,
78
+ type ChatGroupIconUpdateFailedV2026WebhookEvent,
79
+ type ChatCreatedV2026WebhookEvent,
80
+ type ChatTypingIndicatorStartedV2026WebhookEvent,
81
+ type ChatTypingIndicatorStoppedV2026WebhookEvent,
82
+ type PhoneNumberStatusUpdatedV2026WebhookEvent,
83
+ type MessageSentV2025WebhookEvent,
84
+ type MessageReceivedV2025WebhookEvent,
85
+ type MessageReadV2025WebhookEvent,
86
+ type MessageDeliveredV2025WebhookEvent,
87
+ type MessageFailedV2025WebhookEvent,
88
+ type ReactionAddedV2025WebhookEvent,
89
+ type ReactionRemovedV2025WebhookEvent,
90
+ type ParticipantAddedV2025WebhookEvent,
91
+ type ParticipantRemovedV2025WebhookEvent,
92
+ type ChatGroupNameUpdatedV2025WebhookEvent,
93
+ type ChatGroupIconUpdatedV2025WebhookEvent,
94
+ type ChatGroupNameUpdateFailedV2025WebhookEvent,
95
+ type ChatGroupIconUpdateFailedV2025WebhookEvent,
96
+ type ChatCreatedV2025WebhookEvent,
97
+ type ChatTypingIndicatorStartedV2025WebhookEvent,
98
+ type ChatTypingIndicatorStoppedV2025WebhookEvent,
99
+ type PhoneNumberStatusUpdatedV2025WebhookEvent,
100
+ type EventsWebhookEvent,
101
+ } from './webhooks';
@@ -3,6 +3,7 @@
3
3
  import { APIResource } from '../core/resource';
4
4
  import * as Shared from './shared';
5
5
  import { APIPromise } from '../core/api-promise';
6
+ import { ListMessagesPagination, type ListMessagesPaginationParams, PagePromise } from '../core/pagination';
6
7
  import { buildHeaders } from '../internal/headers';
7
8
  import { RequestOptions } from '../internal/request-options';
8
9
  import { path } from '../internal/utils/path';
@@ -32,6 +33,21 @@ export class Messages extends APIResource {
32
33
  return this._client.get(path`/v3/messages/${messageID}`, options);
33
34
  }
34
35
 
36
+ /**
37
+ * Edit the text content of a specific part of a previously sent message.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const message = await client.messages.update(
42
+ * '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
43
+ * { text: 'This is the edited message content' },
44
+ * );
45
+ * ```
46
+ */
47
+ update(messageID: string, body: MessageUpdateParams, options?: RequestOptions): APIPromise<Message> {
48
+ return this._client.patch(path`/v3/messages/${messageID}`, { body, ...options });
49
+ }
50
+
35
51
  /**
36
52
  * Deletes a message from the Linq API only. This does NOT unsend or remove the
37
53
  * message from the actual chat - recipients will still see the message.
@@ -95,20 +111,28 @@ export class Messages extends APIResource {
95
111
  *
96
112
  * @example
97
113
  * ```ts
98
- * const response = await client.messages.retrieveThread(
114
+ * // Automatically fetches more pages as needed.
115
+ * for await (const message of client.messages.listMessagesThread(
99
116
  * '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
100
- * );
117
+ * )) {
118
+ * // ...
119
+ * }
101
120
  * ```
102
121
  */
103
- retrieveThread(
122
+ listMessagesThread(
104
123
  messageID: string,
105
- query: MessageRetrieveThreadParams | null | undefined = {},
124
+ query: MessageListMessagesThreadParams | null | undefined = {},
106
125
  options?: RequestOptions,
107
- ): APIPromise<MessageRetrieveThreadResponse> {
108
- return this._client.get(path`/v3/messages/${messageID}/thread`, { query, ...options });
126
+ ): PagePromise<MessagesListMessagesPagination, Message> {
127
+ return this._client.getAPIList(path`/v3/messages/${messageID}/thread`, ListMessagesPagination<Message>, {
128
+ query,
129
+ ...options,
130
+ });
109
131
  }
110
132
  }
111
133
 
134
+ export type MessagesListMessagesPagination = ListMessagesPagination<Message>;
135
+
112
136
  export interface ChatHandle {
113
137
  /**
114
138
  * Unique identifier for this handle
@@ -146,46 +170,6 @@ export interface ChatHandle {
146
170
  status?: 'active' | 'left' | 'removed' | null;
147
171
  }
148
172
 
149
- /**
150
- * A media attachment part
151
- */
152
- export interface MediaPart {
153
- /**
154
- * Unique attachment identifier
155
- */
156
- id: string;
157
-
158
- /**
159
- * Original filename
160
- */
161
- filename: string;
162
-
163
- /**
164
- * MIME type of the file
165
- */
166
- mime_type: string;
167
-
168
- /**
169
- * Reactions on this message part
170
- */
171
- reactions: Array<Reaction> | null;
172
-
173
- /**
174
- * File size in bytes
175
- */
176
- size_bytes: number;
177
-
178
- /**
179
- * Indicates this is a media attachment part
180
- */
181
- type: 'media';
182
-
183
- /**
184
- * Presigned URL for downloading the attachment (expires in 1 hour).
185
- */
186
- url: string;
187
- }
188
-
189
173
  export interface Message {
190
174
  /**
191
175
  * Unique identifier for the message
@@ -246,7 +230,7 @@ export interface Message {
246
230
  /**
247
231
  * Message parts in order (text and media)
248
232
  */
249
- parts?: Array<TextPart | MediaPart> | null;
233
+ parts?: Array<Shared.TextPartResponse | Shared.MediaPartResponse> | null;
250
234
 
251
235
  /**
252
236
  * Messaging service type
@@ -387,26 +371,6 @@ export interface ReplyTo {
387
371
  part_index?: number;
388
372
  }
389
373
 
390
- /**
391
- * A text message part
392
- */
393
- export interface TextPart {
394
- /**
395
- * Reactions on this message part
396
- */
397
- reactions: Array<Reaction> | null;
398
-
399
- /**
400
- * Indicates this is a text message part
401
- */
402
- type: 'text';
403
-
404
- /**
405
- * The text content
406
- */
407
- value: string;
408
- }
409
-
410
374
  export interface MessageAddReactionResponse {
411
375
  message?: string;
412
376
 
@@ -415,19 +379,16 @@ export interface MessageAddReactionResponse {
415
379
  trace_id?: string;
416
380
  }
417
381
 
418
- /**
419
- * Response containing messages in a thread with pagination
420
- */
421
- export interface MessageRetrieveThreadResponse {
382
+ export interface MessageUpdateParams {
422
383
  /**
423
- * Messages in the thread, ordered by the specified order parameter
384
+ * New text content for the message part
424
385
  */
425
- messages: Array<Message>;
386
+ text: string;
426
387
 
427
388
  /**
428
- * Cursor for fetching the next page of results (null if no more results)
389
+ * Index of the message part to edit. Defaults to 0.
429
390
  */
430
- next_cursor?: string | null;
391
+ part_index?: number;
431
392
  }
432
393
 
433
394
  export interface MessageDeleteParams {
@@ -463,17 +424,7 @@ export interface MessageAddReactionParams {
463
424
  part_index?: number;
464
425
  }
465
426
 
466
- export interface MessageRetrieveThreadParams {
467
- /**
468
- * Pagination cursor from previous next_cursor response
469
- */
470
- cursor?: string;
471
-
472
- /**
473
- * Maximum number of messages to return
474
- */
475
- limit?: number;
476
-
427
+ export interface MessageListMessagesThreadParams extends ListMessagesPaginationParams {
477
428
  /**
478
429
  * Sort order for messages (asc = oldest first, desc = newest first)
479
430
  */
@@ -483,17 +434,16 @@ export interface MessageRetrieveThreadParams {
483
434
  export declare namespace Messages {
484
435
  export {
485
436
  type ChatHandle as ChatHandle,
486
- type MediaPart as MediaPart,
487
437
  type Message as Message,
488
438
  type MessageEffect as MessageEffect,
489
439
  type Reaction as Reaction,
490
440
  type ReactionType as ReactionType,
491
441
  type ReplyTo as ReplyTo,
492
- type TextPart as TextPart,
493
442
  type MessageAddReactionResponse as MessageAddReactionResponse,
494
- type MessageRetrieveThreadResponse as MessageRetrieveThreadResponse,
443
+ type MessagesListMessagesPagination as MessagesListMessagesPagination,
444
+ type MessageUpdateParams as MessageUpdateParams,
495
445
  type MessageDeleteParams as MessageDeleteParams,
496
446
  type MessageAddReactionParams as MessageAddReactionParams,
497
- type MessageRetrieveThreadParams as MessageRetrieveThreadParams,
447
+ type MessageListMessagesThreadParams as MessageListMessagesThreadParams,
498
448
  };
499
449
  }