@in.pulse-crm/sdk 2.1.1 → 2.2.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.
@@ -7,3 +7,4 @@ export * from "./response.types";
7
7
  export * from "./socket-events.types";
8
8
  export * from "./socket-rooms.types";
9
9
  export * from "./user.types";
10
+ export * from "./whatsapp.types";
@@ -23,3 +23,4 @@ __exportStar(require("./response.types"), exports);
23
23
  __exportStar(require("./socket-events.types"), exports);
24
24
  __exportStar(require("./socket-rooms.types"), exports);
25
25
  __exportStar(require("./user.types"), exports);
26
+ __exportStar(require("./whatsapp.types"), exports);
@@ -1,5 +1,6 @@
1
1
  import { SocketServerAdminRoom, SocketServerChatRoom, SocketServerReportsRoom, SocketServerRoom } from "./socket-rooms.types";
2
2
  import { MessageResponse } from "./response.types";
3
+ import { WppMessage } from "./whatsapp.types";
3
4
  export declare enum SocketEventType {
4
5
  WppChatStarted = "wpp_chat_started",
5
6
  WppChatFinished = "wpp_chat_finished",
@@ -47,6 +48,7 @@ export interface WppChatStartedEventData {
47
48
  export interface WppChatFinishedEventData {
48
49
  }
49
50
  export interface WppMessageEventData {
51
+ message: WppMessage;
50
52
  }
51
53
  export interface WppMessageStatusEventData {
52
54
  }
@@ -12,8 +12,3 @@ var SocketEventType;
12
12
  SocketEventType["WwebjsAuth"] = "wwebjs_auth";
13
13
  SocketEventType["ReportStatus"] = "report_status";
14
14
  })(SocketEventType || (exports.SocketEventType = SocketEventType = {}));
15
- ;
16
- ;
17
- ;
18
- ;
19
- ;
@@ -0,0 +1,17 @@
1
+ export type WppMessageStatus = "PENDING" | "SENT" | "RECEIVED" | "READ" | "DOWNLOADED" | "ERROR";
2
+ export interface WppMessage {
3
+ instanceName: string;
4
+ id: string;
5
+ from: string;
6
+ to: string;
7
+ type: string;
8
+ quotedId: string | null;
9
+ chatId: number | null;
10
+ body: string;
11
+ timestamp: bigint;
12
+ status: WppMessageStatus;
13
+ fileId: number | null;
14
+ fileName: string | null;
15
+ fileType: string | null;
16
+ fileSize: bigint | null;
17
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in.pulse-crm/sdk",
3
- "version": "2.1.1",
3
+ "version": "2.2.1",
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",
@@ -7,3 +7,4 @@ export * from "./response.types";
7
7
  export * from "./socket-events.types";
8
8
  export * from "./socket-rooms.types";
9
9
  export * from "./user.types";
10
+ export * from "./whatsapp.types";
@@ -1,76 +1,144 @@
1
- import { SocketServerAdminRoom, SocketServerChatRoom, SocketServerReportsRoom, SocketServerRoom } from "./socket-rooms.types";
1
+ import {
2
+ SocketServerAdminRoom,
3
+ SocketServerChatRoom,
4
+ SocketServerReportsRoom,
5
+ SocketServerRoom,
6
+ } from "./socket-rooms.types";
2
7
  import { MessageResponse } from "./response.types";
8
+ import { WppMessage } from "./whatsapp.types";
3
9
 
4
10
  export enum SocketEventType {
5
- WppChatStarted = "wpp_chat_started",
6
- WppChatFinished = "wpp_chat_finished",
7
- WppMessage = "wpp_message",
8
- WppMessageStatus = "wpp_message_status",
9
- WppMessageReaction = "wpp_message_reaction",
10
- WwebjsQr = "wwebjs_qr",
11
- WwebjsAuth = "wwebjs_auth",
12
- ReportStatus = "report_status"
11
+ WppChatStarted = "wpp_chat_started",
12
+ WppChatFinished = "wpp_chat_finished",
13
+ WppMessage = "wpp_message",
14
+ WppMessageStatus = "wpp_message_status",
15
+ WppMessageReaction = "wpp_message_reaction",
16
+ WwebjsQr = "wwebjs_qr",
17
+ WwebjsAuth = "wwebjs_auth",
18
+ ReportStatus = "report_status",
13
19
  }
14
20
 
15
21
  export interface EmitSocketEventFn {
16
- (type: SocketEventType.WwebjsQr, room: SocketServerAdminRoom, data: WWEBJSQrEventData): Promise<MessageResponse>;
17
- (type: SocketEventType.WwebjsAuth, room: SocketServerAdminRoom, data: WWEBJSAuthEventData): Promise<MessageResponse>;
18
- (type: SocketEventType.WppChatStarted, room: SocketServerRoom, data: WppChatStartedEventData): Promise<MessageResponse>;
19
- (type: SocketEventType.WppChatFinished, room: SocketServerRoom, data: WppChatFinishedEventData): Promise<MessageResponse>;
20
- (type: SocketEventType.WppMessage, room: SocketServerChatRoom, data: WppMessageEventData): Promise<MessageResponse>;
21
- (type: SocketEventType.WppMessageStatus, room: SocketServerChatRoom, data: WppMessageStatusEventData): Promise<MessageResponse>;
22
- (type: SocketEventType.WppMessageReaction, room: SocketServerChatRoom, data: WppMessageReactionEventData): Promise<MessageResponse>;
23
- (type: SocketEventType.ReportStatus, room: SocketServerReportsRoom, data: ReportStatusEventData): Promise<MessageResponse>;
22
+ (
23
+ type: SocketEventType.WwebjsQr,
24
+ room: SocketServerAdminRoom,
25
+ data: WWEBJSQrEventData,
26
+ ): Promise<MessageResponse>;
27
+ (
28
+ type: SocketEventType.WwebjsAuth,
29
+ room: SocketServerAdminRoom,
30
+ data: WWEBJSAuthEventData,
31
+ ): Promise<MessageResponse>;
32
+ (
33
+ type: SocketEventType.WppChatStarted,
34
+ room: SocketServerRoom,
35
+ data: WppChatStartedEventData,
36
+ ): Promise<MessageResponse>;
37
+ (
38
+ type: SocketEventType.WppChatFinished,
39
+ room: SocketServerRoom,
40
+ data: WppChatFinishedEventData,
41
+ ): Promise<MessageResponse>;
42
+ (
43
+ type: SocketEventType.WppMessage,
44
+ room: SocketServerChatRoom,
45
+ data: WppMessageEventData,
46
+ ): Promise<MessageResponse>;
47
+ (
48
+ type: SocketEventType.WppMessageStatus,
49
+ room: SocketServerChatRoom,
50
+ data: WppMessageStatusEventData,
51
+ ): Promise<MessageResponse>;
52
+ (
53
+ type: SocketEventType.WppMessageReaction,
54
+ room: SocketServerChatRoom,
55
+ data: WppMessageReactionEventData,
56
+ ): Promise<MessageResponse>;
57
+ (
58
+ type: SocketEventType.ReportStatus,
59
+ room: SocketServerReportsRoom,
60
+ data: ReportStatusEventData,
61
+ ): Promise<MessageResponse>;
24
62
  }
25
63
 
26
64
  export interface ListenSocketEventFn {
27
- (type: SocketEventType.WwebjsQr, callback: (data: WWEBJSQrEventData) => void): void;
28
- (type: SocketEventType.WwebjsAuth, callback: (data: WWEBJSAuthEventData) => void): void;
29
- (type: SocketEventType.WppChatStarted, callback: (data: WppChatStartedEventData) => void): void;
30
- (type: SocketEventType.WppChatFinished, callback: (data: WppChatFinishedEventData) => void): void;
31
- (type: SocketEventType.WppMessage, callback: (data: WppMessageEventData) => void): void;
32
- (type: SocketEventType.WppMessageStatus, callback: (data: WppMessageStatusEventData) => void): void;
33
- (type: SocketEventType.WppMessageReaction, callback: (data: WppMessageReactionEventData) => void): void;
34
- (type: SocketEventType.ReportStatus, callback: (data: ReportStatusEventData) => void): void;
65
+ (
66
+ type: SocketEventType.WwebjsQr,
67
+ callback: (data: WWEBJSQrEventData) => void,
68
+ ): void;
69
+ (
70
+ type: SocketEventType.WwebjsAuth,
71
+ callback: (data: WWEBJSAuthEventData) => void,
72
+ ): void;
73
+ (
74
+ type: SocketEventType.WppChatStarted,
75
+ callback: (data: WppChatStartedEventData) => void,
76
+ ): void;
77
+ (
78
+ type: SocketEventType.WppChatFinished,
79
+ callback: (data: WppChatFinishedEventData) => void,
80
+ ): void;
81
+ (
82
+ type: SocketEventType.WppMessage,
83
+ callback: (data: WppMessageEventData) => void,
84
+ ): void;
85
+ (
86
+ type: SocketEventType.WppMessageStatus,
87
+ callback: (data: WppMessageStatusEventData) => void,
88
+ ): void;
89
+ (
90
+ type: SocketEventType.WppMessageReaction,
91
+ callback: (data: WppMessageReactionEventData) => void,
92
+ ): void;
93
+ (
94
+ type: SocketEventType.ReportStatus,
95
+ callback: (data: ReportStatusEventData) => void,
96
+ ): void;
35
97
  }
36
98
 
37
99
  export interface UnlistenSocketEventFn {
38
- (type: SocketEventType): void;
100
+ (type: SocketEventType): void;
39
101
  }
40
102
 
41
103
  // EventData
42
104
  export interface WWEBJSQrEventData {
43
- qr: string;
44
- phone: string;
105
+ qr: string;
106
+ phone: string;
45
107
  }
46
108
 
47
109
  export interface WWEBJSAuthEventData {
48
- phone: string;
49
- success: boolean;
50
- message?: string;
110
+ phone: string;
111
+ success: boolean;
112
+ message?: string;
51
113
  }
52
114
 
53
- export interface WppChatStartedEventData { };
54
- export interface WppChatFinishedEventData { };
55
- export interface WppMessageEventData { };
56
- export interface WppMessageStatusEventData { };
57
- export interface WppMessageReactionEventData { };
115
+ export interface WppChatStartedEventData {}
116
+ export interface WppChatFinishedEventData {}
117
+ export interface WppMessageEventData {
118
+ message: WppMessage;
119
+ }
120
+ export interface WppMessageStatusEventData {}
121
+ export interface WppMessageReactionEventData {}
58
122
 
59
123
  export type ReportStatusEventData = {
60
- id: number;
61
- type: string;
62
- } & ({
63
- isCompleted: true;
64
- isFailed: false;
65
- fileId: number;
66
- chats: number;
67
- messages: number;
68
- } | {
69
- isCompleted: false;
70
- isFailed: true;
71
- error: string;
72
- } | {
73
- isCompleted: false;
74
- isFailed: false;
75
- progress: number;
76
- });
124
+ id: number;
125
+ type: string;
126
+ } & (
127
+ | {
128
+ isCompleted: true;
129
+ isFailed: false;
130
+ fileId: number;
131
+ chats: number;
132
+ messages: number;
133
+ }
134
+ | {
135
+ isCompleted: false;
136
+ isFailed: true;
137
+ error: string;
138
+ }
139
+ | {
140
+ isCompleted: false;
141
+ isFailed: false;
142
+ progress: number;
143
+ }
144
+ );
@@ -0,0 +1,24 @@
1
+ export type WppMessageStatus =
2
+ | "PENDING"
3
+ | "SENT"
4
+ | "RECEIVED"
5
+ | "READ"
6
+ | "DOWNLOADED"
7
+ | "ERROR";
8
+
9
+ export interface WppMessage {
10
+ instanceName: string;
11
+ id: string;
12
+ from: string;
13
+ to: string;
14
+ type: string;
15
+ quotedId: string | null;
16
+ chatId: number | null;
17
+ body: string;
18
+ timestamp: bigint;
19
+ status: WppMessageStatus;
20
+ fileId: number | null;
21
+ fileName: string | null;
22
+ fileType: string | null;
23
+ fileSize: bigint | null;
24
+ }