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

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.md +122 -38
  2. package/README.npm.md +0 -0
  3. package/dist/etiquetas.es.js +65 -0
  4. package/dist/etiquetas.es.js.map +1 -0
  5. package/dist/etiquetas.umd.js +358 -0
  6. package/dist/etiquetas.umd.js.map +1 -0
  7. package/dist/index-Bl0CvwuC.js +59982 -0
  8. package/dist/index-Bl0CvwuC.js.map +1 -0
  9. package/dist/index.es-eEPQXFRd.js +9229 -0
  10. package/dist/index.es-eEPQXFRd.js.map +1 -0
  11. package/dist/purify.es-DzZgBtzL.js +965 -0
  12. package/dist/purify.es-DzZgBtzL.js.map +1 -0
  13. package/package.json +38 -14
  14. package/README.git.md +0 -486
  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/api/api.js DELETED
@@ -1,316 +0,0 @@
1
- import axios from 'axios';
2
- import fs from 'fs';
3
- import path from 'path';
4
- import { fileURLToPath } from 'url';
5
-
6
- /**
7
- * Configuração base da API
8
- */
9
- const API_BASE_URL = 'https://db33.dev.dinabox.net/api';
10
-
11
- // Obter __dirname equivalente em ES modules
12
- const __filename = fileURLToPath(import.meta.url);
13
- const __dirname = path.dirname(__filename);
14
-
15
- /**
16
- * Instância do axios configurada para a API de etiquetas
17
- */
18
- // Read authorization token from token.txt
19
- let authToken = '';
20
- try {
21
- authToken = fs.readFileSync(path.join(__dirname, 'token.txt'), 'utf8').trim();
22
- } catch (error) {
23
- console.warn('Warning: Could not read token.txt file:', error.message);
24
- }
25
-
26
- const apiClient = axios.create({
27
- baseURL: API_BASE_URL,
28
- timeout: 10000,
29
- headers: {
30
- 'Content-Type': 'application/json',
31
- 'Accept': 'application/json',
32
- 'Authorization': authToken ? `Bearer ${authToken}` : ''
33
- }
34
- });
35
-
36
- /**
37
- * Tipos de etiquetas disponíveis
38
- */
39
- export const LABEL_TYPES = {
40
- PART: 'part',
41
- SCRAP: 'scrap',
42
- THICKENED: 'thickened',
43
- INPUT: 'input',
44
- VOLUME: 'volume'
45
- };
46
-
47
- /**
48
- * Interceptor para tratamento de erros
49
- */
50
- apiClient.interceptors.response.use(
51
- (response) => response,
52
- (error) => {
53
- console.error('Erro na API:', error.response?.data || error.message);
54
- return Promise.reject(error);
55
- }
56
- );
57
-
58
- /**
59
- * API de Etiquetas - Funções baseadas no schema /api/api-labels.json
60
- */
61
- export class LabelsAPI {
62
-
63
- /**
64
- * Lista etiquetas com filtros opcionais
65
- * GET /v1/labels
66
- *
67
- * @param {Object} params - Parâmetros de consulta
68
- * @param {number} [params.p] - Página
69
- * @param {string} [params.s] - Busca
70
- * @param {number} [params.label_id] - ID da etiqueta
71
- * @param {string} [params.label_type] - Tipo da etiqueta (part, scrap, thickened, input, volume)
72
- * @returns {Promise} Resposta da API
73
- */
74
- static async getLabels(params = {}) {
75
- try {
76
- const response = await apiClient.get('/v1/labels', { params });
77
- return response.data;
78
- } catch (error) {
79
- throw new Error(`Erro ao buscar etiquetas: ${error.message}`);
80
- }
81
- }
82
-
83
- /**
84
- * Busca etiquetas por página
85
- *
86
- * @param {number} page - Número da página
87
- * @param {Object} filters - Filtros adicionais
88
- * @returns {Promise} Resposta da API
89
- */
90
- static async getLabelsByPage(page = 1, filters = {}) {
91
- return this.getLabels({ p: page, ...filters });
92
- }
93
-
94
- /**
95
- * Busca etiquetas por termo de pesquisa
96
- *
97
- * @param {string} searchTerm - Termo de busca
98
- * @param {Object} filters - Filtros adicionais
99
- * @returns {Promise} Resposta da API
100
- */
101
- static async searchLabels(searchTerm, filters = {}) {
102
- return this.getLabels({ s: searchTerm, ...filters });
103
- }
104
-
105
- /**
106
- * Busca etiquetas por tipo
107
- *
108
- * @param {string} labelType - Tipo da etiqueta
109
- * @param {Object} filters - Filtros adicionais
110
- * @returns {Promise} Resposta da API
111
- */
112
- static async getLabelsByType(labelType, filters = {}) {
113
- this.validateLabelType(labelType, true);
114
- return this.getLabels({ label_type: labelType, ...filters });
115
- }
116
-
117
- /**
118
- * Obtém uma etiqueta específica
119
- * GET /v1/label
120
- *
121
- * @param {number} labelId - ID da etiqueta
122
- * @returns {Promise} Resposta da API
123
- */
124
- static async getLabel(labelId) {
125
- try {
126
- const response = await apiClient.get('/v1/label', {
127
- params: { label_id: labelId }
128
- });
129
-
130
- if (!response.data || !response.data.labels || !response.data.labels.length) {
131
- return null;
132
- }
133
-
134
-
135
-
136
- // Retorna uma etiqueta aleatória
137
- //console.log('Dados da etiqueta:', response.data.labels)
138
- return response.data.labels.filter(label => label.label_id == labelId)[0] || null;
139
- } catch (error) {
140
- throw new Error(`Erro ao buscar etiqueta ${labelId}: ${error.message}`);
141
- }
142
- }
143
-
144
- /**
145
- * Cria uma nova etiqueta
146
- * POST /v1/label
147
- *
148
- * @param {Object} labelData - Dados da etiqueta
149
- * @param {string} [labelData.label_type] - Tipo da etiqueta
150
- * @param {string} [labelData.label_name] - Nome da etiqueta
151
- * @param {string} [labelData.label_content] - Conteúdo da etiqueta
152
- * @returns {Promise} Resposta da API
153
- */
154
- static async createLabel(labelData) {
155
- try {
156
- // Validação do tipo de etiqueta
157
- if (labelData.label_type) {
158
- this.validateLabelType(labelData.label_type, true);
159
- }
160
-
161
- const response = await apiClient.post('/v1/label', labelData);
162
- return response.data;
163
- } catch (error) {
164
- throw new Error(`Erro ao criar etiqueta: ${error.message}`);
165
- }
166
- }
167
-
168
- /**
169
- * Valida se o tipo de etiqueta é um dos tipos permitidos
170
- *
171
- * @param {string} labelType - Tipo de etiqueta a ser validado
172
- * @returns {boolean} True se for válido, false caso contrário
173
- * @throws {Error} Se o tipo for inválido e throwError for true
174
- */
175
- static validateLabelType(labelType, throwError = false) {
176
- const isValid = Object.values(LABEL_TYPES).includes(labelType);
177
- if (!isValid && throwError) {
178
- throw new Error(`Tipo de etiqueta inválido: "${labelType}" não é um de part, scrap, thickened, input e volume.`);
179
- }
180
- return isValid;
181
- }
182
-
183
- /**
184
- * Retorna um tipo de etiqueta se for válido
185
- *
186
- * @param {string} labelType - Tipo de etiqueta a verificar
187
- * @returns {string} O tipo de etiqueta validado
188
- * @throws {Error} Se o tipo for inválido
189
- */
190
- static labelByType(labelType) {
191
- this.validateLabelType(labelType, true);
192
- return labelType;
193
- }
194
-
195
- /**
196
- * Atualiza uma etiqueta existente
197
- * POST /v1/label (com label_id)
198
- *
199
- * @param {number} labelId - ID da etiqueta
200
- * @param {Object} labelData - Dados atualizados da etiqueta
201
- * @returns {Promise} Resposta da API
202
- */
203
- static async updateLabel(labelId, labelData) {
204
- try {
205
- // Validação do tipo de etiqueta
206
- if (labelData.label_type) {
207
- this.validateLabelType(labelData.label_type, true);
208
- }
209
-
210
- const response = await apiClient.post('/v1/label', {
211
- label_id: labelId,
212
- ...labelData
213
- });
214
- return response.data;
215
- } catch (error) {
216
- throw new Error(`Erro ao atualizar etiqueta ${labelId}: ${error.message}`);
217
- }
218
- }
219
-
220
- /**
221
- * Remove uma etiqueta
222
- * DELETE /v1/label
223
- *
224
- * @param {number} labelId - ID da etiqueta
225
- * @returns {Promise} Resposta da API
226
- */
227
- static async deleteLabel(labelId) {
228
- try {
229
- const response = await apiClient.delete('/v1/label', {
230
- params: { label_id: labelId }
231
- });
232
- return response.data;
233
- } catch (error) {
234
- throw new Error(`Erro ao deletar etiqueta ${labelId}: ${error.message}`);
235
- }
236
- }
237
-
238
- /**
239
- * Configura o token de autenticação
240
- *
241
- * @param {string} token - Token de autenticação
242
- */
243
- static setAuthToken(token) {
244
- apiClient.defaults.headers.common['Authorization'] = `Bearer ${token}`;
245
- }
246
-
247
- /**
248
- * Remove o token de autenticação
249
- */
250
- static removeAuthToken() {
251
- delete apiClient.defaults.headers.common['Authorization'];
252
- }
253
-
254
- /**
255
- * Configura a URL base da API
256
- *
257
- * @param {string} baseURL - Nova URL base
258
- */
259
- static setBaseURL(baseURL) {
260
- apiClient.defaults.baseURL = baseURL;
261
- }
262
- }
263
-
264
- /**
265
- * Funções de conveniência para uso direto
266
- */
267
-
268
- /**
269
- * Busca todas as etiquetas de peças
270
- */
271
- export const getPartLabels = (filters = {}) =>
272
- LabelsAPI.getLabelsByType(LABEL_TYPES.PART, filters);
273
-
274
- /**
275
- * Busca todas as etiquetas de retalhos
276
- */
277
- export const getScrapLabels = (filters = {}) =>
278
- LabelsAPI.getLabelsByType(LABEL_TYPES.SCRAP, filters);
279
-
280
- /**
281
- * Busca todas as etiquetas de tamponamento
282
- */
283
- export const getThickenedLabels = (filters = {}) =>
284
- LabelsAPI.getLabelsByType(LABEL_TYPES.THICKENED, filters);
285
-
286
- /**
287
- * Busca todas as etiquetas de insumos
288
- */
289
- export const getInputLabels = (filters = {}) =>
290
- LabelsAPI.getLabelsByType(LABEL_TYPES.INPUT, filters);
291
-
292
- /**
293
- * Busca todas as etiquetas de volumes
294
- */
295
- export const getVolumeLabels = (filters = {}) =>
296
- LabelsAPI.getLabelsByType(LABEL_TYPES.VOLUME, filters);
297
-
298
- /**
299
- * Valida e retorna um tipo de etiqueta
300
- *
301
- * @param {string} labelType - Tipo de etiqueta a verificar
302
- * @returns {string} O tipo de etiqueta validado
303
- * @throws {Error} Se o tipo for inválido
304
- */
305
- export const validateLabelType = (labelType) =>
306
- LabelsAPI.labelByType(labelType);
307
-
308
- /**
309
- * Exporta a instância do cliente axios configurado
310
- */
311
- export { apiClient };
312
-
313
- /**
314
- * Exporta a classe principal
315
- */
316
- export default LabelsAPI;
@@ -1,64 +0,0 @@
1
- {
2
- "volume":{
3
- "id":"680",
4
- "description":"Volume#1",
5
- "project_id":"33",
6
- "author_id":"5745",
7
- "label":null,
8
- "created_at":"2025-07-25 09:23:43",
9
- "updated_at":null,
10
- "customer":"abc",
11
- "project_name":"03-09-2024"
12
- },
13
- "parts":[
14
- {
15
- "id":"3240",
16
- "uuid":"520100157006735",
17
- "project_id":"33",
18
- "module_id":"250",
19
- "bundle_id":"680",
20
- "p_id":"006735",
21
- "name":"Base",
22
- "ref":"P006735",
23
- "thickness":"15",
24
- "has_damage":"0",
25
- "has_edge_banding":"1",
26
- "doubled_status":"0",
27
- "has_machining":"1",
28
- "cut_status":null,
29
- "edge_banding_status":"0",
30
- "machining_status":"0",
31
- "hole_side_a":"[{\"d\": 0.6, \"t\": \"R1\", \"y\": 34.4, \"z\": 0.8, \"r1\": \"{{B15}}\", \"r2\": \"\", \"x1\": 0, \"x2\": 86.9}, {\"d\": 1.5, \"t\": \"F1\", \"x\": 6, \"y\": 84.5, \"z\": 1.2, \"r1\": \"{{B01}}\", \"r2\": \"\"}, {\"d\": 1.5, \"t\": \"F1\", \"x\": 29, \"y\": 84.5, \"z\": 1.2, \"r1\": \"{{B01}}\", \"r2\": \"\"}, {\"d\": 1.5, \"t\": \"F1\", \"x\": 29, \"y\": 2.4, \"z\": 1.2, \"r1\": \"{{B01}}\", \"r2\": \"\"}, {\"d\": 1.5, \"t\": \"F1\", \"x\": 6, \"y\": 2.4, \"z\": 1.2, \"r1\": \"{{B01}}\", \"r2\": \"\"}]",
32
- "hole_side_b":"0",
33
- "hole_side_c":"[{\"d\": 0.8, \"t\": \"F3\", \"x\": 6, \"y\": 0.75, \"z\": 2.5, \"r1\": \"{{B10}}\", \"r2\": \"{{B16}}\"}, {\"d\": 0.8, \"t\": \"F3\", \"x\": 3, \"y\": 0.75, \"z\": 2.5, \"r1\": \"{{B06}}\", \"r2\": \"{{B17}}\"}, {\"d\": 0.8, \"t\": \"F3\", \"x\": 32, \"y\": 0.75, \"z\": 2.5, \"r1\": \"{{B10}}\", \"r2\": \"{{B17}}\"}, {\"d\": 0.8, \"t\": \"F3\", \"x\": 29, \"y\": 0.75, \"z\": 2.5, \"r1\": \"{{B10}}\", \"r2\": \"{{B16}}\"}]",
34
- "hole_side_d":"[{\"d\": 0.8, \"t\": \"F4\", \"x\": 29, \"y\": 0.75, \"z\": 2.5, \"r1\": \"{{B11}}\", \"r2\": \"{{B16}}\"}, {\"d\": 0.8, \"t\": \"F4\", \"x\": 32, \"y\": 0.75, \"z\": 2.5, \"r1\": \"{{B07}}\", \"r2\": \"{{B17}}\"}, {\"d\": 0.8, \"t\": \"F4\", \"x\": 3, \"y\": 0.75, \"z\": 2.5, \"r1\": \"{{B07}}\", \"r2\": \"{{B17}}\"}, {\"d\": 0.8, \"t\": \"F4\", \"x\": 6, \"y\": 0.75, \"z\": 2.5, \"r1\": \"{{B11}}\", \"r2\": \"{{B16}}\"}]",
35
- "hole_side_e":"0",
36
- "hole_invert":"0",
37
- "hole_side_f":"0",
38
- "edge_thickness":null,
39
- "edge_top":"0",
40
- "edge_left":"{\"id\": \"1509996200\", \"abs\": \"0.45\", \"name\": \"Branco Liso\", \"perimeter\": 0.8690000000000001}",
41
- "edge_right":"0",
42
- "edge_bottom":"0",
43
- "material_name":"Branco Liso",
44
- "material_id":"1509996200",
45
- "note":"COM RASGO EM 869 mm",
46
- "type":"cabinet",
47
- "count":"1",
48
- "width":"380",
49
- "height":"869",
50
- "increase_width":"0",
51
- "weight":"18.696",
52
- "created_at":"2024-09-03 08:59:16",
53
- "updated_at":null,
54
- "cuted_at":null,
55
- "edge_at":null,
56
- "machining_at":null,
57
- "bundle_at":"2025-07-25 09:23:39",
58
- "quantity":1
59
- }
60
- ],
61
- "inputs":[
62
-
63
- ]
64
- }