@zauru-sdk/services 2.23.0 → 2.24.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.
@@ -9,6 +9,11 @@ axiosInstance.interceptors.request.use(function (request) {
9
9
  const baseName = `${request.baseURL}${request.url}`;
10
10
  console.log(chalk.green(baseName));
11
11
  request.timeout = 200000;
12
+ request.metadata = { startTime: Date.now() };
13
+ if (config.debugHTTP) {
14
+ console.log(chalk.cyan(`[DEBUG] REQUEST METHOD: ${request.method?.toUpperCase()}`));
15
+ console.log(chalk.cyan("[DEBUG] REQUEST BODY:"), JSON.stringify(request.data, null, 2));
16
+ }
12
17
  return request;
13
18
  }, function (error) {
14
19
  console.log(chalk.red("---------------- ERROR CON REQUEST CMS ----------------"));
@@ -19,13 +24,22 @@ axiosInstance.interceptors.request.use(function (request) {
19
24
  // Add a response interceptor
20
25
  axiosInstance.interceptors.response.use(function (response) {
21
26
  // Do something with response data
22
- const baseName = `${response.config.baseURL}${response.config.url}`;
27
+ if (config.debugHTTP) {
28
+ const elapsed = Date.now() -
29
+ (response.config.metadata?.startTime ?? Date.now());
30
+ console.log(chalk.cyan(`[DEBUG] RESPONSE TIME: ${elapsed}ms`));
31
+ console.log(chalk.cyan("[DEBUG] RESPONSE DATA:"), JSON.stringify(response.data, null, 2));
32
+ }
23
33
  return response;
24
34
  }, function (error) {
25
35
  console.log(chalk.red("---------------- ERROR CON REQUEST CMS ----------------"));
26
36
  console.log(`${error}`);
27
37
  // Do something with response error
28
38
  const { response } = error;
39
+ if (config.debugHTTP) {
40
+ const elapsed = Date.now() - (error.config?.metadata?.startTime ?? Date.now());
41
+ console.log(chalk.cyan(`[DEBUG] RESPONSE TIME: ${elapsed}ms`));
42
+ }
29
43
  const msgError = response
30
44
  ? `HTTP ${response.status} ${response.statusText} - URL: ${response?.config?.baseURL}${response?.config?.url} - ${JSON.stringify(response?.data)}`
31
45
  : error;
@@ -9,6 +9,11 @@ axiosInstance.interceptors.request.use(function (request) {
9
9
  const baseName = `${request.baseURL}${request.url}`;
10
10
  console.log(chalk.green(baseName));
11
11
  request.timeout = 200000;
12
+ request.metadata = { startTime: Date.now() };
13
+ if (config.debugHTTP) {
14
+ console.log(chalk.cyan(`[DEBUG] REQUEST METHOD: ${request.method?.toUpperCase()}`));
15
+ console.log(chalk.cyan("[DEBUG] REQUEST BODY:"), JSON.stringify(request.data, null, 2));
16
+ }
12
17
  return request;
13
18
  }, function (error) {
14
19
  console.log(chalk.red("---------------- ERROR CON REQUEST GRAPHQL ----------------"));
@@ -19,13 +24,22 @@ axiosInstance.interceptors.request.use(function (request) {
19
24
  // Add a response interceptor
20
25
  axiosInstance.interceptors.response.use(function (response) {
21
26
  // Do something with response data
22
- const baseName = `${response.config.baseURL}${response.config.url}`;
27
+ if (config.debugHTTP) {
28
+ const elapsed = Date.now() -
29
+ (response.config.metadata?.startTime ?? Date.now());
30
+ console.log(chalk.cyan(`[DEBUG] RESPONSE TIME: ${elapsed}ms`));
31
+ console.log(chalk.cyan("[DEBUG] RESPONSE DATA:"), JSON.stringify(response.data, null, 2));
32
+ }
23
33
  return response;
24
34
  }, function (error) {
25
35
  console.log(chalk.red("---------------- ERROR CON REQUEST GRAPHQL ----------------"));
26
36
  console.log(`${error}`);
27
37
  // Do something with response error
28
38
  const { response } = error;
39
+ if (config.debugHTTP) {
40
+ const elapsed = Date.now() - (error.config?.metadata?.startTime ?? Date.now());
41
+ console.log(chalk.cyan(`[DEBUG] RESPONSE TIME: ${elapsed}ms`));
42
+ }
29
43
  const msgError = response
30
44
  ? `HTTP ${response.status} ${response.statusText} - URL: ${response?.config?.baseURL}${response?.config?.url} - ${JSON.stringify(response?.data)}`
31
45
  : error;
@@ -9,6 +9,11 @@ axiosInstance.interceptors.request.use(function (request) {
9
9
  const baseName = `${request.baseURL}${request.url}`;
10
10
  console.log(chalk.green(baseName));
11
11
  request.timeout = 200000;
12
+ request.metadata = { startTime: Date.now() };
13
+ if (config.debugHTTP) {
14
+ console.log(chalk.cyan(`[DEBUG] REQUEST METHOD: ${request.method?.toUpperCase()}`));
15
+ console.log(chalk.cyan("[DEBUG] REQUEST BODY:"), JSON.stringify(request.data, null, 2));
16
+ }
12
17
  return request;
13
18
  }, function (error) {
14
19
  console.log(chalk.red("---------------- ERROR CON REQUEST ----------------"));
@@ -19,13 +24,22 @@ axiosInstance.interceptors.request.use(function (request) {
19
24
  // Add a response interceptor
20
25
  axiosInstance.interceptors.response.use(function (response) {
21
26
  // Do something with response data
22
- const baseName = `${response.config.baseURL}${response.config.url}`;
27
+ if (config.debugHTTP) {
28
+ const elapsed = Date.now() -
29
+ (response.config.metadata?.startTime ?? Date.now());
30
+ console.log(chalk.cyan(`[DEBUG] RESPONSE TIME: ${elapsed}ms`));
31
+ console.log(chalk.cyan("[DEBUG] RESPONSE DATA:"), JSON.stringify(response.data, null, 2));
32
+ }
23
33
  return response;
24
34
  }, function (error) {
25
35
  console.log(chalk.red("---------------- ERROR CON REQUEST ----------------"));
26
36
  console.log(`${error}`);
27
37
  // Do something with response error
28
38
  const { response } = error;
39
+ if (config.debugHTTP) {
40
+ const elapsed = Date.now() - (error.config?.metadata?.startTime ?? Date.now());
41
+ console.log(chalk.cyan(`[DEBUG] RESPONSE TIME: ${elapsed}ms`));
42
+ }
29
43
  const msgError = response
30
44
  ? `HTTP ${response.status} ${response.statusText} - URL: ${response?.config?.baseURL}${response?.config?.url} - ${JSON.stringify(response?.data)}`
31
45
  : error;
@@ -9,6 +9,11 @@ axiosInstance.interceptors.request.use(function (request) {
9
9
  const baseName = `${request.baseURL}${request.url}`;
10
10
  console.log(chalk.green(baseName));
11
11
  request.timeout = 200000;
12
+ request.metadata = { startTime: Date.now() };
13
+ if (config.debugHTTP) {
14
+ console.log(chalk.cyan(`[DEBUG] REQUEST METHOD: ${request.method?.toUpperCase()}`));
15
+ console.log(chalk.cyan("[DEBUG] REQUEST BODY:"), JSON.stringify(request.data, null, 2));
16
+ }
12
17
  return request;
13
18
  }, function (error) {
14
19
  console.log(chalk.red("---------------- ERROR CON REQUEST (REQUEST INTERCEPTOR) ----------------"));
@@ -19,12 +24,21 @@ axiosInstance.interceptors.request.use(function (request) {
19
24
  // Add a response interceptor
20
25
  axiosInstance.interceptors.response.use(function (response) {
21
26
  // Do something with response data
22
- const baseName = `${response.config.baseURL}${response.config.url}`;
27
+ if (config.debugHTTP) {
28
+ const elapsed = Date.now() -
29
+ (response.config.metadata?.startTime ?? Date.now());
30
+ console.log(chalk.cyan(`[DEBUG] RESPONSE TIME: ${elapsed}ms`));
31
+ console.log(chalk.cyan("[DEBUG] RESPONSE DATA:"), JSON.stringify(response.data, null, 2));
32
+ }
23
33
  return response;
24
34
  }, function (error) {
25
35
  console.log(chalk.red("---------------- ERROR CON REQUEST (RESPONSE INTERCEPTOR) ----------------"));
26
36
  // Do something with response error
27
37
  const { response } = error;
38
+ if (config.debugHTTP) {
39
+ const elapsed = Date.now() - (error.config?.metadata?.startTime ?? Date.now());
40
+ console.log(chalk.cyan(`[DEBUG] RESPONSE TIME: ${elapsed}ms`));
41
+ }
28
42
  const msgError = response
29
43
  ? `HTTP ${response.status} ${response.statusText} - URL: ${response?.config?.baseURL}${response?.config?.url} - ${JSON.stringify(response?.data)}`
30
44
  : error;
@@ -149,37 +149,6 @@ export async function createInvoicePOS(headers, body) {
149
149
  return response.data;
150
150
  });
151
151
  }
152
- /**
153
- * updateInvoicePOS
154
- * @param headers
155
- * @param body
156
- * @returns
157
- */
158
- /*
159
- export async function updateInvoicePOS(
160
- headers: any,
161
- body: Partial<InvoiceGraphQL>,
162
- ): Promise<AxiosUtilsResponse<InvoiceGraphQL>> {
163
- return handlePossibleAxiosErrors(async () => {
164
- const sendBody = {
165
- ...body,
166
- invoice_details_attributes: arrayToObject(body.invoice_details),
167
- } as any;
168
- if (sendBody.deleted_invoice_details)
169
- delete sendBody.deleted_invoice_details;
170
- if (sendBody.__rvfInternalFormId) delete sendBody.__rvfInternalFormId;
171
- if (sendBody.invoice_details) delete sendBody.invoice_details;
172
-
173
- const response = await httpZauru.patch<InvoiceGraphQL>(
174
- `/pos/invoices/${body.id}.json`,
175
- { invoice: sendBody },
176
- { headers },
177
- );
178
-
179
- return response.data;
180
- });
181
- }
182
- */
183
152
  /**
184
153
  * deleteInvoicePOS
185
154
  * @param headers
@@ -44,12 +44,6 @@ export declare function deleteInvoiceOrder(headers: any, id: string | number): P
44
44
  * @returns
45
45
  */
46
46
  export declare function createInvoicePOS(headers: any, body: Partial<InvoiceGraphQL>): Promise<AxiosUtilsResponse<InvoiceGraphQL>>;
47
- /**
48
- * updateInvoicePOS
49
- * @param headers
50
- * @param body
51
- * @returns
52
- */
53
47
  /**
54
48
  * deleteInvoicePOS
55
49
  * @param headers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/services",
3
- "version": "2.23.0",
3
+ "version": "2.24.0",
4
4
  "description": "Servicios de consulta a Zauru",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -26,11 +26,11 @@
26
26
  "@remix-run/node": "^2.8.1",
27
27
  "@upstash/redis": "^1.34.5",
28
28
  "@zauru-sdk/common": "^2.16.1",
29
- "@zauru-sdk/config": "^2.19.0",
29
+ "@zauru-sdk/config": "^2.23.1",
30
30
  "@zauru-sdk/graphql": "^2.19.1",
31
31
  "@zauru-sdk/types": "^2.16.0",
32
32
  "axios": "^1.6.7",
33
33
  "chalk": "5.3.0"
34
34
  },
35
- "gitHead": "dd7ff51f53cd22b8c8a343139d596f1c66e973ce"
35
+ "gitHead": "799053c918c45098292942718cc1836090536466"
36
36
  }