@zauru-sdk/common 1.0.49 → 1.0.60

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/CHANGELOG.md CHANGED
@@ -3,6 +3,62 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.0.60](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.59...v1.0.60) (2024-04-17)
7
+
8
+ **Note:** Version bump only for package @zauru-sdk/common
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.0.59](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.58...v1.0.59) (2024-04-17)
15
+
16
+ **Note:** Version bump only for package @zauru-sdk/common
17
+
18
+
19
+
20
+
21
+
22
+ ## [1.0.58](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.57...v1.0.58) (2024-04-17)
23
+
24
+ **Note:** Version bump only for package @zauru-sdk/common
25
+
26
+
27
+
28
+
29
+
30
+ ## [1.0.57](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.56...v1.0.57) (2024-04-17)
31
+
32
+ **Note:** Version bump only for package @zauru-sdk/common
33
+
34
+
35
+
36
+
37
+
38
+ ## [1.0.56](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.55...v1.0.56) (2024-04-17)
39
+
40
+ **Note:** Version bump only for package @zauru-sdk/common
41
+
42
+
43
+
44
+
45
+
46
+ ## [1.0.55](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.54...v1.0.55) (2024-04-17)
47
+
48
+ **Note:** Version bump only for package @zauru-sdk/common
49
+
50
+
51
+
52
+
53
+
54
+ ## [1.0.50](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.49...v1.0.50) (2024-04-02)
55
+
56
+ **Note:** Version bump only for package @zauru-sdk/common
57
+
58
+
59
+
60
+
61
+
6
62
  ## [1.0.49](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.48...v1.0.49) (2024-04-02)
7
63
 
8
64
  **Note:** Version bump only for package @zauru-sdk/common
package/LICENCE.md CHANGED
@@ -1,11 +1,11 @@
1
- # Released under MIT License
2
-
3
- Copyright (c) 2013 Mark Otto.
4
-
5
- Copyright (c) 2017 Andrew Fong.
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
-
9
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
-
11
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ # Released under MIT License
2
+
3
+ Copyright (c) 2013 Mark Otto.
4
+
5
+ Copyright (c) 2017 Andrew Fong.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,17 +1,23 @@
1
- import moment from "moment";
2
- import "moment-timezone";
3
- import { MONTHS } from "@zauru-sdk/types";
4
- export const DESTINOS_MUESTRA_OPTIONS = [
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.handlePossibleAxiosErrors = exports.sortByProperty = exports.capitalLetter = exports.labFormPatter = exports.labServicePattern = exports.getRandomNum = exports.CURRENCY_PREFIX = exports.truncateDecimals = exports.reduceAdd = exports.ZAURU_REGEX = exports.convertToFormData = exports.arrayToObject = exports.getParsedIdFromString = exports.incrementString = exports.isNumeric = exports.toFixedIfNeeded = exports.formatTimeToTimePicker = exports.formatDateToDatePicker = exports.formatDateToUTC = exports.extractIdFromForm = exports.parsedBaculoFormValue = exports.getPayeeInfoOptions = exports.getPayeeFormated = exports.getDateAfterDays = exports.getTimePickerCurrentTime = exports.getDatePickerCurrentDate = exports.isToday = exports.todayLongString = exports.zauruDateToLongString = exports.stringDateToParsedUTCDate = exports.localDateToUSDate = exports.getStringFullDate = exports.getTodayMinutesDifference = exports.getTodayDaysDifference = exports.truncateText = exports.getStringDate = exports.getZauruDateByText = exports.getNewDateByFormat = exports.getFechaJuliana = exports.isJsonArray = exports.extractValueBetweenTags = exports.generateClientUUID = exports.getBasketsSchema = exports.DESTINOS_MUESTRA_OPTIONS = void 0;
7
+ const moment_1 = __importDefault(require("moment"));
8
+ require("moment-timezone");
9
+ const types_1 = require("@zauru-sdk/types");
10
+ exports.DESTINOS_MUESTRA_OPTIONS = [
5
11
  { label: "Microbiología", value: "microbiologa" },
6
12
  { label: "Residuos de plaguicidas", value: "residuos_de_plaguicidas" },
7
13
  ];
8
- moment.locale("es");
14
+ moment_1.default.locale("es");
9
15
  /**
10
16
  * Obtener el objeto de canastas en base al string de canastas
11
17
  * @param basketsString
12
18
  * @returns
13
19
  */
14
- export const getBasketsSchema = (basketsString) => {
20
+ const getBasketsSchema = (basketsString) => {
15
21
  //Sacar conteo de canastas y su descripción de colores
16
22
  //ejemplo: vienen en un campo así: 8-53311-VERDE,3-53315-ROSADA,4-53313-ROJA
17
23
  const splitedText = basketsString.split(",");
@@ -25,29 +31,32 @@ export const getBasketsSchema = (basketsString) => {
25
31
  });
26
32
  return baskets;
27
33
  };
28
- export function generateClientUUID() {
34
+ exports.getBasketsSchema = getBasketsSchema;
35
+ function generateClientUUID() {
29
36
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
30
37
  const r = (Math.random() * 16) | 0, v = c == "x" ? r : (r & 0x3) | 0x8;
31
38
  return v.toString(16);
32
39
  });
33
40
  }
41
+ exports.generateClientUUID = generateClientUUID;
34
42
  /**
35
43
  * extractValueBetweenTags
36
44
  * @param input
37
45
  * @param tagName
38
46
  * @returns
39
47
  */
40
- export function extractValueBetweenTags(input, tagName) {
48
+ function extractValueBetweenTags(input, tagName) {
41
49
  const regex = new RegExp(`<${tagName}[^>]*>(.*?)<\\/${tagName}>`, "i");
42
50
  const match = input.match(regex);
43
51
  return match ? match[1] : "";
44
52
  }
53
+ exports.extractValueBetweenTags = extractValueBetweenTags;
45
54
  /**
46
55
  * isJsonArray
47
56
  * @param value
48
57
  * @returns
49
58
  */
50
- export function isJsonArray(value) {
59
+ function isJsonArray(value) {
51
60
  try {
52
61
  const parsed = JSON.parse(value);
53
62
  return Array.isArray(parsed);
@@ -56,11 +65,12 @@ export function isJsonArray(value) {
56
65
  return false;
57
66
  }
58
67
  }
68
+ exports.isJsonArray = isJsonArray;
59
69
  /**
60
70
  *
61
71
  * @param date Recibe el date en formato UTC
62
72
  */
63
- export const getFechaJuliana = (date) => {
73
+ const getFechaJuliana = (date) => {
64
74
  function getDaysInMonth(month) {
65
75
  return new Date(new Date().getFullYear(), month, 0).getDate();
66
76
  }
@@ -73,45 +83,49 @@ export const getFechaJuliana = (date) => {
73
83
  }
74
84
  return numberOfDays;
75
85
  };
76
- const dt = moment(date).toDate();
86
+ const dt = (0, moment_1.default)(date).toDate();
77
87
  const month = dt.getMonth();
78
88
  const day = getNumberOfDays(month, dt.getDate());
79
89
  return `${dt.getFullYear()}-${day}`;
80
90
  };
91
+ exports.getFechaJuliana = getFechaJuliana;
81
92
  /**
82
93
  * Convierte una fecha de tipo 25 de jul de 2022 a Date
83
94
  * @param date
84
95
  * @returns
85
96
  */
86
- export const getNewDateByFormat = (date) => {
97
+ const getNewDateByFormat = (date) => {
87
98
  if (!date) {
88
99
  return new Date();
89
100
  }
90
101
  const date_parts = date.split(" ");
91
- const new_date = new Date(parseInt(date_parts[4]), MONTHS[date_parts[2]], parseInt(date_parts[0]));
102
+ const new_date = new Date(parseInt(date_parts[4]), types_1.MONTHS[date_parts[2]], parseInt(date_parts[0]));
92
103
  return new_date;
93
104
  };
105
+ exports.getNewDateByFormat = getNewDateByFormat;
94
106
  /**
95
107
  * Convierte una fecha de tipo 25 de jul de 2022 a YYYY-MM-DD
96
108
  * @param date
97
109
  * @returns
98
110
  */
99
- export const getZauruDateByText = (date) => {
100
- const newDate = getNewDateByFormat(date);
101
- return getStringDate(newDate);
111
+ const getZauruDateByText = (date) => {
112
+ const newDate = (0, exports.getNewDateByFormat)(date);
113
+ return (0, exports.getStringDate)(newDate);
102
114
  };
115
+ exports.getZauruDateByText = getZauruDateByText;
103
116
  /**
104
117
  * Convierte una fecha de tipo Date a YYYY-MM-DD
105
118
  * @param date
106
119
  * @returns
107
120
  */
108
- export const getStringDate = (date) => {
121
+ const getStringDate = (date) => {
109
122
  const year = date.getFullYear();
110
123
  const month = date.getMonth() + 1;
111
124
  const day = date.getDay();
112
125
  return `${year}-${month <= 9 ? `0${month}` : month}-${day <= 9 ? `0${day}` : day}`;
113
126
  };
114
- export function truncateText(text, maxLength) {
127
+ exports.getStringDate = getStringDate;
128
+ function truncateText(text, maxLength) {
115
129
  if (!text || !maxLength) {
116
130
  return "";
117
131
  }
@@ -125,30 +139,33 @@ export function truncateText(text, maxLength) {
125
139
  return text;
126
140
  }
127
141
  }
128
- export const getTodayDaysDifference = (date) => {
142
+ exports.truncateText = truncateText;
143
+ const getTodayDaysDifference = (date) => {
129
144
  // Crear el objeto de Moment para la fecha de creación
130
- const fechaCreacion = moment(date);
145
+ const fechaCreacion = (0, moment_1.default)(date);
131
146
  // Crear el objeto de Moment para la fecha actual
132
- const ahora = moment();
147
+ const ahora = (0, moment_1.default)();
133
148
  // Calcular la diferencia en días
134
149
  const diferencia = ahora.diff(fechaCreacion, "days");
135
150
  return diferencia;
136
151
  };
137
- export const getTodayMinutesDifference = (date) => {
152
+ exports.getTodayDaysDifference = getTodayDaysDifference;
153
+ const getTodayMinutesDifference = (date) => {
138
154
  // Crear el objeto de Moment para la fecha de creación
139
- const fechaCreacion = moment(date);
155
+ const fechaCreacion = (0, moment_1.default)(date);
140
156
  // Crear el objeto de Moment para la fecha actual
141
- const ahora = moment();
157
+ const ahora = (0, moment_1.default)();
142
158
  // Calcular la diferencia en minutos
143
159
  const diferencia = ahora.diff(fechaCreacion, "minutes");
144
160
  return diferencia;
145
161
  };
162
+ exports.getTodayMinutesDifference = getTodayMinutesDifference;
146
163
  /**
147
164
  * Convierte una fecha de tipo Date a DD-MM-YYY HH:mm:ss
148
165
  * @param date
149
166
  * @returns
150
167
  */
151
- export const getStringFullDate = (date) => {
168
+ const getStringFullDate = (date) => {
152
169
  const hour = date.getHours();
153
170
  const minutes = date.getMinutes();
154
171
  const seconds = date.getSeconds();
@@ -157,32 +174,35 @@ export const getStringFullDate = (date) => {
157
174
  const day = date.getDay();
158
175
  return `${day <= 9 ? `0${day}` : day}-${month <= 9 ? `0${month}` : month}-${year} ${hour}:${minutes}:${seconds}`;
159
176
  };
177
+ exports.getStringFullDate = getStringFullDate;
160
178
  /**
161
179
  * Convierte una fecha de tipo DD/MM/YYYY a YYYY/MM/DD
162
180
  * @param dateStr
163
181
  * @returns
164
182
  */
165
- export const localDateToUSDate = (dateStr) => {
166
- const date = moment(dateStr, "DD/MM/YYYY");
183
+ const localDateToUSDate = (dateStr) => {
184
+ const date = (0, moment_1.default)(dateStr, "DD/MM/YYYY");
167
185
  const newDateStr = date.format("YYYY/MM/DD");
168
186
  return newDateStr;
169
187
  };
170
- export const stringDateToParsedUTCDate = (date) => {
188
+ exports.localDateToUSDate = localDateToUSDate;
189
+ const stringDateToParsedUTCDate = (date) => {
171
190
  const issueDate = new Date(date);
172
191
  issueDate.setMinutes(issueDate.getMinutes() - 360);
173
192
  return issueDate;
174
193
  };
194
+ exports.stringDateToParsedUTCDate = stringDateToParsedUTCDate;
175
195
  /**
176
196
  * zauruDateToLongString
177
197
  * @param date
178
198
  * @returns
179
199
  */
180
- export function zauruDateToLongString(date, hours = false) {
200
+ function zauruDateToLongString(date, hours = false) {
181
201
  if (!date) {
182
202
  return "invalid date:zauruDateToLongString";
183
203
  }
184
204
  // Asume que la fecha de entrada está en UTC y la convierte a la zona horaria local del navegador
185
- const issueDate = moment.utc(date).local();
205
+ const issueDate = moment_1.default.utc(date).local();
186
206
  let formatString = "dddd, D [de] MMMM [de] YYYY";
187
207
  if (hours) {
188
208
  formatString += ", HH:mm a"; // Añade la hora en formato de 12 horas con AM/PM
@@ -190,14 +210,15 @@ export function zauruDateToLongString(date, hours = false) {
190
210
  // Formatea la fecha en el locale español
191
211
  return issueDate.locale("es").format(formatString);
192
212
  }
213
+ exports.zauruDateToLongString = zauruDateToLongString;
193
214
  /**
194
215
  * todayLongString
195
216
  * @param date
196
217
  * @returns
197
218
  */
198
- export function todayLongString(hours = false) {
219
+ function todayLongString(hours = false) {
199
220
  // Analiza la fecha y hora sin ajustes de zona horaria
200
- const issueDate = moment(new Date().toISOString());
221
+ const issueDate = (0, moment_1.default)(new Date().toISOString());
201
222
  let formatString = "dddd, D [de] MMMM [de] YYYY";
202
223
  if (hours) {
203
224
  formatString += ", HH:mm a"; // Añade la hora en formato de 12 horas con AM/PM
@@ -205,27 +226,31 @@ export function todayLongString(hours = false) {
205
226
  // Formatea la fecha en el locale español
206
227
  return issueDate.locale("es").format(formatString);
207
228
  }
208
- export function isToday(dateStr) {
229
+ exports.todayLongString = todayLongString;
230
+ function isToday(dateStr) {
209
231
  // Parsea la fecha dada y la fecha actual a inicio del día (00:00:00)
210
- const givenDate = moment(dateStr).startOf("day");
211
- const today = moment().startOf("day");
232
+ const givenDate = (0, moment_1.default)(dateStr).startOf("day");
233
+ const today = (0, moment_1.default)().startOf("day");
212
234
  // Compara si son iguales
213
235
  return givenDate.isSame(today);
214
236
  }
215
- export const getDatePickerCurrentDate = () => {
237
+ exports.isToday = isToday;
238
+ const getDatePickerCurrentDate = () => {
216
239
  const date = new Date();
217
240
  const year = date.getFullYear();
218
241
  const month = String(date.getMonth() + 1).padStart(2, "0"); // Los meses van de 0 a 11, por eso sumamos 1.
219
242
  const day = String(date.getDate()).padStart(2, "0");
220
243
  return `${year}-${month}-${day}`;
221
244
  };
222
- export const getTimePickerCurrentTime = () => {
245
+ exports.getDatePickerCurrentDate = getDatePickerCurrentDate;
246
+ const getTimePickerCurrentTime = () => {
223
247
  const date = new Date();
224
248
  const hours = String(date.getHours()).padStart(2, "0");
225
249
  const minutes = String(date.getMinutes()).padStart(2, "0");
226
250
  return `${hours}:${minutes}`;
227
251
  };
228
- export const getDateAfterDays = (daysAfterToday) => {
252
+ exports.getTimePickerCurrentTime = getTimePickerCurrentTime;
253
+ const getDateAfterDays = (daysAfterToday) => {
229
254
  const date = new Date();
230
255
  date.setDate(date.getDate() + daysAfterToday); // Agregamos el número de días a la fecha actual.
231
256
  const year = date.getFullYear();
@@ -233,10 +258,12 @@ export const getDateAfterDays = (daysAfterToday) => {
233
258
  const day = String(date.getDate()).padStart(2, "0");
234
259
  return `${year}-${month}-${day}`;
235
260
  };
236
- export const getPayeeFormated = (payee) => {
261
+ exports.getDateAfterDays = getDateAfterDays;
262
+ const getPayeeFormated = (payee) => {
237
263
  return `<${payee.id_number}> ${payee.tin ? `${payee.tin} | ` : ""}${payee.name}`;
238
264
  };
239
- export const getPayeeInfoOptions = (payees) => {
265
+ exports.getPayeeFormated = getPayeeFormated;
266
+ const getPayeeInfoOptions = (payees) => {
240
267
  return payees.map((x) => {
241
268
  return {
242
269
  label: `<${x.id_number}> ${x.tin ? `${x.tin} | ` : ""}${x.name}`,
@@ -245,31 +272,34 @@ export const getPayeeInfoOptions = (payees) => {
245
272
  };
246
273
  });
247
274
  };
248
- export const parsedBaculoFormValue = (value) => {
275
+ exports.getPayeeInfoOptions = getPayeeInfoOptions;
276
+ const parsedBaculoFormValue = (value) => {
249
277
  if (value === "false") {
250
278
  return "No";
251
279
  }
252
280
  else if (value === "true") {
253
281
  return "Si";
254
282
  }
255
- else if (DESTINOS_MUESTRA_OPTIONS.some((x) => x.value === value)) {
256
- return DESTINOS_MUESTRA_OPTIONS.find((x) => x.value === value)?.label;
283
+ else if (exports.DESTINOS_MUESTRA_OPTIONS.some((x) => x.value === value)) {
284
+ return exports.DESTINOS_MUESTRA_OPTIONS.find((x) => x.value === value)?.label;
257
285
  }
258
286
  return capitalLetter(value);
259
287
  };
260
- export function extractIdFromForm(s) {
288
+ exports.parsedBaculoFormValue = parsedBaculoFormValue;
289
+ function extractIdFromForm(s) {
261
290
  const match = s.match(/LAB_FORM_(\d+);/);
262
291
  if (match && match[1]) {
263
292
  return parseInt(match[1], 10);
264
293
  }
265
294
  return null;
266
295
  }
296
+ exports.extractIdFromForm = extractIdFromForm;
267
297
  /**
268
298
  * Formatea una fecha de tipo YYYY-MM-DD a 2023-08-07T20:56:00.540245
269
299
  * @param dateString
270
300
  * @returns
271
301
  */
272
- export function formatDateToUTC(dateString) {
302
+ function formatDateToUTC(dateString) {
273
303
  const date = new Date(dateString);
274
304
  const year = date.getUTCFullYear();
275
305
  const month = String(date.getUTCMonth() + 1).padStart(2, "0");
@@ -280,19 +310,22 @@ export function formatDateToUTC(dateString) {
280
310
  const milliseconds = String(date.getUTCMilliseconds()).padStart(3, "0");
281
311
  return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${milliseconds}`;
282
312
  }
283
- export const formatDateToDatePicker = (date) => {
313
+ exports.formatDateToUTC = formatDateToUTC;
314
+ const formatDateToDatePicker = (date) => {
284
315
  const year = date.getFullYear();
285
316
  const month = `0${date.getMonth() + 1}`.slice(-2); // Los meses van de 0 a 11, así que le sumamos 1
286
317
  const day = `0${date.getDate()}`.slice(-2);
287
318
  return `${year}-${month}-${day}`;
288
319
  };
289
- export const formatTimeToTimePicker = (timeString) => {
320
+ exports.formatDateToDatePicker = formatDateToDatePicker;
321
+ const formatTimeToTimePicker = (timeString) => {
290
322
  const [hours, minutes] = timeString.split(":").map(Number);
291
323
  const date = new Date();
292
324
  date.setHours(hours, minutes, 0, 0); // Establecemos las horas y minutos, y reseteamos segundos y milisegundos
293
325
  return date;
294
326
  };
295
- export const toFixedIfNeeded = (value) => {
327
+ exports.formatTimeToTimePicker = formatTimeToTimePicker;
328
+ const toFixedIfNeeded = (value) => {
296
329
  if (!value) {
297
330
  return "0";
298
331
  }
@@ -303,10 +336,12 @@ export const toFixedIfNeeded = (value) => {
303
336
  const decimal = decimals > 2 ? value.toFixed(2) : value.toString();
304
337
  return decimal.replace(".00", "");
305
338
  };
306
- export const isNumeric = (value) => {
339
+ exports.toFixedIfNeeded = toFixedIfNeeded;
340
+ const isNumeric = (value) => {
307
341
  return !isNaN(value) && !isNaN(parseFloat(value));
308
342
  };
309
- export function incrementString(str) {
343
+ exports.isNumeric = isNumeric;
344
+ function incrementString(str) {
310
345
  // Encuentra la parte numérica de la cadena usando una expresión regular
311
346
  const match = str.match(/(\D*)(\d+)$/);
312
347
  if (!match) {
@@ -322,7 +357,8 @@ export function incrementString(str) {
322
357
  .padStart(numberPart.length, "0");
323
358
  return prefix + incrementedString;
324
359
  }
325
- export function getParsedIdFromString(inputString) {
360
+ exports.incrementString = incrementString;
361
+ function getParsedIdFromString(inputString) {
326
362
  const regex = /<(\d+)>/; // Expresión regular para encontrar el número entre los corchetes
327
363
  const match = inputString.match(regex); // Buscar la coincidencia en el string
328
364
  let number = 0;
@@ -335,7 +371,8 @@ export function getParsedIdFromString(inputString) {
335
371
  }
336
372
  return number;
337
373
  }
338
- export const arrayToObject = (arr = [], options) => {
374
+ exports.getParsedIdFromString = getParsedIdFromString;
375
+ const arrayToObject = (arr = [], options) => {
339
376
  return arr.reduce((acc, cur, idx) => {
340
377
  const tempVal = cur;
341
378
  if (options?.withOutId) {
@@ -345,7 +382,8 @@ export const arrayToObject = (arr = [], options) => {
345
382
  return acc;
346
383
  }, {});
347
384
  };
348
- export function convertToFormData(obj) {
385
+ exports.arrayToObject = arrayToObject;
386
+ function convertToFormData(obj) {
349
387
  const formData = new FormData();
350
388
  function appendFormData(data, root = "") {
351
389
  if (data && typeof data === "object" && !(data instanceof File)) {
@@ -376,7 +414,8 @@ export function convertToFormData(obj) {
376
414
  appendFormData(obj);
377
415
  return formData;
378
416
  }
379
- export const ZAURU_REGEX = {
417
+ exports.convertToFormData = convertToFormData;
418
+ exports.ZAURU_REGEX = {
380
419
  porcentaje: /^\d{1,2}(\.\d{1,2})?$/,
381
420
  };
382
421
  /**
@@ -385,43 +424,47 @@ export const ZAURU_REGEX = {
385
424
  * @param a
386
425
  * @returns
387
426
  */
388
- export function reduceAdd(accumulator, a) {
427
+ function reduceAdd(accumulator, a) {
389
428
  return accumulator + a;
390
429
  }
430
+ exports.reduceAdd = reduceAdd;
391
431
  /**
392
432
  * Truncar decimales, ejemplo: truncateDecimals(43.434340934, 2) => 43.43
393
433
  * @param number
394
434
  * @param digits
395
435
  * @returns
396
436
  */
397
- export const truncateDecimals = function (number, digits) {
437
+ const truncateDecimals = function (number, digits) {
398
438
  const multiplier = Math.pow(10, digits), adjustedNum = number * multiplier, truncatedNum = Math[adjustedNum < 0 ? "ceil" : "floor"](adjustedNum);
399
439
  return truncatedNum / multiplier;
400
440
  };
441
+ exports.truncateDecimals = truncateDecimals;
401
442
  /**
402
443
  * PREFIX - QUEMADOS POR INDICACIONES DE SARTIP
403
444
  */
404
445
  //TODO: Falta agregar los demás currencies
405
- export const CURRENCY_PREFIX = [
446
+ exports.CURRENCY_PREFIX = [
406
447
  { id: 1, code: "GTQ", prefix: "Q" },
407
448
  { id: 2, code: "USD", prefix: "$" },
408
449
  { id: 3, code: "LHN", prefix: "L" },
409
450
  { id: 12, code: "MXN", prefix: "$" },
410
451
  ];
411
- export const getRandomNum = () => {
452
+ const getRandomNum = () => {
412
453
  const randomNum = Math.random() * 10 + 1;
413
454
  return parseFloat(randomNum.toFixed(2));
414
455
  };
456
+ exports.getRandomNum = getRandomNum;
415
457
  //COMMONS DE LABORATORIO
416
- export const labServicePattern = /LAB_SERVICE_\d+;/g;
417
- export const labFormPatter = /LAB_FORM_\d+;/;
418
- export function capitalLetter(str = "") {
458
+ exports.labServicePattern = /LAB_SERVICE_\d+;/g;
459
+ exports.labFormPatter = /LAB_FORM_\d+;/;
460
+ function capitalLetter(str = "") {
419
461
  if (str.length > 0) {
420
462
  return str.charAt(0).toUpperCase() + str.slice(1);
421
463
  }
422
464
  return str;
423
465
  }
424
- export const sortByProperty = (array, property) => {
466
+ exports.capitalLetter = capitalLetter;
467
+ const sortByProperty = (array, property) => {
425
468
  // Crear una copia del array
426
469
  const arrayCopy = [...array];
427
470
  return arrayCopy.sort((a, b) => {
@@ -434,12 +477,13 @@ export const sortByProperty = (array, property) => {
434
477
  return 0;
435
478
  });
436
479
  };
480
+ exports.sortByProperty = sortByProperty;
437
481
  /**
438
482
  * Handle web app table actions and return a response with a consistent format.
439
483
  * @param action A function that returns a Promise of type T.
440
484
  * @returns A Promise of AxiosUtilsResponse<T>.
441
485
  */
442
- export async function handlePossibleAxiosErrors(action) {
486
+ async function handlePossibleAxiosErrors(action) {
443
487
  try {
444
488
  const result = await action();
445
489
  return { error: false, data: result };
@@ -448,3 +492,4 @@ export async function handlePossibleAxiosErrors(action) {
448
492
  return { error: true, userMsg: error?.toString() };
449
493
  }
450
494
  }
495
+ exports.handlePossibleAxiosErrors = handlePossibleAxiosErrors;
@@ -1,4 +1,7 @@
1
- export const guatemalaCountryInfo = [
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMunSelectOptions = exports.getDepSelectOptions = exports.guatemalaCountryInfo = void 0;
4
+ exports.guatemalaCountryInfo = [
2
5
  { value: 0, label: "GUATEMALA,GUATEMALA" },
3
6
  {
4
7
  value: 1,
@@ -808,8 +811,8 @@ export const guatemalaCountryInfo = [
808
811
  { value: 356, label: "JUTIAPA,QUESADA" },
809
812
  { value: 357, label: "JUTIAPA,CERRO GORDO" },
810
813
  ];
811
- export const getDepSelectOptions = () => {
812
- const optionsDep = guatemalaCountryInfo?.map((x) => {
814
+ const getDepSelectOptions = () => {
815
+ const optionsDep = exports.guatemalaCountryInfo?.map((x) => {
813
816
  const value = x.label.split(",")[0];
814
817
  return { label: value, value };
815
818
  }) ?? [];
@@ -822,9 +825,11 @@ export const getDepSelectOptions = () => {
822
825
  const uniqueArray = Array.from(uniqueValues.values());
823
826
  return uniqueArray;
824
827
  };
825
- export const getMunSelectOptions = () => {
826
- return (guatemalaCountryInfo?.map((x) => {
828
+ exports.getDepSelectOptions = getDepSelectOptions;
829
+ const getMunSelectOptions = () => {
830
+ return (exports.guatemalaCountryInfo?.map((x) => {
827
831
  const value = x.label.split(",")[1];
828
832
  return { label: value, value };
829
833
  }) ?? []);
830
834
  };
835
+ exports.getMunSelectOptions = getMunSelectOptions;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./common.js"), exports);
18
+ __exportStar(require("./gtZones.js"), exports);
package/dist/common.d.ts CHANGED
@@ -99,7 +99,7 @@ export declare const arrayToObject: (arr?: Array<any>, options?: {
99
99
  }) => {
100
100
  [key: string]: any;
101
101
  };
102
- export declare function convertToFormData(obj: any): import("undici-types").FormData;
102
+ export declare function convertToFormData(obj: any): FormData;
103
103
  export declare const ZAURU_REGEX: {
104
104
  porcentaje: RegExp;
105
105
  };