@in.pulse-crm/sdk 2.7.5 → 2.7.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.
@@ -1,5 +1,5 @@
1
1
  import ApiClient from "./api-client";
2
- import { ChatsReport, GenerateChatsReportOptions } from "./types/reports.types";
2
+ import { ChatsReport, ExecuteSqlReportOptions, ExportSqlReportOptions, GenerateChatsReportOptions, SQLReportRow } from "./types/reports.types";
3
3
  /**
4
4
  * ReportsClient class to handle reports related API calls.
5
5
  *
@@ -26,6 +26,32 @@ export default class ReportsClient extends ApiClient {
26
26
  * @param chatsReportId - The unique identifier of the chat report to be deleted.
27
27
  */
28
28
  deleteChatsReport(chatsReportId: number): Promise<void>;
29
+ /**
30
+ * Desative a report sql by its unique identifier.
31
+ *
32
+ * @param reportId - The unique identifier of the chat report to be deleted.
33
+ */
34
+ deleteHistoryReport(reportId: number): Promise<void>;
35
+ /**
36
+ * Execute a report sql interactions based on the provided options.
37
+ *
38
+ * @param body - The options for execute the report sql.
39
+ * @returns A promise that resolves to the data of the generated chats report.
40
+ */
41
+ executeSqlReport(body: ExecuteSqlReportOptions): Promise<SQLReportRow[]>;
42
+ /**
43
+ * Retrieves chat reports from the server.
44
+ *
45
+ * @returns A promise that resolves to an array of chat reports wrapped in a `DataResponse` object.
46
+ */
47
+ getSqlReportsHistory(): Promise<any[]>;
48
+ /**
49
+ * Export a report sql interactions based on the provided options.
50
+ *
51
+ * @param body - The options for export the report sql.
52
+ * @returns A promise that resolves to the data of the generated chats report.
53
+ */
54
+ exportReportSql(body: ExportSqlReportOptions): Promise<Blob>;
29
55
  /**
30
56
  * Sets the authorization token for the HTTP client.
31
57
  *
@@ -41,6 +41,49 @@ class ReportsClient extends api_client_1.default {
41
41
  const url = `/api/reports/chats/${chatsReportId}`;
42
42
  await this.httpClient.delete(url);
43
43
  }
44
+ /**
45
+ * Desative a report sql by its unique identifier.
46
+ *
47
+ * @param reportId - The unique identifier of the chat report to be deleted.
48
+ */
49
+ async deleteHistoryReport(reportId) {
50
+ const url = `/api/reports-history/${reportId}`;
51
+ await this.httpClient.delete(url);
52
+ }
53
+ /**
54
+ * Execute a report sql interactions based on the provided options.
55
+ *
56
+ * @param body - The options for execute the report sql.
57
+ * @returns A promise that resolves to the data of the generated chats report.
58
+ */
59
+ async executeSqlReport(body) {
60
+ const url = `/api/execute-report-sql`;
61
+ const { data: res } = await this.httpClient.post(url, body);
62
+ return res.data;
63
+ }
64
+ /**
65
+ * Retrieves chat reports from the server.
66
+ *
67
+ * @returns A promise that resolves to an array of chat reports wrapped in a `DataResponse` object.
68
+ */
69
+ async getSqlReportsHistory() {
70
+ const url = `/api/reports-history`;
71
+ const { data: res } = await this.httpClient.get(url);
72
+ return res.data;
73
+ }
74
+ /**
75
+ * Export a report sql interactions based on the provided options.
76
+ *
77
+ * @param body - The options for export the report sql.
78
+ * @returns A promise that resolves to the data of the generated chats report.
79
+ */
80
+ async exportReportSql(body) {
81
+ const url = `/api/export-report-sql`;
82
+ const response = await this.httpClient.post(url, body, {
83
+ responseType: 'blob',
84
+ });
85
+ return response.data;
86
+ }
44
87
  /**
45
88
  * Sets the authorization token for the HTTP client.
46
89
  *
@@ -20,3 +20,23 @@ export interface GenerateChatsReportOptions {
20
20
  startDate: string;
21
21
  endDate: string;
22
22
  }
23
+ export interface SQLReportColumn {
24
+ name: string;
25
+ type: string;
26
+ }
27
+ export type SQLReportRow = Record<string, any>;
28
+ export interface SqlReport {
29
+ id: string;
30
+ description: string;
31
+ sql: string;
32
+ createdAt: string;
33
+ status: "pending" | "completed" | "failed";
34
+ resultUrl?: string;
35
+ }
36
+ export interface ExecuteSqlReportOptions {
37
+ sql: string;
38
+ description?: string;
39
+ }
40
+ export interface ExportSqlReportOptions extends ExecuteSqlReportOptions {
41
+ format: ChatsReportFormat;
42
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in.pulse-crm/sdk",
3
- "version": "2.7.5",
3
+ "version": "2.7.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",
@@ -1,5 +1,5 @@
1
1
  import ApiClient from "./api-client";
2
- import { ChatsReport, GenerateChatsReportOptions } from "./types/reports.types";
2
+ import { ChatsReport, ExecuteSqlReportOptions, ExportSqlReportOptions, GenerateChatsReportOptions, SQLReportRow } from "./types/reports.types";
3
3
  import { DataResponse, MessageResponse } from "./types/response.types";
4
4
 
5
5
  /**
@@ -46,6 +46,56 @@ export default class ReportsClient extends ApiClient {
46
46
  const url = `/api/reports/chats/${chatsReportId}`;
47
47
  await this.httpClient.delete<MessageResponse>(url);
48
48
  }
49
+ /**
50
+ * Desative a report sql by its unique identifier.
51
+ *
52
+ * @param reportId - The unique identifier of the chat report to be deleted.
53
+ */
54
+
55
+ public async deleteHistoryReport(reportId: number) {
56
+ const url = `/api/reports-history/${reportId}`;
57
+ await this.httpClient.delete<MessageResponse>(url);
58
+ }
59
+ /**
60
+ * Execute a report sql interactions based on the provided options.
61
+ *
62
+ * @param body - The options for execute the report sql.
63
+ * @returns A promise that resolves to the data of the generated chats report.
64
+ */
65
+
66
+ public async executeSqlReport(body: ExecuteSqlReportOptions) {
67
+ const url = `/api/execute-report-sql`;
68
+ const { data: res } = await this.httpClient.post<DataResponse<SQLReportRow[]>>(url, body);
69
+ return res.data;
70
+ }
71
+
72
+ /**
73
+ * Retrieves chat reports from the server.
74
+ *
75
+ * @returns A promise that resolves to an array of chat reports wrapped in a `DataResponse` object.
76
+ */
77
+ public async getSqlReportsHistory() {
78
+ const url = `/api/reports-history`;
79
+ const { data: res } =
80
+ await this.httpClient.get<DataResponse<Array<any>>>(url);
81
+
82
+ return res.data;
83
+ }
84
+ /**
85
+ * Export a report sql interactions based on the provided options.
86
+ *
87
+ * @param body - The options for export the report sql.
88
+ * @returns A promise that resolves to the data of the generated chats report.
89
+ */
90
+
91
+ public async exportReportSql(body: ExportSqlReportOptions) {
92
+ const url = `/api/export-report-sql`;
93
+ const response = await this.httpClient.post(url, body, {
94
+ responseType: 'blob',
95
+ });
96
+ return response.data as Blob;
97
+ }
98
+
49
99
 
50
100
  /**
51
101
  * Sets the authorization token for the HTTP client.
@@ -21,4 +21,29 @@ export interface GenerateChatsReportOptions {
21
21
  format: ChatsReportFormat;
22
22
  startDate: string;
23
23
  endDate: string;
24
- }
24
+ }
25
+
26
+ export interface SQLReportColumn {
27
+ name: string;
28
+ type: string;
29
+ }
30
+
31
+ export type SQLReportRow = Record<string, any>;
32
+
33
+ export interface SqlReport {
34
+ id: string;
35
+ description: string;
36
+ sql: string;
37
+ createdAt: string;
38
+ status: "pending" | "completed" | "failed";
39
+ resultUrl?: string;
40
+ }
41
+
42
+ export interface ExecuteSqlReportOptions {
43
+ sql: string;
44
+ description?: string;
45
+ }
46
+
47
+ export interface ExportSqlReportOptions extends ExecuteSqlReportOptions {
48
+ format: ChatsReportFormat;
49
+ }