@in.pulse-crm/sdk 2.2.5 → 2.2.7

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 {
@@ -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.
@@ -50,7 +50,7 @@ export interface WppChatFinishedEventData {
50
50
  chatId: number;
51
51
  }
52
52
  export interface WppMessageEventData {
53
- messageId: string;
53
+ messageId: number;
54
54
  }
55
55
  export interface WppMessageStatusEventData {
56
56
  messageId: number;
@@ -1,3 +1,4 @@
1
+ import { Customer } from "./customers.types";
1
2
  export interface WppContact {
2
3
  id: number;
3
4
  name: string;
@@ -72,3 +73,14 @@ export declare enum WppChatPriority {
72
73
  VERY_HIGH = "VERY_HIGH",
73
74
  URGENCY = "URGENCY"
74
75
  }
76
+ export type WppChatWithDetails = WppChat & {
77
+ contact: WppContact | null;
78
+ customer: Customer | null;
79
+ };
80
+ export type WppChatsAndMessages = {
81
+ chats: WppChatWithDetails[];
82
+ messages: WppMessage[];
83
+ };
84
+ export type WppChatWithDetailsAndMessages = WppChatWithDetails & {
85
+ messages: WppMessage[];
86
+ };
@@ -1,15 +1,17 @@
1
1
  import { DataResponse, PaginatedResponse } from "./types/response.types";
2
2
  import { CreateUserDTO, UpdateUserDTO, User } from "./types/user.types";
3
3
  import ApiClient from "./api-client";
4
+ import { RequestFilters } from "./types";
4
5
  /**
5
6
  * SDK para operações de usuários.
6
7
  */
7
8
  export default class UsersClient extends ApiClient {
8
9
  /**
9
10
  * Obtém a lista de usuários.
11
+ * @param filters - Filtros opcionais para a query.
10
12
  * @returns Uma resposta paginada contendo os usuários.
11
13
  */
12
- getUsers(): Promise<PaginatedResponse<User>>;
14
+ getUsers(filters?: RequestFilters<User>): Promise<PaginatedResponse<User>>;
13
15
  /**
14
16
  * Obtém um usuário pelo ID.
15
17
  * @param userId - O ID do usuário.
@@ -10,9 +10,15 @@ const api_client_1 = __importDefault(require("./api-client"));
10
10
  class UsersClient extends api_client_1.default {
11
11
  /**
12
12
  * Obtém a lista de usuários.
13
+ * @param filters - Filtros opcionais para a query.
13
14
  * @returns Uma resposta paginada contendo os usuários.
14
15
  */
15
- async getUsers() {
16
+ async getUsers(filters) {
17
+ let baseUrl = `/api/users`;
18
+ const params = new URLSearchParams(filters);
19
+ if (params.toString()) {
20
+ baseUrl += `?${params.toString()}`;
21
+ }
16
22
  const response = await this.httpClient.get(`/api/users`);
17
23
  return response.data;
18
24
  }
@@ -1,19 +1,8 @@
1
1
  import ApiClient from "./api-client";
2
- import { Customer } from "./types";
3
2
  import { DataResponse } from "./types/response.types";
4
- import { WppChat, WppContact, WppMessage } from "./types/whatsapp.types";
5
- type ChatWithContactAndCustomer = WppChat & {
6
- customer: Customer;
7
- contact: WppContact;
8
- };
9
- type ChatsAndMessages = {
10
- chats: ChatWithContactAndCustomer[];
11
- messages: WppMessage[];
12
- };
13
- type GetChatsResponse = DataResponse<ChatsAndMessages>;
14
- type GetChatResponse = DataResponse<ChatWithContactAndCustomer & {
15
- messages: WppMessage[];
16
- }>;
3
+ import { WppChatsAndMessages, WppChatWithDetailsAndMessages, WppMessage } from "./types/whatsapp.types";
4
+ type GetChatsResponse = DataResponse<WppChatsAndMessages>;
5
+ type GetChatResponse = DataResponse<WppChatWithDetailsAndMessages>;
17
6
  type GetMessageResponse = DataResponse<WppMessage>;
18
7
  export default class WhatsappClient extends ApiClient {
19
8
  getChatsWithMessages(): Promise<GetChatsResponse>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in.pulse-crm/sdk",
3
- "version": "2.2.5",
3
+ "version": "2.2.7",
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",
@@ -25,11 +25,12 @@
25
25
  "dependencies": {
26
26
  "@in.pulse-crm/utils": "^1.3.0",
27
27
  "axios": "^1.8.3",
28
- "socket.io-client": "^4.8.1"
28
+ "socket.io-client": "^4.8.1",
29
+ "tsc": "^2.0.4"
29
30
  },
30
31
  "devDependencies": {
31
32
  "@types/node": "^22.13.10",
32
33
  "prettier": "^3.5.3",
33
- "typescript": "^5.8.2"
34
+ "typescript": "^5.8.3"
34
35
  }
35
36
  }
@@ -119,7 +119,7 @@ export interface WppChatFinishedEventData {
119
119
  chatId: number;
120
120
  }
121
121
  export interface WppMessageEventData {
122
- messageId: string;
122
+ messageId: number;
123
123
  }
124
124
  export interface WppMessageStatusEventData {
125
125
  messageId: number;
@@ -1,82 +1,96 @@
1
+ import { Customer } from "./customers.types";
2
+
1
3
  export interface WppContact {
2
- id: number;
3
- name: string;
4
- phone: string;
5
- customerId?: number;
6
- instance: string;
7
- isBlocked: boolean;
8
- isOnlyAdmin: boolean;
4
+ id: number;
5
+ name: string;
6
+ phone: string;
7
+ customerId?: number;
8
+ instance: string;
9
+ isBlocked: boolean;
10
+ isOnlyAdmin: boolean;
9
11
  }
10
12
 
11
13
  export interface WppMessage {
12
- id: number;
13
- instance: string;
14
- wwebjsId?: string;
15
- wabaId?: string;
16
- from: string;
17
- to: string;
18
- type: string;
19
- quotedId?: string;
20
- chatId?: number;
21
- contactId?: number;
22
- body: string;
23
- timestamp: string;
24
- status: WppMessageStatus;
25
- fileId?: number;
26
- fileName?: string;
27
- fileType?: string;
28
- fileSize?: string;
14
+ id: number;
15
+ instance: string;
16
+ wwebjsId?: string;
17
+ wabaId?: string;
18
+ from: string;
19
+ to: string;
20
+ type: string;
21
+ quotedId?: string;
22
+ chatId?: number;
23
+ contactId?: number;
24
+ body: string;
25
+ timestamp: string;
26
+ status: WppMessageStatus;
27
+ fileId?: number;
28
+ fileName?: string;
29
+ fileType?: string;
30
+ fileSize?: string;
29
31
  }
30
32
 
31
33
  export interface WppChat {
32
- id: number;
33
- instance: string;
34
- contactId?: number;
35
- userId?: number;
36
- walletId?: number;
37
- botId?: number;
38
- resultId?: number;
39
- sectorId?: number;
40
- type: WppChatType;
41
- priority: WppChatPriority;
42
- avatarUrl?: string;
43
- isFinished: boolean;
34
+ id: number;
35
+ instance: string;
36
+ contactId?: number;
37
+ userId?: number;
38
+ walletId?: number;
39
+ botId?: number;
40
+ resultId?: number;
41
+ sectorId?: number;
42
+ type: WppChatType;
43
+ priority: WppChatPriority;
44
+ avatarUrl?: string;
45
+ isFinished: boolean;
44
46
  }
45
47
 
46
48
  export interface WppSector {
47
- id: number;
48
- name: string;
49
- instanceName: string;
50
- wppInstanceId?: number;
51
- startChats: boolean;
52
- receiveChats: boolean;
49
+ id: number;
50
+ name: string;
51
+ instanceName: string;
52
+ wppInstanceId?: number;
53
+ startChats: boolean;
54
+ receiveChats: boolean;
53
55
  }
54
56
 
55
57
  export interface WppWallet {
56
- instanceName: string;
57
- id: number;
58
- name: string;
58
+ instanceName: string;
59
+ id: number;
60
+ name: string;
59
61
  }
60
62
 
61
63
  // Enums
62
64
  export enum WppMessageStatus {
63
- PENDING = "PENDING",
64
- SENT = "SENT",
65
- RECEIVED = "RECEIVED",
66
- READ = "READ",
67
- DOWNLOADED = "DOWNLOADED",
68
- ERROR = "ERROR",
65
+ PENDING = "PENDING",
66
+ SENT = "SENT",
67
+ RECEIVED = "RECEIVED",
68
+ READ = "READ",
69
+ DOWNLOADED = "DOWNLOADED",
70
+ ERROR = "ERROR",
69
71
  }
70
72
 
71
73
  export enum WppChatType {
72
- RECEPTIVE = "RECEPTIVE",
73
- ACTIVE = "ACTIVE",
74
+ RECEPTIVE = "RECEPTIVE",
75
+ ACTIVE = "ACTIVE",
74
76
  }
75
77
 
76
78
  export enum WppChatPriority {
77
- LOW = "LOW",
78
- NORMAL = "NORMAL",
79
- HIGH = "HIGH",
80
- VERY_HIGH = "VERY_HIGH",
81
- URGENCY = "URGENCY",
79
+ LOW = "LOW",
80
+ NORMAL = "NORMAL",
81
+ HIGH = "HIGH",
82
+ VERY_HIGH = "VERY_HIGH",
83
+ URGENCY = "URGENCY",
82
84
  }
85
+
86
+ export type WppChatWithDetails = WppChat & {
87
+ contact: WppContact | null;
88
+ customer: Customer | null;
89
+ };
90
+ export type WppChatsAndMessages = {
91
+ chats: WppChatWithDetails[];
92
+ messages: WppMessage[];
93
+ };
94
+ export type WppChatWithDetailsAndMessages = WppChatWithDetails & {
95
+ messages: WppMessage[];
96
+ };
@@ -1,6 +1,7 @@
1
1
  import { DataResponse, PaginatedResponse } from "./types/response.types";
2
2
  import { CreateUserDTO, UpdateUserDTO, User } from "./types/user.types";
3
3
  import ApiClient from "./api-client";
4
+ import { RequestFilters } from "./types";
4
5
 
5
6
  /**
6
7
  * SDK para operações de usuários.
@@ -8,9 +9,16 @@ import ApiClient from "./api-client";
8
9
  export default class UsersClient extends ApiClient {
9
10
  /**
10
11
  * Obtém a lista de usuários.
12
+ * @param filters - Filtros opcionais para a query.
11
13
  * @returns Uma resposta paginada contendo os usuários.
12
14
  */
13
- public async getUsers() {
15
+ public async getUsers(filters?: RequestFilters<User>) {
16
+ let baseUrl = `/api/users`;
17
+ const params = new URLSearchParams(filters);
18
+ if (params.toString()) {
19
+ baseUrl += `?${params.toString()}`;
20
+ }
21
+
14
22
  const response =
15
23
  await this.httpClient.get<PaginatedResponse<User>>(`/api/users`);
16
24
 
@@ -1,20 +1,13 @@
1
1
  import ApiClient from "./api-client";
2
- import { Customer } from "./types";
3
2
  import { DataResponse } from "./types/response.types";
4
- import { WppChat, WppContact, WppMessage } from "./types/whatsapp.types";
5
-
6
- type ChatWithContactAndCustomer = WppChat & {
7
- customer: Customer;
8
- contact: WppContact;
9
- };
10
- type ChatsAndMessages = {
11
- chats: ChatWithContactAndCustomer[];
12
- messages: WppMessage[];
13
- };
14
- type GetChatsResponse = DataResponse<ChatsAndMessages>;
15
- type GetChatResponse = DataResponse<
16
- ChatWithContactAndCustomer & { messages: WppMessage[] }
17
- >;
3
+ import {
4
+ WppChatsAndMessages,
5
+ WppChatWithDetailsAndMessages,
6
+ WppMessage,
7
+ } from "./types/whatsapp.types";
8
+
9
+ type GetChatsResponse = DataResponse<WppChatsAndMessages>;
10
+ type GetChatResponse = DataResponse<WppChatWithDetailsAndMessages>;
18
11
  type GetMessageResponse = DataResponse<WppMessage>;
19
12
 
20
13
  export default class WhatsappClient extends ApiClient {
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
  }