@jtandrelevicius/utils-js-library 1.0.3 → 1.0.4

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.
Files changed (2) hide show
  1. package/index.js +7 -14
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -20,13 +20,11 @@ class DataQueryService {
20
20
  */
21
21
  static normalizeResponse(rawValue) {
22
22
  try {
23
- // Tenta parsear se for string, senão usa o valor original
24
23
  const parsedValue = typeof rawValue === 'string' ? JSON.parse(rawValue) : rawValue;
25
24
 
26
25
  if (!parsedValue) return [];
27
26
  if (Array.isArray(parsedValue)) return parsedValue;
28
27
 
29
- // Lógica de fallback para estruturas aninhadas complexas (ex: respostas SAP/Legacy)
30
28
  let finalData = null;
31
29
 
32
30
  if (typeof parsedValue === 'object') {
@@ -55,7 +53,6 @@ class DataQueryService {
55
53
  * @returns {Promise<Array<Object>>} Promise resolvendo com os dados.
56
54
  */
57
55
  static async fetch(query, params = null) {
58
- // Tenta usar o executor configurado ou busca o global executeQuery como fallback
59
56
  const executor = this.executor || (typeof window !== 'undefined' ? window.executeQuery : null);
60
57
 
61
58
  if (typeof executor !== 'function') {
@@ -112,7 +109,7 @@ class DataQueryService {
112
109
  }
113
110
 
114
111
  /**
115
- * FormatUtils (Antigo JFSK)
112
+ * FormatUtils
116
113
  * Utilitários para formatação de moeda, números e datas (Locale pt-BR).
117
114
  */
118
115
  class FormatUtils {
@@ -190,7 +187,7 @@ class FormatUtils {
190
187
  }
191
188
 
192
189
  /**
193
- * SortUtils (Antigo JOSK)
190
+ * SortUtils
194
191
  * Utilitários para ordenação de listas.
195
192
  */
196
193
  class SortUtils {
@@ -218,7 +215,7 @@ class SortUtils {
218
215
  }
219
216
 
220
217
  /**
221
- * ExportService (Antigo JEXSK)
218
+ * ExportService
222
219
  * Exportação para Excel (.xlsx) e CSV.
223
220
  */
224
221
  class ExportService {
@@ -246,7 +243,7 @@ class ExportService {
246
243
  });
247
244
  return row;
248
245
  });
249
- // @ts-ignore
246
+
250
247
  const worksheet = XLSX.utils.json_to_sheet(formattedData);
251
248
  const workbook = XLSX.utils.book_new();
252
249
  XLSX.utils.book_append_sheet(workbook, worksheet, sheetName);
@@ -287,31 +284,27 @@ class ExportService {
287
284
  }
288
285
  }
289
286
 
290
- // ==========================================
291
- // DETECÇÃO DE AMBIENTE (Browser vs Node.js)
292
- // ==========================================
293
287
 
294
288
  const lib = {
295
289
  DataQueryService,
296
290
  FormatUtils,
297
291
  SortUtils,
298
292
  ExportService,
299
- // Aliases para retrocompatibilidade
293
+
300
294
  JSK: DataQueryService,
301
295
  JFSK: FormatUtils,
302
296
  JOSK: SortUtils,
303
297
  JEXSK: ExportService
304
298
  };
305
299
 
306
- // Se estiver em ambiente Node.js/CommonJS
300
+
307
301
  if (typeof module !== 'undefined' && module.exports) {
308
302
  module.exports = lib;
309
303
  }
310
- // Se estiver no Browser (janela global)
304
+
311
305
  else if (typeof window !== 'undefined') {
312
306
  Object.assign(window, lib);
313
307
 
314
- // Configuração automática se existir a função legado
315
308
  if (typeof window.executeQuery === 'function') {
316
309
  DataQueryService.setExecutor(window.executeQuery);
317
310
  console.log("[DataQueryService] Executor 'executeQuery' detectado e configurado automaticamente.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jtandrelevicius/utils-js-library",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {