@green-api/greenapi-integration 0.3.0 → 0.5.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.
@@ -2,7 +2,7 @@
2
2
  * Base interface for GREEN-API WhatsApp instances.
3
3
  * Contains the essential credentials needed to interact with the API.
4
4
  */
5
- interface BaseInstance {
5
+ export interface BaseInstance {
6
6
  idInstance: number | bigint;
7
7
  apiTokenInstance: string;
8
8
  stateInstance?: InstanceState;
@@ -22,6 +22,7 @@ export interface Instance extends BaseInstance {
22
22
  export type Message = ({
23
23
  type: "text";
24
24
  message: string;
25
+ linkPreview?: boolean;
25
26
  } & BaseMessage) | ({
26
27
  type: "upload-file";
27
28
  caption?: string;
@@ -97,7 +98,57 @@ export type SendPoll = Extract<Message, {
97
98
  export type ForwardMessages = Extract<Message, {
98
99
  type: "forward";
99
100
  }>;
100
- export type MessageType = "textMessage" | "extendedTextMessage" | "imageMessage" | "videoMessage" | "documentMessage" | "audioMessage" | "contactMessage" | "locationMessage" | "pollMessage";
101
+ export type QueueMessageType = "sendMessage" | "sendPoll" | "sendFileByUrl" | "sendLocation" | "sendContact" | "ForwardMessages";
102
+ export type QueueMessageBody = SendMessage | SendPoll | SendFileByUrl | SendLocation | SendContact | ForwardMessages;
103
+ export interface QueueMessage {
104
+ messageID?: string;
105
+ messagesIDs?: string[];
106
+ type: QueueMessageType;
107
+ body: QueueMessageBody;
108
+ }
109
+ export interface ClearMessagesQueue {
110
+ isCleared: boolean;
111
+ }
112
+ export type MessageType = "textMessage" | "extendedTextMessage" | "imageMessage" | "videoMessage" | "documentMessage" | "audioMessage" | "contactMessage" | "locationMessage" | "pollMessage" | "reactionMessage" | "pollUpdateMessage" | "quotedMessage" | "stickerMessage";
113
+ export interface GetMessage {
114
+ chatId: string;
115
+ idMessage: string;
116
+ }
117
+ export interface GetChatHistory {
118
+ chatId: string;
119
+ count?: number;
120
+ }
121
+ export interface BaseJournalMessage {
122
+ idMessage: string;
123
+ timestamp: number;
124
+ typeMessage: MessageType;
125
+ chatId: string;
126
+ isForwarded: boolean;
127
+ forwardingScore: number;
128
+ }
129
+ export interface IncomingJournalFields {
130
+ type: "incoming";
131
+ senderId: string;
132
+ senderName: string;
133
+ senderContactName: string;
134
+ }
135
+ export interface OutgoingJournalFields {
136
+ type: "outgoing";
137
+ statusMessage: OutgoingMessageStatus;
138
+ sendByApi: boolean;
139
+ }
140
+ export type BaseIncomingJournalMessage = BaseJournalMessage & IncomingJournalFields;
141
+ export type BaseOutgoingJournalMessage = BaseJournalMessage & OutgoingJournalFields;
142
+ export type BaseJournalResponse = BaseIncomingJournalMessage | BaseOutgoingJournalMessage;
143
+ export type OutgoingJournalResponse = BaseOutgoingJournalMessage & WebhookMessageData & {
144
+ quotedMessage?: QuotedMessage;
145
+ };
146
+ export type IncomingJournalResponse = BaseIncomingJournalMessage & WebhookMessageData & {
147
+ quotedMessage?: QuotedMessage;
148
+ };
149
+ export type JournalResponse = BaseJournalResponse & WebhookMessageData & {
150
+ quotedMessage?: QuotedMessage;
151
+ };
101
152
  export interface ForwardableMessage {
102
153
  forwardingScore: number;
103
154
  isForwarded: boolean;
@@ -129,6 +180,12 @@ export interface ContactMessageData extends ForwardableMessage {
129
180
  displayName: string;
130
181
  vcard: string;
131
182
  }
183
+ export interface ContactsArrayMessageData extends ForwardableMessage {
184
+ contacts: Array<{
185
+ displayName: string;
186
+ vcard: string;
187
+ }>;
188
+ }
132
189
  export interface PollMessageData {
133
190
  name: string;
134
191
  options: PollOption[];
@@ -147,6 +204,12 @@ type QuotedMessage = {
147
204
  displayName: string;
148
205
  vcard: string;
149
206
  };
207
+ } | {
208
+ typeMessage: "contactsArrayMessage";
209
+ contacts: Array<{
210
+ displayName: string;
211
+ vcard: string;
212
+ }>;
150
213
  } | {
151
214
  typeMessage: "locationMessage";
152
215
  location: {
@@ -223,6 +286,9 @@ export type WebhookMessageData = {
223
286
  } | {
224
287
  typeMessage: "pollUpdateMessage";
225
288
  pollMessageData: PollUpdateMessageData;
289
+ } | {
290
+ typeMessage: "contactsArrayMessage";
291
+ messageData: ContactsArrayMessageData;
226
292
  };
227
293
  export interface MessageWebhook {
228
294
  typeWebhook: "incomingMessageReceived" | "outgoingMessageReceived" | "outgoingAPIMessageReceived";
@@ -274,6 +340,83 @@ export interface Reboot {
274
340
  export interface Logout {
275
341
  isLogout: boolean;
276
342
  }
343
+ export interface ReadChat {
344
+ chatId: string;
345
+ idMessage?: string;
346
+ }
347
+ export interface ReadChatResponse {
348
+ setRead: boolean;
349
+ }
350
+ export interface CheckWhatsapp {
351
+ phoneNumber: number;
352
+ }
353
+ export interface CheckWhatsappResponse {
354
+ existsWhatsapp: boolean;
355
+ }
356
+ export interface GetAvatar {
357
+ chatId: string;
358
+ }
359
+ export interface GetAvatarResponse {
360
+ urlAvatar: string;
361
+ available: boolean;
362
+ }
363
+ export type ContactType = "user" | "group";
364
+ export interface Contact {
365
+ id: string;
366
+ name: string;
367
+ contactName: string;
368
+ type: ContactType;
369
+ }
370
+ export interface ProductImageUrls {
371
+ requested: string;
372
+ original: string;
373
+ }
374
+ export interface ProductReviewStatus {
375
+ whatsapp: string;
376
+ }
377
+ export interface Product {
378
+ id: string;
379
+ imageUrls: ProductImageUrls;
380
+ reviewStatus: ProductReviewStatus;
381
+ availability: string;
382
+ name: string;
383
+ description?: string;
384
+ price: string | null;
385
+ isHidden: boolean;
386
+ }
387
+ export interface ContactInfo {
388
+ avatar: string;
389
+ name: string;
390
+ contactName: string;
391
+ email: string;
392
+ category: string;
393
+ description: string;
394
+ products: Product[];
395
+ chatId: string;
396
+ lastSeen: string | null;
397
+ isArchive: boolean;
398
+ isDisappearing: boolean;
399
+ isMute: boolean;
400
+ messageExpiration: number;
401
+ muteExpiration: number | null;
402
+ isBusiness: boolean;
403
+ }
404
+ export interface ArchiveChat {
405
+ chatId: string;
406
+ }
407
+ export interface UnarchiveChat {
408
+ chatId: string;
409
+ }
410
+ export type EphemeralExpiration = 0 | 86400 | 604800 | 7776000;
411
+ export interface SetDisappearingChat {
412
+ chatId: string;
413
+ ephemeralExpiration: EphemeralExpiration;
414
+ }
415
+ export interface SetDisappearingChatResponse {
416
+ chatId: string;
417
+ disappearingMessagesInChat: boolean;
418
+ ephemeralExpiration: EphemeralExpiration;
419
+ }
277
420
  /**
278
421
  * Represents an instance state in the GREEN-API system.
279
422
  */
@@ -313,6 +456,84 @@ export interface SetProfilePicture {
313
456
  urlAvatar: string;
314
457
  setProfilePicture: boolean;
315
458
  }
459
+ export interface CreateGroup {
460
+ groupName: string;
461
+ chatIds: string[];
462
+ }
463
+ export interface CreateGroupResponse {
464
+ created: boolean;
465
+ chatId: string;
466
+ groupInviteLink: string;
467
+ }
468
+ export interface UpdateGroupName {
469
+ groupId: string;
470
+ groupName: string;
471
+ }
472
+ export interface UpdateGroupNameResponse {
473
+ updateGroupName: boolean;
474
+ }
475
+ export interface GroupParticipant {
476
+ id: string;
477
+ isAdmin: boolean;
478
+ isSuperAdmin: boolean;
479
+ }
480
+ export interface GroupData {
481
+ groupId: string;
482
+ owner: string;
483
+ subject: string;
484
+ creation: number;
485
+ participants: GroupParticipant[];
486
+ subjectTime: number;
487
+ subjectOwner: string;
488
+ groupInviteLink: string;
489
+ }
490
+ export interface GetGroupData {
491
+ groupId: string;
492
+ }
493
+ export interface AddGroupParticipant {
494
+ groupId: string;
495
+ participantChatId: string;
496
+ }
497
+ export interface AddGroupParticipantResponse {
498
+ addParticipant: boolean;
499
+ }
500
+ export interface RemoveGroupParticipant {
501
+ groupId: string;
502
+ participantChatId: string;
503
+ }
504
+ export interface RemoveGroupParticipantResponse {
505
+ removeParticipant: boolean;
506
+ }
507
+ export interface SetGroupAdmin {
508
+ groupId: string;
509
+ participantChatId: string;
510
+ }
511
+ export interface SetGroupAdminResponse {
512
+ setGroupAdmin: boolean;
513
+ }
514
+ export interface RemoveAdmin {
515
+ groupId: string;
516
+ participantChatId: string;
517
+ }
518
+ export interface RemoveAdminResponse {
519
+ removeAdmin: boolean;
520
+ }
521
+ export interface SetGroupPicture {
522
+ groupId: string;
523
+ file: Blob | File;
524
+ }
525
+ export interface SetGroupPictureResponse {
526
+ setGroupPicture: boolean;
527
+ urlAvatar: string | null;
528
+ reason: string;
529
+ }
530
+ export interface LeaveGroup {
531
+ groupId: string;
532
+ }
533
+ export interface LeaveGroupResponse {
534
+ leaveGroup?: boolean;
535
+ removeAdmin?: boolean;
536
+ }
316
537
  export interface BaseRequest {
317
538
  headers: Record<string, any>;
318
539
  body: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@green-api/greenapi-integration",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "GREEN-API Integration library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",