@green-api/greenapi-integration 0.6.0 → 0.6.2

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 (5) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1080 -1061
  3. package/README.ru.md +1092 -1068
  4. package/dist/types/types.d.ts +161 -6
  5. package/package.json +42 -41
@@ -109,7 +109,7 @@ export interface QueueMessage {
109
109
  export interface ClearMessagesQueue {
110
110
  isCleared: boolean;
111
111
  }
112
- export type MessageType = "textMessage" | "extendedTextMessage" | "imageMessage" | "videoMessage" | "documentMessage" | "audioMessage" | "contactMessage" | "locationMessage" | "pollMessage" | "reactionMessage" | "pollUpdateMessage" | "quotedMessage" | "stickerMessage";
112
+ export type MessageType = "textMessage" | "extendedTextMessage" | "imageMessage" | "videoMessage" | "documentMessage" | "audioMessage" | "contactMessage" | "locationMessage" | "contactsArrayMessage" | "pollMessage" | "reactionMessage" | "pollUpdateMessage" | "quotedMessage" | "stickerMessage" | "editedMessage" | "deletedMessage" | "buttonsMessage" | "listMessage" | "templateMessage" | "groupInviteMessage";
113
113
  export interface GetMessage {
114
114
  chatId: string;
115
115
  idMessage: string;
@@ -140,13 +140,17 @@ export interface OutgoingJournalFields {
140
140
  export type BaseIncomingJournalMessage = BaseJournalMessage & IncomingJournalFields;
141
141
  export type BaseOutgoingJournalMessage = BaseJournalMessage & OutgoingJournalFields;
142
142
  export type BaseJournalResponse = BaseIncomingJournalMessage | BaseOutgoingJournalMessage;
143
- export type OutgoingJournalResponse = BaseOutgoingJournalMessage & WebhookMessageData & {
143
+ export type JournalMessageData<T> = T extends {
144
+ typeMessage: "imageMessage" | "videoMessage" | "documentMessage" | "audioMessage" | "stickerMessage";
145
+ fileMessageData: FileMessageData;
146
+ } ? Omit<T, "fileMessageData"> & FileMessageData : T;
147
+ export type OutgoingJournalResponse = BaseOutgoingJournalMessage & JournalMessageData<WebhookMessageData> & {
144
148
  quotedMessage?: QuotedMessage;
145
149
  };
146
- export type IncomingJournalResponse = BaseIncomingJournalMessage & WebhookMessageData & {
150
+ export type IncomingJournalResponse = BaseIncomingJournalMessage & JournalMessageData<WebhookMessageData> & {
147
151
  quotedMessage?: QuotedMessage;
148
152
  };
149
- export type JournalResponse = BaseJournalResponse & WebhookMessageData & {
153
+ export type JournalResponse = BaseJournalResponse & JournalMessageData<WebhookMessageData> & {
150
154
  quotedMessage?: QuotedMessage;
151
155
  };
152
156
  export interface ForwardableMessage {
@@ -159,6 +163,76 @@ export interface MediaMessage extends ForwardableMessage {
159
163
  export interface TextMessageData {
160
164
  textMessage: string;
161
165
  }
166
+ export interface EditedMessageData {
167
+ textMessage?: string;
168
+ caption?: string;
169
+ stanzaId: string;
170
+ }
171
+ export interface DeletedMessageData {
172
+ stanzaId: string;
173
+ }
174
+ export interface ReactionMessageData {
175
+ text: string;
176
+ }
177
+ export interface ButtonData {
178
+ buttonId: string;
179
+ buttonText: string;
180
+ }
181
+ export interface ButtonsMessageData extends ForwardableMessage {
182
+ contentText: string;
183
+ footer: string;
184
+ buttons: ButtonData[];
185
+ }
186
+ export interface ListRowData {
187
+ title: string;
188
+ rowId: string;
189
+ description?: string;
190
+ }
191
+ export interface ListSectionData {
192
+ title: string;
193
+ rows: ListRowData[];
194
+ }
195
+ export interface ListMessageData extends ForwardableMessage {
196
+ contentText: string;
197
+ title?: string;
198
+ footer?: string;
199
+ buttonText?: string;
200
+ sections: ListSectionData[];
201
+ }
202
+ export interface UrlButtonData {
203
+ displayText: string;
204
+ url: string;
205
+ }
206
+ export interface CallButtonData {
207
+ displayText: string;
208
+ phoneNumber: string;
209
+ }
210
+ export interface QuickReplyButtonData {
211
+ displayText: string;
212
+ id: string;
213
+ }
214
+ export interface TemplateButtonData {
215
+ index: number;
216
+ urlButton?: UrlButtonData;
217
+ callButton?: CallButtonData;
218
+ quickReplyButton?: QuickReplyButtonData;
219
+ }
220
+ export interface TemplateMessageData extends ForwardableMessage {
221
+ namespace?: string;
222
+ elementName?: string;
223
+ contentText: string;
224
+ footer?: string;
225
+ buttons: TemplateButtonData[];
226
+ }
227
+ export interface GroupInviteMessageData {
228
+ groupJid: string;
229
+ inviteCode: string;
230
+ inviteExpiration: string;
231
+ groupName: string;
232
+ caption: string;
233
+ name: string;
234
+ jpegThumbnail: string;
235
+ }
162
236
  export interface ExtendedTextMessageData extends MediaMessage {
163
237
  text: string;
164
238
  description: string;
@@ -169,6 +243,7 @@ export interface FileMessageData extends MediaMessage {
169
243
  caption: string;
170
244
  mimeType: string;
171
245
  fileName: string;
246
+ isAnimated?: boolean;
172
247
  }
173
248
  export interface LocationMessageData extends MediaMessage {
174
249
  nameLocation: string;
@@ -198,6 +273,15 @@ export type QuotedMessage = {
198
273
  } & ({
199
274
  typeMessage: "textMessage";
200
275
  textMessage: string;
276
+ } | {
277
+ typeMessage: "extendedTextMessage";
278
+ textMessage: string;
279
+ extendedTextMessage: {
280
+ description?: string;
281
+ title?: string;
282
+ previewType?: string;
283
+ jpegThumbnail?: string | null;
284
+ };
201
285
  } | {
202
286
  typeMessage: "contactMessage";
203
287
  contact: {
@@ -224,6 +308,32 @@ export type QuotedMessage = {
224
308
  downloadUrl: string;
225
309
  caption: string;
226
310
  jpegThumbnail: string;
311
+ } | {
312
+ typeMessage: "stickerMessage";
313
+ downloadUrl: string;
314
+ caption: string;
315
+ jpegThumbnail: string;
316
+ isAnimated: boolean;
317
+ } | {
318
+ typeMessage: "buttonsMessage";
319
+ contentText: string;
320
+ footer?: string;
321
+ buttons: ButtonData[];
322
+ } | {
323
+ typeMessage: "listMessage";
324
+ contentText: string;
325
+ title?: string;
326
+ footer?: string;
327
+ buttonText?: string;
328
+ sections: ListSectionData[];
329
+ } | {
330
+ typeMessage: "templateMessage";
331
+ contentText: string;
332
+ footer?: string;
333
+ buttons: TemplateButtonData[];
334
+ } | {
335
+ typeMessage: "groupInviteMessage";
336
+ groupInviteMessageData: GroupInviteMessageData;
227
337
  });
228
338
  export interface PollVote {
229
339
  optionName: string;
@@ -236,7 +346,7 @@ export interface PollUpdateMessageData {
236
346
  multipleAnswers: boolean;
237
347
  }
238
348
  export type OutgoingMessageStatus = "sent" | "delivered" | "read" | "failed" | "noAccount" | "notInGroup" | "yellowCard";
239
- export type WebhookType = "stateInstanceChanged" | "outgoingMessageStatus" | "outgoingAPIMessageReceived" | "outgoingMessageReceived" | "incomingMessageReceived";
349
+ export type WebhookType = "stateInstanceChanged" | "outgoingMessageStatus" | "outgoingAPIMessageReceived" | "outgoingMessageReceived" | "incomingMessageReceived" | "incomingCall";
240
350
  /**
241
351
  * Webhook payload received when a message status changes.
242
352
  * Used to track delivery and read receipts.
@@ -274,6 +384,10 @@ export type WebhookMessageData = {
274
384
  } | {
275
385
  typeMessage: "imageMessage" | "videoMessage" | "documentMessage" | "audioMessage";
276
386
  fileMessageData: FileMessageData;
387
+ } | {
388
+ typeMessage: "quotedMessage";
389
+ extendedTextMessageData: ExtendedTextMessageData;
390
+ quotedMessage: QuotedMessage;
277
391
  } | {
278
392
  typeMessage: "locationMessage";
279
393
  locationMessageData: LocationMessageData;
@@ -289,6 +403,31 @@ export type WebhookMessageData = {
289
403
  } | {
290
404
  typeMessage: "contactsArrayMessage";
291
405
  messageData: ContactsArrayMessageData;
406
+ } | {
407
+ typeMessage: "editedMessage";
408
+ editedMessageData: EditedMessageData;
409
+ } | {
410
+ typeMessage: "deletedMessage";
411
+ deletedMessageData: DeletedMessageData;
412
+ } | {
413
+ typeMessage: "reactionMessage";
414
+ extendedTextMessageData: ReactionMessageData;
415
+ quotedMessage: QuotedMessage;
416
+ } | {
417
+ typeMessage: "buttonsMessage";
418
+ buttonsMessage: ButtonsMessageData;
419
+ } | {
420
+ typeMessage: "listMessage";
421
+ listMessage: ListMessageData;
422
+ } | {
423
+ typeMessage: "templateMessage";
424
+ templateMessage: TemplateMessageData;
425
+ } | {
426
+ typeMessage: "stickerMessage";
427
+ fileMessageData: FileMessageData;
428
+ } | {
429
+ typeMessage: "groupInviteMessage";
430
+ groupInviteMessageData: GroupInviteMessageData;
292
431
  };
293
432
  export interface MessageWebhook {
294
433
  typeWebhook: "incomingMessageReceived" | "outgoingMessageReceived" | "outgoingAPIMessageReceived";
@@ -310,10 +449,23 @@ export interface MessageWebhook {
310
449
  quotedMessage?: QuotedMessage;
311
450
  };
312
451
  }
452
+ export type CallStatus = "offer" | "pickUp" | "hangUp" | "missed" | "declined";
453
+ export interface IncomingCallWebhook {
454
+ from: string;
455
+ typeWebhook: "incomingCall";
456
+ instanceData: {
457
+ idInstance: number;
458
+ wid: string;
459
+ typeInstance: string;
460
+ };
461
+ status: CallStatus;
462
+ timestamp: number;
463
+ idMessage: string;
464
+ }
313
465
  /**
314
466
  * Primary webhook types received from GREEN-API.
315
467
  */
316
- export type GreenApiWebhook = MessageWebhook | OutgoingMessageStatusWebhook | StateInstanceWebhook;
468
+ export type GreenApiWebhook = MessageWebhook | OutgoingMessageStatusWebhook | StateInstanceWebhook | IncomingCallWebhook;
317
469
  /**
318
470
  * Configuration settings for a GREEN-API instance.
319
471
  * Controls webhook behavior, message handling, and other instance features.
@@ -333,6 +485,9 @@ export interface Settings {
333
485
  keepOnlineStatus?: "yes" | "no";
334
486
  pollMessageWebhook?: "yes" | "no";
335
487
  incomingCallWebhook?: "yes" | "no";
488
+ incomingBlockWebhook?: "yes" | "no";
489
+ editedMessageWebhook?: "yes" | "no";
490
+ deletedMessageWebhook?: "yes" | "no";
336
491
  }
337
492
  export interface Reboot {
338
493
  isReboot: boolean;
package/package.json CHANGED
@@ -1,41 +1,42 @@
1
- {
2
- "name": "@green-api/greenapi-integration",
3
- "version": "0.6.0",
4
- "description": "GREEN-API Integration library",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "files": [
8
- "dist"
9
- ],
10
- "scripts": {
11
- "build": "tsc",
12
- "clean": "rimraf dist",
13
- "prebuild": "npm run clean",
14
- "prepare": "npm run build",
15
- "docs": "typedoc",
16
- "docs:watch": "typedoc --watch"
17
- },
18
- "keywords": [
19
- "green-api",
20
- "whatsapp",
21
- "integration"
22
- ],
23
- "author": "GREEN-API team",
24
- "license": "MIT",
25
- "devDependencies": {
26
- "@types/express": "^5.0.0",
27
- "@types/jest": "^29.5.14",
28
- "@types/node": "^22.10.2",
29
- "express": "^4.21.2",
30
- "jest": "^29.7.0",
31
- "rimraf": "^6.0.1",
32
- "ts-jest": "^29.2.5",
33
- "ts-node": "^10.9.2",
34
- "typedoc": "^0.27.6",
35
- "typedoc-plugin-markdown": "^4.4.1",
36
- "typescript": "^5.7.2"
37
- },
38
- "dependencies": {
39
- "axios": "^1.7.9"
40
- }
41
- }
1
+ {
2
+ "name": "@green-api/greenapi-integration",
3
+ "version": "0.6.2",
4
+ "description": "GREEN-API Integration library",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "LICENSE"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "clean": "rimraf dist",
14
+ "prebuild": "npm run clean",
15
+ "prepare": "npm run build",
16
+ "docs": "typedoc",
17
+ "docs:watch": "typedoc --watch"
18
+ },
19
+ "keywords": [
20
+ "green-api",
21
+ "whatsapp",
22
+ "integration"
23
+ ],
24
+ "author": "GREEN-API team",
25
+ "license": "MIT",
26
+ "devDependencies": {
27
+ "@types/express": "^5.0.0",
28
+ "@types/jest": "^29.5.14",
29
+ "@types/node": "^22.10.2",
30
+ "express": "^4.21.2",
31
+ "jest": "^29.7.0",
32
+ "rimraf": "^6.0.1",
33
+ "ts-jest": "^29.2.5",
34
+ "ts-node": "^10.9.2",
35
+ "typedoc": "^0.27.6",
36
+ "typedoc-plugin-markdown": "^4.4.1",
37
+ "typescript": "^5.7.2"
38
+ },
39
+ "dependencies": {
40
+ "axios": "^1.7.9"
41
+ }
42
+ }