@builderbot/provider-evolution-api 1.2.7 → 1.2.8-alpha.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/LICENSE.md +21 -0
- package/dist/evolution/core.d.ts +16 -25
- package/dist/evolution/core.d.ts.map +1 -1
- package/dist/evolution/provider.d.ts +108 -19
- package/dist/evolution/provider.d.ts.map +1 -1
- package/dist/index.cjs +519 -589
- package/dist/interface/evolution.d.ts +13 -8
- package/dist/interface/evolution.d.ts.map +1 -1
- package/dist/types.d.ts +68 -191
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/download.d.ts +8 -0
- package/dist/utils/download.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -5
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +5 -9
- package/dist/utils/downloadFile.d.ts +0 -16
- package/dist/utils/downloadFile.d.ts.map +0 -1
- package/dist/utils/mediaUrl.d.ts +0 -3
- package/dist/utils/mediaUrl.d.ts.map +0 -1
- package/dist/utils/number.d.ts +0 -2
- package/dist/utils/number.d.ts.map +0 -1
- package/dist/utils/processIncomingMsg.d.ts +0 -3
- package/dist/utils/processIncomingMsg.d.ts.map +0 -1
- package/dist/utils/profile.d.ts +0 -4
- package/dist/utils/profile.d.ts.map +0 -1
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Leifer Mendez
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/evolution/core.d.ts
CHANGED
|
@@ -1,47 +1,38 @@
|
|
|
1
1
|
import EventEmitter from 'node:events';
|
|
2
2
|
import type polka from 'polka';
|
|
3
3
|
import type Queue from 'queue-promise';
|
|
4
|
-
import type { Message } from '~/types';
|
|
5
4
|
/**
|
|
6
|
-
* Class representing
|
|
5
|
+
* Class representing EvolutionCoreVendor, a vendor class for WhatsApp Business API integration.
|
|
6
|
+
* Handles webhook validation, message reception, and processing through Meta's Cloud API.
|
|
7
7
|
* @extends EventEmitter
|
|
8
8
|
*/
|
|
9
9
|
export declare class EvolutionCoreVendor extends EventEmitter {
|
|
10
|
-
queue: Queue;
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
13
|
-
* @
|
|
11
|
+
* Queue for handling asynchronous message processing
|
|
12
|
+
* @private
|
|
14
13
|
*/
|
|
15
|
-
|
|
14
|
+
private readonly queue;
|
|
16
15
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @
|
|
16
|
+
* Creates an instance of EvolutionCoreVendor.
|
|
17
|
+
* @param {Queue} _queue - The queue instance for managing message processing.
|
|
19
18
|
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Check if the token is valid.
|
|
23
|
-
* @param {string} mode - The mode parameter.
|
|
24
|
-
* @param {string} token - The token parameter.
|
|
25
|
-
* @param {string} originToken - The origin token parameter.
|
|
26
|
-
* @returns {boolean} Returns true if token is valid, false otherwise.
|
|
27
|
-
*/
|
|
28
|
-
tokenIsValid(mode: string, token: string, originToken: string): boolean;
|
|
29
|
-
private extractStatus;
|
|
19
|
+
constructor(_queue: Queue);
|
|
30
20
|
/**
|
|
31
|
-
* Middleware function for
|
|
21
|
+
* Middleware function for health check endpoint.
|
|
22
|
+
* Returns a simple response to verify the service is running.
|
|
32
23
|
* @type {polka.Middleware}
|
|
33
24
|
*/
|
|
34
|
-
|
|
25
|
+
indexHome: polka.Middleware;
|
|
35
26
|
/**
|
|
36
|
-
* Middleware function for handling incoming messages.
|
|
27
|
+
* Middleware function for handling incoming webhook messages.
|
|
28
|
+
* Processes incoming messages from WhatsApp and adds them to the processing queue.
|
|
37
29
|
* @type {polka.Middleware}
|
|
38
30
|
*/
|
|
39
31
|
incomingMsg: polka.Middleware;
|
|
40
32
|
/**
|
|
41
|
-
*
|
|
42
|
-
* @param
|
|
43
|
-
* @returns {Promise<void>} Promise that resolves when processing is complete.
|
|
33
|
+
* Procesa un mensaje entrante y lo emite al flujo del bot.
|
|
34
|
+
* @param message - Objeto de mensaje enriquecido.
|
|
44
35
|
*/
|
|
45
|
-
processMessage: (message:
|
|
36
|
+
processMessage: (message: any) => Promise<void>;
|
|
46
37
|
}
|
|
47
38
|
//# sourceMappingURL=core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/evolution/core.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/evolution/core.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,KAAK,MAAM,eAAe,CAAA;AA0BtC;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,YAAY;IACjD;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAO;IAE7B;;;OAGG;gBACS,MAAM,EAAE,KAAK;IAQzB;;;;OAIG;IACI,SAAS,EAAE,KAAK,CAAC,UAAU,CAQjC;IAED;;;;OAIG;IACI,WAAW,EAAE,KAAK,CAAC,UAAU,CAkHnC;IAED;;;OAGG;IACI,cAAc,GAAI,SAAS,GAAG,KAAG,OAAO,CAAC,IAAI,CAAC,CASpD;CACJ"}
|
|
@@ -1,35 +1,124 @@
|
|
|
1
1
|
import { ProviderClass } from '@builderbot/bot';
|
|
2
2
|
import type { Vendor } from '@builderbot/bot/dist/provider/interface/provider';
|
|
3
|
-
import type { BotContext } from '@builderbot/bot/dist/types';
|
|
3
|
+
import type { BotContext, SendOptions } from '@builderbot/bot/dist/types';
|
|
4
|
+
import { Middleware } from 'polka';
|
|
5
|
+
import type polka from 'polka';
|
|
4
6
|
import Queue from 'queue-promise';
|
|
7
|
+
|
|
5
8
|
import type { EvolutionInterface } from '../interface/evolution';
|
|
6
|
-
import type { EvolutionGlobalVendorArgs,
|
|
9
|
+
import type { EvolutionGlobalVendorArgs, SaveFileOptions } from '../types';
|
|
10
|
+
/**
|
|
11
|
+
* Evolution API Provider implementation
|
|
12
|
+
* Handles all communication with Evolution API for sending messages, media, etc.
|
|
13
|
+
*/
|
|
7
14
|
declare class EvolutionProvider extends ProviderClass<EvolutionInterface> implements EvolutionInterface {
|
|
8
|
-
vendor: Vendor<
|
|
15
|
+
vendor: Vendor<EvolutionInterface & {
|
|
16
|
+
indexHome: polka.Middleware;
|
|
17
|
+
incomingMsg: polka.Middleware;
|
|
18
|
+
}>;
|
|
9
19
|
queue: Queue;
|
|
20
|
+
incomingMsg: any;
|
|
10
21
|
globalVendorArgs: EvolutionGlobalVendorArgs;
|
|
22
|
+
/**
|
|
23
|
+
* Creates an instance of Evolution Provider
|
|
24
|
+
* @param args Provider configuration
|
|
25
|
+
*/
|
|
11
26
|
constructor(args: EvolutionGlobalVendorArgs);
|
|
27
|
+
sendMessageMeta: (body: any) => Promise<any>;
|
|
28
|
+
sendImageUrl: (to: string, url: string, mediaName?: string, caption?: string) => Promise<any>;
|
|
29
|
+
sendVideoUrl: (to: string, url: string, mediaName?: string, caption?: string) => Promise<any>;
|
|
30
|
+
sendAudioUrl: (to: string, url: string, mediaName?: string, caption?: string) => Promise<any>;
|
|
31
|
+
sendList: (to: string, list: any) => Promise<any>;
|
|
32
|
+
sendListComplete: (to: string, list: any) => Promise<any>;
|
|
33
|
+
indexHome?: Middleware<any, any, any, any>;
|
|
34
|
+
/**
|
|
35
|
+
* Initialize HTTP server middleware
|
|
36
|
+
*/
|
|
12
37
|
protected beforeHttpServerInit(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Initialize vendor core
|
|
40
|
+
*/
|
|
13
41
|
protected initVendor(): Promise<any>;
|
|
14
|
-
|
|
15
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Build standard headers for API requests
|
|
44
|
+
* @param additionalHeaders Optional additional headers to include
|
|
45
|
+
* @returns Headers object with apiKey
|
|
46
|
+
*/
|
|
47
|
+
private builderHeader;
|
|
48
|
+
/**
|
|
49
|
+
* Verify connection with Evolution API after HTTP server initialization
|
|
50
|
+
*/ protected afterHttpServerInit(): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Event bus configuration
|
|
53
|
+
*/
|
|
54
|
+
protected busEvents(): {
|
|
16
55
|
event: string;
|
|
17
56
|
func: (payload: any) => void;
|
|
18
57
|
}[];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
sendMedia(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Punto de entrada para envío de archivos multimedia.
|
|
60
|
+
* Detecta el tipo de archivo y redirige a la función correspondiente.
|
|
61
|
+
*
|
|
62
|
+
* @param number Número de destino
|
|
63
|
+
* @param mediaUrl URL o path del archivo
|
|
64
|
+
* @param caption Texto opcional
|
|
65
|
+
*/
|
|
66
|
+
sendMedia: (number: string, mediaUrl: string, caption: string) => Promise<any>;
|
|
67
|
+
/**
|
|
68
|
+
* Envía una imagen al número dado.
|
|
69
|
+
* @param number Número destino
|
|
70
|
+
* @param filePath Ruta local de la imagen
|
|
71
|
+
* @param caption Texto opcional
|
|
72
|
+
*/
|
|
73
|
+
sendImage: (number: string, filePath: string, caption: string) => Promise<any>;
|
|
74
|
+
/**
|
|
75
|
+
* Envía un video al número dado.
|
|
76
|
+
* @param number Número destino
|
|
77
|
+
* @param filePath Ruta local del video
|
|
78
|
+
* @param caption Texto opcional
|
|
79
|
+
*/
|
|
80
|
+
sendVideo: (number: string, filePath: string, caption: string) => Promise<any>;
|
|
81
|
+
/**
|
|
82
|
+
* Envía un archivo de audio en formato compatible (OPUS).
|
|
83
|
+
* @param number Número destino
|
|
84
|
+
* @param filePath Ruta local del archivo de audio
|
|
85
|
+
*/
|
|
86
|
+
sendAudio: (number: string, filePath: string) => Promise<any>;
|
|
87
|
+
/**
|
|
88
|
+
* Envía un documento genérico al número dado.
|
|
89
|
+
* @param number Número destino
|
|
90
|
+
* @param filePath Ruta local del archivo
|
|
91
|
+
* @param caption Texto opcional
|
|
92
|
+
*/
|
|
93
|
+
sendFile: (number: string, filePath: string, caption: string) => Promise<any>;
|
|
94
|
+
/**
|
|
95
|
+
* Envía un mensaje de texto plano.
|
|
96
|
+
* @param number Número destino
|
|
97
|
+
* @param message Contenido del mensaje
|
|
98
|
+
*/
|
|
99
|
+
sendText: (number: string, message: string) => Promise<any>;
|
|
100
|
+
/**
|
|
101
|
+
* Función general para hacer peticiones POST a la API externa.
|
|
102
|
+
* @param body Cuerpo de la petición
|
|
103
|
+
* @param ruta Ruta relativa del endpoint (optional)
|
|
104
|
+
*/
|
|
105
|
+
sendMessageToApi: (body: any, ruta?: string) => Promise<any>;
|
|
106
|
+
/**
|
|
107
|
+
* Encola el envío de un mensaje para asegurar orden y evitar conflictos.
|
|
108
|
+
* @param body Cuerpo del mensaje
|
|
109
|
+
* @param ruta Ruta del endpoint
|
|
110
|
+
*/
|
|
111
|
+
sendMessageEvoApi: (body: any, ruta: string) => Promise<any>;
|
|
112
|
+
/**
|
|
113
|
+
* Enrutador general para envío de mensajes.
|
|
114
|
+
* Si incluye media, se envía como archivo. Si no, como texto plano.
|
|
115
|
+
*
|
|
116
|
+
* @param number Número destino
|
|
117
|
+
* @param message Mensaje de texto
|
|
118
|
+
* @param options Opciones adicionales (media, etc.)
|
|
119
|
+
*/
|
|
120
|
+
sendMessage(number: string, message: string, options?: SendOptions): Promise<any>;
|
|
121
|
+
saveFile: (ctx: Partial<BotContext>, options?: SaveFileOptions) => Promise<string>;
|
|
33
122
|
}
|
|
34
123
|
export { EvolutionProvider };
|
|
35
124
|
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/evolution/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/evolution/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kDAAkD,CAAA;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AASzE,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,MAAM,eAAe,CAAA;AAEjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,KAAK,EAAE,yB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