@in.pulse-crm/sdk 2.4.7 → 2.4.9

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 CHANGED
@@ -1,4 +1,4 @@
1
- {
2
- "tabWidth": 4,
3
- "useTabs": true
4
- }
1
+ {
2
+ "tabWidth": 4,
3
+ "useTabs": true
4
+ }
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import ApiClient from "./api-client";
4
2
  import { File, UploadFileOptions } from "./types/files.types";
5
3
  declare class FilesClient extends ApiClient {
package/dist/index.d.ts CHANGED
@@ -9,3 +9,4 @@ export { default as SocketClient } from "./socket.client";
9
9
  export { default as UsersClient } from "./users.client";
10
10
  export { default as WhatsappClient } from "./whatsapp.client";
11
11
  export { default as WalletsClient } from "./wallets.client";
12
+ export { default as InternalChat } from "./internal.client";
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.WalletsClient = exports.WhatsappClient = exports.UsersClient = exports.SocketClient = exports.SocketServerClient = exports.ReportsClient = exports.InstancesClient = exports.FilesClient = exports.CustomersClient = exports.AuthClient = void 0;
20
+ exports.InternalChat = exports.WalletsClient = exports.WhatsappClient = exports.UsersClient = exports.SocketClient = exports.SocketServerClient = exports.ReportsClient = exports.InstancesClient = exports.FilesClient = exports.CustomersClient = exports.AuthClient = void 0;
21
21
  __exportStar(require("./types"), exports);
22
22
  var auth_client_1 = require("./auth.client");
23
23
  Object.defineProperty(exports, "AuthClient", { enumerable: true, get: function () { return __importDefault(auth_client_1).default; } });
@@ -39,3 +39,5 @@ var whatsapp_client_1 = require("./whatsapp.client");
39
39
  Object.defineProperty(exports, "WhatsappClient", { enumerable: true, get: function () { return __importDefault(whatsapp_client_1).default; } });
40
40
  var wallets_client_1 = require("./wallets.client");
41
41
  Object.defineProperty(exports, "WalletsClient", { enumerable: true, get: function () { return __importDefault(wallets_client_1).default; } });
42
+ var internal_client_1 = require("./internal.client");
43
+ Object.defineProperty(exports, "InternalChat", { enumerable: true, get: function () { return __importDefault(internal_client_1).default; } });
@@ -0,0 +1,10 @@
1
+ import ApiClient from "./api-client";
2
+ import { InternalChat } from "./types/internal.types";
3
+ export default class InternalChatClient extends ApiClient {
4
+ getChatsForUser(userId: number, instance: string): Promise<InternalChat[]>;
5
+ getChatById(id: number): Promise<InternalChat>;
6
+ sendMessageToChat(chatId: number, userId: number, content: string): Promise<any>;
7
+ createGroup(name: string, participantIds: number[], userId: number): Promise<InternalChat>;
8
+ updateGroupMembers(groupId: number, add: number[], remove: number[]): Promise<any>;
9
+ setAuth(token: string): void;
10
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const api_client_1 = __importDefault(require("./api-client"));
7
+ class InternalChatClient extends api_client_1.default {
8
+ async getChatsForUser(userId, instance) {
9
+ const url = `/api/internal/chats?userId=${userId}&instance=${instance}`;
10
+ const { data: res } = await this.httpClient.get(url);
11
+ return res.data;
12
+ }
13
+ async getChatById(id) {
14
+ const { data: res } = await this.httpClient.get(`/api/internal/chats/${id}`);
15
+ return res.data;
16
+ }
17
+ async sendMessageToChat(chatId, userId, content) {
18
+ const { data: res } = await this.httpClient.post(`/api/internal/chats/${chatId}/messages?userId=${userId}`, {
19
+ content,
20
+ });
21
+ return res;
22
+ }
23
+ async createGroup(name, participantIds, userId) {
24
+ const { data: res } = await this.httpClient.post(`/api/internal/chats/group?userId=${userId}`, { name, participantIds });
25
+ return res.data;
26
+ }
27
+ async updateGroupMembers(groupId, add, remove) {
28
+ const { data: res } = await this.httpClient.put(`/api/internal/chats/group/${groupId}/members`, { add, remove });
29
+ return res.data;
30
+ }
31
+ setAuth(token) {
32
+ this.httpClient.defaults.headers.common["Authorization"] =
33
+ `Bearer ${token}`;
34
+ }
35
+ }
36
+ exports.default = InternalChatClient;
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  export interface UploadFileOptions {
4
2
  /**
5
3
  * Nome da instância onde o arquivo está armazenado.
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in.pulse-crm/sdk",
3
- "version": "2.4.7",
3
+ "version": "2.4.9",
4
4
  "description": "SDKs for abstraction of api consumption of in.pulse-crm application",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -26,8 +26,7 @@
26
26
  "@in.pulse-crm/utils": "^1.3.0",
27
27
  "axios": "^1.8.3",
28
28
  "form-data": "^4.0.2",
29
- "socket.io-client": "^4.8.1",
30
- "tsc": "^2.0.4"
29
+ "socket.io-client": "^4.8.1"
31
30
  },
32
31
  "devDependencies": {
33
32
  "@types/node": "^22.13.10",
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { InternalChat } from './types/internal.types';
1
2
  export * from "./types";
2
3
  export { default as AuthClient } from "./auth.client";
3
4
  export { default as CustomersClient } from "./customers.client";
@@ -8,4 +9,5 @@ export { default as SocketServerClient } from "./socket-server.client";
8
9
  export { default as SocketClient } from "./socket.client";
9
10
  export { default as UsersClient } from "./users.client";
10
11
  export { default as WhatsappClient } from "./whatsapp.client";
11
- export { default as WalletsClient } from "./wallets.client";
12
+ export { default as WalletsClient } from "./wallets.client";
13
+ export { default as InternalChat } from "./internal.client";
@@ -0,0 +1,44 @@
1
+ import ApiClient from "./api-client";
2
+ import { DataResponse } from "./types/response.types";
3
+ import { InternalChat } 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
- type: SocketEventType.WwebjsQr,
25
- room: SocketServerAdminRoom,
26
- data: WWEBJSQrEventData,
29
+ type: SocketEventType.WwebjsQr,
30
+ room: SocketServerAdminRoom,
31
+ data: WWEBJSQrEventData,
27
32
  ): Promise<MessageResponse>;
28
33
  (
29
- type: SocketEventType.WwebjsAuth,
30
- room: SocketServerAdminRoom,
31
- data: WWEBJSAuthEventData,
34
+ type: SocketEventType.WwebjsAuth,
35
+ room: SocketServerAdminRoom,
36
+ data: WWEBJSAuthEventData,
32
37
  ): Promise<MessageResponse>;
33
38
  (
34
- type: SocketEventType.WppChatStarted,
35
- room: SocketServerRoom,
36
- data: WppChatStartedEventData,
39
+ type: SocketEventType.WppChatStarted,
40
+ room: SocketServerRoom,
41
+ data: WppChatStartedEventData,
37
42
  ): Promise<MessageResponse>;
38
43
  (
39
- type: SocketEventType.WppChatFinished,
40
- room: SocketServerRoom,
41
- data: WppChatFinishedEventData,
44
+ type: SocketEventType.WppChatFinished,
45
+ room: SocketServerRoom,
46
+ data: WppChatFinishedEventData,
42
47
  ): Promise<MessageResponse>;
43
48
  (
44
- type: SocketEventType.WppMessage,
45
- room: SocketServerChatRoom,
46
- data: WppMessageEventData,
49
+ type: SocketEventType.WppMessage,
50
+ room: SocketServerChatRoom,
51
+ data: WppMessageEventData,
47
52
  ): Promise<MessageResponse>;
48
53
  (
49
- type: SocketEventType.WppMessageStatus,
50
- room: SocketServerChatRoom,
51
- data: WppMessageStatusEventData,
54
+ type: SocketEventType.WppMessageStatus,
55
+ room: SocketServerChatRoom,
56
+ data: WppMessageStatusEventData,
52
57
  ): Promise<MessageResponse>;
53
58
  (
54
- type: SocketEventType.WppContactMessagesRead,
55
- room: SocketServerChatRoom,
56
- data: WppContactMessagesReadEventData,
59
+ type: SocketEventType.WppContactMessagesRead,
60
+ room: SocketServerChatRoom,
61
+ data: WppContactMessagesReadEventData,
57
62
  ): Promise<MessageResponse>;
58
63
  (
59
- type: SocketEventType.WppMessageReaction,
60
- room: SocketServerChatRoom,
61
- data: WppMessageReactionEventData,
64
+ type: SocketEventType.WppMessageReaction,
65
+ room: SocketServerChatRoom,
66
+ data: WppMessageReactionEventData,
62
67
  ): Promise<MessageResponse>;
63
68
  (
64
- type: SocketEventType.ReportStatus,
65
- room: SocketServerReportsRoom,
66
- data: ReportStatusEventData,
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
- type: SocketEventType.WwebjsQr,
73
- callback: (data: WWEBJSQrEventData) => void,
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
- type: SocketEventType.WwebjsAuth,
77
- callback: (data: WWEBJSAuthEventData) => void,
109
+ type: SocketEventType.WppChatFinished,
110
+ callback: (data: WppChatFinishedEventData) => void,
78
111
  ): void;
79
112
  (
80
- type: SocketEventType.WppChatStarted,
81
- callback: (data: WppChatStartedEventData) => void,
113
+ type: SocketEventType.WppMessage,
114
+ callback: (data: WppMessageEventData) => void,
82
115
  ): void;
83
116
  (
84
- type: SocketEventType.WppChatFinished,
85
- callback: (data: WppChatFinishedEventData) => void,
117
+ type: SocketEventType.WppMessageStatus,
118
+ callback: (data: WppMessageStatusEventData) => void,
86
119
  ): void;
87
120
  (
88
- type: SocketEventType.WppMessage,
89
- callback: (data: WppMessageEventData) => void,
121
+ type: SocketEventType.WppContactMessagesRead,
122
+ callback: (data: WppContactMessagesReadEventData) => void,
90
123
  ): void;
91
124
  (
92
- type: SocketEventType.WppMessageStatus,
93
- callback: (data: WppMessageStatusEventData) => void,
125
+ type: SocketEventType.WppMessageReaction,
126
+ callback: (data: WppMessageReactionEventData) => void,
94
127
  ): void;
95
128
  (
96
- type: SocketEventType.WppContactMessagesRead,
97
- callback: (data: WppContactMessagesReadEventData) => void,
129
+ type: SocketEventType.ReportStatus,
130
+ callback: (data: ReportStatusEventData) => void,
98
131
  ): void;
99
132
  (
100
- type: SocketEventType.WppMessageReaction,
101
- callback: (data: WppMessageReactionEventData) => void,
133
+ type: SocketEventType.InternalChatStarted,
134
+ callback: (data: InternalChatStartedEventData) => void,
102
135
  ): void;
103
136
  (
104
- type: SocketEventType.ReportStatus,
105
- callback: (data: ReportStatusEventData) => void,
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;
@@ -1,3 +1,4 @@
1
+ // src/types/socket-rooms.types.ts
1
2
  type ReportType = "chats";
2
3
  type PhoneNumber = string;
3
4
  type WalletId = 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
  }