sysone-api-mapper 1.0.91 → 1.0.93

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/axiosInstance.js CHANGED
@@ -4,20 +4,4 @@ const axiosInstance = axios.create({
4
4
  baseURL: '',
5
5
  });
6
6
 
7
- // Agregar interceptor para debug
8
- axiosInstance.interceptors.request.use(
9
- (config) => {
10
- console.log("📡 Request desde apiMapper:", {
11
- baseURL: config.baseURL,
12
- url: config.url,
13
- fullURL: `${config.baseURL}${config.url}`,
14
- headers: config.headers
15
- });
16
- return config;
17
- },
18
- (error) => {
19
- return Promise.reject(error);
20
- }
21
- );
22
-
23
7
  export default axiosInstance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sysone-api-mapper",
3
- "version": "1.0.91",
3
+ "version": "1.0.93",
4
4
  "description": "Paquete mapper para portal de productores",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -90,6 +90,15 @@ const configs = {
90
90
  },
91
91
  };
92
92
 
93
+ const getUrl = (serviceUrl, routeParams) => {
94
+ if (!routeParams || routeParams.length === 0) return serviceUrl;
95
+ return serviceUrl.replace(/{(\d+)}/g, function (match, routeParamNumber) {
96
+ return routeParams[routeParamNumber]
97
+ ? routeParams[routeParamNumber]
98
+ : match;
99
+ });
100
+ };
101
+
93
102
 
94
103
  export const apiMapper = async (
95
104
  endpointCode,
@@ -138,8 +147,8 @@ export const apiMapper = async (
138
147
  validateStatus: (status) => status < 500,
139
148
  };
140
149
 
141
- const fullUrl = `${config.baseURL}${endpointData.url}`.replace(/([^:]\/)\/+/g, "$1");
142
- console.log("URL completa:", fullUrl);
150
+ const urlWithParams = getUrl(endpointData.url, routeParams);
151
+ const fullUrl = `${config.baseURL}${urlWithParams}`.replace(/([^:]\/)\/+/g, "$1");
143
152
 
144
153
  let response;
145
154
  let request;
@@ -150,6 +159,7 @@ export const apiMapper = async (
150
159
  const { mappedParams, responseType, headers: requestHeaders, ...otherOptions } = request;
151
160
 
152
161
  response = await axiosInstance.get(fullUrl, {
162
+ ...config,
153
163
  params: mappedParams,
154
164
  responseType: responseType,
155
165
  headers: {