@in.pulse-crm/sdk 2.10.2 → 2.10.3
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/package.json +1 -1
- package/src/socket-server.client.ts +20 -20
- package/src/types/socket-events.types.ts +39 -3
- 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";
|
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;
|
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
|
}
|