@zauru-sdk/services 2.0.96 → 2.0.101

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.
@@ -0,0 +1,8 @@
1
+ import { AxiosUtilsResponse } from "@zauru-sdk/types";
2
+ /**
3
+ * getCMSGeneralQuery
4
+ * @param headers
5
+ * @param queryKey - clave dinámica para acceder a los datos en la respuesta (ej. 'purchase_orders', 'users')
6
+ * @returns
7
+ */
8
+ export declare const getCMSGeneralQuery: <T>(query: string) => Promise<AxiosUtilsResponse<T[]>>;
package/dist/common.d.ts CHANGED
@@ -29,6 +29,7 @@ export declare const getHeaders: (cookie: string | null, _session?: Session | nu
29
29
  }) => Promise<{
30
30
  [key: string]: string;
31
31
  }>;
32
+ export declare const getCMSHeaders: () => Promise<AxiosRequestHeaders>;
32
33
  /**
33
34
  * getGraphQLAPIHeaders
34
35
  * @param session
@@ -0,0 +1,20 @@
1
+ import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
+ import { getCMSHeaders } from "../common.js";
3
+ import { httpCMSAPI } from "~/zauru/httpCMS.js";
4
+ /**
5
+ * getCMSGeneralQuery
6
+ * @param headers
7
+ * @param queryKey - clave dinámica para acceder a los datos en la respuesta (ej. 'purchase_orders', 'users')
8
+ * @returns
9
+ */
10
+ export const getCMSGeneralQuery = async (query) => {
11
+ return handlePossibleAxiosErrors(async () => {
12
+ const headers = await getCMSHeaders();
13
+ // Respuesta con clave dinámica basada en query
14
+ const response = await httpCMSAPI.post("", {
15
+ query,
16
+ }, { headers });
17
+ // Retorna los datos según la clave dinámica proporcionada
18
+ return response.data;
19
+ });
20
+ };
@@ -5,6 +5,7 @@ import { httpZauru } from "./zauru/httpZauru.js";
5
5
  import { getAgencyInfo, getEmployeeInfo, getOauthUserInfo, getProfileInformation, } from "./zauru/zauru-profiles.js";
6
6
  import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
7
7
  import { getVariables } from "./zauru/zauru-variables.js";
8
+ import { config } from "@zauru-sdk/config";
8
9
  /**
9
10
  * loginWebApp
10
11
  * @param session
@@ -89,6 +90,13 @@ export const getHeaders = async (cookie, _session, config, extraConfig) => {
89
90
  }
90
91
  return headers;
91
92
  };
93
+ export const getCMSHeaders = async () => {
94
+ const token = config.cmsAPIToken;
95
+ return {
96
+ Authorization: `users API-Key ${token}`,
97
+ "Content-Type": "application/json",
98
+ };
99
+ };
92
100
  /**
93
101
  * getGraphQLToken
94
102
  * @param session
package/dist/esm/index.js CHANGED
@@ -2,6 +2,7 @@ export * from "./common.js";
2
2
  export * from "./graphql/index.js";
3
3
  export * from "./sessions/sessions.js";
4
4
  export * from "./sessions/upstash.js";
5
+ export * from "./zauru/httpCMS.js";
5
6
  export * from "./zauru/httpGraphQL.js";
6
7
  export * from "./zauru/httpOauth.js";
7
8
  export * from "./zauru/httpZauru.js";
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./common.js";
2
2
  export * from "./graphql/index.js";
3
3
  export * from "./sessions/sessions.js";
4
4
  export * from "./sessions/upstash.js";
5
+ export * from "./zauru/httpCMS.js";
5
6
  export * from "./zauru/httpGraphQL.js";
6
7
  export * from "./zauru/httpOauth.js";
7
8
  export * from "./zauru/httpZauru.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/services",
3
- "version": "2.0.96",
3
+ "version": "2.0.101",
4
4
  "description": "Servicios de consulta a Zauru",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -25,11 +25,11 @@
25
25
  "dependencies": {
26
26
  "@remix-run/node": "^2.8.1",
27
27
  "@zauru-sdk/common": "^2.0.94",
28
- "@zauru-sdk/config": "^2.0.87",
28
+ "@zauru-sdk/config": "^2.0.100",
29
29
  "@zauru-sdk/graphql": "^2.0.93",
30
30
  "@zauru-sdk/types": "^2.0.92",
31
31
  "axios": "^1.6.7",
32
32
  "chalk": "5.3.0"
33
33
  },
34
- "gitHead": "b46314dae63e6d018c4913cc8fc7ecb0c6c51d91"
34
+ "gitHead": "600c804405b61d0b07ebc19ecb4f02d25ba1e28b"
35
35
  }