@natyapp/meta 1.3.1 → 1.4.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/dist/Entities/Logs.d.ts +16 -16
- package/dist/Entities/Logs.js +13 -13
- package/dist/Entities/connection.d.ts +15 -15
- package/dist/Entities/connection.js +13 -13
- package/dist/Entities/errorLogs.d.ts +9 -9
- package/dist/Entities/errorLogs.js +13 -13
- package/dist/Entities/index.d.ts +5 -5
- package/dist/Entities/index.js +21 -21
- package/dist/Entities/messages.d.ts +9 -9
- package/dist/Entities/messages.js +13 -13
- package/dist/Entities/webhooks.d.ts +17 -17
- package/dist/Entities/webhooks.js +13 -13
- package/dist/Entities/whatsappMessage.d.ts +63 -63
- package/dist/Entities/whatsappMessage.js +9 -9
- package/dist/Errors/Either.d.ts +15 -15
- package/dist/Errors/Either.js +37 -37
- package/dist/Errors/ErrorHandling.d.ts +10 -10
- package/dist/Errors/ErrorHandling.js +15 -15
- package/dist/Errors/index.d.ts +2 -2
- package/dist/Errors/index.js +18 -18
- package/dist/configs/axiosInterceptors.d.ts +7 -7
- package/dist/configs/axiosInterceptors.js +10 -10
- package/dist/elements/button.d.ts +18 -18
- package/dist/elements/button.js +11 -11
- package/dist/elements/image.d.ts +9 -9
- package/dist/elements/image.js +12 -12
- package/dist/elements/index.d.ts +3 -3
- package/dist/elements/index.js +19 -19
- package/dist/elements/list.d.ts +78 -78
- package/dist/elements/list.js +55 -55
- package/dist/elements/text.d.ts +12 -12
- package/dist/elements/text.js +13 -13
- package/dist/index.d.ts +8 -8
- package/dist/index.js +44 -44
- package/dist/interfaces/IConnection.d.ts +13 -13
- package/dist/interfaces/IConnection.js +2 -2
- package/dist/interfaces/IEventsMessage.d.ts +2 -2
- package/dist/interfaces/IEventsMessage.js +2 -2
- package/dist/interfaces/ILog.d.ts +10 -10
- package/dist/interfaces/ILog.js +2 -2
- package/dist/interfaces/IMessage.d.ts +22 -22
- package/dist/interfaces/IMessage.js +2 -2
- package/dist/interfaces/ISdk.d.ts +16 -16
- package/dist/interfaces/ISdk.js +2 -2
- package/dist/interfaces/IWebhook.d.ts +14 -14
- package/dist/interfaces/IWebhook.js +2 -2
- package/dist/interfaces/index.d.ts +5 -5
- package/dist/interfaces/index.js +21 -21
- package/dist/queue/messageQueue.d.ts +11 -11
- package/dist/queue/messageQueue.js +20 -20
- package/dist/routes/index.d.ts +3 -3
- package/dist/routes/index.js +11 -11
- package/dist/routes/webhooks/index.d.ts +3 -3
- package/dist/routes/webhooks/index.js +13 -13
- package/dist/routes/webhooks/methods/connection.d.ts +3 -3
- package/dist/routes/webhooks/methods/connection.js +42 -41
- package/dist/routes/webhooks/methods/messages.d.ts +3 -3
- package/dist/routes/webhooks/methods/messages.js +21 -21
- package/dist/services/axiosInstances.d.ts +18 -18
- package/dist/services/axiosInstances.js +45 -45
- package/dist/services/index.d.ts +3 -3
- package/dist/services/index.js +19 -19
- package/dist/services/middlewares/index.d.ts +1 -1
- package/dist/services/middlewares/index.js +5 -5
- package/dist/services/middlewares/validations.d.ts +4 -4
- package/dist/services/middlewares/validations.js +8 -8
- package/dist/services/mutations/connection.d.ts +2 -2
- package/dist/services/mutations/connection.js +49 -49
- package/dist/services/mutations/index.d.ts +3 -3
- package/dist/services/mutations/index.js +19 -19
- package/dist/services/mutations/logs.d.ts +2 -2
- package/dist/services/mutations/logs.js +25 -25
- package/dist/services/mutations/messages.d.ts +2 -2
- package/dist/services/mutations/messages.js +25 -25
- package/dist/services/mutations/validation.d.ts +5 -5
- package/dist/services/mutations/validation.js +15 -15
- package/dist/services/mutations/webhooks.d.ts +2 -2
- package/dist/services/mutations/webhooks.js +49 -49
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +19 -19
- package/dist/types/logs.d.ts +5 -5
- package/dist/types/logs.js +2 -2
- package/dist/types/requestTypes.d.ts +11 -11
- package/dist/types/requestTypes.js +2 -2
- package/dist/types/whatsappTypes.d.ts +68 -68
- package/dist/types/whatsappTypes.js +2 -2
- package/dist/ui/Button.d.ts +27 -27
- package/dist/ui/Button.js +95 -95
- package/dist/useCases/cadastroIncorporado/cadastroIncorporado.d.ts +1 -1
- package/dist/useCases/cadastroIncorporado/cadastroIncorporado.js +7 -7
- package/dist/useCases/connection/index.d.ts +15 -15
- package/dist/useCases/connection/index.js +16 -16
- package/dist/useCases/events/NatyEvents.d.ts +35 -35
- package/dist/useCases/events/NatyEvents.js +13 -13
- package/dist/useCases/index.d.ts +6 -6
- package/dist/useCases/index.js +16 -16
- package/dist/useCases/log/index.d.ts +10 -10
- package/dist/useCases/log/index.js +12 -12
- package/dist/useCases/message/index.d.ts +9 -9
- package/dist/useCases/message/index.js +6 -6
- package/dist/useCases/message/whatsappResponse.d.ts +62 -62
- package/dist/useCases/message/whatsappResponse.js +405 -403
- package/dist/useCases/messages/index.d.ts +10 -10
- package/dist/useCases/messages/index.js +12 -12
- package/dist/useCases/sdk/index.d.ts +19 -19
- package/dist/useCases/sdk/index.js +48 -48
- package/dist/useCases/webhook/index.d.ts +15 -15
- package/dist/useCases/webhook/index.js +16 -16
- package/dist/utils/constants.d.ts +11 -11
- package/dist/utils/constants.js +17 -17
- package/dist/utils/genUuid.d.ts +1 -1
- package/dist/utils/genUuid.js +16 -16
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +17 -17
- package/dist/utils/tryCatch.d.ts +1 -1
- package/dist/utils/tryCatch.js +19 -19
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ConnectionEntity } from "../Entities/connection";
|
|
2
|
-
import { Either } from "../Errors";
|
|
3
|
-
import { getAllProps, getAllReturn } from "../types/requestTypes";
|
|
4
|
-
export interface IConnection {
|
|
5
|
-
insert(connection: Partial<ConnectionEntity>): Promise<Either<connectionErrors, ConnectionEntity>>;
|
|
6
|
-
getSingle(id: string): Promise<Either<connectionErrors, ConnectionEntity>>;
|
|
7
|
-
SearchOne(key: string, value: string): Promise<Either<connectionErrors, ConnectionEntity>>;
|
|
8
|
-
getAll(props: getAllProps): Promise<Either<connectionErrors, getAllReturn<ConnectionEntity>>>;
|
|
9
|
-
update(id: string, connection: Partial<ConnectionEntity>): Promise<Either<connectionErrors, ConnectionEntity>>;
|
|
10
|
-
updateMany(connection: Partial<ConnectionEntity>[]): Promise<Either<connectionErrors, ConnectionEntity[]>>;
|
|
11
|
-
deleteOne(id: string): Promise<Either<connectionErrors, ConnectionEntity>>;
|
|
12
|
-
}
|
|
13
|
-
export type connectionErrors = "";
|
|
1
|
+
import { ConnectionEntity } from "../Entities/connection";
|
|
2
|
+
import { Either } from "../Errors";
|
|
3
|
+
import { getAllProps, getAllReturn } from "../types/requestTypes";
|
|
4
|
+
export interface IConnection {
|
|
5
|
+
insert(connection: Partial<ConnectionEntity>): Promise<Either<connectionErrors, ConnectionEntity>>;
|
|
6
|
+
getSingle(id: string): Promise<Either<connectionErrors, ConnectionEntity>>;
|
|
7
|
+
SearchOne(key: string, value: string): Promise<Either<connectionErrors, ConnectionEntity>>;
|
|
8
|
+
getAll(props: getAllProps): Promise<Either<connectionErrors, getAllReturn<ConnectionEntity>>>;
|
|
9
|
+
update(id: string, connection: Partial<ConnectionEntity>): Promise<Either<connectionErrors, ConnectionEntity>>;
|
|
10
|
+
updateMany(connection: Partial<ConnectionEntity>[]): Promise<Either<connectionErrors, ConnectionEntity[]>>;
|
|
11
|
+
deleteOne(id: string): Promise<Either<connectionErrors, ConnectionEntity>>;
|
|
12
|
+
}
|
|
13
|
+
export type connectionErrors = "";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export interface IEventsMessage {
|
|
2
|
-
}
|
|
1
|
+
export interface IEventsMessage {
|
|
2
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { LogsEntity } from "../Entities/Logs";
|
|
2
|
-
import { Either } from "../Errors";
|
|
3
|
-
import { getAllProps, getAllReturn } from "../types/requestTypes";
|
|
4
|
-
export interface ILog {
|
|
5
|
-
getSingle(key: string): Promise<Either<logErrors, LogsEntity>>;
|
|
6
|
-
getAll(props: getAllProps): Promise<Either<logErrors, getAllReturn<LogsEntity>>>;
|
|
7
|
-
searchOne(key: keyof LogsEntity, value: string): Promise<Either<logErrors, LogsEntity>>;
|
|
8
|
-
}
|
|
9
|
-
type logErrors = "";
|
|
10
|
-
export {};
|
|
1
|
+
import { LogsEntity } from "../Entities/Logs";
|
|
2
|
+
import { Either } from "../Errors";
|
|
3
|
+
import { getAllProps, getAllReturn } from "../types/requestTypes";
|
|
4
|
+
export interface ILog {
|
|
5
|
+
getSingle(key: string): Promise<Either<logErrors, LogsEntity>>;
|
|
6
|
+
getAll(props: getAllProps): Promise<Either<logErrors, getAllReturn<LogsEntity>>>;
|
|
7
|
+
searchOne(key: keyof LogsEntity, value: string): Promise<Either<logErrors, LogsEntity>>;
|
|
8
|
+
}
|
|
9
|
+
type logErrors = "";
|
|
10
|
+
export {};
|
package/dist/interfaces/ILog.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Button } from "../elements/button";
|
|
2
|
-
import { List } from "../elements/list";
|
|
3
|
-
import { Text } from "../elements/text";
|
|
4
|
-
export interface IMessage {
|
|
5
|
-
text: Text;
|
|
6
|
-
button: typeof Button;
|
|
7
|
-
list: List;
|
|
8
|
-
}
|
|
9
|
-
export interface ISendMessageReturn {
|
|
10
|
-
messaging_product: "whatsapp";
|
|
11
|
-
contacts: [
|
|
12
|
-
{
|
|
13
|
-
input: string;
|
|
14
|
-
wa_id: string;
|
|
15
|
-
}
|
|
16
|
-
];
|
|
17
|
-
messages: [
|
|
18
|
-
{
|
|
19
|
-
id: string;
|
|
20
|
-
}
|
|
21
|
-
];
|
|
22
|
-
}
|
|
1
|
+
import { Button } from "../elements/button";
|
|
2
|
+
import { List } from "../elements/list";
|
|
3
|
+
import { Text } from "../elements/text";
|
|
4
|
+
export interface IMessage {
|
|
5
|
+
text: Text;
|
|
6
|
+
button: typeof Button;
|
|
7
|
+
list: List;
|
|
8
|
+
}
|
|
9
|
+
export interface ISendMessageReturn {
|
|
10
|
+
messaging_product: "whatsapp";
|
|
11
|
+
contacts: [
|
|
12
|
+
{
|
|
13
|
+
input: string;
|
|
14
|
+
wa_id: string;
|
|
15
|
+
}
|
|
16
|
+
];
|
|
17
|
+
messages: [
|
|
18
|
+
{
|
|
19
|
+
id: string;
|
|
20
|
+
}
|
|
21
|
+
];
|
|
22
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Response } from "../Errors/ErrorHandling";
|
|
2
|
-
import { Connection, Log, Message, Webhook } from "../useCases";
|
|
3
|
-
import { Express } from "express";
|
|
4
|
-
export interface ISdk {
|
|
5
|
-
connect({ appToken, }: ConnectProps): Promise<Response<ConnectErrors, boolean>>;
|
|
6
|
-
Connection: typeof Connection;
|
|
7
|
-
Message: typeof Message;
|
|
8
|
-
Webhook: typeof Webhook;
|
|
9
|
-
Log: typeof Log;
|
|
10
|
-
}
|
|
11
|
-
export type ConnectProps = {
|
|
12
|
-
appToken: string;
|
|
13
|
-
pathname?: string;
|
|
14
|
-
app?: Express;
|
|
15
|
-
};
|
|
16
|
-
export type ConnectErrors = "AppToken inválido";
|
|
1
|
+
import { Response } from "../Errors/ErrorHandling";
|
|
2
|
+
import { Connection, Log, Message, Webhook } from "../useCases";
|
|
3
|
+
import { Express } from "express";
|
|
4
|
+
export interface ISdk {
|
|
5
|
+
connect({ appToken, }: ConnectProps): Promise<Response<ConnectErrors, boolean>>;
|
|
6
|
+
Connection: typeof Connection;
|
|
7
|
+
Message: typeof Message;
|
|
8
|
+
Webhook: typeof Webhook;
|
|
9
|
+
Log: typeof Log;
|
|
10
|
+
}
|
|
11
|
+
export type ConnectProps = {
|
|
12
|
+
appToken: string;
|
|
13
|
+
pathname?: string;
|
|
14
|
+
app?: Express;
|
|
15
|
+
};
|
|
16
|
+
export type ConnectErrors = "AppToken inválido";
|
package/dist/interfaces/ISdk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { WebhooksEntity } from "../Entities/webhooks";
|
|
2
|
-
import { Either } from "../Errors";
|
|
3
|
-
import { getAllProps, getAllReturn } from "../types/requestTypes";
|
|
4
|
-
export interface IWebhook {
|
|
5
|
-
insert(webhook: Partial<WebhooksEntity>): Promise<Either<webhookErrors, WebhooksEntity>>;
|
|
6
|
-
getSingle(id: string): Promise<Either<webhookErrors, WebhooksEntity>>;
|
|
7
|
-
searchOne(key: string, value: string): Promise<Either<webhookErrors, WebhooksEntity>>;
|
|
8
|
-
getAll(props: getAllProps): Promise<Either<webhookErrors, getAllReturn<WebhooksEntity>>>;
|
|
9
|
-
update(id: string, connection: Partial<WebhooksEntity>): Promise<Either<webhookErrors, WebhooksEntity>>;
|
|
10
|
-
updateMany(connection: Partial<WebhooksEntity>[]): Promise<Either<webhookErrors, WebhooksEntity[]>>;
|
|
11
|
-
deleteOne(id: string): Promise<Either<webhookErrors, WebhooksEntity>>;
|
|
12
|
-
}
|
|
13
|
-
type webhookErrors = "";
|
|
14
|
-
export {};
|
|
1
|
+
import { WebhooksEntity } from "../Entities/webhooks";
|
|
2
|
+
import { Either } from "../Errors";
|
|
3
|
+
import { getAllProps, getAllReturn } from "../types/requestTypes";
|
|
4
|
+
export interface IWebhook {
|
|
5
|
+
insert(webhook: Partial<WebhooksEntity>): Promise<Either<webhookErrors, WebhooksEntity>>;
|
|
6
|
+
getSingle(id: string): Promise<Either<webhookErrors, WebhooksEntity>>;
|
|
7
|
+
searchOne(key: string, value: string): Promise<Either<webhookErrors, WebhooksEntity>>;
|
|
8
|
+
getAll(props: getAllProps): Promise<Either<webhookErrors, getAllReturn<WebhooksEntity>>>;
|
|
9
|
+
update(id: string, connection: Partial<WebhooksEntity>): Promise<Either<webhookErrors, WebhooksEntity>>;
|
|
10
|
+
updateMany(connection: Partial<WebhooksEntity>[]): Promise<Either<webhookErrors, WebhooksEntity[]>>;
|
|
11
|
+
deleteOne(id: string): Promise<Either<webhookErrors, WebhooksEntity>>;
|
|
12
|
+
}
|
|
13
|
+
type webhookErrors = "";
|
|
14
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./IConnection";
|
|
2
|
-
export * from "./IWebhook";
|
|
3
|
-
export * from "./IMessage";
|
|
4
|
-
export * from "./ILog";
|
|
5
|
-
export * from "./ISdk";
|
|
1
|
+
export * from "./IConnection";
|
|
2
|
+
export * from "./IWebhook";
|
|
3
|
+
export * from "./IMessage";
|
|
4
|
+
export * from "./ILog";
|
|
5
|
+
export * from "./ISdk";
|
package/dist/interfaces/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./IConnection"), exports);
|
|
18
|
-
__exportStar(require("./IWebhook"), exports);
|
|
19
|
-
__exportStar(require("./IMessage"), exports);
|
|
20
|
-
__exportStar(require("./ILog"), exports);
|
|
21
|
-
__exportStar(require("./ISdk"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./IConnection"), exports);
|
|
18
|
+
__exportStar(require("./IWebhook"), exports);
|
|
19
|
+
__exportStar(require("./IMessage"), exports);
|
|
20
|
+
__exportStar(require("./ILog"), exports);
|
|
21
|
+
__exportStar(require("./ISdk"), exports);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { WhatsappMessage } from "../Entities/whatsappMessage";
|
|
2
|
-
export declare class MessageQueue {
|
|
3
|
-
private queueItems;
|
|
4
|
-
constructor();
|
|
5
|
-
addQueueItemForTopic(queueItem: IMessageQueueItem, topic: string): void;
|
|
6
|
-
processSingleItemForQueueTopic(topic: string, itemId: string): void;
|
|
7
|
-
}
|
|
8
|
-
export interface IMessageQueueItem {
|
|
9
|
-
id: string;
|
|
10
|
-
value: WhatsappMessage;
|
|
11
|
-
}
|
|
1
|
+
import { WhatsappMessage } from "../Entities/whatsappMessage";
|
|
2
|
+
export declare class MessageQueue {
|
|
3
|
+
private queueItems;
|
|
4
|
+
constructor();
|
|
5
|
+
addQueueItemForTopic(queueItem: IMessageQueueItem, topic: string): void;
|
|
6
|
+
processSingleItemForQueueTopic(topic: string, itemId: string): void;
|
|
7
|
+
}
|
|
8
|
+
export interface IMessageQueueItem {
|
|
9
|
+
id: string;
|
|
10
|
+
value: WhatsappMessage;
|
|
11
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageQueue = void 0;
|
|
4
|
-
class MessageQueue {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.queueItems = {};
|
|
7
|
-
}
|
|
8
|
-
addQueueItemForTopic(queueItem, topic) {
|
|
9
|
-
if (this.queueItems[topic] === undefined) {
|
|
10
|
-
this.queueItems[topic] = [queueItem];
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
this.queueItems[topic].push(queueItem);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
processSingleItemForQueueTopic(topic, itemId) {
|
|
17
|
-
this.queueItems[topic] = this.queueItems[topic].filter((item) => item.id !== itemId);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.MessageQueue = MessageQueue;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageQueue = void 0;
|
|
4
|
+
class MessageQueue {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.queueItems = {};
|
|
7
|
+
}
|
|
8
|
+
addQueueItemForTopic(queueItem, topic) {
|
|
9
|
+
if (this.queueItems[topic] === undefined) {
|
|
10
|
+
this.queueItems[topic] = [queueItem];
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
this.queueItems[topic].push(queueItem);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
processSingleItemForQueueTopic(topic, itemId) {
|
|
17
|
+
this.queueItems[topic] = this.queueItems[topic].filter((item) => item.id !== itemId);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.MessageQueue = MessageQueue;
|
package/dist/routes/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Router } from "express";
|
|
2
|
-
import { NatyMeta } from "../useCases";
|
|
3
|
-
export declare const principalRoute: (naty: NatyMeta) => Router;
|
|
1
|
+
import { Router } from "express";
|
|
2
|
+
import { NatyMeta } from "../useCases";
|
|
3
|
+
export declare const principalRoute: (naty: NatyMeta) => Router;
|
package/dist/routes/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.principalRoute = void 0;
|
|
4
|
-
const express_1 = require("express");
|
|
5
|
-
const webhooks_1 = require("./webhooks");
|
|
6
|
-
const principalRoute = (naty) => {
|
|
7
|
-
const router = (0, express_1.Router)();
|
|
8
|
-
router.use("/webhooks", (0, webhooks_1.webhooksRouter)(naty));
|
|
9
|
-
return router;
|
|
10
|
-
};
|
|
11
|
-
exports.principalRoute = principalRoute;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.principalRoute = void 0;
|
|
4
|
+
const express_1 = require("express");
|
|
5
|
+
const webhooks_1 = require("./webhooks");
|
|
6
|
+
const principalRoute = (naty) => {
|
|
7
|
+
const router = (0, express_1.Router)();
|
|
8
|
+
router.use("/webhooks", (0, webhooks_1.webhooksRouter)(naty));
|
|
9
|
+
return router;
|
|
10
|
+
};
|
|
11
|
+
exports.principalRoute = principalRoute;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Router } from "express";
|
|
2
|
-
import { NatyMeta } from "../../useCases";
|
|
3
|
-
export declare const webhooksRouter: (events: NatyMeta) => Router;
|
|
1
|
+
import { Router } from "express";
|
|
2
|
+
import { NatyMeta } from "../../useCases";
|
|
3
|
+
export declare const webhooksRouter: (events: NatyMeta) => Router;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.webhooksRouter = void 0;
|
|
4
|
-
const express_1 = require("express");
|
|
5
|
-
const messages_1 = require("./methods/messages");
|
|
6
|
-
const connection_1 = require("./methods/connection");
|
|
7
|
-
const webhooksRouter = (events) => {
|
|
8
|
-
const router = (0, express_1.Router)();
|
|
9
|
-
router.use("/messages", (0, messages_1.messagesRouter)(events));
|
|
10
|
-
router.use("/connections", (0, connection_1.connectionRouter)(events));
|
|
11
|
-
return router;
|
|
12
|
-
};
|
|
13
|
-
exports.webhooksRouter = webhooksRouter;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.webhooksRouter = void 0;
|
|
4
|
+
const express_1 = require("express");
|
|
5
|
+
const messages_1 = require("./methods/messages");
|
|
6
|
+
const connection_1 = require("./methods/connection");
|
|
7
|
+
const webhooksRouter = (events) => {
|
|
8
|
+
const router = (0, express_1.Router)();
|
|
9
|
+
router.use("/messages", (0, messages_1.messagesRouter)(events));
|
|
10
|
+
router.use("/connections", (0, connection_1.connectionRouter)(events));
|
|
11
|
+
return router;
|
|
12
|
+
};
|
|
13
|
+
exports.webhooksRouter = webhooksRouter;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Router } from "express";
|
|
2
|
-
import { NatyMeta } from "../../../useCases";
|
|
3
|
-
export declare const connectionRouter: (naty: NatyMeta) => Router;
|
|
1
|
+
import { Router } from "express";
|
|
2
|
+
import { NatyMeta } from "../../../useCases";
|
|
3
|
+
export declare const connectionRouter: (naty: NatyMeta) => Router;
|
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.connectionRouter = void 0;
|
|
4
|
-
const express_1 = require("express");
|
|
5
|
-
const whatsappResponse_1 = require("../../../useCases/message/whatsappResponse");
|
|
6
|
-
const services_1 = require("../../../services");
|
|
7
|
-
const connectionRouter = (naty) => {
|
|
8
|
-
const router = (0, express_1.Router)();
|
|
9
|
-
router.post("/", async (req, res) => {
|
|
10
|
-
var _a;
|
|
11
|
-
const { companyId, message, data } = req.body;
|
|
12
|
-
let dataReturn = {
|
|
13
|
-
companyId,
|
|
14
|
-
message: message,
|
|
15
|
-
data,
|
|
16
|
-
};
|
|
17
|
-
if (message === "confirm_connection") {
|
|
18
|
-
try {
|
|
19
|
-
const connectionId = (_a = data["hub.verify_token"]) === null || _a === void 0 ? void 0 : _a.split("/")[0];
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
throw new Error("Não foi possível encontrar
|
|
23
|
-
|
|
24
|
-
if (!
|
|
25
|
-
throw new Error("
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.connectionRouter = void 0;
|
|
4
|
+
const express_1 = require("express");
|
|
5
|
+
const whatsappResponse_1 = require("../../../useCases/message/whatsappResponse");
|
|
6
|
+
const services_1 = require("../../../services");
|
|
7
|
+
const connectionRouter = (naty) => {
|
|
8
|
+
const router = (0, express_1.Router)();
|
|
9
|
+
router.post("/", async (req, res) => {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const { companyId, message, data } = req.body;
|
|
12
|
+
let dataReturn = {
|
|
13
|
+
companyId,
|
|
14
|
+
message: message,
|
|
15
|
+
data,
|
|
16
|
+
};
|
|
17
|
+
if (message === "confirm_connection") {
|
|
18
|
+
try {
|
|
19
|
+
const connectionId = (_a = (data["hub.verify_token"] || data["verify_token"])) === null || _a === void 0 ? void 0 : _a.split("/")[0];
|
|
20
|
+
const getConnections = await services_1.connectionMutations.getAll({ page: 0, size: 1000 });
|
|
21
|
+
if (getConnections.isError)
|
|
22
|
+
throw new Error("Não foi possível encontrar a instância");
|
|
23
|
+
const connectionInfo = (_b = getConnections.isSuccess) === null || _b === void 0 ? void 0 : _b.find(item => item._id === connectionId);
|
|
24
|
+
if (!connectionInfo)
|
|
25
|
+
throw new Error("Não foi possível encontrar Connection");
|
|
26
|
+
dataReturn.connection = connectionInfo;
|
|
27
|
+
const whatsAppResponse = new whatsappResponse_1.WhatsappResponse(companyId, connectionInfo.phoneNumberId);
|
|
28
|
+
const accountInfo = await whatsAppResponse.get_account_info();
|
|
29
|
+
if (!accountInfo)
|
|
30
|
+
throw new Error("Não foi possível encontrar Account");
|
|
31
|
+
dataReturn.accountInfo = accountInfo;
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
console.log(err);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
naty.emit("connection", dataReturn);
|
|
38
|
+
res.json({ connection: req.body });
|
|
39
|
+
});
|
|
40
|
+
return router;
|
|
41
|
+
};
|
|
42
|
+
exports.connectionRouter = connectionRouter;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Router } from "express";
|
|
2
|
-
import { NatyMeta } from "../../../useCases";
|
|
3
|
-
export declare const messagesRouter: (naty: NatyMeta) => Router;
|
|
1
|
+
import { Router } from "express";
|
|
2
|
+
import { NatyMeta } from "../../../useCases";
|
|
3
|
+
export declare const messagesRouter: (naty: NatyMeta) => Router;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.messagesRouter = void 0;
|
|
4
|
-
const express_1 = require("express");
|
|
5
|
-
// import db from "../../mock/response.json";
|
|
6
|
-
const whatsappMessage_1 = require("../../../Entities/whatsappMessage");
|
|
7
|
-
const whatsappResponse_1 = require("../../../useCases/message/whatsappResponse");
|
|
8
|
-
const messagesRouter = (naty) => {
|
|
9
|
-
const router = (0, express_1.Router)();
|
|
10
|
-
router.post("/", (req, res) => {
|
|
11
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
12
|
-
const { companyId, data } = req.body;
|
|
13
|
-
// console.log({ messageValue });
|
|
14
|
-
const phone_number_id = (_c = (_b = (_a = data.entry[0]) === null || _a === void 0 ? void 0 : _a.changes[0]) === null || _b === void 0 ? void 0 : _b.value.metadata) === null || _c === void 0 ? void 0 : _c.phone_number_id;
|
|
15
|
-
const clientNumber = (_g = (_f = (_e = (_d = data.entry[0]) === null || _d === void 0 ? void 0 : _d.changes[0]) === null || _e === void 0 ? void 0 : _e.value) === null || _f === void 0 ? void 0 : _f.contacts[0]) === null || _g === void 0 ? void 0 : _g.wa_id;
|
|
16
|
-
naty.emit("message", new whatsappResponse_1.WhatsappResponse(companyId, phone_number_id, clientNumber, new whatsappMessage_1.WhatsappMessage(data)));
|
|
17
|
-
res.json(true);
|
|
18
|
-
});
|
|
19
|
-
return router;
|
|
20
|
-
};
|
|
21
|
-
exports.messagesRouter = messagesRouter;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.messagesRouter = void 0;
|
|
4
|
+
const express_1 = require("express");
|
|
5
|
+
// import db from "../../mock/response.json";
|
|
6
|
+
const whatsappMessage_1 = require("../../../Entities/whatsappMessage");
|
|
7
|
+
const whatsappResponse_1 = require("../../../useCases/message/whatsappResponse");
|
|
8
|
+
const messagesRouter = (naty) => {
|
|
9
|
+
const router = (0, express_1.Router)();
|
|
10
|
+
router.post("/", (req, res) => {
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
12
|
+
const { companyId, data } = req.body;
|
|
13
|
+
// console.log({ messageValue });
|
|
14
|
+
const phone_number_id = (_c = (_b = (_a = data.entry[0]) === null || _a === void 0 ? void 0 : _a.changes[0]) === null || _b === void 0 ? void 0 : _b.value.metadata) === null || _c === void 0 ? void 0 : _c.phone_number_id;
|
|
15
|
+
const clientNumber = (_g = (_f = (_e = (_d = data.entry[0]) === null || _d === void 0 ? void 0 : _d.changes[0]) === null || _e === void 0 ? void 0 : _e.value) === null || _f === void 0 ? void 0 : _f.contacts[0]) === null || _g === void 0 ? void 0 : _g.wa_id;
|
|
16
|
+
naty.emit("message", new whatsappResponse_1.WhatsappResponse(companyId, phone_number_id, clientNumber, new whatsappMessage_1.WhatsappMessage(data)));
|
|
17
|
+
res.json(true);
|
|
18
|
+
});
|
|
19
|
+
return router;
|
|
20
|
+
};
|
|
21
|
+
exports.messagesRouter = messagesRouter;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export declare const newAxiosInstance: ({ url, phone_number_id, accessToken, }: {
|
|
2
|
-
url?: string | undefined;
|
|
3
|
-
phone_number_id?: string | undefined;
|
|
4
|
-
accessToken: string;
|
|
5
|
-
}) => import("axios").AxiosInstance;
|
|
6
|
-
export declare const axiosInstanceForDownloadMedia: ({ url, accessToken, }: {
|
|
7
|
-
url?: string | undefined;
|
|
8
|
-
accessToken: string;
|
|
9
|
-
}) => import("axios").AxiosInstance;
|
|
10
|
-
export declare const axiosInstanceGeneral: ({ url, accessToken, }: {
|
|
11
|
-
url?: string | undefined;
|
|
12
|
-
accessToken: string;
|
|
13
|
-
}) => import("axios").AxiosInstance;
|
|
14
|
-
declare const api: import("axios").AxiosInstance;
|
|
15
|
-
export { api };
|
|
16
|
-
export declare const updateInterceptor: (interceptors: {
|
|
17
|
-
[key: string]: string;
|
|
18
|
-
}, callback?: ((bool: boolean) => void) | undefined) => Promise<number>;
|
|
1
|
+
export declare const newAxiosInstance: ({ url, phone_number_id, accessToken, }: {
|
|
2
|
+
url?: string | undefined;
|
|
3
|
+
phone_number_id?: string | undefined;
|
|
4
|
+
accessToken: string;
|
|
5
|
+
}) => import("axios").AxiosInstance;
|
|
6
|
+
export declare const axiosInstanceForDownloadMedia: ({ url, accessToken, }: {
|
|
7
|
+
url?: string | undefined;
|
|
8
|
+
accessToken: string;
|
|
9
|
+
}) => import("axios").AxiosInstance;
|
|
10
|
+
export declare const axiosInstanceGeneral: ({ url, accessToken, }: {
|
|
11
|
+
url?: string | undefined;
|
|
12
|
+
accessToken: string;
|
|
13
|
+
}) => import("axios").AxiosInstance;
|
|
14
|
+
declare const api: import("axios").AxiosInstance;
|
|
15
|
+
export { api };
|
|
16
|
+
export declare const updateInterceptor: (interceptors: {
|
|
17
|
+
[key: string]: string;
|
|
18
|
+
}, callback?: ((bool: boolean) => void) | undefined) => Promise<number>;
|