@in.pulse-crm/sdk 2.4.7 → 2.4.8
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/.prettierrc +4 -4
- package/dist/files.client.d.ts +0 -2
- package/dist/types/files.types.d.ts +0 -2
- package/dist/types/internal.types.d.ts +109 -0
- package/dist/types/internal.types.js +16 -0
- package/dist/types/socket-events.types.d.ts +31 -1
- package/dist/types/socket-events.types.js +4 -0
- package/package.json +1 -1
- package/src/internal.client.ts +44 -0
- package/src/types/internal.types.ts +137 -0
- package/src/types/socket-events.types.ts +104 -49
- package/src/types/socket-rooms.types.ts +1 -0
- package/tsconfig.json +16 -16
package/.prettierrc
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tabWidth": 4,
|
|
3
|
-
"useTabs": true
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"tabWidth": 4,
|
|
3
|
+
"useTabs": true
|
|
4
|
+
}
|
package/dist/files.client.d.ts
CHANGED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Customer } from "./customers.types";
|
|
2
|
+
export interface InternalContact {
|
|
3
|
+
id: number;
|
|
4
|
+
name: string;
|
|
5
|
+
phone: string;
|
|
6
|
+
userId?: number;
|
|
7
|
+
instance: string;
|
|
8
|
+
isDeleted: boolean;
|
|
9
|
+
isBlocked: boolean;
|
|
10
|
+
isOnlyAdmin: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface InternalMessage {
|
|
13
|
+
id: number;
|
|
14
|
+
instance: string;
|
|
15
|
+
from: string;
|
|
16
|
+
to: string;
|
|
17
|
+
type: string;
|
|
18
|
+
quotedId?: number | null;
|
|
19
|
+
internalchatId?: number | null;
|
|
20
|
+
internalcontactId?: number | null;
|
|
21
|
+
body: string;
|
|
22
|
+
timestamp: string;
|
|
23
|
+
status: WppMessageStatus;
|
|
24
|
+
fileId?: number | null;
|
|
25
|
+
fileName?: string | null;
|
|
26
|
+
fileType?: string | null;
|
|
27
|
+
fileSize?: string | null;
|
|
28
|
+
}
|
|
29
|
+
export interface InternalChat {
|
|
30
|
+
id: number;
|
|
31
|
+
instance: string;
|
|
32
|
+
internalcontactId?: number | null;
|
|
33
|
+
userId?: number | null;
|
|
34
|
+
sectorId?: number | null;
|
|
35
|
+
avatarUrl?: string | null;
|
|
36
|
+
isFinished: boolean;
|
|
37
|
+
startedAt?: string | null;
|
|
38
|
+
finishedAt?: string | null;
|
|
39
|
+
finishedBy?: number | null;
|
|
40
|
+
isGroup: boolean;
|
|
41
|
+
groupName?: string | null;
|
|
42
|
+
groupDescription?: string | null;
|
|
43
|
+
groupCreatedBy?: number | null;
|
|
44
|
+
groupCreatedAt?: string | null;
|
|
45
|
+
}
|
|
46
|
+
export interface InternalChatMember {
|
|
47
|
+
internalchatId: number;
|
|
48
|
+
internalcontactId: number;
|
|
49
|
+
joinedAt: string;
|
|
50
|
+
lastReadAt?: string | null;
|
|
51
|
+
}
|
|
52
|
+
export interface InternalChatTag {
|
|
53
|
+
internalchatId: number;
|
|
54
|
+
tagId: number;
|
|
55
|
+
}
|
|
56
|
+
export interface WppContactWithCustomer {
|
|
57
|
+
id: number;
|
|
58
|
+
name: string;
|
|
59
|
+
phone: string;
|
|
60
|
+
customerId?: number;
|
|
61
|
+
instance: string;
|
|
62
|
+
isBlocked: boolean;
|
|
63
|
+
isOnlyAdmin: boolean;
|
|
64
|
+
customer: Customer | null;
|
|
65
|
+
chatingWith: string | null;
|
|
66
|
+
}
|
|
67
|
+
export interface WppSector {
|
|
68
|
+
id: number;
|
|
69
|
+
name: string;
|
|
70
|
+
instanceName: string;
|
|
71
|
+
wppInstanceId?: number;
|
|
72
|
+
startChats: boolean;
|
|
73
|
+
receiveChats: boolean;
|
|
74
|
+
}
|
|
75
|
+
export type WppMessageStatus = "PENDING" | "SENT" | "RECEIVED" | "READ" | "DOWNLOADED" | "ERROR" | "REVOKED";
|
|
76
|
+
export type InternalMessageStatus = "PENDING" | "SENT" | "RECEIVED" | "READ" | "DOWNLOADED" | "ERROR" | "REVOKED";
|
|
77
|
+
export declare enum WppChatType {
|
|
78
|
+
RECEPTIVE = "RECEPTIVE",
|
|
79
|
+
ACTIVE = "ACTIVE"
|
|
80
|
+
}
|
|
81
|
+
export declare enum WppChatPriority {
|
|
82
|
+
LOW = "LOW",
|
|
83
|
+
NORMAL = "NORMAL",
|
|
84
|
+
HIGH = "HIGH",
|
|
85
|
+
VERY_HIGH = "VERY_HIGH",
|
|
86
|
+
URGENCY = "URGENCY"
|
|
87
|
+
}
|
|
88
|
+
export type InternalChatWithDetails = InternalChat & {
|
|
89
|
+
contact: InternalContact | null;
|
|
90
|
+
customer: Customer | null;
|
|
91
|
+
};
|
|
92
|
+
export type InternalChatsAndMessages = {
|
|
93
|
+
chats: InternalChatWithDetails[];
|
|
94
|
+
messages: InternalMessage[];
|
|
95
|
+
};
|
|
96
|
+
export type InternalChatWithDetailsAndMessages = InternalChatWithDetails & {
|
|
97
|
+
messages: InternalMessage[];
|
|
98
|
+
};
|
|
99
|
+
export interface SendMessageData {
|
|
100
|
+
sendAsChatOwner?: boolean;
|
|
101
|
+
sendAsAudio?: boolean;
|
|
102
|
+
sendAsDocument?: boolean;
|
|
103
|
+
contactId: number;
|
|
104
|
+
quotedId?: number | null;
|
|
105
|
+
chatId?: number | null;
|
|
106
|
+
text?: string | null;
|
|
107
|
+
file?: File;
|
|
108
|
+
fileId?: number;
|
|
109
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WppChatPriority = exports.WppChatType = void 0;
|
|
4
|
+
var WppChatType;
|
|
5
|
+
(function (WppChatType) {
|
|
6
|
+
WppChatType["RECEPTIVE"] = "RECEPTIVE";
|
|
7
|
+
WppChatType["ACTIVE"] = "ACTIVE";
|
|
8
|
+
})(WppChatType || (exports.WppChatType = WppChatType = {}));
|
|
9
|
+
var WppChatPriority;
|
|
10
|
+
(function (WppChatPriority) {
|
|
11
|
+
WppChatPriority["LOW"] = "LOW";
|
|
12
|
+
WppChatPriority["NORMAL"] = "NORMAL";
|
|
13
|
+
WppChatPriority["HIGH"] = "HIGH";
|
|
14
|
+
WppChatPriority["VERY_HIGH"] = "VERY_HIGH";
|
|
15
|
+
WppChatPriority["URGENCY"] = "URGENCY";
|
|
16
|
+
})(WppChatPriority || (exports.WppChatPriority = WppChatPriority = {}));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SocketServerAdminRoom, SocketServerChatRoom, SocketServerReportsRoom, SocketServerRoom } from "./socket-rooms.types";
|
|
2
2
|
import { MessageResponse } from "./response.types";
|
|
3
3
|
import { WppMessage, WppMessageStatus } from "./whatsapp.types";
|
|
4
|
+
import { InternalMessage, InternalMessageStatus } from "./internal.types";
|
|
4
5
|
export declare enum SocketEventType {
|
|
5
6
|
WppChatStarted = "wpp_chat_started",
|
|
6
7
|
WppChatFinished = "wpp_chat_finished",
|
|
@@ -10,7 +11,11 @@ export declare enum SocketEventType {
|
|
|
10
11
|
WppContactMessagesRead = "wpp_contact_messages_read",
|
|
11
12
|
WwebjsQr = "wwebjs_qr",
|
|
12
13
|
WwebjsAuth = "wwebjs_auth",
|
|
13
|
-
ReportStatus = "report_status"
|
|
14
|
+
ReportStatus = "report_status",
|
|
15
|
+
InternalChatStarted = "internal_chat_started",
|
|
16
|
+
InternalChatFinished = "internal_chat_finished",
|
|
17
|
+
InternalMessageStatus = "internal_chat_status",
|
|
18
|
+
InternalMessage = "internal_message"
|
|
14
19
|
}
|
|
15
20
|
export interface EmitSocketEventFn {
|
|
16
21
|
(type: SocketEventType.WwebjsQr, room: SocketServerAdminRoom, data: WWEBJSQrEventData): Promise<MessageResponse>;
|
|
@@ -22,6 +27,10 @@ export interface EmitSocketEventFn {
|
|
|
22
27
|
(type: SocketEventType.WppContactMessagesRead, room: SocketServerChatRoom, data: WppContactMessagesReadEventData): Promise<MessageResponse>;
|
|
23
28
|
(type: SocketEventType.WppMessageReaction, room: SocketServerChatRoom, data: WppMessageReactionEventData): Promise<MessageResponse>;
|
|
24
29
|
(type: SocketEventType.ReportStatus, room: SocketServerReportsRoom, data: ReportStatusEventData): Promise<MessageResponse>;
|
|
30
|
+
(type: SocketEventType.InternalMessage, room: SocketServerChatRoom, data: InternalMessageEventData): Promise<MessageResponse>;
|
|
31
|
+
(type: SocketEventType.InternalMessageStatus, room: SocketServerChatRoom, data: InternalMessageEventData): Promise<MessageResponse>;
|
|
32
|
+
(type: SocketEventType.InternalChatStarted, room: SocketServerRoom, data: InternalChatStartedEventData): Promise<MessageResponse>;
|
|
33
|
+
(type: SocketEventType.InternalChatFinished, room: SocketServerRoom, data: InternalChatFinishedEventData): Promise<MessageResponse>;
|
|
25
34
|
}
|
|
26
35
|
export interface ListenSocketEventFn {
|
|
27
36
|
(type: SocketEventType.WwebjsQr, callback: (data: WWEBJSQrEventData) => void): void;
|
|
@@ -33,6 +42,10 @@ export interface ListenSocketEventFn {
|
|
|
33
42
|
(type: SocketEventType.WppContactMessagesRead, callback: (data: WppContactMessagesReadEventData) => void): void;
|
|
34
43
|
(type: SocketEventType.WppMessageReaction, callback: (data: WppMessageReactionEventData) => void): void;
|
|
35
44
|
(type: SocketEventType.ReportStatus, callback: (data: ReportStatusEventData) => void): void;
|
|
45
|
+
(type: SocketEventType.InternalChatStarted, callback: (data: InternalChatStartedEventData) => void): void;
|
|
46
|
+
(type: SocketEventType.InternalChatFinished, callback: (data: InternalChatFinishedEventData) => void): void;
|
|
47
|
+
(type: SocketEventType.InternalMessage, callback: (data: InternalMessageEventData) => void): void;
|
|
48
|
+
(type: SocketEventType.InternalMessageStatus, callback: (data: InternalMessageStatusEventData) => void): void;
|
|
36
49
|
}
|
|
37
50
|
export interface UnlistenSocketEventFn {
|
|
38
51
|
(type: SocketEventType): void;
|
|
@@ -67,6 +80,23 @@ export interface WppMessageReactionEventData {
|
|
|
67
80
|
messageId: number;
|
|
68
81
|
reaction: string;
|
|
69
82
|
}
|
|
83
|
+
export interface InternalChatStartedEventData {
|
|
84
|
+
chatId: number;
|
|
85
|
+
}
|
|
86
|
+
export interface InternalChatFinishedEventData {
|
|
87
|
+
chatId: number;
|
|
88
|
+
}
|
|
89
|
+
export interface InternalContactMessagesReadEventData {
|
|
90
|
+
contactId: number;
|
|
91
|
+
}
|
|
92
|
+
export interface InternalMessageEventData {
|
|
93
|
+
message: InternalMessage;
|
|
94
|
+
}
|
|
95
|
+
export interface InternalMessageStatusEventData {
|
|
96
|
+
messageId: number;
|
|
97
|
+
contactId: number;
|
|
98
|
+
status: InternalMessageStatus;
|
|
99
|
+
}
|
|
70
100
|
export type ReportStatusEventData = {
|
|
71
101
|
id: number;
|
|
72
102
|
type: string;
|
|
@@ -12,4 +12,8 @@ var SocketEventType;
|
|
|
12
12
|
SocketEventType["WwebjsQr"] = "wwebjs_qr";
|
|
13
13
|
SocketEventType["WwebjsAuth"] = "wwebjs_auth";
|
|
14
14
|
SocketEventType["ReportStatus"] = "report_status";
|
|
15
|
+
SocketEventType["InternalChatStarted"] = "internal_chat_started";
|
|
16
|
+
SocketEventType["InternalChatFinished"] = "internal_chat_finished";
|
|
17
|
+
SocketEventType["InternalMessageStatus"] = "internal_chat_status";
|
|
18
|
+
SocketEventType["InternalMessage"] = "internal_message";
|
|
15
19
|
})(SocketEventType || (exports.SocketEventType = SocketEventType = {}));
|
package/package.json
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import ApiClient from "./api-client";
|
|
2
|
+
import { DataResponse, MessageResponse } from "./types/response.types";
|
|
3
|
+
import { InternalChat, InternalMessage } from "./types/internal.types";
|
|
4
|
+
|
|
5
|
+
export default class InternalChatClient extends ApiClient {
|
|
6
|
+
public async getChatsForUser(userId: number, instance: string) {
|
|
7
|
+
const url = `/api/internal/chats?userId=${userId}&instance=${instance}`;
|
|
8
|
+
const { data: res } = await this.httpClient.get<DataResponse<InternalChat[]>>(url);
|
|
9
|
+
return res.data;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public async getChatById(id: number) {
|
|
13
|
+
const { data: res } = await this.httpClient.get<DataResponse<InternalChat>>(`/api/internal/chats/${id}`);
|
|
14
|
+
return res.data;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public async sendMessageToChat(chatId: number, userId: number, content: string) {
|
|
18
|
+
const { data: res } = await this.httpClient.post(`/api/internal/chats/${chatId}/messages?userId=${userId}`, {
|
|
19
|
+
content,
|
|
20
|
+
});
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public async createGroup(name: string, participantIds: number[], userId: number) {
|
|
25
|
+
const { data: res } = await this.httpClient.post<DataResponse<InternalChat>>(
|
|
26
|
+
`/api/internal/chats/group?userId=${userId}`,
|
|
27
|
+
{ name, participantIds }
|
|
28
|
+
);
|
|
29
|
+
return res.data;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public async updateGroupMembers(groupId: number, add: number[], remove: number[]) {
|
|
33
|
+
const { data: res } = await this.httpClient.put<DataResponse<any>>(
|
|
34
|
+
`/api/internal/chats/group/${groupId}/members`,
|
|
35
|
+
{ add, remove }
|
|
36
|
+
);
|
|
37
|
+
return res.data;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public setAuth(token: string) {
|
|
41
|
+
this.httpClient.defaults.headers.common["Authorization"] =
|
|
42
|
+
`Bearer ${token}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Customer } from "./customers.types";
|
|
2
|
+
|
|
3
|
+
export interface InternalContact {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
phone: string;
|
|
7
|
+
userId?: number;
|
|
8
|
+
instance: string;
|
|
9
|
+
isDeleted: boolean;
|
|
10
|
+
isBlocked: boolean;
|
|
11
|
+
isOnlyAdmin: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface InternalMessage {
|
|
15
|
+
id: number;
|
|
16
|
+
instance: string;
|
|
17
|
+
from: string;
|
|
18
|
+
to: string;
|
|
19
|
+
type: string;
|
|
20
|
+
quotedId?: number | null;
|
|
21
|
+
internalchatId?: number | null;
|
|
22
|
+
internalcontactId?: number | null;
|
|
23
|
+
body: string;
|
|
24
|
+
timestamp: string; // DateTime como ISO
|
|
25
|
+
status: WppMessageStatus;
|
|
26
|
+
fileId?: number | null;
|
|
27
|
+
fileName?: string | null;
|
|
28
|
+
fileType?: string | null;
|
|
29
|
+
fileSize?: string | null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface InternalChat {
|
|
33
|
+
id: number;
|
|
34
|
+
instance: string;
|
|
35
|
+
internalcontactId?: number | null;
|
|
36
|
+
userId?: number | null;
|
|
37
|
+
sectorId?: number | null;
|
|
38
|
+
avatarUrl?: string | null;
|
|
39
|
+
isFinished: boolean;
|
|
40
|
+
startedAt?: string | null;
|
|
41
|
+
finishedAt?: string | null;
|
|
42
|
+
finishedBy?: number | null;
|
|
43
|
+
isGroup: boolean;
|
|
44
|
+
groupName?: string | null;
|
|
45
|
+
groupDescription?: string | null;
|
|
46
|
+
groupCreatedBy?: number | null;
|
|
47
|
+
groupCreatedAt?: string | null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface InternalChatMember {
|
|
51
|
+
internalchatId: number;
|
|
52
|
+
internalcontactId: number;
|
|
53
|
+
joinedAt: string;
|
|
54
|
+
lastReadAt?: string | null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface InternalChatTag {
|
|
58
|
+
internalchatId: number;
|
|
59
|
+
tagId: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface WppContactWithCustomer {
|
|
63
|
+
id: number;
|
|
64
|
+
name: string;
|
|
65
|
+
phone: string;
|
|
66
|
+
customerId?: number;
|
|
67
|
+
instance: string;
|
|
68
|
+
isBlocked: boolean;
|
|
69
|
+
isOnlyAdmin: boolean;
|
|
70
|
+
customer: Customer | null;
|
|
71
|
+
chatingWith: string | null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface WppSector {
|
|
75
|
+
id: number;
|
|
76
|
+
name: string;
|
|
77
|
+
instanceName: string;
|
|
78
|
+
wppInstanceId?: number;
|
|
79
|
+
startChats: boolean;
|
|
80
|
+
receiveChats: boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Enums
|
|
84
|
+
export type WppMessageStatus =
|
|
85
|
+
| "PENDING"
|
|
86
|
+
| "SENT"
|
|
87
|
+
| "RECEIVED"
|
|
88
|
+
| "READ"
|
|
89
|
+
| "DOWNLOADED"
|
|
90
|
+
| "ERROR"
|
|
91
|
+
| "REVOKED";
|
|
92
|
+
|
|
93
|
+
export type InternalMessageStatus =
|
|
94
|
+
| "PENDING"
|
|
95
|
+
| "SENT"
|
|
96
|
+
| "RECEIVED"
|
|
97
|
+
| "READ"
|
|
98
|
+
| "DOWNLOADED"
|
|
99
|
+
| "ERROR"
|
|
100
|
+
| "REVOKED";
|
|
101
|
+
|
|
102
|
+
export enum WppChatType {
|
|
103
|
+
RECEPTIVE = "RECEPTIVE",
|
|
104
|
+
ACTIVE = "ACTIVE",
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export enum WppChatPriority {
|
|
108
|
+
LOW = "LOW",
|
|
109
|
+
NORMAL = "NORMAL",
|
|
110
|
+
HIGH = "HIGH",
|
|
111
|
+
VERY_HIGH = "VERY_HIGH",
|
|
112
|
+
URGENCY = "URGENCY",
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export type InternalChatWithDetails = InternalChat & {
|
|
116
|
+
contact: InternalContact | null;
|
|
117
|
+
customer: Customer | null;
|
|
118
|
+
};
|
|
119
|
+
export type InternalChatsAndMessages = {
|
|
120
|
+
chats: InternalChatWithDetails[];
|
|
121
|
+
messages: InternalMessage[];
|
|
122
|
+
};
|
|
123
|
+
export type InternalChatWithDetailsAndMessages = InternalChatWithDetails & {
|
|
124
|
+
messages: InternalMessage[];
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export interface SendMessageData {
|
|
128
|
+
sendAsChatOwner?: boolean;
|
|
129
|
+
sendAsAudio?: boolean;
|
|
130
|
+
sendAsDocument?: boolean;
|
|
131
|
+
contactId: number;
|
|
132
|
+
quotedId?: number | null;
|
|
133
|
+
chatId?: number | null;
|
|
134
|
+
text?: string | null;
|
|
135
|
+
file?: File;
|
|
136
|
+
fileId?: number;
|
|
137
|
+
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from "./socket-rooms.types";
|
|
7
7
|
import { MessageResponse } from "./response.types";
|
|
8
8
|
import { WppMessage, WppMessageStatus } from "./whatsapp.types";
|
|
9
|
+
import { InternalMessage, InternalMessageStatus } from "./internal.types";
|
|
9
10
|
|
|
10
11
|
export enum SocketEventType {
|
|
11
12
|
WppChatStarted = "wpp_chat_started",
|
|
@@ -17,92 +18,132 @@ export enum SocketEventType {
|
|
|
17
18
|
WwebjsQr = "wwebjs_qr",
|
|
18
19
|
WwebjsAuth = "wwebjs_auth",
|
|
19
20
|
ReportStatus = "report_status",
|
|
21
|
+
InternalChatStarted = "internal_chat_started",
|
|
22
|
+
InternalChatFinished = "internal_chat_finished",
|
|
23
|
+
InternalMessageStatus = "internal_chat_status",
|
|
24
|
+
InternalMessage = "internal_message",
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
export interface EmitSocketEventFn {
|
|
23
28
|
(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
type: SocketEventType.WwebjsQr,
|
|
30
|
+
room: SocketServerAdminRoom,
|
|
31
|
+
data: WWEBJSQrEventData,
|
|
27
32
|
): Promise<MessageResponse>;
|
|
28
33
|
(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
type: SocketEventType.WwebjsAuth,
|
|
35
|
+
room: SocketServerAdminRoom,
|
|
36
|
+
data: WWEBJSAuthEventData,
|
|
32
37
|
): Promise<MessageResponse>;
|
|
33
38
|
(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
type: SocketEventType.WppChatStarted,
|
|
40
|
+
room: SocketServerRoom,
|
|
41
|
+
data: WppChatStartedEventData,
|
|
37
42
|
): Promise<MessageResponse>;
|
|
38
43
|
(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
type: SocketEventType.WppChatFinished,
|
|
45
|
+
room: SocketServerRoom,
|
|
46
|
+
data: WppChatFinishedEventData,
|
|
42
47
|
): Promise<MessageResponse>;
|
|
43
48
|
(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
type: SocketEventType.WppMessage,
|
|
50
|
+
room: SocketServerChatRoom,
|
|
51
|
+
data: WppMessageEventData,
|
|
47
52
|
): Promise<MessageResponse>;
|
|
48
53
|
(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
type: SocketEventType.WppMessageStatus,
|
|
55
|
+
room: SocketServerChatRoom,
|
|
56
|
+
data: WppMessageStatusEventData,
|
|
52
57
|
): Promise<MessageResponse>;
|
|
53
58
|
(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
type: SocketEventType.WppContactMessagesRead,
|
|
60
|
+
room: SocketServerChatRoom,
|
|
61
|
+
data: WppContactMessagesReadEventData,
|
|
57
62
|
): Promise<MessageResponse>;
|
|
58
63
|
(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
type: SocketEventType.WppMessageReaction,
|
|
65
|
+
room: SocketServerChatRoom,
|
|
66
|
+
data: WppMessageReactionEventData,
|
|
62
67
|
): Promise<MessageResponse>;
|
|
63
68
|
(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
type: SocketEventType.ReportStatus,
|
|
70
|
+
room: SocketServerReportsRoom,
|
|
71
|
+
data: ReportStatusEventData,
|
|
72
|
+
): Promise<MessageResponse>;
|
|
73
|
+
(
|
|
74
|
+
type: SocketEventType.InternalMessage,
|
|
75
|
+
room: SocketServerChatRoom,
|
|
76
|
+
data: InternalMessageEventData,
|
|
77
|
+
): Promise<MessageResponse>;
|
|
78
|
+
(
|
|
79
|
+
type: SocketEventType.InternalMessageStatus,
|
|
80
|
+
room: SocketServerChatRoom,
|
|
81
|
+
data: InternalMessageEventData,
|
|
82
|
+
): Promise<MessageResponse>;
|
|
83
|
+
(
|
|
84
|
+
type: SocketEventType.InternalChatStarted,
|
|
85
|
+
room: SocketServerRoom,
|
|
86
|
+
data: InternalChatStartedEventData,
|
|
87
|
+
): Promise<MessageResponse>;
|
|
88
|
+
(
|
|
89
|
+
type: SocketEventType.InternalChatFinished,
|
|
90
|
+
room: SocketServerRoom,
|
|
91
|
+
data: InternalChatFinishedEventData,
|
|
67
92
|
): Promise<MessageResponse>;
|
|
68
93
|
}
|
|
69
94
|
|
|
70
95
|
export interface ListenSocketEventFn {
|
|
71
96
|
(
|
|
72
|
-
|
|
73
|
-
|
|
97
|
+
type: SocketEventType.WwebjsQr,
|
|
98
|
+
callback: (data: WWEBJSQrEventData) => void,
|
|
99
|
+
): void;
|
|
100
|
+
(
|
|
101
|
+
type: SocketEventType.WwebjsAuth,
|
|
102
|
+
callback: (data: WWEBJSAuthEventData) => void,
|
|
103
|
+
): void;
|
|
104
|
+
(
|
|
105
|
+
type: SocketEventType.WppChatStarted,
|
|
106
|
+
callback: (data: WppChatStartedEventData) => void,
|
|
74
107
|
): void;
|
|
75
108
|
(
|
|
76
|
-
|
|
77
|
-
|
|
109
|
+
type: SocketEventType.WppChatFinished,
|
|
110
|
+
callback: (data: WppChatFinishedEventData) => void,
|
|
78
111
|
): void;
|
|
79
112
|
(
|
|
80
|
-
|
|
81
|
-
|
|
113
|
+
type: SocketEventType.WppMessage,
|
|
114
|
+
callback: (data: WppMessageEventData) => void,
|
|
82
115
|
): void;
|
|
83
116
|
(
|
|
84
|
-
|
|
85
|
-
|
|
117
|
+
type: SocketEventType.WppMessageStatus,
|
|
118
|
+
callback: (data: WppMessageStatusEventData) => void,
|
|
86
119
|
): void;
|
|
87
120
|
(
|
|
88
|
-
|
|
89
|
-
|
|
121
|
+
type: SocketEventType.WppContactMessagesRead,
|
|
122
|
+
callback: (data: WppContactMessagesReadEventData) => void,
|
|
90
123
|
): void;
|
|
91
124
|
(
|
|
92
|
-
|
|
93
|
-
|
|
125
|
+
type: SocketEventType.WppMessageReaction,
|
|
126
|
+
callback: (data: WppMessageReactionEventData) => void,
|
|
94
127
|
): void;
|
|
95
128
|
(
|
|
96
|
-
|
|
97
|
-
|
|
129
|
+
type: SocketEventType.ReportStatus,
|
|
130
|
+
callback: (data: ReportStatusEventData) => void,
|
|
98
131
|
): void;
|
|
99
132
|
(
|
|
100
|
-
type: SocketEventType.
|
|
101
|
-
callback: (data:
|
|
133
|
+
type: SocketEventType.InternalChatStarted,
|
|
134
|
+
callback: (data: InternalChatStartedEventData) => void,
|
|
102
135
|
): void;
|
|
103
136
|
(
|
|
104
|
-
|
|
105
|
-
|
|
137
|
+
type: SocketEventType.InternalChatFinished,
|
|
138
|
+
callback: (data: InternalChatFinishedEventData) => void,
|
|
139
|
+
): void;
|
|
140
|
+
(
|
|
141
|
+
type: SocketEventType.InternalMessage,
|
|
142
|
+
callback: (data: InternalMessageEventData) => void,
|
|
143
|
+
): void;
|
|
144
|
+
(
|
|
145
|
+
type: SocketEventType.InternalMessageStatus,
|
|
146
|
+
callback: (data: InternalMessageStatusEventData) => void,
|
|
106
147
|
): void;
|
|
107
148
|
}
|
|
108
149
|
|
|
@@ -110,18 +151,16 @@ export interface UnlistenSocketEventFn {
|
|
|
110
151
|
(type: SocketEventType): void;
|
|
111
152
|
}
|
|
112
153
|
|
|
113
|
-
// EventData
|
|
154
|
+
// EventData types
|
|
114
155
|
export interface WWEBJSQrEventData {
|
|
115
156
|
qr: string;
|
|
116
157
|
phone: string;
|
|
117
158
|
}
|
|
118
|
-
|
|
119
159
|
export interface WWEBJSAuthEventData {
|
|
120
160
|
phone: string;
|
|
121
161
|
success: boolean;
|
|
122
162
|
message?: string;
|
|
123
163
|
}
|
|
124
|
-
|
|
125
164
|
export interface WppChatStartedEventData {
|
|
126
165
|
chatId: number;
|
|
127
166
|
}
|
|
@@ -143,7 +182,23 @@ export interface WppMessageReactionEventData {
|
|
|
143
182
|
messageId: number;
|
|
144
183
|
reaction: string;
|
|
145
184
|
}
|
|
146
|
-
|
|
185
|
+
export interface InternalChatStartedEventData {
|
|
186
|
+
chatId: number;
|
|
187
|
+
}
|
|
188
|
+
export interface InternalChatFinishedEventData {
|
|
189
|
+
chatId: number;
|
|
190
|
+
}
|
|
191
|
+
export interface InternalContactMessagesReadEventData {
|
|
192
|
+
contactId: number;
|
|
193
|
+
}
|
|
194
|
+
export interface InternalMessageEventData {
|
|
195
|
+
message: InternalMessage;
|
|
196
|
+
}
|
|
197
|
+
export interface InternalMessageStatusEventData {
|
|
198
|
+
messageId: number;
|
|
199
|
+
contactId: number;
|
|
200
|
+
status: InternalMessageStatus;
|
|
201
|
+
}
|
|
147
202
|
export type ReportStatusEventData = {
|
|
148
203
|
id: number;
|
|
149
204
|
type: string;
|
package/tsconfig.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
4
|
-
"module": "commonjs" /* Specify what module code is generated. */,
|
|
5
|
-
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
6
|
-
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
7
|
-
"strict": true /* Enable all strict type-checking options. */,
|
|
8
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
|
|
9
|
-
"noUnusedLocals": false,
|
|
10
|
-
"outDir": "./dist", /* Redirect output structure to the directory. */
|
|
11
|
-
"declaration": true
|
|
12
|
-
},
|
|
13
|
-
"include": [
|
|
14
|
-
"src/index.ts",
|
|
15
|
-
"src/**/*.{ts}"
|
|
16
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
4
|
+
"module": "commonjs" /* Specify what module code is generated. */,
|
|
5
|
+
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
6
|
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
7
|
+
"strict": true /* Enable all strict type-checking options. */,
|
|
8
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
|
|
9
|
+
"noUnusedLocals": false,
|
|
10
|
+
"outDir": "./dist", /* Redirect output structure to the directory. */
|
|
11
|
+
"declaration": true
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"src/index.ts",
|
|
15
|
+
"src/**/*.{ts}"
|
|
16
|
+
]
|
|
17
17
|
}
|