etiquetas.js 1.0.0-alpha.1 → 1.0.0-alpha.3

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 (40) hide show
  1. package/README.git.md +121 -486
  2. package/README.md +142 -5
  3. package/README.npm.md +0 -0
  4. package/dist/etiquetas.es.js +66 -0
  5. package/dist/etiquetas.es.js.map +1 -0
  6. package/dist/etiquetas.umd.js +358 -0
  7. package/dist/etiquetas.umd.js.map +1 -0
  8. package/dist/index-BkmabrFq.js +59122 -0
  9. package/dist/index-BkmabrFq.js.map +1 -0
  10. package/dist/index.es-B4lKWyrH.js +9229 -0
  11. package/dist/index.es-B4lKWyrH.js.map +1 -0
  12. package/dist/purify.es-DzZgBtzL.js +965 -0
  13. package/dist/purify.es-DzZgBtzL.js.map +1 -0
  14. package/package.json +48 -15
  15. package/api/api-labels.json +0 -114
  16. package/api/api.js +0 -316
  17. package/api/mock/data-volume-id_680.json +0 -64
  18. package/api/mock/labels-input.json +0 -96
  19. package/api/mock/labels-part.json +0 -216
  20. package/api/mock/labels-scrap.json +0 -76
  21. package/api/mock/labels-thickened.json +0 -96
  22. package/api/mock/labels-volume.json +0 -56
  23. package/api/token.txt +0 -1
  24. package/services/index.js +0 -28
  25. package/src/constants.js +0 -247
  26. package/src/createLabel.js +0 -342
  27. package/src/etiquetas.js +0 -654
  28. package/src/formatData.js +0 -96
  29. package/src/formatDataIntegrated.js +0 -498
  30. package/src/index.js +0 -86
  31. package/src/label/services/index.js +0 -1201
  32. package/src/label/services/sortFunctions.js +0 -158
  33. package/src/label/services/utils.js +0 -280
  34. package/src/labelWorker.js +0 -123
  35. package/src/reducer.js +0 -40
  36. package/src/store.js +0 -55
  37. package/src/templates.js +0 -139
  38. package/src/useLabelData.js +0 -99
  39. package/src/usePrinterStore.js +0 -115
  40. package/src/variableManager.js +0 -224
package/README.md CHANGED
@@ -9,6 +9,7 @@ Sistema completo para geração de etiquetas de peças, tamponamentos, insumos,
9
9
  - Download em formato PDF
10
10
  - Templates personalizáveis
11
11
  - Integração com API para busca de modelos de etiquetas
12
+ - **🔄 Legacy Transformer** - Sistema de transformação de dados legados
12
13
 
13
14
  ## 🚀 Instalação
14
15
 
@@ -19,20 +20,156 @@ npm install etiquetas.js
19
20
  ## ⚙️ Uso Básico
20
21
 
21
22
  ```javascript
22
- import { etiquetas } from 'etiquetas.js';
23
+ import etiquetas from './src/etiquetas.js';
23
24
 
24
- // Inicializar o sistema
25
+ // Inicializar o sistema com seu token JWT para autenticação na API
25
26
  etiquetas.init({
26
27
  token:'<jwt-token>'
27
28
  });
28
29
 
29
30
  // Gerar etiqueta de peça
30
- const pdfPeca = await etiquetas.makePartLabel(dadosPeca, '<id-etiqueta>');
31
+ const pdfBuffer = await etiquetas.makeLabel(labelData, '<id-etiqueta>',options);
32
+ //Gerar e enviar para impressora, caso a impressora não esteja disponível o arquivo é baixado automaticamente
33
+ await etiquetas.sendLabel(labelData, '<id-etiqueta>',{
34
+ fileName:<nome-do-arquivo>
35
+ });
31
36
 
32
37
  // Download ou impressão
33
- await etiquetas.downloadPDF(pdfPeca, '<nome-etiqueta>.pdf');
38
+ await etiquetas.downloadPDF(pdfBuffer, '<nome-etiqueta>.pdf');
34
39
  // ou
35
- await etiquetas.sendToPrinter(pdfPeca);
40
+ await etiquetas.sendToPrinter(pdfBuffer);
41
+ ```
42
+
43
+ ## 🔄 Legacy Transformer
44
+
45
+ O sistema de transformação de dados legados permite converter dados antigos para o formato atual das etiquetas. **O transformer padrão é configurado na função `init()`** e será aplicado automaticamente em todas as operações.
46
+
47
+ ### Configuração no Init
48
+
49
+ ```javascript
50
+ import etiquetas from './src/etiquetas.js';
51
+
52
+ // Inicializar com legacy transformer (padrão)
53
+ etiquetas.init({
54
+ token: 'your-token',
55
+ // defaultTransformer não especificado = legacy por padrão
56
+ });
57
+
58
+ // Inicializar com transformer customizado como padrão
59
+ etiquetas.init({
60
+ token: 'your-token',
61
+ defaultTransformer: {
62
+ fieldMap: 'custom',
63
+ fieldMapSource: {
64
+ old_field: 'new_field',
65
+ status: ['active', 'inactive', 'pending']
66
+ }
67
+ }
68
+ });
69
+
70
+ // Inicializar sem transformer (desabilitado)
71
+ etiquetas.init({
72
+ token: 'your-token',
73
+ defaultTransformer: {
74
+ fieldMap: 'none'
75
+ }
76
+ });
77
+ ```
78
+
79
+ ### Uso Básico (Usa Padrão do Init)
80
+
81
+ ```javascript
82
+ // O transformer configurado no init será aplicado automaticamente
83
+ const pdf = await etiquetas.makeLabel({
84
+ VARIAVEL1: 123,
85
+ VARIAVEL2: '12345',
86
+
87
+ }, 'template-id');
88
+
89
+ // Também funciona com sendLabel
90
+ const result = await etiquetas.sendLabel(legacyData, 'template-id');
36
91
  ```
37
92
 
93
+ ### Sobrescrever Transformer Padrão
94
+
95
+ ```javascript
96
+ // Sobrescrever para usar legacy transformer
97
+ const pdf = await etiquetas.makeLabel(legacyData, 'template-id', {
98
+ transformer: {
99
+ fieldMap: "legacy"
100
+ }
101
+ });
102
+
103
+ // Sobrescrever para usar fieldMap customizado
104
+ const customFieldMap = {
105
+ // Mapeamento simples
106
+ OLD_FIELD: 'newField',
107
+
108
+ // Mapeamento com array de valores
109
+ STATUS: ['active', 'inactive', 'pending'],
110
+
111
+ // Transformação com função
112
+ CUSTOM_CODE: (data) => data.code ? `NEW_${data.code}` : null
113
+ };
114
+
115
+ const pdf = await etiquetas.makeLabel(legacyData, 'template-id', {
116
+ transformer: {
117
+ fieldMap: "custom",
118
+ fieldMapSource: customFieldMap
119
+ }
120
+ });
121
+
122
+ // Sobrescrever para desabilitar transformer
123
+ const pdf = await etiquetas.makeLabel(normalizedData, 'template-id', {
124
+ transformer: {
125
+ fieldMap: "none"
126
+ }
127
+ });
128
+ ```
129
+
130
+ ### Opções do Init
131
+
132
+ | Opção | Tipo | Descrição |
133
+ |-------|------|-----------|
134
+ | `defaultTransformer.fieldMap` | string | Tipo do fieldMap padrão: `"legacy"` (padrão), `"custom"` ou `"none"` |
135
+ | `defaultTransformer.fieldMapSource` | Object | FieldMap customizado (obrigatório se `fieldMap="custom"`) |
136
+
137
+ ### Opções das Funções (Sobrescrever Padrão)
138
+
139
+ | Opção | Tipo | Descrição |
140
+ |-------|------|-----------|
141
+ | `transformer.fieldMap` | string | Tipo do fieldMap: `"legacy"`, `"custom"` ou `"none"` (sobrescreve padrão do init) |
142
+ | `transformer.fieldMapSource` | Object | FieldMap customizado (obrigatório se `fieldMap="custom"`) |
143
+
144
+ ### API Legacy (Deprecated)
145
+
146
+ ```javascript
147
+ // ⚠️ API antiga - ainda funciona mas está deprecated
148
+ const pdf = await etiquetas.makeLabel(legacyData, 'template-id', {
149
+ useLegacyTransformer: true,
150
+ customFieldMap: myFieldMap
151
+ });
152
+ ```
153
+
154
+ ### Validação e Tratamento de Erros
155
+
156
+ ```javascript
157
+ // Validar fieldMap antes de usar
158
+ const isValid = etiquetas.validateFieldMap(myFieldMap);
159
+
160
+ // Tratamento de erros
161
+ try {
162
+ const pdf = await etiquetas.makeLabel(legacyData, 'template-id', {
163
+ transformer: {
164
+ fieldMap: "custom",
165
+ fieldMapSource: invalidFieldMap
166
+ }
167
+ });
168
+ } catch (error) {
169
+ console.error('Erro na transformação:', error.message);
170
+ }
171
+ ```
172
+
173
+ Para documentação completa sobre transformações, consulte: [src/transformers/README.md](src/transformers/README.md)
174
+
38
175
 
package/README.npm.md ADDED
File without changes
@@ -0,0 +1,66 @@
1
+ import { a1, a, j, L, b, N, M, Q, P, a7, F, H, K, U, V, k, T, a9, E, I, y, S, W, B, l, a8, a0, Y, a4, a5, o, h, aa, $, d, n, p, v, e, f, i, t, r, a3, C, D, q, G, w, Z, a6, O, s, R, x, z, J, X, a2, u, m, A } from "./index-BkmabrFq.js";
2
+ export {
3
+ a1 as DEFAULT_LAMINATION_COLORS,
4
+ a as LABEL_TYPES,
5
+ j as LabelWorker,
6
+ L as LabelsAPI,
7
+ b as apiClient,
8
+ N as base64Decode,
9
+ M as base64Encode,
10
+ Q as checkPrinterAvailability,
11
+ P as convertPdfToImages,
12
+ a7 as convertSVGTableToAutoTableData,
13
+ F as createBrowserCanvas,
14
+ H as createBrowserDOM,
15
+ K as createBuffer,
16
+ U as createImage,
17
+ V as createImageFromPart,
18
+ k as createLabelWorker,
19
+ T as createMiniSheet,
20
+ a9 as dataTypeList,
21
+ E as default,
22
+ I as downloadFile,
23
+ y as downloadPDF,
24
+ S as downloadPdfFallback,
25
+ W as drawRect,
26
+ B as etiquetas,
27
+ l as generateLabelsFromHookData,
28
+ a8 as generateTableSVG,
29
+ a0 as getAspectRatio,
30
+ Y as getBorderColor,
31
+ a4 as getImagesFromUrl,
32
+ a5 as getImagesFromUrlToBase64,
33
+ o as getInputForLabels,
34
+ h as getInputLabels,
35
+ aa as getInputsByCategory,
36
+ $ as getNode,
37
+ d as getPartLabels,
38
+ n as getPartsForLabels,
39
+ p as getPartsFromProjectToLabels,
40
+ v as getPrinterStatus,
41
+ e as getScrapLabels,
42
+ f as getThickenedLabels,
43
+ i as getVolumeLabels,
44
+ t as init,
45
+ r as initialState,
46
+ a3 as initializeBrowserEnvironment,
47
+ C as isBrowser,
48
+ D as isNodeJS,
49
+ q as labelTypeNames,
50
+ G as loadImageBrowser,
51
+ w as makeLabel,
52
+ Z as makeLamination,
53
+ a6 as mmToPx,
54
+ O as processLabelForParts,
55
+ s as reducer,
56
+ R as sendImagesToPrinter,
57
+ x as sendLabel,
58
+ z as sendToPrinter,
59
+ J as serializeXML,
60
+ X as setBorder,
61
+ a2 as stopCreatingLabels,
62
+ u as useLabelData,
63
+ m as useLabelStore,
64
+ A as validateLabelData
65
+ };
66
+ //# sourceMappingURL=etiquetas.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"etiquetas.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}