@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.
@@ -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 headers
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>>>;
@@ -1,10 +1,9 @@
1
1
  import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
2
  import { getCMSHeaders } from "../common.js";
3
- import { httpCMSAPI } from "~/zauru/httpCMS.js";
3
+ import { httpCMSAPI } from "../zauru/httpCMS.js";
4
4
  /**
5
5
  * getCMSGeneralQuery
6
- * @param headers
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
@@ -1,5 +1,6 @@
1
1
  export * from "./common.js";
2
2
  export * from "./graphql/index.js";
3
+ export * from "./cms/index.js";
3
4
  export * from "./sessions/sessions.js";
4
5
  export * from "./sessions/upstash.js";
5
6
  export * from "./zauru/httpCMS.js";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./common.js";
2
2
  export * from "./graphql/index.js";
3
+ export * from "./cms/index.js";
3
4
  export * from "./sessions/sessions.js";
4
5
  export * from "./sessions/upstash.js";
5
6
  export * from "./zauru/httpCMS.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/services",
3
- "version": "2.0.101",
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": "600c804405b61d0b07ebc19ecb4f02d25ba1e28b"
34
+ "gitHead": "20298e13a23c5c6d5a810ed6ee0c52c17f4413b6"
35
35
  }