@natyapp/meta 1.6.7 → 1.7.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/.github/copilot-instructions.md +1540 -0
- package/README.md +122 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.js +11 -2
- package/dist/interfaces/IConnection.d.ts +2 -2
- package/dist/interfaces/ILog.d.ts +2 -2
- package/dist/interfaces/ILogger.d.ts +62 -0
- package/dist/interfaces/ILogger.js +2 -0
- package/dist/interfaces/ISdk.d.ts +4 -2
- package/dist/interfaces/IWebhook.d.ts +2 -2
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/index.js +1 -0
- package/dist/queue/messageQueue.d.ts +1 -1
- package/dist/queue/messageQueue.js +45 -0
- package/dist/routes/webhooks/methods/connection.js +78 -11
- package/dist/routes/webhooks/methods/messages.js +18 -3
- package/dist/services/axiosInstances.d.ts +14 -5
- package/dist/services/axiosInstances.js +111 -23
- package/dist/services/middlewares/validations.d.ts +2 -2
- package/dist/services/middlewares/validations.js +1 -2
- package/dist/services/mutations/connection.js +1 -1
- package/dist/services/mutations/logs.js +1 -1
- package/dist/services/mutations/messages.js +1 -1
- package/dist/services/mutations/validation.d.ts +1 -1
- package/dist/services/mutations/validation.js +1 -1
- package/dist/services/mutations/webhooks.js +1 -1
- package/dist/types/logs.d.ts +1 -1
- package/dist/types/requestTypes.d.ts +2 -0
- package/dist/useCases/connection/index.d.ts +9 -9
- package/dist/useCases/connection/index.js +156 -7
- package/dist/useCases/events/NatyEvents.d.ts +4 -2
- package/dist/useCases/events/NatyEvents.js +13 -1
- package/dist/useCases/log/index.d.ts +5 -5
- package/dist/useCases/log/index.js +65 -3
- package/dist/useCases/message/whatsappResponse.d.ts +33 -23
- package/dist/useCases/message/whatsappResponse.js +655 -109
- package/dist/useCases/messages/index.d.ts +5 -5
- package/dist/useCases/messages/index.js +66 -3
- package/dist/useCases/sdk/index.d.ts +8 -4
- package/dist/useCases/sdk/index.js +38 -6
- package/dist/useCases/webhook/index.d.ts +9 -9
- package/dist/useCases/webhook/index.js +154 -7
- package/dist/utils/consoleLogger.d.ts +20 -0
- package/dist/utils/consoleLogger.js +51 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/loggerContext.d.ts +57 -0
- package/dist/utils/loggerContext.js +90 -0
- package/dist/utils/methodContext.d.ts +34 -0
- package/dist/utils/methodContext.js +48 -0
- package/dist/utils/parseError.d.ts +12 -0
- package/dist/utils/parseError.js +27 -3
- package/dist/utils/pinoAdapter.d.ts +30 -0
- package/dist/utils/pinoAdapter.js +68 -0
- package/dist/utils/sanitize.d.ts +42 -0
- package/dist/utils/sanitize.js +120 -0
- package/dist/utils/tryCatch.d.ts +10 -1
- package/dist/utils/tryCatch.js +40 -5
- package/docs/01-visao-geral.md +355 -0
- package/docs/02-contexto-negocio.md +596 -0
- package/docs/03-arquitetura.md +925 -0
- package/docs/04-fluxos-funcionais.md +887 -0
- package/docs/05-integracoes.md +960 -0
- package/docs/06-entidades.md +849 -0
- package/docs/07-guia-pratico.md +1133 -0
- package/docs/08-troubleshooting.md +816 -0
- package/docs/README.md +125 -0
- package/examples/logger-example.ts +279 -0
- package/package.json +2 -2
- /package/dist/{Entities → entities}/Logs.d.ts +0 -0
- /package/dist/{Entities → entities}/Logs.js +0 -0
- /package/dist/{Entities → entities}/connection.d.ts +0 -0
- /package/dist/{Entities → entities}/connection.js +0 -0
- /package/dist/{Entities → entities}/errorLogs.d.ts +0 -0
- /package/dist/{Entities → entities}/errorLogs.js +0 -0
- /package/dist/{Entities → entities}/index.d.ts +0 -0
- /package/dist/{Entities → entities}/index.js +0 -0
- /package/dist/{Entities → entities}/messages.d.ts +0 -0
- /package/dist/{Entities → entities}/messages.js +0 -0
- /package/dist/{Entities → entities}/webhooks.d.ts +0 -0
- /package/dist/{Entities → entities}/webhooks.js +0 -0
- /package/dist/{Entities → entities}/whatsappMessage.d.ts +0 -0
- /package/dist/{Entities → entities}/whatsappMessage.js +0 -0
- /package/dist/{Errors → errors}/Either.d.ts +0 -0
- /package/dist/{Errors → errors}/Either.js +0 -0
- /package/dist/{Errors → errors}/ErrorHandling.d.ts +0 -0
- /package/dist/{Errors → errors}/ErrorHandling.js +0 -0
- /package/dist/{Errors → errors}/index.d.ts +0 -0
- /package/dist/{Errors → errors}/index.js +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { WhatsappMessage } from "../../
|
|
1
|
+
import { LogsEntity } from "../../entities/Logs";
|
|
2
|
+
import { WhatsappMessage } from "../../entities/whatsappMessage";
|
|
3
3
|
import { Button } from "../../elements/button";
|
|
4
4
|
import { List } from "../../elements/list";
|
|
5
5
|
import { ISendMessageReturn } from "../../interfaces";
|
|
6
6
|
import { getAllReturn } from "../../types";
|
|
7
7
|
import { contactType } from "../../types/whatsappTypes";
|
|
8
8
|
import { connectionEvent } from "../events/NatyEvents";
|
|
9
|
+
import { Either } from "../../errors/Either";
|
|
9
10
|
export declare class WhatsappResponse {
|
|
10
11
|
companyId: string;
|
|
11
12
|
phone_number_id: string;
|
|
@@ -15,55 +16,64 @@ export declare class WhatsappResponse {
|
|
|
15
16
|
messageType: string;
|
|
16
17
|
private apiCall;
|
|
17
18
|
token: string;
|
|
19
|
+
private logger;
|
|
20
|
+
private _initialized;
|
|
21
|
+
private _initializationPromise;
|
|
18
22
|
constructor(companyId: string, phone_number_id: string, clientNumber?: string, message?: WhatsappMessage | undefined);
|
|
23
|
+
/**
|
|
24
|
+
* Ensures the WhatsappResponse instance is initialized with valid token.
|
|
25
|
+
* This method implements lazy initialization and is idempotent.
|
|
26
|
+
* @returns Either with error or void on success
|
|
27
|
+
*/
|
|
28
|
+
private ensureInitialized;
|
|
19
29
|
private getApiInstanceToken;
|
|
20
30
|
updateClientNumber(clientNumber: string): Promise<void>;
|
|
21
|
-
get_account_info(): Promise<connectionEvent["accountInfo"]
|
|
31
|
+
get_account_info(): Promise<Either<Error, connectionEvent["accountInfo"]>>;
|
|
22
32
|
get_old_messages({ page, size, }: {
|
|
23
33
|
page: number;
|
|
24
34
|
size: number;
|
|
25
|
-
}): Promise<getAllReturn<
|
|
26
|
-
send_text_message(text: string): Promise<ISendMessageReturn
|
|
27
|
-
send_button(btn: Button): Promise<ISendMessageReturn
|
|
28
|
-
send_list(list: List): Promise<ISendMessageReturn
|
|
35
|
+
}): Promise<Either<Error, getAllReturn<LogsEntity>>>;
|
|
36
|
+
send_text_message(text: string): Promise<Either<Error, ISendMessageReturn>>;
|
|
37
|
+
send_button(btn: Button): Promise<Either<Error, ISendMessageReturn>>;
|
|
38
|
+
send_list(list: List): Promise<Either<Error, ISendMessageReturn>>;
|
|
29
39
|
reply({ type, toReply, messageToReply, }: {
|
|
30
40
|
type: "text" | "interactive";
|
|
31
41
|
toReply: string | Button | List;
|
|
32
42
|
messageToReply?: string;
|
|
33
|
-
}): Promise<ISendMessageReturn
|
|
34
|
-
mark_as_read(): Promise<boolean
|
|
43
|
+
}): Promise<Either<Error, ISendMessageReturn>>;
|
|
44
|
+
mark_as_read(): Promise<Either<Error, boolean>>;
|
|
35
45
|
send_reaction(emoji?: string): Promise<ISendMessageReturn | null>;
|
|
36
46
|
send_location({ long, lat, name, address, }: {
|
|
37
47
|
long?: number;
|
|
38
48
|
lat?: number;
|
|
39
49
|
name: string;
|
|
40
50
|
address: string;
|
|
41
|
-
}): Promise<ISendMessageReturn
|
|
42
|
-
send_contacts(contacts: contactType[]): Promise<ISendMessageReturn
|
|
43
|
-
createMedia(stream: string, fileType: string): Promise<any
|
|
51
|
+
}): Promise<Either<Error, ISendMessageReturn>>;
|
|
52
|
+
send_contacts(contacts: contactType[]): Promise<Either<Error, ISendMessageReturn>>;
|
|
53
|
+
createMedia(stream: string, fileType: string): Promise<Either<Error, any>>;
|
|
44
54
|
sendLink(link: string, linkType: "image" | "document" | "audio" | "video" | "sticker", linkData?: {
|
|
45
55
|
caption?: string;
|
|
46
56
|
filename?: string;
|
|
47
|
-
}): Promise<ISendMessageReturn
|
|
57
|
+
}): Promise<Either<Error, ISendMessageReturn>>;
|
|
48
58
|
send_image(stream: string, filetype: "image/jpeg" | "image/png" | "link", fileData: {
|
|
49
59
|
description: string;
|
|
50
|
-
}): Promise<ISendMessageReturn
|
|
60
|
+
}): Promise<Either<Error, ISendMessageReturn>>;
|
|
51
61
|
send_document(stream: string, filetype: "text/plain" | "application/pdf" | "application/vnd.ms-powerpoint" | "application/msword" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "link", fileData: {
|
|
52
62
|
fileName: string;
|
|
53
63
|
description: string;
|
|
54
|
-
}): Promise<ISendMessageReturn
|
|
64
|
+
}): Promise<Either<Error, ISendMessageReturn>>;
|
|
55
65
|
send_video(stream: string, filetype: "video/mp4" | "video/3gp" | "link", fileData: {
|
|
56
66
|
description: string;
|
|
57
|
-
}): Promise<ISendMessageReturn
|
|
58
|
-
send_sticker(stream: string, filetype: "image/webp" | "link"): Promise<ISendMessageReturn
|
|
59
|
-
send_audio(stream: string, filetype: "audio/aac" | "audio/mp4" | "audio/mpeg" | "audio/amr" | "audio/ogg" | "link"): Promise<ISendMessageReturn
|
|
60
|
-
download_media(url: string, mimetype: string): Promise<any
|
|
61
|
-
get_media_url(media_id: string): Promise<any
|
|
62
|
-
update_long_lived_token(client_id: string, client_secret: string, fb_exchange_token: string): Promise<string
|
|
67
|
+
}): Promise<Either<Error, ISendMessageReturn>>;
|
|
68
|
+
send_sticker(stream: string, filetype: "image/webp" | "link"): Promise<Either<Error, ISendMessageReturn>>;
|
|
69
|
+
send_audio(stream: string, filetype: "audio/aac" | "audio/mp4" | "audio/mpeg" | "audio/amr" | "audio/ogg" | "link"): Promise<Either<Error, ISendMessageReturn>>;
|
|
70
|
+
download_media(url: string, mimetype: string): Promise<Either<Error, any>>;
|
|
71
|
+
get_media_url(media_id: string): Promise<Either<Error, any>>;
|
|
72
|
+
update_long_lived_token(client_id: string, client_secret: string, fb_exchange_token: string): Promise<Either<Error, string>>;
|
|
63
73
|
send_template_text_message(template: string, language: string, bodyParameters?: Array<{
|
|
64
74
|
type: string;
|
|
65
75
|
text: string;
|
|
66
|
-
}>): Promise<ISendMessageReturn
|
|
76
|
+
}>): Promise<Either<Error, ISendMessageReturn>>;
|
|
67
77
|
send_template_media_message(template: string, language: string, options: {
|
|
68
78
|
header?: {
|
|
69
79
|
type: "image" | "video" | "document";
|
|
@@ -76,5 +86,5 @@ export declare class WhatsappResponse {
|
|
|
76
86
|
type: string;
|
|
77
87
|
text: string;
|
|
78
88
|
}>;
|
|
79
|
-
}): Promise<ISendMessageReturn
|
|
89
|
+
}): Promise<Either<Error, ISendMessageReturn>>;
|
|
80
90
|
}
|