@zauru-sdk/services 2.0.101 → 2.0.103
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/cms/index.d.ts +17 -3
- package/dist/esm/cms/index.js +9 -4
- package/dist/esm/index.js +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +2 -2
package/dist/cms/index.d.ts
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { AxiosUtilsResponse } from "@zauru-sdk/types";
|
|
2
|
+
export type CMSGeneralQueryResponse<T> = {
|
|
3
|
+
[key: string]: {
|
|
4
|
+
docs: T[];
|
|
5
|
+
hasNextPage: boolean;
|
|
6
|
+
hasPrevPage: boolean;
|
|
7
|
+
limit: number;
|
|
8
|
+
nextPage: number | null;
|
|
9
|
+
offset: number;
|
|
10
|
+
page: number;
|
|
11
|
+
pagingCounter: number;
|
|
12
|
+
prevPage: number | null;
|
|
13
|
+
totalDocs: number;
|
|
14
|
+
totalPages: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
2
17
|
/**
|
|
3
18
|
* getCMSGeneralQuery
|
|
4
|
-
* @param
|
|
5
|
-
* @param queryKey - clave dinámica para acceder a los datos en la respuesta (ej. 'purchase_orders', 'users')
|
|
19
|
+
* @param query
|
|
6
20
|
* @returns
|
|
7
21
|
*/
|
|
8
|
-
export declare const getCMSGeneralQuery: <T>(query: string) => Promise<AxiosUtilsResponse<T
|
|
22
|
+
export declare const getCMSGeneralQuery: <T>(query: string) => Promise<AxiosUtilsResponse<CMSGeneralQueryResponse<T>>>;
|
package/dist/esm/cms/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
2
|
import { getCMSHeaders } from "../common.js";
|
|
3
|
-
import { httpCMSAPI } from "
|
|
3
|
+
import { httpCMSAPI } from "../zauru/httpCMS.js";
|
|
4
4
|
/**
|
|
5
5
|
* getCMSGeneralQuery
|
|
6
|
-
* @param
|
|
7
|
-
* @param queryKey - clave dinámica para acceder a los datos en la respuesta (ej. 'purchase_orders', 'users')
|
|
6
|
+
* @param query
|
|
8
7
|
* @returns
|
|
9
8
|
*/
|
|
10
9
|
export const getCMSGeneralQuery = async (query) => {
|
|
@@ -14,7 +13,13 @@ export const getCMSGeneralQuery = async (query) => {
|
|
|
14
13
|
const response = await httpCMSAPI.post("", {
|
|
15
14
|
query,
|
|
16
15
|
}, { headers });
|
|
16
|
+
if (response.data.errors) {
|
|
17
|
+
throw new Error(response.data.errors?.map((x) => x.message).join(";"));
|
|
18
|
+
}
|
|
19
|
+
if (!response.data.data) {
|
|
20
|
+
throw new Error("No data found");
|
|
21
|
+
}
|
|
17
22
|
// Retorna los datos según la clave dinámica proporcionada
|
|
18
|
-
return response.data;
|
|
23
|
+
return response.data.data;
|
|
19
24
|
});
|
|
20
25
|
};
|
package/dist/esm/index.js
CHANGED
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/services",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.103",
|
|
4
4
|
"description": "Servicios de consulta a Zauru",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"axios": "^1.6.7",
|
|
32
32
|
"chalk": "5.3.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "20298e13a23c5c6d5a810ed6ee0c52c17f4413b6"
|
|
35
35
|
}
|