@in.pulse-crm/sdk 2.10.2 → 2.10.4
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 +2 -0
- package/dist/types/files.types.d.ts +2 -0
- package/dist/types/socket-events.types.d.ts +13 -0
- package/dist/types/socket-events.types.js +2 -0
- package/dist/types/whatsapp.types.d.ts +8 -2
- package/package.json +1 -1
- package/src/socket-server.client.ts +20 -20
- package/src/types/socket-events.types.ts +39 -3
- package/src/types/whatsapp.types.ts +49 -45
- 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
|
@@ -7,6 +7,8 @@ export declare enum SocketEventType {
|
|
|
7
7
|
WppChatFinished = "wpp_chat_finished",
|
|
8
8
|
WppChatTransfer = "wpp_chat_transfer",
|
|
9
9
|
WppMessage = "wpp_message",
|
|
10
|
+
WppMessageEdit = "wpp_message_edit",
|
|
11
|
+
WppMessageDelete = "wpp_message_delete",
|
|
10
12
|
WppMessageStatus = "wpp_message_status",
|
|
11
13
|
WppMessageReaction = "wpp_message_reaction",
|
|
12
14
|
WppContactMessagesRead = "wpp_contact_messages_read",
|
|
@@ -25,6 +27,8 @@ export interface EmitSocketEventFn {
|
|
|
25
27
|
(type: SocketEventType.WppChatFinished, room: SocketServerRoom, data: WppChatFinishedEventData): Promise<MessageResponse>;
|
|
26
28
|
(type: SocketEventType.WppChatTransfer, room: SocketServerRoom, data: WppChatTransferEventData): Promise<MessageResponse>;
|
|
27
29
|
(type: SocketEventType.WppMessage, room: SocketServerChatRoom, data: WppMessageEventData): Promise<MessageResponse>;
|
|
30
|
+
(type: SocketEventType.WppMessageEdit, room: SocketServerChatRoom, data: WppMessageEditEventData): Promise<MessageResponse>;
|
|
31
|
+
(type: SocketEventType.WppMessageDelete, room: SocketServerChatRoom, data: WppMessageDeleteEventData): Promise<MessageResponse>;
|
|
28
32
|
(type: SocketEventType.WppMessageStatus, room: SocketServerChatRoom, data: WppMessageStatusEventData): Promise<MessageResponse>;
|
|
29
33
|
(type: SocketEventType.WppContactMessagesRead, room: SocketServerChatRoom, data: WppContactMessagesReadEventData): Promise<MessageResponse>;
|
|
30
34
|
(type: SocketEventType.WppMessageReaction, room: SocketServerChatRoom, data: WppMessageReactionEventData): Promise<MessageResponse>;
|
|
@@ -49,6 +53,8 @@ export interface ListenSocketEventFn {
|
|
|
49
53
|
(type: SocketEventType.InternalChatFinished, callback: (data: InternalChatFinishedEventData) => void): void;
|
|
50
54
|
(type: SocketEventType.InternalMessage, callback: (data: InternalMessageEventData) => void): void;
|
|
51
55
|
(type: SocketEventType.InternalMessageStatus, callback: (data: InternalMessageStatusEventData) => void): void;
|
|
56
|
+
(type: SocketEventType.WppMessageEdit, callback: (data: WppMessageEditEventData) => void): void;
|
|
57
|
+
(type: SocketEventType.WppMessageDelete, callback: (data: WppMessageDeleteEventData) => void): void;
|
|
52
58
|
}
|
|
53
59
|
export interface UnlistenSocketEventFn {
|
|
54
60
|
(type: SocketEventType): void;
|
|
@@ -77,6 +83,13 @@ export interface WppContactMessagesReadEventData {
|
|
|
77
83
|
export interface WppMessageEventData {
|
|
78
84
|
message: WppMessage;
|
|
79
85
|
}
|
|
86
|
+
export interface WppMessageEditEventData {
|
|
87
|
+
messageId: number;
|
|
88
|
+
newText: string;
|
|
89
|
+
}
|
|
90
|
+
export interface WppMessageDeleteEventData {
|
|
91
|
+
messageId: number;
|
|
92
|
+
}
|
|
80
93
|
export interface WppMessageStatusEventData {
|
|
81
94
|
messageId: number;
|
|
82
95
|
contactId: number;
|
|
@@ -7,6 +7,8 @@ var SocketEventType;
|
|
|
7
7
|
SocketEventType["WppChatFinished"] = "wpp_chat_finished";
|
|
8
8
|
SocketEventType["WppChatTransfer"] = "wpp_chat_transfer";
|
|
9
9
|
SocketEventType["WppMessage"] = "wpp_message";
|
|
10
|
+
SocketEventType["WppMessageEdit"] = "wpp_message_edit";
|
|
11
|
+
SocketEventType["WppMessageDelete"] = "wpp_message_delete";
|
|
10
12
|
SocketEventType["WppMessageStatus"] = "wpp_message_status";
|
|
11
13
|
SocketEventType["WppMessageReaction"] = "wpp_message_reaction";
|
|
12
14
|
SocketEventType["WppContactMessagesRead"] = "wpp_contact_messages_read";
|
|
@@ -28,6 +28,8 @@ export interface WppMessage {
|
|
|
28
28
|
instance: string;
|
|
29
29
|
wwebjsId?: string | null;
|
|
30
30
|
wabaId?: string | null;
|
|
31
|
+
gupshupId?: string | null;
|
|
32
|
+
gupshupRequestId?: string | null;
|
|
31
33
|
from: string;
|
|
32
34
|
to: string;
|
|
33
35
|
type: string;
|
|
@@ -43,9 +45,13 @@ export interface WppMessage {
|
|
|
43
45
|
fileName?: string | null;
|
|
44
46
|
fileType?: string | null;
|
|
45
47
|
fileSize?: string | null;
|
|
48
|
+
wwebjsIdStanza: string | null;
|
|
49
|
+
sentAt: Date;
|
|
50
|
+
userId: number | null;
|
|
51
|
+
billingCategory: string | null;
|
|
46
52
|
}
|
|
47
53
|
export interface ForwardMessagesData {
|
|
48
|
-
sourceType:
|
|
54
|
+
sourceType: "whatsapp" | "internal";
|
|
49
55
|
messageIds: number[];
|
|
50
56
|
whatsappTargets?: Array<{
|
|
51
57
|
id: string;
|
|
@@ -197,5 +203,5 @@ export interface AutomaticResponseRuleDTO {
|
|
|
197
203
|
cooldownSeconds: number;
|
|
198
204
|
fileId?: number | null;
|
|
199
205
|
userIds: number[];
|
|
200
|
-
schedules: Omit<AutomaticResponseSchedule,
|
|
206
|
+
schedules: Omit<AutomaticResponseSchedule, "id">[];
|
|
201
207
|
}
|
package/package.json
CHANGED
|
@@ -8,26 +8,26 @@ import { MessageResponse } from "./types/response.types";
|
|
|
8
8
|
* for emitting events to specific rooms on the server.
|
|
9
9
|
*/
|
|
10
10
|
export default class SocketServerApi extends ApiClient {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of the SocketServerApiClient.
|
|
13
|
+
*
|
|
14
|
+
* @param baseUrl - The base URL for the socket server API.
|
|
15
|
+
*/
|
|
16
|
+
constructor(baseUrl: string) {
|
|
17
|
+
super(baseUrl);
|
|
18
|
+
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Emits a socket event to a specified room with a given event name and value.
|
|
22
|
+
*
|
|
23
|
+
* @param event - The name of the event to emit.
|
|
24
|
+
* @param room - The name of the room to which the event should be emitted.
|
|
25
|
+
* @param value - The payload or data to send with the event.
|
|
26
|
+
* @returns A promise that resolves with the response from the API call.
|
|
27
|
+
*/
|
|
28
|
+
public emit: EmitSocketEventFn = (event, room, value) => {
|
|
29
|
+
return this.ax
|
|
30
30
|
.post<MessageResponse>(`/api/ws/emit/${room}/${event}`, value)
|
|
31
31
|
.then((res) => res.data);
|
|
32
|
-
|
|
33
|
-
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -7,13 +7,19 @@ import {
|
|
|
7
7
|
} from "./socket-rooms.types";
|
|
8
8
|
import { MessageResponse } from "./response.types";
|
|
9
9
|
import { WppMessage, WppMessageStatus } from "./whatsapp.types";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
InternalChat,
|
|
12
|
+
InternalChatMember,
|
|
13
|
+
InternalMessage,
|
|
14
|
+
} from "./internal.types";
|
|
11
15
|
|
|
12
16
|
export enum SocketEventType {
|
|
13
17
|
WppChatStarted = "wpp_chat_started",
|
|
14
18
|
WppChatFinished = "wpp_chat_finished",
|
|
15
19
|
WppChatTransfer = "wpp_chat_transfer",
|
|
16
20
|
WppMessage = "wpp_message",
|
|
21
|
+
WppMessageEdit = "wpp_message_edit",
|
|
22
|
+
WppMessageDelete = "wpp_message_delete",
|
|
17
23
|
WppMessageStatus = "wpp_message_status",
|
|
18
24
|
WppMessageReaction = "wpp_message_reaction",
|
|
19
25
|
WppContactMessagesRead = "wpp_contact_messages_read",
|
|
@@ -57,6 +63,16 @@ export interface EmitSocketEventFn {
|
|
|
57
63
|
room: SocketServerChatRoom,
|
|
58
64
|
data: WppMessageEventData,
|
|
59
65
|
): Promise<MessageResponse>;
|
|
66
|
+
(
|
|
67
|
+
type: SocketEventType.WppMessageEdit,
|
|
68
|
+
room: SocketServerChatRoom,
|
|
69
|
+
data: WppMessageEditEventData,
|
|
70
|
+
): Promise<MessageResponse>;
|
|
71
|
+
(
|
|
72
|
+
type: SocketEventType.WppMessageDelete,
|
|
73
|
+
room: SocketServerChatRoom,
|
|
74
|
+
data: WppMessageDeleteEventData,
|
|
75
|
+
): Promise<MessageResponse>;
|
|
60
76
|
(
|
|
61
77
|
type: SocketEventType.WppMessageStatus,
|
|
62
78
|
room: SocketServerChatRoom,
|
|
@@ -116,7 +132,7 @@ export interface ListenSocketEventFn {
|
|
|
116
132
|
type: SocketEventType.WppChatFinished,
|
|
117
133
|
callback: (data: WppChatFinishedEventData) => void,
|
|
118
134
|
): void;
|
|
119
|
-
|
|
135
|
+
(
|
|
120
136
|
type: SocketEventType.WppChatTransfer,
|
|
121
137
|
callback: (data: WppChatTransferEventData) => void,
|
|
122
138
|
): void;
|
|
@@ -156,6 +172,14 @@ export interface ListenSocketEventFn {
|
|
|
156
172
|
type: SocketEventType.InternalMessageStatus,
|
|
157
173
|
callback: (data: InternalMessageStatusEventData) => void,
|
|
158
174
|
): void;
|
|
175
|
+
(
|
|
176
|
+
type: SocketEventType.WppMessageEdit,
|
|
177
|
+
callback: (data: WppMessageEditEventData) => void,
|
|
178
|
+
): void;
|
|
179
|
+
(
|
|
180
|
+
type: SocketEventType.WppMessageDelete,
|
|
181
|
+
callback: (data: WppMessageDeleteEventData) => void,
|
|
182
|
+
): void;
|
|
159
183
|
}
|
|
160
184
|
|
|
161
185
|
export interface UnlistenSocketEventFn {
|
|
@@ -187,6 +211,15 @@ export interface WppContactMessagesReadEventData {
|
|
|
187
211
|
export interface WppMessageEventData {
|
|
188
212
|
message: WppMessage;
|
|
189
213
|
}
|
|
214
|
+
|
|
215
|
+
export interface WppMessageEditEventData {
|
|
216
|
+
messageId: number;
|
|
217
|
+
newText: string;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface WppMessageDeleteEventData {
|
|
221
|
+
messageId: number;
|
|
222
|
+
}
|
|
190
223
|
export interface WppMessageStatusEventData {
|
|
191
224
|
messageId: number;
|
|
192
225
|
contactId: number;
|
|
@@ -197,7 +230,10 @@ export interface WppMessageReactionEventData {
|
|
|
197
230
|
reaction: string;
|
|
198
231
|
}
|
|
199
232
|
export interface InternalChatStartedEventData {
|
|
200
|
-
chat: InternalChat & {
|
|
233
|
+
chat: InternalChat & {
|
|
234
|
+
participants: InternalChatMember[];
|
|
235
|
+
messages: InternalMessage[];
|
|
236
|
+
};
|
|
201
237
|
}
|
|
202
238
|
export interface InternalChatFinishedEventData {
|
|
203
239
|
chatId: number;
|
|
@@ -31,6 +31,8 @@ export interface WppMessage {
|
|
|
31
31
|
instance: string;
|
|
32
32
|
wwebjsId?: string | null;
|
|
33
33
|
wabaId?: string | null;
|
|
34
|
+
gupshupId?: string | null;
|
|
35
|
+
gupshupRequestId?: string | null;
|
|
34
36
|
from: string;
|
|
35
37
|
to: string;
|
|
36
38
|
type: string;
|
|
@@ -46,12 +48,16 @@ export interface WppMessage {
|
|
|
46
48
|
fileName?: string | null;
|
|
47
49
|
fileType?: string | null;
|
|
48
50
|
fileSize?: string | null;
|
|
51
|
+
wwebjsIdStanza: string | null;
|
|
52
|
+
sentAt: Date;
|
|
53
|
+
userId: number | null;
|
|
54
|
+
billingCategory: string | null;
|
|
49
55
|
}
|
|
50
56
|
export interface ForwardMessagesData {
|
|
51
|
-
sourceType:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
sourceType: "whatsapp" | "internal";
|
|
58
|
+
messageIds: number[];
|
|
59
|
+
whatsappTargets?: Array<{ id: string; isGroup: boolean }>;
|
|
60
|
+
internalTargets?: Array<{ id: number }>;
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
export interface WppChat {
|
|
@@ -171,58 +177,56 @@ export interface WppSchedule {
|
|
|
171
177
|
contact: WppContact;
|
|
172
178
|
}
|
|
173
179
|
export type NotificationType =
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
| "CHAT_AUTO_FINISHED"
|
|
181
|
+
| "CHAT_TRANSFERRED"
|
|
182
|
+
| "CHAT_REASSIGNED"
|
|
183
|
+
| "ALERT"
|
|
184
|
+
| "INFO"
|
|
185
|
+
| "WARNING"
|
|
186
|
+
| "ERROR";
|
|
182
187
|
|
|
183
188
|
export interface AppNotification {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
189
|
+
id: number;
|
|
190
|
+
title: string;
|
|
191
|
+
description: string;
|
|
192
|
+
read: boolean;
|
|
193
|
+
instance: string;
|
|
194
|
+
userId: number | null;
|
|
195
|
+
chatId: number | null;
|
|
196
|
+
type: NotificationType;
|
|
197
|
+
createdAt: string;
|
|
193
198
|
}
|
|
194
199
|
|
|
195
200
|
export interface PaginatedNotificationsResponse {
|
|
196
|
-
|
|
197
|
-
|
|
201
|
+
notifications: AppNotification[];
|
|
202
|
+
totalCount: number;
|
|
198
203
|
}
|
|
199
204
|
export interface AutomaticResponseSchedule {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
205
|
+
id?: number;
|
|
206
|
+
dayOfWeek: number;
|
|
207
|
+
startTime: string;
|
|
208
|
+
endTime: string;
|
|
204
209
|
}
|
|
205
210
|
|
|
206
211
|
export interface AutomaticResponseRule {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
id: number;
|
|
213
|
+
name: string;
|
|
214
|
+
message: string;
|
|
215
|
+
isEnabled: boolean;
|
|
216
|
+
isGlobal: boolean;
|
|
217
|
+
cooldownSeconds: number;
|
|
218
|
+
fileId: number | null;
|
|
219
|
+
schedules: AutomaticResponseSchedule[];
|
|
220
|
+
userAssignments: { userId: number }[];
|
|
216
221
|
}
|
|
217
222
|
|
|
218
223
|
export interface AutomaticResponseRuleDTO {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
name: string;
|
|
225
|
+
message: string;
|
|
226
|
+
isEnabled: boolean;
|
|
227
|
+
isGlobal: boolean;
|
|
228
|
+
cooldownSeconds: number;
|
|
229
|
+
fileId?: number | null;
|
|
230
|
+
userIds: number[];
|
|
231
|
+
schedules: Omit<AutomaticResponseSchedule, "id">[];
|
|
227
232
|
}
|
|
228
|
-
|
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
|
}
|