@in.pulse-crm/sdk 1.6.2 → 2.0.0
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/dist/api-client.d.ts +9 -0
- package/dist/api-client.js +29 -0
- package/dist/{auth.d.ts → auth.client.d.ts} +4 -38
- package/dist/{auth.js → auth.client.js} +6 -10
- package/dist/customers.client.d.ts +37 -0
- package/dist/{customer.js → customers.client.js} +6 -10
- package/dist/files.client.d.ts +31 -0
- package/dist/{file.js → files.client.js} +6 -26
- package/dist/index.d.ts +9 -12
- package/dist/index.js +21 -41
- package/dist/{instance.d.ts → instance.client.d.ts} +3 -9
- package/dist/{instance.js → instance.client.js} +6 -10
- package/dist/reports.client.d.ts +9 -0
- package/dist/{report.js → reports.client.js} +6 -6
- package/dist/socket-server.client.d.ts +24 -0
- package/dist/socket-server.client.js +34 -0
- package/dist/socket.client.d.ts +49 -0
- package/dist/socket.client.js +74 -0
- package/dist/types/auth.types.d.ts +29 -0
- package/dist/{customer.d.ts → types/customers.types.d.ts} +0 -42
- package/dist/{file.d.ts → types/files.types.d.ts} +3 -38
- package/dist/types/files.types.js +15 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.js +23 -0
- package/dist/{report.d.ts → types/reports.types.d.ts} +0 -10
- package/dist/types/socket-events.types.d.ts +72 -0
- package/dist/types/socket-events.types.js +19 -0
- package/dist/types/socket-rooms.types.d.ts +15 -0
- package/dist/{user.d.ts → types/user.types.d.ts} +0 -41
- package/dist/types/user.types.js +19 -0
- package/dist/users.client.d.ts +40 -0
- package/dist/{user.js → users.client.js} +11 -27
- package/package.json +1 -1
- package/src/api-client.ts +33 -0
- package/src/{auth.ts → auth.client.ts} +4 -43
- package/src/customers.client.ts +66 -0
- package/src/files.client.ts +57 -0
- package/src/index.ts +9 -87
- package/src/{instance.ts → instance.client.ts} +4 -8
- package/src/reports.client.ts +34 -0
- package/src/socket-server.client.ts +32 -0
- package/src/socket.client.ts +78 -0
- package/src/types/auth.types.ts +31 -0
- package/src/types/customers.types.ts +68 -0
- package/src/types/files.types.ts +78 -0
- package/src/types/index.ts +7 -0
- package/src/types/reports.types.ts +24 -0
- package/src/types/socket-events.types.ts +76 -0
- package/src/types/socket-rooms.types.ts +31 -0
- package/src/{user.ts → types/user.types.ts} +1 -78
- package/src/users.client.ts +74 -0
- package/dist/auth.sdk.d.ts +0 -15
- package/dist/auth.sdk.js +0 -62
- package/dist/instance.sdk.d.ts +0 -10
- package/dist/instance.sdk.js +0 -27
- package/dist/socket-client.d.ts +0 -57
- package/dist/socket-client.js +0 -74
- package/dist/socket-server.d.ts +0 -17
- package/dist/socket-server.js +0 -22
- package/dist/src/sdks/auth.sdk.js +0 -52
- package/dist/src/sdks/index.js +0 -14
- package/dist/src/sdks/instance.sdk.js +0 -31
- package/dist/src/sdks/user.sdk.js +0 -42
- package/dist/src/types/user.types.js +0 -2
- package/dist/types/socket-client.types.d.ts +0 -97
- package/dist/types/socket-client.types.js +0 -2
- package/dist/types/socket-server.types.d.ts +0 -121
- package/dist/types/socket-server.types.js +0 -2
- package/dist/user.sdk.d.ts +0 -14
- package/dist/user.sdk.js +0 -39
- package/src/customer.ts +0 -140
- package/src/file.ts +0 -145
- package/src/report.ts +0 -60
- package/src/socket-client.ts +0 -78
- package/src/socket-server.ts +0 -20
- package/src/types/socket-client.types.ts +0 -114
- package/src/types/socket-server.types.ts +0 -174
- /package/dist/{src/types → types}/auth.types.js +0 -0
- /package/dist/{response.js → types/customers.types.js} +0 -0
- /package/dist/{src/types/index.js → types/reports.types.js} +0 -0
- /package/dist/{response.d.ts → types/response.types.d.ts} +0 -0
- /package/dist/{src/types → types}/response.types.js +0 -0
- /package/dist/{src/types/instance.types.js → types/socket-rooms.types.js} +0 -0
- /package/src/{response.ts → types/response.types.ts} +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosError } from 'axios';
|
|
2
|
+
import { ErrorResponse } from './types/response.types';
|
|
3
|
+
export default class ApiClient {
|
|
4
|
+
protected readonly httpClient: AxiosInstance;
|
|
5
|
+
private baseUrl;
|
|
6
|
+
constructor(baseUrl: string);
|
|
7
|
+
private initializeResponseInterceptor;
|
|
8
|
+
protected handleError: (error: AxiosError<ErrorResponse>) => Promise<never>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 axios_1 = __importDefault(require("axios"));
|
|
7
|
+
class ApiClient {
|
|
8
|
+
httpClient;
|
|
9
|
+
baseUrl;
|
|
10
|
+
constructor(baseUrl) {
|
|
11
|
+
this.baseUrl = baseUrl;
|
|
12
|
+
this.httpClient = axios_1.default.create({
|
|
13
|
+
baseURL: `${this.baseUrl}`,
|
|
14
|
+
timeout: 10000,
|
|
15
|
+
headers: {
|
|
16
|
+
'Content-Type': 'application/json',
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
this.initializeResponseInterceptor();
|
|
20
|
+
}
|
|
21
|
+
initializeResponseInterceptor() {
|
|
22
|
+
this.httpClient.interceptors.response.use(null, this.handleError);
|
|
23
|
+
}
|
|
24
|
+
handleError = (error) => {
|
|
25
|
+
const errorMessage = error.response?.data?.message || error.message;
|
|
26
|
+
return Promise.reject(new Error(errorMessage));
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.default = ApiClient;
|
|
@@ -1,44 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
export interface LoginData {
|
|
5
|
-
/**
|
|
6
|
-
* Token de autenticação.
|
|
7
|
-
*/
|
|
8
|
-
token: string;
|
|
9
|
-
/**
|
|
10
|
-
* Dados do usuário.
|
|
11
|
-
*/
|
|
12
|
-
user: User;
|
|
13
|
-
}
|
|
14
|
-
export interface SessionData {
|
|
15
|
-
/**
|
|
16
|
-
* ID do usuário.
|
|
17
|
-
*/
|
|
18
|
-
userId: number;
|
|
19
|
-
/**
|
|
20
|
-
* ID do setor do usuário.
|
|
21
|
-
*/
|
|
22
|
-
sectorId: number;
|
|
23
|
-
/**
|
|
24
|
-
* Papel do usuário.
|
|
25
|
-
*/
|
|
26
|
-
role: string;
|
|
27
|
-
/**
|
|
28
|
-
* Nome da instância.
|
|
29
|
-
*/
|
|
30
|
-
instance: string;
|
|
31
|
-
}
|
|
1
|
+
import { DataResponse } from "./types/response.types";
|
|
2
|
+
import ApiClient from "./api-client";
|
|
3
|
+
import { LoginData, SessionData } from "./types/auth.types";
|
|
32
4
|
/**
|
|
33
5
|
* Classe AuthSDK para interagir com a API de autenticação.
|
|
34
6
|
*/
|
|
35
|
-
export default class
|
|
36
|
-
private readonly httpClient;
|
|
37
|
-
/**
|
|
38
|
-
* Cria uma instância do SDK de autenticação.
|
|
39
|
-
* @param {AxiosInstance} httpClient A instância do cliente HTTP a ser usada para fazer requisições à API.
|
|
40
|
-
*/
|
|
41
|
-
constructor(httpClient: AxiosInstance);
|
|
7
|
+
export default class AuthClient extends ApiClient {
|
|
42
8
|
/**
|
|
43
9
|
* Realiza o login do usuário.
|
|
44
10
|
* @param {string} instance Nome da instância do Inpulse.
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const utils_1 = require("@in.pulse-crm/utils");
|
|
7
|
+
const api_client_1 = __importDefault(require("./api-client"));
|
|
4
8
|
/**
|
|
5
9
|
* Classe AuthSDK para interagir com a API de autenticação.
|
|
6
10
|
*/
|
|
7
|
-
class
|
|
8
|
-
httpClient;
|
|
9
|
-
/**
|
|
10
|
-
* Cria uma instância do SDK de autenticação.
|
|
11
|
-
* @param {AxiosInstance} httpClient A instância do cliente HTTP a ser usada para fazer requisições à API.
|
|
12
|
-
*/
|
|
13
|
-
constructor(httpClient) {
|
|
14
|
-
this.httpClient = httpClient;
|
|
15
|
-
}
|
|
11
|
+
class AuthClient extends api_client_1.default {
|
|
16
12
|
/**
|
|
17
13
|
* Realiza o login do usuário.
|
|
18
14
|
* @param {string} instance Nome da instância do Inpulse.
|
|
@@ -74,4 +70,4 @@ class AuthSDK {
|
|
|
74
70
|
}
|
|
75
71
|
}
|
|
76
72
|
}
|
|
77
|
-
exports.default =
|
|
73
|
+
exports.default = AuthClient;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import ApiClient from "./api-client";
|
|
2
|
+
import { CreateCustomerDTO, UpdateCustomerDTO } from "./types/customers.types";
|
|
3
|
+
declare class CustomersClient extends ApiClient {
|
|
4
|
+
/**
|
|
5
|
+
* Cria um novo cliente.
|
|
6
|
+
* @param data - Os dados do cliente a serem criados.
|
|
7
|
+
* @returns Uma Promise que resolve para o cliente criado.
|
|
8
|
+
*/
|
|
9
|
+
createCustomer(data: CreateCustomerDTO): Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* Obtém um cliente pelo ID.
|
|
12
|
+
* @param customerId - O ID do cliente a ser obtido.
|
|
13
|
+
* @returns Uma Promise que resolve para o cliente obtido.
|
|
14
|
+
*/
|
|
15
|
+
getCustomerById(customerId: number): Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Atualiza um cliente existente.
|
|
18
|
+
* @param customerId - O ID do cliente a ser atualizado.
|
|
19
|
+
* @param data - Os dados atualizados do cliente.
|
|
20
|
+
* @returns Uma Promise que resolve para o cliente atualizado.
|
|
21
|
+
*/
|
|
22
|
+
updateCustomer(customerId: number, data: UpdateCustomerDTO): Promise<any>;
|
|
23
|
+
/**
|
|
24
|
+
* Obtém todos os clientes.
|
|
25
|
+
*
|
|
26
|
+
* @param filters - Filtros opcionais para a busca de clientes.
|
|
27
|
+
* @todo Implementar tipagem para os filtros.
|
|
28
|
+
* @returns Uma Promise que resolve para uma lista de clientes.
|
|
29
|
+
*/
|
|
30
|
+
getAllCustomers(filters: Record<string, string>): Promise<any>;
|
|
31
|
+
/**
|
|
32
|
+
* Define o token de autenticação para as requisições.
|
|
33
|
+
* @param token - O token de autenticação a ser definido.
|
|
34
|
+
*/
|
|
35
|
+
setAuth(token: string): void;
|
|
36
|
+
}
|
|
37
|
+
export default CustomersClient;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Cria uma instância do SDK de usuários.
|
|
7
|
-
* @param httpClient - A instância do cliente HTTP a ser usada para fazer requisições à API.
|
|
8
|
-
*/
|
|
9
|
-
constructor(httpClient) {
|
|
10
|
-
this.httpClient = httpClient;
|
|
11
|
-
}
|
|
6
|
+
const api_client_1 = __importDefault(require("./api-client"));
|
|
7
|
+
class CustomersClient extends api_client_1.default {
|
|
12
8
|
/**
|
|
13
9
|
* Cria um novo cliente.
|
|
14
10
|
* @param data - Os dados do cliente a serem criados.
|
|
@@ -61,4 +57,4 @@ class CustomerSDK {
|
|
|
61
57
|
this.httpClient.defaults.headers.common["Authorization"] = `Bearer ${token}`;
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
|
-
exports.default =
|
|
60
|
+
exports.default = CustomersClient;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import ApiClient from "./api-client";
|
|
4
|
+
import { UploadFileOptions } from "./types/files.types";
|
|
5
|
+
declare class FilesClient extends ApiClient {
|
|
6
|
+
/**
|
|
7
|
+
* Busca um arquivo pelo ID.
|
|
8
|
+
* @param {number} id - ID do arquivo.
|
|
9
|
+
* @returns {Promise<Buffer>} Um buffer contendo os dados do arquivo.
|
|
10
|
+
*/
|
|
11
|
+
fetchFile(id: number): Promise<Buffer>;
|
|
12
|
+
/**
|
|
13
|
+
* Obtém a URL de download de um arquivo.
|
|
14
|
+
* @param {number} id - ID do arquivo.
|
|
15
|
+
* @returns {string} URL de download do arquivo.
|
|
16
|
+
*/
|
|
17
|
+
getFileDownloadUrl(id: number): string;
|
|
18
|
+
/**
|
|
19
|
+
* Faz o upload de um arquivo.
|
|
20
|
+
* @param {UploadFileOptions} props - Opções para o upload do arquivo.
|
|
21
|
+
* @returns {Promise<File>} Os dados do arquivo enviado.
|
|
22
|
+
*/
|
|
23
|
+
uploadFile(props: UploadFileOptions): Promise<File>;
|
|
24
|
+
/**
|
|
25
|
+
* Deleta um arquivo pelo ID.
|
|
26
|
+
* @param {number} id - ID do arquivo.
|
|
27
|
+
* @returns {Promise<void>}
|
|
28
|
+
*/
|
|
29
|
+
deleteFile(id: number): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export default FilesClient;
|
|
@@ -1,30 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Enum que representa os tipos de diretórios de arquivos.
|
|
6
|
-
*
|
|
7
|
-
* @enum {string}
|
|
8
|
-
* @property {string} PUBLIC - Representa o diretório público.
|
|
9
|
-
* @property {string} MODELS - Representa o diretório de modelos.
|
|
10
|
-
*/
|
|
11
|
-
var FileDirType;
|
|
12
|
-
(function (FileDirType) {
|
|
13
|
-
FileDirType["PUBLIC"] = "public";
|
|
14
|
-
FileDirType["MODELS"] = "models";
|
|
15
|
-
})(FileDirType || (exports.FileDirType = FileDirType = {}));
|
|
16
|
-
/**
|
|
17
|
-
* SDK para operações de arquivos.
|
|
18
|
-
*/
|
|
19
|
-
class FileSDK {
|
|
20
|
-
httpClient;
|
|
21
|
-
/**
|
|
22
|
-
* Cria uma instância do SDK de arquivos.
|
|
23
|
-
* @param httpClient A instância do cliente HTTP a ser usada para fazer requisições à API.
|
|
24
|
-
*/
|
|
25
|
-
constructor(httpClient) {
|
|
26
|
-
this.httpClient = httpClient;
|
|
27
|
-
}
|
|
6
|
+
const api_client_1 = __importDefault(require("./api-client"));
|
|
7
|
+
class FilesClient extends api_client_1.default {
|
|
28
8
|
/**
|
|
29
9
|
* Busca um arquivo pelo ID.
|
|
30
10
|
* @param {number} id - ID do arquivo.
|
|
@@ -69,4 +49,4 @@ class FileSDK {
|
|
|
69
49
|
await this.httpClient.delete(`/files/${id}`);
|
|
70
50
|
}
|
|
71
51
|
}
|
|
72
|
-
exports.default =
|
|
52
|
+
exports.default = FilesClient;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import { EmitFunction, ChatsReportStatusData, SocketServerAdminRoom, SocketServerMonitorRoom, SocketServerReportsRoom, SocketServerRoom, ChatId, QRCode, SocketEventType } from "./types/socket-server.types";
|
|
11
|
-
import { SocketClientChatRoom, SocketClientAdminRoom, SocketClientMonitorRoom, SocketClientReportsRoom, SocketClientRoom } from "./types/socket-client.types";
|
|
12
|
-
export { AuthSDK, LoginData, SessionData, FileSDK, File, FileDirType, InstanceSDK, UserSDK, CreateUserDTO, UpdateUserDTO, User, UserRole, CustomerSDK, Customer, CreateCustomerDTO, UpdateCustomerDTO, DataResponse, ErrorResponse, PaginatedResponse, QueryResponse, ReportSDK, ChatsReport, ChatsReportFormat as ChatsReportFileFormat, GenerateChatsReportOptions, SocketClientSDK, SocketClientChatRoom as SocketChatRoom, SocketClientAdminRoom, SocketClientMonitorRoom, SocketClientReportsRoom, SocketClientRoom, SocketServerSDK, EmitFunction, SocketEventType, ChatsReportStatusData, SocketServerAdminRoom, SocketServerMonitorRoom, SocketServerReportsRoom, SocketServerRoom, ChatId, QRCode, };
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export { default as AuthClient } from "./auth.client";
|
|
3
|
+
export { default as CustomersClient } from "./customers.client";
|
|
4
|
+
export { default as FilesClient } from "./files.client";
|
|
5
|
+
export { default as InstancesClient } from "./instance.client";
|
|
6
|
+
export { default as ReportsClient } from "./reports.client";
|
|
7
|
+
export { default as SocketServerClient } from "./socket-server.client";
|
|
8
|
+
export { default as SocketClient } from "./socket.client";
|
|
9
|
+
export { default as UsersClient } from "./users.client";
|
package/dist/index.js
CHANGED
|
@@ -10,48 +10,28 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
35
16
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
18
|
};
|
|
38
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Object.defineProperty(exports, "
|
|
45
|
-
|
|
46
|
-
exports
|
|
47
|
-
|
|
48
|
-
exports
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
exports.SocketServerSDK = socket_server_1.default;
|
|
20
|
+
exports.UsersClient = exports.SocketClient = exports.SocketServerClient = exports.ReportsClient = exports.InstancesClient = exports.FilesClient = exports.CustomersClient = exports.AuthClient = void 0;
|
|
21
|
+
__exportStar(require("./types"), exports);
|
|
22
|
+
var auth_client_1 = require("./auth.client");
|
|
23
|
+
Object.defineProperty(exports, "AuthClient", { enumerable: true, get: function () { return __importDefault(auth_client_1).default; } });
|
|
24
|
+
var customers_client_1 = require("./customers.client");
|
|
25
|
+
Object.defineProperty(exports, "CustomersClient", { enumerable: true, get: function () { return __importDefault(customers_client_1).default; } });
|
|
26
|
+
var files_client_1 = require("./files.client");
|
|
27
|
+
Object.defineProperty(exports, "FilesClient", { enumerable: true, get: function () { return __importDefault(files_client_1).default; } });
|
|
28
|
+
var instance_client_1 = require("./instance.client");
|
|
29
|
+
Object.defineProperty(exports, "InstancesClient", { enumerable: true, get: function () { return __importDefault(instance_client_1).default; } });
|
|
30
|
+
var reports_client_1 = require("./reports.client");
|
|
31
|
+
Object.defineProperty(exports, "ReportsClient", { enumerable: true, get: function () { return __importDefault(reports_client_1).default; } });
|
|
32
|
+
var socket_server_client_1 = require("./socket-server.client");
|
|
33
|
+
Object.defineProperty(exports, "SocketServerClient", { enumerable: true, get: function () { return __importDefault(socket_server_client_1).default; } });
|
|
34
|
+
var socket_client_1 = require("./socket.client");
|
|
35
|
+
Object.defineProperty(exports, "SocketClient", { enumerable: true, get: function () { return __importDefault(socket_client_1).default; } });
|
|
36
|
+
var users_client_1 = require("./users.client");
|
|
37
|
+
Object.defineProperty(exports, "UsersClient", { enumerable: true, get: function () { return __importDefault(users_client_1).default; } });
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ApiClient from "./api-client";
|
|
2
2
|
/**
|
|
3
3
|
* Classe InstanceSDK para interagir com a API de instâncias.
|
|
4
4
|
*/
|
|
5
|
-
declare class
|
|
6
|
-
private readonly httpClient;
|
|
7
|
-
/**
|
|
8
|
-
* Cria uma instância do SDK de instância.
|
|
9
|
-
* @param {AxiosInstance} httpClient A instância do cliente HTTP a ser usada para fazer requisições à API.
|
|
10
|
-
*/
|
|
11
|
-
constructor(httpClient: AxiosInstance);
|
|
5
|
+
declare class InstancesClient extends ApiClient {
|
|
12
6
|
/**
|
|
13
7
|
* Executa uma consulta na instância especificada.
|
|
14
8
|
* @param {string} instance Nome da instância do Inpulse.
|
|
@@ -18,4 +12,4 @@ declare class InstanceSDK {
|
|
|
18
12
|
*/
|
|
19
13
|
executeQuery<T>(instance: string, query: string, parameters: any[]): Promise<T>;
|
|
20
14
|
}
|
|
21
|
-
export default
|
|
15
|
+
export default InstancesClient;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const api_client_1 = __importDefault(require("./api-client"));
|
|
3
7
|
/**
|
|
4
8
|
* Classe InstanceSDK para interagir com a API de instâncias.
|
|
5
9
|
*/
|
|
6
|
-
class
|
|
7
|
-
httpClient;
|
|
8
|
-
/**
|
|
9
|
-
* Cria uma instância do SDK de instância.
|
|
10
|
-
* @param {AxiosInstance} httpClient A instância do cliente HTTP a ser usada para fazer requisições à API.
|
|
11
|
-
*/
|
|
12
|
-
constructor(httpClient) {
|
|
13
|
-
this.httpClient = httpClient;
|
|
14
|
-
}
|
|
10
|
+
class InstancesClient extends api_client_1.default {
|
|
15
11
|
/**
|
|
16
12
|
* Executa uma consulta na instância especificada.
|
|
17
13
|
* @param {string} instance Nome da instância do Inpulse.
|
|
@@ -34,4 +30,4 @@ class InstanceSDK {
|
|
|
34
30
|
return response.data.result;
|
|
35
31
|
}
|
|
36
32
|
}
|
|
37
|
-
exports.default =
|
|
33
|
+
exports.default = InstancesClient;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import ApiClient from "./api-client";
|
|
2
|
+
import { ChatsReport, GenerateChatsReportOptions } from "./types/reports.types";
|
|
3
|
+
import { DataResponse, MessageResponse } from "./types/response.types";
|
|
4
|
+
export default class ReportsClient extends ApiClient {
|
|
5
|
+
getChatsReports(): Promise<DataResponse<ChatsReport[]>>;
|
|
6
|
+
generateChatsReport(body: GenerateChatsReportOptions): Promise<DataResponse<ChatsReport>>;
|
|
7
|
+
deleteChatsReport(chatsReportId: number): Promise<MessageResponse>;
|
|
8
|
+
setAuth(token: string): void;
|
|
9
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
constructor(httpClient) {
|
|
6
|
-
this.httpClient = httpClient;
|
|
7
|
-
}
|
|
6
|
+
const api_client_1 = __importDefault(require("./api-client"));
|
|
7
|
+
class ReportsClient extends api_client_1.default {
|
|
8
8
|
async getChatsReports() {
|
|
9
9
|
const url = `/reports/chats`;
|
|
10
10
|
const response = await this.httpClient.get(url);
|
|
@@ -24,4 +24,4 @@ class ReportSDK {
|
|
|
24
24
|
this.httpClient.defaults.headers.common["Authorization"] = `Bearer ${token}`;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
exports.default =
|
|
27
|
+
exports.default = ReportsClient;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { EmitSocketEventFn } from "./types/socket-events.types";
|
|
2
|
+
import ApiClient from "./api-client";
|
|
3
|
+
/**
|
|
4
|
+
* A client for interacting with a socket server API.
|
|
5
|
+
* Extends the `ApiClient` class to provide http functionality
|
|
6
|
+
* for emitting events to specific rooms on the server.
|
|
7
|
+
*/
|
|
8
|
+
export default class SocketServerApi extends ApiClient {
|
|
9
|
+
/**
|
|
10
|
+
* Creates an instance of the SocketServerApiClient.
|
|
11
|
+
*
|
|
12
|
+
* @param baseUrl - The base URL for the socket server API.
|
|
13
|
+
*/
|
|
14
|
+
constructor(baseUrl: string);
|
|
15
|
+
/**
|
|
16
|
+
* Emits a socket event to a specified room with a given event name and value.
|
|
17
|
+
*
|
|
18
|
+
* @param event - The name of the event to emit.
|
|
19
|
+
* @param room - The name of the room to which the event should be emitted.
|
|
20
|
+
* @param value - The payload or data to send with the event.
|
|
21
|
+
* @returns A promise that resolves with the response from the API call.
|
|
22
|
+
*/
|
|
23
|
+
emit: EmitSocketEventFn;
|
|
24
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* A client for interacting with a socket server API.
|
|
9
|
+
* Extends the `ApiClient` class to provide http functionality
|
|
10
|
+
* for emitting events to specific rooms on the server.
|
|
11
|
+
*/
|
|
12
|
+
class SocketServerApi extends api_client_1.default {
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of the SocketServerApiClient.
|
|
15
|
+
*
|
|
16
|
+
* @param baseUrl - The base URL for the socket server API.
|
|
17
|
+
*/
|
|
18
|
+
constructor(baseUrl) {
|
|
19
|
+
super(baseUrl);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Emits a socket event to a specified room with a given event name and value.
|
|
23
|
+
*
|
|
24
|
+
* @param event - The name of the event to emit.
|
|
25
|
+
* @param room - The name of the room to which the event should be emitted.
|
|
26
|
+
* @param value - The payload or data to send with the event.
|
|
27
|
+
* @returns A promise that resolves with the response from the API call.
|
|
28
|
+
*/
|
|
29
|
+
emit = (event, room, value) => {
|
|
30
|
+
return this.httpClient.post(`/emit/${room}/${event}`, value)
|
|
31
|
+
.then(res => res.data);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
exports.default = SocketServerApi;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ListenSocketEventFn, UnlistenSocketEventFn } from "./types/socket-events.types";
|
|
2
|
+
/**
|
|
3
|
+
* A client for interacting with a WebSocket server.
|
|
4
|
+
* This class provides methods to connect to the server, listen for events,
|
|
5
|
+
* and manage WebSocket connections.
|
|
6
|
+
*/
|
|
7
|
+
export default class SocketClient {
|
|
8
|
+
private readonly ws;
|
|
9
|
+
private readonly listeners;
|
|
10
|
+
/**
|
|
11
|
+
* Initializes a new instance of the socket client.
|
|
12
|
+
*
|
|
13
|
+
* @param baseUrl - The base URL of the WebSocket server to connect to.
|
|
14
|
+
* This URL is used to establish the WebSocket connection.
|
|
15
|
+
*
|
|
16
|
+
* The WebSocket client is configured with the following options:
|
|
17
|
+
* - `autoConnect`: Disabled by default to allow manual connection control.
|
|
18
|
+
* - `transports`: Uses the 'websocket' transport protocol exclusively.
|
|
19
|
+
*/
|
|
20
|
+
constructor(baseUrl: string);
|
|
21
|
+
/**
|
|
22
|
+
* Establishes a WebSocket connection using the provided authentication token.
|
|
23
|
+
*
|
|
24
|
+
* @param token - The authentication token to be used for the WebSocket connection.
|
|
25
|
+
* This token is sent as part of the WebSocket authentication payload.
|
|
26
|
+
*/
|
|
27
|
+
connect(token: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Disconnects the WebSocket client from the server.
|
|
30
|
+
* This method terminates the current WebSocket connection
|
|
31
|
+
* by invoking the `disconnect` method on the WebSocket instance.
|
|
32
|
+
*/
|
|
33
|
+
disconnect(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Registers an event listener for a specified WebSocket event and provides a way to remove it.
|
|
36
|
+
*
|
|
37
|
+
* @param event - The name of the WebSocket event to listen for.
|
|
38
|
+
* @param callback - A function to be executed when the event is triggered. The function receives the event data as its argument.
|
|
39
|
+
* @returns A function that, when called, removes the event listener for the specified event.
|
|
40
|
+
*/
|
|
41
|
+
on: ListenSocketEventFn;
|
|
42
|
+
/**
|
|
43
|
+
* Removes a previously registered event listener from the WebSocket connection.
|
|
44
|
+
*
|
|
45
|
+
* @param event - The name of the event to stop listening for.
|
|
46
|
+
* @param callback - The callback function that was previously registered for the event.
|
|
47
|
+
*/
|
|
48
|
+
off: UnlistenSocketEventFn;
|
|
49
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const socket_io_client_1 = require("socket.io-client");
|
|
4
|
+
/**
|
|
5
|
+
* A client for interacting with a WebSocket server.
|
|
6
|
+
* This class provides methods to connect to the server, listen for events,
|
|
7
|
+
* and manage WebSocket connections.
|
|
8
|
+
*/
|
|
9
|
+
class SocketClient {
|
|
10
|
+
ws;
|
|
11
|
+
listeners = new Map();
|
|
12
|
+
/**
|
|
13
|
+
* Initializes a new instance of the socket client.
|
|
14
|
+
*
|
|
15
|
+
* @param baseUrl - The base URL of the WebSocket server to connect to.
|
|
16
|
+
* This URL is used to establish the WebSocket connection.
|
|
17
|
+
*
|
|
18
|
+
* The WebSocket client is configured with the following options:
|
|
19
|
+
* - `autoConnect`: Disabled by default to allow manual connection control.
|
|
20
|
+
* - `transports`: Uses the 'websocket' transport protocol exclusively.
|
|
21
|
+
*/
|
|
22
|
+
constructor(baseUrl) {
|
|
23
|
+
this.ws = (0, socket_io_client_1.io)(baseUrl, {
|
|
24
|
+
autoConnect: false,
|
|
25
|
+
transports: ['websocket'],
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Establishes a WebSocket connection using the provided authentication token.
|
|
30
|
+
*
|
|
31
|
+
* @param token - The authentication token to be used for the WebSocket connection.
|
|
32
|
+
* This token is sent as part of the WebSocket authentication payload.
|
|
33
|
+
*/
|
|
34
|
+
connect(token) {
|
|
35
|
+
this.ws.auth = { token };
|
|
36
|
+
this.ws.connect();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Disconnects the WebSocket client from the server.
|
|
40
|
+
* This method terminates the current WebSocket connection
|
|
41
|
+
* by invoking the `disconnect` method on the WebSocket instance.
|
|
42
|
+
*/
|
|
43
|
+
disconnect() {
|
|
44
|
+
this.ws.disconnect();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Registers an event listener for a specified WebSocket event and provides a way to remove it.
|
|
48
|
+
*
|
|
49
|
+
* @param event - The name of the WebSocket event to listen for.
|
|
50
|
+
* @param callback - A function to be executed when the event is triggered. The function receives the event data as its argument.
|
|
51
|
+
* @returns A function that, when called, removes the event listener for the specified event.
|
|
52
|
+
*/
|
|
53
|
+
on = (event, callback) => {
|
|
54
|
+
if (!this.listeners.get(event)) {
|
|
55
|
+
this.ws.on(event, (data) => {
|
|
56
|
+
callback(data);
|
|
57
|
+
});
|
|
58
|
+
this.listeners.set(event, callback);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Removes a previously registered event listener from the WebSocket connection.
|
|
63
|
+
*
|
|
64
|
+
* @param event - The name of the event to stop listening for.
|
|
65
|
+
* @param callback - The callback function that was previously registered for the event.
|
|
66
|
+
*/
|
|
67
|
+
off = (event) => {
|
|
68
|
+
const listener = this.listeners.get(event);
|
|
69
|
+
if (!listener)
|
|
70
|
+
return;
|
|
71
|
+
this.ws.off(event, listener);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
exports.default = SocketClient;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { User } from "./user.types";
|
|
2
|
+
export interface LoginData {
|
|
3
|
+
/**
|
|
4
|
+
* Token de autenticação.
|
|
5
|
+
*/
|
|
6
|
+
token: string;
|
|
7
|
+
/**
|
|
8
|
+
* Dados do usuário.
|
|
9
|
+
*/
|
|
10
|
+
user: User;
|
|
11
|
+
}
|
|
12
|
+
export interface SessionData {
|
|
13
|
+
/**
|
|
14
|
+
* ID do usuário.
|
|
15
|
+
*/
|
|
16
|
+
userId: number;
|
|
17
|
+
/**
|
|
18
|
+
* ID do setor do usuário.
|
|
19
|
+
*/
|
|
20
|
+
sectorId: number;
|
|
21
|
+
/**
|
|
22
|
+
* Papel do usuário.
|
|
23
|
+
*/
|
|
24
|
+
role: string;
|
|
25
|
+
/**
|
|
26
|
+
* Nome da instância.
|
|
27
|
+
*/
|
|
28
|
+
instance: string;
|
|
29
|
+
}
|